From: Paul Eggert Date: Fri, 8 Feb 2013 21:01:15 +0000 (-0800) Subject: AC_USE_SYSTEM_EXTENSIONS: improve port to HP-UX X-Git-Tag: v2.69b~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e3779d9b13604aafc50e318f3ea4a1c00ba2003;p=thirdparty%2Fautoconf.git AC_USE_SYSTEM_EXTENSIONS: improve port to HP-UX * lib/autoconf/specific.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. --- diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 248a7a35..4fca0a8f 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -395,11 +395,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 @@ -408,6 +403,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__ @@ -428,6 +429,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 + mbstate_t x;]])], + [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #define _XOPEN_SOURCE 500 + #include + 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