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';
12 my $DEFCONFIG = $ARGV[1];
13 ($DEFCONFIG and -f $DEFCONFIG) or die 'invalid config file';
17 open CONFIG, $DEFCONFIG or die 'cannot open config file';
19 /^([\w_]+)=([ym])/ and $config{$1} = $2;
20 /^([\w_]+)=(\d+)/ and $config{$1} = $2;
21 /^([\w_]+)=(".+")/ and $config{$1} = $2;
25 open FIND, "find \"$PATH\" -name Config.in |";
30 s/sysdeps\/linux\///g;
32 print STDERR "$input => $output\n";
33 $output =~ /^(.+)\/[^\/]+$/ and system("mkdir -p $1");
36 open OUTPUT, ">$output";
37 my ($cur, $default_set, $line);
38 while ($line = <INPUT>) {
39 next if $line =~ /^\s*mainmenu/;
41 # FIXME: make this dynamic
42 $line =~ s/default CONFIG_FEATURE_BUFFERS_USE_MALLOC/default CONFIG_FEATURE_BUFFERS_GO_ON_STACK/;
43 $line =~ s/default BUSYBOX_CONFIG_FEATURE_SH_IS_NONE/default BUSYBOX_CONFIG_FEATURE_SH_IS_ASH/;
45 if ($line =~ /^\s*config\s*([\w_]+)/) {
49 if ($line =~ /^\s*(menu|choice|end|source)/) {
53 $line =~ s/^(\s*source\s+)/$1package\/busybox\/config\//;
55 $line =~ s/(\s+)((CONFIG|FDISK|USING|CROSS|EXTRA|PREFIX|FEATURE|HAVE|BUSYBOX)[\w_]*)/$1BUSYBOX_$2/g;
58 ($cur !~ /^CONFIG/ or $cur eq 'CONFIG_LFS') and do {
59 $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/;
61 if ($line =~ /^\s*default/) {
64 $c = $config{$cur} or $c = 'n';
66 $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/;