]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - mkfiles.pl
Surround process protection with an #ifndef UNPROTECT
[PuTTY.git] / mkfiles.pl
index 9ec915a0dd608fa8d5a244b28d12451e1ba49b02..90e4f9dc1b9747fd099934de40fe59b72946ccdb 100755 (executable)
@@ -131,9 +131,10 @@ while (<IN>) {
     $i = shift @objs;
     if ($groups{$i}) {
       foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
-    } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
-              $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
+    } elsif (($i =~ /^\[([A-Z]*)\]$/) and defined $prog) {
       $type = substr($i,1,(length $i)-2);
+      die "unrecognised program type for $prog [$type]\n"
+          if ! grep { $type eq $_ } qw(G C X U MX UT);
     } else {
       push @$listref, $i;
     }
@@ -458,10 +459,10 @@ if (defined $makefiles{'cygwin'}) {
               (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
               "\n".
     "LDFLAGS = -mno-cygwin -s\n".
-    &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
-      " --define WINVER=0x0400")."\n".
+    &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1 ".
+      "--define WINVER=0x0400 ".(join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
     "\n".
-    $makefile_extra{'cygwin'}->{'vars'} .
+    &def($makefile_extra{'cygwin'}->{'vars'}) .
     "\n".
     ".SUFFIXES:\n".
     "\n";
@@ -491,7 +492,7 @@ if (defined $makefiles{'cygwin'}) {
       }
     }
     print "\n";
-    print $makefile_extra{'cygwin'}->{'end'};
+    print &def($makefile_extra{'cygwin'}->{'end'});
     print "\nclean:\n".
     "\trm -f *.o *.exe *.res.o *.so *.map\n".
     "\n".
@@ -540,7 +541,7 @@ if (defined $makefiles{'borland'}) {
     "BCB = \$(MAKEDIR)\\..\n".
     "!endif\n".
     "\n".
-    $makefile_extra{'borland'}->{'vars'} .
+    &def($makefile_extra{'borland'}->{'vars'}) .
     "\n".
     ".c.obj:\n".
     &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
@@ -597,7 +598,7 @@ if (defined $makefiles{'borland'}) {
       }
     }
     print "\n";
-    print $makefile_extra{'borland'}->{'end'};
+    print &def($makefile_extra{'borland'}->{'end'});
     print "\nclean:\n".
     "\t-del *.obj\n".
     "\t-del *.exe\n".
@@ -635,10 +636,11 @@ if (defined $makefiles{'vc'}) {
       "CFLAGS = /nologo /W3 /O1 " .
       (join " ", map {"-I$dirpfx$_"} @srcdirs) .
       " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
-      "LFLAGS = /incremental:no /fixed\n".
-      "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
+      "LFLAGS = /incremental:no /dynamicbase /nxcompat\n".
+      "RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs).
+      " -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
       "\n".
-      $makefile_extra{'vc'}->{'vars'} .
+      &def($makefile_extra{'vc'}->{'vars'}) .
       "\n".
       "\n";
     print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
@@ -679,7 +681,7 @@ if (defined $makefiles{'vc'}) {
        }
     }
     print "\n";
-    print $makefile_extra{'vc'}->{'end'};
+    print &def($makefile_extra{'vc'}->{'end'});
     print "\nclean: tidy\n".
       "\t-del *.exe\n\n".
       "tidy:\n".
@@ -1158,7 +1160,7 @@ if (defined $makefiles{'vstudio10'} || defined $makefiles{'vstudio12'}) {
             "      <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
             "      <WarningLevel>Level3</WarningLevel>\n" .
             "      <AdditionalIncludeDirectories>" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
-            "      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;SECURITY_WIN32;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
+            "      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
             "      <AssemblerListingLocation>.\\Release\\</AssemblerListingLocation>\n" .
             "      <PrecompiledHeaderOutputFile>.\\Release\\$windows_project.pch</PrecompiledHeaderOutputFile>\n" .
             "      <ObjectFileName>.\\Release\\</ObjectFileName>\n" .
@@ -1197,7 +1199,7 @@ if (defined $makefiles{'vstudio10'} || defined $makefiles{'vstudio12'}) {
             "      <MinimalRebuild>true</MinimalRebuild>\n" .
             "      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n" .
             "      <AdditionalIncludeDirectories>" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
-            "      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;SECURITY_WIN32;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
+            "      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
             "      <AssemblerListingLocation>.\\Debug\\</AssemblerListingLocation>\n" .
             "      <PrecompiledHeaderOutputFile>.\\Debug\\$windows_project.pch</PrecompiledHeaderOutputFile>\n" .
             "      <ObjectFileName>.\\Debug\\</ObjectFileName>\n" .
@@ -1377,9 +1379,9 @@ if (defined $makefiles{'gtk'}) {
     ".SUFFIXES:\n".
     "\n".
     "\n";
-    print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));
+    print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U:UT"));
     print "\n\n";
-    foreach $p (&prognames("X:U")) {
+    foreach $p (&prognames("X:U:UT")) {
       ($prog, $type) = split ",", $p;
       $objstr = &objects($p, "X.o", undef, undef);
       print &splitline($prog . ": " . $objstr), "\n";
@@ -1397,9 +1399,9 @@ if (defined $makefiles{'gtk'}) {
       print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
     }
     print "\n";
-    print $makefile_extra{'gtk'}->{'end'};
+    print &def($makefile_extra{'gtk'}->{'end'});
     print "\nclean:\n".
-    "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
+    "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U:UT")) . "\n";
     print "\nFORCE:\n";
     select STDOUT; close OUT;
 }
@@ -1444,9 +1446,9 @@ if (defined $makefiles{'unix'}) {
     ".SUFFIXES:\n".
     "\n".
     "\n";
-    print &splitline("all:" . join "", map { " $_" } &progrealnames("U"));
+    print &splitline("all:" . join "", map { " $_" } &progrealnames("U:UT"));
     print "\n\n";
-    foreach $p (&prognames("U")) {
+    foreach $p (&prognames("U:UT")) {
       ($prog, $type) = split ",", $p;
       $objstr = &objects($p, "X.o", undef, undef);
       print &splitline($prog . ": " . $objstr), "\n";
@@ -1466,13 +1468,14 @@ if (defined $makefiles{'unix'}) {
     print "\n";
     print &def($makefile_extra{'unix'}->{'end'});
     print "\nclean:\n".
-    "\trm -f *.o". (join "", map { " $_" } &progrealnames("U")) . "\n";
+    "\trm -f *.o". (join "", map { " $_" } &progrealnames("U:UT")) . "\n";
     print "\nFORCE:\n";
     select STDOUT; close OUT;
 }
 
 if (defined $makefiles{'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;
@@ -1481,12 +1484,15 @@ 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";
 
+    # 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
     # (version.o) can conveniently be made to depend on it.
-    @sources = ("allsources", "=",
-                map {"${dirpfx}$_"} sort keys %allsourcefiles);
+    @sources = ("allsources", "=", sort keys %allsourcefiles);
     print &splitline(join " ", @sources), "\n\n";
 
     @cliprogs = ("bin_PROGRAMS", "=");
@@ -1505,13 +1511,20 @@ if (defined $makefiles{'am'}) {
     print &splitline(join " ", @cliprogs), "\n";
     print "endif\n\n";
 
+    @noinstcliprogs = ("noinst_PROGRAMS", "=");
+    foreach $p (&prognames("UT")) {
+      ($prog, $type) = split ",", $p;
+      push @noinstcliprogs, $prog;
+    }
+    print &splitline(join " ", @noinstcliprogs), "\n";
+
     %objtosrc = ();
-    foreach $d (&deps("X", undef, $dirpfx, "/", "am")) {
+    foreach $d (&deps("X", undef, "", "/", "am")) {
       $objtosrc{$d->{obj}} = $d->{deps}->[0];
     }
 
     print &splitline(join " ", "AM_CPPFLAGS", "=",
-                     map {"-I$dirpfx$_"} @srcdirs), "\n";
+                     map {"-I\$(srcdir)/$_"} @srcdirs), "\n";
 
     @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", "\$(WARNINGOPTS)");
     print "if HAVE_GTK\n";
@@ -1531,7 +1544,7 @@ if (defined $makefiles{'am'}) {
     print &splitline(join " ", "noinst_LIBRARIES", "=",
                      sort { $a cmp $b } values %amspeciallibs), "\n\n";
 
-    foreach $p (&prognames("X:U")) {
+    foreach $p (&prognames("X:U:UT")) {
       ($prog, $type) = split ",", $p;
       print "if HAVE_GTK\n" if $type eq "X";
       @progsources = ("${prog}_SOURCES", "=");
@@ -1556,7 +1569,7 @@ if (defined $makefiles{'am'}) {
       print "endif\n" if $type eq "X";
       print "\n";
     }
-    print $makefile_extra{'am'}->{'end'};
+    print &def($makefile_extra{'am'}->{'end'});
     select STDOUT; close OUT;
 }
 
@@ -1583,11 +1596,11 @@ if (defined $makefiles{'lcc'}) {
       (join " ", map {"-I$dirpfx$_"} @srcdirs) .
       "\n".
     "# Resource compilation flags\n".
-    "RCFLAGS = \n".
+    "RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs)."\n".
     "\n".
     "# Get include directory for resource compiler\n".
     "\n".
-    $makefile_extra{'lcc'}->{'vars'} .
+    &def($makefile_extra{'lcc'}->{'vars'}) .
     "\n";
     print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
     print "\n\n";
@@ -1618,7 +1631,7 @@ if (defined $makefiles{'lcc'}) {
       }
     }
     print "\n";
-    print $makefile_extra{'lcc'}->{'end'};
+    print &def($makefile_extra{'lcc'}->{'end'});
     print "\nclean:\n".
     "\t-del *.obj\n".
     "\t-del *.exe\n".
@@ -1649,9 +1662,9 @@ if (defined $makefiles{'osx'}) {
     "MLDFLAGS = -framework Cocoa\n".
     "ULDFLAGS =\n".
     "\n" .
-    $makefile_extra{'osx'}->{'vars'} .
+    &def($makefile_extra{'osx'}->{'vars'}) .
     "\n" .
-    &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .
+    &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U:UT")) .
     "\n";
     foreach $p (&prognames("MX")) {
       ($prog, $type) = split ",", $p;
@@ -1679,7 +1692,7 @@ if (defined $makefiles{'osx'}) {
       print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
                        $objstr . " $libstr", 69), "\n\n";
     }
-    foreach $p (&prognames("U")) {
+    foreach $p (&prognames("U:UT")) {
       ($prog, $type) = split ",", $p;
       $objstr = &objects($p, "X.o", undef, undef);
       print &splitline($prog . ": " . $objstr), "\n";
@@ -1703,7 +1716,7 @@ if (defined $makefiles{'osx'}) {
     }
     print "\n".&def($makefile_extra{'osx'}->{'end'});
     print "\nclean:\n".
-    "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".
+    "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U:UT")) . "\n".
     "\trm -rf *.app\n".
     "\n".
     "FORCE:\n";
@@ -1909,7 +1922,7 @@ if ($do_unix) {
     system "./mkauto.sh";
     die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0;
     if ($do_unix == 1) {
-        chdir ($targetdir = dirname($makefiles{"am"}))
+        chdir ($targetdir = "unix")
             or die "$targetdir: chdir: $!\n";
     }
     system "./configure", @confargs;