chiark / gitweb /
Fix completion checking in Killer Solo.
[sgt-puzzles.git] / mkfiles.pl
index d532c95204c7340dfefa02b1753ed46b3dd8b3dd..c1623dfd12e82245e91c12d02d0399bf9041e004 100755 (executable)
@@ -57,7 +57,8 @@ eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
 
 @srcdirs = ("./");
 
-$divert = undef; # ref to scalar in which text is currently being put
+$divert = undef; # ref to array of refs of scalars in which text is
+                 # currently being put
 $help = ""; # list of newline-free lines of help text
 $project_name = "project"; # this is a good enough default
 %makefiles = (); # maps makefile types to output makefile pathnames
@@ -83,14 +84,16 @@ readinput: while (1) {
       if ((defined $_[0]) && $_[0] eq "!end") {
          $divert = undef;
       } else {
-         ${$divert} .= "$_\n";
+          for my $ref (@$divert) {
+              ${$ref} .= "$_\n";
+          }
       }
       next;
   }
   # Skip comments and blank lines.
   next if /^\s*#/ or scalar @_ == 0;
 
-  if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
+  if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = [\$help]; next; }
   if ($_[0] eq "!name") { $project_name = $_[1]; next; }
   if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
   if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
@@ -102,10 +105,15 @@ readinput: while (1) {
       next;
   }
   if ($_[0] eq "!begin") {
-      if ($_[1] =~ /^>(.*)/) {
-         $divert = \$auxfiles{$1};
-      } elsif (&mfval($_[1])) {
-         $divert = \$makefile_extra{$_[1]};
+      my @args = @_;
+      shift @args;
+      $divert = [];
+      for my $component (@args) {
+          if ($component =~ /^>(.*)/) {
+              push @$divert, \$auxfiles{$1};
+          } elsif ($component =~ /^([^_]*)(_.*)?$/ and &mfval($1)) {
+              push @$divert, \$makefile_extra{$component};
+          }
       }
       next;
   }
@@ -1181,7 +1189,8 @@ if (defined $makefiles{'gtk'}) {
 
 if (defined $makefiles{'am'}) {
     $mftyp = 'am';
-    $dirpfx = "\$(srcdir)/" . &dirpfx($makefiles{'am'}, "/");
+    die "Makefile.am in a subdirectory is not supported\n"
+        if &dirpfx($makefiles{'am'}, "/") ne "";
 
     ##-- Unix/autoconf Makefile.am
     open OUT, ">$makefiles{'am'}"; select OUT;
@@ -1190,26 +1199,25 @@ if (defined $makefiles{'am'}) {
     "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
     "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
 
-    @binprogs = ();
+    print $makefile_extra{'am_begin'} || "";
+
+    # All programs go in noinstprogs by default. If you want them
+    # installed anywhere else, you have to also add them to
+    # bin_PROGRAMS using '!begin am'. (Automake doesn't seem to mind
+    # having a program name in _both_ of bin_PROGRAMS and
+    # noinst_PROGRAMS.)
     @noinstprogs = ();
     foreach $p (&prognames("X:U")) {
         ($prog, $type) = split ",", $p;
-        if ("FIXME") { # decide which programs go where
-            push @binprogs, # FIXME "\$(BINPREFIX)" .
-                $prog;
-        } else {
-            push @noinstprogs, # FIXME "\$(BINPREFIX)" .
-                $prog;
-        }
+        push @noinstprogs, $prog;
     }
-    print &splitline(join " ", "bin_PROGRAMS", "=", @binprogs), "\n";
     print &splitline(join " ", "noinst_PROGRAMS", "=", @noinstprogs), "\n";
 
     %objtosrc = ();
     %amspeciallibs = ();
     %amlibobjname = ();
     %allsources = ();
-    foreach $d (&deps("X", undef, $dirpfx, "/", "am")) {
+    foreach $d (&deps("X", undef, "", "/", "am")) {
         my $obj = $d->{obj};
         my $use_archive = 0;
         
@@ -1222,6 +1230,7 @@ if (defined $makefiles{'am'}) {
         if (defined $cflags{'am'} && $cflags{'am'}->{$obj}) {
             # This file needs to go in an archive, so that we can
             # change the compile flags as specified in Recipe
+            $use_archive = 1;
             $archivecflags{$obj} = [$cflags{'am'}->{$obj}];
         }
         if ($use_archive) {
@@ -1234,6 +1243,10 @@ if (defined $makefiles{'am'}) {
         map { $allsources{$_} = 1 } @{$d->{deps}};
     }
 
+    # 2014-02-22: as of automake-1.14 we begin to get complained at if
+    # we don't use this option
+    print "AUTOMAKE_OPTIONS = subdir-objects\n\n";
+
     # Complete list of source and header files. Not used by the
     # auto-generated parts of this makefile, but Recipe might like to
     # have it available as a variable so that mandatory-rebuild things
@@ -1241,7 +1254,7 @@ if (defined $makefiles{'am'}) {
     print &splitline(join " ", "allsources", "=",
                      sort {$a cmp $b} keys %allsources), "\n\n";
 
-    @amcppflags = map {"-I$dirpfx$_"} @srcdirs;
+    @amcppflags = map {"-I\$(srcdir)/$_"} @srcdirs;
     print &splitline(join " ", "AM_CPPFLAGS", "=", @amcppflags, "\n");
 
     @amcflags = ("\$(GTK_CFLAGS)", "\$(WARNINGOPTS)");