3d9d68a654b4fb5b8f3c4c2745ca42dd3d3ea2e2
[openwrt.git] / scripts / metadata.pl
1 #!/usr/bin/env perl
2 use FindBin;
3 use lib "$FindBin::Bin";
4 use strict;
5 use metadata;
6
7 my %board;
8
9 sub confstr($) {
10 my $conf = shift;
11 $conf =~ tr#/\.\-/#___#;
12 return $conf;
13 }
14
15 sub parse_target_metadata() {
16 my $file = shift @ARGV;
17 my ($target, @target, $profile);
18 my %target;
19
20 open FILE, "<$file" or do {
21 warn "Can't open file '$file': $!\n";
22 return;
23 };
24 while (<FILE>) {
25 chomp;
26 /^Target:\s*(.+)\s*$/ and do {
27 my $name = $1;
28 $target = {
29 id => $name,
30 board => $name,
31 boardconf => confstr($name),
32 conf => confstr($name),
33 profiles => [],
34 features => [],
35 depends => [],
36 subtargets => []
37 };
38 push @target, $target;
39 $target{$name} = $target;
40 if ($name =~ /([^\/]+)\/([^\/]+)/) {
41 push @{$target{$1}->{subtargets}}, $2;
42 $target->{board} = $1;
43 $target->{boardconf} = confstr($1);
44 $target->{subtarget} = 1;
45 $target->{parent} = $target{$1};
46 }
47 };
48 /^Target-Kernel:\s*(\d+\.\d+)\s*$/ and $target->{kernel} = $1;
49 /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
50 /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
51 /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
52 /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ];
53 /^Target-Depends:\s*(.+)\s*$/ and $target->{depends} = [ split(/\s+/, $1) ];
54 /^Target-Description:/ and $target->{desc} = get_multiline(*FILE);
55 /^Target-Optimization:\s*(.+)\s*$/ and $target->{cflags} = $1;
56 /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
57 /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
58 /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
59 /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ];
60 /^Target-Profile:\s*(.+)\s*$/ and do {
61 $profile = {
62 id => $1,
63 name => $1,
64 packages => []
65 };
66 push @{$target->{profiles}}, $profile;
67 };
68 /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
69 /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
70 /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
71 /^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t");
72 /^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1;
73 }
74 close FILE;
75 foreach my $target (@target) {
76 next if @{$target->{subtargets}} > 0;
77 @{$target->{profiles}} > 0 or $target->{profiles} = [
78 {
79 id => 'Default',
80 name => 'Default',
81 packages => []
82 }
83 ];
84 }
85 return @target;
86 }
87
88 sub gen_kconfig_overrides() {
89 my %config;
90 my %kconfig;
91 my $package;
92 my $pkginfo = shift @ARGV;
93 my $cfgfile = shift @ARGV;
94
95 # parameter 2: build system config
96 open FILE, "<$cfgfile" or return;
97 while (<FILE>) {
98 /^(CONFIG_.+?)=(.+)$/ and $config{$1} = 1;
99 }
100 close FILE;
101
102 # parameter 1: package metadata
103 open FILE, "<$pkginfo" or return;
104 while (<FILE>) {
105 /^Package:\s*(.+?)\s*$/ and $package = $1;
106 /^Kernel-Config:\s*(.+?)\s*$/ and do {
107 my @config = split /\s+/, $1;
108 foreach my $config (@config) {
109 my $val = 'm';
110 my $override;
111 if ($config =~ /^(.+?)=(.+)$/) {
112 $config = $1;
113 $override = 1;
114 $val = $2;
115 }
116 if ($config{"CONFIG_PACKAGE_$package"} and ($config ne 'n')) {
117 $kconfig{$config} = $val;
118 } elsif (!$override) {
119 $kconfig{$config} or $kconfig{$config} = 'n';
120 }
121 }
122 };
123 };
124 close FILE;
125
126 foreach my $kconfig (sort keys %kconfig) {
127 if ($kconfig{$kconfig} eq 'n') {
128 print "# $kconfig is not set\n";
129 } else {
130 print "$kconfig=$kconfig{$kconfig}\n";
131 }
132 }
133 }
134
135 sub merge_package_lists($$) {
136 my $list1 = shift;
137 my $list2 = shift;
138 my @l = ();
139 my %pkgs;
140
141 foreach my $pkg (@$list1, @$list2) {
142 $pkgs{$pkg} = 1;
143 }
144 foreach my $pkg (keys %pkgs) {
145 push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
146 }
147 return sort(@l);
148 }
149
150 sub target_config_features(@) {
151 my $ret;
152
153 while ($_ = shift @_) {
154 /broken/ and $ret .= "\tdepends BROKEN\n";
155 /display/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
156 /gpio/ and $ret .= "\tselect GPIO_SUPPORT\n";
157 /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
158 /usb/ and $ret .= "\tselect USB_SUPPORT\n";
159 /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
160 /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
161 /jffs2/ and $ret .= "\tselect USES_JFFS2\n";
162 /ext2/ and $ret .= "\tselect USES_EXT2\n";
163 /tgz/ and $ret .= "\tselect USES_TGZ\n";
164 /cpiogz/ and $ret .= "\tselect USES_CPIOGZ\n";
165 /fpu/ and $ret .= "\tselect HAS_FPU\n";
166 }
167 return $ret;
168 }
169
170 sub target_name($) {
171 my $target = shift;
172 my $parent = $target->{parent};
173 if ($parent) {
174 return $target->{parent}->{name}." - ".$target->{name};
175 } else {
176 return $target->{name};
177 }
178 }
179
180 sub kver($) {
181 my $v = shift;
182 $v =~ tr/\./_/;
183 $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
184 return $v;
185 }
186
187 sub print_target($) {
188 my $target = shift;
189 my $features = target_config_features(@{$target->{features}});
190 my $help = $target->{desc};
191 my $kernel = $target->{kernel};
192 my $confstr;
193 $kernel =~ tr/./_/;
194
195 chomp $features;
196 $features .= "\n";
197 if ($help =~ /\w+/) {
198 $help =~ s/^\s*/\t /mg;
199 $help = "\thelp\n$help";
200 } else {
201 undef $help;
202 }
203
204 my $v = kver($target->{version});
205 if (@{$target->{subtargets}} == 0) {
206 $confstr = <<EOF;
207 config TARGET_$target->{conf}
208 bool "$target->{name}"
209 select LINUX_$kernel
210 select LINUX_$v
211 EOF
212 }
213 else {
214 $confstr = <<EOF;
215 config TARGET_$target->{conf}
216 bool "$target->{name}"
217 EOF
218 }
219 if ($target->{subtarget}) {
220 $confstr .= "\tdepends TARGET_$target->{boardconf}\n";
221 }
222 if (@{$target->{subtargets}} > 0) {
223 $confstr .= "\tselect HAS_SUBTARGETS\n";
224 } else {
225 $confstr .= "\tselect $target->{arch}\n";
226 foreach my $dep (@{$target->{depends}}) {
227 my $mode = "depends";
228 my $flags;
229 my $name;
230
231 $dep =~ /^([@\+\-]+)(.+)$/;
232 $flags = $1;
233 $name = $2;
234
235 next if $name =~ /:/;
236 $flags =~ /-/ and $mode = "deselect";
237 $flags =~ /\+/ and $mode = "select";
238 $flags =~ /@/ and $confstr .= "\t$mode $name\n";
239 }
240 $confstr .= $features;
241 }
242
243 $confstr .= "$help\n\n";
244 print $confstr;
245 }
246
247 sub gen_target_config() {
248 my @target = parse_target_metadata();
249 my %defaults;
250
251 my @target_sort = sort {
252 target_name($a) cmp target_name($b);
253 } @target;
254
255
256 print <<EOF;
257 choice
258 prompt "Target System"
259 default TARGET_brcm_2_4
260 reset if !DEVEL
261
262 EOF
263
264 foreach my $target (@target_sort) {
265 next if $target->{subtarget};
266 print_target($target);
267 }
268
269 print <<EOF;
270 endchoice
271
272 choice
273 prompt "Subtarget" if HAS_SUBTARGETS
274
275 EOF
276 foreach my $target (@target) {
277 next unless $target->{subtarget};
278 print_target($target);
279 }
280
281 print <<EOF;
282 endchoice
283
284 choice
285 prompt "Target Profile"
286
287 EOF
288
289 foreach my $target (@target) {
290 my $profiles = $target->{profiles};
291
292 foreach my $profile (@$profiles) {
293 print <<EOF;
294 config TARGET_$target->{conf}_$profile->{id}
295 bool "$profile->{name}"
296 depends TARGET_$target->{conf}
297 $profile->{config}
298 EOF
299 $profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n";
300 my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
301 foreach my $pkg (@pkglist) {
302 print "\tselect DEFAULT_$pkg\n";
303 $defaults{$pkg} = 1;
304 }
305 my $help = $profile->{desc};
306 if ($help =~ /\w+/) {
307 $help =~ s/^\s*/\t /mg;
308 $help = "\thelp\n$help";
309 } else {
310 undef $help;
311 }
312 print "$help\n";
313 }
314 }
315
316 print <<EOF;
317 endchoice
318
319 config HAS_SUBTARGETS
320 bool
321
322 config TARGET_BOARD
323 string
324
325 EOF
326 foreach my $target (@target) {
327 $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n";
328 }
329 print <<EOF;
330
331 config DEFAULT_TARGET_OPTIMIZATION
332 string
333 EOF
334 foreach my $target (@target) {
335 next if @{$target->{subtargets}} > 0;
336 print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n";
337 }
338 print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
339
340 my %kver;
341 foreach my $target (@target) {
342 my $v = kver($target->{version});
343 next if $kver{$v};
344 $kver{$v} = 1;
345 print <<EOF;
346
347 config LINUX_$v
348 bool
349
350 EOF
351 }
352 foreach my $def (sort keys %defaults) {
353 print "\tconfig DEFAULT_".$def."\n";
354 print "\t\tbool\n\n";
355 }
356 }
357
358 my %dep_check;
359 sub __find_package_dep($$) {
360 my $pkg = shift;
361 my $name = shift;
362 my $deps = ($pkg->{vdepends} or $pkg->{depends});
363
364 return 0 unless defined $deps;
365 foreach my $dep (@{$deps}) {
366 next if $dep_check{$dep};
367 $dep_check{$dep} = 1;
368 return 1 if $dep eq $name;
369 return 1 if ($package{$dep} and (__find_package_dep($package{$dep},$name) == 1));
370 }
371 return 0;
372 }
373
374 # wrapper to avoid infinite recursion
375 sub find_package_dep($$) {
376 my $pkg = shift;
377 my $name = shift;
378
379 %dep_check = ();
380 return __find_package_dep($pkg, $name);
381 }
382
383 sub package_depends($$) {
384 my $a = shift;
385 my $b = shift;
386 my $ret;
387
388 return 0 if ($a->{submenu} ne $b->{submenu});
389 if (find_package_dep($a, $b->{name}) == 1) {
390 $ret = 1;
391 } elsif (find_package_dep($b, $a->{name}) == 1) {
392 $ret = -1;
393 } else {
394 return 0;
395 }
396 return $ret;
397 }
398
399 sub mconf_depends {
400 my $pkgname = shift;
401 my $depends = shift;
402 my $only_dep = shift;
403 my $res;
404 my $dep = shift;
405 my $seen = shift;
406 my $parent_condition = shift;
407 $dep or $dep = {};
408 $seen or $seen = {};
409
410 $depends or return;
411 my @depends = @$depends;
412 foreach my $depend (@depends) {
413 my $m = "depends";
414 $depend =~ s/^([@\+]+)//;
415 my $flags = $1;
416 my $vdep;
417 my $condition;
418
419 if ($depend =~ /^(.+):(.+)$/) {
420 if ($1 ne "PACKAGE_$pkgname") {
421 if ($parent_condition) {
422 $condition = "$parent_condition && $1";
423 } else {
424 $condition = $1;
425 }
426 }
427 $depend = $2;
428 }
429 next if $seen->{$depend};
430 next if $package{$depend} and $package{$depend}->{buildonly};
431 $seen->{$depend} = 1;
432 if ($vdep = $package{$depend}->{vdepends}) {
433 $depend = join("||", map { "PACKAGE_".$_ } @$vdep);
434 } else {
435 $flags =~ /\+/ and do {
436 # Menuconfig will not treat 'select FOO' as a real dependency
437 # thus if FOO depends on other config options, these dependencies
438 # will not be checked. To fix this, we simply emit all of FOO's
439 # depends here as well.
440 $package{$depend} and mconf_depends($pkgname, $package{$depend}->{depends}, 1, $dep, $seen, $condition);
441
442 $m = "select";
443 next if $only_dep;
444 };
445 $flags =~ /@/ or $depend = "PACKAGE_$depend";
446 if ($condition) {
447 if ($m =~ /select/) {
448 $depend = "$depend if $condition";
449 } else {
450 $depend = "!($condition) || $depend";
451 }
452 }
453 }
454 $dep->{$depend} =~ /select/ or $dep->{$depend} = $m;
455 }
456 foreach my $depend (keys %$dep) {
457 my $m = $dep->{$depend};
458 $res .= "\t\t$m $depend\n";
459 }
460 return $res;
461 }
462
463 sub print_package_config_category($) {
464 my $cat = shift;
465 my %menus;
466 my %menu_dep;
467
468 return unless $category{$cat};
469
470 print "menu \"$cat\"\n\n";
471 my %spkg = %{$category{$cat}};
472
473 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
474 foreach my $pkg (@{$spkg{$spkg}}) {
475 next if $pkg->{buildonly};
476 my $menu = $pkg->{submenu};
477 if ($menu) {
478 $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep};
479 } else {
480 $menu = 'undef';
481 }
482 $menus{$menu} or $menus{$menu} = [];
483 push @{$menus{$menu}}, $pkg;
484 }
485 }
486 my @menus = sort {
487 ($a eq 'undef' ? 1 : 0) or
488 ($b eq 'undef' ? -1 : 0) or
489 ($a cmp $b)
490 } keys %menus;
491
492 foreach my $menu (@menus) {
493 my @pkgs = sort {
494 package_depends($a, $b) or
495 ($a->{name} cmp $b->{name})
496 } @{$menus{$menu}};
497 if ($menu ne 'undef') {
498 $menu_dep{$menu} and print "if $menu_dep{$menu}\n";
499 print "menu \"$menu\"\n";
500 }
501 foreach my $pkg (@pkgs) {
502 my $title = $pkg->{name};
503 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
504 if ($c > 0) {
505 $title .= ("." x $c). " ". $pkg->{title};
506 }
507 print "\t";
508 $pkg->{menu} and print "menu";
509 print "config PACKAGE_".$pkg->{name}."\n";
510 print "\t\t".($pkg->{tristate} ? 'tristate' : 'bool')." \"$title\"\n";
511 print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n";
512 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
513 print "\t\tdefault $default\n";
514 }
515 print mconf_depends($pkg->{name}, $pkg->{depends}, 0);
516 print "\t\thelp\n";
517 print $pkg->{description};
518 print "\n";
519
520 $pkg->{config} and print $pkg->{config}."\n";
521 }
522 if ($menu ne 'undef') {
523 print "endmenu\n";
524 $menu_dep{$menu} and print "endif\n";
525 }
526 }
527 print "endmenu\n\n";
528
529 undef $category{$cat};
530 }
531
532 sub gen_package_config() {
533 parse_package_metadata($ARGV[0]) or exit 1;
534 print "menuconfig UCI_PRECONFIG\n\tbool \"Image configuration\"\n" if %preconfig;
535 foreach my $preconfig (keys %preconfig) {
536 foreach my $cfg (keys %{$preconfig{$preconfig}}) {
537 my $conf = $preconfig{$preconfig}->{$cfg}->{id};
538 $conf =~ tr/\.-/__/;
539 print <<EOF
540 config UCI_PRECONFIG_$conf
541 string "$preconfig{$preconfig}->{$cfg}->{label}" if UCI_PRECONFIG
542 depends PACKAGE_$preconfig
543 default "$preconfig{$preconfig}->{$cfg}->{default}"
544
545 EOF
546 }
547 }
548 print_package_config_category 'Base system';
549 foreach my $cat (keys %category) {
550 print_package_config_category $cat;
551 }
552 }
553
554 sub get_conditional_dep($$) {
555 my $condition = shift;
556 my $depstr = shift;
557 if ($condition) {
558 if ($condition =~ /^!(.+)/) {
559 return "\$(if \$(CONFIG_$1),,$depstr)";
560 } else {
561 return "\$(if \$(CONFIG_$condition),$depstr)";
562 }
563 } else {
564 return $depstr;
565 }
566 }
567
568 sub gen_package_mk() {
569 my %conf;
570 my %dep;
571 my %done;
572 my $line;
573
574 parse_package_metadata($ARGV[0]) or exit 1;
575 foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
576 my $config;
577 my $pkg = $package{$name};
578 my @srcdeps;
579
580 next if defined $pkg->{vdepends};
581
582 if ($ENV{SDK}) {
583 $conf{$pkg->{src}} or do {
584 $config = 'm';
585 $conf{$pkg->{src}} = 1;
586 };
587 } else {
588 $config = "\$(CONFIG_PACKAGE_$name)"
589 }
590 if ($config) {
591 $pkg->{buildonly} and $config = "";
592 print "package-$config += $pkg->{subdir}$pkg->{src}\n";
593 $pkg->{prereq} and print "prereq-$config += $pkg->{subdir}$pkg->{src}\n";
594 }
595
596 next if $done{$pkg->{src}};
597 $done{$pkg->{src}} = 1;
598
599 if (@{$pkg->{buildtypes}} > 0) {
600 print "buildtypes-$pkg->{subdir}$pkg->{src} = ".join(' ', @{$pkg->{buildtypes}})."\n";
601 }
602
603 foreach my $spkg (@{$srcpackage{$pkg->{src}}}) {
604 foreach my $dep (@{$spkg->{depends}}, @{$spkg->{builddepends}}) {
605 $dep =~ /@/ or do {
606 $dep =~ s/\+//g;
607 push @srcdeps, $dep;
608 };
609 }
610 }
611 foreach my $type (@{$pkg->{buildtypes}}) {
612 my @extra_deps;
613 my %deplines;
614
615 next unless $pkg->{"builddepends/$type"};
616 foreach my $dep (@{$pkg->{"builddepends/$type"}}) {
617 my $suffix = "";
618 my $condition;
619
620 if ($dep =~ /^(.+):(.+)/) {
621 $condition = $1;
622 $dep = $2;
623 }
624 if ($dep =~ /^(.+)(\/.+)/) {
625 $dep = $1;
626 $suffix = $2;
627 }
628 my $pkg_dep = $package{$dep};
629 next unless $pkg_dep;
630
631 my $idx = "";
632 if (defined $pkg_dep->{src}) {
633 $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
634 } elsif (defined($srcpackage{$dep})) {
635 $idx = $subdir{$dep}.$dep;
636 }
637 my $depstr = "\$(curdir)/$idx$suffix/compile";
638 my $depline = get_conditional_dep($condition, $depstr);
639 if ($depline) {
640 $deplines{$dep} = $depline;
641 }
642 }
643 my $depline = join(" ", values %deplines);
644 if ($depline) {
645 $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/$type/compile += $depline\n";
646 }
647 }
648
649 my $hasdeps = 0;
650 my %deplines;
651 foreach my $deps (@srcdeps) {
652 my $idx;
653 my $condition;
654 my $prefix = "";
655 my $suffix = "";
656
657 if ($deps =~ /^(.+):(.+)/) {
658 $condition = $1;
659 $deps = $2;
660 }
661 if ($deps =~ /^(.+)(\/.+)/) {
662 $deps = $1;
663 $suffix = $2;
664 }
665
666 my $pkg_dep = $package{$deps};
667 my @deps;
668
669 if ($pkg_dep->{vdepends}) {
670 @deps = @{$pkg_dep->{vdepends}};
671 } else {
672 @deps = ($deps);
673 }
674
675 foreach my $dep (@deps) {
676 $pkg_dep = $package{$deps};
677 if (defined $pkg_dep->{src}) {
678 ($pkg->{src} ne $pkg_dep->{src}) and $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
679 } elsif (defined($srcpackage{$dep})) {
680 $idx = $subdir{$dep}.$dep;
681 }
682 undef $idx if $idx =~ /^(kernel)|(base-files)$/;
683 if ($idx) {
684 my $depline;
685 next if $pkg->{src} eq $pkg_dep->{src};
686 next if $dep{$pkg->{src}."->".$idx};
687 next if $dep{$pkg->{src}."->($dep)".$idx} and $pkg_dep->{vdepends};
688 my $depstr;
689
690 if ($pkg_dep->{vdepends}) {
691 $depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx$suffix/compile)";
692 $dep{$pkg->{src}."->($dep)".$idx} = 1;
693 } else {
694 $depstr = "\$(curdir)/$idx$suffix/compile";
695 $dep{$pkg->{src}."->".$idx} = 1;
696 }
697 $depline = get_conditional_dep($condition, $depstr);
698 if ($depline) {
699 $deplines{$idx.$dep} = $depline;
700 }
701 }
702 }
703 }
704 my $depline = join(" ", values %deplines);
705 if ($depline) {
706 $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile += $depline\n";
707 }
708 }
709
710 if ($line ne "") {
711 print "\n$line";
712 }
713 foreach my $preconfig (keys %preconfig) {
714 my $cmds;
715 foreach my $cfg (keys %{$preconfig{$preconfig}}) {
716 my $conf = $preconfig{$preconfig}->{$cfg}->{id};
717 $conf =~ tr/\.-/__/;
718 $cmds .= "\techo \"uci set '$preconfig{$preconfig}->{$cfg}->{id}=\$(subst \",,\$(CONFIG_UCI_PRECONFIG_$conf))'\"; \\\n";
719 }
720 next unless $cmds;
721 print <<EOF
722
723 \$(TARGET_DIR)/etc/uci-defaults/$preconfig: FORCE
724 ( \\
725 $cmds \\
726 ) > \$@
727
728 ifneq (\$(UCI_PRECONFIG)\$(CONFIG_UCI_PRECONFIG),)
729 package/preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
730 endif
731 EOF
732 }
733 }
734
735 sub gen_package_source() {
736 parse_package_metadata($ARGV[0]) or exit 1;
737 foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
738 my $pkg = $package{$name};
739 if ($pkg->{name} && $pkg->{source}) {
740 print "$pkg->{name}: ";
741 print "$pkg->{source}\n";
742 }
743 }
744 }
745
746 sub parse_command() {
747 my $cmd = shift @ARGV;
748 for ($cmd) {
749 /^target_config$/ and return gen_target_config();
750 /^package_mk$/ and return gen_package_mk();
751 /^package_config$/ and return gen_package_config();
752 /^kconfig/ and return gen_kconfig_overrides();
753 /^package_source$/ and return gen_package_source();
754 }
755 print <<EOF
756 Available Commands:
757 $0 target_config [file] Target metadata in Kconfig format
758 $0 package_mk [file] Package metadata in makefile format
759 $0 package_config [file] Package metadata in Kconfig format
760 $0 kconfig [file] [config] Kernel config overrides
761 $0 package_source [file] Package source file information
762
763 EOF
764 }
765
766 parse_command();
This page took 0.115602 seconds and 3 git commands to generate.