diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-14 20:59:02 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-14 20:59:02 -0500 |
commit | 1e6c4dfdeb040b2dd5c4d6d803ab95c3971ad80c (patch) | |
tree | 594366f7c9e9ab8a54d2b82121c8802b1950ead6 /scripts | |
parent | 51be08419dc86c72486ac556aa39bc01026a403d (diff) | |
parent | 364212fddaaa60c5a64f67a0f5624ad996ecc8a0 (diff) |
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
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/streamline_config.pl | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index ec7afce4c88d..bccf07ddd0b6 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
@@ -250,33 +250,61 @@ if ($kconfig) { | |||
250 | read_kconfig($kconfig); | 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 | # Read all Makefiles to map the configs to the objects | 275 | # Read all Makefiles to map the configs to the objects |
254 | foreach my $makefile (@makefiles) { | 276 | foreach my $makefile (@makefiles) { |
255 | 277 | ||
256 | my $cont = 0; | 278 | my $line = ""; |
279 | my %make_vars; | ||
257 | 280 | ||
258 | open(MIN,$makefile) || die "Can't open $makefile"; | 281 | open(MIN,$makefile) || die "Can't open $makefile"; |
259 | while (<MIN>) { | 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 | my $objs; | 294 | my $objs; |
261 | 295 | ||
262 | # is this a line after a line with a backslash? | 296 | $_ = convert_vars($_, %make_vars); |
263 | if ($cont && /(\S.*)$/) { | ||
264 | $objs = $1; | ||
265 | } | ||
266 | $cont = 0; | ||
267 | 297 | ||
268 | # collect objects after obj-$(CONFIG_FOO_BAR) | 298 | # collect objects after obj-$(CONFIG_FOO_BAR) |
269 | if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { | 299 | if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { |
270 | $var = $1; | 300 | $var = $1; |
271 | $objs = $2; | 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 | if (defined($objs)) { | 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 | foreach my $obj (split /\s+/,$objs) { | 308 | foreach my $obj (split /\s+/,$objs) { |
281 | $obj =~ s/-/_/g; | 309 | $obj =~ s/-/_/g; |
282 | if ($obj =~ /(.*)\.o$/) { | 310 | if ($obj =~ /(.*)\.o$/) { |