about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-05-13 21:35:34 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-05-13 21:35:34 +0000
commit78caf4b0e71e66918748427c1e1d9f9dade9e970 (patch)
tree8307c4443f3adb9a880fd9734147c01ee5931191
parent268fe97b9555aeee769e6bed36b10ccd3c8a10e8 (diff)
downloadnetpbm-mirror-78caf4b0e71e66918748427c1e1d9f9dade9e970.tar.gz
netpbm-mirror-78caf4b0e71e66918748427c1e1d9f9dade9e970.tar.xz
netpbm-mirror-78caf4b0e71e66918748427c1e1d9f9dade9e970.zip
Deal with MinGW failure to handl _XOPEN_SOURCE == null
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2973 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rwxr-xr-xbuildtools/configure.pl39
-rw-r--r--doc/HISTORY3
-rw-r--r--doc/INSTALL41
3 files changed, 81 insertions, 2 deletions
diff --git a/buildtools/configure.pl b/buildtools/configure.pl
index 93045b77..4e6ff21a 100755
--- a/buildtools/configure.pl
+++ b/buildtools/configure.pl
@@ -442,6 +442,18 @@ sub askAboutDjgpp() {
 
 
 
+sub askAboutMingw() {
+
+    print("Are you building for the MinGW environment?\n");
+    print("\n");
+    
+    my $retval = promptYesNo("n");
+
+    return $retval;
+}
+
+
+
 sub computePlatformDefault($) {
 
     my ($defaultP) = @_;
@@ -556,6 +568,29 @@ sub getPlatform() {
 
 
 
+sub warnMingwXopenSource($) {
+    my ($subplatform) = @_;
+
+    if ($subplatform ne 'cygwin' && $subplatform ne 'djgpp') {
+        my $mingw = askAboutMingw();
+
+        if ($mingw) {
+            print << 'EOF';
+
+MinGW does not implement enough of the standard on which Netpbm relies to
+build out-of-the-box, but there is a trivial way to add the needed capability
+to MinGW.  See file doc/INSTALL for details.
+
+Press ENTER to continue.
+
+EOF
+            <STDIN>;
+        }
+    }
+}
+
+
+
 sub getGccChoiceFromUser($) {
     my ($platform) = @_;
 
@@ -2084,6 +2119,10 @@ if ($platform eq "NONE") {
     exit;
 }
 
+if ($platform eq 'WINDOWS') {
+    warnMingwXopenSource($subplatform);
+}
+
 getCompiler($platform, $subplatform, \my $compiler);
 
 getLinker($platform, $compiler, \my $baseLinker, \my $linkViaCompiler);
diff --git a/doc/HISTORY b/doc/HISTORY
index 82622a16..fe88e505 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -49,6 +49,9 @@ not yet  BJH  Release 10.79.00
               you need _XOPEN_SOURCE=500, and Cygwin has changed to enforce
               this.
 
+              Build: document MinGW _XOPEN_SOURCE incompatibility and add
+              warning to Configure.
+
               Debian packaging: fix bug: don't try to include Manweb files, as
               it is no longer packaged by 'make package'.
 
diff --git a/doc/INSTALL b/doc/INSTALL
index a71e5179..39bbc0a5 100644
--- a/doc/INSTALL
+++ b/doc/INSTALL
@@ -182,6 +182,45 @@ Netpbm has also been built for Windows using Djgpp, as late as 2001.
 
 See also the general installation instructions above.
 
+Mingw Modification
+-------------------
+
+With at least some versions of MinGW, you have to make a small change to
+_mingw.h or you get a compilation failure for invalid syntax in that file
+where it expands the macro _XOPEN_SOURCE.
+
+The problem is that many Netpbm programs declare that they need a C library
+that conforms to any version of the X/Open (XPG, XSI, SUS) standard.  The way
+they do that is, in accordance with the earliest version of that standard, by
+defining the macro _XOPEN_SOURCE with a null (zero-length) body.  But MinGW is
+not designed to work with programs that request anything earlier than Issue
+(version) 5 of this standard, and in fact _mingw.h will not compile if the
+macro expands to something other than a number.
+
+But it is easy to add pre-Issue 5 function to MinGW and having done so, your
+MinGW installation will also work with lots of other code.  All you have to do
+is change
+
+  if _XOPEN_SOURCE < 500
+
+to
+
+  if (_XOPEN_SOURCE + 0) < 500
+
+in _mingw.h.  This is the trick other C libraries use.
+
+(A user proposed that this change be distributed in _mingw.h, in April 2017 on
+the mingw-users mailing list, but the maintainer was opposed to accomodating
+programs written for the older standards).
+
+If you cannot change _mingw.h, you can alternatively change Netpbm.  Find all
+instances of
+
+  #define _XOPEN_SOURCE
+
+and change them to
+
+  #define _XOPEN_SOURCE 0
 
 
 INSTALLATION - MAKING ONLY THE PARTS YOU NEED
@@ -457,5 +496,3 @@ link is picking up the old system version instead.  Why?  Because the link
 options say to search /usr/lib _before_ the local build directory.  And they
 do that because libpng-config erroneously says that you need a -L /usr/lib
 link option to find the Libpng library.
-
-