remove madwifi-old
[openwrt.git] / 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 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
28 print "\t\tdefault $default\n";
29 }
30 foreach my $depend (@{$pkg->{depends}}) {
31 my $m = "depends";
32 $depend =~ s/^([@\+])//;
33 my $flags = $1;
34 $flags =~ /@/ or $depend = "PACKAGE_$depend";
35 $flags =~ /\+/ and $m = "select";
36 print "\t\t$m $depend\n";
37 }
38 print "\t\thelp\n";
39 print $pkg->{description};
40 print "\n";
41
42 $pkg->{config} and print $pkg->{config}."\n";
43 }
44 }
45 print "endmenu\n\n";
46
47 undef $category{$cat};
48 }
49
50 my $line;
51 while ($line = <>) {
52 chomp $line;
53 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
54 $makefile = $1;
55 $src = $2;
56 undef $pkg;
57 };
58 $line =~ /^Package: \s*(.+)\s*$/ and do {
59 $pkg = {};
60 $pkg->{src} = $src;
61 $pkg->{makefile} = $makefile;
62 $pkg->{name} = $1;
63 $pkg->{default} = "m if ALL";
64 };
65 $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
66 $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
67 $line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
68 $line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
69 $line =~ /^Depends: \s*(.+)\s*$/ and do {
70 my @dep = split /\s+/, $1;
71 $pkg->{depends} = \@dep;
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 }
This page took 0.056026 seconds and 5 git commands to generate.