3 # Copyright (C) 2006 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
18 sub print_category($) {
21 return unless $category{$cat};
23 print "menu \"$cat\"\n\n";
24 my %spkg = %{$category{$cat}};
25 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
26 foreach my $pkg (@{$spkg{$spkg}}) {
27 if ($cur_menu ne $pkg->{submenu}) {
30 $cur_menu_dep and do {
32 $cur_menu_dep = undef;
36 if ($pkg->{submenu}) {
37 $cur_menu = $pkg->{submenu};
38 $cur_menu_dep = $pkg->{submenudep} and print "if $cur_menu_dep\n";
39 print "menu \"$cur_menu\"\n";
42 my $title = $pkg->{name};
43 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
45 $title .= ("." x $c). " ". $pkg->{title};
48 $pkg->{menu} and print "menu";
49 print "config PACKAGE_".$pkg->{name}."\n";
50 print "\t\ttristate \"$title\"\n";
51 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
52 print "\t\tdefault $default\n";
54 foreach my $depend (@{$pkg->{depends}}) {
56 $depend =~ s/^([@\+]+)//;
58 $flags =~ /@/ or $depend = "PACKAGE_$depend";
59 $flags =~ /\+/ and $m = "select";
60 print "\t\t$m $depend\n";
63 print $pkg->{description};
66 $pkg->{config} and print $pkg->{config}."\n";
71 undef $category{$cat};
77 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
82 $line =~ /^Package: \s*(.+)\s*$/ and do {
85 $pkg->{makefile} = $makefile;
87 $pkg->{default} = "m if ALL";
89 $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
90 $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
91 $line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
92 $line =~ /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
93 $line =~ /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
94 $line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
95 $line =~ /^Depends: \s*(.+)\s*$/ and do {
96 my @dep = split /\s+/, $1;
97 $pkg->{depends} = \@dep;
99 $line =~ /^Category: \s*(.+)\s*$/ and do {
100 $pkg->{category} = $1;
101 defined $category{$1} or $category{$1} = {};
102 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
103 push @{$category{$1}->{$src}}, $pkg;
105 $line =~ /^Description: \s*(.*)\s*$/ and do {
106 my $desc = "\t\t$1\n\n";
109 last if $line =~ /^@@/;
110 $desc .= "\t\t$line";
112 $pkg->{description} = $desc;
114 $line =~ /^Config: \s*(.*)\s*$/ and do {
118 last if $line =~ /^@@/;
121 $pkg->{config} = $conf;
125 print_category 'Base system';
126 foreach my $cat (keys %category) {