|
|
|
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. |
|
dnl This file is free software; the Free Software Foundation |
|
dnl gives unlimited permission to copy and/or distribute it, |
|
dnl with or without modifications, as long as this notice is preserved. |
|
|
|
AC_PREREQ([2.62]) |
|
|
|
|
|
|
|
AC_DEFUN([gl_COMMON], [ |
|
dnl Use AC_REQUIRE here, so that the code is expanded once only. |
|
AC_REQUIRE([gl_00GNULIB]) |
|
AC_REQUIRE([gl_COMMON_BODY]) |
|
AC_REQUIRE([gl_ZZGNULIB]) |
|
]) |
|
AC_DEFUN([gl_COMMON_BODY], [ |
|
AH_VERBATIM([_GL_GNUC_PREREQ], |
|
[ |
|
|
|
|
|
((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) |
|
|
|
|
|
|
|
]) |
|
AH_VERBATIM([_Noreturn], |
|
[ |
|
|
|
|
|
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ |
|
|| (defined _MSC_VER && 1900 <= _MSC_VER)) \ |
|
&& 0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ |
|
|| (!defined __STRICT_ANSI__ \ |
|
&& (_GL_GNUC_PREREQ (4, 7) \ |
|
|| (defined __apple_build_version__ \ |
|
? 6000000 <= __apple_build_version__ \ |
|
: 3 < __clang_major__ + (5 <= __clang_minor__)))))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]) |
|
AH_VERBATIM([isoc99_inline], |
|
[ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AH_VERBATIM([attribute], |
|
[ |
|
|
|
&& (!defined __clang_minor__ \ |
|
|| (defined __apple_build_version__ \ |
|
? 6000000 <= __apple_build_version__ \ |
|
: 5 <= __clang_major__))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710) |
|
|
|
|
|
|
|
]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. |
|
[ |
|
/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function |
|
is the size of the returned memory block. |
|
_GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied |
|
by the Nth argument of the function is the size of the returned memory block. |
|
*/ |
|
/* Applies to: function, pointer to function, function types. */ |
|
#if _GL_HAS_ATTRIBUTE (alloc_size) |
|
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) |
|
#else |
|
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) |
|
#endif |
|
|
|
/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the |
|
function and report an error if it cannot do so. */ |
|
/* Applies to: function. */ |
|
#if _GL_HAS_ATTRIBUTE (always_inline) |
|
# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
|
#else |
|
# define _GL_ATTRIBUTE_ALWAYS_INLINE |
|
#endif |
|
|
|
/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show |
|
in stack traces when debugging. The compiler should omit the function from |
|
stack traces. */ |
|
/* Applies to: function. */ |
|
#if _GL_HAS_ATTRIBUTE (artificial) |
|
# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) |
|
#else |
|
# define _GL_ATTRIBUTE_ARTIFICIAL |
|
#endif |
|
|
|
/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ |
|
/* Applies to: functions. */ |
|
/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at |
|
<https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. |
|
Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ |
|
#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ |
|
# ifndef __SUNPRO_C |
|
# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) |
|
# else |
|
# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) |
|
# endif |
|
#else |
|
# define _GL_ATTRIBUTE_COLD |
|
#endif |
|
|
|
/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate |
|
calls to the function with the same arguments. |
|
This attribute is safe for a function that neither depends on nor affects |
|
observable state, and always returns exactly once - e.g., does not loop |
|
forever, and does not call longjmp. |
|
(This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ |
|
/* Applies to: functions. */ |
|
#if _GL_HAS_ATTRIBUTE (const) |
|
# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) |
|
#else |
|
# define _GL_ATTRIBUTE_CONST |
|
#endif |
|
|
|
/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers |
|
that can be freed by passing them as the Ith argument to the |
|
function F. |
|
_GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that |
|
can be freed via 'free'; it can be used only after declaring 'free'. */ |
|
/* Applies to: functions. Cannot be used on inline functions. */ |
|
#if _GL_GNUC_PREREQ (11, 0) |
|
# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) |
|
#else |
|
# define _GL_ATTRIBUTE_DEALLOC(f, i) |
|
#endif |
|
/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue |
|
to use this earlier definition, since <stdlib.h> may not have been included |
|
yet. */ |
|
|
|
|
|
|
|
|
|
_GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) |
|
|
|
|
|
_GL_ATTRIBUTE_DEALLOC (free, 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. |
|
[ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]) |
|
AH_VERBATIM([async_safe], |
|
[ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]) |
|
AH_VERBATIM([micro_optimizations], |
|
[ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]) |
|
dnl Hint which direction to take regarding cross-compilation guesses: |
|
dnl When a user installs a program on a platform they are not intimately |
|
dnl familiar with, --enable-cross-guesses=conservative is the appropriate |
|
dnl choice. It implements the "If we don't know, assume the worst" principle. |
|
dnl However, when an operating system developer (on a platform which is not |
|
dnl yet known to gnulib) builds packages for their platform, they want to |
|
dnl expose, not hide, possible platform bugs; in this case, |
|
dnl --enable-cross-guesses=risky is the appropriate choice. |
|
dnl Sets the variables |
|
dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), |
|
dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). |
|
AC_ARG_ENABLE([cross-guesses], |
|
[AS_HELP_STRING([--enable-cross-guesses={conservative|risky}], |
|
[specify policy for cross-compilation guesses])], |
|
[if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then |
|
AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) |
|
enableval=conservative |
|
fi |
|
gl_cross_guesses="$enableval"], |
|
[gl_cross_guesses=conservative]) |
|
if test $gl_cross_guesses = risky; then |
|
gl_cross_guess_normal="guessing yes" |
|
gl_cross_guess_inverted="guessing no" |
|
else |
|
gl_cross_guess_normal="guessing no" |
|
gl_cross_guess_inverted="guessing yes" |
|
fi |
|
dnl Preparation for running test programs: |
|
dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not |
|
dnl to /dev/tty, so they can be redirected to log files. Such diagnostics |
|
dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. |
|
LIBC_FATAL_STDERR_=1 |
|
export LIBC_FATAL_STDERR_ |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE], |
|
[ |
|
GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2]) |
|
AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1]) |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], |
|
[ |
|
gl_MODULE_INDICATOR_SET_VARIABLE_AUX( |
|
[GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]], |
|
[abcdefghijklmnopqrstuvwxyz./-], |
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], |
|
[gl_MODULE_INDICATOR_CONDITION]) |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX], |
|
[ |
|
m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1], |
|
[ |
|
dnl Simplify the expression VALUE || 1 to 1. |
|
$1=1 |
|
], |
|
[gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1], |
|
[gl_MODULE_INDICATOR_CONDITION])]) |
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR], |
|
[ |
|
dnl Simplify the expression 1 || CONDITION to 1. |
|
if test "$[]$1" != 1; then |
|
dnl Simplify the expression 0 || CONDITION to CONDITION. |
|
if test "$[]$1" = 0; then |
|
$1=$2 |
|
else |
|
$1="($[]$1 || $2)" |
|
fi |
|
fi |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_MODULE_INDICATOR], |
|
[ |
|
AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], |
|
[abcdefghijklmnopqrstuvwxyz./-], |
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), |
|
[gl_MODULE_INDICATOR_CONDITION], |
|
[Define to a C preprocessor expression that evaluates to 1 or 0, |
|
depending whether the gnulib module $1 shall be considered present.]) |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], |
|
[ |
|
AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], |
|
[abcdefghijklmnopqrstuvwxyz./-], |
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], |
|
[Define to 1 when the gnulib module $1 should be tested.]) |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK], |
|
[ |
|
dnl Override gl_WARN_ON_USE_PREPARE. |
|
dnl But hide this definition from 'aclocal'. |
|
AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], []) |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS], |
|
[ |
|
dnl Override gl_MODULE_INDICATOR_FOR_TESTS. |
|
AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], []) |
|
]) |
|
|
|
|
|
|
|
AC_DEFUN([gl_FEATURES_H], |
|
[ |
|
AC_CHECK_HEADERS_ONCE([features.h]) |
|
if test $ac_cv_header_features_h = yes; then |
|
HAVE_FEATURES_H=1 |
|
else |
|
HAVE_FEATURES_H=0 |
|
fi |
|
AC_SUBST([HAVE_FEATURES_H]) |
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_PROG_CC_C99], |
|
[ |
|
dnl Just use AC_PROG_CC_C99. |
|
dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted |
|
dnl value of CC will contain the C99 enabling options twice. But this is only |
|
dnl a cosmetic problem. |
|
dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99; |
|
dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete." |
|
m4_version_prereq([2.70], |
|
[AC_REQUIRE([AC_PROG_CC])], |
|
[AC_REQUIRE([AC_PROG_CC_C99])]) |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_PROG_AR_RANLIB], |
|
[ |
|
dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler |
|
dnl as "cc", and GCC as "gcc". They have different object file formats and |
|
dnl library formats. In particular, the GNU binutils programs ar and ranlib |
|
dnl produce libraries that work only with gcc, not with cc. |
|
AC_REQUIRE([AC_PROG_CC]) |
|
dnl The '][' hides this use from 'aclocal'. |
|
AC_BEFORE([$0], [A][M_PROG_AR]) |
|
AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], |
|
[ |
|
AC_EGREP_CPP([Amsterdam], |
|
[ |
|
|
|
Amsterdam |
|
|
|
], |
|
[gl_cv_c_amsterdam_compiler=yes], |
|
[gl_cv_c_amsterdam_compiler=no]) |
|
]) |
|
|
|
dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not |
|
dnl building with __ACK__. |
|
if test $gl_cv_c_amsterdam_compiler = yes; then |
|
if test -z "$AR"; then |
|
AR='cc -c.a' |
|
fi |
|
if test -z "$ARFLAGS"; then |
|
ARFLAGS='-o' |
|
fi |
|
else |
|
dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST |
|
dnl ARFLAGS variable (it is filed into Makefile.in directly by automake |
|
dnl script on-demand, if not specified by ./configure of course). |
|
dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above |
|
dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block |
|
dnl because AM_PROG_AR is written so it could re-set AR variable even for |
|
dnl __ACK__. It may seem like its easier to avoid calling the macro here, |
|
dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good |
|
dnl default value and automake should usually know them). |
|
dnl |
|
dnl The '][' hides this use from 'aclocal'. |
|
m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:]) |
|
fi |
|
|
|
dnl In case the code above has not helped with setting AR/ARFLAGS, use |
|
dnl Automake-documented default values for AR and ARFLAGS, but prefer |
|
dnl ${host}-ar over ar (useful for cross-compiling). |
|
AC_CHECK_TOOL([AR], [ar], [ar]) |
|
if test -z "$ARFLAGS"; then |
|
ARFLAGS='cr' |
|
fi |
|
|
|
AC_SUBST([AR]) |
|
AC_SUBST([ARFLAGS]) |
|
if test -z "$RANLIB"; then |
|
if test $gl_cv_c_amsterdam_compiler = yes; then |
|
RANLIB=':' |
|
else |
|
dnl Use the ranlib program if it is available. |
|
AC_PROG_RANLIB |
|
fi |
|
fi |
|
AC_SUBST([RANLIB]) |
|
]) |
|
|
|
# AC_C_RESTRICT |
|
# This definition is copied from post-2.70 Autoconf and overrides the |
|
# AC_C_RESTRICT macro from autoconf 2.60..2.70. |
|
m4_version_prereq([2.70.1], [], [ |
|
AC_DEFUN([AC_C_RESTRICT], |
|
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], |
|
[ac_cv_c_restrict=no |
|
# Put '__restrict__' first, to avoid problems with glibc and non-GCC; see: |
|
# https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html |
|
# Put 'restrict' last, because C++ lacks it. |
|
for ac_kw in __restrict__ __restrict _Restrict restrict; do |
|
AC_COMPILE_IFELSE( |
|
[AC_LANG_PROGRAM( |
|
[[typedef int *int_ptr; |
|
int foo (int_ptr $ac_kw ip) { return ip[0]; } |
|
int bar (int [$ac_kw]); /* Catch GCC bug 14050. */ |
|
int bar (int ip[$ac_kw]) { return ip[0]; } |
|
]], |
|
[[int s[1]; |
|
int *$ac_kw t = s; |
|
t[0] = 0; |
|
return foo (t) + bar (t); |
|
]])], |
|
[ac_cv_c_restrict=$ac_kw]) |
|
test "$ac_cv_c_restrict" != no && break |
|
done |
|
]) |
|
AH_VERBATIM([restrict], |
|
[/* Define to the equivalent of the C99 'restrict' keyword, or to |
|
nothing if this is not supported. Do not define if restrict is |
|
supported only directly. */ |
|
#undef restrict |
|
/* Work around a bug in older versions of Sun C++, which did not |
|
#define __restrict__ or support _Restrict or __restrict__ |
|
even though the corresponding Sun C compiler ended up with |
|
"#define restrict _Restrict" or "#define restrict __restrict__" |
|
in the previous line. This workaround can be removed once |
|
we assume Oracle Developer Studio 12.5 (2016) or later. */ |
|
#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__ |
|
# define _Restrict |
|
# define __restrict__ |
|
#endif]) |
|
case $ac_cv_c_restrict in |
|
restrict) ;; |
|
no) AC_DEFINE([restrict], []) ;; |
|
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; |
|
esac |
|
])# AC_C_RESTRICT |
|
]) |
|
|
|
# gl_BIGENDIAN |
|
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. |
|
# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some |
|
# macros invoke AC_C_BIGENDIAN with arguments. |
|
AC_DEFUN([gl_BIGENDIAN], |
|
[ |
|
AC_C_BIGENDIAN |
|
]) |
|
|
|
# A temporary file descriptor. |
|
# Must be less than 10, because dash 0.5.8 does not support redirections |
|
# with multi-digit file descriptors. |
|
m4_define([GL_TMP_FD], 9) |
|
|
|
# gl_SILENT(command) |
|
# executes command, but without the normal configure output. |
|
# This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.) |
|
# inside another AC_CACHE_CHECK. |
|
AC_DEFUN([gl_SILENT], |
|
[ |
|
exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null |
|
$1 |
|
exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&- |
|
]) |
|
|
|
# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) |
|
# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not |
|
# output a spurious "(cached)" mark in the midst of other configure output. |
|
# This macro should be used instead of AC_CACHE_VAL when it is not surrounded |
|
# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. |
|
AC_DEFUN([gl_CACHE_VAL_SILENT], |
|
[ |
|
gl_SILENT([ |
|
AC_CACHE_VAL([$1], [$2]) |
|
]) |
|
]) |
|
|
|
# gl_CONDITIONAL(conditional, condition) |
|
# is like AM_CONDITIONAL(conditional, condition), except that it does not |
|
# produce an error |
|
# configure: error: conditional "..." was never defined. |
|
# Usually this means the macro was only invoked conditionally. |
|
# when only invoked conditionally. Instead, in that case, both the _TRUE |
|
# and the _FALSE case are disabled. |
|
AC_DEFUN([gl_CONDITIONAL], |
|
[ |
|
pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl |
|
AM_CONDITIONAL([$1], [$2]) |
|
popdef([AC_CONFIG_COMMANDS_PRE])dnl |
|
if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then |
|
[$1]_TRUE=' |
|
[$1]_FALSE='#' |
|
fi |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_CC_ALLOW_WARNINGS], |
|
[ |
|
AC_REQUIRE([AC_PROG_CC]) |
|
AC_CACHE_CHECK([for C compiler option to allow warnings], |
|
[gl_cv_cc_wallow], |
|
[rm -f conftest* |
|
echo 'int dummy;' > conftest.c |
|
AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null |
|
AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null |
|
dnl Test the number of error output lines, because AIX xlc accepts the |
|
dnl option '-Wno-error', just to produce a warning |
|
dnl "Option -Wno-error was incorrectly specified. The option will be ignored." |
|
dnl afterwards. |
|
if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then |
|
gl_cv_cc_wallow='-Wno-error' |
|
else |
|
gl_cv_cc_wallow=none |
|
fi |
|
rm -f conftest* |
|
]) |
|
case "$gl_cv_cc_wallow" in |
|
none) GL_CFLAG_ALLOW_WARNINGS='' ;; |
|
*) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;; |
|
esac |
|
AC_SUBST([GL_CFLAG_ALLOW_WARNINGS]) |
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_CXX_ALLOW_WARNINGS], |
|
[ |
|
dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX. |
|
if test -n "$CXX" && test "$CXX" != no; then |
|
AC_CACHE_CHECK([for C++ compiler option to allow warnings], |
|
[gl_cv_cxx_wallow], |
|
[rm -f conftest* |
|
echo 'int dummy;' > conftest.cc |
|
AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null |
|
AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null |
|
dnl Test the number of error output lines, because AIX xlC accepts the |
|
dnl option '-Wno-error', just to produce a warning |
|
dnl "Option -Wno-error was incorrectly specified. The option will be ignored." |
|
dnl afterwards. |
|
if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then |
|
gl_cv_cxx_wallow='-Wno-error' |
|
else |
|
gl_cv_cxx_wallow=none |
|
fi |
|
rm -f conftest* |
|
]) |
|
case "$gl_cv_cxx_wallow" in |
|
none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; |
|
*) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;; |
|
esac |
|
else |
|
GL_CXXFLAG_ALLOW_WARNINGS='' |
|
fi |
|
AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) |
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([gl_CC_GNULIB_WARNINGS], |
|
[ |
|
AC_REQUIRE([gl_CC_ALLOW_WARNINGS]) |
|
dnl Assume that the compiler supports -Wno-* options only if it also supports |
|
dnl -Wno-error. |
|
GL_CFLAG_GNULIB_WARNINGS='' |
|
if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then |
|
dnl Enable these warning options: |
|
dnl |
|
dnl GCC clang |
|
dnl -Wno-cast-qual >= 3 >= 3.9 |
|
dnl -Wno-conversion >= 3 >= 3.9 |
|
dnl -Wno-float-conversion >= 4.9 >= 3.9 |
|
dnl -Wno-float-equal >= 3 >= 3.9 |
|
dnl -Wimplicit-fallthrough >= 7 >= 3.9 |
|
dnl -Wno-pedantic >= 4.8 >= 3.9 |
|
dnl -Wno-sign-compare >= 3 >= 3.9 |
|
dnl -Wno-sign-conversion >= 4.3 >= 3.9 |
|
dnl -Wno-type-limits >= 4.3 >= 3.9 |
|
dnl -Wno-undef >= 3 >= 3.9 |
|
dnl -Wno-unsuffixed-float-constants >= 4.5 |
|
dnl -Wno-unused-function >= 3 >= 3.9 |
|
dnl -Wno-unused-parameter >= 3 >= 3.9 |
|
dnl |
|
cat > conftest.c <<\EOF |
|
|
|
-Wno-cast-qual |
|
-Wno-conversion |
|
-Wno-float-equal |
|
-Wno-sign-compare |
|
-Wno-undef |
|
-Wno-unused-function |
|
-Wno-unused-parameter |
|
|
|
|
|
-Wno-float-conversion |
|
|
|
|
|
-Wimplicit-fallthrough |
|
|
|
|
|
-Wno-pedantic |
|
|
|
|
|
-Wno-sign-conversion |
|
-Wno-type-limits |
|
|
|
|
|
-Wno-unsuffixed-float-constants |
|
|
|
EOF |
|
gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out" |
|
if AC_TRY_EVAL([gl_command]); then |
|
gl_options=`grep -v '#' conftest.out` |
|
for word in $gl_options; do |
|
GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word" |
|
done |
|
fi |
|
rm -f conftest.c conftest.out |
|
fi |
|
AC_SUBST([GL_CFLAG_GNULIB_WARNINGS]) |
|
]) |
|
|
|
dnl gl_CONDITIONAL_HEADER([foo.h]) |
|
dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input |
|
dnl and produces |
|
dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based |
|
dnl on whether GL_GENERATE_FOO_H is true or false, |
|
dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of |
|
dnl the shell variable GL_GENERATE_FOO_H. |
|
AC_DEFUN([gl_CONDITIONAL_HEADER], |
|
[ |
|
m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1))) |
|
m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1))) |
|
m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1))) |
|
case "$gl_generate_var" in |
|
false) gl_header_name='' ;; |
|
true) |
|
dnl It is OK to use a .h file in lib/ from within tests/, but not vice |
|
dnl versa. |
|
if test -z "$gl_header_name"; then |
|
gl_header_name="${gl_source_base_prefix}$1" |
|
fi |
|
;; |
|
*) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;; |
|
esac |
|
AC_SUBST(gl_header_name) |
|
gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var]) |
|
m4_popdef([gl_generate_cond]) |
|
m4_popdef([gl_generate_var]) |
|
m4_popdef([gl_header_name]) |
|
]) |
|
|
|
dnl gl_CHECK_FUNCS_ANDROID([func], [[ |
|
dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem |
|
dnl on Android. |
|
dnl Namely, if func was added to Android API level, say, 28, then the libc.so |
|
dnl has the symbol func always, whereas the header file <foo.h> declares func |
|
dnl conditionally: |
|
dnl |
|
dnl ... func (...) __INTRODUCED_IN(28); |
|
dnl |
|
dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28", |
|
dnl the function func is declared and exists in libc. |
|
dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27", |
|
dnl the function func is not declared but exists in libc. We need to treat this |
|
dnl case like the case where func does not exist. |
|
AC_DEFUN([gl_CHECK_FUNCS_ANDROID], |
|
[ |
|
AC_CHECK_DECL([$1], , , [$2]) |
|
if test $ac_cv_have_decl_[$1] = yes; then |
|
AC_CHECK_FUNCS([$1]) |
|
else |
|
ac_cv_func_[$1]=no |
|
fi |
|
]) |
|
|
|
dnl Expands to some code for use in .c programs that, on native Windows, defines |
|
dnl the Microsoft deprecated alias function names to the underscore-prefixed |
|
dnl actual function names. With this macro, these function names are available |
|
dnl without linking with '-loldnames' and without generating warnings. |
|
dnl Usage: Use it after all system header files are included. |
|
dnl |
|
dnl |
|
dnl ]GL_MDA_DEFINES[ |
|
dnl ... |
|
AC_DEFUN([GL_MDA_DEFINES],[ |
|
AC_REQUIRE([_GL_MDA_DEFINES]) |
|
[$gl_mda_defines] |
|
]) |
|
AC_DEFUN([_GL_MDA_DEFINES], |
|
[gl_mda_defines=' |
|
#if defined _WIN32 && !defined __CYGWIN__ |
|
#define access _access |
|
#define chdir _chdir |
|
#define chmod _chmod |
|
#define close _close |
|
#define creat _creat |
|
#define dup _dup |
|
#define dup2 _dup2 |
|
#define ecvt _ecvt |
|
#define execl _execl |
|
#define execle _execle |
|
#define execlp _execlp |
|
#define execv _execv |
|
#define execve _execve |
|
#define execvp _execvp |
|
#define execvpe _execvpe |
|
#define fcloseall _fcloseall |
|
#define fcvt _fcvt |
|
#define fdopen _fdopen |
|
#define fileno _fileno |
|
#define gcvt _gcvt |
|
#define getcwd _getcwd |
|
#define getpid _getpid |
|
#define getw _getw |
|
#define isatty _isatty |
|
#define j0 _j0 |
|
#define j1 _j1 |
|
#define jn _jn |
|
#define lfind _lfind |
|
#define lsearch _lsearch |
|
#define lseek _lseek |
|
#define memccpy _memccpy |
|
#define mkdir _mkdir |
|
#define mktemp _mktemp |
|
#define open _open |
|
#define putenv _putenv |
|
#define putw _putw |
|
#define read _read |
|
#define rmdir _rmdir |
|
#define strdup _strdup |
|
#define swab _swab |
|
#define tempnam _tempnam |
|
#define tzset _tzset |
|
#define umask _umask |
|
#define unlink _unlink |
|
#define utime _utime |
|
#define wcsdup _wcsdup |
|
#define write _write |
|
#define y0 _y0 |
|
#define y1 _y1 |
|
#define yn _yn |
|
#endif |
|
' |
|
]) |
|
|