gnulib-common.m4 revision 2
0N/A# gnulib-common.m4 serial 20
2362N/Adnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
0N/Adnl This file is free software; the Free Software Foundation
0N/Adnl gives unlimited permission to copy and/or distribute it,
0N/Adnl with or without modifications, as long as this notice is preserved.
0N/A
2362N/A# gl_COMMON
0N/A# is expanded unconditionally through gnulib-tool magic.
2362N/AAC_DEFUN([gl_COMMON], [
0N/A dnl Use AC_REQUIRE here, so that the code is expanded once only.
0N/A AC_REQUIRE([gl_00GNULIB])
0N/A AC_REQUIRE([gl_COMMON_BODY])
0N/A])
0N/AAC_DEFUN([gl_COMMON_BODY], [
0N/A AH_VERBATIM([isoc99_inline],
0N/A[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
0N/A the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
0N/A earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
0N/A __APPLE__ && __MACH__ test for MacOS X.
0N/A __APPLE_CC__ tests for the Apple compiler and its version.
2362N/A __STDC_VERSION__ tests for the C99 mode. */
2362N/A#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
2362N/A# define __GNUC_STDC_INLINE__ 1
0N/A#endif])
0N/A AH_VERBATIM([unused_parameter],
0N/A[/* Define as a marker that can be attached to declarations that might not
0N/A be used. This helps to reduce warnings, such as from
0N/A GCC -Wunused-parameter. */
0N/A#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
0N/A# define _GL_UNUSED __attribute__ ((__unused__))
0N/A#else
0N/A# define _GL_UNUSED
0N/A#endif
0N/A/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
0N/A is a misnomer outside of parameter lists. */
0N/A#define _UNUSED_PARAMETER_ _GL_UNUSED
0N/A])
0N/A dnl Preparation for running test programs:
0N/A dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
0N/A dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
0N/A dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
0N/A LIBC_FATAL_STDERR_=1
0N/A export LIBC_FATAL_STDERR_
0N/A])
0N/A
0N/A# gl_MODULE_INDICATOR_CONDITION
0N/A# expands to a C preprocessor expression that evaluates to 1 or 0, depending
0N/A# whether a gnulib module that has been requested shall be considered present
0N/A# or not.
0N/AAC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1])
0N/A
# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
# sets the shell variable that indicates the presence of the given module to
# a C preprocessor expression that will evaluate to 1.
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
[
GNULIB_[]m4_translit([[$1]],
[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION
])
# gl_MODULE_INDICATOR([modulename])
# defines a C macro indicating the presence of the given module
# in a location where it can be used.
# | Value | Value |
# | in lib/ | in tests/ |
# --------------------------------------------+---------+-----------+
# Module present among main modules: | 1 | 1 |
# --------------------------------------------+---------+-----------+
# Module present among tests-related modules: | 0 | 1 |
# --------------------------------------------+---------+-----------+
# Module not present at all: | 0 | 0 |
# --------------------------------------------+---------+-----------+
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.])
])
# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
# defines a C macro indicating the presence of the given module
# in lib or tests. This is useful to determine whether the module
# should be tested.
# | Value | Value |
# | in lib/ | in tests/ |
# --------------------------------------------+---------+-----------+
# Module present among main modules: | 1 | 1 |
# --------------------------------------------+---------+-----------+
# Module present among tests-related modules: | 1 | 1 |
# --------------------------------------------+---------+-----------+
# Module not present at all: | 0 | 0 |
# --------------------------------------------+---------+-----------+
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.])
])
# m4_foreach_w
# is a backport of autoconf-2.59c's m4_foreach_w.
# Remove this macro when we can assume autoconf >= 2.60.
m4_ifndef([m4_foreach_w],
[m4_define([m4_foreach_w],
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
# ----------------------------------------------------
# Backport of autoconf-2.63b's macro.
# Remove this macro when we can assume autoconf >= 2.64.
m4_ifndef([AS_VAR_IF],
[m4_define([AS_VAR_IF],
[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
# AC_PROG_MKDIR_P
# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
# for interoperability with automake-1.9.6 from autoconf-2.62.
# Remove this macro when we can assume autoconf >= 2.62 or
# autoconf >= 2.60 && automake >= 1.10.
m4_ifdef([AC_PROG_MKDIR_P], [
dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
m4_define([AC_PROG_MKDIR_P],
m4_defn([AC_PROG_MKDIR_P])[
AC_SUBST([MKDIR_P])])], [
dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
[AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
MKDIR_P='$(mkdir_p)'
AC_SUBST([MKDIR_P])])])
# AC_C_RESTRICT
# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61,
# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
# works.
# This definition can be removed once autoconf >= 2.62 can be assumed.
m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
AC_DEFUN([AC_C_RESTRICT],
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
[ac_cv_c_restrict=no
# The order here caters to the fact that C++ does not require restrict.
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 s[1];
int * $ac_kw t = s;
t[0] = 0;
return foo(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 directly. */
#undef restrict
/* Work around a bug in Sun C++: it does not support _Restrict, even
though the corresponding Sun C compiler does, which causes
"#define restrict _Restrict" in the previous line. Perhaps some future
version of Sun C++ will work with _Restrict; if so, it'll probably
define __RESTRICT, just as Sun C does. */
#if defined __SUNPRO_CC && !defined __RESTRICT
# define _Restrict
#endif])
case $ac_cv_c_restrict in
restrict) ;;
no) AC_DEFINE([restrict], []) ;;
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
esac
])
])
# 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
])
# 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],
[
saved_as_echo_n="$as_echo_n"
as_echo_n=':'
AC_CACHE_VAL([$1], [$2])
as_echo_n="$saved_as_echo_n"
])