powerpc: Create a powerpc64 config feature
[openwrt/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 /pcie/ and $ret .= "\tselect PCIE_SUPPORT\n";
159 /usb/ and $ret .= "\tselect USB_SUPPORT\n";
160 /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
161 /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
162 /jffs2/ and $ret .= "\tselect USES_JFFS2\n";
163 /ext2/ and $ret .= "\tselect USES_EXT2\n";
164 /tgz/ and $ret .= "\tselect USES_TGZ\n";
165 /cpiogz/ and $ret .= "\tselect USES_CPIOGZ\n";
166 /fpu/ and $ret .= "\tselect HAS_FPU\n";
167 /ramdisk/ and $ret .= "\tselect USES_INITRAMFS\n";
168 /powerpc64/ and $ret .= "\tselect powerpc64\n";
169 }
170 return $ret;
171 }
172
173 sub target_name($) {
174 my $target = shift;
175 my $parent = $target->{parent};
176 if ($parent) {
177 return $target->{parent}->{name}." - ".$target->{name};
178 } else {
179 return $target->{name};
180 }
181 }
182
183 sub kver($) {
184 my $v = shift;
185 $v =~ tr/\./_/;
186 $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
187 return $v;
188 }
189
190 sub print_target($) {
191 my $target = shift;
192 my $features = target_config_features(@{$target->{features}});
193 my $help = $target->{desc};
194 my $kernel = $target->{kernel};
195 my $confstr;
196 $kernel =~ tr/./_/;
197
198 chomp $features;
199 $features .= "\n";
200 if ($help =~ /\w+/) {
201 $help =~ s/^\s*/\t /mg;
202 $help = "\thelp\n$help";
203 } else {
204 undef $help;
205 }
206
207 my $v = kver($target->{version});
208 if (@{$target->{subtargets}} == 0) {
209 $confstr = <<EOF;
210 config TARGET_$target->{conf}
211 bool "$target->{name}"
212 select LINUX_$kernel
213 select LINUX_$v
214 EOF
215 }
216 else {
217 $confstr = <<EOF;
218 config TARGET_$target->{conf}
219 bool "$target->{name}"
220 EOF
221 }
222 if ($target->{subtarget}) {
223 $confstr .= "\tdepends TARGET_$target->{boardconf}\n";
224 }
225 if (@{$target->{subtargets}} > 0) {
226 $confstr .= "\tselect HAS_SUBTARGETS\n";
227 } else {
228 $confstr .= "\tselect $target->{arch}\n";
229 foreach my $dep (@{$target->{depends}}) {
230 my $mode = "depends";
231 my $flags;
232 my $name;
233
234 $dep =~ /^([@\+\-]+)(.+)$/;
235 $flags = $1;
236 $name = $2;
237
238 next if $name =~ /:/;
239 $flags =~ /-/ and $mode = "deselect";
240 $flags =~ /\+/ and $mode = "select";
241 $flags =~ /@/ and $confstr .= "\t$mode $name\n";
242 }
243 $confstr .= $features;
244 }
245
246 $confstr .= "$help\n\n";
247 print $confstr;
248 }
249
250 sub gen_target_config() {
251 my @target = parse_target_metadata();
252 my %defaults;
253
254 my @target_sort = sort {
255 target_name($a) cmp target_name($b);
256 } @target;
257
258
259 print <<EOF;
260 choice
261 prompt "Target System"
262 default TARGET_brcm_2_4
263 reset if !DEVEL
264
265 EOF
266
267 foreach my $target (@target_sort) {
268 next if $target->{subtarget};
269 print_target($target);
270 }
271
272 print <<EOF;
273 endchoice
274
275 choice
276 prompt "Subtarget" if HAS_SUBTARGETS
277
278 EOF
279 foreach my $target (@target) {
280 next unless $target->{subtarget};
281 print_target($target);
282 }
283
284 print <<EOF;
285 endchoice
286
287 choice
288 prompt "Target Profile"
289
290 EOF
291
292 foreach my $target (@target) {
293 my $profiles = $target->{profiles};
294
295 foreach my $profile (@$profiles) {
296 print <<EOF;
297 config TARGET_$target->{conf}_$profile->{id}
298 bool "$profile->{name}"
299 depends TARGET_$target->{conf}
300 $profile->{config}
301 EOF
302 $profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n";
303 my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
304 foreach my $pkg (@pkglist) {
305 print "\tselect DEFAULT_$pkg\n";
306 $defaults{$pkg} = 1;
307 }
308 my $help = $profile->{desc};
309 if ($help =~ /\w+/) {
310 $help =~ s/^\s*/\t /mg;
311 $help = "\thelp\n$help";
312 } else {
313 undef $help;
314 }
315 print "$help\n";
316 }
317 }
318
319 print <<EOF;
320 endchoice
321
322 config HAS_SUBTARGETS
323 bool
324
325 config TARGET_BOARD
326 string
327
328 EOF
329 foreach my $target (@target) {
330 $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n";
331 }
332 print <<EOF;
333
334 config DEFAULT_TARGET_OPTIMIZATION
335 string
336 EOF
337 foreach my $target (@target) {
338 next if @{$target->{subtargets}} > 0;
339 print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n";
340 }
341 print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
342
343 my %kver;
344 foreach my $target (@target) {
345 my $v = kver($target->{version});
346 next if $kver{$v};
347 $kver{$v} = 1;
348 print <<EOF;
349
350 config LINUX_$v
351 bool
352
353 EOF
354 }
355 foreach my $def (sort keys %defaults) {
356 print "\tconfig DEFAULT_".$def."\n";
357 print "\t\tbool\n\n";
358 }
359 }
360
361 my %dep_check;
362 sub __find_package_dep($$) {
363 my $pkg = shift;
364 my $name = shift;
365 my $deps = ($pkg->{vdepends} or $pkg->{depends});
366
367 return 0 unless defined $deps;
368 foreach my $dep (@{$deps}) {
369 next if $dep_check{$dep};
370 $dep_check{$dep} = 1;
371 return 1 if $dep eq $name;
372 return 1 if ($package{$dep} and (__find_package_dep($package{$dep},$name) == 1));
373 }
374 return 0;
375 }
376
377 # wrapper to avoid infinite recursion
378 sub find_package_dep($$) {
379 my $pkg = shift;
380 my $name = shift;
381
382 %dep_check = ();
383 return __find_package_dep($pkg, $name);
384 }
385
386 sub package_depends($$) {
387 my $a = shift;
388 my $b = shift;
389 my $ret;
390
391 return 0 if ($a->{submenu} ne $b->{submenu});
392 if (find_package_dep($a, $b->{name}) == 1) {
393 $ret = 1;
394 } elsif (find_package_dep($b, $a->{name}) == 1) {
395 $ret = -1;
396 } else {
397 return 0;
398 }
399 return $ret;
400 }
401
402 sub mconf_depends {
403 my $pkgname = shift;
404 my $depends = shift;
405 my $only_dep = shift;
406 my $res;
407 my $dep = shift;
408 my $seen = shift;
409 my $parent_condition = shift;
410 $dep or $dep = {};
411 $seen or $seen = {};
412
413 $depends or return;
414 my @depends = @$depends;
415 foreach my $depend (@depends) {
416 my $m = "depends";
417 $depend =~ s/^([@\+]+)//;
418 my $flags = $1;
419 my $vdep;
420 my $condition = $parent_condition;
421
422 if ($depend =~ /^(.+):(.+)$/) {
423 if ($1 ne "PACKAGE_$pkgname") {
424 if ($condition) {
425 $condition = "$condition && $1";
426 } else {
427 $condition = $1;
428 }
429 }
430 $depend = $2;
431 }
432 next if $seen->{$depend};
433 next if $package{$depend} and $package{$depend}->{buildonly};
434 $seen->{$depend} = 1;
435 if ($vdep = $package{$depend}->{vdepends}) {
436 $depend = join("||", map { "PACKAGE_".$_ } @$vdep);
437 } else {
438 $flags =~ /\+/ and do {
439 # Menuconfig will not treat 'select FOO' as a real dependency
440 # thus if FOO depends on other config options, these dependencies
441 # will not be checked. To fix this, we simply emit all of FOO's
442 # depends here as well.
443 $package{$depend} and mconf_depends($pkgname, $package{$depend}->{depends}, 1, $dep, $seen, $condition);
444
445 $m = "select";
446 next if $only_dep;
447 };
448 $flags =~ /@/ or $depend = "PACKAGE_$depend";
449 if ($condition) {
450 if ($m =~ /select/) {
451 $depend = "$depend if $condition";
452 } else {
453 $depend = "!($condition) || $depend";
454 }
455 }
456 }
457 $dep->{$depend} =~ /select/ or $dep->{$depend} = $m;
458 }
459 foreach my $depend (keys %$dep) {
460 my $m = $dep->{$depend};
461 $res .= "\t\t$m $depend\n";
462 }
463 return $res;
464 }
465
466 sub print_package_config_category($) {
467 my $cat = shift;
468 my %menus;
469 my %menu_dep;
470
471 return unless $category{$cat};
472
473 print "menu \"$cat\"\n\n";
474 my %spkg = %{$category{$cat}};
475
476 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
477 foreach my $pkg (@{$spkg{$spkg}}) {
478 next if $pkg->{buildonly};
479 my $menu = $pkg->{submenu};
480 if ($menu) {
481 $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep};
482 } else {
483 $menu = 'undef';
484 }
485 $menus{$menu} or $menus{$menu} = [];
486 push @{$menus{$menu}}, $pkg;
487 }
488 }
489 my @menus = sort {
490 ($a eq 'undef' ? 1 : 0) or
491 ($b eq 'undef' ? -1 : 0) or
492 ($a cmp $b)
493 } keys %menus;
494
495 foreach my $menu (@menus) {
496 my @pkgs = sort {
497 package_depends($a, $b) or
498 ($a->{name} cmp $b->{name})
499 } @{$menus{$menu}};
500 if ($menu ne 'undef') {
501 $menu_dep{$menu} and print "if $menu_dep{$menu}\n";
502 print "menu \"$menu\"\n";
503 }
504 foreach my $pkg (@pkgs) {
505 my $title = $pkg->{name};
506 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
507 if ($c > 0) {
508 $title .= ("." x $c). " ". $pkg->{title};
509 }
510 print "\t";
511 $pkg->{menu} and print "menu";
512 print "config PACKAGE_".$pkg->{name}."\n";
513 print "\t\t".($pkg->{tristate} ? 'tristate' : 'bool')." \"$title\"\n";
514 print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n";
515 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
516 print "\t\tdefault $default\n";
517 }
518 print mconf_depends($pkg->{name}, $pkg->{depends}, 0);
519 print "\t\thelp\n";
520 print $pkg->{description};
521 print "\n";
522
523 $pkg->{config} and print $pkg->{config}."\n";
524 }
525 if ($menu ne 'undef') {
526 print "endmenu\n";
527 $menu_dep{$menu} and print "endif\n";
528 }
529 }
530 print "endmenu\n\n";
531
532 undef $category{$cat};
533 }
534
535 sub gen_package_config() {
536 parse_package_metadata($ARGV[0]) or exit 1;
537 print "menuconfig UCI_PRECONFIG\n\tbool \"Image configuration\"\n" if %preconfig;
538 foreach my $preconfig (keys %preconfig) {
539 foreach my $cfg (keys %{$preconfig{$preconfig}}) {
540 my $conf = $preconfig{$preconfig}->{$cfg}->{id};
541 $conf =~ tr/\.-/__/;
542 print <<EOF
543 config UCI_PRECONFIG_$conf
544 string "$preconfig{$preconfig}->{$cfg}->{label}" if UCI_PRECONFIG
545 depends PACKAGE_$preconfig
546 default "$preconfig{$preconfig}->{$cfg}->{default}"
547
548 EOF
549 }
550 }
551 print_package_config_category 'Base system';
552 foreach my $cat (keys %category) {
553 print_package_config_category $cat;
554 }
555 }
556
557 sub get_conditional_dep($$) {
558 my $condition = shift;
559 my $depstr = shift;
560 if ($condition) {
561 if ($condition =~ /^!(.+)/) {
562 return "\$(if \$(CONFIG_$1),,$depstr)";
563 } else {
564 return "\$(if \$(CONFIG_$condition),$depstr)";
565 }
566 } else {
567 return $depstr;
568 }
569 }
570
571 sub gen_package_mk() {
572 my %conf;
573 my %dep;
574 my %done;
575 my $line;
576
577 parse_package_metadata($ARGV[0]) or exit 1;
578 foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
579 my $config;
580 my $pkg = $package{$name};
581 my @srcdeps;
582
583 next if defined $pkg->{vdepends};
584
585 if ($ENV{SDK}) {
586 $conf{$pkg->{src}} or do {
587 $config = 'm';
588 $conf{$pkg->{src}} = 1;
589 };
590 } else {
591 $config = "\$(CONFIG_PACKAGE_$name)"
592 }
593 if ($config) {
594 $pkg->{buildonly} and $config = "";
595 print "package-$config += $pkg->{subdir}$pkg->{src}\n";
596 $pkg->{prereq} and print "prereq-$config += $pkg->{subdir}$pkg->{src}\n";
597 }
598
599 next if $done{$pkg->{src}};
600 $done{$pkg->{src}} = 1;
601
602 if (@{$pkg->{buildtypes}} > 0) {
603 print "buildtypes-$pkg->{subdir}$pkg->{src} = ".join(' ', @{$pkg->{buildtypes}})."\n";
604 }
605
606 foreach my $spkg (@{$srcpackage{$pkg->{src}}}) {
607 foreach my $dep (@{$spkg->{depends}}, @{$spkg->{builddepends}}) {
608 $dep =~ /@/ or do {
609 $dep =~ s/\+//g;
610 push @srcdeps, $dep;
611 };
612 }
613 }
614 foreach my $type (@{$pkg->{buildtypes}}) {
615 my @extra_deps;
616 my %deplines;
617
618 next unless $pkg->{"builddepends/$type"};
619 foreach my $dep (@{$pkg->{"builddepends/$type"}}) {
620 my $suffix = "";
621 my $condition;
622
623 if ($dep =~ /^(.+):(.+)/) {
624 $condition = $1;
625 $dep = $2;
626 }
627 if ($dep =~ /^(.+)(\/.+)/) {
628 $dep = $1;
629 $suffix = $2;
630 }
631 my $pkg_dep = $package{$dep};
632 next unless $pkg_dep;
633
634 my $idx = "";
635 if (defined $pkg_dep->{src}) {
636 $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
637 } elsif (defined($srcpackage{$dep})) {
638 $idx = $subdir{$dep}.$dep;
639 }
640 my $depstr = "\$(curdir)/$idx$suffix/compile";
641 my $depline = get_conditional_dep($condition, $depstr);
642 if ($depline) {
643 $deplines{$dep} = $depline;
644 }
645 }
646 my $depline = join(" ", values %deplines);
647 if ($depline) {
648 $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/$type/compile += $depline\n";
649 }
650 }
651
652 my $hasdeps = 0;
653 my %deplines;
654 foreach my $deps (@srcdeps) {
655 my $idx;
656 my $condition;
657 my $prefix = "";
658 my $suffix = "";
659
660 if ($deps =~ /^(.+):(.+)/) {
661 $condition = $1;
662 $deps = $2;
663 }
664 if ($deps =~ /^(.+)(\/.+)/) {
665 $deps = $1;
666 $suffix = $2;
667 }
668
669 my $pkg_dep = $package{$deps};
670 my @deps;
671
672 if ($pkg_dep->{vdepends}) {
673 @deps = @{$pkg_dep->{vdepends}};
674 } else {
675 @deps = ($deps);
676 }
677
678 foreach my $dep (@deps) {
679 $pkg_dep = $package{$deps};
680 if (defined $pkg_dep->{src}) {
681 ($pkg->{src} ne $pkg_dep->{src}.$suffix) and $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
682 } elsif (defined($srcpackage{$dep})) {
683 $idx = $subdir{$dep}.$dep;
684 }
685 $idx .= $suffix;
686 undef $idx if $idx =~ /^(kernel)|(base-files)$/;
687 if ($idx) {
688 my $depline;
689 next if $pkg->{src} eq $pkg_dep->{src}.$suffix;
690 next if $dep{$pkg->{src}."->".$idx};
691 next if $dep{$pkg->{src}."->($dep)".$idx} and $pkg_dep->{vdepends};
692 my $depstr;
693
694 if ($pkg_dep->{vdepends}) {
695 $depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx/compile)";
696 $dep{$pkg->{src}."->($dep)".$idx} = 1;
697 } else {
698 $depstr = "\$(curdir)/$idx/compile";
699 $dep{$pkg->{src}."->".$idx} = 1;
700 }
701 $depline = get_conditional_dep($condition, $depstr);
702 if ($depline) {
703 $deplines{$idx.$dep} = $depline;
704 }
705 }
706 }
707 }
708 my $depline = join(" ", values %deplines);
709 if ($depline) {
710 $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile += $depline\n";
711 }
712 }
713
714 if ($line ne "") {
715 print "\n$line";
716 }
717 foreach my $preconfig (keys %preconfig) {
718 my $cmds;
719 foreach my $cfg (keys %{$preconfig{$preconfig}}) {
720 my $conf = $preconfig{$preconfig}->{$cfg}->{id};
721 $conf =~ tr/\.-/__/;
722 $cmds .= "\techo \"uci set '$preconfig{$preconfig}->{$cfg}->{id}=\$(subst \",,\$(CONFIG_UCI_PRECONFIG_$conf))'\"; \\\n";
723 }
724 next unless $cmds;
725 print <<EOF
726
727 \$(TARGET_DIR)/etc/uci-defaults/$preconfig: FORCE
728 ( \\
729 $cmds \\
730 ) > \$@
731
732 ifneq (\$(UCI_PRECONFIG)\$(CONFIG_UCI_PRECONFIG),)
733 package/preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
734 endif
735 EOF
736 }
737 }
738
739 sub gen_package_source() {
740 parse_package_metadata($ARGV[0]) or exit 1;
741 foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
742 my $pkg = $package{$name};
743 if ($pkg->{name} && $pkg->{source}) {
744 print "$pkg->{name}: ";
745 print "$pkg->{source}\n";
746 }
747 }
748 }
749
750 sub parse_command() {
751 my $cmd = shift @ARGV;
752 for ($cmd) {
753 /^target_config$/ and return gen_target_config();
754 /^package_mk$/ and return gen_package_mk();
755 /^package_config$/ and return gen_package_config();
756 /^kconfig/ and return gen_kconfig_overrides();
757 /^package_source$/ and return gen_package_source();
758 }
759 print <<EOF
760 Available Commands:
761 $0 target_config [file] Target metadata in Kconfig format
762 $0 package_mk [file] Package metadata in makefile format
763 $0 package_config [file] Package metadata in Kconfig format
764 $0 kconfig [file] [config] Kernel config overrides
765 $0 package_source [file] Package source file information
766
767 EOF
768 }
769
770 parse_command();