summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-08-23 19:14:01 +0200
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-08-23 19:14:01 +0200
commitc602300fc87bab51346895f14f7600c77334a457 (patch)
treee02aaa08ead44af13d79bf1a3c1c8d5d2ffae7b6
parentdab030a8dca6641d33fb4ad9e90a257e6f38cf9d (diff)
downloadmonitoring-plugins-c602300fc87bab51346895f14f7600c77334a457.tar.gz
Add more files...
-rw-r--r--m4/00gnulib.m485
-rw-r--r--m4/gnulib-common.m41075
-rw-r--r--m4/gnulib-tool.m463
-rw-r--r--m4/zzgnulib.m423
4 files changed, 1246 insertions, 0 deletions
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4
new file mode 100644
index 00000000..dea34e83
--- /dev/null
+++ b/m4/00gnulib.m4
@@ -0,0 +1,85 @@
1# 00gnulib.m4 serial 8
2dnl Copyright (C) 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl This file must be named something that sorts before all other
8dnl gnulib-provided .m4 files. It is needed until the clang fix has
9dnl been included in Autoconf.
10
11# The following definitions arrange to use a compiler option
12# -Werror=implicit-function-declaration in AC_CHECK_DECL, when the
13# compiler is clang. Without it, clang implicitly declares "known"
14# library functions in C mode, but not in C++ mode, which would cause
15# Gnulib to omit a declaration and thus later produce an error in C++
16# mode. As of clang 9.0, these "known" functions are identified through
17# LIBBUILTIN invocations in the LLVM source file
18# llvm/tools/clang/include/clang/Basic/Builtins.def.
19# It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL,
20# because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed
21# to AC_REQUIRE anything: some configure.ac files have their first
22# AC_CHECK_DECL executed conditionally. Therefore append the extra tests
23# to AC_PROG_CC.
24AC_DEFUN([gl_COMPILER_CLANG],
25[
26dnl AC_REQUIRE([AC_PROG_CC])
27 AC_CACHE_CHECK([whether the compiler is clang],
28 [gl_cv_compiler_clang],
29 [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error
30 dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has
31 dnl not yet been invoked.
32 _AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM([[
34 #ifdef __clang__
35 barfbarf
36 #endif
37 ]],[[]])
38 ],
39 [gl_cv_compiler_clang=no],
40 [gl_cv_compiler_clang=yes])
41 ])
42])
43AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL],
44[
45dnl AC_REQUIRE([AC_PROG_CC])
46dnl AC_REQUIRE([gl_COMPILER_CLANG])
47 AC_CACHE_CHECK([for compiler option needed when checking for declarations],
48 [gl_cv_compiler_check_decl_option],
49 [if test $gl_cv_compiler_clang = yes; then
50 dnl Test whether the compiler supports the option
51 dnl '-Werror=implicit-function-declaration'.
52 save_ac_compile="$ac_compile"
53 ac_compile="$ac_compile -Werror=implicit-function-declaration"
54 dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a
55 dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
56 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
57 [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'],
58 [gl_cv_compiler_check_decl_option=none])
59 ac_compile="$save_ac_compile"
60 else
61 gl_cv_compiler_check_decl_option=none
62 fi
63 ])
64 if test "x$gl_cv_compiler_check_decl_option" != xnone; then
65 ac_compile_for_check_decl="$ac_compile $gl_cv_compiler_check_decl_option"
66 else
67 ac_compile_for_check_decl="$ac_compile"
68 fi
69])
70dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl
71dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC
72dnl in zzgnulib.m4 is inactive, use the original ac_compile.
73m4_define([_AC_CHECK_DECL_BODY],
74[ ac_save_ac_compile="$ac_compile"
75 if test -n "$ac_compile_for_check_decl"; then
76 ac_compile="$ac_compile_for_check_decl"
77 fi]
78m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile"
79])
80
81# gl_00GNULIB
82# -----------
83# Witness macro that this file has been included. Needed to force
84# Automake to include this file prior to all other gnulib .m4 files.
85AC_DEFUN([gl_00GNULIB])
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
new file mode 100644
index 00000000..30911d15
--- /dev/null
+++ b/m4/gnulib-common.m4
@@ -0,0 +1,1075 @@
1# gnulib-common.m4 serial 73
2dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_PREREQ([2.62])
8
9# gl_COMMON
10# is expanded unconditionally through gnulib-tool magic.
11AC_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])
16])
17AC_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__))
23#else
24# define _GL_GNUC_PREREQ(major, minor) 0
25#endif
26])
27 AH_VERBATIM([_Noreturn],
28[/* The _Noreturn keyword of C11. */
29#ifndef _Noreturn
30# if (defined __cplusplus \
31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
33 && 0)
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)
53# else
54# define _Noreturn
55# endif
56#endif
57])
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
67#endif])
68 AH_VERBATIM([attribute],
69[/* Attributes. */
70#if (defined __has_attribute \
71 && (!defined __clang_minor__ \
72 || (defined __apple_build_version__ \
73 ? 6000000 <= __apple_build_version__ \
74 : 3 < __clang_major__ + (5 <= __clang_minor__))))
75# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
76#else
77# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
78# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
79# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
80# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
81# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
82# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
83# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
84# define _GL_ATTR_diagnose_if 0
85# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
86# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
87# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
88# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
89# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
90# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
91# ifdef _ICC
92# define _GL_ATTR_may_alias 0
93# else
94# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
95# endif
96# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
97# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
98# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
99# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
100# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
101# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
102# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
103# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
104# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
105# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
106#endif
107
108#ifdef __has_c_attribute
109# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710 \
110 && _GL_GNUC_PREREQ (4, 6))
111# pragma GCC diagnostic ignored "-Wpedantic"
112# endif
113# define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__)
114#else
115# define _GL_HAS_C_ATTRIBUTE(attr) 0
116#endif
117
118]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
119[
120/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
121 is the size of the returned memory block.
122 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
123 by the Nth argument of the function is the size of the returned memory block.
124 */
125/* Applies to: function, pointer to function, function types. */
126#if _GL_HAS_ATTRIBUTE (alloc_size)
127# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
128#else
129# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
130#endif
131
132/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
133 function and report an error if it cannot do so. */
134/* Applies to: function. */
135#if _GL_HAS_ATTRIBUTE (always_inline)
136# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
137#else
138# define _GL_ATTRIBUTE_ALWAYS_INLINE
139#endif
140
141/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
142 in stack traces when debugging. The compiler should omit the function from
143 stack traces. */
144/* Applies to: function. */
145#if _GL_HAS_ATTRIBUTE (artificial)
146# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
147#else
148# define _GL_ATTRIBUTE_ARTIFICIAL
149#endif
150
151/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */
152/* Applies to: functions. */
153/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
154 <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
155 Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
156#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
157# ifndef __SUNPRO_C
158# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
159# else
160# define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
161# endif
162#else
163# define _GL_ATTRIBUTE_COLD
164#endif
165
166/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
167 calls to the function with the same arguments.
168 This attribute is safe for a function that neither depends on nor affects
169 observable state, and always returns exactly once - e.g., does not loop
170 forever, and does not call longjmp.
171 (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
172/* Applies to: functions. */
173#if _GL_HAS_ATTRIBUTE (const)
174# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
175#else
176# define _GL_ATTRIBUTE_CONST
177#endif
178
179/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
180 that can be freed by passing them as the Ith argument to the
181 function F.
182 _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
183 can be freed via 'free'; it can be used only after declaring 'free'. */
184/* Applies to: functions. Cannot be used on inline functions. */
185#if _GL_GNUC_PREREQ (11, 0)
186# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
187#else
188# define _GL_ATTRIBUTE_DEALLOC(f, i)
189#endif
190/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
191 to use this earlier definition, since <stdlib.h> may not have been included
192 yet. */
193#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
194# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
195#endif
196
197/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
198 The compiler may warn if the entity is used. */
199/* Applies to:
200 - function, variable,
201 - struct, union, struct/union member,
202 - enumeration, enumeration item,
203 - typedef,
204 in C++ also: namespace, class, template specialization. */
205#if _GL_HAS_C_ATTRIBUTE (deprecated)
206# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
207#elif _GL_HAS_ATTRIBUTE (deprecated)
208# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
209#else
210# define _GL_ATTRIBUTE_DEPRECATED
211#endif
212
213/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
214 the function call is not optimized away.
215 _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
216 the function call is not optimized away. */
217/* Applies to: functions. */
218#if _GL_HAS_ATTRIBUTE (error)
219# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
220# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
221#elif _GL_HAS_ATTRIBUTE (diagnose_if)
222# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
223# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
224#else
225# define _GL_ATTRIBUTE_ERROR(msg)
226# define _GL_ATTRIBUTE_WARNING(msg)
227#endif
228
229/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
230 visible to debuggers etc., even with '-fwhole-program'. */
231/* Applies to: functions, variables. */
232#if _GL_HAS_ATTRIBUTE (externally_visible)
233# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
234#else
235# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
236#endif
237
238/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
239 the control flow falls through to the immediately following 'case' or
240 'default' label. The compiler should not warn in this case. */
241/* Applies to: Empty statement (;), inside a 'switch' statement. */
242/* Always expands to something. */
243#if _GL_HAS_C_ATTRIBUTE (fallthrough)
244# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
245#elif _GL_HAS_ATTRIBUTE (fallthrough)
246# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
247#else
248# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
249#endif
250
251/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
252 declares that the STRING-INDEXth function argument is a format string of
253 style ARCHETYPE, which is one of:
254 printf, gnu_printf
255 scanf, gnu_scanf,
256 strftime, gnu_strftime,
257 strfmon,
258 or the same thing prefixed and suffixed with '__'.
259 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
260 are suitable for the format string. */
261/* Applies to: functions. */
262#if _GL_HAS_ATTRIBUTE (format)
263# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
264#else
265# define _GL_ATTRIBUTE_FORMAT(spec)
266#endif
267
268/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
269 compilation unit, it executes code from that unit only by return or by
270 exception handling. This declaration lets the compiler optimize that unit
271 more aggressively. */
272/* Applies to: functions. */
273#if _GL_HAS_ATTRIBUTE (leaf)
274# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
275#else
276# define _GL_ATTRIBUTE_LEAF
277#endif
278
279/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
280 allocated memory. */
281/* Applies to: functions. */
282#if _GL_HAS_ATTRIBUTE (malloc)
283# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
284#else
285# define _GL_ATTRIBUTE_MALLOC
286#endif
287
288/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
289 same storage as pointers to other types. Thus this declaration disables
290 strict aliasing optimization. */
291/* Applies to: types. */
292/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
293#if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
294# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
295#else
296# define _GL_ATTRIBUTE_MAY_ALIAS
297#endif
298
299/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
300 the entity is not used. The compiler should not warn if the entity is not
301 used. */
302/* Applies to:
303 - function, variable,
304 - struct, union, struct/union member,
305 - enumeration, enumeration item,
306 - typedef,
307 in C++ also: class. */
308/* In C++ and C2x, this is spelled [[__maybe_unused__]].
309 GCC's syntax is __attribute__ ((__unused__)).
310 clang supports both syntaxes. */
311#if _GL_HAS_C_ATTRIBUTE (maybe_unused)
312# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
313#else
314# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
315#endif
316/* Alternative spelling of this macro, for convenience. */
317#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
318/* Earlier spellings of this macro. */
319#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
320
321/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not
322 discard the return value. The compiler may warn if the caller does not use
323 the return value, unless the caller uses something like ignore_value. */
324/* Applies to: function, enumeration, class. */
325#if _GL_HAS_C_ATTRIBUTE (nodiscard)
326# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
327#elif _GL_HAS_ATTRIBUTE (warn_unused_result)
328# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
329#else
330# define _GL_ATTRIBUTE_NODISCARD
331#endif
332
333/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
334 function. */
335/* Applies to: functions. */
336#if _GL_HAS_ATTRIBUTE (noinline)
337# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
338#else
339# define _GL_ATTRIBUTE_NOINLINE
340#endif
341
342/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
343 must not be NULL.
344 _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
345 null. */
346/* Applies to: functions. */
347#if _GL_HAS_ATTRIBUTE (nonnull)
348# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
349#else
350# define _GL_ATTRIBUTE_NONNULL(args)
351#endif
352
353/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
354 not meant to be NUL-terminated. */
355/* Applies to: struct/union members and variables that are arrays of element
356 type '[[un]signed] char'. */
357#if _GL_HAS_ATTRIBUTE (nonstring)
358# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
359#else
360# define _GL_ATTRIBUTE_NONSTRING
361#endif
362
363/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
364
365/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
366 */
367/* Applies to: functions. */
368#if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
369# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
370#else
371# define _GL_ATTRIBUTE_NOTHROW
372#endif
373
374/* _GL_ATTRIBUTE_PACKED declares:
375 For struct members: The member has the smallest possible alignment.
376 For struct, union, class: All members have the smallest possible alignment,
377 minimizing the memory required. */
378/* Applies to: struct members, struct, union,
379 in C++ also: class. */
380#if _GL_HAS_ATTRIBUTE (packed)
381# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
382#else
383# define _GL_ATTRIBUTE_PACKED
384#endif
385
386/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
387 calls to the function with the same arguments if observable state is not
388 changed between calls.
389 This attribute is safe for a function that does not affect
390 observable state, and always returns exactly once.
391 (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
392/* Applies to: functions. */
393#if _GL_HAS_ATTRIBUTE (pure)
394# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
395#else
396# define _GL_ATTRIBUTE_PURE
397#endif
398
399/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
400 a non-NULL pointer. */
401/* Applies to: functions. */
402#if _GL_HAS_ATTRIBUTE (returns_nonnull)
403# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
404#else
405# define _GL_ATTRIBUTE_RETURNS_NONNULL
406#endif
407
408/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
409 trailing NULL argument.
410 _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
411 _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
412/* Applies to: functions. */
413#if _GL_HAS_ATTRIBUTE (sentinel)
414# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
415#else
416# define _GL_ATTRIBUTE_SENTINEL(pos)
417#endif
418
419/* A helper macro. Don't use it directly. */
420#if _GL_HAS_ATTRIBUTE (unused)
421# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
422#else
423# define _GL_ATTRIBUTE_UNUSED
424#endif
425
426]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
427[
428/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the
429 immediately preceding label is not used. The compiler should not warn
430 if the label is not used. */
431/* Applies to: label (both in C and C++). */
432/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
433 syntax. But clang does. */
434#if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
435# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
436#else
437# define _GL_UNUSED_LABEL
438#endif
439])
440 AH_VERBATIM([async_safe],
441[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
442 signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
443 invoked from such signal handlers. Such functions have some restrictions:
444 * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
445 or should be listed as async-signal-safe in POSIX
446 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
447 section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in
448 particular, are NOT async-signal-safe.
449 * All memory locations (variables and struct fields) that these functions
450 access must be marked 'volatile'. This holds for both read and write
451 accesses. Otherwise the compiler might optimize away stores to and
452 reads from such locations that occur in the program, depending on its
453 data flow analysis. For example, when the program contains a loop
454 that is intended to inspect a variable set from within a signal handler
455 while (!signal_occurred)
456 ;
457 the compiler is allowed to transform this into an endless loop if the
458 variable 'signal_occurred' is not declared 'volatile'.
459 Additionally, recall that:
460 * A signal handler should not modify errno (except if it is a handler
461 for a fatal signal and ends by raising the same signal again, thus
462 provoking the termination of the process). If it invokes a function
463 that may clobber errno, it needs to save and restore the value of
464 errno. */
465#define _GL_ASYNC_SAFE
466])
467 AH_VERBATIM([micro_optimizations],
468[/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
469 n1 and n2 are expressions without side effects, that evaluate to real
470 numbers (excluding NaN).
471 It returns
472 1 if n1 > n2
473 0 if n1 == n2
474 -1 if n1 < n2
475 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
476 jump with nearly all GCC versions up to GCC 10.
477 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many
478 GCC versions up to GCC 9.
479 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
480 avoids conditional jumps in all GCC versions >= 3.4. */
481#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
482])
483 dnl Hint which direction to take regarding cross-compilation guesses:
484 dnl When a user installs a program on a platform they are not intimately
485 dnl familiar with, --enable-cross-guesses=conservative is the appropriate
486 dnl choice. It implements the "If we don't know, assume the worst" principle.
487 dnl However, when an operating system developer (on a platform which is not
488 dnl yet known to gnulib) builds packages for their platform, they want to
489 dnl expose, not hide, possible platform bugs; in this case,
490 dnl --enable-cross-guesses=risky is the appropriate choice.
491 dnl Sets the variables
492 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
493 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
494 AC_ARG_ENABLE([cross-guesses],
495 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
496 [specify policy for cross-compilation guesses])],
497 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
498 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
499 enableval=conservative
500 fi
501 gl_cross_guesses="$enableval"],
502 [gl_cross_guesses=conservative])
503 if test $gl_cross_guesses = risky; then
504 gl_cross_guess_normal="guessing yes"
505 gl_cross_guess_inverted="guessing no"
506 else
507 gl_cross_guess_normal="guessing no"
508 gl_cross_guess_inverted="guessing yes"
509 fi
510 dnl Preparation for running test programs:
511 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
512 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
513 dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
514 LIBC_FATAL_STDERR_=1
515 export LIBC_FATAL_STDERR_
516])
517
518# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename])
519# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue])
520# initializes the shell variable that indicates the presence of the given module
521# as a C preprocessor expression.
522AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE],
523[
524 GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2])
525 AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1])
526])
527
528# gl_MODULE_INDICATOR_CONDITION
529# expands to a C preprocessor expression that evaluates to 1 or 0, depending
530# whether a gnulib module that has been requested shall be considered present
531# or not.
532m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
533
534# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
535# sets the shell variable that indicates the presence of the given module to
536# a C preprocessor expression that will evaluate to 1.
537AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
538[
539 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
540 [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]],
541 [abcdefghijklmnopqrstuvwxyz./-],
542 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
543 [gl_MODULE_INDICATOR_CONDITION])
544])
545
546# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
547# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
548# The shell variable's value is a C preprocessor expression that evaluates
549# to 0 or 1.
550AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
551[
552 m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
553 [
554 dnl Simplify the expression VALUE || 1 to 1.
555 $1=1
556 ],
557 [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
558 [gl_MODULE_INDICATOR_CONDITION])])
559])
560
561# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
562# modifies the shell variable to include the given condition. The shell
563# variable's value is a C preprocessor expression that evaluates to 0 or 1.
564AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
565[
566 dnl Simplify the expression 1 || CONDITION to 1.
567 if test "$[]$1" != 1; then
568 dnl Simplify the expression 0 || CONDITION to CONDITION.
569 if test "$[]$1" = 0; then
570 $1=$2
571 else
572 $1="($[]$1 || $2)"
573 fi
574 fi
575])
576
577# gl_MODULE_INDICATOR([modulename])
578# defines a C macro indicating the presence of the given module
579# in a location where it can be used.
580# | Value | Value |
581# | in lib/ | in tests/ |
582# --------------------------------------------+---------+-----------+
583# Module present among main modules: | 1 | 1 |
584# --------------------------------------------+---------+-----------+
585# Module present among tests-related modules: | 0 | 1 |
586# --------------------------------------------+---------+-----------+
587# Module not present at all: | 0 | 0 |
588# --------------------------------------------+---------+-----------+
589AC_DEFUN([gl_MODULE_INDICATOR],
590[
591 AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
592 [abcdefghijklmnopqrstuvwxyz./-],
593 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
594 [gl_MODULE_INDICATOR_CONDITION],
595 [Define to a C preprocessor expression that evaluates to 1 or 0,
596 depending whether the gnulib module $1 shall be considered present.])
597])
598
599# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
600# defines a C macro indicating the presence of the given module
601# in lib or tests. This is useful to determine whether the module
602# should be tested.
603# | Value | Value |
604# | in lib/ | in tests/ |
605# --------------------------------------------+---------+-----------+
606# Module present among main modules: | 1 | 1 |
607# --------------------------------------------+---------+-----------+
608# Module present among tests-related modules: | 1 | 1 |
609# --------------------------------------------+---------+-----------+
610# Module not present at all: | 0 | 0 |
611# --------------------------------------------+---------+-----------+
612AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
613[
614 AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
615 [abcdefghijklmnopqrstuvwxyz./-],
616 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
617 [Define to 1 when the gnulib module $1 should be tested.])
618])
619
620# gl_ASSERT_NO_GNULIB_POSIXCHECK
621# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
622# and thereby enables an optimization of configure and config.h.
623# Used by Emacs.
624AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
625[
626 dnl Override gl_WARN_ON_USE_PREPARE.
627 dnl But hide this definition from 'aclocal'.
628 AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
629])
630
631# gl_ASSERT_NO_GNULIB_TESTS
632# asserts that there will be no gnulib tests in the scope of the configure.ac
633# and thereby enables an optimization of config.h.
634# Used by Emacs.
635AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
636[
637 dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
638 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
639])
640
641# Test whether <features.h> exists.
642# Set HAVE_FEATURES_H.
643AC_DEFUN([gl_FEATURES_H],
644[
645 AC_CHECK_HEADERS_ONCE([features.h])
646 if test $ac_cv_header_features_h = yes; then
647 HAVE_FEATURES_H=1
648 else
649 HAVE_FEATURES_H=0
650 fi
651 AC_SUBST([HAVE_FEATURES_H])
652])
653
654# gl_PROG_CC_C99
655# Modifies the value of the shell variable CC in an attempt to make $CC
656# understand ISO C99 source code.
657AC_DEFUN([gl_PROG_CC_C99],
658[
659 dnl Just use AC_PROG_CC_C99.
660 dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
661 dnl value of CC will contain the C99 enabling options twice. But this is only
662 dnl a cosmetic problem.
663 dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
664 dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
665 m4_version_prereq([2.70],
666 [AC_REQUIRE([AC_PROG_CC])],
667 [AC_REQUIRE([AC_PROG_CC_C99])])
668])
669
670# gl_PROG_AR_RANLIB
671# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
672# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
673# the values.
674AC_DEFUN([gl_PROG_AR_RANLIB],
675[
676 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
677 dnl as "cc", and GCC as "gcc". They have different object file formats and
678 dnl library formats. In particular, the GNU binutils programs ar and ranlib
679 dnl produce libraries that work only with gcc, not with cc.
680 AC_REQUIRE([AC_PROG_CC])
681 dnl The '][' hides this use from 'aclocal'.
682 AC_BEFORE([$0], [A][M_PROG_AR])
683 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
684 [
685 AC_EGREP_CPP([Amsterdam],
686 [
687#ifdef __ACK__
688Amsterdam
689#endif
690 ],
691 [gl_cv_c_amsterdam_compiler=yes],
692 [gl_cv_c_amsterdam_compiler=no])
693 ])
694
695 dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
696 dnl building with __ACK__.
697 if test $gl_cv_c_amsterdam_compiler = yes; then
698 if test -z "$AR"; then
699 AR='cc -c.a'
700 fi
701 if test -z "$ARFLAGS"; then
702 ARFLAGS='-o'
703 fi
704 else
705 dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
706 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
707 dnl script on-demand, if not specified by ./configure of course).
708 dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
709 dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
710 dnl because AM_PROG_AR is written so it could re-set AR variable even for
711 dnl __ACK__. It may seem like its easier to avoid calling the macro here,
712 dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
713 dnl default value and automake should usually know them).
714 dnl
715 dnl The '][' hides this use from 'aclocal'.
716 m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
717 fi
718
719 dnl In case the code above has not helped with setting AR/ARFLAGS, use
720 dnl Automake-documented default values for AR and ARFLAGS, but prefer
721 dnl ${host}-ar over ar (useful for cross-compiling).
722 AC_CHECK_TOOL([AR], [ar], [ar])
723 if test -z "$ARFLAGS"; then
724 ARFLAGS='cr'
725 fi
726
727 AC_SUBST([AR])
728 AC_SUBST([ARFLAGS])
729 if test -z "$RANLIB"; then
730 if test $gl_cv_c_amsterdam_compiler = yes; then
731 RANLIB=':'
732 else
733 dnl Use the ranlib program if it is available.
734 AC_PROG_RANLIB
735 fi
736 fi
737 AC_SUBST([RANLIB])
738])
739
740# AC_C_RESTRICT
741# This definition is copied from post-2.70 Autoconf and overrides the
742# AC_C_RESTRICT macro from autoconf 2.60..2.70.
743m4_version_prereq([2.70.1], [], [
744AC_DEFUN([AC_C_RESTRICT],
745[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
746 [ac_cv_c_restrict=no
747 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
748 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
749 # Put 'restrict' last, because C++ lacks it.
750 for ac_kw in __restrict__ __restrict _Restrict restrict; do
751 AC_COMPILE_IFELSE(
752 [AC_LANG_PROGRAM(
753 [[typedef int *int_ptr;
754 int foo (int_ptr $ac_kw ip) { return ip[0]; }
755 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
756 int bar (int ip[$ac_kw]) { return ip[0]; }
757 ]],
758 [[int s[1];
759 int *$ac_kw t = s;
760 t[0] = 0;
761 return foo (t) + bar (t);
762 ]])],
763 [ac_cv_c_restrict=$ac_kw])
764 test "$ac_cv_c_restrict" != no && break
765 done
766 ])
767 AH_VERBATIM([restrict],
768[/* Define to the equivalent of the C99 'restrict' keyword, or to
769 nothing if this is not supported. Do not define if restrict is
770 supported only directly. */
771#undef restrict
772/* Work around a bug in older versions of Sun C++, which did not
773 #define __restrict__ or support _Restrict or __restrict__
774 even though the corresponding Sun C compiler ended up with
775 "#define restrict _Restrict" or "#define restrict __restrict__"
776 in the previous line. This workaround can be removed once
777 we assume Oracle Developer Studio 12.5 (2016) or later. */
778#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
779# define _Restrict
780# define __restrict__
781#endif])
782 case $ac_cv_c_restrict in
783 restrict) ;;
784 no) AC_DEFINE([restrict], []) ;;
785 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
786 esac
787])# AC_C_RESTRICT
788])
789
790# gl_BIGENDIAN
791# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
792# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
793# macros invoke AC_C_BIGENDIAN with arguments.
794AC_DEFUN([gl_BIGENDIAN],
795[
796 AC_C_BIGENDIAN
797])
798
799# A temporary file descriptor.
800# Must be less than 10, because dash 0.5.8 does not support redirections
801# with multi-digit file descriptors.
802m4_define([GL_TMP_FD], 9)
803
804# gl_SILENT(command)
805# executes command, but without the normal configure output.
806# This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
807# inside another AC_CACHE_CHECK.
808AC_DEFUN([gl_SILENT],
809[
810 exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
811 $1
812 exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
813])
814
815# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
816# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
817# output a spurious "(cached)" mark in the midst of other configure output.
818# This macro should be used instead of AC_CACHE_VAL when it is not surrounded
819# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
820AC_DEFUN([gl_CACHE_VAL_SILENT],
821[
822 gl_SILENT([
823 AC_CACHE_VAL([$1], [$2])
824 ])
825])
826
827# gl_CONDITIONAL(conditional, condition)
828# is like AM_CONDITIONAL(conditional, condition), except that it does not
829# produce an error
830# configure: error: conditional "..." was never defined.
831# Usually this means the macro was only invoked conditionally.
832# when only invoked conditionally. Instead, in that case, both the _TRUE
833# and the _FALSE case are disabled.
834AC_DEFUN([gl_CONDITIONAL],
835[
836 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
837 AM_CONDITIONAL([$1], [$2])
838 popdef([AC_CONFIG_COMMANDS_PRE])dnl
839 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
840 [$1]_TRUE='#'
841 [$1]_FALSE='#'
842 fi
843])
844
845# gl_CC_ALLOW_WARNINGS
846# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
847# that reverts a preceding '-Werror' option, if available.
848# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
849# and empty otherwise.
850AC_DEFUN([gl_CC_ALLOW_WARNINGS],
851[
852 AC_REQUIRE([AC_PROG_CC])
853 AC_CACHE_CHECK([for C compiler option to allow warnings],
854 [gl_cv_cc_wallow],
855 [rm -f conftest*
856 echo 'int dummy;' > conftest.c
857 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
858 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
859 dnl Test the number of error output lines, because AIX xlc accepts the
860 dnl option '-Wno-error', just to produce a warning
861 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
862 dnl afterwards.
863 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
864 gl_cv_cc_wallow='-Wno-error'
865 else
866 gl_cv_cc_wallow=none
867 fi
868 rm -f conftest*
869 ])
870 case "$gl_cv_cc_wallow" in
871 none) GL_CFLAG_ALLOW_WARNINGS='' ;;
872 *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
873 esac
874 AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
875])
876
877# gl_CXX_ALLOW_WARNINGS
878# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
879# that reverts a preceding '-Werror' option, if available.
880AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
881[
882 dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
883 if test -n "$CXX" && test "$CXX" != no; then
884 AC_CACHE_CHECK([for C++ compiler option to allow warnings],
885 [gl_cv_cxx_wallow],
886 [rm -f conftest*
887 echo 'int dummy;' > conftest.cc
888 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
889 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
890 dnl Test the number of error output lines, because AIX xlC accepts the
891 dnl option '-Wno-error', just to produce a warning
892 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
893 dnl afterwards.
894 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
895 gl_cv_cxx_wallow='-Wno-error'
896 else
897 gl_cv_cxx_wallow=none
898 fi
899 rm -f conftest*
900 ])
901 case "$gl_cv_cxx_wallow" in
902 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
903 *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
904 esac
905 else
906 GL_CXXFLAG_ALLOW_WARNINGS=''
907 fi
908 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
909])
910
911# gl_CC_GNULIB_WARNINGS
912# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
913# set that enables or disables warnings as suitable for the Gnulib coding style.
914AC_DEFUN([gl_CC_GNULIB_WARNINGS],
915[
916 AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
917 dnl Assume that the compiler supports -Wno-* options only if it also supports
918 dnl -Wno-error.
919 GL_CFLAG_GNULIB_WARNINGS=''
920 if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
921 dnl Enable these warning options:
922 dnl
923 dnl GCC clang
924 dnl -Wno-cast-qual >= 3 >= 3.9
925 dnl -Wno-conversion >= 3 >= 3.9
926 dnl -Wno-float-conversion >= 4.9 >= 3.9
927 dnl -Wno-float-equal >= 3 >= 3.9
928 dnl -Wimplicit-fallthrough >= 7 >= 3.9
929 dnl -Wno-pedantic >= 4.8 >= 3.9
930 dnl -Wno-sign-compare >= 3 >= 3.9
931 dnl -Wno-sign-conversion >= 4.3 >= 3.9
932 dnl -Wno-type-limits >= 4.3 >= 3.9
933 dnl -Wno-undef >= 3 >= 3.9
934 dnl -Wno-unsuffixed-float-constants >= 4.5
935 dnl -Wno-unused-function >= 3 >= 3.9
936 dnl -Wno-unused-parameter >= 3 >= 3.9
937 dnl
938 cat > conftest.c <<\EOF
939 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
940 -Wno-cast-qual
941 -Wno-conversion
942 -Wno-float-equal
943 -Wno-sign-compare
944 -Wno-undef
945 -Wno-unused-function
946 -Wno-unused-parameter
947 #endif
948 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
949 -Wno-float-conversion
950 #endif
951 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
952 -Wimplicit-fallthrough
953 #endif
954 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
955 -Wno-pedantic
956 #endif
957 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
958 -Wno-sign-conversion
959 -Wno-type-limits
960 #endif
961 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
962 -Wno-unsuffixed-float-constants
963 #endif
964EOF
965 gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
966 if AC_TRY_EVAL([gl_command]); then
967 gl_options=`grep -v '#' conftest.out`
968 for word in $gl_options; do
969 GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
970 done
971 fi
972 rm -f conftest.c conftest.out
973 fi
974 AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
975])
976
977dnl gl_CONDITIONAL_HEADER([foo.h])
978dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
979dnl and produces
980dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
981dnl on whether GL_GENERATE_FOO_H is true or false,
982dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
983dnl the shell variable GL_GENERATE_FOO_H.
984AC_DEFUN([gl_CONDITIONAL_HEADER],
985[
986 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
987 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
988 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
989 case "$gl_generate_var" in
990 false) gl_header_name='' ;;
991 true)
992 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
993 dnl versa.
994 if test -z "$gl_header_name"; then
995 gl_header_name="${gl_source_base_prefix}$1"
996 fi
997 ;;
998 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
999 esac
1000 AC_SUBST(gl_header_name)
1001 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
1002 m4_popdef([gl_generate_cond])
1003 m4_popdef([gl_generate_var])
1004 m4_popdef([gl_header_name])
1005])
1006
1007dnl Expands to some code for use in .c programs that, on native Windows, defines
1008dnl the Microsoft deprecated alias function names to the underscore-prefixed
1009dnl actual function names. With this macro, these function names are available
1010dnl without linking with '-loldnames' and without generating warnings.
1011dnl Usage: Use it after all system header files are included.
1012dnl #include <...>
1013dnl #include <...>
1014dnl ]GL_MDA_DEFINES[
1015dnl ...
1016AC_DEFUN([GL_MDA_DEFINES],[
1017AC_REQUIRE([_GL_MDA_DEFINES])
1018[$gl_mda_defines]
1019])
1020AC_DEFUN([_GL_MDA_DEFINES],
1021[gl_mda_defines='
1022#if defined _WIN32 && !defined __CYGWIN__
1023#define access _access
1024#define chdir _chdir
1025#define chmod _chmod
1026#define close _close
1027#define creat _creat
1028#define dup _dup
1029#define dup2 _dup2
1030#define ecvt _ecvt
1031#define execl _execl
1032#define execle _execle
1033#define execlp _execlp
1034#define execv _execv
1035#define execve _execve
1036#define execvp _execvp
1037#define execvpe _execvpe
1038#define fcloseall _fcloseall
1039#define fcvt _fcvt
1040#define fdopen _fdopen
1041#define fileno _fileno
1042#define gcvt _gcvt
1043#define getcwd _getcwd
1044#define getpid _getpid
1045#define getw _getw
1046#define isatty _isatty
1047#define j0 _j0
1048#define j1 _j1
1049#define jn _jn
1050#define lfind _lfind
1051#define lsearch _lsearch
1052#define lseek _lseek
1053#define memccpy _memccpy
1054#define mkdir _mkdir
1055#define mktemp _mktemp
1056#define open _open
1057#define putenv _putenv
1058#define putw _putw
1059#define read _read
1060#define rmdir _rmdir
1061#define strdup _strdup
1062#define swab _swab
1063#define tempnam _tempnam
1064#define tzset _tzset
1065#define umask _umask
1066#define unlink _unlink
1067#define utime _utime
1068#define wcsdup _wcsdup
1069#define write _write
1070#define y0 _y0
1071#define y1 _y1
1072#define yn _yn
1073#endif
1074'
1075])
diff --git a/m4/gnulib-tool.m4 b/m4/gnulib-tool.m4
new file mode 100644
index 00000000..8428901c
--- /dev/null
+++ b/m4/gnulib-tool.m4
@@ -0,0 +1,63 @@
1# gnulib-tool.m4 serial 4
2dnl Copyright (C) 2004-2005, 2009-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl The following macros need not be invoked explicitly.
8dnl Invoking them does nothing except to declare default arguments
9dnl for "gnulib-tool --import".
10
11dnl Usage: gl_LOCAL_DIR([DIR])
12AC_DEFUN([gl_LOCAL_DIR], [])
13
14dnl Usage: gl_MODULES([module1 module2 ...])
15AC_DEFUN([gl_MODULES], [])
16
17dnl Usage: gl_AVOID([module1 module2 ...])
18AC_DEFUN([gl_AVOID], [])
19
20dnl Usage: gl_SOURCE_BASE([DIR])
21AC_DEFUN([gl_SOURCE_BASE], [])
22
23dnl Usage: gl_M4_BASE([DIR])
24AC_DEFUN([gl_M4_BASE], [])
25
26dnl Usage: gl_PO_BASE([DIR])
27AC_DEFUN([gl_PO_BASE], [])
28
29dnl Usage: gl_DOC_BASE([DIR])
30AC_DEFUN([gl_DOC_BASE], [])
31
32dnl Usage: gl_TESTS_BASE([DIR])
33AC_DEFUN([gl_TESTS_BASE], [])
34
35dnl Usage: gl_WITH_TESTS
36AC_DEFUN([gl_WITH_TESTS], [])
37
38dnl Usage: gl_LIB([LIBNAME])
39AC_DEFUN([gl_LIB], [])
40
41dnl Usage: gl_LGPL or gl_LGPL([VERSION])
42AC_DEFUN([gl_LGPL], [])
43
44dnl Usage: gl_MAKEFILE_NAME([FILENAME])
45AC_DEFUN([gl_MAKEFILE_NAME], [])
46
47dnl Usage: gl_TESTS_MAKEFILE_NAME([FILENAME])
48AC_DEFUN([gl_TESTS_MAKEFILE_NAME], [])
49
50dnl Usage: gl_AUTOMAKE_SUBDIR
51AC_DEFUN([gl_AUTOMAKE_SUBDIR], [])
52
53dnl Usage: gl_LIBTOOL
54AC_DEFUN([gl_LIBTOOL], [])
55
56dnl Usage: gl_MACRO_PREFIX([PREFIX])
57AC_DEFUN([gl_MACRO_PREFIX], [])
58
59dnl Usage: gl_PO_DOMAIN([DOMAIN])
60AC_DEFUN([gl_PO_DOMAIN], [])
61
62dnl Usage: gl_VC_FILES([BOOLEAN])
63AC_DEFUN([gl_VC_FILES], [])
diff --git a/m4/zzgnulib.m4 b/m4/zzgnulib.m4
new file mode 100644
index 00000000..fd73a201
--- /dev/null
+++ b/m4/zzgnulib.m4
@@ -0,0 +1,23 @@
1# zzgnulib.m4 serial 1
2dnl Copyright (C) 2020-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl This file must be named something that sorts after all other
8dnl package- or gnulib-provided .m4 files - at least for those packages
9dnl that redefine AC_PROG_CC.
10
11dnl Redefine AC_PROG_CC so that it ends with invocations of gl_COMPILER_CLANG
12dnl and gl_COMPILER_PREPARE_CHECK_DECL.
13m4_define([AC_PROG_CC],
14 m4_defn([AC_PROG_CC])[
15gl_COMPILER_CLANG
16gl_COMPILER_PREPARE_CHECK_DECL
17])
18
19# gl_ZZGNULIB
20# -----------
21# Witness macro that this file has been included. Needed to force
22# Automake to include this file after all other gnulib .m4 files.
23AC_DEFUN([gl_ZZGNULIB])