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.
11 ($PATH and -d
$PATH) or die 'invalid path';
15 open FIND
, "find \"$PATH\" -name Config.in |";
20 my $replace = quotemeta($PATH);
21 $output =~ s/^$replace\///g
;
22 $output =~ s/sysdeps\/linux\///g;
23 print STDERR
"$input => $output\n";
24 $output =~ /^(.+)\/[^\
/]+$/ and system("mkdir -p $1");
27 open OUTPUT
, ">$output";
28 my ($cur, $default_set, $line);
29 while ($line = <INPUT
>) {
30 next if $line =~ /^\s*mainmenu/;
32 # FIXME: make this dynamic
33 $line =~ s/default FEATURE_BUFFERS_USE_MALLOC/default FEATURE_BUFFERS_GO_ON_STACK/;
34 $line =~ s/default FEATURE_SH_IS_NONE/default FEATURE_SH_IS_ASH/;
36 if ($line =~ /^\s*config\s*([\w_]+)/) {
40 if ($line =~ /^\s*(menu|choice|end|source)/) {
44 $line =~ s/^(\s*source\s+)([^\/]+\/)*([^\
/]+\/[^\
/]+)$/$1$3/;
45 if ($line =~ /^(\s*range\s*)(\w+)(\s+)(\w+)\s*$/) {
49 $r1 =~ s/^([a-zA-Z]+)/BUSYBOX_CONFIG_$1/;
50 $r2 =~ s/^([a-zA-Z]+)/BUSYBOX_CONFIG_$1/;
51 $line = "$prefix$r1 $r2\n";
54 $line =~ s/^(\s*(prompt "[^"]+" if|config|depends|depends on|select|default|default \w if)\s+\!?)([A-Z_])/$1BUSYBOX_CONFIG_$3/g;
55 $line =~ s/(( \|\| | \&\& | \( )!?)([A-Z_])/$1BUSYBOX_CONFIG_$3/g;
56 $line =~ s/(\( ?!?)([A-Z_]+ (\|\||&&))/$1BUSYBOX_CONFIG_$2/g;
59 ($cur eq 'LFS') and do {
60 $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/;
62 if ($line =~ /^\s*default/) {
65 $c = "BUSYBOX_DEFAULT_$cur";
67 $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/;