From c0a57d0b9eb38dd291d535d94fa75c360c69a4eb Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 7 Apr 2016 07:52:01 +0100 Subject: [PATCH] Fix semantics of empty string in mkfiles.pl "!cflags". Previously, if you tried to set the special cflags for an object file to the empty string, mkfiles.pl would normalise that to the string "1". I'm not entirely sure why - that line of code was added without explanation in commit 64150a5ef which brought in that directive in the first place - but I have to guess that it was left over from some earlier design iteration in which I hadn't quite decided whether I was going to need a string or a boolean to separate version.o from other objects. Of course, setting an object's cflags to "" is a bit of a weird thing to want to do anyway - why not just leave them unset? But in fact I've now thought of something useful for it to do: this commit arranges that setting cflags="" has the effect (in the 'am' makefile type) of separating the object out into its own little automake library but not actually giving that library any separate cflags. And the point of _that_, in turn, will be that then you can add cflags to it _conditionally_ in a "!begin am" snippet, e.g. conditionalised on something in configure. --- mkfiles.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mkfiles.pl b/mkfiles.pl index a96aa9ae..1e930327 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -84,7 +84,15 @@ while () { if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;} if ($_[0] eq "!cflags" and &mfval($_[1])) { ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line - $rest = 1 if $rest eq ""; + if ($rest eq "") { + # Make sure this file doesn't get lumped together with any + # other file's cflags. + $rest = "F" . $_[2]; + } else { + # Give this file a specific set of cflags, but permit it to + # go together with other files using the same set. + $rest = "C" . $rest; + } $cflags{$_[1]}->{$_[2]} = $rest; next; } @@ -1552,9 +1560,11 @@ if (defined $makefiles{'am'}) { %amspeciallibs = (); foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) { + my $flags = $cflags{'am'}->{$obj}; + $flags = "" if $flags !~ s/^C//; print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n"; print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags, - $cflags{'am'}->{$obj}), "\n"; + $flags), "\n"; $amspeciallibs{$obj} = "lib${obj}.a"; } print &splitline(join " ", "noinst_LIBRARIES", "=", -- 2.45.2