extensions: port better to HP-UX
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Feb 2013 21:10:01 +0000 (13:10 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Feb 2013 21:10:18 +0000 (13:10 -0800)
This is merged from git Autoconf.
* m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS):
On hosts that need _XOPEN_SOURCE, define it when configuring, too,
so that it's compatible with the value used when compiling.

ChangeLog
m4/extensions.m4

index 9f1b60f..fa5bda0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2013-02-08  Paul Eggert  <eggert@cs.ucla.edu>
 
+       extensions: port better to HP-UX
+       This is merged from git Autoconf.
+       * m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS):
+       On hosts that need _XOPEN_SOURCE, define it when configuring, too,
+       so that it's compatible with the value used when compiling.
+
        openpty: fix bug where HAVE_OPENPTY is mistakenly 1
        Problem reported by Mats Erik Andersson in
        <http://lists.gnu.org/archive/html/bug-gnulib/2013-02/msg00051.html>.
index 33daf38..07ba376 100644 (file)
@@ -8,7 +8,7 @@
 
 # This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
 # Autoconf.  Perhaps we can remove this once we can assume Autoconf
-# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
+# 2.70 or later everywhere, but since Autoconf mutates rapidly
 # enough in this area it's likely we'll need to redefine
 # AC_USE_SYSTEM_EXTENSIONS for quite some time.
 
@@ -68,11 +68,6 @@ dnl configure.ac when using autoheader 2.62.
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
 #endif
-/* HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
-   regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1.  */
-#ifdef __hpux
-# define _XOPEN_SOURCE 500
-#endif
 /* Enable threading extensions on Solaris.  */
 #ifndef _POSIX_PTHREAD_SEMANTICS
 # undef _POSIX_PTHREAD_SEMANTICS
@@ -81,6 +76,12 @@ dnl configure.ac when using autoheader 2.62.
 #ifndef _TANDEM_SOURCE
 # undef _TANDEM_SOURCE
 #endif
+/* Enable X/Open extensions if necessary.  HP-UX 11.11 defines
+   mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
+   whether compiling with -Ae or -D_HPUX_SOURCE=1.  */
+#ifndef _XOPEN_SOURCE
+# undef _XOPEN_SOURCE
+#endif
 /* Enable general extensions on Solaris.  */
 #ifndef __EXTENSIONS__
 # undef __EXTENSIONS__
@@ -101,6 +102,22 @@ dnl configure.ac when using autoheader 2.62.
   AC_DEFINE([_GNU_SOURCE])
   AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
   AC_DEFINE([_TANDEM_SOURCE])
+  AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
+    [ac_cv_should_define__xopen_source],
+    [ac_cv_should_define__xopen_source=no
+     AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([[
+          #include <wchar.h>
+          mbstate_t x;]])],
+       [],
+       [AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM([[
+             #define _XOPEN_SOURCE 500
+             #include <wchar.h>
+             mbstate_t x;]])],
+          [ac_cv_should_define__xopen_source=yes])])])
+  test $ac_cv_should_define__xopen_source = yes &&
+    AC_DEFINE([_XOPEN_SOURCE], [500])
 ])# AC_USE_SYSTEM_EXTENSIONS
 
 # gl_USE_SYSTEM_EXTENSIONS