Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-kconfig

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-kconfig:
kconfig/streamline-config.pl: Fix parsing Makefile with variables
kconfig/streamline-config.pl: Simplify backslash line concatination

+40 -12
+40 -12
scripts/kconfig/streamline_config.pl
··· 250 250 read_kconfig($kconfig); 251 251 } 252 252 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 + 253 275 # Read all Makefiles to map the configs to the objects 254 276 foreach my $makefile (@makefiles) { 255 277 256 - my $cont = 0; 278 + my $line = ""; 279 + my %make_vars; 257 280 258 281 open(MIN,$makefile) || die "Can't open $makefile"; 259 282 while (<MIN>) { 283 + # if this line ends with a backslash, continue 284 + chomp; 285 + if (/^(.*)\\$/) { 286 + $line .= $1; 287 + next; 288 + } 289 + 290 + $line .= $_; 291 + $_ = $line; 292 + $line = ""; 293 + 260 294 my $objs; 261 295 262 - # is this a line after a line with a backslash? 263 - if ($cont && /(\S.*)$/) { 264 - $objs = $1; 265 - } 266 - $cont = 0; 296 + $_ = convert_vars($_, %make_vars); 267 297 268 298 # collect objects after obj-$(CONFIG_FOO_BAR) 269 299 if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { 270 300 $var = $1; 271 301 $objs = $2; 302 + 303 + # check if variables are set 304 + } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) { 305 + $make_vars{$1} = $2; 272 306 } 273 307 if (defined($objs)) { 274 - # test if the line ends with a backslash 275 - if ($objs =~ m,(.*)\\$,) { 276 - $objs = $1; 277 - $cont = 1; 278 - } 279 - 280 308 foreach my $obj (split /\s+/,$objs) { 281 309 $obj =~ s/-/_/g; 282 310 if ($obj =~ /(.*)\.o$/) {