add Build/InstallDev template to install dev files in STAGING_DIR, introduce a NEEDS...
[openwrt/staging/dedeckeh.git] / openwrt / scripts / gen_menuconfig.pl
1 #!/usr/bin/perl
2 use strict;
3
4 my $src;
5 my $makefile;
6 my $pkg;
7 my %category;
8
9 sub print_category($) {
10 my $cat = shift;
11
12 return unless $category{$cat};
13
14 print "menu \"$cat\"\n\n";
15 my %spkg = %{$category{$cat}};
16 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
17 foreach my $pkg (@{$spkg{$spkg}}) {
18 my $title = $pkg->{name};
19 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
20 if ($c > 0) {
21 $title .= ("." x $c). " ". $pkg->{title};
22 }
23 print "\t";
24 $pkg->{menu} and print "menu";
25 print "config PACKAGE_".$pkg->{name}."\n";
26 print "\t\ttristate \"$title\"\n";
27 print "\t\tdefault ".$pkg->{default}."\n";
28 foreach my $depend (@{$pkg->{depends}}) {
29 print "\t\tdepends PACKAGE_$depend\n";
30 }
31 foreach my $need (@{$pkg->{needs}}) {
32 print "\t\tselect PACKAGE_$need\n";
33 }
34 print "\t\thelp\n";
35 print $pkg->{description};
36 print "\n";
37
38 $pkg->{config} and print $pkg->{config}."\n";
39 }
40 }
41 print "endmenu\n\n";
42
43 undef $category{$cat};
44 }
45
46 my $line;
47 while ($line = <>) {
48 chomp $line;
49 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
50 $makefile = $1;
51 $src = $2;
52 undef $pkg;
53 };
54 $line =~ /^Package: \s*(.+)\s*$/ and do {
55 $pkg = {};
56 $pkg->{src} = $src;
57 $pkg->{makefile} = $makefile;
58 $pkg->{name} = $1;
59 $pkg->{default} = "m if ALL";
60 };
61 $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
62 $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
63 $line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
64 $line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
65 $line =~ /^Depends: \s*(.+)\s*$/ and do {
66 my @dep = split /,\s*/, $1;
67 $pkg->{depends} = \@dep;
68 };
69 $line =~ /^Needs: \s*(.+)\s*$/ and do {
70 my @need = split /,\s*/, $1;
71 $pkg->{needs} = \@need;
72 };
73 $line =~ /^Category: \s*(.+)\s*$/ and do {
74 $pkg->{category} = $1;
75 defined $category{$1} or $category{$1} = {};
76 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
77 push @{$category{$1}->{$src}}, $pkg;
78 };
79 $line =~ /^Description: \s*(.*)\s*$/ and do {
80 my $desc = "\t\t$1\n\n";
81 my $line;
82 while ($line = <>) {
83 last if $line =~ /^@@/;
84 $desc .= "\t\t$line";
85 }
86 $pkg->{description} = $desc;
87 };
88 $line =~ /^Config: \s*(.*)\s*$/ and do {
89 my $conf = "$1\n";
90 my $line;
91 while ($line = <>) {
92 last if $line =~ /^@@/;
93 $conf .= "$line";
94 }
95 $pkg->{config} = $conf;
96 }
97 }
98
99 print_category 'Base system';
100 foreach my $cat (keys %category) {
101 print_category $cat;
102 }