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.
21 $cur_menu_dep and do {
23 $cur_menu_dep = undef;
29 sub print_category($) {
32 return unless $category{$cat};
34 print "menu \"$cat\"\n\n";
35 my %spkg = %{$category{$cat}};
36 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
37 foreach my $pkg (@{$spkg{$spkg}}) {
38 if ($cur_menu ne $pkg->{submenu}) {
40 if ($pkg->{submenu}) {
41 $cur_menu = $pkg->{submenu};
42 $cur_menu_dep = $pkg->{submenudep} and print "if $cur_menu_dep\n";
43 print "menu \"$cur_menu\"\n";
46 my $title = $pkg->{name};
47 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
49 $title .= ("." x $c). " ". $pkg->{title};
52 $pkg->{menu} and print "menu";
53 print "config PACKAGE_".$pkg->{name}."\n";
54 print "\t\ttristate \"$title\"\n";
55 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
56 print "\t\tdefault $default\n";
58 foreach my $depend (@{$pkg->{depends}}) {
60 $depend =~ s/^([@\+]+)//;
62 $flags =~ /@/ or $depend = "PACKAGE_$depend";
63 $flags =~ /\+/ and $m = "select";
64 print "\t\t$m $depend\n";
67 print $pkg->{description};
70 $pkg->{config} and print $pkg->{config}."\n";
76 undef $category{$cat};
82 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
87 $line =~ /^Package: \s*(.+)\s*$/ and do {
90 $pkg->{makefile} = $makefile;
92 $pkg->{default} = "m if ALL";
94 $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
95 $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
96 $line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
97 $line =~ /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
98 $line =~ /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
99 $line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
100 $line =~ /^Depends: \s*(.+)\s*$/ and do {
101 my @dep = split /\s+/, $1;
102 $pkg->{depends} = \@dep;
104 $line =~ /^Category: \s*(.+)\s*$/ and do {
105 $pkg->{category} = $1;
106 defined $category{$1} or $category{$1} = {};
107 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
108 push @{$category{$1}->{$src}}, $pkg;
110 $line =~ /^Description: \s*(.*)\s*$/ and do {
111 my $desc = "\t\t$1\n\n";
114 last if $line =~ /^@@/;
115 $desc .= "\t\t$line";
117 $pkg->{description} = $desc;
119 $line =~ /^Config: \s*(.*)\s*$/ and do {
123 last if $line =~ /^@@/;
126 $pkg->{config} = $conf;
130 print_category 'Base system';
131 foreach my $cat (keys %category) {