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