about summary refs log tree commit diff
path: root/buildtools
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/Makefile15
-rw-r--r--buildtools/README.pkg70
-rwxr-xr-xbuildtools/configure.pl691
-rwxr-xr-xbuildtools/empty_depend19
-rwxr-xr-xbuildtools/installnetpbm.pl429
-rwxr-xr-xbuildtools/installosf2
-rwxr-xr-xbuildtools/makeman20
-rw-r--r--buildtools/manpage.mk68
-rwxr-xr-xbuildtools/stamp-date2
9 files changed, 921 insertions, 395 deletions
diff --git a/buildtools/Makefile b/buildtools/Makefile
index 9c0ee778..8671c066 100644
--- a/buildtools/Makefile
+++ b/buildtools/Makefile
@@ -8,13 +8,9 @@ include $(BUILDDIR)/config.mk
 
 MERGE_OBJECTS =
 
-# These are programs that are used by the make files:
-PROGS = libopt typegen endiangen
+BUILDPROGS = libopt typegen endiangen
 
-all: $(PROGS)
-
-BINARIES =
-SCRIPTS =
+all: $(BUILDPROGS)
 
 OMIT_BUILDTOOL_RULE = 1
 include $(SRCDIR)/common.mk
@@ -30,16 +26,17 @@ endif
 libopt.o: libopt.c
 	$(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) \
 	  -DSHLIBPREFIXLIST="\"$(SHLIBPREFIXLIST)\"" \
-	  $(STRIP_DLL_VERSION) $(EXPLICIT) $(CFLAGS_PERSONAL) $(CADD) \
+	  $(STRIP_DLL_VERSION) $(EXPLICIT) \
+	  $(CFLAGS_PERSONAL) $(CFLAGS) $(CADD) \
 	  $<
 
 typegen.o endiangen.o:%.o:%.c
 	$(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) $<
 
-$(PROGS):%:%.o
+$(BUILDPROGS):%:%.o
 	$(LD_FOR_BUILD) -o $@ $(LDFLAGS_FOR_BUILD) $<
 
 distclean clean: cleanlocal
 .PHONY: cleanlocal
 cleanlocal:
-	rm -f $(PROGS)
+	rm -f $(BUILDPROGS)
diff --git a/buildtools/README.pkg b/buildtools/README.pkg
index e544cbb7..d642dee8 100644
--- a/buildtools/README.pkg
+++ b/buildtools/README.pkg
@@ -111,15 +111,26 @@ The parts to be installed are:
 
 
     One of the Netpbm programs is Manweb, which is designed to be a
-    replacement for the classic Man program that can access both
-    traditional man pages and worldwide web documentation in the
-    Netpbm style with the familiar 'man jpegtopnm' kind of command.
-    To set up your system for this, you will have to be sure to create
-    the /usr/man/web directory, with 'netpbm.url' in it.  Also, If you
-    install Manweb as 'man', there is no point to installing the
+    replacement for the classic Man program that can access both traditional
+    man pages and worldwide web documentation in the Netpbm style with the
+    familiar 'man jpegtopnm' kind of command.  The package contains the files
+    necessary to use Manweb to access Netpbm documention on the web (on
+    netpbm.sourceforge.net).  These files are the contents of the man/web
+    directory and the file 'bin/doc.url'.  You should install the
+    'bin/doc.url' file if you are installing the Netpbm executables in a
+    directory all their own.  You should install the 'man/web' files if you
+    are installing the Netpbm executables in some global directory such as
+    'usr/bin'.  You should install neither of these if you don't intend to use
+    Manweb.
+
+    If you install Manweb as 'man', there is no point to installing the
     pointer man pages -- they will never be used.
-    
 
+    If you want to use Manweb to view the Netpbm manual but use a local
+    copy of the manual instead of accessing it on the web, you can get the
+    HTML files from the Sourceforge Subversion repository and install those
+    instead of the .url files that appear in the 'man/web' directory of the
+    package.
 
 The instructions above suggest putting the Netpbm parts in common
 directories such as /usr/bin, mingled with other packages.  This is
@@ -134,21 +145,34 @@ entire installation when you don't want it anymore, and to keep
 multiple versions around.
 
 
-netpbm.config
+netpbm.pc
+---------
+
+You should create a file named 'netpbm.pc' out of the template file
+'pkgconfig_template' in the package directory, and install netpbm.pc in
+your pkg-config directory (typically /usr/lib/pkgconfig).  Programs that want
+to find out where you installed some part of Netpbm can use a 'pkg-config
+netpbm ...' command to find out.  For example, a make file for a program that
+uses the Netpbm programming library might use this facility to generate the
+necessary compiler and linker options to access that library.
+
+The pkg-config facility is fairly widely used, especially with things related
+to the X Window System.
+
+
+netpbm-config
 -------------
 
-You should create a shell script named 'netpbm.config' out of the
-template file 'config_template' in the package directory, and install
-netpbm.config in your executable search path.  Programs that want to
-find out where you installed some part of Netpbm can invoke
-netpbm.config and it will tell them.  For example, a make file for a
-program that uses the Netpbm programming library might use
-netpbm.config to generate the necessary compiler and linker options to
-access that library.
-
-Using netpbm.config, it's possible to have a viable Netpbm
-installation where netpbm.config is the only file in any default
-search path.
-
-The xxx.config file concept is a relatively new but growing convention,
-seen mostly in software related to the X Window System.
+You should create a shell script named 'netpbm-config' out of the template
+file 'config_template' in the package directory, and install netpbm-config in
+your executable search path.  Programs that want to find out where you
+installed some part of Netpbm can invoke netpbm-config and it will tell them.
+For example, a make file for a program that uses the Netpbm programming
+library might use netpbm-config to generate the necessary compiler and linker
+options to access that library.
+
+Using netpbm-config, it's possible to have a viable Netpbm installation where
+netpbm-config is the only file in any default search path.
+
+The xxx-config concept (in general, not just Netpbm) has largely been replaced
+by the pkg-config concept (see netpbm.pc above).
diff --git a/buildtools/configure.pl b/buildtools/configure.pl
index 21f11bf3..9cafd019 100755
--- a/buildtools/configure.pl
+++ b/buildtools/configure.pl
@@ -42,6 +42,11 @@ my ($TRUE, $FALSE) = (1,0);
 
 my $testCc;
 
+# $warned is logical.  It means we have issued a warning to Standard Output.
+
+my $warned;
+
+
 ##############################################################################
 #
 #  Implementation note:
@@ -93,6 +98,97 @@ sub prompt($$) {
 
 
 
+sub promptYesNo($) {
+    my ($default) = @_;
+
+    my $retval;
+
+    while (!defined($retval)) {
+        my $response = prompt("(y)es or (n)o", $default);
+        
+        if (uc($response) =~ m{ ^ (Y|YES) $ }x)  {
+            $retval = $TRUE;
+        } elsif (uc($response) =~ m{ ^ (N|NO) $ }x)  {
+            $retval = $FALSE;
+        } else {
+            print("'$response' isn't one of the choices.  \n" .
+                  "You must choose 'yes' or 'no' (or 'y' or 'n').\n");
+        }
+    }
+
+    return $retval;
+}
+
+
+
+sub flow($) {
+    my ($unflowed) = @_;
+#-----------------------------------------------------------------------------
+#  Return the text $unflowed, split with newlines into 72 character lines.
+#  We assum $unflowed is pure text, without any kind of formatting characters
+#  such as newlines.
+#-----------------------------------------------------------------------------
+    my $retval;
+
+    my @words = split(m{\s+}, $unflowed);
+    
+    my $currentLine;
+    
+    $currentLine = "";
+    
+    foreach my $word (@words) {
+        my $mustSpill;
+        if (length($currentLine) == 0) {
+            $currentLine = $word;
+            $mustSpill = $FALSE;
+        } else {
+            my $separator;
+            if (substr($currentLine, -1) eq '.') {
+                $separator = "  ";
+            } else {
+                $separator = " ";
+            }
+                
+            if (length($currentLine) + length($separator) + length($word)
+                <= 72) {
+                $currentLine .= $separator;
+                $currentLine .= $word;
+                $mustSpill = $FALSE;
+            } else {
+                $mustSpill = $TRUE;
+            }
+        }
+        if ($mustSpill) {
+            $retval .= $currentLine;
+            $retval .= "\n";
+            $currentLine = $word;
+        }
+    }
+
+    $retval .= $currentLine;
+    $retval .= "\n";
+
+    return $retval;
+}
+
+
+
+sub warnUser($) {
+    my ($warning) = @_;
+#-----------------------------------------------------------------------------
+#  Warn the user the build might fail, with explanation "$warning".
+#-----------------------------------------------------------------------------
+    print("************************************" .
+          "************************************\n");
+    print flow("WARNING: $warning");
+    print("************************************" .
+          "************************************\n");
+
+    $warned = $TRUE;
+}
+
+
+
 sub tmpdir() {
 # This is our approximation of File::Spec->tmpdir(), which became part of
 # basic Perl some time after Perl 5.005_03.
@@ -257,7 +353,7 @@ sub testCompile($$$) {
 sub testCompileLink($$$) {
     my ($flags, $cSourceCodeR, $successR) = @_;
 #-----------------------------------------------------------------------------
-#  Do a test compile of the program in @{$cSourceCodeR}.
+#  Do a test compile and link of the program in @{$cSourceCodeR}.
 #  
 #  Return $$successR == $TRUE iff the compile succeeds (exit code 0).
 #-----------------------------------------------------------------------------
@@ -322,20 +418,8 @@ sub askAboutCygwin() {
         $default = "n";
     }
     
-    my $retval;
+    my $retval = promptYesNo($default);
 
-    while (!defined($retval)) {
-        my $response = prompt("(y)es or (n)o", $default);
-    
-        if (uc($response) =~ /^(Y|YES)$/)  {
-            $retval = $TRUE;
-        } elsif (uc($response) =~ /^(N|NO)$/)  {
-            $retval = $FALSE;
-        } else {
-            print("'$response' isn't one of the choices.  \n" .
-                  "You must choose 'yes' or 'no' (or 'y' or 'n').\n");
-        }
-    }
     return $retval;
 }
 
@@ -353,20 +437,7 @@ sub askAboutDjgpp() {
         $default = "n";
     }
     
-    my $retval;
-
-    while (!defined($retval)) {
-        my $response = prompt("(y)es or (n)o", $default);
-    
-        if (uc($response) =~ /^(Y|YES)$/)  {
-            $retval = $TRUE;
-        } elsif (uc($response) =~ /^(N|NO)$/)  {
-            $retval = $FALSE;
-        } else {
-            print("'$response' isn't one of the choices.  \n" .
-                  "You must choose 'yes' or 'no' (or 'y' or 'n').\n");
-        }
-    }
+    my $retval = promptYesNo($default);
 }
 
 
@@ -407,10 +478,10 @@ sub getPlatform() {
     print("Which of the following best describes your platform?\n");
  
     print("gnu      GNU/Linux\n");
+    print("win      Windows/DOS (Cygwin, DJGPP, Mingw32)\n");
     print("sun      Solaris or SunOS\n");
     print("hp       HP-UX\n");
     print("aix      AIX\n");
-    print("win      Windows/DOS (Cygwin, DJGPP, Mingw32)\n");
     print("tru64    Tru64\n");
     print("irix     Irix\n");
     print("bsd      NetBSD, BSD/OS\n");
@@ -485,6 +556,49 @@ sub getPlatform() {
 
 
 
+sub getGccChoiceFromUser($) {
+    my ($platform) = @_;
+
+    my $retval;
+
+    print("GNU compiler or native operating system compiler (cc)?\n");
+    print("\n");
+
+    my $default;
+
+    if ($platform eq "SOLARIS" || $platform eq "SCO" ) {
+        $default = "gcc";
+    } else {
+        $default = "cc";
+    }
+
+    while (!defined($retval)) {
+        my $response = prompt("gcc or cc", $default);
+
+        if ($response eq "gcc") {
+            $retval = "gcc";
+        } elsif ($response eq "cc") {
+            $retval = "cc";
+        } else {
+            print("'$response' isn't one of the choices.  \n" .
+                  "You must choose 'gcc' or 'cc'.\n");
+        }
+    }
+    if ($retval eq 'gcc' && !commandExists('gcc')) {
+        warnUser("WARNING: You selected the GNU compiler, " .
+                 "but do not appear to have a program " .
+                 "named 'gcc' in your PATH.  This may " .
+                 "cause trouble later.  You may need to " .
+                 "set the CC environment variable or CC " .
+                 "makefile variable or install 'gcc'");
+    }
+    print("\n");
+
+    return $retval;
+}
+
+
+
 sub getCompiler($$$) {
     my ($platform, $subplatform, $compilerR) = @_;
 #-----------------------------------------------------------------------------
@@ -529,45 +643,23 @@ sub getCompiler($$$) {
                             "DARWIN"  => 1,
                             );
 
-    if ($gccUsualPlatform{$platform}) {
-        $$compilerR = "gcc";
-    } elsif ($platform eq "WINDOWS" && $subplatform eq "cygwin") {
-        $$compilerR = "gcc";
-    } elsif ($gccOptionalPlatform{$platform}) {
-        print("GNU compiler or native operating system compiler (cc)?\n");
-        print("\n");
-
-        my $default;
+    if (commandExists('x86_64-w64-mingw32-gcc')) {
+        printf("Do you want to use the Mingw-w64 Cross-Compiler?\n");
 
-        if ($platform eq "SOLARIS" || $platform eq "SCO" ) {
-            $default = "gcc";
-        } else {
-            $default = "cc";
+        if (promptYesNo('y') eq "y") {
+            $$compilerR = 'x86_64-w64-mingw32-gcc';
         }
-
-        my $response = prompt("gcc or cc", $default);
-
-        if ($response eq "gcc") {
+    }
+    if (!defined($$compilerR)) {
+        if ($gccUsualPlatform{$platform}) {
             $$compilerR = "gcc";
-        } elsif ($response eq "cc") {
-            $$compilerR = "cc";
+        } elsif ($platform eq "WINDOWS" && $subplatform eq "cygwin") {
+            $$compilerR = "gcc";
+        } elsif ($gccOptionalPlatform{$platform}) {
+            $$compilerR = getGccChoiceFromUser($platform);
         } else {
-            print("'$response' isn't one of the choices.  \n" .
-                  "You must choose 'gcc' or 'cc'.\n");
-            exit 12;
+            $$compilerR = 'cc';
         }
-
-        if ($$compilerR eq 'gcc' && !commandExists('gcc')) {
-            print("WARNING: You selected the GNU compiler, " .
-                  "but do not appear to have a program " .
-                  "named 'gcc' in your PATH.  This may " .
-                  "cause trouble later.  You may need to " .
-                  "set the CC environment variable or CC " .
-                  "makefile variable or install 'gcc'\n");
-        }
-        print("\n");
-    } else {
-        $$compilerR = 'cc';
     }
 }
 
@@ -743,16 +835,16 @@ sub getLibTypes($$$$$$$$) {
         my $response = prompt("(y)es or (n)o", $default);
         
         if (uc($response) =~ /^(Y|YES)$/)  {
-            $staticlib_too = "y";
+            $staticlib_too = "Y";
         } elsif (uc($response) =~ /^(N|NO)$/)  {
-            $staticlib_too = "n";
+            $staticlib_too = "N";
         } else {
             print("'$response' isn't one of the choices.  \n" .
               "You must choose 'yes' or 'no' (or 'y' or 'n').\n");
             exit 12;
         }
     } else {
-        $staticlib_too = "n";
+        $staticlib_too = "N";
     }
     print("\n");
 
@@ -855,6 +947,7 @@ sub getInttypes($) {
 }
 
 
+
 sub getInt64($$) {
 
     my ($inttypes_h, $haveInt64R) = @_;
@@ -890,6 +983,85 @@ sub getInt64($$) {
 
 
 
+sub determineSseCapability($) {
+
+    my ($haveEmmintrinR) = @_;
+
+    if (defined($testCc)) {
+
+        print("(Doing test compiles to determine if your compiler has SSE " .
+              "intrinsics -- ignore errors)\n");
+
+        my $cflags = testCflags();
+
+        my $works;
+
+        my @cSourceCode = (
+                           "#include <emmintrin.h>\n",
+                           );
+            
+        testCompile($cflags, \@cSourceCode, \my $success);
+            
+        if ($success) {
+            print("It does.\n");
+            $$haveEmmintrinR = $TRUE;
+        } else {
+            print("It does not.  Programs will not exploit fast SSE " .
+                  "instructions.\n");
+            $$haveEmmintrinR = $FALSE;
+        }
+        print("\n");
+    } else {
+        # We conservatively estimate the facility isn't there
+        $$haveEmmintrinR = $FALSE;
+    }
+}
+
+
+
+sub getSse($) {
+
+    my ($wantSseR) = @_;
+
+    determineSseCapability(\my $haveEmmintrin);
+
+    my $gotit;
+
+    print("Use SSE instructions?\n");
+    print("\n");
+
+    my $default = $haveEmmintrin ? "y" : "n";
+
+    $$wantSseR = promptYesNo($default);
+
+    # Another complication in the SSE world is that GNU compiler options
+    # -msse, -msse2, and -march=xxx affect whether the compiler can or will
+    # generate the instructions.  When compiling for older processors, the
+    # default for these options is negative ; for newer processors, it is
+    # affirmative.  -[no]msse2 determines whether macro __SSE2__ macro is
+    # defined.  If it is not, #include <emmintrins.h> fails (<emmintrins.h>
+    # checks __SSE2__.
+
+    # The Netpbm build does not mess with these compiler options.  If the
+    # user wants something other than the default, he can put it in CFLAGS
+    # in config.mk manually or on the make command line on in CFLAGS_PERSONAL.
+}
+
+
+sub getIcon($$) {
+
+    my ($platform, $wantIconR) = @_;
+
+    if ($platform eq 'WINDOWS') {
+        print("Include an icon in each executable?\n");
+        $$wantIconR = promptYesNo("y");
+    } else {
+        $$wantIconR = $FALSE;
+    }
+}
+
+
+
 # TODO: These should do test compiles to see if the headers are in the
 # default search path, both to create a default to offer and to issue a
 # warning after user has chosen.  Also test links to test the link library.
@@ -915,7 +1087,7 @@ sub getTiffLibrary($@) {
             $tifflib = $response;
         }
         if (defined($tifflib) and $tifflib =~ m{/} and !-f($tifflib)) {
-            printf("WARNING: No regular file named '$tifflib' exists.\n");
+            warnUser("No regular file named '$tifflib' exists.");
         }
     }
     my $tiffhdr_dir;
@@ -937,7 +1109,7 @@ sub getTiffLibrary($@) {
             $tiffhdr_dir = $response;
         }
         if (defined($tiffhdr_dir) and !-d($tiffhdr_dir)) {
-            printf("WARNING: No directory named '$tiffhdr_dir' exists.\n");
+            warnUser("No directory named '$tiffhdr_dir' exists.");
         }
     }
     return($tifflib, $tiffhdr_dir);
@@ -978,7 +1150,7 @@ sub getJpegLibrary($@) {
             $jpeghdr_dir = $response;
         }
         if (defined($jpeghdr_dir) and !-d($jpeghdr_dir)) {
-            printf("WARNING: No directory named '$jpeghdr_dir' exists.\n");
+            warnUser("No directory named '$jpeghdr_dir' exists.");
         }
     }
     return($jpeglib, $jpeghdr_dir);
@@ -1075,43 +1247,49 @@ sub getX11Library($@) {
     my ($platform, @suggestedHdrDir) = @_;
 
     my $x11lib;
-    {
-        my $default;
-
-        if (-d('/usr/link/X11')) {
-            $default = '/usr/link/X11/libX11' . libSuffix($platform);
-        } elsif (-d('/usr/X11R6/lib')) {
-            $default = '/usr/X11R6/lib/libX11' . libSuffix($platform);
-        } else {
-            $default = "libX11" . libSuffix($platform);
-        }
-        print("What is your X11 (X client) library?\n");
-        
-        my $response = prompt("library filename or 'none'", $default);
-        
-        if ($response ne "none") {
-            $x11lib = $response;
-        }
-    }
     my $x11hdr_dir;
-    if (defined($x11lib)) {
-        my $default;
 
-        $default = "default";
+    if (system('pkg-config x11 --exists') == 0) {
+        # We don't need to ask where X libraries are; pkg-config knows and the
+        # make files will use that.
+    } else {
+        {
+            my $default;
 
-        print("Where are the interface headers for it?\n");
-        
-        my $response = prompt("X11 header directory", $default);
-        
-        if ($response ne "default") {
-            $x11hdr_dir = $response;
+            if (-d('/usr/link/X11')) {
+                $default = '/usr/link/X11/libX11' . libSuffix($platform);
+            } elsif (-d('/usr/X11R6/lib')) {
+                $default = '/usr/X11R6/lib/libX11' . libSuffix($platform);
+            } else {
+                $default = "libX11" . libSuffix($platform);
+            }
+            print("What is your X11 (X client) library?\n");
+            
+            my $response = prompt("library filename or 'none'", $default);
+            
+            if ($response ne "none") {
+                $x11lib = $response;
+            }
         }
-        if (defined($x11hdr_dir)) {
-            if (!-d($x11hdr_dir)) {
-                printf("WARNING: No directory named '$x11hdr_dir' exists.\n");
-            } elsif (!-d("$x11hdr_dir/X11")) {
-                printf("WARNING: Directory '$x11hdr_dir' does not contain " .
-                       "the requisite 'X11' subdirectory\n");
+        if (defined($x11lib)) {
+            my $default;
+
+            $default = "default";
+
+            print("Where are the interface headers for it?\n");
+            
+            my $response = prompt("X11 header directory", $default);
+            
+            if ($response ne "default") {
+                $x11hdr_dir = $response;
+            }
+            if (defined($x11hdr_dir)) {
+                if (!-d($x11hdr_dir)) {
+                    warnUser("No directory named '$x11hdr_dir' exists.");
+                } elsif (!-d("$x11hdr_dir/X11")) {
+                    warnUser("Directory '$x11hdr_dir' does not contain " .
+                             "the requisite 'X11' subdirectory");
+                }
             }
         }
     }
@@ -1137,6 +1315,8 @@ sub getLinuxsvgaLibrary($@) {
             # &>/dev/null should work above, but on 12.03.26, it caused the
             # return value of system() always to be zero!
             $default = 'libvga.so';
+        } elsif (-f('/usr/lib/libvga.a')) {
+            $default = '/usr/lib/libvga.a';
         } else {
             $default = 'none';
         }
@@ -1166,8 +1346,7 @@ sub getLinuxsvgaLibrary($@) {
         }
         if (defined($svgalibhdr_dir)) {
             if (!-d($svgalibhdr_dir)) {
-                printf("WARNING: No directory named " .
-                       "'$svgalibhdr_dir' exists.\n");
+                warnUser("No directory named '$svgalibhdr_dir' exists.");
             }
         }
     }
@@ -1283,7 +1462,8 @@ sub gnuCflags($) {
     return("CFLAGS = " . gnuOptimizeOpt($gccCommandName) . " -ffast-math " .
            " -pedantic -fno-common " . 
            "-Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit " .
-           "-Wwrite-strings -Wmissing-prototypes -Wundef\n");
+           "-Wwrite-strings -Wmissing-prototypes -Wundef " .
+           "-Wno-unknown-pragmas\n");
 }
 
 
@@ -1332,10 +1512,10 @@ sub validateLibraries(@) {
     foreach my $libname (@libList) {
         if (defined($libname)) {
             if ($libname =~ m{/} and !-f($libname)) {
-                print("WARNING: No regular file named '$libname' exists.\n");
+                warnUser("No regular file named '$libname' exists.");
             } elsif (!($libname =~ m{ .* \. (so|a|sa|sl|dll|dylib) $ }x)) {
-                print("WARNING: The library name '$libname' does not have " .
-                      "a conventional suffix (.so, .a, .dll, etc.)\n");
+                warnUser("The library name '$libname' does not have " .
+                         "a conventional suffix (.so, .a, .dll, etc.)");
             }
         }
     }
@@ -1347,16 +1527,12 @@ sub warnJpegTiffDependency($$) {
     my ($jpeglib, $tifflib) = @_;
 
     if (defined($tifflib) && !defined($jpeglib)) {
-        print("WARNING: You say you have a Tiff library, " .
-              "but no Jpeg library.\n");
-        print("Sometimes the Tiff library prerequires the " .
-              "Jpeg library.  If \n");
-        print("that is the case on your system, you will " .
-              "have some links fail with\n");
-        print("missing 'jpeg...' symbols.  If so, rerun " .
-              "Configure and say you\n");
-        print("have no Tiff library either.\n");
-        print("\n");
+        warnUser("You say you have a Tiff library, but no Jpeg library.  " .
+                 "Sometimes the Tiff library prerequires the " .
+                 "Jpeg library.  If that is the case on your system, " .
+                 "you will have some links fail with " .
+                 "missing 'jpeg...' symbols.  If so, rerun " .
+                 "Configure and say you have no Tiff library either.");
     }
 }
 
@@ -1401,41 +1577,37 @@ sub printMissingHdrWarning($$) {
 
     my ($name, $hdr_dir) = @_;
 
-    print("WARNING: You said the compile-time part of the $name library " .
-          "(the header\n");
-    print("files) is in ");
+    warnUser("You said the compile-time part of the $name library " .
+             "(the header files) is in " .
+             
+             (defined($hdr_dir) ?
+              "directory '$hdr_dir', " :
+              "the compiler's default search path, ") .
 
-    if (defined($hdr_dir)) {
-        print("directory '$hdr_dir', ");
-    } else {
-        print("the compiler's default search path, ");
-    }
-    print("but a test compile failed\n");
-    print("to confirm that.  If your configuration is exotic, the test " .
-          "compile might\n");
-    print("just be wrong, but otherwise the Netpbm build will fail.\n");
-    print("\n");
-    print("To fix this, either install the $name library there \n");
-    print("or re-run Configure and answer the question about the $name " .
-          "library\n");
-    print("differently.\n");
-    print("\n");
+             "but a test compile failed to confirm that.  " .
+             "If your configuration is exotic, the test compile might" .
+             "just be wrong, but otherwise the Netpbm build will fail.  " .
+             "To fix this, either install the $name library there " .
+             "or re-run Configure and answer the question about the $name " .
+             "library differently."
+        );
 }
 
 
 
 sub printOldJpegWarning() {
-    print("WARNING: Your JPEG library appears to be too old for Netpbm.\n");
-    print("We base this conclusion on the fact that jpeglib.h apparently\n");
-    print("does not define struct jpeg_marker_struct.\n");
-    print("If the JPEG library is not Independent Jpeg Group's Version 6b\n");
-    print("or better, the Netpbm build will fail when it attempts to build\n");
-    print("the parts that use the JPEG library.\n");
-    print("\n");
-    print("If your configuration is exotic, this test may just be wrong.\n");
-    print("Otherwise, either upgrade your JPEG library or re-run Configure\n");
-    print("and say you don't have a JPEG library.\n");
-    print("\n");
+    warnUser("Your JPEG library appears to be too old for Netpbm.  " .
+             "We base this conclusion on the fact that jpeglib.h apparently" .
+             "does not define struct jpeg_marker_struct.  " .
+             "If the JPEG library is not " .
+             "Independent Jpeg Group's Version 6b" .
+             "or better, the Netpbm build will fail when it attempts " .
+             "to build the parts that use the JPEG library.  " .
+             "If your configuration is exotic, " .
+             "this test may just be wrong.  " .
+             "Otherwise, either upgrade your JPEG library " .
+             "or re-run Configure and say you don't have a JPEG library."
+        );
 }
 
 
@@ -1470,6 +1642,56 @@ sub testJpegHdr($) {
 
 
 
+sub warnJpegNotInDefaultPath($) {
+    my ($jpegLib) = @_;
+
+    print("You said your JPEG library is '$jpegLib', which says it is "
+          . "in the linker's default search path, but a test link we did "
+          . "failed as if it is not.  If it isn't, the build will fail\n");
+}
+
+
+
+sub testJpegLink($) {
+    my ($jpegLib) = @_;
+#-----------------------------------------------------------------------------
+#  See if we can link the JPEG library with the information user gave us.
+#  $jpegLib is the answer to the "what is your JPEG library" prompt, so
+#  it is either a library file name such as "libjpeg.so", in the linker's
+#  default search path, or it is an absolute path name such as
+#  "/usr/jpeg/lib/libjpeg.so".
+#
+#  We actually test only the default search path case, since users often
+#  incorrectly specify that by taking the default.
+#-----------------------------------------------------------------------------
+    if ($jpegLib =~ m{( lib | cyg ) (.+) \. ( so | a )$}x) {
+        my $libName = $2;
+
+        # It's like "libjpeg.so", so is a library in the default search path.
+        # $libName is "jpeg" in this example.
+
+        # First we test our test tool.  We can do this only with GCC.
+
+        my @emptySource;
+
+        testCompileLink('-nostartfiles', \@emptySource, \my $controlWorked);
+
+        if ($controlWorked) {
+            # The "control" case worked.  Now see if it still works when we add
+            # the JPEG library.
+
+            testCompileLink("-nostartfiles -l$libName", \@emptySource,
+                            \my $workedWithJpeg);
+
+            if (!$workedWithJpeg) {
+                warnJpegNotInDefaultPath($jpegLib);
+            }
+        }
+    }
+}
+
+
+
 sub testCompileZlibH($$) {
     my ($cflags, $successR) = @_;
 #-----------------------------------------------------------------------------
@@ -1531,38 +1753,47 @@ sub testPngHdr($$) {
 
 
 
-sub printBadPngConfigLdflagsWarning($) {
-    my ($pngLdFlags) = @_;
-
-    print << 'EOF';
-WARNING: 'libpng-config' in this environment (a program in your PATH)
-gives instructions that don't work for linking with the PNG library.
-Our test link failed.
-
-This indicates Libpng is installed incorrectly on this system.  If so,
-your Netpbm build, which uses 'libpng-config', will fail.  But it
-might also just be our test that is broken.
-
-EOF
+sub printBadPngConfigCflagsWarning($) {
+    my ($pngCFlags) = @_;
 
+    warnUser("'libpng-config' in this environment (a program in your PATH) " .
+             "gives instructions that don't work for compiling for " .
+             "(not linking with) the PNG library.  " .
+             "Our test compile failed.  " .
+             "This indicates Libpng is installed incorrectly " .
+             "on this system.  If so, your Netpbm build, " .
+             "which uses 'libpng-config', will fail.  " .
+             "But it might also just be our test that is broken.");
 }
 
 
 
-sub printBadPngConfigCflagsWarning($) {
-    my ($pngCFlags) = @_;
+sub pngLinkWorksWithLzLmMsg() {
 
-    print << 'EOF';
-WARNING: 'libpng-config' in this environment (a program in your PATH)
-gives instructions that don't work for compiling for the PNG library.
-Our test compile failed.
+    return
+        "When we added \"-lz -lm\" to the linker flags, the link worked.  " .
+        "That means the fix for this may be to modify 'libpng-config' " .
+        "so that 'libpng-config --ldflags' includes \"-lz -lm\" " .
+        "in its output.  But the right fix may actually " .
+        "be to build libpng differently so that it specifies its dependency " .
+        "on those libraries, or to put those libraries in a different " .
+        "place, or to create missing symbolic links.";
+}
 
-This indicates Libpng is installed incorrectly on this system.  If so,
-your Netpbm build, which uses 'libpng-config', will fail.  But it
-might also just be our test that is broken.
 
-EOF
 
+sub printBadPngConfigLdflagsWarning($$) {
+    my ($pngLdFlags, $lzLmSuccess) = @_;
+
+    warnUser(
+        "'libpng-config' in this environment (a program in your PATH) " .
+        "gives instructions that don't work for linking " .
+        "with the PNG library.  Our test link failed.  " .
+        "This indicates Libpng is installed incorrectly on this system.  " .
+        "If so, your Netpbm build, which uses 'libpng-config', will fail.  " .
+        "But it might also just be our test that is broken.  " .
+        ($lzLmSuccess ? pngLinkWorksWithLzLmMsg : "")
+        );
 }
 
 
@@ -1588,7 +1819,10 @@ sub testLinkPnglib($$) {
                         \@cSourceCode, \my $success);
         
         if (!$success) {
-            printBadPngConfigLdflagsWarning($pngLdflags);
+            testCompileLink("$generalCflags $pngCflags $pngLdflags -lz -lm",
+                        \@cSourceCode, \my $lzLmSuccess);
+
+            printBadPngConfigLdflagsWarning($pngLdflags, $lzLmSuccess);
         }
     }
 }
@@ -1633,20 +1867,15 @@ sub testCompileXmlreaderH($$) {
 sub printBadXml2CFlagsWarning($) {
     my ($xml2CFlags) = @_;
 
-    print << 'EOF';
-
-WARNING: 'xml2-config' in this environment (a program in your PATH)
-gives instructions that don't work for compiling for the Libxml2 library.
-Our test compile failed.
-
-This indicates Libxml2 is installed incorrectly on this system.  If so,
-your Netpbm build, which uses 'xml2-config', will fail.  But it
-might also just be our test that is broken.
-
-'xml2-config' says to use compiler options '$xml2CFlags'.
-
-EOF
-
+    warnUser(
+      "'xml2-config' in this environment (a program in your PATH) " .
+        "gives instructions that don't work for compiling for the " .
+        "Libxml2 library.  Our test compile failed.  " .
+        "This indicates Libxml2 is installed incorrectly on this system.  " .
+        "If so, your Netpbm build, which uses 'xml2-config', will fail.  " .
+        "But it might also just be our test that is broken.  ".
+        "'xml2-config' says to use compiler options '$xml2CFlags'.  "
+        );
 }
 
 
@@ -1669,26 +1898,24 @@ sub testCompileXmlReaderTypes($$) {
 
 sub printMissingXmlReaderTypesWarning() {
 
-    print << 'EOF';
-
-WARNING: Your libxml2 interface header file does not define the type
-'xmlReaderTypes', which Netpbm needs.  In order to build Netpbm successfully,
-you must install a more recent version of Libxml2.
-
-EOF
+    warnUser(
+        "Your libxml2 interface header file does not define the type " .
+        "'xmlReaderTypes', which Netpbm needs.  " .
+        "In order to build Netpbm successfully, " .
+        "you must install a more recent version of Libxml2.  "
+        );
 }
 
 
 
 sub printNoLibxml2Warning() {
 
-    print << 'EOF';
-
-WARNING: You appear not to have Libxml2 installed ('xml2-config' does not
-exist in your program search PATH).  If this is the case at build time,
-the build will skip building 'svgtopam'.
-
-EOF
+    warnUser(
+        "You appear not to have Libxml2 installed ('xml2-config' does not " .
+        "exist in your program search PATH).  " .
+        "If this is the case at build time, " .
+        "the build will skip building 'svgtopam'."
+        );
 }
 
 
@@ -1731,6 +1958,8 @@ sub testConfiguration($$$$$$) {
 
     if (defined($jpeglib)) {
         testJpegHdr($jpeghdr_dir);
+
+        testJpegLink($jpeglib);
     }
     if (defined($pnglib) && defined($zlib)) {
         testPngHdr($pnghdr_dir, $zhdr_dir);
@@ -1862,41 +2091,37 @@ getInttypes(\my $inttypesHeaderFile);
 
 getInt64($inttypesHeaderFile, \my $haveInt64);
 
+getSse(\my $wantSse);
+
 findProcessManagement(\my $dontHaveProcessMgmt);
 
+getIcon($platform, \my $wantIcon);
+
 #******************************************************************************
 #
 #  FIND THE PREREQUISITE LIBRARIES
 #
 #*****************************************************************************
 
-print("\n\n");
-print("The following questions concern the subroutine libraries that are " .
-      "Netpbm\n");
-print("prerequisites.  Every library has a compile-time part (header " .
-      "files)\n");
-print("and a link-time part.  In the case of a shared library, these are " .
-      "both\n");
-print("part of the \"development\" component of the library, which may be " .
-      "separately\n");
-print("installable from the runtime shared library.  For each library, you " .
-      "must\n");
-print("give the filename of the link library.  If it is not in your " .
-      "linker's\n");
-print("default search path, give the absolute pathname of the file.  In " .
-      "addition,\n");
-print("you will be asked for the directory in which the library's interface " .
-      "headers\n");
-print("reside, and you can respond 'default' if they are in your compiler's " .
-      "default\n");
-print("search path.\n");
-print("\n");
-print("If you don't have the library on your system, you can enter 'none' " .
-      "as the\n");
-print("library filename and the builder will skip any part that requires " .
-      "that ");
-print("library.\n");
-print("\n");
+print << 'EOF';
+
+
+The following questions concern the subroutine libraries that are Netpbm
+prerequisites.  Every library has a compile-time part (header files)
+and a link-time part.  In the case of a shared library, these are both
+part of the "development" component of the library, which may be separately
+installable from the runtime shared library.  For each library, you must
+give the filename of the link library.  If it is not in your linker's
+default search path, give the absolute pathname of the file.  In addition,
+you will be asked for the directory in which the library's interface headers
+reside, and you can respond 'default' if they are in your compiler's default
+search path.
+
+If you don't have the library on your system, you can enter 'none' as the
+library filename and the builder will skip any part that requires that
+library.
+
+EOF
 
 my ($jpeglib, $jpeghdr_dir) = getJpegLibrary($platform);
 print("\n");
@@ -2131,7 +2356,7 @@ if ($platform eq "GNU") {
     # only Ppmtompeg and it isn't clear that using long instead of int is
     # ever right anyway.
 
-    push(@config_mk, "OMIT_NETWORK = y\n");
+    push(@config_mk, "OMIT_NETWORK = Y\n");
     push(@config_mk, "LINKER_CAN_DO_EXPLICIT_LIBRARY=Y\n");
 } elsif ($platform eq "IRIX") {
 #    push(@config_mk, "INSTALL = install\n");
@@ -2145,7 +2370,7 @@ if ($platform eq "GNU") {
         makeCompilerGcc(\@config_mk);
     }
     push(@config_mk, "EXE = .exe\n");
-    push(@config_mk, "OMIT_NETWORK = y\n");
+    push(@config_mk, "OMIT_NETWORK = Y\n");
 #    # Though it may not have the link as "ginstall", "install" in a Windows
 #    # Unix environment is usually GNU install.
 #    my $ginstall_result = `ginstall --version 2>/dev/null`;
@@ -2160,6 +2385,9 @@ if ($platform eq "GNU") {
     if ($subplatform ne "cygwin") {
         push(@config_mk, "MSVCRT = Y\n");
     }
+    if ($wantIcon) {
+        push(@config_mk, 'WINICON_OBJECT = $(BUILDDIR)/icon/netpbm.o', "\n");
+    }
 } elsif ($platform eq "BEOS") {
     push(@config_mk, "LDSHLIB = -nostart\n");
 } elsif ($platform eq "OPENBSD") {
@@ -2296,6 +2524,10 @@ if ($haveInt64 ne 'Y') {
     push(@config_mk, "HAVE_INT64 = $haveInt64\n");
 }
 
+if ($wantSse) {
+    push(@config_mk, "WANT_SSE = Y\n");
+}
+
 if ($dontHaveProcessMgmt) {
     push(@config_mk, "DONT_HAVE_PROCESS_MGMT = Y\n");
 }
@@ -2322,6 +2554,9 @@ print("make.\n");
 print("\n");
 
 print("Now you may proceed with 'make'\n");
+if ($warned) {
+    print("BUT: per the previous WARNINGs, don't be surprised if it fails\n");
+}
 print("\n");
 
 
diff --git a/buildtools/empty_depend b/buildtools/empty_depend
deleted file mode 100755
index a4ba372c..00000000
--- a/buildtools/empty_depend
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-# This program turns every Makefile.depend file into an empty file,
-# so that dependencies in there can't make trouble for users trying to
-# build Netpbm.  They don't need dependencies anyway, since they're 
-# building everything and not modifying anything.
-
-# Developers should do 'make dep' to create real Makefile.depend files
-# before building
-
-my $mf_list = `find . -name Makefile.depend`;
-my @mf_list = split(/\s/, $mf_list);
-foreach (@mf_list) {
-    print "Emptying $_\n";
-    open(MF, ">$_");
-    close(MF);
-}
diff --git a/buildtools/installnetpbm.pl b/buildtools/installnetpbm.pl
index 25376ec3..61900335 100755
--- a/buildtools/installnetpbm.pl
+++ b/buildtools/installnetpbm.pl
@@ -47,7 +47,10 @@ sub prompt($$) {
 
 
 sub getPkgdir() {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where the Netpbm package is (i.e. where
+#  'make package' put it).
+#-----------------------------------------------------------------------------
     my $pkgdir;
 
     while (!$pkgdir) {
@@ -141,7 +144,7 @@ sub getPrefix() {
 
 sub getCpCommand() {
 #-----------------------------------------------------------------------------
-# compute the command + options need to do a recursive copy, preserving
+# Compute the command + options need to do a recursive copy, preserving
 # symbolic links and file attributes.
 #-----------------------------------------------------------------------------
     my $cpCommand;
@@ -168,7 +171,10 @@ sub getCpCommand() {
 
 
 sub getBinDir($) {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the programs installed, and return
+#  that.
+#-----------------------------------------------------------------------------
     my ($prefix) = @_;
 
     print("Where do you want the programs installed?\n");
@@ -223,7 +229,10 @@ sub installProgram($$$) {
 
 
 sub getLibDir($) {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the runtime libraries installed and
+#  return that.
+#-----------------------------------------------------------------------------
     my ($prefix) = @_;
 
     print("Where do you want the shared library installed?\n");
@@ -256,8 +265,174 @@ sub getLibDir($) {
 
 
 
-sub 
-execLdconfig() {
+sub ldconfigExists() {
+
+    return (system("ldconfig -? >/dev/null 2>/dev/null") >> 8) != 127;
+}
+
+
+
+sub crleExists() {
+
+    return (system("crle -? 2>/dev/null") >> 8) != 127;
+}
+
+
+
+sub dirName($) {
+    my ($fileName) = @_;
+#-----------------------------------------------------------------------------
+#  The directory component of file name $fileName.
+#-----------------------------------------------------------------------------
+
+    my @components = split(m{/}, $fileName);
+
+    pop(@components);
+
+    if (@components == 1 && $components[0] eq '') {
+        return '/';
+    } else {
+        return join('/', @components);
+    }
+}
+
+
+
+sub ldConfigKnowsDir($) {
+    my ($shlibDir) = @_;
+#-----------------------------------------------------------------------------
+#  Ldconfig appears to search $shlibDir for shared libraries.
+#
+#  Our determination is approximate.  We just look at whether 'ldconfig'
+#  found anything in $shlibDir the last time it searched.  If it searched
+#  $shlibDir and just didn't find anything or $shlibDir has been added to
+#  its search path since then, we'll wrongly conclue that it doesn't search
+#  $shlibDir now.
+#-----------------------------------------------------------------------------
+    my @ldconfigOutput = split(m{\n}, qx{ldconfig -p});
+
+    my $found;
+
+    foreach (@ldconfigOutput) {
+
+        if (m{ => \s (.*) $ }x) {
+            my ($fileName) = ($1);
+
+            if (dirName($fileName) eq $shlibDir) {
+                $found = $TRUE;
+            }
+        }
+    }
+    return $found;
+}
+
+
+
+
+sub warnNonstandardShlibDirLdconfig($) {
+    my ($shlibDir) = @_;
+#-----------------------------------------------------------------------------
+#  Assuming this is a system that has an 'ldconfig' program, warn the user
+#  if $shlibDir appears not to be in the system shared library search path.
+#-----------------------------------------------------------------------------
+
+    # This appears to be a system that uses the GNU libc dynamic linker.
+    # The list of system shared library directories is in /etc/ld.so.conf.
+    # The program Ldconfig searches the directories in that list and
+    # remembers all the shared libraries it found (and some informtaion
+    # about them) in its cache /etc/ld.so.cache, which is what the 
+    # dynamic linker uses at run time to find the shared libraries.
+
+    if (!ldConfigKnowsDir($shlibDir)) {
+        print("You have installed shared libraries in " .
+              "'$shlibDir',\n" .
+              "which does not appear to be a system shared " .
+              "library directory ('ldconfig -p' \n" .
+              "doesn't show any other libraries in there).  " .
+              "Therefore, the system may not be\n" .
+              "able to find the Netpbm shared libraries " .
+              "when you run Netpbm programs.\n" .
+              "\n" .
+              "To fix this, you may need to update /etc/ld.so.conf\n" .
+              "\n" .
+              "You may need to use an LD_LIBRARY_PATH " .
+              "environment variable when running Netpbm programs\n" .
+              "\n");
+    }
+}
+
+
+
+
+sub warnNonstandardShlibDirCrle($) {
+    my ($shlibDir) = @_;
+#-----------------------------------------------------------------------------
+#  Assuming this is a system that has a 'crle' program, warn the user
+#  if $shlibDir appears not to be in the system shared library search path.
+#-----------------------------------------------------------------------------
+    # We should use 'crle' here to determine whether $shlibDir is a
+    # system directory.  But I don't have a Solaris system to reverse
+    # engineer/test with.
+
+    if ($shlibDir ne "/lib" && $shlibDir ne "/usr/lib") {
+        print("You have installed shared libraries in " .
+              "'$shlibDir',\n" .
+              "which is not a conventional system shared " .
+              "library directory.\n" .
+              "Therefore, the system may not be able to " .
+              "find the Netpbm\n" .
+              "shared libraries when you run Netpbm programs.\n" .
+              "\n" .
+              "To fix this, you may need to run 'crle -l'.\n" .
+              "\n" .
+              "You may need to use an LD_LIBRARY_PATH " .
+              "environment variable when running Netpbm programs\n" .
+              "\n");
+    }
+}
+        
+
+
+sub warnNonstandardShlibDirGeneric($) {
+    my ($shlibDir) = @_;
+#-----------------------------------------------------------------------------
+#  Without assuming any particular shared library search scheme on this
+#  system, warn if $shlibDir appears not to be in the system shared library
+#  search path.
+#-----------------------------------------------------------------------------
+
+    if ($shlibDir ne "/lib" && $shlibDir ne "/usr/lib") {
+        print("You have installed shared libraries in " .
+              "'$shlibDir',\n" .
+              "which is not a conventional system shared " .
+              "library directory.\n" .
+              "Therefore, the system may not be able to " .
+              "find the Netpbm\n" .
+              "shared libraries when you run Netpbm programs.\n" .
+              "\n" .
+              "You may need to use an LD_LIBRARY_PATH " .
+              "environment variable when running Netpbm programs\n" .
+              "\n");
+    }
+}
+
+
+
+sub warnNonstandardShlibDir($) {
+    my ($shlibDir) = @_;
+
+    if (ldconfigExists()) {
+        warnNonstandardShlibDirLdconfig($shlibDir);
+    } elsif (crleExists()) {
+        warnNonstandardShlibDirCrle($shlibDir);
+    } else {
+        warnNonstandardShlibDirGeneric($shlibDir);
+    }
+}
+
+
+
+sub execLdconfig() {
 #-----------------------------------------------------------------------------
 #  Run Ldconfig.  Try with the -X option first, and if that is an invalid
 #  option (which we have seen on an openBSD system), try it without -X.
@@ -311,15 +486,7 @@ execLdconfig() {
 
 
 
-sub ldconfigExists() {
-
-    return (system("ldconfig -? 2>/dev/null") >> 8) != 127;
-}
-
-
-
-sub
-doLdconfig() {
+sub doLdconfig() {
 #-----------------------------------------------------------------------------
 #  Run Ldconfig where appropriate.
 #-----------------------------------------------------------------------------
@@ -336,7 +503,7 @@ doLdconfig() {
               "to put the \n");
         print("Netpbm shared library in the cache?  This works only if " .
               "you have\n");
-        print("installed the library in a standard location.\n");
+        print("installed the library in a directory Ldconfig knows about.\n");
         print("\n");
         
         my $done;
@@ -377,6 +544,9 @@ sub installSharedLib($$$) {
         } else {
             print("done.\n");
             print("\n");
+
+            warnNonstandardShlibDir($libDir);
+
             doLdconfig();
         }
         $$libdirR = $libDir;
@@ -390,7 +560,10 @@ sub installSharedLib($$$) {
 
 
 sub getLinkDir($) {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the link-edit libraries installed and
+#  return that.
+#-----------------------------------------------------------------------------
     my ($prefix) = @_;
 
     print("Where do you want the static link library installed?\n");
@@ -450,7 +623,10 @@ sub installStaticLib($$$) {
 
 
 sub getDataDir($) {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the runtime data files installed and
+#  return that.
+#-----------------------------------------------------------------------------
     my ($prefix) = @_;
 
     print("Where do you want the data files installed?\n");
@@ -484,7 +660,10 @@ sub getDataDir($) {
 
 
 sub getHdrDir($) {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the compile-time header files
+#  installed and return that.
+#-----------------------------------------------------------------------------
     my ($prefix) = @_;
 
     print("Where do you want the library interface header files installed?\n");
@@ -574,7 +753,10 @@ sub installHeader($$$) {
 
 
 sub getManDir($) {
-
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the pointer man pages
+#  installed and return that.
+#-----------------------------------------------------------------------------
     my ($prefix) = @_;
 
     print("Where do you want the man pages installed?\n");
@@ -792,10 +974,37 @@ sub installManPage($$$) {
 
 
 
+sub netpbmVersion($) {
+    my ($pkgdir) = @_;
+
+    my $versionOpened = open(VERSION, "<$pkgdir/VERSION");
+
+    my $version;
+    my $error;
+
+    if (!$versionOpened) {
+        $error = "Unable to open $pkgdir/VERSION for reading.  " .
+            "Errno=$ERRNO\n";
+    } else {
+        $version = <VERSION>;
+        chomp($version);
+        close(VERSION);
+    }
+
+    if ($error) {
+        print("Failed to determine the version of Netpbm from the package, "
+              . "so that will not be correct in netpbm.config and netpbm.pc.  "
+              . $error . "\n");
+        $version = "???";
+    }
+    return $version;
+}
+
+
+
 sub 
-processTemplate($$$$$$$$$) {
-    my ($templateR, $version, $bindir, $libdir, $linkdir, $datadir, 
-        $includedir, $mandir, $outputR) = @_;
+processTemplate($$$) {
+    my ($templateR, $infoR, $outputR) = @_;
 
     my @output;
 
@@ -803,26 +1012,26 @@ processTemplate($$$$$$$$$) {
         if (m{^@}) {
             # Comment -- ignore it.
         } else {
-            if (defined($version)) {
-                s/\@VERSION\@/$version/;
+            if (defined($infoR->{VERSION})) {
+                s/\@VERSION\@/$infoR->{VERSION}/;
             }
-            if (defined($bindir)) {
-                s/\@BINDIR@/$bindir/;
+            if (defined($infoR->{BINDIR})) {
+                s/\@BINDIR@/$infoR->{BINDIR}/;
             }
-            if (defined($libdir)) {
-                s/\@LIBDIR@/$libdir/;
+            if (defined($infoR->{LIBDIR})) {
+                s/\@LIBDIR@/$infoR-.{LIBDIR}/;
             }
-            if (defined($linkdir)) {
-                s/\@LINKDIR@/$linkdir/;
+            if (defined($infoR->{LINKDIR})) {
+                s/\@LINKDIR@/$infoR->{LINKDIR}/;
             }
-            if (defined($datadir)) {
-                s/\@DATADIR@/$datadir/;
+            if (defined($infoR->{DATADIR})) {
+                s/\@DATADIR@/$infoR->{DATADIR}/;
             }
-            if (defined($includedir)) {
-                s/\@INCLUDEDIR@/$includedir/;
+            if (defined($infoR->{INCLUDEDIR})) {
+                s/\@INCLUDEDIR@/$infoR->{INCLUDEDIR}/;
             }
-            if (defined($mandir)) {
-                s/\@MANDIR@/$mandir/;
+            if (defined($infoR->{MANDIR})) {
+                s/\@MANDIR@/$infoR->{MANDIR}/;
             }
             push(@output, $_);
         }
@@ -832,11 +1041,12 @@ processTemplate($$$$$$$$$) {
 
 
 
-sub
-installConfig($$$$$$$) {
-    my ($pkgdir, 
-        $bindir, $libdir, $linkdir, $datadir, $includedir, $mandir) = @_;
-
+sub installConfig($$) {
+    my ($installdir, $templateSubsR) = @_;
+#-----------------------------------------------------------------------------
+# Install 'netpbm-config' -- a program you run to tell you things about
+# how Netpbm is installed.
+#-----------------------------------------------------------------------------
     my $error;
 
     my $configTemplateFilename = dirname($0) . "/config_template";
@@ -849,41 +1059,108 @@ installConfig($$$$$$$) {
 
         close(TEMPLATE);
 
-        my $versionOpened = open(VERSION, "<$pkgdir/VERSION");
+        processTemplate(\@template, $templateSubsR, \my $fileContentsR);
 
-        my $version;
-        if (!$versionOpened) {
-            $error = "Unable to open $pkgdir/VERSION for reading.  " .
-                "Errno=$ERRNO\n";
+        # TODO: Really, this ought to go in an independent directory,
+        # because you might want to have the Netpbm executables in
+        # some place not in the PATH and use this program, via the
+        # PATH, to find them.
+        
+        my $filename = "$installdir/netpbm-config";
+        
+        my $success = open(NETPBM_CONFIG, ">$filename");
+        if ($success) {
+            chmod(0755, $filename);
+            foreach (@{$fileContentsR}) { print NETPBM_CONFIG; }
+            close(NETPBM_CONFIG);
         } else {
-            $version = <VERSION>;
-            chomp($version);
-            close(VERSION);
-
-            processTemplate(\@template, $version, $bindir, $libdir,
-                            $linkdir, $datadir, $includedir, $mandir,
-                            \my $fileContentsR);
-
-            # TODO: Really, this ought to go in an independent directory,
-            # because you might want to have the Netpbm executables in
-            # some place not in the PATH and use this program, via the
-            # PATH, to find them.
-            
-            my $filename = "$bindir/netpbm-config";
+            $error = "Unable to open the file " .
+                "'$filename' for writing.  Errno=$ERRNO\n";
+        }
+    }
+    if ($error) {
+        print(STDERR "Failed to create the Netpbm configuration program.  " .
+              "$error\n");
+    }
+}
+
+
+
+
+sub getPkgconfigDir($) {
+#-----------------------------------------------------------------------------
+#  Find out from the user where he wants the Pkg-config file for the
+#  installation (netpbm.pc) and return that.
+#-----------------------------------------------------------------------------
+    my ($prefix) = @_;
+
+    print("Where do you want the Pkg-config file netpbm.pc installed?\n");
+    print("\n");
+
+    my $pkgconfigDir;
+
+    while (!$pkgconfigDir) {
+        my $default = "$prefix/lib/pkgconfig";
+
+        my $response = prompt("Pkg-config directory", $default);
+        
+        if (-d($response)) {
+            $pkgconfigDir = $response;
+        } else {
+            my $succeeded = mkdir($response, 0777);
             
-            my $success = open(NETPBM_CONFIG, ">$filename");
-            if ($success) {
-                chmod(0755, $filename);
-                foreach (@{$fileContentsR}) { print NETPBM_CONFIG; }
-                close(NETPBM_CONFIG);
+            if (!$succeeded) {
+                print("Unable to create directory '$response'.  " .
+                      "Error=$ERRNO\n");
             } else {
-                $error = "Unable to open the file " .
-                    "'$filename' for writing.  Errno=$ERRNO\n";
+                $pkgconfigDir = $response;
             }
         }
     }
+    print("\n");
+
+    return $pkgconfigDir;
+}
+
+
+
+sub installPkgConfig($$) {
+    my ($prefix, $templateSubsR) = @_;
+#-----------------------------------------------------------------------------
+# Install a pkg-config file (netpbm.pc) - used by the 'pkg-config' program to
+# find out various things about how Netpbm is installed.
+#-----------------------------------------------------------------------------
+    my $pkgconfigDir = getPkgconfigDir($prefix);
+
+    my $error;
+
+    my $pcTemplateFilename = dirname($0) . "/pkgconfig_template";
+
+    my $templateOpened = open(TEMPLATE, "<$pcTemplateFilename");
+    if (!$templateOpened) {
+        $error = "Can't open template file '$pcTemplateFilename'.\n";
+    } else {
+        my @template = <TEMPLATE>;
+
+        close(TEMPLATE);
+
+        processTemplate(\@template, $templateSubsR,
+                        \my $fileContentsR);
+
+        my $filename = "$pkgconfigDir/netpbm.pc";
+        
+        my $success = open(NETPBM_PC, ">$filename");
+        if ($success) {
+            chmod(0755, $filename);
+            foreach (@{$fileContentsR}) { print NETPBM_PC; }
+            close(NETPBM_PC);
+        } else {
+            $error = "Unable to open the file " .
+                "'$filename' for writing.  Errno=$ERRNO\n";
+        }
+    }
     if ($error) {
-        print(STDERR "Failed to create the Netpbm configuration program.  " .
+        print(STDERR "Failed to create the Netpbm Pkg-config file.  " .
               "$error\n");
     }
 }
@@ -929,8 +1206,18 @@ print("\n");
 installManPage($pkgdir, $prefix, \my $mandir);
 print("\n");
 
-installConfig($pkgdir, 
-              $bindir, $libdir, $linkdir, $datadir, $includedir, $mandir);
+my $templateSubsR =
+    {VERSION    => netpbmVersion($pkgdir),
+     BINDIR     => $bindir,
+     LIBDIR     => $libdir,
+     LINKDIR    => $linkdir,
+     DATADIR    => $datadir,
+     INCLUDEDIR => $includedir,
+     MANDIR     => $mandir};
+
+installConfig($bindir, $templateSubsR);
+
+installPkgConfig($prefix, $templateSubsR);
 
 print("Installation is complete (except where previous error messages have\n");
 print("indicated otherwise).\n");
diff --git a/buildtools/installosf b/buildtools/installosf
index 1d1d61a7..77934411 100755
--- a/buildtools/installosf
+++ b/buildtools/installosf
@@ -17,7 +17,7 @@ while [ $# -gt 0 ]; do
     elif [ "$1" = "-m" ]; then 
         shift
         PERMISSIONS=$1
-    elif [ ${SOURCE_FILE}x == x ]; then
+    elif [ ${SOURCE_FILE}x = x ]; then
         SOURCE_FILE=$1
     else
         TARGET_DIR=$1
diff --git a/buildtools/makeman b/buildtools/makeman
index 2e122779..94ee2172 100755
--- a/buildtools/makeman
+++ b/buildtools/makeman
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/python
 #
 # makeman -- compile netpbm's stereotyped HTML to troff markup
 #
@@ -51,9 +51,7 @@ def makeman(name, file, indoc):
     # Protect escapes before we try generating font changes.
     indoc = indoc.replace("\\", r"\e")
     # Header-bashing
-    indoc = indoc.replace('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "DTD/xhtml11.dtd">', "")
-    indoc = indoc.replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', "")
-    indoc = indoc.replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">\n',"")
+    indoc = re.sub('(?i)<!DOCTYPE html[^>]*>', "", indoc)
     indoc = indoc.replace('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">', "")
     indoc = indoc.replace('<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"/>', "")
     indoc = indoc.replace('<?xml version="1.1" encoding="iso-8859-1" ?>\n',"")
@@ -121,7 +119,10 @@ def makeman(name, file, indoc):
     indoc = re.sub("(?i)</SUP>", r"\\d", indoc)
     # Paragraph handling
     indoc = re.sub("(?i)\n*<P>\n*", r"\n.PP\n", indoc)
+    indoc = re.sub("(?i)<br */>", r"\n.PP\n", indoc)
     indoc = re.sub("(?i)</P>", "", indoc)
+    indoc = re.sub("(?i)<!--[^>]*-->", "", indoc)
+    indoc = re.sub("(?i)<meta[^>]*>", "", indoc)
     lines = indoc.split("\n")
     listdepth = 0
     for i in range(len(lines)):
@@ -138,13 +139,14 @@ def makeman(name, file, indoc):
     indoc = re.sub('(?i)<A[ \n]+HREF="mailto:[^>]+">([^<]+)</A>', r'\\fI\1\\fP', indoc)    
     # Format manual crossreferences
     def xrefmatch(match):
-        xrefto = match.group(1)
-        xrefsection = sectmap.get(xrefto, 1)
+        xrefto = match.group(2)
+        xrefurl = match.group(1)
+        xrefsection = sectmap.get(xrefurl, 1)
         if xrefsection == 0:
             return "\n.I " + xrefto
         else:
-            return "\n.BR %s (%d)" % (xrefto, xrefsection)
-    indoc = re.sub(r'(?i)\n* *(?:\\fB)?<A[ \n]+HREF="[^>]+.html">([^<]+)</A>(?:\\fP)?',
+            return "\n.BR %s (%d)\n" % (xrefto, xrefsection)
+    indoc = re.sub(r'(?i)\n* *(?:\\fB)?<A[ \n]+HREF="?([^>]+.html)"?>([^<]+)</A>(?:\\fP)?',
                    xrefmatch, indoc)
     # Format URLs
     def urlmatch(match):
@@ -159,7 +161,7 @@ def makeman(name, file, indoc):
     indoc = indoc.replace("&#174;", r"\*R")
     indoc = indoc.replace("&copy;", r"\(co")
     # Turn anchors into .UN tags
-    indoc = re.sub('(?i)<A NAME *= *"#?([a-zA-Z][a-zA-Z0-9.-]+)">(?:&nbsp;)*</A>\s*', ".UN \\1\n", indoc)
+    indoc = re.sub('(?i)<A NAME *= *"#?([a-zA-Z_][a-zA-Z_0-9.-]+)">(?:&nbsp;)*</A>\s*', ".UN \\1\n", indoc)
     # Strip off the index trailer
     trailer = re.compile('<HR */*>.*', re.DOTALL | re.IGNORECASE)
     indoc = re.sub(trailer, "", indoc)
diff --git a/buildtools/manpage.mk b/buildtools/manpage.mk
index e1c0bce2..76116ffe 100644
--- a/buildtools/manpage.mk
+++ b/buildtools/manpage.mk
@@ -48,43 +48,62 @@ MAN1 = \
 	mtvtoppm.1 \
 	neotoppm.1 \
 	palmtopnm.1 \
+	pamaddnoise.1 \
 	pamarith.1 \
+	pambackground.1 \
+	pambayer.1 \
 	pamchannel.1 \
 	pamcomp.1 \
 	pamcut.1 \
 	pamdeinterlace.1 \
+	pamdepth.1 \
 	pamdice.1 \
 	pamditherbw.1 \
 	pamedge.1 \
 	pamendian.1 \
+	pamenlarge.1 \
 	pamfile.1 \
 	pamfixtrunc.1 \
 	pamflip.1 \
 	pamfunc.1 \
 	pamgauss.1 \
+	pamgradient.1 \
 	pamlookup.1 \
+	pammasksharpen.1 \
+	pammixinterlace.1 \
 	pamoil.1 \
 	pamperspective.1 \
+	pampick.1 \
 	pampop9.1 \
+	pamrgbatopng.1 \
 	pamscale.1 \
 	pamseq.1 \
 	pamsharpmap.1 \
 	pamsharpness.1 \
 	pamslice.1 \
+	pamsplit.1 \
 	pamstack.1 \
 	pamstereogram.1 \
 	pamstretch-gen.1 \
 	pamstretch.1 \
 	pamsumm.1 \
 	pamsummcol.1 \
+	pamthreshold.1 \
+	pamtilt.1 \
 	pamtodjvurle.1 \
+	pamtofits.1 \
+	pamtogif.1 \
 	pamtohdiff.1 \
 	pamtohtmltbl.1 \
 	pamtojpeg2k.1 \
 	pamtopfm.1 \
 	pamtopnm.1 \
+	pamtosvg.1 \
 	pamtotga.1 \
+	pamtotiff.1 \
 	pamtouil.1 \
+	pamtoxvmini.1 \
+	pamx.1 \
 	pbmclean.1 \
 	pbmlife.1 \
 	pbmmake.1 \
@@ -107,11 +126,13 @@ MAN1 = \
 	pbmtog3.1 \
 	pbmtogem.1 \
 	pbmtogo.1 \
+	pbmtoibm23xx.1 \
 	pbmtoicon.1 \
 	pbmtolj.1 \
 	pbmtoln03.1 \
 	pbmtolps.1 \
 	pbmtomacp.1 \
+	pbmtomatrixorbital.1 \
 	pbmtomda.1 \
 	pbmtomgr.1 \
 	pbmtomrf.1 \
@@ -136,10 +157,13 @@ MAN1 = \
 	pgmabel.1 \
 	pgmbentley.1 \
 	pgmcrater.1 \
+	pgmdeshadow.1 \
 	pgmedge.1 \
 	pgmenhance.1 \
 	pgmhist.1 \
 	pgmkernel.1 \
+	pgmmake.1 \
+	pgmmedian.1 \
 	pgmminkowski.1 \
 	pgmmorphconv.1 \
 	pgmnoise.1 \
@@ -217,9 +241,13 @@ MAN1 = \
 	ppmchange.1 \
 	ppmcie.1 \
 	ppmcolormask.1 \
+	ppmdcfont.1 \
+	ppmddumpfont.1 \
 	ppmdim.1 \
 	ppmdist.1 \
 	ppmdither.1 \
+	ppmdmkfont.1 \
+	ppmdraw.1 \
 	ppmfade.1 \
 	ppmflash.1 \
 	ppmforge.1 \
@@ -279,6 +307,7 @@ MAN1 = \
 	rawtopgm.1 \
 	rawtoppm.1 \
 	rgb3toppm.1 \
+	rlatopam.1 \
 	rletopnm.1 \
 	sbigtopgm.1 \
 	sgitopnm.1 \
@@ -302,40 +331,11 @@ MAN1 = \
 	yuvsplittoppm.1 \
 	yuvtoppm.1 \
 	zeisstopnm.1 \
-        pamaddnoise.1 \
-        pambackground.1 \
-        pambayer.1 \
-        pamdepth.1 \
-        pamenlarge.1 \
-        pamgradient.1 \
-        pammasksharpen.1 \
-        pammixinterlace.1 \
-        pampick.1 \
-        pamrgbatopng.1 \
-        pamsplit.1 \
-        pamthreshold.1 \
-        pamtilt.1 \
-        pamtofits.1 \
-        pamtogif.1 \
-        pamtosvg.1 \
-        pamtotiff.1 \
-        pamtoxvmini.1 \
-        pamx.1 \
-        pbmtoibm23xx.1 \
-        pbmtomatrixorbital.1 \
-        pgmdeshadow.1 \
-        pgmmake.1 \
-        pgmmedian.1 \
-        ppmdcfont.1 \
-        ppmddumpfont.1 \
-        ppmdmkfont.1 \
-        ppmdraw.1 \
-        rlatopam.1 \
 
 MAN3 = \
-	libnetpbm.3 \
 	libnetpbm_image.3 \
 	libnetpbm_ug.3 \
+	libnetpbm.3 \
 	libpbm.3 \
 	libpgm.3 \
 	libpm.3 \
@@ -348,13 +348,13 @@ MAN5 = \
 	extendedopacity.5 \
 	pam.5 \
 	pbm.5 \
-        pfm.5 \
+	pfm.5 \
 	pgm.5 \
 	pnm.5 \
 	ppm.5 \
 
 # These things do get converted to man pages and installed.
-MANPAGES = $(MAN1) netpbm.1 $(MAN3) $(MAN5)
+MANPAGES = netpbm.1 $(MAN1) $(MAN3) $(MAN5)
 HTMLMANUALS = $(MAN1:.1=.html) $(MAN3:.3=.html) $(MAN5:.5=.html)
 
 # These things don't get converted to manual pages.
@@ -388,13 +388,13 @@ xmlpages:
 # This will install the generated man pages
 installman:
 	set -x
-	for f in $(MAN1); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man1/$$f.gz; fi; done
+	for f in netpbm.1 $(MAN1); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man1/$$f.gz; fi; done
 	for f in $(MAN3); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man3/$$f.gz; fi; done
 	for f in $(MAN5); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man5/$$f.gz; fi; done
 
 # This will uninstall them
 uninstallman:
-	for f in $(MAN1); do rm -f $(MANDIR)/man1/$$f.gz; fi; done
+	for f in netpbm.1 $(MAN1); do rm -f $(MANDIR)/man1/$$f.gz; fi; done
 	for f in $(MAN3); do rm -f $(MANDIR)/man3/$$f.gz; fi; done
 	for f in $(MAN5); do rm -f $(MANDIR)/man5/$$f.gz; fi; done
 
diff --git a/buildtools/stamp-date b/buildtools/stamp-date
index 5fb6c13a..32839e94 100755
--- a/buildtools/stamp-date
+++ b/buildtools/stamp-date
@@ -9,7 +9,7 @@
 # documentation.  This software is provided "as is" without express or
 # implied warranty.
 #
-DATE=`date`
+DATE=$(date)
 LOGNAME_OR_UNKNOWN=${LOGNAME:-UNKNOWN}
 USER=${USER:-$LOGNAME_OR_UNKNOWN}
 if [ "$USER" = "UNKNOWN" ]; then