diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-08-03 04:15:16 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:31:02 -0500 |
commit | 36f64c0f057fc80186e3493f9e723677131c3c34 (patch) | |
tree | dd82b9252f346d5f1ed4bcf57fd31234f4946c38 /source4/build/smb_build/config_mk.pm | |
parent | 26daec8d09b88b7758505d6fe732ea8f57fbf05c (diff) | |
download | samba-36f64c0f057fc80186e3493f9e723677131c3c34.tar.gz samba-36f64c0f057fc80186e3493f9e723677131c3c34.tar.bz2 samba-36f64c0f057fc80186e3493f9e723677131c3c34.zip |
r8979: Bunch of makefile fragment inclusion fixes:
- support whitespace
- support "include " keyword
- move swig stuff to .mk file
- support autogenerated makefile portions (use "include echo foo|")
(This used to be commit 43779c09b6a75e03f4cf6e8953a837cddd318aa5)
Diffstat (limited to 'source4/build/smb_build/config_mk.pm')
-rw-r--r-- | source4/build/smb_build/config_mk.pm | 95 |
1 files changed, 34 insertions, 61 deletions
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm index 274a2aab8b..c5a035f375 100644 --- a/source4/build/smb_build/config_mk.pm +++ b/source4/build/smb_build/config_mk.pm @@ -40,67 +40,68 @@ my %attribute_types = ( # # $filename - the path of the config.mk file # which should be parsed -# -# $result - the resulting structure -# -# $result->{ERROR_CODE} - the error_code, '0' means success -# $result->{ERROR_STR} - the error string -# -# $result->{$key}{KEY} - the key == the variable which was parsed -# $result->{$key}{VAL} - the value of the variable -sub _parse_config_mk($) +sub run_config_mk($$) { - my $filename = shift; + my ($input, $filename) = @_; my $result; my $linenum = -1; - my $waiting = 0; + my $infragment = 0; my $section = "GLOBAL"; my $makefile = ""; + + open(CONFIG_MK, $filename) or die("Can't open `$filename'\n"); + my @lines = <CONFIG_MK>; + close(CONFIG_MK); - open(CONFIG_MK, "<$filename") or die("Can't open `$filename'\n"); - - while (<CONFIG_MK>) { - my $line = $_; + my $line = ""; + my $prev = ""; + foreach (@lines) { $linenum++; # lines beginning with '#' are ignored - next if ($line =~ /^\#.*$/); + next if (/^\#.*$/); + + if (/^(.*)\\$/) { + $prev .= $1; + next; + } else { + $line = "$prev$_"; + $prev = ""; + } - if (not $waiting and ($line =~ /^\[([a-zA-Z0-9_:]+)\][\t ]*$/)) + if ($line =~ /^\[([a-zA-Z0-9_:]+)\][\t ]*$/) { $section = $1; + $infragment = 0; + next; + } + + # include + if ($line =~ /^include (.*)$/) { + $makefile .= run_config_mk($input, $1); next; } # empty line if ($line =~ /^[ \t]*$/) { - $waiting = 0; $section = "GLOBAL"; + if ($infragment) { $makefile.="\n"; } next; } # global stuff is considered part of the makefile if ($section eq "GLOBAL") { $makefile .= $line; + $infragment = 1; next; } + # Assignment - if (not $waiting and - ($line =~ /^([a-zA-Z0-9_]+)([\t ]*)=(.*)$/)) { - my $key = $1; - my $val = $3; - - # Continuing lines - if ($val =~ /^(.*)\\$/) { - $val = $1; - ($val.= " $1") while(($line = <CONFIG_MK>) =~ /^[\t ]*(.*)\\$/); - $val .= $line; - } - - $result->{$section}{$key}{KEY} = $key; - $result->{$section}{$key}{VAL} = $val; + if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) { + $result->{$section}{$1}{VAL} = $2; + $result->{$section}{$1}{KEY} = $1; next; } @@ -108,17 +109,6 @@ sub _parse_config_mk($) die("$filename:$linenum: Bad line while parsing $filename"); } - close(CONFIG_MK); - - return ($result,$makefile); -} - -sub import_file($$) -{ - my ($input, $filename) = @_; - - my ($result, $makefile) = _parse_config_mk($filename); - foreach my $section (keys %{$result}) { my ($type, $name) = split(/::/, $section, 2); @@ -143,25 +133,8 @@ sub import_file($$) } } } - + return $makefile; } -sub import_files($$) -{ - my ($input, $config_list) = @_; - - open(IN, $config_list) or die("Can't open $config_list: $!"); - my @mkfiles = grep{!/^#/} <IN>; - close(IN); - - $| = 1; - my $makefragment = ""; - - foreach (@mkfiles) { - s/\n//g; - $makefragment.= import_file($input, $_); - } - return $makefragment; -} 1; |