Several people have spotted an uninitialised structure member leading to a
[u/mdw/putty] / mkfiles.pl
index 76e8e8a..835a940 100755 (executable)
@@ -300,7 +300,8 @@ sub splitline {
   $splitchar = (defined $splitchar ? $splitchar : '\\');
   while (length $line > $len) {
     $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
-    $result .= $1 . " ${splitchar}\n\t\t";
+    $result .= $1;
+    $result .= " ${splitchar}\n\t\t" if $2 ne '';
     $line = $2;
     $len = 60;
   }
@@ -395,7 +396,7 @@ if (defined $makefiles{'cygwin'}) {
     "# RCINC = --include-dir c:\\cygwin\\include\\\n".
     "\n".
     &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
-      " -D_NO_OLDNAMES -DNO_MULTIMON " .
+      " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
               (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
               "\n".
     "LDFLAGS = -mno-cygwin -s\n".
@@ -428,7 +429,7 @@ if (defined $makefiles{'cygwin'}) {
       if ($d->{obj} =~ /\.res\.o$/) {
          print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n";
       } else {
-         print "\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c ".$d->{deps}->[0]."\n\n";
+         print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
       }
     }
     print "\n";
@@ -472,7 +473,7 @@ if (defined $makefiles{'borland'}) {
     "MAKEFILE = Makefile.bor\n".
     "\n".
     "# C compilation flags\n".
-    "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
+    "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
     "# Resource compilation flags\n".
     "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
     "\n".
@@ -485,7 +486,7 @@ if (defined $makefiles{'borland'}) {
     "\n".
     ".c.obj:\n".
     &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
-              " \$(XFLAGS) \$(CFLAGS) ".
+              " \$(CFLAGS) \$(XFLAGS) ".
               (join " ", map {"-I$dirpfx$_"} @srcdirs) .
               " /c \$*.c",69)."\n".
     ".rc.res:\n".
@@ -575,7 +576,7 @@ if (defined $makefiles{'vc'}) {
       "# C compilation flags\n".
       "CFLAGS = /nologo /W3 /O1 " .
       (join " ", map {"-I$dirpfx$_"} @srcdirs) .
-      " /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n".
+      " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
       "LFLAGS = /incremental:no /fixed\n".
       "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
       "\n".
@@ -614,7 +615,7 @@ if (defined $makefiles{'vc'}) {
         print &splitline(sprintf("%s: %s", $d->{obj},
                                  join " ", @$extradeps, @{$d->{deps}})), "\n";
         if ($d->{obj} =~ /.obj$/) {
-           print "\tcl \$(COMPAT) \$(XFLAGS) \$(CFLAGS) /c ".$d->{deps}->[0],"\n\n";
+           print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
        } else {
            print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
        }
@@ -923,20 +924,38 @@ if (defined $makefiles{'gtk'}) {
     "# You can define this path to point at your tools if you need to\n".
     "# TOOLPATH = /opt/gcc/bin\n".
     "CC = \$(TOOLPATH)cc\n".
+    "# If necessary set the path to krb5-config here\n".
+    "KRB5CONFIG=krb5-config\n".
+    "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
+    "# (depending on what works on your system) if you want to enforce\n".
+    "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n".
+    "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
+    "# to 1.2 if it isn't found.\n".
+    "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
+    "\n".
+    "-include Makefile.local\n".
+    "\n".
+    "unexport CFLAGS # work around a weird issue with krb5-config\n".
     "\n".
     &splitline("CFLAGS = -O2 -Wall -Werror -g " .
               (join " ", map {"-I$dirpfx$_"} @srcdirs) .
-              " `gtk-config --cflags`")."\n".
-    "XLDFLAGS = `gtk-config --libs`\n".
-    "ULDFLAGS =#\n".
-    "INSTALL=install\n",
-    "INSTALL_PROGRAM=\$(INSTALL)\n",
-    "INSTALL_DATA=\$(INSTALL)\n",
-    "prefix=/usr/local\n",
-    "exec_prefix=\$(prefix)\n",
-    "bindir=\$(exec_prefix)/bin\n",
-    "mandir=\$(prefix)/man\n",
-    "man1dir=\$(mandir)/man1\n",
+              " \$(shell \$(GTK_CONFIG) --cflags)").
+                " -D _FILE_OFFSET_BITS=64\n".
+    "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
+    "ULDFLAGS = \$(LDFLAGS)\n".
+    "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
+    "CFLAGS+= \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
+    "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
+    "ULDFLAGS = \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
+    "endif\n".
+    "INSTALL=install\n".
+    "INSTALL_PROGRAM=\$(INSTALL)\n".
+    "INSTALL_DATA=\$(INSTALL)\n".
+    "prefix=/usr/local\n".
+    "exec_prefix=\$(prefix)\n".
+    "bindir=\$(exec_prefix)/bin\n".
+    "mandir=\$(prefix)/man\n".
+    "man1dir=\$(mandir)/man1\n".
     "\n".
     $makefile_extra{'gtk'}->{'vars'} .
     "\n".
@@ -950,8 +969,8 @@ if (defined $makefiles{'gtk'}) {
       $objstr = &objects($p, "X.o", undef, undef);
       print &splitline($prog . ": " . $objstr), "\n";
       $libstr = &objects($p, undef, undef, "-lX");
-      print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
-                       $objstr . " $libstr", 69), "\n\n";
+      print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
+                       $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
     }
     foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
       if ($forceobj{$d->{obj_orig}}) {
@@ -960,7 +979,7 @@ if (defined $makefiles{'gtk'}) {
         print &splitline(sprintf("%s: %s", $d->{obj},
                                  join " ", @{$d->{deps}})), "\n";
       }
-      print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n");
+      print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
     }
     print "\n";
     print $makefile_extra{'gtk'}->{'end'};
@@ -990,14 +1009,14 @@ if (defined $makefiles{'ac'}) {
               (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
     "XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".
     "ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".
-    "INSTALL=\@INSTALL\@\n",
-    "INSTALL_PROGRAM=\$(INSTALL)\n",
-    "INSTALL_DATA=\$(INSTALL)\n",
-    "prefix=\@prefix\@\n",
-    "exec_prefix=\@exec_prefix\@\n",
-    "bindir=\@bindir\@\n",
-    "mandir=\@mandir\@\n",
-    "man1dir=\$(mandir)/man1\n",
+    "INSTALL=\@INSTALL\@\n".
+    "INSTALL_PROGRAM=\$(INSTALL)\n".
+    "INSTALL_DATA=\$(INSTALL)\n".
+    "prefix=\@prefix\@\n".
+    "exec_prefix=\@exec_prefix\@\n".
+    "bindir=\@bindir\@\n".
+    "mandir=\@mandir\@\n".
+    "man1dir=\$(mandir)/man1\n".
     "\n".
     $makefile_extra{'gtk'}->{'vars'} .
     "\n".
@@ -1013,8 +1032,8 @@ if (defined $makefiles{'ac'}) {
       $objstr = &objects($p, "X.o", undef, undef);
       print &splitline($prog . ": " . $objstr), "\n";
       $libstr = &objects($p, undef, undef, "-lX");
-      print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
-                       $objstr . " $libstr", 69), "\n\n";
+      print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
+                       $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
     }
     foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
       if ($forceobj{$d->{obj_orig}}) {
@@ -1023,12 +1042,15 @@ if (defined $makefiles{'ac'}) {
         print &splitline(sprintf("%s: %s", $d->{obj},
                                  join " ", @{$d->{deps}})), "\n";
       }
-      print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n");
+      print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
     }
     print "\n";
     print $makefile_extra{'gtk'}->{'end'};
     print "\nclean:\n".
     "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
+    print "\ndistclean: clean\n".
+    "\t". &splitline("rm -f config.status config.cache config.log ".
+                    "configure.lineno config.status.lineno Makefile") . "\n";
     print "\nFORCE:\n";
     select STDOUT; close OUT;
 }
@@ -1224,7 +1246,7 @@ if (defined $makefiles{'lcc'}) {
       }
       if ($d->{obj} =~ /\.obj$/) {
          print &splitline("\tlcc -O -p6 \$(COMPAT)".
-                          " \$(XFLAGS) \$(CFLAGS) ".$d->{deps}->[0],69)."\n";
+                          " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
       } else {
           print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
                            $d->{deps}->[0],69)."\n";
@@ -1309,9 +1331,9 @@ if (defined $makefiles{'osx'}) {
       }
       $firstdep = $d->{deps}->[0];
       if ($firstdep =~ /\.c$/) {
-         print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n";
+         print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
       } elsif ($firstdep =~ /\.m$/) {
-         print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n";
+         print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
       }
     }
     print "\n".$makefile_extra{'osx'}->{'end'};