4 ($PATH and -d $PATH) or die 'invalid path';
5 my $DEFCONFIG = $ARGV[1];
6 ($DEFCONFIG and -f $DEFCONFIG) or die 'invalid config file';
10 open CONFIG, $DEFCONFIG or die 'cannot open config file';
12 /^([\w_]+)=([ym])/ and $config{$1} = $2;
13 /^([\w_]+)=(\d+)/ and $config{$1} = $2;
14 /^([\w_]+)=(".+")/ and $config{$1} = $2;
18 open FIND, "find \"$PATH\" -name Config.in |";
23 s/sysdeps\/linux\///g;
25 print STDERR "$input => $output\n";
26 $output =~ /^(.+)\/[^\/]+$/ and system("mkdir -p $1");
29 open OUTPUT, ">$output";
30 my ($cur, $default_set, $line);
31 while ($line = <INPUT>) {
32 next if $line =~ /^\s*mainmenu/;
34 # FIXME: make this dynamic
35 $line =~ s/default CONFIG_FEATURE_BUFFERS_USE_MALLOC/default CONFIG_FEATURE_BUFFERS_GO_ON_STACK/;
36 $line =~ s/default BUSYBOX_CONFIG_FEATURE_SH_IS_NONE/default BUSYBOX_CONFIG_FEATURE_SH_IS_ASH/;
38 if ($line =~ /^\s*config\s*([\w_]+)/) {
42 if ($line =~ /^\s*(menu|choice|end|source)/) {
46 $line =~ s/^(\s*source\s+)/$1package\/busybox\/config\//;
48 $line =~ s/(\s+)((CONFIG|FDISK|USING|CROSS|EXTRA|PREFIX|FEATURE|HAVE|BUSYBOX)[\w_]*)/$1BUSYBOX_$2/g;
51 ($cur !~ /^CONFIG/ or $cur eq 'CONFIG_LFS') and do {
52 $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/;
54 if ($line =~ /^\s*default/) {
57 $c = $config{$cur} or $c = 'n';
59 $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/;