From 78caf4b0e71e66918748427c1e1d9f9dade9e970 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 13 May 2017 21:35:34 +0000 Subject: 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 --- buildtools/configure.pl | 39 +++++++++++++++++++++++++++++++++++++++ doc/HISTORY | 3 +++ doc/INSTALL | 41 +++++++++++++++++++++++++++++++++++++++-- 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 + ; + } + } +} + + + 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. - - -- cgit 1.4.1