mediatek: fix IPv4-only corner case and commit in 99-net-ps
[oweals/openwrt.git] / target / sdk / convert-config.pl
1 #!/usr/bin/env perl
2 use strict;
3
4 while (<>) {
5         my $match;
6         my $var;
7         my $val;
8         my $type;
9         chomp;
10         next if /^CONFIG_SIGNED_PACKAGES/;
11
12         if (/^CONFIG_([^=]+)=(.*)$/) {
13                 $var = $1;
14                 $val = $2;
15
16                 next if $var eq 'ALL';
17
18                 if ($val eq 'y') {
19                         $type = "bool";
20                 } elsif ($val eq 'm') {
21                         $type = "tristate";
22                 } elsif ($val =~ /^".*"$/) {
23                         $type = "string";
24                 } elsif ($val =~ /^\d+$/) {
25                         $type = "int";
26                 } else {
27                         warn "WARNING: no type found for symbol CONFIG_$var=$val\n";
28                         next;
29                 }
30         } elsif (/^# CONFIG_BUSYBOX_(.*) is not set/) {
31                 $var = "BUSYBOX_$1";
32                 $val = 'n';
33                 $type = "bool";
34         } else {
35                 # We don't want to preserve a record of deselecting
36                 # packages because we may want build them in the SDK.
37                 # non-package configs however may be important to preserve
38                 # the same compilation settings for packages that get
39                 # recompiled in the SDK.
40                 # Also we want avoid preserving image generation settings
41                 # because we set those while in ImageBuilder
42                 next if /^(# )?CONFIG_PACKAGE/;
43                 next if /^(# )?CONFIG_TARGET/;
44                 if (/^# CONFIG_(.*) is not set/) {
45                         $var = $1;
46                         $val = 'n';
47                         $type = "bool";
48                 }
49         }
50
51         if (($var ne '') && ($type ne '') && ($val ne '')) {
52                 print <<EOF;
53 config $var
54         $type
55         default $val
56
57 EOF
58         }
59 }