about summary refs log tree commit diff
path: root/buildtools
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/Makefile12
-rw-r--r--buildtools/README.pkg10
-rwxr-xr-xbuildtools/configure.pl663
-rw-r--r--buildtools/debian/README122
-rwxr-xr-xbuildtools/debian/mkdeb541
-rwxr-xr-xbuildtools/debian/postinst5
-rwxr-xr-xbuildtools/debian/postrm5
-rw-r--r--buildtools/endiangen.c6
-rwxr-xr-xbuildtools/installnetpbm.pl14
-rwxr-xr-xbuildtools/installosf2
-rw-r--r--buildtools/libopt.c10
-rwxr-xr-xbuildtools/makeman50
-rwxr-xr-xbuildtools/makepointerman10
-rw-r--r--buildtools/manpage.mk (renamed from buildtools/Makefile.manpage)100
14 files changed, 582 insertions, 968 deletions
diff --git a/buildtools/Makefile b/buildtools/Makefile
index 8ea61abe..9c0ee778 100644
--- a/buildtools/Makefile
+++ b/buildtools/Makefile
@@ -4,7 +4,7 @@ ifeq ($(SRCDIR)x,x)
 endif
 SUBDIR = buildtools
 VPATH = .:$(SRCDIR)/$(SUBDIR)
-include $(BUILDDIR)/Makefile.config
+include $(BUILDDIR)/config.mk
 
 MERGE_OBJECTS =
 
@@ -17,7 +17,7 @@ BINARIES =
 SCRIPTS =
 
 OMIT_BUILDTOOL_RULE = 1
-include $(SRCDIR)/Makefile.common
+include $(SRCDIR)/common.mk
 
 ifdef DLLVER
 STRIP_DLL_VERSION=-DDLLVERSTR="\"$(DLLVER)\""
@@ -28,16 +28,16 @@ EXPLICIT=-DEXPLICIT
 endif
 
 libopt.o: libopt.c
-	$(CC_FOR_BUILD) -c $(CFLAGS_FOR_BUILD) \
+	$(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) \
 	  -DSHLIBPREFIXLIST="\"$(SHLIBPREFIXLIST)\"" \
 	  $(STRIP_DLL_VERSION) $(EXPLICIT) $(CFLAGS_PERSONAL) $(CADD) \
-	  -o $@ $<
+	  $<
 
 typegen.o endiangen.o:%.o:%.c
-	$(CC_FOR_BUILD) -c $(CFLAGS_FOR_BUILD) -o $@ $<
+	$(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) $<
 
 $(PROGS):%:%.o
-	$(LD_FOR_BUILD) -o $@ $<
+	$(LD_FOR_BUILD) -o $@ $(LDFLAGS_FOR_BUILD) $<
 
 distclean clean: cleanlocal
 .PHONY: cleanlocal
diff --git a/buildtools/README.pkg b/buildtools/README.pkg
index b2a6b0ef..e544cbb7 100644
--- a/buildtools/README.pkg
+++ b/buildtools/README.pkg
@@ -69,6 +69,16 @@ The parts to be installed are:
     that is in the default search path of your compiler.  Typical
     directories for this are /usr/include and /usr/local/include.
 
+    All of the files are meant to be named like <netpbm/xxx.h> for C
+    #include purposes, which means on an ordinary system, they are
+    installed in a directory named "netpbm".  Thus, they are organized
+    this way in the package.  BUT: until Netpbm 10.41 (December 2007),
+    they were packaged for, and customarily used, just as <xxx.h>.
+    Therefore, for backward compatibility, it is a good idea to make
+    symbolic links from the parent directory into the netpbm/
+    directory.  But as that may pollute your namespace, you may prefer
+    just to make all users migrate to the <netpbm/xxx.h> form.
+
   Data Files
 
     These are files that you can use for various purposes as input to
diff --git a/buildtools/configure.pl b/buildtools/configure.pl
index ed8fce8a..21f11bf3 100755
--- a/buildtools/configure.pl
+++ b/buildtools/configure.pl
@@ -13,26 +13,26 @@ use Config;
 
 my ($TRUE, $FALSE) = (1,0);
 
-# This program generates Makefile.config, which is included by all of the
+# This program generates config.mk, which is included by all of the
 # Netpbm makefiles.  You run this program as the first step in building 
 # Netpbm.  (The second step is 'make').
 
 # This program is only a convenience.  It is supported to create 
-# Makefile.config any way you want.  In fact, an easy way is to copy
-# Makefile.config.in and follow the instructions in the comments therein
+# config.mk any way you want.  In fact, an easy way is to copy
+# config.mk.in and follow the instructions in the comments therein
 # to uncomment certain lines and make other changes.
 
 # Note that if you invoke 'make' without having first run 'configure',
 # the make will call 'configure' itself when it finds
-# 'Makefile.config' missing.  That might look a little messy to the
+# 'config.mk' missing.  That might look a little messy to the
 # user, but it isn't the normal build process.
 
-# The argument to this program is the filepath of the Makefile.config.in
-# file.  If unspecified, the default is 'Makefile.config.in' in the 
+# The argument to this program is the filepath of the config.mk.in
+# file.  If unspecified, the default is 'config.mk.in' in the 
 # Netpbm source directory.
 
 # For explanations of the stuff we put in the make files, see the comments
-# in Makefile.config.in.
+# in config.mk.in.
 
 
 # $testCc is the command we use to do test compiles.  Note that test
@@ -42,6 +42,18 @@ my ($TRUE, $FALSE) = (1,0);
 
 my $testCc;
 
+##############################################################################
+#
+#  Implementation note:
+#
+#  At one time, we thought we had to add /usr/local/lib and /usr/local/include
+#  to the path on some platforms because they needed it and didn't include
+#  it in the default compiler search path.  But then we had reason to doubt
+#  that was really required, so removed the function on 04.03.15 and never
+#  had any complaint in the next 3 years.
+##############################################################################
+
+
 #******************************************************************************
 #
 #  SUBROUTINES
@@ -87,13 +99,17 @@ sub tmpdir() {
 
     my $retval;
     
-    if ($ENV{"TMPDIR"}) {
-        $retval = $ENV{"TMPDIR"};
+    if ($ENV{'TMPDIR'}) {
+        $retval = $ENV{'TMPDIR'};
+    } elsif ($ENV{'TEMP'}) {
+        $retval = $ENV{'TEMP'};
     } else {
-        if ($Config{'osvers'} eq "djgpp") {
-            $retval = "/dev/env/DJDIR/tmp";
+        if ($Config{'osvers'} eq 'djgpp') {
+            $retval = '/dev/env/DJDIR/tmp';
         } else {
-            $retval =  "/tmp";
+            if (-d('/tmp')) {
+                $retval =  '/tmp';
+            }
         }
     }
     return $retval;
@@ -110,14 +126,43 @@ sub tempFile($) {
 #                                       DIR=>File::Spec->tmpdir(),
 #                                       UNLINK=>0);
     my ($suffix) = @_;
+
     my $fileName;
     local *file;  # For some inexplicable reason, must be local, not my
-    my $i;
-    $i = 0;
-    do {
-        $fileName = tmpdir() . "/netpbm" . $i++ . $suffix;
-    } until sysopen(*file, $fileName, O_RDWR|O_CREAT|O_EXCL);
 
+    my $tmpdir = tmpdir();
+
+    if (!defined($tmpdir)) {
+        print STDERR ("Cannot determine what directory to use for " .
+                      "temporary files.  " .
+                      "Set TMPDIR environment variable to fix this.\n");
+        exit(1);
+    } else {
+        if (!-d($tmpdir)) {
+            print STDERR ("Temporary file directory '$tmpdir' does not " .
+                          "exist.  Create it or set TMPDIR environment " .
+                          "variable appropriately\n");
+            exit(1);
+        } else {
+            for (my $i = 0; $i < 50 && !defined($fileName); ++$i) {
+                my $trialFileName = tmpdir() . "/netpbm" . $i . $suffix;
+
+                my $success = sysopen(*file,
+                                      $trialFileName,
+                                      O_RDWR|O_CREAT|O_EXCL);
+
+                if ($success) {
+                    $fileName = $trialFileName;
+                }
+            }
+
+            if (!defined($fileName)) {
+                print STDERR ("Unable to create a temporary file in " .
+                              "directory '$tmpdir'\n");
+                exit(1);
+            }
+        }
+    }
     return(*file, $fileName);
 }
 
@@ -159,8 +204,7 @@ sub chooseTestCompiler($$) {
 
 
 
-sub testCflags($) {
-    my ($needLocal) = @_;
+sub testCflags() {
 
     my $cflags;
 
@@ -176,9 +220,6 @@ sub testCflags($) {
         $cflags .= " " . $ENV{"CFLAGS"};
     }
     
-    if ($needLocal) {
-        $cflags .= " -I/usr/local/include";
-    }
     return $cflags;
 }    
 
@@ -213,10 +254,40 @@ sub testCompile($$$) {
 
 
 
+sub testCompileLink($$$) {
+    my ($flags, $cSourceCodeR, $successR) = @_;
+#-----------------------------------------------------------------------------
+#  Do a test compile of the program in @{$cSourceCodeR}.
+#  
+#  Return $$successR == $TRUE iff the compile succeeds (exit code 0).
+#-----------------------------------------------------------------------------
+    my ($cFile, $cFileName) = tempFile('.c');
+
+    print $cFile @{$cSourceCodeR};
+    
+    my ($oFile, $oFileName) = tempFile('');
+
+    # Note that $flags may contain -l options, which where static linking
+    # is involved have to go _after_ the base object file ($oFileName).
+    
+    my $compileCommand = "$testCc -o $oFileName $cFileName $flags";
+    print ("Doing test compile/link: $compileCommand\n");
+    my $rc = system($compileCommand);
+    
+    unlink($oFileName);
+    close($oFile);
+    unlink($cFileName);
+    close($cFile);
+
+    $$successR = ($rc == 0);
+}
+
+
+
 sub displayIntroduction() {
     print("This is the Netpbm configurator.  It is an interactive dialog " .
           "that\n");
-    print("helps you build the file 'Makefile.config' and prepare to build ");
+    print("helps you build the file 'config.mk' and prepare to build ");
     print("Netpbm.\n");
     print("\n");
 
@@ -414,8 +485,8 @@ sub getPlatform() {
 
 
 
-sub getCompiler($$) {
-    my ($platform, $compilerR) = @_;
+sub getCompiler($$$) {
+    my ($platform, $subplatform, $compilerR) = @_;
 #-----------------------------------------------------------------------------
 #  Here are some of the issues surrounding choosing a compiler:
 #
@@ -460,6 +531,8 @@ sub getCompiler($$) {
 
     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");
@@ -701,7 +774,7 @@ sub inttypesDefault() {
         print("(Doing test compiles to choose a default for you -- " .
               "ignore errors)\n");
 
-        my $cflags = testCflags($FALSE);
+        my $cflags = testCflags();
 
         my $works;
 
@@ -791,7 +864,7 @@ sub getInt64($$) {
         print("(Doing test compiles to determine if you have int64 type -- " .
               "ignore errors)\n");
 
-        my $cflags = testCflags($FALSE);
+        my $cflags = testCflags();
 
         my $works;
 
@@ -822,7 +895,7 @@ sub getInt64($$) {
 # warning after user has chosen.  Also test links to test the link library.
 
 # It looks like these should all be in the default search paths and were there
-# just to override defaults in Makefile.config.in.  Since Configure now
+# just to override defaults in config.mk.in.  Since Configure now
 # creates a default of "standard search path," I'm guessing we don't need
 # to set these anymore.
 
@@ -1140,8 +1213,8 @@ sub help() {
     print("It is not GNU Configure.\n");
     print("\n");
     print("There is one optional argument to this program:  The " .
-          "name of the file to use as the basis for the Makefile.config " .
-          "file.  Default is 'Makefile.config.in'\n");
+          "name of the file to use as the basis for the config.mk " .
+          "file.  Default is 'config.mk.in'\n");
     print("\n");
     print("Otherwise, the program is interactive.\n");
 }
@@ -1188,7 +1261,7 @@ sub gnuOptimizeOpt($) {
         print("Therefore, I am configuring the build to not do inline \n");
         print("optimization.  This will make some Netpbm programs \n");
         print("noticeably slower.  If I am wrong about your compiler, just\n");
-        print("edit Makefile.config and change -O0 to -O3 near the bottom.\n");
+        print("edit config.mk and change -O0 to -O3 near the bottom.\n");
         print("\n");
         print("The problem is known to exist in the GNU Compiler \n");
         print("release 2.96.  If you upgrade, you will not have this \n");
@@ -1204,38 +1277,22 @@ sub gnuOptimizeOpt($) {
 
 
 
-sub needLocal($) {
-#-----------------------------------------------------------------------------
-#  Return wether or not /usr/local paths must be added to compiles and
-#  links.  In a properly configured system, those paths should be in
-#  the compiler and linker default search paths, e.g. the compiler
-#  should search /usr/local/include and then /usr/include without any
-#  -I options needed.  But we've seen some systems where it isn't.
-#
-#  Actually, I have doubts now as to whether these misconfigured systems
-#  really exist.  This subroutine was apparently always broken, because
-#  before 04.03.15, it had "netbsd", etc. in lower case.  So it always
-#  returned false.  I never had a complaint.  Plus, we had a bug in 
-#  Makefile.config.in wherein it wiped out the user's setting of the LDFLAGS
-#  environment variable.  This could explain /usr/local/lib not being in
-#  the path when it should have been.
-#
-#  So I've disabled this function; we'll see if we encounter any truly
-#  misconfigured systems.  04.03.15.
-#-----------------------------------------------------------------------------
-    my ($platform) = @_;
+sub gnuCflags($) {
+    my ($gccCommandName) = @_;
 
-    return $FALSE;  # See comments above.
+    return("CFLAGS = " . gnuOptimizeOpt($gccCommandName) . " -ffast-math " .
+           " -pedantic -fno-common " . 
+           "-Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit " .
+           "-Wwrite-strings -Wmissing-prototypes -Wundef\n");
+}
 
-    my $needLocal;
-    
-    if ($platform eq "NETBSD" || $platform eq "OPENBSD" || 
-        $platform eq "FREEBSD") {
-        $needLocal = $TRUE;
-    } else {
-        $needLocal = $FALSE;
-    }
-    return $needLocal;
+
+
+sub makeCompilerGcc($) {
+    my ($config_mkR) = @_;
+    my $compileCommand = 'gcc';
+    push(@{$config_mkR}, "CC = $compileCommand\n");
+    push(@{$config_mkR}, gnuCflags($compileCommand));
 }
 
 
@@ -1246,7 +1303,7 @@ sub findProcessManagement($) {
 #  Return $TRUE iff the system does not have <sys/wait.h> in its default
 #  search path.
 #-----------------------------------------------------------------------------
-    my $cflags = testCflags($FALSE);
+    my $cflags = testCflags();
 
     my @cSourceCode = (
                        "#include <sys/wait.h>\n",
@@ -1383,13 +1440,13 @@ sub printOldJpegWarning() {
 
 
 
-sub testJpegHdr($$) {
+sub testJpegHdr($) {
 
-    my ($needLocal, $jpeghdr_dir) = @_;
+    my ($jpeghdr_dir) = @_;
 
     if (defined($testCc)) {
 
-        my $generalCflags = testCflags($needLocal);
+        my $generalCflags = testCflags();
 
         my $jpegIOpt = $jpeghdr_dir ? "-I$jpeghdr_dir" : "";
 
@@ -1442,15 +1499,15 @@ sub testCompilePngH($$) {
 
 
 
-sub testPngHdr($$$) {
+sub testPngHdr($$) {
 #-----------------------------------------------------------------------------
 #  Issue a warning if the compiler can't find png.h.
 #-----------------------------------------------------------------------------
-    my ($needLocal, $pnghdr_dir, $zhdr_dir) = @_;
+    my ($pnghdr_dir, $zhdr_dir) = @_;
 
     if (defined($testCc)) {
 
-        my $generalCflags = testCflags($needLocal);
+        my $generalCflags = testCflags();
 
         my $zlibIOpt = $zhdr_dir ? "-I$zhdr_dir" : "";
 
@@ -1474,13 +1531,76 @@ sub testPngHdr($$$) {
 
 
 
-sub testLibpngConfig($) {
-    my ($needLocal) = @_;
+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) = @_;
+
+    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.
+
+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 testLinkPnglib($$) {
+    my ($generalCflags, $pngCflags) = @_;
+
+    my @cSourceCode = (
+                       "#include <png.h>\n",
+                       "int main() {\n",
+                       "png_create_write_struct(0, NULL, NULL, NULL);\n",
+                       "}\n",
+                       );
+
+    testCompile("$generalCflags $pngCflags", \@cSourceCode, \my $success);
+    if (!$success) {
+        # Since it won't compile, we can't test the link
+    } else {
+        my $pngLdflags = qx{libpng-config --ldflags};
+        chomp($pngLdflags);
+        
+        testCompileLink("$generalCflags $pngCflags $pngLdflags",
+                        \@cSourceCode, \my $success);
+        
+        if (!$success) {
+            printBadPngConfigLdflagsWarning($pngLdflags);
+        }
+    }
+}
+
+
+
+sub testLibpngConfig() {
 #-----------------------------------------------------------------------------
 #  Issue a warning if the instructions 'libpng-config' give for compiling
 #  with Libpng don't work.
 #-----------------------------------------------------------------------------
-    my $generalCflags = testCflags($needLocal);
+    my $generalCflags = testCflags();
 
     my $pngCflags = qx{libpng-config --cflags};
     chomp($pngCflags);
@@ -1488,33 +1608,136 @@ sub testLibpngConfig($) {
     testCompilePngH("$generalCflags $pngCflags", \my $success);
 
     if (!$success) {
-        print("\n");
-        print("Unable to compile a test PNG program using the compiler " .
-              "flags that libpng-config says to use: '$pngCflags'.\n");
-        print("This indicates that you have Libpng installed incorrectly.\n");
-        print("libpng-config gets installed as part of the Libpng package.\n");
+        printBadPngConfigCflagsWarning($pngCflags);
     } else {
-        
+        testLinkPnglib($generalCflags, $pngCflags);
+    }
+}
+
+
+
+sub testCompileXmlreaderH($$) {
+    my ($cflags, $successR) = @_;
+#-----------------------------------------------------------------------------
+#  Do a test compile to see if we can see xmlreader.h.
+#-----------------------------------------------------------------------------
+    my @cSourceCode = (
+                       "#include <libxml/xmlreader.h>\n",
+                       );
+    
+    testCompile($cflags, \@cSourceCode, $successR);
+}
+
+
+
+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
+
+}
+
+
+
+sub testCompileXmlReaderTypes($$) {
+    my ($cflags, $successR) = @_;
+#-----------------------------------------------------------------------------
+#  Do a test compile to see if xmlreader.h defines xmlReaderTypes,
+#  assuming we can compile with xmlreader.h in general.
+#-----------------------------------------------------------------------------
+    my @cSourceCode = (
+                       "#include <libxml/xmlreader.h>\n",
+                       "xmlReaderTypes dummy;\n",
+                       );
+    
+    testCompile($cflags, \@cSourceCode, $successR);
+}
+
+
+
+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
+}
+
+
+
+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
+}
+
+
+
+sub testLibxml2Hdr() {
+#-----------------------------------------------------------------------------
+#  Issue a warning if the instructions 'xml2-config' give for compiling
+#  with Libxml2 don't work.  In particular, note whether they get us a
+#  modern enough Libxml2 to have the 'xmlReaderTypes' type.
+#-----------------------------------------------------------------------------
+    if (commandExists('xml2-config')) {
+        my $generalCflags = testCflags();
+
+        my $xml2Cflags = qx{xml2-config --cflags};
+        chomp($xml2Cflags);
 
+        testCompileXmlreaderH("$generalCflags $xml2Cflags", \my $success);
+
+        if (!$success) {
+            printBadXml2CflagsWarning($xml2Cflags);
+        } else {
+            testCompileXmlReaderTypes("$generalCflags $xml2Cflags",
+                                      \my $success);
+
+            if (!$success) {
+                printMissingXmlReaderTypesWarning();
+            }
+        }
+    } else {
+        printNoLibxml2Warning();
     }
 }
 
 
 
-sub testConfiguration($$$$$$$) {
+sub testConfiguration($$$$$$) {
 
-    my ($needLocal, $jpeglib, $jpeghdr_dir,
+    my ($jpeglib, $jpeghdr_dir,
         $pnglib, $pnghdr_dir, $zlib, $zhdr_dir) = @_;
 
     if (defined($jpeglib)) {
-        testJpegHdr($needLocal, $jpeghdr_dir);
+        testJpegHdr($jpeghdr_dir);
     }
     if (defined($pnglib) && defined($zlib)) {
-        testPngHdr($needLocal, $pnghdr_dir, $zhdr_dir);
+        testPngHdr($pnghdr_dir, $zhdr_dir);
     } elsif (commandExists('libpng-config')) {
-        testLibpngConfig($needLocal);
+        testLibpngConfig();
     }
+    testLibxml2Hdr();
 
     # TODO: We ought to validate other libraries too.  But it's not
     # that important, because in the vast majority of cases where the
@@ -1546,8 +1769,8 @@ if (@ARGV > 0) {
     $configInPathArg = $ARGV[0];
 }
 
-if (stat("Makefile.config")) {
-    print("Discard existing Makefile.config?\n");
+if (stat("config.mk")) {
+    print("Discard existing config.mk?\n");
     print("Y or N (N) ==> ");
 
     my $answer = <STDIN>;
@@ -1570,21 +1793,22 @@ my ($platform, $subplatform) = getPlatform();
 print("\n");
 
 if ($platform eq "NONE") {
-    print("You will have to construct Makefile.config manually.  To do \n");
-    print("this, copy Makefile.config.in as Makefile.config, and then \n");
+    print("You will have to construct config.mk manually.  To do \n");
+    print("this, copy config.mk.in as config.mk, and then \n");
     print("edit it.  Follow the instructions and examples in the file. \n");
     print("Please report your results to the Netpbm maintainer so he \n");
     print("can improve the configure program. \n");
     exit;
 }
 
-getCompiler($platform, \my $compiler);
+getCompiler($platform, $subplatform, \my $compiler);
+
 getLinker($platform, $compiler, \my $baseLinker, \my $linkViaCompiler);
 
 chooseTestCompiler($compiler, \$testCc);
 
 my $netpbmlib_runtime_path;
-    # Undefined if the default from Makefile.config.in is acceptable.
+    # Undefined if the default from config.mk.in is acceptable.
 
 if ($platform eq "SOLARIS" or $platform eq "IRIX" or
     $platform eq "DARWIN" or $platform eq "NETBSD" or
@@ -1728,8 +1952,7 @@ validateLibraries($jpeglib, $tifflib, $pnglib, $zlib);
 
 warnJpegTiffDependency($jpeglib, $tifflib);
 
-testConfiguration(needLocal($platform), 
-                  $jpeglib, $jpeghdr_dir,
+testConfiguration($jpeglib, $jpeghdr_dir,
                   $pnglib, $pnghdr_dir,
                   $zlib, $zhdr_dir,
                   );
@@ -1745,7 +1968,7 @@ my $defaultConfigInPath;
 if (-f("GNUmakefile")) {
     # He's apparently running us in the source tree or an already set up
     # build directory.
-    $defaultConfigInPath = "Makefile.config.in";
+    $defaultConfigInPath = "config.mk.in";
 } else {
     my $srcdir;
     my $done;
@@ -1770,41 +1993,24 @@ if (-f("GNUmakefile")) {
     unlink("Makefile");
     symlink("$srcdir/Makefile", "Makefile");
 
-    open(SRCDIR, ">Makefile.srcdir");
+    open(SRCDIR, ">srcdir.mk");
     print(SRCDIR "SRCDIR = $srcdir\n");
     close(SRCDIR);
     
-    $defaultConfigInPath = "$srcdir/Makefile.config.in";
-}
-
-sub makeCompilerGcc($) {
-    my ($Makefile_configR) = @_;
-    my $compileCommand = 'gcc';
-    push(@{$Makefile_configR}, "CC = $compileCommand\n");
-    push(@{$Makefile_configR}, gnuCflags($compileCommand));
+    $defaultConfigInPath = "$srcdir/config.mk.in";
 }
 
-
 #******************************************************************************
 #
-#  BUILD Makefile.config
+#  BUILD config.mk
 #
 #*****************************************************************************
 
-sub gnuCflags($) {
-    my ($gccCommandName) = @_;
-
-    return("CFLAGS = " . gnuOptimizeOpt($gccCommandName) . " -ffast-math " .
-           " -pedantic -fno-common " . 
-           "-Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit " .
-           "-Wwrite-strings -Wmissing-prototypes -Wundef\n");
-}
-
-my @Makefile_config;
-    # This is the complete Makefile.config contents.  We construct it here
-    # and ultimately write the whole thing out as Makefile.config.
+my @config_mk;
+    # This is the complete config.mk contents.  We construct it here
+    # and ultimately write the whole thing out as config.mk.
 
-# First, we just read the 'Makefile.config.in' in
+# First, we just read the 'config.mk.in' in
 
 my $configInPath;
 if (defined($configInPathArg)) {
@@ -1815,9 +2021,9 @@ if (defined($configInPathArg)) {
 open (CONFIG_IN,"<$configInPath") or
     die("Unable to open file '$configInPath' for input.");
 
-@Makefile_config = <CONFIG_IN>;
+@config_mk = <CONFIG_IN>;
 
-unshift(@Makefile_config, 
+unshift(@config_mk, 
         "####This file was automatically created by 'configure.'\n",
         "####Many variables are set twice -- a generic setting, then \n",
         "####a system-specific override at the bottom of the file.\n",
@@ -1826,101 +2032,98 @@ unshift(@Makefile_config,
 close(CONFIG_IN);
 
 # Now, add the variable settings that override the default settings that are
-# done by the Makefile.config.in contents.
+# done by the config.mk.in contents.
 
-push(@Makefile_config, "\n\n\n\n");
-push(@Makefile_config, "####Lines above were copied from Makefile.config.in " .
+push(@config_mk, "\n\n\n\n");
+push(@config_mk, "####Lines above were copied from config.mk.in " .
      "by 'configure'.\n");
-push(@Makefile_config, "####Lines below were added by 'configure' based on " .
+push(@config_mk, "####Lines below were added by 'configure' based on " .
      "the $platform platform.\n");
 if (defined($subplatform)) {
-    push(@Makefile_config, "####subplatform '$subplatform'\n");
+    push(@config_mk, "####subplatform '$subplatform'\n");
 }
 
-push(@Makefile_config, "DEFAULT_TARGET = $default_target\n");
+push(@config_mk, "DEFAULT_TARGET = $default_target\n");
 
-push(@Makefile_config, "NETPBMLIBTYPE=$netpbmlibtype\n");
-push(@Makefile_config, "NETPBMLIBSUFFIX=$netpbmlibsuffix\n");
+push(@config_mk, "NETPBMLIBTYPE=$netpbmlibtype\n");
+push(@config_mk, "NETPBMLIBSUFFIX=$netpbmlibsuffix\n");
 if (defined($shlibprefixlist)) {
-    push(@Makefile_config, "SHLIBPREFIXLIST=$shlibprefixlist\n");
+    push(@config_mk, "SHLIBPREFIXLIST=$shlibprefixlist\n");
 }
-push(@Makefile_config, "STATICLIB_TOO=$staticlib_too\n");
+push(@config_mk, "STATICLIB_TOO=$staticlib_too\n");
 
 if (defined($netpbmlib_runtime_path)) {
-    push(@Makefile_config, "NETPBMLIB_RUNTIME_PATH=$netpbmlib_runtime_path\n");
+    push(@config_mk, "NETPBMLIB_RUNTIME_PATH=$netpbmlib_runtime_path\n");
 }
 
 if ($platform eq "GNU") {
-    my $compileCommand;
     if (!commandExists("cc") && commandExists("gcc")) {
-        $compileCommand = "gcc";
-        push(@Makefile_config, "CC = $compileCommand\n");
+        makeCompilerGcc(\@config_mk);
     } else {
-        $compileCommand = "cc";
+        push(@config_mk, gnuCflags('cc'));
     }
-    push(@Makefile_config, gnuCflags($compileCommand));
 # The merged programs have a main_XXX subroutine instead of main(),
 # which would cause a warning with -Wmissing-declarations or 
 # -Wmissing-prototypes.
-    push(@Makefile_config, "CFLAGS_MERGE = " .
+    push(@config_mk, "CFLAGS_MERGE = " .
          "-Wno-missing-declarations -Wno-missing-prototypes\n");
-    push(@Makefile_config, "LDRELOC = ld --reloc\n");
-    push(@Makefile_config, "LINKER_CAN_DO_EXPLICIT_LIBRARY=Y\n");
+    push(@config_mk, "LDRELOC = ld --reloc\n");
+    push(@config_mk, "LINKER_CAN_DO_EXPLICIT_LIBRARY=Y\n");
 } elsif ($platform eq "SOLARIS") {
-    push(@Makefile_config, 'LDSHLIB = -Wl,-Bdynamic,-G,-h,$(SONAME)', "\n");
+    push(@config_mk, 'LDSHLIB = -Wl,-Bdynamic,-G,-h,$(SONAME)', "\n");
 
-    push(@Makefile_config, 'NEED_RUNTIME_PATH = Y', "\n");
+    push(@config_mk, 'NEED_RUNTIME_PATH = Y', "\n");
     if ($compiler eq "cc") {
-        push(@Makefile_config, "CFLAGS = -O\n");
-        push(@Makefile_config, "CFLAGS_SHLIB = -Kpic\n");
+        push(@config_mk, "CFLAGS = -O\n");
+        push(@config_mk, "CFLAGS_SHLIB = -Kpic\n");
     } else {
-        makeCompilerGcc(\@Makefile_config);
+        makeCompilerGcc(\@config_mk);
     }
     # Before Netpbm 10.20 (January 2004), we set this to -R for 
     # $compiler == cc and -rpath otherwise.  But now we know that the GNU
     # compiler can also invoke a linker that needs -R, so we're more flexible.
     if ($baseLinker eq "GNU") {
-        push(@Makefile_config, "RPATHOPTNAME = -rpath\n");
+        push(@config_mk, "RPATHOPTNAME = -rpath\n");
     } else {
-        push(@Makefile_config, "RPATHOPTNAME = -R\n");
+        push(@config_mk, "RPATHOPTNAME = -R\n");
     }
-    push(@Makefile_config, "NETWORKLD = -lsocket -lnsl\n");
+    push(@config_mk, "NETWORKLD = -lsocket -lnsl\n");
 } elsif ($platform eq "HP-UX") {
     if ($compiler eq "gcc") {
-        makeCompilerGcc(\@Makefile_config);
-        push(@Makefile_config, "CFLAGS += -fPIC\n");
-        push(@Makefile_config, "LDSHLIB = -shared -fPIC\n");
-        push(@Makefile_config, 'LDFLAGS += -Wl,+b,/usr/pubsw/lib', "\n");
+        makeCompilerGcc(\@config_mk);
+        push(@config_mk, "CFLAGS += -fPIC\n");
+        push(@config_mk, "LDSHLIB = -shared -fPIC\n");
+        push(@config_mk, 'LDFLAGS += -Wl,+b,/usr/pubsw/lib', "\n");
     } else {
         # We don't know what to do here.  We used to (before 10.20) just
         # just assume the compiler was gcc.  We know that the gcc stuff
         # above does NOT work for HP native compiler.
-        push(@Makefile_config, "LDSHLIB =\n");
+        push(@config_mk, "LDSHLIB =\n");
     }
 } elsif ($platform eq "AIX") {
-    push(@Makefile_config, 'LDFLAGS = -L /usr/pubsw/lib', "\n");
+    push(@config_mk, 'LDFLAGS += -L /usr/pubsw/lib', "\n");
     if ($compiler eq "cc") {
         # Yes, the -L option implies the runtime as well as linktime library
         # search path.  There's no way to specify runtime path independently.
-        push(@Makefile_config, "RPATHOPTNAME = -L\n");
-        push(@Makefile_config, "LDSHLIB = -qmkshrobj\n");
+        push(@config_mk, "RPATHOPTNAME = -L\n");
+        push(@config_mk, "LDSHLIB = -qmkshrobj\n");
     } else {
-        makeCompilerGcc(\@Makefile_config);
-        push(@Makefile_config, "LDSHLIB = -shared\n");
+        makeCompilerGcc(\@config_mk);
+        push(@config_mk, "LDSHLIB = -shared\n");
     }
 } elsif ($platform eq "TRU64") {
-#    push(@Makefile_config, "INSTALL = installbsd\n");
+#    push(@config_mk, "INSTALL = installbsd\n");
     if ($compiler eq "cc") {
-        push(@Makefile_config, 'CFLAGS = -O2 -std1', "\n");
-        push(@Makefile_config, "LDFLAGS = -call_shared -oldstyle_liblookup " .
+        push(@config_mk, 'CFLAGS = -O2 -std1', "\n");
+        push(@config_mk, "LDFLAGS = -call_shared -oldstyle_liblookup " .
              "-L/usr/local/lib\n");
-        push(@Makefile_config, "LDSHLIB = -shared -expect_unresolved \"*\"\n");
+        push(@config_mk, "LDSHLIB = -shared -expect_unresolved \"*\"\n");
     } else {
         # We've never tested this.  This is just here to give a user a 
         # headstart on submitting to us the necessary information.  2002.07.04.
-        push(@Makefile_config, "CC = gcc\n");
-        push(@Makefile_config, 'CFLAGS = -O3', "\n");
-        push(@Makefile_config, "LDSHLIB = -shared\n");
+        push(@config_mk, "CC = gcc\n");
+        push(@config_mk, 'CFLAGS = -O3', "\n");
+        push(@config_mk, "LDSHLIB = -shared\n");
     }
     # Between May 2000 and July 2003, we had -DLONG_32 in these options.
     # We took it out because it generated bad code for a TRU64 user in
@@ -1928,76 +2131,80 @@ if ($platform eq "GNU") {
     # only Ppmtompeg and it isn't clear that using long instead of int is
     # ever right anyway.
 
-    push(@Makefile_config, "OMIT_NETWORK = y\n");
-    push(@Makefile_config, "LINKER_CAN_DO_EXPLICIT_LIBRARY=Y\n");
+    push(@config_mk, "OMIT_NETWORK = y\n");
+    push(@config_mk, "LINKER_CAN_DO_EXPLICIT_LIBRARY=Y\n");
 } elsif ($platform eq "IRIX") {
-#    push(@Makefile_config, "INSTALL = install\n");
-    push(@Makefile_config, "MANPAGE_FORMAT = cat\n");
-    push(@Makefile_config, "RANLIB = true\n");
-    push(@Makefile_config, "CFLAGS = -n32 -O3 -fullwarn\n");
-    push(@Makefile_config, "LDFLAGS = -n32\n");
-    push(@Makefile_config, "LDSHLIB = -shared -n32\n");
+#    push(@config_mk, "INSTALL = install\n");
+    push(@config_mk, "MANPAGE_FORMAT = cat\n");
+    push(@config_mk, "RANLIB = true\n");
+    push(@config_mk, "CFLAGS = -n32 -O3 -fullwarn\n");
+    push(@config_mk, "LDFLAGS = -n32\n");
+    push(@config_mk, "LDSHLIB = -shared -n32\n");
 } elsif ($platform eq "WINDOWS") {
     if ($subplatform eq "cygwin") {
-        makeCompilerGcc(\@Makefile_config);
+        makeCompilerGcc(\@config_mk);
     }
-    push(@Makefile_config, "EXE = .exe\n");
-    push(@Makefile_config, "OMIT_NETWORK = y\n");
+    push(@config_mk, "EXE = .exe\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`;
 #    if (!$ginstall_result) {
 #        # System doesn't have 'ginstall', so use 'install' instead.
-#        push(@Makefile_config, "INSTALL = install\n");
+#        push(@config_mk, "INSTALL = install\n");
 #    }
-    push(@Makefile_config, 'SYMLINK = ', symlink_command(), "\n");
-    push(@Makefile_config, 'DLLVER=$(NETPBM_MAJOR_RELEASE)', "\n");
-    push(@Makefile_config, "LDSHLIB = " . 
+    push(@config_mk, 'SYMLINK = ', symlink_command(), "\n");
+    push(@config_mk, 'DLLVER=$(NETPBM_MAJOR_RELEASE)', "\n");
+    push(@config_mk, "LDSHLIB = " . 
          '-shared -Wl,--image-base=0x10000000 -Wl,--enable-auto-import', "\n");
+    if ($subplatform ne "cygwin") {
+        push(@config_mk, "MSVCRT = Y\n");
+    }
 } elsif ($platform eq "BEOS") {
-    push(@Makefile_config, "LDSHLIB = -nostart\n");
+    push(@config_mk, "LDSHLIB = -nostart\n");
 } elsif ($platform eq "OPENBSD") {
     # vedge@vedge.com.ar says on 2001.04.29 that there are a ton of 
     # undefined symbols in the Fiasco stuff on OpenBSD.  So we'll just
     # cut it out of the build until someone feels like fixing it.
-    push(@Makefile_config, "BUILD_FIASCO = N\n");
+    push(@config_mk, "BUILD_FIASCO = N\n");
 } elsif ($platform eq "FREEBSD") {
 } elsif ($platform eq "AMIGA") {
-    push(@Makefile_config, "CFLAGS = -m68020-60 -ffast-math -mstackextend\n");
+    push(@config_mk, "CFLAGS = -m68020-60 -ffast-math -mstackextend\n");
 } elsif ($platform eq "UNIXWARE") {
     # Nothing to do.
 } elsif ($platform eq "SCO") {
     # Got this from "John H. DuBois III" <spcecdt@armory.com> 2002.09.27:
-    push(@Makefile_config, "RANLIB = true\n");
+    push(@config_mk, "RANLIB = true\n");
     if ($compiler eq "cc") {
-        push(@Makefile_config, "CFLAGS = -O\n");
-        push(@Makefile_config, "CFLAGS_SHLIB = -O -K pic\n");
-        push(@Makefile_config, "LDSHLIB = -G\n");
-        push(@Makefile_config, "SHLIB_CLIB =\n");
+        push(@config_mk, "CFLAGS = -O\n");
+        push(@config_mk, "CFLAGS_SHLIB = -O -K pic\n");
+        push(@config_mk, "LDSHLIB = -G\n");
+        push(@config_mk, "SHLIB_CLIB =\n");
     } else {
-        makeCompilerGcc(\@Makefile_config);
-        push(@Makefile_config, "LDSHLIB = -shared\n"); 
+        makeCompilerGcc(\@config_mk);
+        push(@config_mk, "LDSHLIB = -shared\n"); 
     }
-    push(@Makefile_config, "NETWORKLD = -lsocket -lresolve\n");
+    push(@config_mk, "NETWORKLD = -lsocket -lresolve\n");
 } elsif ($platform eq "DARWIN") {
-    push(@Makefile_config, "CC = cc -no-cpp-precomp\n");
-    push(@Makefile_config, 'CFLAGS_SHLIB = -fno-common', "\n");
-    push(@Makefile_config, "LDSHLIB = ",
-         "-dynamiclib ",
-         '-install_name $(NETPBMLIB_RUNTIME_PATH)/libnetpbm.$(MAJ).dylib', 
-         "\n");
-#    push(@Makefile_config, "INSTALL = install\n");
+    push(@config_mk, "CC = cc -no-cpp-precomp\n");
+    push(@config_mk, gnuCflags('cc'));
+    push(@config_mk, 'CFLAGS_SHLIB = -fno-common', "\n");
+
+    my $installNameOpt;
+    if ($netpbmlib_runtime_path eq '') {
+        $installNameOpt = '';
+    } else {
+        $installNameOpt  =
+            '-install_name $(NETPBMLIB_RUNTIME_PATH)/libnetpbm.$(MAJ).dylib';
+    }
+    push(@config_mk, "LDSHLIB = -dynamiclib $installNameOpt\n");
+#    push(@config_mk, "INSTALL = install\n");
 } else {
     die ("Internal error: invalid value for \$platform: '$platform'\n");
 }
 
-if (needLocal($platform)) {
-    push(@Makefile_config, "CFLAGS += -I/usr/local/include\n");
-    push(@Makefile_config, "LDFLAGS += -L/usr/local/lib\n");
-}
-
 if ($linkViaCompiler) {
-    push(@Makefile_config, "LINKERISCOMPILER = Y\n");
+    push(@config_mk, "LINKERISCOMPILER = Y\n");
 }
 
 my $flex_result = `flex --version`;
@@ -2019,7 +2226,7 @@ if (!$flex_result) {
         my $key = <STDIN>;
         print("\n");
 
-        push(@Makefile_config, "LEX=\n");
+        push(@config_mk, "LEX=\n");
     } else {
         print("\n");
         print("Using 'lex' as the pattern matcher generator, " .
@@ -2027,70 +2234,70 @@ if (!$flex_result) {
         print("find 'flex' on your system.\n");
         print("\n");
 
-        push(@Makefile_config, "LEX = lex\n"); 
+        push(@config_mk, "LEX = lex\n"); 
     }
 }
 
 if ($compiler eq 'gcc') {
-    push(@Makefile_config, "CFLAGS_SHLIB += -fPIC\n");
+    push(@config_mk, "CFLAGS_SHLIB += -fPIC\n");
 }
 
 if (defined($tiffhdr_dir)) {
-    push(@Makefile_config, "TIFFHDR_DIR = $tiffhdr_dir\n");
+    push(@config_mk, "TIFFHDR_DIR = $tiffhdr_dir\n");
 }
 if (defined($tifflib)) {
-    push(@Makefile_config, "TIFFLIB = $tifflib\n");
+    push(@config_mk, "TIFFLIB = $tifflib\n");
 }
 
 if (defined($jpeghdr_dir)) {
-    push(@Makefile_config, "JPEGHDR_DIR = $jpeghdr_dir\n");
+    push(@config_mk, "JPEGHDR_DIR = $jpeghdr_dir\n");
 }
 if (defined($jpeglib)) {
-    push(@Makefile_config, "JPEGLIB = $jpeglib\n");
+    push(@config_mk, "JPEGLIB = $jpeglib\n");
 }
 
 if (defined($pnghdr_dir)) {
-    push(@Makefile_config, "PNGHDR_DIR = $pnghdr_dir\n");
+    push(@config_mk, "PNGHDR_DIR = $pnghdr_dir\n");
 }
 if (defined($pnglib)) {
-    push(@Makefile_config, "PNGLIB = $pnglib\n");
+    push(@config_mk, "PNGLIB = $pnglib\n");
 }
 
 if (defined($zhdr_dir)) {
-    push(@Makefile_config, "ZHDR_DIR = $zhdr_dir\n");
+    push(@config_mk, "ZHDR_DIR = $zhdr_dir\n");
 }
 if (defined($zlib)) {
-    push(@Makefile_config, "ZLIB = $zlib\n");
+    push(@config_mk, "ZLIB = $zlib\n");
 }
 
 if (defined($x11hdr_dir)) {
-    push(@Makefile_config, "X11HDR_DIR = $x11hdr_dir\n");
+    push(@config_mk, "X11HDR_DIR = $x11hdr_dir\n");
 }
 if (defined($x11lib)) {
-    push(@Makefile_config, "X11LIB = $x11lib\n");
+    push(@config_mk, "X11LIB = $x11lib\n");
 }
 
 if (defined($linuxsvgahdr_dir)) {
-    push(@Makefile_config, "LINUXSVGAHDR_DIR = $linuxsvgahdr_dir\n");
+    push(@config_mk, "LINUXSVGAHDR_DIR = $linuxsvgahdr_dir\n");
 }
 if (defined($linuxsvgalib)) {
-    push(@Makefile_config, "LINUXSVGALIB = $linuxsvgalib\n");
+    push(@config_mk, "LINUXSVGALIB = $linuxsvgalib\n");
 }
 
 if (defined($netpbm_docurl)) {
-    push(@Makefile_config, "NETPBM_DOCURL = $netpbm_docurl\n");
+    push(@config_mk, "NETPBM_DOCURL = $netpbm_docurl\n");
 }
 
 if ($inttypesHeaderFile ne '<inttypes.h>') {
-    push(@Makefile_config, "INTTYPES_H = $inttypesHeaderFile\n");
+    push(@config_mk, "INTTYPES_H = $inttypesHeaderFile\n");
 }
 
 if ($haveInt64 ne 'Y') {
-    push(@Makefile_config, "HAVE_INT64 = $haveInt64\n");
+    push(@config_mk, "HAVE_INT64 = $haveInt64\n");
 }
 
 if ($dontHaveProcessMgmt) {
-    push(@Makefile_config, "DONT_HAVE_PROCESS_MGMT = Y\n");
+    push(@config_mk, "DONT_HAVE_PROCESS_MGMT = Y\n");
 }
 
 #******************************************************************************
@@ -2099,23 +2306,21 @@ if ($dontHaveProcessMgmt) {
 #
 #*****************************************************************************
 
-open(MAKEFILE_CONFIG, ">Makefile.config") or
-    die("Unable to open Makefile.config for writing in the current " .
+open(config_mk, ">config.mk") or
+    die("Unable to open config.mk for writing in the current " .
         "directory.");
 
-print MAKEFILE_CONFIG @Makefile_config;
+print config_mk @config_mk;
 
-close(MAKEFILE_CONFIG) or
-    die("Error:  Close of Makefile.config failed.\n");
+close(config_mk) or
+    die("Error:  Close of config.mk failed.\n");
 
 print("\n");
-print("We have created the file 'Makefile.config'.  Note, however, that \n");
-print("we guessed a lot at your configuration and you may want to look \n");
-print("at Makefile.config and edit it to your requirements and taste \n");
-print("before doing the make.\n");
+print("We have created the file 'config.mk'.  You may want to look \n");
+print("at it and edit it to your requirements and taste before doing the \n");
+print("make.\n");
 print("\n");
 
-
 print("Now you may proceed with 'make'\n");
 print("\n");
 
diff --git a/buildtools/debian/README b/buildtools/debian/README
deleted file mode 100644
index 1c600c6b..00000000
--- a/buildtools/debian/README
+++ /dev/null
@@ -1,122 +0,0 @@
-Files in this directory are for creating a Debian package (.deb file),
-which one can use to install Netpbm on a Debian system (or a system running
-a derivative of Debian, such as Ubuntu or Mint).
-
-You can of course install on one of these systems by running 'installnetpbm',
-or otherwise inserting all the files in the proper place in your system file
-tree, but having a Debian package allows you to manage those files using
-Debian's normal package management.  The package management system will know
-where the Netpbm files came from, and you can upgrade or remove Netpbm easily.
-The package management system will also be aware of prerequisites of Netpbm
-and ensure that you don't have Debian's own inferior version of Netpbm
-installed (which would cause conflicts).
-
-The package we create is named 'netpbm-sf' (where the "sf" is from
-"SourceForge"), to be distinct from the package named "netpbm" which is part
-of Debian.
-
-To install Netpbm as a Debian package:
-
-  1) Follow the regular instructions to build and package Netpbm
-     (configure, make, make package).
-
-  2) With the root of the built Netpbm build tree as your current
-     directory:
-
-     $ make deb
-
-     (This defaults to getting Netpbm from /tmp/netpbm, which is also where
-     'make package' defaults to putting it).
-
-  3) $ dpkg --install netpbm-sfXXXX.deb
-
-     (netpbm-sfXXXX.deb is the file created by 'makedeb', in the current
-     directory).
-
-
-PREREQUSISITES
---------------
-
-The following information was taken from the Wheezy version of Debian, in
-January 2014.
-
-You don't actually need the current version of any of these.  For example,
-while we list package libjpeg8-dev, the package libjpeg62-dev works fine.
-
-
-Building
---------
-
-You need the following Debian packages to build all of Netpbm.
-
-You could omit some of these and, in the Netpbm build configuration dialog,
-indicate you don't have them, and the build will simply omit some parts.
-For example, if you don't install libx11-dev, the Netpbm build process
-will not build the 'pamx' program.
-
-  libjpeg8-dev
-  libpng12-0-dev
-  libsvga1-dev
-  libtiff5-dev
-  libx11-dev
-  libxml2a-dev
-  zlib1g-dev
-
-
-In addition, you need the following build tools:
-
-  make
-  gcc
-  flex
-  perl
-  pkg-config
-
-
-
-Running
--------
-
-The following Debian packages are the known prerequisites for running Netpbm
-(and the package created by 'mkdeb' knows this).
-
-    libc6
-    libjpeg8
-    libpng12-0
-    libsvga1
-    libtiff5
-    libx11-6
-    zlib1g
-    ghostscript
-    perl
-    perl-base
-    bash
-
-Note that many of these are needed only for a few parts of Netpbm, and it will
-be pretty obvious what the problem is when you need the prerequisite package
-and don't have it, so if you don't want to install a prerequisite, it would
-probably be fine to force install Netpbm, ignoring the prerequisites.
-
-
-CONFLICTS WITH DEBIAN'S NETPBM
-------------------------------
-
-Debian has several packages of Netpbm, all based on a slightly modified
-Sourceforge Netpbm 9.25 from 2002 (don't be confused by Debian's numbering
-system, which makes it look like it is Netpbm 10).  If you want to install
-Sourceforge Netpbm on your system, you will want first to remove any of these
-you have installed:
-
-  netpbm
-  netpbm-dev
-  libnetpbm9
-  libnetpbm10
-
-Sourceforge Netpbm should be backward compatible with all of those.  Note that
-'mkdeb' makes only one package.  It contains the programs, the runtime
-libraries, and the development files.
-
-We have not yet worked out what has to be done about the fact that the Debian
-packaging system thinks the Debian Netpbm packages are prerequisites for
-things.  If you install Sourceforge Netpbm via the package created by mkdeb,
-you should tell the Netpbm maintainer whatever you learn about that.
-
diff --git a/buildtools/debian/mkdeb b/buildtools/debian/mkdeb
deleted file mode 100755
index 42a986eb..00000000
--- a/buildtools/debian/mkdeb
+++ /dev/null
@@ -1,541 +0,0 @@
-#!/usr/bin/perl
-###############################################################################
-#                                mkdeb
-###############################################################################
-#
-#  This generates a Debian packge file (.deb) to install Sourceforge
-#  Netpbm on a Debian system.
-#
-#  This is especially useful because Debian does not have a good Debian
-#  package (what Debian contains is derived from Sourceforge Netpbm ca.
-#  2002).
-#
-###############################################################################
-
-use strict;
-use warnings;
-use English;
-use Getopt::Long;
-
-my $TRUE=1; my $FALSE = 0;
-
-
-
-sub parseCommandLine(@) {
-
-    local @ARGV = @_;  # GetOptions takes input from @ARGV only
-
-    my %cmdline;
-
-    my $validOptions = GetOptions(\%cmdline,
-                                  "buildtools=s",
-                                  "arch=s",
-                                  "pkgdir=s",
-        );
-
-    if (!$validOptions) {
-        print(STDERR "Invalid option syntax.\n");
-        exit(1);
-    }
-    if (@ARGV > 0) {
-        print(STDERR "This program takes no non-option arguments.  " .
-              "You specified ",
-              scalar(@ARGV), "\n");
-        exit(1);
-    } 
-
-    return(\%cmdline);
-}
-
-
-
-sub writeFile($$$$) {
-    my ($fileLinesR, $fileName, $executable, $errorR) = @_;
-
-    my $success = open(FILE, ">$fileName");
-    if ($success) {
-        if ($executable eq 'EXECUTABLE') {
-            chmod(0755, $fileName);
-        } else {
-            chmod(0644, $fileName);
-        }
-        foreach (@{$fileLinesR}) { print FILE; }
-        close(FILE);
-    } else {
-        $$errorR = "Unable to open the file " .
-            "'$fileName' for writing.  Errno=$ERRNO\n";
-    }
-}
-
-
-
-sub netpbmVersion($) {
-    my ($pkgdir) = @_;
-
-    my $versionFileName = "$pkgdir/VERSION";
-
-    my $versionOpened = open(VERSION, "<$versionFileName");
-
-    my $retval;
-    my $error;
-
-    if (!$versionOpened) {
-        $error = "Unable to open '$versionFileName' for reading.  " .
-            "Errno=$ERRNO\n";
-    } else {
-        my $version = <VERSION>;
-        chomp($version);
-
-        if ($version =~ m{^Netpbm (\S*)}) {
-            my ($versionNumber) = ($1);
-            $retval = $versionNumber;
-        } else {
-            die("Can't understand format of '$versionFileName': '$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");
-        $retval = "???";
-    }
-    return $retval;
-}
-
-
-
-sub control($$) {
-    my ($release, $architecture) = @_;
-
-# The Debian packaging system doesn't provide a way to express Netpbm's actual
-# prerequisites.  For example, Netpbm needs Version 6.2 or better of Libjpeg,
-# but there is no way to state that here.  Instead, we state Libjpeg 8.
-# This makes the Netpbm package less useful.
-
-    my %control;
-
-    my $debianNativeNetpbm = 
-        'netpbm, ' .
-        'libnetpbm10, ' .
-        'libnetpbm10-dev, ' .
-        'netpbm-dev, ' .
-        'netpbm-nonfree, ' .
-        'pbmwbmp, ' .
-        'pnmtopng, ' .
-        'ucbmpeg';
-
-    $control{'Package'} = 'netpbm-sf';
-    $control{'Version'} = $release;
-    $control{'Architecture'} = $architecture;
-    $control{'Maintainer'} = 'Bryan Henderson <bryanh@giraffe-data.com>';
-    $control{'Installed-Size'} = '6164';
-    $control{'Depends'} =
-        'libc6, ' .
-        'libjpeg62, ' .
-        'libpng12-0, ' .
-        'libsvga1, ' .
-        'libtiff4, ' .
-        'libx11-6, ' .
-        'libxml2, ' .
-        'zlib1g, ' .
-        'ghostscript, ' .
-        'perl, ' .
-        'perl-base, ' .
-        'bash'
-        ;
-    $control{'Recommends'} = '';
-    $control{'Recommends'} = '';
-    $control{'Conflicts'} = $debianNativeNetpbm;
-    $control{'Replaces'} = $debianNativeNetpbm;
-    $control{'Provides'} = 
-        'netpbm, ' .
-        'pbmwbmp, ' .
-        'pnmtopng, ' .
-        'netpbm-dev, ' .
-        'libnetpbm10'
-        ;
-    $control{'Section'} = 'graphics';
-    $control{'Priority'} = 'optional';
-    $control{'Section'} = 'graphics';
-    $control{'Description'} = 'Graphics conversion tools between image formats
- Netpbm is a toolkit for manipulation of graphic images, including
- conversion of images between a variety of different formats. There
- are over 300 separate tools in the package including converters for
- more than 80 graphics formats.  This is the Super Stable version from
- the Sourceforge Netpbm project, unmodified.';
-
-    return \%control;
-}
-
-
-
-sub writeControlFile($$) {
-    my ($controlR, $fileName) = @_;
-
-    open(CTL, '>', $fileName)
-        or die "Can't open '$fileName': $ERRNO";
-
-    while (my ($key, $value) = each %{$controlR}) {
-        print CTL ("$key: $value\n");
-    }
-    
-    close(CTL);
-}
-
-
-
-sub createScripts($$) {
-    my ($dpkgDirName, $buildToolsDir) = @_;
-
-    my @scriptList = ('postinst', 'postrm');
-
-    my @scriptFileList = map("$buildToolsDir/debian/$_", @scriptList);
-
-    system('cp', @scriptFileList, "$dpkgDirName/DEBIAN/") &&
-        die("Failed to copy postinst, etc. to '$dpkgDirName/DEBIAN'.");
-
-    my @createdFileList = map("$dpkgDirName/DEBIAN/$_", @scriptList);
-
-    chmod(0755, @createdFileList);
-}
-
-
-
-sub createDirOrDie($) {
-    my ($newDirName) = @_;
-
-    mkdir($newDirName)
-        or die("Couldn't create directory '$newDirName'.  $ERRNO");
-
-    chmod(0755, $newDirName);
-}
-
-
-
-sub 
-processTemplate($$$) {
-    my ($templateR, $infoR, $outputR) = @_;
-
-    my @output;
-
-    foreach (@{$templateR}) {
-        if (m{^@}) {
-            # Comment -- ignore it.
-        } else {
-            if (defined($infoR->{VERSION})) {
-                s/\@VERSION\@/$infoR->{VERSION}/;
-            }
-            if (defined($infoR->{BINDIR})) {
-                s/\@BINDIR@/$infoR->{BINDIR}/;
-            }
-            if (defined($infoR->{LIBDIR})) {
-                s/\@LIBDIR@/$infoR-.{LIBDIR}/;
-            }
-            if (defined($infoR->{LINKDIR})) {
-                s/\@LINKDIR@/$infoR->{LINKDIR}/;
-            }
-            if (defined($infoR->{DATADIR})) {
-                s/\@DATADIR@/$infoR->{DATADIR}/;
-            }
-            if (defined($infoR->{INCLUDEDIR})) {
-                s/\@INCLUDEDIR@/$infoR->{INCLUDEDIR}/;
-            }
-            if (defined($infoR->{MANDIR})) {
-                s/\@MANDIR@/$infoR->{MANDIR}/;
-            }
-            push(@output, $_);
-        }
-    }
-    $$outputR = \@output;
-}
-
-
-
-
-
-sub makeConfig($$$) {
-    my ($fileName, $templateSubsR, $netpbmPkgDir) = @_;
-#-----------------------------------------------------------------------------
-# Install 'netpbm-config' -- a program you run to tell you things about
-# how Netpbm is installed.
-#-----------------------------------------------------------------------------
-    my $error;
-
-    my $configTemplateFilename = $netpbmPkgDir . "/config_template";
-
-    my $templateOpened = open(TEMPLATE, "<$configTemplateFilename");
-    if (!$templateOpened) {
-        $error = "Can't open template file '$configTemplateFilename'.\n";
-    } else {
-        my @template = <TEMPLATE>;
-
-        close(TEMPLATE);
-
-        processTemplate(\@template, $templateSubsR, \my $fileContentsR);
-
-        writeFile($fileContentsR, $fileName, 'EXECUTABLE', \$error);
-    }
-    if ($error) {
-        print(STDERR "Failed to create the Netpbm configuration program.  " .
-              "$error\n");
-    }
-}
-
-
-
-sub makePkgConfig($$$) {
-    my ($fileName, $templateSubsR, $netpbmPkgDir) = @_;
-#-----------------------------------------------------------------------------
-# Install a pkg-config file (netpbm.pc) - used by the 'pkg-config' program to
-# find out various things about how Netpbm is installed.
-#-----------------------------------------------------------------------------
-    my $error;
-
-    my $pcTemplateFilename = "$netpbmPkgDir/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);
-
-        writeFile($fileContentsR, $fileName, 'NOTEXECUTABLE', \$error);
-    }
-    if ($error) {
-        print(STDERR "Failed to create the Netpbm Pkg-config file.  " .
-              "$error\n");
-    }
-}
-
-
-
-sub makeManweb($$) {
-    my ($dpkgDirName, $netpbmPkgDir) = @_;
-#-----------------------------------------------------------------------------
-#  Set up things so one can read the manual with e.g.
-#
-#    $ manweb pnmtojpeg
-#-----------------------------------------------------------------------------
-    my @manwebConfContents;
-
-    push(@manwebConfContents, "#Configuration file for Manweb\n");
-    push(@manwebConfContents, "webdir=/usr/man/web\n");
-
-    createDirOrDie("$dpkgDirName/etc");
-
-    my $manwebConfFileName = "$dpkgDirName/etc/manweb.conf";
-
-    writeFile(\@manwebConfContents, $manwebConfFileName,
-        'NOTEXECUTABLE', \my $error);
-
-    if ($error) {
-        die("Failed to create Manweb configuration file $manwebConfFileName");
-    }
-    createDirOrDie("$dpkgDirName/usr/man");
-
-    system('cp', '--archive',
-           "$netpbmPkgDir/man/web", "$dpkgDirName/usr/man/web") &&
-               die("Failed to copy executables from '$netpbmPkgDir/bin' " .
-                   "to '$dpkgDirName/usr/bin'");
-}
-
-
-
-sub buildDpkgBuildTree($$$$$) {
-    my ($dpkgDirName, $release, $netpbmPkgDir, $architecture,
-        $buildToolsDir) = @_;
-#-----------------------------------------------------------------------------
-#  Create the directory tree that is the input to Dpkg-deb --build.
-#  This tree contains all the files to be installed, _plus_ the control
-#  subdirectory named DEBIAN.
-#-----------------------------------------------------------------------------
-    print("Creating file tree for input to dpkg-deb --build as " .
-          "'$dpkgDirName'\n");
-
-    createDirOrDie($dpkgDirName);
-
-    createDirOrDie("$dpkgDirName/DEBIAN");
-
-    my $controlR = control($release, $architecture);
-
-    writeControlFile($controlR, "$dpkgDirName/DEBIAN/control");
-
-    createScripts($dpkgDirName, $buildToolsDir);
-
-    createDirOrDie("$dpkgDirName/usr");
-
-    system('cp', '--archive',
-           "$netpbmPkgDir/bin", "$dpkgDirName/usr/bin") &&
-               die("Failed to copy executables from '$netpbmPkgDir/bin' " .
-                   "to '$dpkgDirName/usr/bin'");
-
-    # doc.url is inappropriate with the program installed into the global
-    # /usr/bin .
-    unlink("$dpkgDirName/usr/bin/doc.url");
-
-    system("cp", "--archive", "$netpbmPkgDir/include",
-           "$dpkgDirName/usr/include") &&
-               die("Failed to copy header files from " .
-                   "'$netpbmPkgDir/include' " .
-                   "to '$dpkgDirName/usr/include'");
-
-    system("cp", "--archive",
-           "$netpbmPkgDir/lib", "$dpkgDirName/usr/lib") &&
-               die("Failed to copy libraries from '$netpbmPkgDir/lib' " .
-                   "to '$dpkgDirName/usr/lib'");
-
-    my @linkFileList = glob("$netpbmPkgDir/link/*");
-
-    if (@linkFileList > 0) {
-        system("cp", "--archive",
-               @linkFileList, "$dpkgDirName/usr/lib/") &&
-                   die("Failed to copy libraries from '$netpbmPkgDir/link' " .
-                       "to '$dpkgDirName/usr/lib'");
-    }
-    createDirOrDie("$dpkgDirName/usr/share");
-
-    system("cp", "--archive",
-           "$netpbmPkgDir/misc", "$dpkgDirName/usr/share/netpbm") &&
-               die("Failed to copy files from '$netpbmPkgDir/misc' " .
-                   "to '$dpkgDirName/usr/share/netpbm'");
-
-    # We install Netpbm in the default search path, so most of the values
-    # 'netpbm-config' returns are null strings.
-    my $templateSubsR =
-    {VERSION    => $release,
-     BINDIR     => '',
-     LIBDIR     => '',
-     LINKDIR    => '',
-     DATADIR    => '/usr/share/netpbm',
-     INCLUDEDIR => '',
-     MANDIR     => ''};
-
-    makeConfig("$dpkgDirName/usr/bin/netpbm-config", $templateSubsR,
-               $netpbmPkgDir);
-
-    createDirOrDie("$dpkgDirName/usr/lib/pkgconfig");
-
-    makePkgConfig("$dpkgDirName/usr/lib/pkgconfig/netpbm.pc", $templateSubsR,
-                  $netpbmPkgDir);
-
-    makeManweb($dpkgDirName, $netpbmPkgDir);
-}
-
-
-
-sub debianArchOfThisMachine() {
-
-    # A lazy implementation that handles only the most common cases
-
-    my $retval;
-
-    my $arch = qx{'arch'};
-    chomp($arch);
-
-    if ($arch eq 'x86_64') {
-        $retval = 'amd64';
-    } elsif ($arch =~ m{i.86}) {
-        $retval = 'i386';
-    } else {
-        die("Can't determine the Debian architecture classification of this " .
-            "system.  You'll have to give a -arch option");
-    }
-    return $retval;
-}
-
-
-
-sub buildToolsDir($) {
-    my ($cmdlineR) = @_;
-
-    my $retval;
-
-    if (exists($cmdlineR->{'buildtools'})) {
-        $retval = $cmdlineR->{'buildtools'};
-    } else {
-        if (-f('./debian/mkdeb')) {
-            $retval = '.';
-        } else {
-            die("The current directory does not appear to be 'buildtools' " .
-                "subdirectory of a Netpbm source tree, so you will have " .
-                "to use the -buildtools option to identify it");
-        }
-    }
-    return $retval;
-}
-
-
-
-sub netpbmPkgDir($) {
-    my ($cmdlineR) = @_;
-
-    my $retval;
-
-    if (exists($cmdlineR->{'pkgdir'})) {
-        $retval = $cmdlineR->{'pkgdir'};
-    } else {
-        my $tmpdir = $ENV{TMPDIR} || "/tmp";
-
-        my $defaultPkgDir = "$tmpdir/netpbm";
-
-        if (-d($defaultPkgDir)) {
-            $retval = $defaultPkgDir;
-        } else {
-            die("No directory '$defaultPkgDir' exists.  " .
-                "You can specify the Netpbm package directory " .
-                "(what 'make package' created), with a -pkgdir option");
-        }
-    }
-    return $retval;
-}
-
-
-
-sub arch($) {
-    my ($cmdlineR) = @_;
-
-    my $retval;
-
-    if (exists($cmdlineR->{'arch'})) {
-        $retval = $cmdlineR->{'arch'};
-    } else {
-        $retval = debianArchOfThisMachine();
-    }
-
-    return $retval;
-}
-
-
-
-###############################################################################
-#                               MAIN PROGRAM
-###############################################################################
-
-my $cmdlineR = parseCommandLine(@ARGV);
-
-my $buildTools = buildToolsDir($cmdlineR);
-
-my $netpbmPkgDir = netpbmPkgDir($cmdlineR);
-
-my $arch = arch($cmdlineR);
-
-my $release = netpbmVersion($netpbmPkgDir);
-
-my $dpkgDirName = "/tmp/netpbm-sf-$release";
- 
-buildDpkgBuildTree($dpkgDirName, $release, $netpbmPkgDir, $arch,
-                   $buildTools);
-
-my $debFileName = 'netpbm-sf-' . $release . '_' . $arch . '.deb';
-
-system('dpkg-deb', '--build', $dpkgDirName, $debFileName) &&
-    die("dpgk-deb --build with input '$dpkgDirName' failed.");
-
-system('rm', '--recursive', $dpkgDirName);
diff --git a/buildtools/debian/postinst b/buildtools/debian/postinst
deleted file mode 100755
index 60836d52..00000000
--- a/buildtools/debian/postinst
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-set -e
-if [ "$1" = "configure" ]; then
-  ldconfig
-fi
diff --git a/buildtools/debian/postrm b/buildtools/debian/postrm
deleted file mode 100755
index 5f0c15e7..00000000
--- a/buildtools/debian/postrm
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-set -e
-if [ "$1" = "remove" ]; then
-  ldconfig
-fi
diff --git a/buildtools/endiangen.c b/buildtools/endiangen.c
index 07560c10..6b88b896 100644
--- a/buildtools/endiangen.c
+++ b/buildtools/endiangen.c
@@ -59,9 +59,9 @@ byteOrder(void) {
 
 
 static unsigned int
-bitsPerWord(void) {
+bitsPerLong(void) {
 
-    return MAX(sizeof(long), sizeof(int)) * 8;
+    return sizeof(long) * 8;
 }
 
 
@@ -87,7 +87,7 @@ main(int argc, char **argv) {
            byteOrder() == ENDIAN_LITTLE ? "LITTLE_ENDIAN" : "BIG_ENDIAN");
     printf("#endif\n");
     printf("\n");
-    printf("#define BITS_PER_WORD %u\n", bitsPerWord());
+    printf("#define BITS_PER_LONG %u\n", bitsPerLong());
 
     return 0;
 }
diff --git a/buildtools/installnetpbm.pl b/buildtools/installnetpbm.pl
index f6ab7ca0..25376ec3 100755
--- a/buildtools/installnetpbm.pl
+++ b/buildtools/installnetpbm.pl
@@ -554,7 +554,19 @@ sub installHeader($$$) {
               "failed.\n");
         print("cp exit code is $rc\n");
     } else {
-        print("done.\n");
+        # Install symbolic links for backward compatibility (because the
+        # netpbm/ subdirectory wasn't used before Netpbm 10.41 (December
+        # 2007).
+
+        my $rc = system("cd $hdrDir; ln -s netpbm/* .");
+
+        if ($rc != 0) {
+            print("Failed to create backward compatibilty symlinks from " .
+                  "$hdrDir into $hdrDir/netpbm\n");
+            print("ln exit code is $rc\n");
+        } else {
+            print("done.\n");
+        }
     }
     $$includedirR = $hdrDir;
 }
diff --git a/buildtools/installosf b/buildtools/installosf
index a4e5c262..1d1d61a7 100755
--- a/buildtools/installosf
+++ b/buildtools/installosf
@@ -4,7 +4,7 @@
 # its $(INSTALL) program and invokes OSF1 Install with the proper
 # parameters to effect what the make file wants.  If your system has
 # OSF1 Install on it, you can just set the INSTALL variable in
-# Makefile.config to "installosf" and 'make install' will work for
+# config.mk to "installosf" and 'make install' will work for
 # you.
 
 # Of course, you could also just install Ginstall and forget about this
diff --git a/buildtools/libopt.c b/buildtools/libopt.c
index 8e21e1be..a0bf1cda 100644
--- a/buildtools/libopt.c
+++ b/buildtools/libopt.c
@@ -11,8 +11,8 @@
   filename to be searched for in the linker's default search path, and
   generate a -l option, but no -L.
 
-  If an argument doesn't make sense as a library filespec, it is
-  copied verbatim, blank delimited, to the output string.
+  If an argument doesn't make sense as a library filespec, we copy
+  it verbatim, blank delimited, to the output string.
 
   The "lib" part of the library name, which we call the prefix, may be
   other than "lib".  The list of recognized values is compiled in as
@@ -52,11 +52,11 @@
 
      NETPBMLIB=../lib/libnetpbm.so
      ...
-     pbmmake: pbmmake.o $(PBMLIB)
-             ld -o pbmmake pbmmake.o `libopt $(PBMLIB)` --rpath=/lib/netpbm
+     pbmmake: pbmmake.o $(NETPBMLIB)
+             ld -o pbmmake pbmmake.o `libopt $(NETPBMLIB)` --rpath=/lib/netpbm
 
   Caveat: "-L../lib -lnetpbm" is NOT exactly the same as
-  "../pbm/libnetpbm.so" on any system.  All of the -l libraries are
+  "../lib/libnetpbm.so" on any system.  All of the -l libraries are
   searched for in all of the -L directories.  So you just might get a
   different library with the -L/-l version than if you specify the
   library file explicitly.
diff --git a/buildtools/makeman b/buildtools/makeman
index 634a2c79..2e122779 100755
--- a/buildtools/makeman
+++ b/buildtools/makeman
@@ -19,7 +19,8 @@
 #  * Loses summary information from tables.
 #  * Only permits one <HR> in the HTML, right before the index.
 #
-# Use the makeman: passthrough to insert format lines for tables.
+# You can use the <?makeman ?> PI to pass text directly through to the
+# generated manual page,  A major use is to insert format lines for tables.
 #
 # By Eric S. Raymond <esr@thyrsus.com>
 # Version 1.0, July 26 2004
@@ -29,7 +30,7 @@ import os, sys, exceptions, re
 source = "netpbm documentation"
 section = 1
 
-warning = '''\
+warning = r'''\
 .\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
 .\" Do not hand-hack it!  If you have bug fixes or improvements, please find
 .\" the corresponding HTML page on the Netpbm website, generate a patch
@@ -47,11 +48,15 @@ def makeman(name, file, indoc):
     # Dot at left margin confuses troff.
     # This program generates these,
     indoc = indoc.replace("\n.", "\n@%@%@")
+    # 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 = 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',"")
-    indoc = indoc.replace('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "DTD/xhtml11.dtd">', "")
     indoc = indoc.replace('<html xmlns="http://www.w3.org/1999/xhtml">', "")
     indoc = indoc.replace("<HEAD>", "").replace("</HEAD>", "")
     indoc = indoc.replace("<head>", "").replace("</head>", "")
@@ -93,8 +98,8 @@ def makeman(name, file, indoc):
     # Literal layout
     indoc = re.sub("(?i)\n *<PRE>", "\n.nf", indoc)
     indoc = re.sub("(?i)\n *</PRE>", "\n.fi", indoc)
-    indoc = re.sub("(?i)\n *<BLOCKQUOTE>", "\n.nf", indoc)
-    indoc = re.sub("(?i)\n *</BLOCKQUOTE>", "\n.fi", indoc)
+    indoc = re.sub("(?i)\n *<BLOCKQUOTE>", "\n.RS", indoc)
+    indoc = re.sub("(?i)\n *</BLOCKQUOTE>", "\n.RE", indoc)
     # Highlight processing
     indoc = re.sub("(?i)<B>", r"\\fB", indoc)
     indoc = re.sub("(?i)</B>", r"\\fP", indoc)
@@ -108,6 +113,8 @@ def makeman(name, file, indoc):
     indoc = re.sub("(?i)</TT>", r"\\fP", indoc)
     indoc = re.sub("(?i)<KBD>", r"\\f(CW", indoc)
     indoc = re.sub("(?i)</KBD>", r"\\fP", indoc)
+    indoc = re.sub("(?i)<CODE>", r"\\f(CW", indoc)
+    indoc = re.sub("(?i)</CODE>", r"\\fP", indoc)
     indoc = re.sub("(?i)<STRONG>", r"\\fB", indoc)
     indoc = re.sub("(?i)</STRONG>", r"\\fP", indoc)
     indoc = re.sub("(?i)<SUP>", r"\\u", indoc)
@@ -150,6 +157,7 @@ def makeman(name, file, indoc):
     indoc = indoc.replace("&lt;", "@#!#@").replace("&gt;", "#@!@#").replace("&amp;", "#!@!@!#")
     indoc = indoc.replace("&#215;", r"\(mu")
     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)
     # Strip off the index trailer
@@ -159,17 +167,17 @@ def makeman(name, file, indoc):
     indoc = indoc.replace("</BODY>", "").replace("</HTML>", "")
     indoc = indoc.replace("</body>", "").replace("</html>", "")
     # Recognize sections with IDs
-    indoc = re.sub('(?i)<H2><A (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</A></H2>',
+    indoc = re.sub('(?i)<H2><A (?:ID|NAME)="([a-zA-Z][_a-zA-Z0-9-]+)">([^><]*)</A></H2>',
                    ".UN \\1\n.SH \\2", indoc)
-    indoc = re.sub('(?i)<H3><A (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</A></H3>',
+    indoc = re.sub('(?i)<H3><A (?:ID|NAME)="([a-zA-Z][_a-zA-Z0-9-]+)">([^><]*)</A></H3>',
                    ".UN \\1\n.SS \\2", indoc)
-    indoc = re.sub('(?i)<H4><A (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</A></H4>',
+    indoc = re.sub('(?i)<H4><A (?:ID|NAME)="([a-zA-Z][_a-zA-Z0-9-]+)">([^><]*)</A></H4>',
                    ".UN \\1\n.B \\2", indoc)
-    indoc = re.sub('(?i)<H2 (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</H2>',
+    indoc = re.sub('(?i)<H2 (?:ID|NAME)="([a-zA-Z][_a-zA-Z0-9-]+)">([^><]*)</H2>',
                    ".UN \\1\n.SH \\2", indoc)
-    indoc = re.sub('(?i)<H3 (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</H3>',
+    indoc = re.sub('(?i)<H3 (?:ID|NAME)="([a-zA-Z][_a-zA-Z0-9-]+)">([^><]*)</H3>',
                    ".UN \\1\n.SS \\2", indoc)
-    indoc = re.sub('(?i)<H4 (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</H4>',
+    indoc = re.sub('(?i)<H4 (?:ID|NAME)="([a-zA-Z][_a-zA-Z0-9-]+)">([^><]*)</H4>',
                    ".UN \\1\n.B \\2", indoc)
     # Sections without IDs
     indoc = re.sub('(?i)<H2>([^><]*)</H2>', ".SH \\1", indoc)
@@ -192,7 +200,7 @@ def makeman(name, file, indoc):
     # Passthrough
     indoc = re.sub(r"<\?makeman (.*) \?>", r'\1', indoc)
     # Comments
-    indoc = re.sub("<!--([^-])*-->", r'.\"\1', indoc)
+    indoc = re.sub("<!--([^\n])*-->", r'.\"\1', indoc)
     # Image tags
     indoc = re.sub(' *<img src="([^"]*)" alt="([^"]*)"( *[a-z]*="?[0-9]*"?)*>', ".B \\2\n.IMG -C \\1", indoc)
     # Special characters
@@ -217,7 +225,7 @@ def makeman(name, file, indoc):
     # Time for error checking now
     badlines = []
     for line in indoc.split("\n"):
-        if "<" in line or ">" in line or re.search("&.*;", line):
+        if "<" in line or ">" in line.replace(" >", "") or re.search("&.*;", line):
             badlines.append(line)
     if badlines:
         sys.stderr.write(("Bad lines from %s:\n-----------------\n" % file) + "\n".join(badlines) + "\n-----------------\n")
@@ -236,19 +244,22 @@ def makeman(name, file, indoc):
 def main(args, mainout=sys.stdout, mainerr=sys.stderr):
     global sectmap
     import getopt
-    (options, arguments) = getopt.getopt(args, "v")
+    (options, arguments) = getopt.getopt(args, "vd:")
+    dirprefix = ""
     verbosity = 0
     for (switch, val) in options:
-        if switch == '-v':
+        if switch == '-d':	# Set HTML input directory
+            dirprefix = val
+        elif switch == '-v':	# Enable verbose error reporting
             verbosity += 1
     try:
         # First pass: gather locations for crossreferences:
         sectmap = {}
         for file in arguments:
             try: 
-                infp = open(file)
+                infp = open(os.path.join(dirprefix, file))
             except:
-                sys.stderr.write("can't open %s" % name)
+                sys.stderr.write("makeman: can't open %s\n" % file)
                 continue
             indoc = infp.read()
             infp.close()
@@ -277,9 +288,9 @@ def main(args, mainout=sys.stdout, mainerr=sys.stderr):
         # Second pass: do formatting
         for file in arguments:
             try: 
-                infp = open(file)
+                infp = open(os.path.join(dirprefix, file))
             except:
-                sys.stderr.write("can't open %s" % name)
+                sys.stderr.write("makeman: can't open %s\n" % file)
                 continue
             indoc = infp.read()
             infp.close()
@@ -321,6 +332,7 @@ def main(args, mainout=sys.stdout, mainerr=sys.stderr):
             (exc_type, exc_value, exc_traceback) = sys.exc_info()
             raise exc_type, exc_value, exc_traceback
         else:
+            mainerr.write("makeman: internal error!\n")
             return 5
 
 if __name__ == "__main__":
diff --git a/buildtools/makepointerman b/buildtools/makepointerman
index 8fbb0f49..58d3a64c 100755
--- a/buildtools/makepointerman
+++ b/buildtools/makepointerman
@@ -74,11 +74,11 @@ print(MANPAGE "If that doesn't work, also try " .
 print(MANPAGE "emailing Bryan Henderson, bryanh\@giraffe-data.com.\n");
 
 print(MANPAGE "\n");
-print(MANPAGE "Note that making the documentation available this way was\n");
-print(MANPAGE "a choice of the person who installed Netpbm on this system.\n");
-print(MANPAGE "It is also possible to install Netpbm such that you would\n");
-print(MANPAGE "simply see the documentation instead of the message you are\n");
-print(MANPAGE "reading now.\n");
+print(MANPAGE "Note that it is possible to install Netpbm with the\n");
+print(MANPAGE "documentation available differently.  For example, you\n");
+print(MANPAGE "could simply see the documentation instead of the message\n");
+print(MANPAGE "you are reading now.  The file 'doc/USERDOC' in the Netpbm\n");
+print(MANPAGE "source tree contains details.");
 print(MANPAGE "\n");
 
 if ($format eq "nroff") {
diff --git a/buildtools/Makefile.manpage b/buildtools/manpage.mk
index e8c17972..e1c0bce2 100644
--- a/buildtools/Makefile.manpage
+++ b/buildtools/manpage.mk
@@ -1,10 +1,8 @@
-# -*-makefile-*-    <-- an Emacs control
-
 # Make Unix man pages from Netpbm HTML user manual
 
 MAKEMAN = makeman
 
-MANDIR = /usr/share/man/man1
+MANDIR = /usr/share/man/
 
 # These can convert to man pages cleanly
 MAN1 = \
@@ -16,6 +14,7 @@ MAN1 = \
 	bmptopnm.1 \
 	bmptoppm.1 \
 	brushtopbm.1 \
+	cameratopam.1 \
 	cmuwmtopbm.1 \
 	ddbugtopbm.1 \
 	escp2topbm.1 \
@@ -41,6 +40,7 @@ MAN1 = \
 	leaftoppm.1 \
 	lispmtopgm.1 \
 	macptopbm.1 \
+	manweb.1 \
 	mdatopbm.1 \
 	mgrtopbm.1 \
 	mrf.1 \
@@ -58,6 +58,7 @@ MAN1 = \
 	pamedge.1 \
 	pamendian.1 \
 	pamfile.1 \
+	pamfixtrunc.1 \
 	pamflip.1 \
 	pamfunc.1 \
 	pamgauss.1 \
@@ -74,8 +75,8 @@ MAN1 = \
 	pamstereogram.1 \
 	pamstretch-gen.1 \
 	pamstretch.1 \
-	pamsummcol.1 \
 	pamsumm.1 \
+	pamsummcol.1 \
 	pamtodjvurle.1 \
 	pamtohdiff.1 \
 	pamtohtmltbl.1 \
@@ -186,8 +187,8 @@ MAN1 = \
 	pnmquant.1 \
 	pnmremap.1 \
 	pnmrotate.1 \
-	pnmscalefixed.1 \
 	pnmscale.1 \
+	pnmscalefixed.1 \
 	pnmshear.1 \
 	pnmsmooth.1 \
 	pnmsplit.1 \
@@ -208,8 +209,8 @@ MAN1 = \
 	pnmtorle.1 \
 	pnmtosgi.1 \
 	pnmtosir.1 \
-	pnmtotiffcmyk.1 \
 	pnmtotiff.1 \
+	pnmtotiffcmyk.1 \
 	pnmtoxwd.1 \
 	ppm3d.1 \
 	ppmbrighten.1 \
@@ -230,8 +231,8 @@ MAN1 = \
 	ppmnorm.1 \
 	ppmntsc.1 \
 	ppmpat.1 \
-	ppmquantall.1 \
 	ppmquant.1 \
+	ppmquantall.1 \
 	ppmrainbow.1 \
 	ppmrelief.1 \
 	ppmrough.1 \
@@ -243,12 +244,12 @@ MAN1 = \
 	ppmtoarbtxt.1 \
 	ppmtobmp.1 \
 	ppmtoeyuv.1 \
-	ppmtogif.1 \
 	ppmtoicr.1 \
 	ppmtoilbm.1 \
 	ppmtojpeg.1 \
 	ppmtoleaf.1 \
 	ppmtolj.1 \
+	ppmtomap.1 \
 	ppmtomitsu.1 \
 	ppmtompeg.1 \
 	ppmtoneo.1 \
@@ -301,6 +302,35 @@ 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 \
@@ -318,39 +348,57 @@ MAN5 = \
 	extendedopacity.5 \
 	pam.5 \
 	pbm.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)
 HTMLMANUALS = $(MAN1:.1=.html) $(MAN3:.3=.html) $(MAN5:.5=.html)
+
+# These things don't get converted to manual pages.
+EXCEPTIONS = directory.html libnetpbm_dir.html libnetpbm_draw.html error.html
+STUBS = pcdindex.1 ppmcolors.1 pnmflip.1 ppmtogif.1
+
+# This works if you've done a full SVN checkout.
+USERGUIDE= ../../userguide
+
 XML = $(HTMLMANUALS:.html=.xml) netpbm.xml
 
-# These things don't get converted to manual pages
-# They're basically link lists, not useful in the man hierarchy.
-EXCEPTIONS = directory.html libnetpbm_dir.html
+# List everything in the userguide directory that is not categorized above.
+# Use this to check that 'make manpages' converts as much as possible
+# of the HTML documentation.
+uncategorized:
+	@echo $(HTMLMANUALS) $(EXCEPTIONS) $(STUBS) | tr " " "\n" | sort >LIST1
+	@(cd $(USERGUIDE); ls | sort) >LIST2
+	@comm -3 LIST1 LIST2
+	@rm LIST1 LIST2
 
-# Make man pages -- reports bad lines to standard error
+# Make man pages -- reports bad lines to standard error.
 manpages:
-	@python $(MAKEMAN) index.html $(HTMLMANUALS) 
-	mv index.1 netpbm.1
+	@python $(MAKEMAN) -d $(USERGUIDE) index.html $(HTMLMANUALS) 
+	@mv index.1 netpbm.1
 
 # Make XML pages, and validate them.
 xmlpages:
-	@for x in $(MANPAGES); do doclifter $$x; done
-	@for x in $(XML); do xmllint -xinclude --postvalid $$x >/dev/null; done
+	@for x in $(MANPAGES); do doclifter -v $$x; done
+	@for x in $(MANPAGES); do xmllint -xinclude --postvalid $$x.xml >/dev/null; done
 
 # This will install the generated man pages
-installman: manpages
-	for f in $(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
+installman:
+	set -x
+	for f in $(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 $(MAN3); do rm -f $(MANDIR)/man3/$$f.gz; fi; done
+	for f in $(MAN5); do rm -f $(MANDIR)/man5/$$f.gz; fi; done
+
+oldclean:
 	# Clean up old locations on Fedora Core 2
 	rm -f $(MANDIR)/man1/extendedopacity.1.gz 
 	rm -f $(MANDIR)/man3/directory.3.gz