Blame m4/extensions.m4

Packit Service fdd496
# serial 15  -*- Autoconf -*-
Packit Service fdd496
# Enable extensions on systems that normally disable them.
Packit Service fdd496
Packit Service fdd496
# Copyright (C) 2003, 2006-2017 Free Software Foundation, Inc.
Packit Service fdd496
# This file is free software; the Free Software Foundation
Packit Service fdd496
# gives unlimited permission to copy and/or distribute it,
Packit Service fdd496
# with or without modifications, as long as this notice is preserved.
Packit Service fdd496
Packit Service fdd496
# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
Packit Service fdd496
# Autoconf.  Perhaps we can remove this once we can assume Autoconf
Packit Service fdd496
# 2.70 or later everywhere, but since Autoconf mutates rapidly
Packit Service fdd496
# enough in this area it's likely we'll need to redefine
Packit Service fdd496
# AC_USE_SYSTEM_EXTENSIONS for quite some time.
Packit Service fdd496
Packit Service fdd496
# If autoconf reports a warning
Packit Service fdd496
#     warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
Packit Service fdd496
# or  warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
Packit Service fdd496
# the fix is
Packit Service fdd496
#   1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
Packit Service fdd496
#      but always AC_REQUIREd,
Packit Service fdd496
#   2) to ensure that for each occurrence of
Packit Service fdd496
#        AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
Packit Service fdd496
#      or
Packit Service fdd496
#        AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit Service fdd496
#      the corresponding gnulib module description has 'extensions' among
Packit Service fdd496
#      its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
Packit Service fdd496
#      invocation occurs in gl_EARLY, not in gl_INIT.
Packit Service fdd496
Packit Service fdd496
# AC_USE_SYSTEM_EXTENSIONS
Packit Service fdd496
# ------------------------
Packit Service fdd496
# Enable extensions on systems that normally disable them,
Packit Service fdd496
# typically due to standards-conformance issues.
Packit Service fdd496
#
Packit Service fdd496
# Remember that #undef in AH_VERBATIM gets replaced with #define by
Packit Service fdd496
# AC_DEFINE.  The goal here is to define all known feature-enabling
Packit Service fdd496
# macros, then, if reports of conflicts are made, disable macros that
Packit Service fdd496
# cause problems on some platforms (such as __EXTENSIONS__).
Packit Service fdd496
AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
Packit Service fdd496
[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
Packit Service fdd496
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
Packit Service fdd496
Packit Service fdd496
  AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
Packit Service fdd496
  if test "$MINIX" = yes; then
Packit Service fdd496
    AC_DEFINE([_POSIX_SOURCE], [1],
Packit Service fdd496
      [Define to 1 if you need to in order for 'stat' and other
Packit Service fdd496
       things to work.])
Packit Service fdd496
    AC_DEFINE([_POSIX_1_SOURCE], [2],
Packit Service fdd496
      [Define to 2 if the system does not provide POSIX.1 features
Packit Service fdd496
       except with this defined.])
Packit Service fdd496
    AC_DEFINE([_MINIX], [1],
Packit Service fdd496
      [Define to 1 if on MINIX.])
Packit Service fdd496
    AC_DEFINE([_NETBSD_SOURCE], [1],
Packit Service fdd496
      [Define to 1 to make NetBSD features available.  MINIX 3 needs this.])
Packit Service fdd496
  fi
Packit Service fdd496
Packit Service fdd496
dnl Use a different key than __EXTENSIONS__, as that name broke existing
Packit Service fdd496
dnl configure.ac when using autoheader 2.62.
Packit Service fdd496
  AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
Packit Service fdd496
[/* Enable extensions on AIX 3, Interix.  */
Packit Service fdd496
#ifndef _ALL_SOURCE
Packit Service fdd496
# undef _ALL_SOURCE
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable general extensions on macOS.  */
Packit Service fdd496
#ifndef _DARWIN_C_SOURCE
Packit Service fdd496
# undef _DARWIN_C_SOURCE
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable GNU extensions on systems that have them.  */
Packit Service fdd496
#ifndef _GNU_SOURCE
Packit Service fdd496
# undef _GNU_SOURCE
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable threading extensions on Solaris.  */
Packit Service fdd496
#ifndef _POSIX_PTHREAD_SEMANTICS
Packit Service fdd496
# undef _POSIX_PTHREAD_SEMANTICS
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC TS 18661-5:2014.  */
Packit Service fdd496
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
Packit Service fdd496
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC TS 18661-1:2014.  */
Packit Service fdd496
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
Packit Service fdd496
# undef __STDC_WANT_IEC_60559_BFP_EXT__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC TS 18661-2:2015.  */
Packit Service fdd496
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
Packit Service fdd496
# undef __STDC_WANT_IEC_60559_DFP_EXT__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC TS 18661-4:2015.  */
Packit Service fdd496
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
Packit Service fdd496
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC TS 18661-3:2015.  */
Packit Service fdd496
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
Packit Service fdd496
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC TR 24731-2:2010.  */
Packit Service fdd496
#ifndef __STDC_WANT_LIB_EXT2__
Packit Service fdd496
# undef __STDC_WANT_LIB_EXT2__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions specified by ISO/IEC 24747:2009.  */
Packit Service fdd496
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
Packit Service fdd496
# undef __STDC_WANT_MATH_SPEC_FUNCS__
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable extensions on HP NonStop.  */
Packit Service fdd496
#ifndef _TANDEM_SOURCE
Packit Service fdd496
# undef _TANDEM_SOURCE
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable X/Open extensions if necessary.  HP-UX 11.11 defines
Packit Service fdd496
   mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
Packit Service fdd496
   whether compiling with -Ae or -D_HPUX_SOURCE=1.  */
Packit Service fdd496
#ifndef _XOPEN_SOURCE
Packit Service fdd496
# undef _XOPEN_SOURCE
Packit Service fdd496
#endif
Packit Service fdd496
/* Enable general extensions on Solaris.  */
Packit Service fdd496
#ifndef __EXTENSIONS__
Packit Service fdd496
# undef __EXTENSIONS__
Packit Service fdd496
#endif
Packit Service fdd496
])
Packit Service fdd496
  AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
Packit Service fdd496
    [ac_cv_safe_to_define___extensions__],
Packit Service fdd496
    [AC_COMPILE_IFELSE(
Packit Service fdd496
       [AC_LANG_PROGRAM([[
Packit Service fdd496
#         define __EXTENSIONS__ 1
Packit Service fdd496
          ]AC_INCLUDES_DEFAULT])],
Packit Service fdd496
       [ac_cv_safe_to_define___extensions__=yes],
Packit Service fdd496
       [ac_cv_safe_to_define___extensions__=no])])
Packit Service fdd496
  test $ac_cv_safe_to_define___extensions__ = yes &&
Packit Service fdd496
    AC_DEFINE([__EXTENSIONS__])
Packit Service fdd496
  AC_DEFINE([_ALL_SOURCE])
Packit Service fdd496
  AC_DEFINE([_DARWIN_C_SOURCE])
Packit Service fdd496
  AC_DEFINE([_GNU_SOURCE])
Packit Service fdd496
  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_LIB_EXT2__])
Packit Service fdd496
  AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
Packit Service fdd496
  AC_DEFINE([_TANDEM_SOURCE])
Packit Service fdd496
  AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
Packit Service fdd496
    [ac_cv_should_define__xopen_source],
Packit Service fdd496
    [ac_cv_should_define__xopen_source=no
Packit Service fdd496
     AC_COMPILE_IFELSE(
Packit Service fdd496
       [AC_LANG_PROGRAM([[
Packit Service fdd496
          #include <wchar.h>
Packit Service fdd496
          mbstate_t x;]])],
Packit Service fdd496
       [],
Packit Service fdd496
       [AC_COMPILE_IFELSE(
Packit Service fdd496
          [AC_LANG_PROGRAM([[
Packit Service fdd496
             #define _XOPEN_SOURCE 500
Packit Service fdd496
             #include <wchar.h>
Packit Service fdd496
             mbstate_t x;]])],
Packit Service fdd496
          [ac_cv_should_define__xopen_source=yes])])])
Packit Service fdd496
  test $ac_cv_should_define__xopen_source = yes &&
Packit Service fdd496
    AC_DEFINE([_XOPEN_SOURCE], [500])
Packit Service fdd496
])# AC_USE_SYSTEM_EXTENSIONS
Packit Service fdd496
Packit Service fdd496
# gl_USE_SYSTEM_EXTENSIONS
Packit Service fdd496
# ------------------------
Packit Service fdd496
# Enable extensions on systems that normally disable them,
Packit Service fdd496
# typically due to standards-conformance issues.
Packit Service fdd496
AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
Packit Service fdd496
[
Packit Service fdd496
  dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
Packit Service fdd496
  dnl gnulib does not need it. But if it gets required by third-party macros
Packit Service fdd496
  dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
Packit Service fdd496
  dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
Packit Service fdd496
  dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
Packit Service fdd496
  dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
Packit Service fdd496
  AC_REQUIRE([AC_GNU_SOURCE])
Packit Service fdd496
Packit Service fdd496
  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
Packit Service fdd496
])