about summary refs log tree commit diff
path: root/buildtools
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools')
-rwxr-xr-xbuildtools/configure.pl342
1 files changed, 189 insertions, 153 deletions
diff --git a/buildtools/configure.pl b/buildtools/configure.pl
index ee9b5ec9..9f219648 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:
@@ -116,6 +121,74 @@ sub promptYesNo($) {
 
 
 
+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.
@@ -512,12 +585,12 @@ sub getGccChoiceFromUser($) {
         }
     }
     if ($retval 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");
+        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");
 
@@ -934,7 +1007,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;
@@ -956,7 +1029,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);
@@ -997,7 +1070,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);
@@ -1127,10 +1200,10 @@ sub getX11Library($@) {
         }
         if (defined($x11hdr_dir)) {
             if (!-d($x11hdr_dir)) {
-                printf("WARNING: No directory named '$x11hdr_dir' exists.\n");
+                warnUser("No directory named '$x11hdr_dir' exists.");
             } elsif (!-d("$x11hdr_dir/X11")) {
-                printf("WARNING: Directory '$x11hdr_dir' does not contain " .
-                       "the requisite 'X11' subdirectory\n");
+                warnUser("Directory '$x11hdr_dir' does not contain " .
+                         "the requisite 'X11' subdirectory");
             }
         }
     }
@@ -1185,8 +1258,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.");
             }
         }
     }
@@ -1352,10 +1424,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.)");
             }
         }
     }
@@ -1367,16 +1439,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.");
     }
 }
 
@@ -1421,41 +1489,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."
+        );
 }
 
 
@@ -1554,33 +1618,28 @@ sub testPngHdr($$) {
 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 (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.
-
-EOF
-
+    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 printPngLinkWorksWithLzLm() {
-
-    print << 'EOF';
-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.
+sub pngLinkWorksWithLzLmMsg() {
 
-EOF
+    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.";
 }
 
 
@@ -1588,26 +1647,15 @@ EOF
 sub printBadPngConfigLdflagsWarning($$) {
     my ($pngLdFlags, $lzLmSuccess) = @_;
 
-    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
-
-    if ($lzLmSuccess) {
-        printPngLinkWorksWithLzLm();
-    }
-
-    print << 'EOF';
-*****************************************************************************
-
-EOF
+    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 : "")
+        );
 }
 
 
@@ -1681,20 +1729,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'.  "
+        );
 }
 
 
@@ -1717,26 +1760,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'."
+        );
 }
 
 
@@ -1918,33 +1959,25 @@ findProcessManagement(\my $dontHaveProcessMgmt);
 #
 #*****************************************************************************
 
-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");
@@ -2367,6 +2400,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");