Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | # |
Uwe Kleine-König | cce1dac | 2011-01-24 21:12:01 +0100 | [diff] [blame] | 3 | # Copyright 2005-2009 - Steven Rostedt |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 4 | # Licensed under the terms of the GNU GPL License version 2 |
| 5 | # |
| 6 | # It's simple enough to figure out how this works. |
| 7 | # If not, then you can ask me at stripconfig@goodmis.org |
| 8 | # |
| 9 | # What it does? |
| 10 | # |
| 11 | # If you have installed a Linux kernel from a distribution |
| 12 | # that turns on way too many modules than you need, and |
| 13 | # you only want the modules you use, then this program |
| 14 | # is perfect for you. |
| 15 | # |
| 16 | # It gives you the ability to turn off all the modules that are |
| 17 | # not loaded on your system. |
| 18 | # |
| 19 | # Howto: |
| 20 | # |
| 21 | # 1. Boot up the kernel that you want to stream line the config on. |
| 22 | # 2. Change directory to the directory holding the source of the |
| 23 | # kernel that you just booted. |
| 24 | # 3. Copy the configuraton file to this directory as .config |
| 25 | # 4. Have all your devices that you need modules for connected and |
| 26 | # operational (make sure that their corresponding modules are loaded) |
| 27 | # 5. Run this script redirecting the output to some other file |
| 28 | # like config_strip. |
| 29 | # 6. Back up your old config (if you want too). |
| 30 | # 7. copy the config_strip file to .config |
| 31 | # 8. Run "make oldconfig" |
| 32 | # |
| 33 | # Now your kernel is ready to be built with only the modules that |
| 34 | # are loaded. |
| 35 | # |
| 36 | # Here's what I did with my Debian distribution. |
| 37 | # |
| 38 | # cd /usr/src/linux-2.6.10 |
| 39 | # cp /boot/config-2.6.10-1-686-smp .config |
| 40 | # ~/bin/streamline_config > config_strip |
| 41 | # mv .config config_sav |
| 42 | # mv config_strip .config |
| 43 | # make oldconfig |
| 44 | # |
hiromu | cf5a189 | 2010-08-17 19:49:18 +0900 | [diff] [blame] | 45 | use strict; |
Arnaud Lacombe | 22d550a | 2011-07-20 00:40:09 -0400 | [diff] [blame] | 46 | use Getopt::Long; |
hiromu | cf5a189 | 2010-08-17 19:49:18 +0900 | [diff] [blame] | 47 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 48 | my $config = ".config"; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 49 | |
Steven Rostedt | cdfc479 | 2009-04-30 14:39:48 -0400 | [diff] [blame] | 50 | my $uname = `uname -r`; |
| 51 | chomp $uname; |
| 52 | |
| 53 | my @searchconfigs = ( |
| 54 | { |
Steven Rostedt | a902483 | 2009-05-07 11:01:34 -0400 | [diff] [blame] | 55 | "file" => ".config", |
| 56 | "exec" => "cat", |
| 57 | }, |
| 58 | { |
Steven Rostedt | cdfc479 | 2009-04-30 14:39:48 -0400 | [diff] [blame] | 59 | "file" => "/proc/config.gz", |
| 60 | "exec" => "zcat", |
| 61 | }, |
| 62 | { |
Steven Rostedt | 810b2be | 2009-04-30 19:30:04 -0400 | [diff] [blame] | 63 | "file" => "/boot/config-$uname", |
| 64 | "exec" => "cat", |
| 65 | }, |
| 66 | { |
Steven Rostedt | cdfc479 | 2009-04-30 14:39:48 -0400 | [diff] [blame] | 67 | "file" => "/boot/vmlinuz-$uname", |
| 68 | "exec" => "scripts/extract-ikconfig", |
| 69 | "test" => "scripts/extract-ikconfig", |
| 70 | }, |
| 71 | { |
| 72 | "file" => "vmlinux", |
| 73 | "exec" => "scripts/extract-ikconfig", |
| 74 | "test" => "scripts/extract-ikconfig", |
| 75 | }, |
| 76 | { |
| 77 | "file" => "/lib/modules/$uname/kernel/kernel/configs.ko", |
| 78 | "exec" => "scripts/extract-ikconfig", |
| 79 | "test" => "scripts/extract-ikconfig", |
| 80 | }, |
| 81 | { |
| 82 | "file" => "kernel/configs.ko", |
| 83 | "exec" => "scripts/extract-ikconfig", |
| 84 | "test" => "scripts/extract-ikconfig", |
| 85 | }, |
| 86 | { |
| 87 | "file" => "kernel/configs.o", |
| 88 | "exec" => "scripts/extract-ikconfig", |
| 89 | "test" => "scripts/extract-ikconfig", |
| 90 | }, |
Steven Rostedt | cdfc479 | 2009-04-30 14:39:48 -0400 | [diff] [blame] | 91 | ); |
| 92 | |
| 93 | sub find_config { |
| 94 | foreach my $conf (@searchconfigs) { |
| 95 | my $file = $conf->{"file"}; |
| 96 | |
| 97 | next if ( ! -f "$file"); |
| 98 | |
| 99 | if (defined($conf->{"test"})) { |
| 100 | `$conf->{"test"} $conf->{"file"} 2>/dev/null`; |
| 101 | next if ($?); |
| 102 | } |
| 103 | |
| 104 | my $exec = $conf->{"exec"}; |
| 105 | |
| 106 | print STDERR "using config: '$file'\n"; |
| 107 | |
| 108 | open(CIN, "$exec $file |") || die "Failed to run $exec $file"; |
| 109 | return; |
| 110 | } |
| 111 | die "No config file found"; |
| 112 | } |
| 113 | |
| 114 | find_config; |
| 115 | |
Arnaud Lacombe | 22d550a | 2011-07-20 00:40:09 -0400 | [diff] [blame] | 116 | # Parse options |
| 117 | my $localmodconfig = 0; |
| 118 | my $localyesconfig = 0; |
| 119 | |
| 120 | GetOptions("localmodconfig" => \$localmodconfig, |
| 121 | "localyesconfig" => \$localyesconfig); |
| 122 | |
Steven Rostedt | 463bf90 | 2009-11-20 09:21:12 -0500 | [diff] [blame] | 123 | # Get the build source and top level Kconfig file (passed in) |
| 124 | my $ksource = $ARGV[0]; |
| 125 | my $kconfig = $ARGV[1]; |
Arnaud Lacombe | f597a71 | 2011-07-01 17:45:31 -0400 | [diff] [blame] | 126 | my $lsmod_file = $ENV{'LSMOD'}; |
Steven Rostedt | 463bf90 | 2009-11-20 09:21:12 -0500 | [diff] [blame] | 127 | |
Toralf Förster | 1743192 | 2010-05-26 20:22:02 +0200 | [diff] [blame] | 128 | my @makefiles = `find $ksource -name Makefile 2>/dev/null`; |
| 129 | chomp @makefiles; |
| 130 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 131 | my %depends; |
| 132 | my %selects; |
| 133 | my %prompts; |
| 134 | my %objects; |
| 135 | my $var; |
Steven Rostedt | 13d7e93 | 2010-01-06 17:56:12 -0500 | [diff] [blame] | 136 | my $iflevel = 0; |
| 137 | my @ifdeps; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 138 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 139 | # prevent recursion |
| 140 | my %read_kconfigs; |
| 141 | |
| 142 | sub read_kconfig { |
| 143 | my ($kconfig) = @_; |
| 144 | |
| 145 | my $state = "NONE"; |
| 146 | my $config; |
| 147 | my @kconfigs; |
| 148 | |
Steven Rostedt | 20d1904 | 2010-10-28 22:13:51 -0400 | [diff] [blame] | 149 | my $cont = 0; |
| 150 | my $line; |
| 151 | |
Steven Rostedt | 4908980 | 2010-10-29 00:56:46 -0400 | [diff] [blame] | 152 | my $source = "$ksource/$kconfig"; |
| 153 | my $last_source = ""; |
| 154 | |
| 155 | # Check for any environment variables used |
| 156 | while ($source =~ /\$(\w+)/ && $last_source ne $source) { |
| 157 | my $env = $1; |
| 158 | $last_source = $source; |
| 159 | $source =~ s/\$$env/$ENV{$env}/; |
| 160 | } |
| 161 | |
| 162 | open(KIN, "$source") || die "Can't open $kconfig"; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 163 | while (<KIN>) { |
| 164 | chomp; |
| 165 | |
Steven Rostedt | 20d1904 | 2010-10-28 22:13:51 -0400 | [diff] [blame] | 166 | # Make sure that lines ending with \ continue |
| 167 | if ($cont) { |
| 168 | $_ = $line . " " . $_; |
| 169 | } |
| 170 | |
| 171 | if (s/\\$//) { |
| 172 | $cont = 1; |
| 173 | $line = $_; |
| 174 | next; |
| 175 | } |
| 176 | |
| 177 | $cont = 0; |
| 178 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 179 | # collect any Kconfig sources |
| 180 | if (/^source\s*"(.*)"/) { |
| 181 | $kconfigs[$#kconfigs+1] = $1; |
| 182 | } |
| 183 | |
| 184 | # configs found |
Steven Rostedt | 8ef17fa | 2010-10-28 22:21:57 -0400 | [diff] [blame] | 185 | if (/^\s*(menu)?config\s+(\S+)\s*$/) { |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 186 | $state = "NEW"; |
Steven Rostedt | 8ef17fa | 2010-10-28 22:21:57 -0400 | [diff] [blame] | 187 | $config = $2; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 188 | |
Steven Rostedt | 13d7e93 | 2010-01-06 17:56:12 -0500 | [diff] [blame] | 189 | for (my $i = 0; $i < $iflevel; $i++) { |
| 190 | if ($i) { |
| 191 | $depends{$config} .= " " . $ifdeps[$i]; |
| 192 | } else { |
| 193 | $depends{$config} = $ifdeps[$i]; |
| 194 | } |
| 195 | $state = "DEP"; |
| 196 | } |
| 197 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 198 | # collect the depends for the config |
| 199 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { |
| 200 | $state = "DEP"; |
| 201 | $depends{$config} = $1; |
| 202 | } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) { |
| 203 | $depends{$config} .= " " . $1; |
| 204 | |
| 205 | # Get the configs that select this config |
| 206 | } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { |
| 207 | if (defined($selects{$1})) { |
| 208 | $selects{$1} .= " " . $config; |
| 209 | } else { |
| 210 | $selects{$1} = $config; |
| 211 | } |
| 212 | |
| 213 | # configs without prompts must be selected |
| 214 | } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { |
| 215 | # note if the config has a prompt |
hiromu yagura | ccece60 | 2010-08-15 13:13:17 +0900 | [diff] [blame] | 216 | $prompts{$config} = 1; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 217 | |
Steven Rostedt | 13d7e93 | 2010-01-06 17:56:12 -0500 | [diff] [blame] | 218 | # Check for if statements |
| 219 | } elsif (/^if\s+(.*\S)\s*$/) { |
| 220 | my $deps = $1; |
| 221 | # remove beginning and ending non text |
| 222 | $deps =~ s/^[^a-zA-Z0-9_]*//; |
| 223 | $deps =~ s/[^a-zA-Z0-9_]*$//; |
| 224 | |
| 225 | my @deps = split /[^a-zA-Z0-9_]+/, $deps; |
| 226 | |
| 227 | $ifdeps[$iflevel++] = join ':', @deps; |
| 228 | |
| 229 | } elsif (/^endif/) { |
| 230 | |
| 231 | $iflevel-- if ($iflevel); |
| 232 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 233 | # stop on "help" |
| 234 | } elsif (/^\s*help\s*$/) { |
| 235 | $state = "NONE"; |
| 236 | } |
| 237 | } |
| 238 | close(KIN); |
| 239 | |
| 240 | # read in any configs that were found. |
| 241 | foreach $kconfig (@kconfigs) { |
| 242 | if (!defined($read_kconfigs{$kconfig})) { |
| 243 | $read_kconfigs{$kconfig} = 1; |
| 244 | read_kconfig($kconfig); |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if ($kconfig) { |
| 250 | read_kconfig($kconfig); |
| 251 | } |
| 252 | |
Steven Rostedt | 364212f | 2012-01-13 17:53:40 -0500 | [diff] [blame] | 253 | sub convert_vars { |
| 254 | my ($line, %vars) = @_; |
| 255 | |
| 256 | my $process = ""; |
| 257 | |
| 258 | while ($line =~ s/^(.*?)(\$\((.*?)\))//) { |
| 259 | my $start = $1; |
| 260 | my $variable = $2; |
| 261 | my $var = $3; |
| 262 | |
| 263 | if (defined($vars{$var})) { |
| 264 | $process .= $start . $vars{$var}; |
| 265 | } else { |
| 266 | $process .= $start . $variable; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | $process .= $line; |
| 271 | |
| 272 | return $process; |
| 273 | } |
| 274 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 275 | # Read all Makefiles to map the configs to the objects |
| 276 | foreach my $makefile (@makefiles) { |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 277 | |
Steven Rostedt | d060d96 | 2012-01-13 17:50:39 -0500 | [diff] [blame] | 278 | my $line = ""; |
Steven Rostedt | 364212f | 2012-01-13 17:53:40 -0500 | [diff] [blame] | 279 | my %make_vars; |
Steven Rostedt | 20d1904 | 2010-10-28 22:13:51 -0400 | [diff] [blame] | 280 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 281 | open(MIN,$makefile) || die "Can't open $makefile"; |
| 282 | while (<MIN>) { |
Steven Rostedt | d060d96 | 2012-01-13 17:50:39 -0500 | [diff] [blame] | 283 | # if this line ends with a backslash, continue |
| 284 | chomp; |
| 285 | if (/^(.*)\\$/) { |
| 286 | $line .= $1; |
| 287 | next; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 288 | } |
Steven Rostedt | d060d96 | 2012-01-13 17:50:39 -0500 | [diff] [blame] | 289 | |
| 290 | $line .= $_; |
| 291 | $_ = $line; |
| 292 | $line = ""; |
| 293 | |
| 294 | my $objs; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 295 | |
Steven Rostedt | 364212f | 2012-01-13 17:53:40 -0500 | [diff] [blame] | 296 | $_ = convert_vars($_, %make_vars); |
| 297 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 298 | # collect objects after obj-$(CONFIG_FOO_BAR) |
| 299 | if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { |
| 300 | $var = $1; |
| 301 | $objs = $2; |
Steven Rostedt | 364212f | 2012-01-13 17:53:40 -0500 | [diff] [blame] | 302 | |
| 303 | # check if variables are set |
| 304 | } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) { |
| 305 | $make_vars{$1} = $2; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 306 | } |
| 307 | if (defined($objs)) { |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 308 | foreach my $obj (split /\s+/,$objs) { |
| 309 | $obj =~ s/-/_/g; |
| 310 | if ($obj =~ /(.*)\.o$/) { |
Toralf Foerster | 1d1d1fe | 2010-05-28 10:25:52 +0200 | [diff] [blame] | 311 | # Objects may be enabled by more than one config. |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 312 | # Store configs in an array. |
| 313 | my @arr; |
| 314 | |
| 315 | if (defined($objects{$1})) { |
| 316 | @arr = @{$objects{$1}}; |
| 317 | } |
| 318 | |
| 319 | $arr[$#arr+1] = $var; |
| 320 | |
| 321 | # The objects have a hash mapping to a reference |
| 322 | # of an array of configs. |
| 323 | $objects{$1} = \@arr; |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | close(MIN); |
| 329 | } |
| 330 | |
| 331 | my %modules; |
| 332 | |
Steven Rostedt | 615f083 | 2010-02-02 21:51:27 -0500 | [diff] [blame] | 333 | if (defined($lsmod_file)) { |
| 334 | if ( ! -f $lsmod_file) { |
Arnaud Lacombe | f597a71 | 2011-07-01 17:45:31 -0400 | [diff] [blame] | 335 | if ( -f $ENV{'objtree'}."/".$lsmod_file) { |
| 336 | $lsmod_file = $ENV{'objtree'}."/".$lsmod_file; |
| 337 | } else { |
| 338 | die "$lsmod_file not found"; |
| 339 | } |
Steven Rostedt | 88f66ea | 2010-01-06 18:49:44 -0500 | [diff] [blame] | 340 | } |
Steven Rostedt | 615f083 | 2010-02-02 21:51:27 -0500 | [diff] [blame] | 341 | if ( -x $lsmod_file) { |
| 342 | # the file is executable, run it |
| 343 | open(LIN, "$lsmod_file|"); |
| 344 | } else { |
| 345 | # Just read the contents |
| 346 | open(LIN, "$lsmod_file"); |
| 347 | } |
| 348 | } else { |
| 349 | |
| 350 | # see what modules are loaded on this system |
| 351 | my $lsmod; |
| 352 | |
hiromu | cf5a189 | 2010-08-17 19:49:18 +0900 | [diff] [blame] | 353 | foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) { |
Steven Rostedt | 615f083 | 2010-02-02 21:51:27 -0500 | [diff] [blame] | 354 | if ( -x "$dir/lsmod" ) { |
| 355 | $lsmod = "$dir/lsmod"; |
| 356 | last; |
| 357 | } |
Steven Rostedt | 88f66ea | 2010-01-06 18:49:44 -0500 | [diff] [blame] | 358 | } |
Steven Rostedt | 615f083 | 2010-02-02 21:51:27 -0500 | [diff] [blame] | 359 | if (!defined($lsmod)) { |
| 360 | # try just the path |
| 361 | $lsmod = "lsmod"; |
| 362 | } |
| 363 | |
| 364 | open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; |
Steven Rostedt | 88f66ea | 2010-01-06 18:49:44 -0500 | [diff] [blame] | 365 | } |
| 366 | |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 367 | while (<LIN>) { |
| 368 | next if (/^Module/); # Skip the first line. |
| 369 | if (/^(\S+)/) { |
| 370 | $modules{$1} = 1; |
| 371 | } |
| 372 | } |
| 373 | close (LIN); |
| 374 | |
| 375 | # add to the configs hash all configs that are needed to enable |
| 376 | # a loaded module. |
| 377 | my %configs; |
| 378 | foreach my $module (keys(%modules)) { |
| 379 | if (defined($objects{$module})) { |
Toralf Foerster | e5199ed | 2010-05-28 10:24:59 +0200 | [diff] [blame] | 380 | my @arr = @{$objects{$module}}; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 381 | foreach my $conf (@arr) { |
| 382 | $configs{$conf} = $module; |
| 383 | } |
| 384 | } else { |
| 385 | # Most likely, someone has a custom (binary?) module loaded. |
| 386 | print STDERR "$module config not found!!\n"; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | my $valid = "A-Za-z_0-9"; |
| 391 | my $repeat = 1; |
| 392 | |
| 393 | # |
| 394 | # Note, we do not care about operands (like: &&, ||, !) we want to add any |
| 395 | # config that is in the depend list of another config. This script does |
| 396 | # not enable configs that are not already enabled. If we come across a |
| 397 | # config A that depends on !B, we can still add B to the list of depends |
| 398 | # to keep on. If A was on in the original config, B would not have been |
| 399 | # and B would not be turned on by this script. |
| 400 | # |
| 401 | sub parse_config_dep_select |
| 402 | { |
| 403 | my ($p) = @_; |
| 404 | |
| 405 | while ($p =~ /[$valid]/) { |
| 406 | |
| 407 | if ($p =~ /^[^$valid]*([$valid]+)/) { |
| 408 | my $conf = "CONFIG_" . $1; |
| 409 | |
| 410 | $p =~ s/^[^$valid]*[$valid]+//; |
| 411 | |
| 412 | if (!defined($configs{$conf})) { |
| 413 | # We must make sure that this config has its |
| 414 | # dependencies met. |
| 415 | $repeat = 1; # do again |
| 416 | $configs{$conf} = 1; |
| 417 | } |
| 418 | } else { |
| 419 | die "this should never happen"; |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | while ($repeat) { |
| 425 | $repeat = 0; |
| 426 | |
| 427 | foreach my $config (keys %configs) { |
| 428 | $config =~ s/^CONFIG_//; |
| 429 | |
Steven Rostedt | 74398d3 | 2009-04-30 10:17:51 -0400 | [diff] [blame] | 430 | if (defined($depends{$config})) { |
| 431 | # This config has dependencies. Make sure they are also included |
| 432 | parse_config_dep_select $depends{$config}; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 433 | } |
| 434 | |
hiromu yagura | ccece60 | 2010-08-15 13:13:17 +0900 | [diff] [blame] | 435 | if (defined($prompts{$config}) || !defined($selects{$config})) { |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 436 | next; |
| 437 | } |
| 438 | |
| 439 | # config has no prompt and must be selected. |
| 440 | parse_config_dep_select $selects{$config}; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | my %setconfigs; |
| 445 | |
| 446 | # Finally, read the .config file and turn off any module enabled that |
| 447 | # we could not find a reason to keep enabled. |
| 448 | while(<CIN>) { |
Steven Rostedt | 744ffcb | 2009-04-30 12:15:10 -0400 | [diff] [blame] | 449 | |
| 450 | if (/CONFIG_IKCONFIG/) { |
| 451 | if (/# CONFIG_IKCONFIG is not set/) { |
| 452 | # enable IKCONFIG at least as a module |
| 453 | print "CONFIG_IKCONFIG=m\n"; |
| 454 | # don't ask about PROC |
Steven Rostedt | d08ca27 | 2009-04-30 19:24:00 -0400 | [diff] [blame] | 455 | print "# CONFIG_IKCONFIG_PROC is not set\n"; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 456 | } else { |
Steven Rostedt | 744ffcb | 2009-04-30 12:15:10 -0400 | [diff] [blame] | 457 | print; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 458 | } |
Steven Rostedt | 744ffcb | 2009-04-30 12:15:10 -0400 | [diff] [blame] | 459 | next; |
| 460 | } |
| 461 | |
| 462 | if (/^(CONFIG.*)=(m|y)/) { |
| 463 | if (defined($configs{$1})) { |
Arnaud Lacombe | 22d550a | 2011-07-20 00:40:09 -0400 | [diff] [blame] | 464 | if ($localyesconfig) { |
| 465 | $setconfigs{$1} = 'y'; |
| 466 | } else { |
| 467 | $setconfigs{$1} = $2; |
| 468 | } |
Steven Rostedt | 744ffcb | 2009-04-30 12:15:10 -0400 | [diff] [blame] | 469 | } elsif ($2 eq "m") { |
| 470 | print "# $1 is not set\n"; |
Steven Rostedt | d08ca27 | 2009-04-30 19:24:00 -0400 | [diff] [blame] | 471 | next; |
Steven Rostedt | 744ffcb | 2009-04-30 12:15:10 -0400 | [diff] [blame] | 472 | } |
Steven Rostedt | 744ffcb | 2009-04-30 12:15:10 -0400 | [diff] [blame] | 473 | } |
Steven Rostedt | d08ca27 | 2009-04-30 19:24:00 -0400 | [diff] [blame] | 474 | print; |
Steven Rostedt | dcc6024 | 2009-04-29 22:52:21 -0400 | [diff] [blame] | 475 | } |
| 476 | close(CIN); |
| 477 | |
| 478 | # Integrity check, make sure all modules that we want enabled do |
| 479 | # indeed have their configs set. |
| 480 | loop: |
| 481 | foreach my $module (keys(%modules)) { |
| 482 | if (defined($objects{$module})) { |
| 483 | my @arr = @{$objects{$module}}; |
| 484 | foreach my $conf (@arr) { |
| 485 | if (defined($setconfigs{$conf})) { |
| 486 | next loop; |
| 487 | } |
| 488 | } |
| 489 | print STDERR "module $module did not have configs"; |
| 490 | foreach my $conf (@arr) { |
| 491 | print STDERR " " , $conf; |
| 492 | } |
| 493 | print STDERR "\n"; |
| 494 | } |
| 495 | } |