1 # gnulib-common.m4 serial 63
2 dnl Copyright (C) 2007-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
10 # is expanded unconditionally through gnulib-tool magic.
11 AC_DEFUN([gl_COMMON], [
12 dnl Use AC_REQUIRE here, so that the code is expanded once only.
13 AC_REQUIRE([gl_00GNULIB])
14 AC_REQUIRE([gl_COMMON_BODY])
15 AC_REQUIRE([gl_ZZGNULIB])
17 AC_DEFUN([gl_COMMON_BODY], [
18 AH_VERBATIM([_GL_GNUC_PREREQ],
19 [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */
20 #if defined __GNUC__ && defined __GNUC_MINOR__
21 # define _GL_GNUC_PREREQ(major, minor) \
22 ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
24 # define _GL_GNUC_PREREQ(major, minor) 0
27 AH_VERBATIM([_Noreturn],
28 [/* The _Noreturn keyword of C11. */
30 # if (defined __cplusplus \
31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
34 /* [[noreturn]] is not practically usable, because with it the syntax
35 extern _Noreturn void func (...);
36 would not be valid; such a declaration would only be valid with 'extern'
37 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
38 AIX system header files and several gnulib header files use precisely
39 this syntax with 'extern'. */
40 # define _Noreturn [[noreturn]]
41 # elif ((!defined __cplusplus || defined __clang__) \
42 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
43 || (!defined __STRICT_ANSI__ \
44 && (_GL_GNUC_PREREQ (4, 7) \
45 || (defined __apple_build_version__ \
46 ? 6000000 <= __apple_build_version__ \
47 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
48 /* _Noreturn works as-is. */
49 # elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
50 # define _Noreturn __attribute__ ((__noreturn__))
51 # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
52 # define _Noreturn __declspec (noreturn)
58 AH_VERBATIM([isoc99_inline],
59 [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
60 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
61 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
62 __APPLE__ && __MACH__ test for Mac OS X.
63 __APPLE_CC__ tests for the Apple compiler and its version.
64 __STDC_VERSION__ tests for the C99 mode. */
65 #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
66 # define __GNUC_STDC_INLINE__ 1
68 AH_VERBATIM([attribute],
70 #ifdef __has_attribute
71 # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
73 # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
74 # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
75 # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
76 # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
77 # define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
78 # define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
79 # define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
80 # define _GL_ATTR_diagnose_if 0
81 # define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
82 # define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
83 # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
84 # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
85 # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
87 # define _GL_ATTR_may_alias 0
89 # define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
91 # define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
92 # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
93 # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
94 # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
95 # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
96 # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
97 # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
98 # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
99 # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
100 # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
101 # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
104 ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
106 #if _GL_HAS_ATTRIBUTE (alloc_size)
107 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
109 # define _GL_ATTRIBUTE_ALLOC_SIZE(args)
112 #if _GL_HAS_ATTRIBUTE (always_inline)
113 # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
115 # define _GL_ATTRIBUTE_ALWAYS_INLINE
118 #if _GL_HAS_ATTRIBUTE (artificial)
119 # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
121 # define _GL_ATTRIBUTE_ARTIFICIAL
124 /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
125 <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
126 Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
127 #if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
129 # define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
131 # define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
134 # define _GL_ATTRIBUTE_COLD
137 #if _GL_HAS_ATTRIBUTE (const)
138 # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
140 # define _GL_ATTRIBUTE_CONST
143 #if 201710L < __STDC_VERSION__
144 # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
145 #elif _GL_HAS_ATTRIBUTE (deprecated)
146 # define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
148 # define _GL_ATTRIBUTE_DEPRECATED
151 #if _GL_HAS_ATTRIBUTE (error)
152 # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
153 # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
154 #elif _GL_HAS_ATTRIBUTE (diagnose_if)
155 # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
156 # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
158 # define _GL_ATTRIBUTE_ERROR(msg)
159 # define _GL_ATTRIBUTE_WARNING(msg)
162 #if _GL_HAS_ATTRIBUTE (externally_visible)
163 # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
165 # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
168 /* FALLTHROUGH is special, because it always expands to something. */
169 #if 201710L < __STDC_VERSION__
170 # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
171 #elif _GL_HAS_ATTRIBUTE (fallthrough)
172 # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
174 # define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
177 #if _GL_HAS_ATTRIBUTE (format)
178 # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
180 # define _GL_ATTRIBUTE_FORMAT(spec)
183 #if _GL_HAS_ATTRIBUTE (leaf)
184 # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
186 # define _GL_ATTRIBUTE_LEAF
189 /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
190 #if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
191 # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
193 # define _GL_ATTRIBUTE_MAY_ALIAS
196 #if 201710L < __STDC_VERSION__
197 # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
198 #elif _GL_HAS_ATTRIBUTE (unused)
199 # define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
201 # define _GL_ATTRIBUTE_MAYBE_UNUSED
203 /* Earlier spellings of this macro. */
204 #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
205 #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
207 #if _GL_HAS_ATTRIBUTE (malloc)
208 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
210 # define _GL_ATTRIBUTE_MALLOC
213 #if 201710L < __STDC_VERSION__
214 # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
215 #elif _GL_HAS_ATTRIBUTE (warn_unused_result)
216 # define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
218 # define _GL_ATTRIBUTE_NODISCARD
221 #if _GL_HAS_ATTRIBUTE (noinline)
222 # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
224 # define _GL_ATTRIBUTE_NOINLINE
227 #if _GL_HAS_ATTRIBUTE (nonnull)
228 # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
230 # define _GL_ATTRIBUTE_NONNULL(args)
233 #if _GL_HAS_ATTRIBUTE (nonstring)
234 # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
236 # define _GL_ATTRIBUTE_NONSTRING
239 /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
241 #if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
242 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
244 # define _GL_ATTRIBUTE_NOTHROW
247 #if _GL_HAS_ATTRIBUTE (packed)
248 # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
250 # define _GL_ATTRIBUTE_PACKED
253 #if _GL_HAS_ATTRIBUTE (pure)
254 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
256 # define _GL_ATTRIBUTE_PURE
259 #if _GL_HAS_ATTRIBUTE (returns_nonnull)
260 # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
262 # define _GL_ATTRIBUTE_RETURNS_NONNULL
265 #if _GL_HAS_ATTRIBUTE (sentinel)
266 # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
268 # define _GL_ATTRIBUTE_SENTINEL(pos)
271 ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
273 /* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'. */
274 #if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
275 # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED
277 # define _GL_UNUSED_LABEL
280 AH_VERBATIM([async_safe],
281 [/* The _GL_ASYNC_SAFE marker should be attached to functions that are
282 signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
283 invoked from such signal handlers. Such functions have some restrictions:
284 * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
285 or should be listed as async-signal-safe in POSIX
286 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
287 section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in
288 particular, are NOT async-signal-safe.
289 * All memory locations (variables and struct fields) that these functions
290 access must be marked 'volatile'. This holds for both read and write
291 accesses. Otherwise the compiler might optimize away stores to and
292 reads from such locations that occur in the program, depending on its
293 data flow analysis. For example, when the program contains a loop
294 that is intended to inspect a variable set from within a signal handler
295 while (!signal_occurred)
297 the compiler is allowed to transform this into an endless loop if the
298 variable 'signal_occurred' is not declared 'volatile'.
299 Additionally, recall that:
300 * A signal handler should not modify errno (except if it is a handler
301 for a fatal signal and ends by raising the same signal again, thus
302 provoking the termination of the process). If it invokes a function
303 that may clobber errno, it needs to save and restore the value of
305 #define _GL_ASYNC_SAFE
307 AH_VERBATIM([micro_optimizations],
308 [/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
309 n1 and n2 are expressions without side effects, that evaluate to real
310 numbers (excluding NaN).
315 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
316 jump with nearly all GCC versions up to GCC 10.
317 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many
318 GCC versions up to GCC 9.
319 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
320 avoids conditional jumps in all GCC versions >= 3.4. */
321 #define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
323 dnl Hint which direction to take regarding cross-compilation guesses:
324 dnl When a user installs a program on a platform they are not intimately
325 dnl familiar with, --enable-cross-guesses=conservative is the appropriate
326 dnl choice. It implements the "If we don't know, assume the worst" principle.
327 dnl However, when an operating system developer (on a platform which is not
328 dnl yet known to gnulib) builds packages for their platform, they want to
329 dnl expose, not hide, possible platform bugs; in this case,
330 dnl --enable-cross-guesses=risky is the appropriate choice.
331 dnl Sets the variables
332 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
333 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
334 AC_ARG_ENABLE([cross-guesses],
335 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
336 [specify policy for cross-compilation guesses])],
337 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
338 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
339 enableval=conservative
341 gl_cross_guesses="$enableval"],
342 [gl_cross_guesses=conservative])
343 if test $gl_cross_guesses = risky; then
344 gl_cross_guess_normal="guessing yes"
345 gl_cross_guess_inverted="guessing no"
347 gl_cross_guess_normal="guessing no"
348 gl_cross_guess_inverted="guessing yes"
350 dnl Preparation for running test programs:
351 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
352 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
353 dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
355 export LIBC_FATAL_STDERR_
358 # gl_MODULE_INDICATOR_CONDITION
359 # expands to a C preprocessor expression that evaluates to 1 or 0, depending
360 # whether a gnulib module that has been requested shall be considered present
362 m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
364 # gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
365 # sets the shell variable that indicates the presence of the given module to
366 # a C preprocessor expression that will evaluate to 1.
367 AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
369 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
370 [GNULIB_[]m4_translit([[$1]],
371 [abcdefghijklmnopqrstuvwxyz./-],
372 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
373 [gl_MODULE_INDICATOR_CONDITION])
376 # gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
377 # modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
378 # The shell variable's value is a C preprocessor expression that evaluates
380 AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
382 m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
384 dnl Simplify the expression VALUE || 1 to 1.
387 [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
388 [gl_MODULE_INDICATOR_CONDITION])])
391 # gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
392 # modifies the shell variable to include the given condition. The shell
393 # variable's value is a C preprocessor expression that evaluates to 0 or 1.
394 AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
396 dnl Simplify the expression 1 || CONDITION to 1.
397 if test "$[]$1" != 1; then
398 dnl Simplify the expression 0 || CONDITION to CONDITION.
399 if test "$[]$1" = 0; then
407 # gl_MODULE_INDICATOR([modulename])
408 # defines a C macro indicating the presence of the given module
409 # in a location where it can be used.
411 # | in lib/ | in tests/ |
412 # --------------------------------------------+---------+-----------+
413 # Module present among main modules: | 1 | 1 |
414 # --------------------------------------------+---------+-----------+
415 # Module present among tests-related modules: | 0 | 1 |
416 # --------------------------------------------+---------+-----------+
417 # Module not present at all: | 0 | 0 |
418 # --------------------------------------------+---------+-----------+
419 AC_DEFUN([gl_MODULE_INDICATOR],
421 AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
422 [abcdefghijklmnopqrstuvwxyz./-],
423 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
424 [gl_MODULE_INDICATOR_CONDITION],
425 [Define to a C preprocessor expression that evaluates to 1 or 0,
426 depending whether the gnulib module $1 shall be considered present.])
429 # gl_MODULE_INDICATOR_FOR_TESTS([modulename])
430 # defines a C macro indicating the presence of the given module
431 # in lib or tests. This is useful to determine whether the module
434 # | in lib/ | in tests/ |
435 # --------------------------------------------+---------+-----------+
436 # Module present among main modules: | 1 | 1 |
437 # --------------------------------------------+---------+-----------+
438 # Module present among tests-related modules: | 1 | 1 |
439 # --------------------------------------------+---------+-----------+
440 # Module not present at all: | 0 | 0 |
441 # --------------------------------------------+---------+-----------+
442 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
444 AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
445 [abcdefghijklmnopqrstuvwxyz./-],
446 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
447 [Define to 1 when the gnulib module $1 should be tested.])
450 # gl_ASSERT_NO_GNULIB_POSIXCHECK
451 # asserts that there will never be a need to #define GNULIB_POSIXCHECK.
452 # and thereby enables an optimization of configure and config.h.
454 AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
456 dnl Override gl_WARN_ON_USE_PREPARE.
457 dnl But hide this definition from 'aclocal'.
458 AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
461 # gl_ASSERT_NO_GNULIB_TESTS
462 # asserts that there will be no gnulib tests in the scope of the configure.ac
463 # and thereby enables an optimization of config.h.
465 AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
467 dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
468 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
471 # Test whether <features.h> exists.
472 # Set HAVE_FEATURES_H.
473 AC_DEFUN([gl_FEATURES_H],
475 AC_CHECK_HEADERS_ONCE([features.h])
476 if test $ac_cv_header_features_h = yes; then
481 AC_SUBST([HAVE_FEATURES_H])
485 # Modifies the value of the shell variable CC in an attempt to make $CC
486 # understand ISO C99 source code.
487 AC_DEFUN([gl_PROG_CC_C99],
489 dnl Just use AC_PROG_CC_C99.
490 dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
491 dnl value of CC will contain the C99 enabling options twice. But this is only
492 dnl a cosmetic problem.
493 dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
494 dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
495 m4_version_prereq([2.70],
496 [AC_REQUIRE([AC_PROG_CC])],
497 [AC_REQUIRE([AC_PROG_CC_C99])])
501 # Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
502 # The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
504 AC_DEFUN([gl_PROG_AR_RANLIB],
506 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
507 dnl as "cc", and GCC as "gcc". They have different object file formats and
508 dnl library formats. In particular, the GNU binutils programs ar and ranlib
509 dnl produce libraries that work only with gcc, not with cc.
510 AC_REQUIRE([AC_PROG_CC])
511 dnl The '][' hides this use from 'aclocal'.
512 AC_BEFORE([$0], [A][M_PROG_AR])
513 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
515 AC_EGREP_CPP([Amsterdam],
521 [gl_cv_c_amsterdam_compiler=yes],
522 [gl_cv_c_amsterdam_compiler=no])
525 dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
526 dnl building with __ACK__.
527 if test $gl_cv_c_amsterdam_compiler = yes; then
528 if test -z "$AR"; then
531 if test -z "$ARFLAGS"; then
535 dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
536 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
537 dnl script on-demand, if not specified by ./configure of course).
538 dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
539 dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
540 dnl because AM_PROG_AR is written so it could re-set AR variable even for
541 dnl __ACK__. It may seem like its easier to avoid calling the macro here,
542 dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
543 dnl default value and automake should usually know them).
545 dnl The '][' hides this use from 'aclocal'.
546 m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
549 dnl In case the code above has not helped with setting AR/ARFLAGS, use
550 dnl Automake-documented default values for AR and ARFLAGS, but prefer
551 dnl ${host}-ar over ar (useful for cross-compiling).
552 AC_CHECK_TOOL([AR], [ar], [ar])
553 if test -z "$ARFLAGS"; then
559 if test -z "$RANLIB"; then
560 if test $gl_cv_c_amsterdam_compiler = yes; then
563 dnl Use the ranlib program if it is available.
571 # This definition is copied from post-2.70 Autoconf and overrides the
572 # AC_C_RESTRICT macro from autoconf 2.60..2.70.
573 m4_version_prereq([2.70.1], [], [
574 AC_DEFUN([AC_C_RESTRICT],
575 [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
577 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
578 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
579 # Put 'restrict' last, because C++ lacks it.
580 for ac_kw in __restrict__ __restrict _Restrict restrict; do
583 [[typedef int *int_ptr;
584 int foo (int_ptr $ac_kw ip) { return ip[0]; }
585 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
586 int bar (int ip[$ac_kw]) { return ip[0]; }
591 return foo (t) + bar (t);
593 [ac_cv_c_restrict=$ac_kw])
594 test "$ac_cv_c_restrict" != no && break
597 AH_VERBATIM([restrict],
598 [/* Define to the equivalent of the C99 'restrict' keyword, or to
599 nothing if this is not supported. Do not define if restrict is
600 supported only directly. */
602 /* Work around a bug in older versions of Sun C++, which did not
603 #define __restrict__ or support _Restrict or __restrict__
604 even though the corresponding Sun C compiler ended up with
605 "#define restrict _Restrict" or "#define restrict __restrict__"
606 in the previous line. This workaround can be removed once
607 we assume Oracle Developer Studio 12.5 (2016) or later. */
608 #if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
610 # define __restrict__
612 case $ac_cv_c_restrict in
614 no) AC_DEFINE([restrict], []) ;;
615 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
621 # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
622 # Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
623 # macros invoke AC_C_BIGENDIAN with arguments.
624 AC_DEFUN([gl_BIGENDIAN],
629 # A temporary file descriptor.
630 # Must be less than 10, because dash 0.5.8 does not support redirections
631 # with multi-digit file descriptors.
632 m4_define([GL_TMP_FD], 9)
635 # executes command, but without the normal configure output.
636 # This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
637 # inside another AC_CACHE_CHECK.
638 AC_DEFUN([gl_SILENT],
640 exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
642 exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
645 # gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
646 # is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
647 # output a spurious "(cached)" mark in the midst of other configure output.
648 # This macro should be used instead of AC_CACHE_VAL when it is not surrounded
649 # by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
650 AC_DEFUN([gl_CACHE_VAL_SILENT],
653 AC_CACHE_VAL([$1], [$2])
657 dnl Expands to some code for use in .c programs that, on native Windows, defines
658 dnl the Microsoft deprecated alias function names to the underscore-prefixed
659 dnl actual function names. With this macro, these function names are available
660 dnl without linking with '-loldnames' and without generating warnings.
661 dnl Usage: Use it after all system header files are included.
666 AC_DEFUN([GL_MDA_DEFINES],[
667 AC_REQUIRE([_GL_MDA_DEFINES])
670 AC_DEFUN([_GL_MDA_DEFINES],
672 #if defined _WIN32 && !defined __CYGWIN__
673 #define access _access
682 #define execle _execle
683 #define execlp _execlp
685 #define execve _execve
686 #define execvp _execvp
687 #define execvpe _execvpe
688 #define fcloseall _fcloseall
690 #define fdopen _fdopen
691 #define fileno _fileno
693 #define getcwd _getcwd
694 #define getpid _getpid
696 #define isatty _isatty
701 #define lsearch _lsearch
703 #define memccpy _memccpy
705 #define mktemp _mktemp
707 #define putenv _putenv
711 #define strdup _strdup
713 #define tempnam _tempnam
716 #define unlink _unlink
718 #define wcsdup _wcsdup