]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix semantics of empty string in mkfiles.pl "!cflags".
authorSimon Tatham <anakin@pobox.com>
Thu, 7 Apr 2016 06:52:01 +0000 (07:52 +0100)
committerSimon Tatham <anakin@pobox.com>
Thu, 7 Apr 2016 06:52:01 +0000 (07:52 +0100)
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

index a96aa9ae9b4cea88f06fe471a699b58cd6059dfb..1e9303270d4c910c26b87510f00c9f51fbcaac84 100755 (executable)
@@ -84,7 +84,15 @@ while (<IN>) {
   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", "=",