disable gettext in menuconfig
[openwrt.git] / scripts / gen_menuconfig.pl
1 #!/usr/bin/perl
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 use strict;
10
11 my $src;
12 my $makefile;
13 my $pkg;
14 my %category;
15 my $cur_menu;
16 my $cur_menu_dep;
17
18 sub close_submenu {
19 if ($cur_menu) {
20 print "endmenu\n";
21 $cur_menu_dep and do {
22 print "endif\n";
23 $cur_menu_dep = undef;
24 };
25 undef $cur_menu;
26 }
27 }
28
29 sub print_category($) {
30 my $cat = shift;
31
32 return unless $category{$cat};
33
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}) {
39 close_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";
44 }
45 }
46 my $title = $pkg->{name};
47 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
48 if ($c > 0) {
49 $title .= ("." x $c). " ". $pkg->{title};
50 }
51 print "\t";
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";
57 }
58 foreach my $depend (@{$pkg->{depends}}) {
59 my $m = "depends";
60 $depend =~ s/^([@\+]+)//;
61 my $flags = $1;
62 $flags =~ /@/ or $depend = "PACKAGE_$depend";
63 $flags =~ /\+/ and $m = "select";
64 print "\t\t$m $depend\n";
65 }
66 print "\t\thelp\n";
67 print $pkg->{description};
68 print "\n";
69
70 $pkg->{config} and print $pkg->{config}."\n";
71 }
72 }
73 close_submenu();
74 print "endmenu\n\n";
75
76 undef $category{$cat};
77 }
78
79 my $line;
80 while ($line = <>) {
81 chomp $line;
82 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
83 $makefile = $1;
84 $src = $2;
85 undef $pkg;
86 };
87 $line =~ /^Package: \s*(.+)\s*$/ and do {
88 $pkg = {};
89 $pkg->{src} = $src;
90 $pkg->{makefile} = $makefile;
91 $pkg->{name} = $1;
92 $pkg->{default} = "m if ALL";
93 };
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;
103 };
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;
109 };
110 $line =~ /^Description: \s*(.*)\s*$/ and do {
111 my $desc = "\t\t$1\n\n";
112 my $line;
113 while ($line = <>) {
114 last if $line =~ /^@@/;
115 $desc .= "\t\t$line";
116 }
117 $pkg->{description} = $desc;
118 };
119 $line =~ /^Config: \s*(.*)\s*$/ and do {
120 my $conf = "$1\n";
121 my $line;
122 while ($line = <>) {
123 last if $line =~ /^@@/;
124 $conf .= "$line";
125 }
126 $pkg->{config} = $conf;
127 }
128 }
129
130 print_category 'Base system';
131 foreach my $cat (keys %category) {
132 print_category $cat;
133 }
This page took 0.104876 seconds and 5 git commands to generate.