6 print "Reading config's ...\n";
10 while (defined($config = readdir(DIR))) {
12 next if $config !~ /^config\..*/;
13 # Nothing that is disabled, or remnant
14 next if $config =~ /.*\.(default|disabled|stub)$/;
16 %{$allconfigs{$config}} = ();
18 print " processing $config ... ";
20 open(CONFIG, "< $config");
24 /^#*\s*CONFIG_(\w+)[\s=](.*)$/ or next;
26 ${$allconfigs{$config}}{$1} = $2;
40 print "Merging lists ... \n";
42 # %options - pointer to flavour config inside the allconfigs array
43 for $config (keys(%allconfigs)) {
44 my %options = %{$allconfigs{$config}};
46 print " processing $config ... ";
48 for $key (keys(%common)) {
49 next if not defined $common{$key};
51 # If we don't have the common option, then it isn't
52 # common. If we do have that option, it must have the same
53 # value. EXCEPT where this file does not have a value at all
54 # which may safely be merged with any other value; the value
55 # will be elided during recombination of the parts.
56 if (!defined($options{$key})) {
57 # Its ok really ... let it merge
58 } elsif (not defined($options{$key})) {
60 } elsif ($common{$key} ne $options{$key}) {
70 print "Creating common config ... ";
72 open(COMMON, "> config.common");
73 print COMMON "#\n# Common config options automatically generated by splitconfig.pl\n#\n";
75 for $key (sort(keys(%common))) {
76 if (not defined $common{$key}) {
77 print COMMON "# CONFIG_$key is UNMERGABLE\n";
78 } elsif ($common{$key} eq "is not set") {
79 print COMMON "# CONFIG_$key is not set\n";
81 print COMMON "CONFIG_$key=$common{$key}\n";
88 print "Creating stub configs ...\n";
90 for $config (keys(%allconfigs)) {
91 my %options = %{$allconfigs{$config}};
93 print " processing $config ... ";
95 open(STUB, "> $config");
96 print STUB "#\n# Config options for $config automatically generated by splitconfig.pl\n#\n";
98 for $key (sort(keys(%options))) {
99 next if defined $common{$key};
101 if ($options{$key} =~ /^is /) {
102 print STUB "# CONFIG_$key $options{$key}\n";
104 print STUB "CONFIG_$key=$options{$key}\n";