]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - mkfiles.pl
Use more modern example keys in Pageant docs.
[PuTTY.git] / mkfiles.pl
index fa05472e2b7ce688da915a530a39c055af8096e2..0e7484889e20244466b7d64fd1dbd497cf6f4645 100755 (executable)
@@ -45,9 +45,10 @@ open IN, "Recipe" or do {
 };
 
 # HACK: One of the source files in `charset' is auto-generated by
-# sbcsgen.pl. We need to generate that _now_, before attempting
-# dependency analysis.
+# sbcsgen.pl, and licence.h is likewise generated by licence.pl. We
+# need to generate those _now_, before attempting dependency analysis.
 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."; select STDOUT;';
+eval 'require "licence.pl"; select STDOUT;';
 
 @srcdirs = ("./");
 
@@ -131,9 +132,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;
     }
@@ -461,7 +463,7 @@ if (defined $makefiles{'cygwin'}) {
     &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 +493,7 @@ if (defined $makefiles{'cygwin'}) {
       }
     }
     print "\n";
-    print $makefile_extra{'cygwin'}->{'end'} if defined $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 +542,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 +599,7 @@ if (defined $makefiles{'borland'}) {
       }
     }
     print "\n";
-    print $makefile_extra{'borland'}->{'end'} if defined $makefile_extra{'borland'}->{'end'};
+    print &def($makefile_extra{'borland'}->{'end'});
     print "\nclean:\n".
     "\t-del *.obj\n".
     "\t-del *.exe\n".
@@ -639,66 +641,79 @@ if (defined $makefiles{'vc'}) {
       "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"));
+    print &splitline("all:" . join "", map { " \$(BUILDDIR)$_.exe" } &progrealnames("G:C"));
     print "\n\n";
     foreach $p (&prognames("G:C")) {
        ($prog, $type) = split ",", $p;
-       $objstr = &objects($p, "X.obj", "X.res", undef);
-       print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
-       print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
-    }
-    foreach $p (&prognames("G:C")) {
-       ($prog, $type) = split ",", $p;
-       print $prog, ".rsp: \$(MAKEFILE)\n";
-       $objstr = &objects($p, "X.obj", "X.res", "X.lib");
+       $objstr = &objects($p, "\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", undef);
+       print &splitline("\$(BUILDDIR)$prog.exe: " . $objstr), "\n";
+
+       $objstr = &objects($p, "\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", "X.lib");
+       $subsys = ($type eq "G") ? "windows" : "console";
+        $inlinefilename = "link_$prog";
+        print "\ttype <<$inlinefilename\n";
        @objlist = split " ", $objstr;
        @objlines = ("");
        foreach $i (@objlist) {
-           if (length($objlines[$#objlines] . " $i") > 50) {
+           if (length($objlines[$#objlines] . " $i") > 72) {
                push @objlines, "";
            }
            $objlines[$#objlines] .= " $i";
        }
-       $subsys = ($type eq "G") ? "windows" : "console";
-       print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
        for ($i=0; $i<=$#objlines; $i++) {
-           print "\techo$objlines[$i] >> $prog.rsp\n";
+           print "$objlines[$i]\n";
        }
-       print "\n";
+       print "<<\n";
+       print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:\$(BUILDDIR)$prog.exe -map:\$(BUILDDIR)$prog.map -nologo -subsystem:$subsys \@$inlinefilename\n\n";
     }
-    foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
+    foreach $d (&deps("\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", $dirpfx, "\\", "vc")) {
         $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
         print &splitline(sprintf("%s: %s", $d->{obj},
                                  join " ", @$extradeps, @{$d->{deps}})), "\n";
-        if ($d->{obj} =~ /.obj$/) {
-           print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
-       } else {
-           print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
+        if ($d->{obj} =~ /.res$/) {
+           print "\trc /Fo@{[$d->{obj}]} \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
        }
     }
     print "\n";
-    print $makefile_extra{'vc'}->{'end'} if defined $makefile_extra{'vc'}->{'end'};
+    foreach $real_srcdir ("", @srcdirs) {
+        $srcdir = $real_srcdir;
+        if ($srcdir ne "") {
+            $srcdir =~ s!/!\\!g;
+            $srcdir = $dirpfx . $srcdir;
+            $srcdir =~ s!\\\.\\!\\!;
+            $srcdir = "{$srcdir}";
+        }
+        # The double colon at the end of the line makes this a
+        # 'batch-mode inference rule', which means that nmake will
+        # aggregate multiple invocations of the rule and issue just
+        # one cl command with multiple source-file arguments. That
+        # noticeably speeds up builds, since starting up the cl
+        # process is a noticeable overhead and now has to be done far
+        # fewer times.
+        print "${srcdir}.c.obj::\n\tcl /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<\n\n";
+    }
+    print &def($makefile_extra{'vc'}->{'end'});
     print "\nclean: tidy\n".
-      "\t-del *.exe\n\n".
+      "\t-del \$(BUILDDIR)*.exe\n\n".
       "tidy:\n".
-      "\t-del *.obj\n".
-      "\t-del *.res\n".
-      "\t-del *.pch\n".
-      "\t-del *.aps\n".
-      "\t-del *.ilk\n".
-      "\t-del *.pdb\n".
-      "\t-del *.rsp\n".
-      "\t-del *.dsp\n".
-      "\t-del *.dsw\n".
-      "\t-del *.ncb\n".
-      "\t-del *.opt\n".
-      "\t-del *.plg\n".
-      "\t-del *.map\n".
-      "\t-del *.idb\n".
-      "\t-del debug.log\n";
+      "\t-del \$(BUILDDIR)*.obj\n".
+      "\t-del \$(BUILDDIR)*.res\n".
+      "\t-del \$(BUILDDIR)*.pch\n".
+      "\t-del \$(BUILDDIR)*.aps\n".
+      "\t-del \$(BUILDDIR)*.ilk\n".
+      "\t-del \$(BUILDDIR)*.pdb\n".
+      "\t-del \$(BUILDDIR)*.rsp\n".
+      "\t-del \$(BUILDDIR)*.dsp\n".
+      "\t-del \$(BUILDDIR)*.dsw\n".
+      "\t-del \$(BUILDDIR)*.ncb\n".
+      "\t-del \$(BUILDDIR)*.opt\n".
+      "\t-del \$(BUILDDIR)*.plg\n".
+      "\t-del \$(BUILDDIR)*.map\n".
+      "\t-del \$(BUILDDIR)*.idb\n".
+      "\t-del \$(BUILDDIR)debug.log\n";
     select STDOUT; close OUT;
 }
 
@@ -1378,9 +1393,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";
@@ -1398,9 +1413,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;
 }
@@ -1445,9 +1460,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";
@@ -1467,7 +1482,7 @@ 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;
 }
@@ -1510,6 +1525,13 @@ 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, "", "/", "am")) {
       $objtosrc{$d->{obj}} = $d->{deps}->[0];
@@ -1536,7 +1558,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", "=");
@@ -1561,7 +1583,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;
 }
 
@@ -1592,7 +1614,7 @@ if (defined $makefiles{'lcc'}) {
     "\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";
@@ -1623,7 +1645,7 @@ if (defined $makefiles{'lcc'}) {
       }
     }
     print "\n";
-    print $makefile_extra{'lcc'}->{'end'} if defined $makefile_extra{'lcc'}->{'end'};
+    print &def($makefile_extra{'lcc'}->{'end'});
     print "\nclean:\n".
     "\t-del *.obj\n".
     "\t-del *.exe\n".
@@ -1654,9 +1676,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;
@@ -1684,7 +1706,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";
@@ -1708,7 +1730,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";