From: Nick Bowler Date: Sat, 22 Oct 2011 17:37:27 +0000 (-0400) Subject: Mangle spliced makefile lines in Gnulib correctly. X-Git-Url: http://git.draconx.ca/gitweb/dxcommon.git/commitdiff_plain/8c2b7b249f46844af925b1f19ab5f8d242b392f3 Mangle spliced makefile lines in Gnulib correctly. Otherwise, target and variable mangling may only apply to the first line. --- diff --git a/scripts/fix-gnulib.pl b/scripts/fix-gnulib.pl index 834fb7a..ee7a0c9 100755 --- a/scripts/fix-gnulib.pl +++ b/scripts/fix-gnulib.pl @@ -17,6 +17,8 @@ my $input = undef; my $m4output = undef; my $m4macro = "DX_FIX_GNULIB"; +my $line = 0; + Getopt::Long::Configure("gnu_getopt", "no_auto_abbrev"); GetOptions( "o|output=s" => \$output, @@ -56,7 +58,7 @@ sub mangle_file { # Fix up things that look like filenames. $word = "lib/$word"; } else { - print STDERR "$0: warning: unrecognized source file: $word\n"; + print STDERR "$0:$line: warning: unrecognized source file: $word\n"; } return "$word"; @@ -65,7 +67,7 @@ sub mangle_file { sub mangle_variable { my $raw = shift; - $raw =~ /([^=]+=)[[:space:]]*(.*)/; + $raw =~ /([^=]+=)[[:space:]]*(.*)/s; my ($left, @right) = ($1, split(/[[:space:]]+/, $2)); return join(" ", ($left, map(mangle_file($_), @right))) . "\n"; @@ -74,7 +76,7 @@ sub mangle_variable { sub mangle_target { my $raw = shift; - $raw =~ /([^:]+):[[:space:]]*(.*)/; + $raw =~ /([^:]+):[[:space:]]*(.*)/s; my @left = split(/[[:space:]]+/, $1); my @right = split(/[[:space:]]+/, $2); @@ -85,6 +87,14 @@ sub mangle_target { } while () { + $line++; + + # Combine line splices. + while (s/\\$//) { + $line++; + $_ = $_ . + } + next if (/^#/); if (!$printed_header) { @@ -147,7 +157,7 @@ EOF # Targets are similar to variables: the target and its dependencies # need to be mangled. - if (/:/) { + if (/^[^\t].*:/) { $_ = mangle_target($_); } @@ -164,7 +174,7 @@ EOF # Finally, references to $(srcdir) and $(builddir) need to be fixed up. s:\$\(srcdir\):\$\(top_srcdir\)/lib:g; s:\$\(builddir\):\$\(top_builddir\)/lib:g; -} continue { print }; +} continue { s/(\n.)/\\\1/g; print; }; print <<'EOF'; gnulib_lt_objects = $(libgnu_la_OBJECTS) $(gl_LTLIBOBJS)