Blame m4/extensions.m4

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