source: freewrt/scripts/gen_busybox_menuconfig.pl@ fdd4f59

freewrt_1_0 freewrt_2_0
Last change on this file since fdd4f59 was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#!/usr/bin/perl
2use strict;
3my $PATH = $ARGV[0];
4($PATH and -d $PATH) or die 'invalid path';
5my $DEFCONFIG = $ARGV[1];
6($DEFCONFIG and -f $DEFCONFIG) or die 'invalid config file';
7
8my %config;
9
10open CONFIG, $DEFCONFIG or die 'cannot open config file';
11while (<CONFIG>) {
12 /^([\w_]+)=([ym])/ and $config{$1} = $2;
13 /^([\w_]+)=(\d+)/ and $config{$1} = $2;
14 /^([\w_]+)=(".+")/ and $config{$1} = $2;
15}
16close CONFIG;
17
18open FIND, "find \"$PATH\" -name Config.in |";
19while (<FIND>) {
20 chomp;
21 my $input = $_;
22 s/^$PATH\///g;
23 s/sysdeps\/linux\///g;
24 my $output = $_;
25 print STDERR "$input => $output\n";
26 $output =~ /^(.+)\/[^\/]+$/ and system("mkdir -p $1");
27
28 open INPUT, $input;
29 open OUTPUT, ">$output";
30 my ($cur, $default_set, $line);
31 while ($line = <INPUT>) {
32 next if $line =~ /^\s*mainmenu/;
33
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/;
37
38 if ($line =~ /^\s*config\s*([\w_]+)/) {
39 $cur = $1;
40 undef $default_set;
41 }
42 if ($line =~ /^\s*(menu|choice|end|source)/) {
43 undef $cur;
44 undef $default_set;
45 }
46 $line =~ s/^(\s*source\s+)/$1package\/busybox\/config\//;
47
48 $line =~ s/(\s+)((CONFIG|FDISK|USING|CROSS|EXTRA|PREFIX|FEATURE|HAVE|BUSYBOX)[\w_]*)/$1BUSYBOX_$2/g;
49
50 if ($cur) {
51 ($cur !~ /^CONFIG/ or $cur eq 'CONFIG_LFS') and do {
52 $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/;
53 };
54 if ($line =~ /^\s*default/) {
55 my $c;
56 $default_set = 1;
57 $c = $config{$cur} or $c = 'n';
58
59 $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/;
60 }
61 }
62
63 print OUTPUT $line;
64 }
65 close OUTPUT;
66 close INPUT;
67
68}
69close FIND;
Note: See TracBrowser for help on using the repository browser.