aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/00gnulib.m430
-rw-r--r--m4/Makefile.am1
-rw-r--r--m4/extensions.m4118
-rw-r--r--m4/gnulib-cache.m435
-rw-r--r--m4/gnulib-common.m4234
-rw-r--r--m4/gnulib-comp.m4219
-rw-r--r--m4/gnulib-tool.m457
-rw-r--r--m4/include_next.m4244
-rw-r--r--m4/stddef_h.m445
-rw-r--r--m4/string_h.m4115
-rw-r--r--m4/strtok_r.m474
-rw-r--r--m4/warn-on-use.m445
-rw-r--r--m4/wchar_t.m418
13 files changed, 1228 insertions, 7 deletions
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4
new file mode 100644
index 000000000..7feed4669
--- /dev/null
+++ b/m4/00gnulib.m4
@@ -0,0 +1,30 @@
1# 00gnulib.m4 serial 2
2dnl Copyright (C) 2009-2011 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 such time as we can
9dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics.
10
11# AC_DEFUN_ONCE([NAME], VALUE)
12# ----------------------------
13# Define NAME to expand to VALUE on the first use (whether by direct
14# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses.
15# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This
16# definition is slower than the version in Autoconf 2.64, because it
17# can only use interfaces that existed since 2.59; but it achieves the
18# same effect. Quoting is necessary to avoid confusing Automake.
19m4_version_prereq([2.63.263], [],
20[m4_define([AC][_DEFUN_ONCE],
21 [AC][_DEFUN([$1],
22 [AC_REQUIRE([_gl_DEFUN_ONCE([$1])],
23 [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl
24[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])])
25
26# gl_00GNULIB
27# -----------
28# Witness macro that this file has been included. Needed to force
29# Automake to include this file prior to all other gnulib .m4 files.
30AC_DEFUN([gl_00GNULIB])
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 3afad7e81..7b44b8e69 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -5,6 +5,7 @@ gettext.m4\
5glib-2.0.m4\ 5glib-2.0.m4\
6glibc21.m4\ 6glibc21.m4\
7glib-gettext.m4\ 7glib-gettext.m4\
8gnulib-cache.m4\
8gtk-2.0.m4\ 9gtk-2.0.m4\
9iconv.m4\ 10iconv.m4\
10intdiv0.m4\ 11intdiv0.m4\
diff --git a/m4/extensions.m4 b/m4/extensions.m4
new file mode 100644
index 000000000..1330503f0
--- /dev/null
+++ b/m4/extensions.m4
@@ -0,0 +1,118 @@
1# serial 9 -*- Autoconf -*-
2# Enable extensions on systems that normally disable them.
3
4# Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
10# Autoconf. Perhaps we can remove this once we can assume Autoconf
11# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
12# enough in this area it's likely we'll need to redefine
13# AC_USE_SYSTEM_EXTENSIONS for quite some time.
14
15# If autoconf reports a warning
16# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
17# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
18# the fix is
19# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
20# but always AC_REQUIREd,
21# 2) to ensure that for each occurrence of
22# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
23# or
24# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
25# the corresponding gnulib module description has 'extensions' among
26# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
27# invocation occurs in gl_EARLY, not in gl_INIT.
28
29# AC_USE_SYSTEM_EXTENSIONS
30# ------------------------
31# Enable extensions on systems that normally disable them,
32# typically due to standards-conformance issues.
33# Remember that #undef in AH_VERBATIM gets replaced with #define by
34# AC_DEFINE. The goal here is to define all known feature-enabling
35# macros, then, if reports of conflicts are made, disable macros that
36# cause problems on some platforms (such as __EXTENSIONS__).
37AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
38[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
39AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
40
41 AC_REQUIRE([AC_CANONICAL_HOST])
42
43 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
44 if test "$MINIX" = yes; then
45 AC_DEFINE([_POSIX_SOURCE], [1],
46 [Define to 1 if you need to in order for `stat' and other
47 things to work.])
48 AC_DEFINE([_POSIX_1_SOURCE], [2],
49 [Define to 2 if the system does not provide POSIX.1 features
50 except with this defined.])
51 AC_DEFINE([_MINIX], [1],
52 [Define to 1 if on MINIX.])
53 fi
54
55 dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
56 dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
57 dnl provided.
58 case "$host_os" in
59 hpux*)
60 AC_DEFINE([_XOPEN_SOURCE], [500],
61 [Define to 500 only on HP-UX.])
62 ;;
63 esac
64
65 AH_VERBATIM([__EXTENSIONS__],
66[/* Enable extensions on AIX 3, Interix. */
67#ifndef _ALL_SOURCE
68# undef _ALL_SOURCE
69#endif
70/* Enable GNU extensions on systems that have them. */
71#ifndef _GNU_SOURCE
72# undef _GNU_SOURCE
73#endif
74/* Enable threading extensions on Solaris. */
75#ifndef _POSIX_PTHREAD_SEMANTICS
76# undef _POSIX_PTHREAD_SEMANTICS
77#endif
78/* Enable extensions on HP NonStop. */
79#ifndef _TANDEM_SOURCE
80# undef _TANDEM_SOURCE
81#endif
82/* Enable general extensions on Solaris. */
83#ifndef __EXTENSIONS__
84# undef __EXTENSIONS__
85#endif
86])
87 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
88 [ac_cv_safe_to_define___extensions__],
89 [AC_COMPILE_IFELSE(
90 [AC_LANG_PROGRAM([[
91# define __EXTENSIONS__ 1
92 ]AC_INCLUDES_DEFAULT])],
93 [ac_cv_safe_to_define___extensions__=yes],
94 [ac_cv_safe_to_define___extensions__=no])])
95 test $ac_cv_safe_to_define___extensions__ = yes &&
96 AC_DEFINE([__EXTENSIONS__])
97 AC_DEFINE([_ALL_SOURCE])
98 AC_DEFINE([_GNU_SOURCE])
99 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
100 AC_DEFINE([_TANDEM_SOURCE])
101])# AC_USE_SYSTEM_EXTENSIONS
102
103# gl_USE_SYSTEM_EXTENSIONS
104# ------------------------
105# Enable extensions on systems that normally disable them,
106# typically due to standards-conformance issues.
107AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
108[
109 dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
110 dnl gnulib does not need it. But if it gets required by third-party macros
111 dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
112 dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
113 dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
114 dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
115 AC_REQUIRE([AC_GNU_SOURCE])
116
117 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
118])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
new file mode 100644
index 000000000..a9ec8f3bd
--- /dev/null
+++ b/m4/gnulib-cache.m4
@@ -0,0 +1,35 @@
1# Copyright (C) 2002-2011 Free Software Foundation, Inc.
2#
3# This file is free software, distributed under the terms of the GNU
4# General Public License. As a special exception to the GNU General
5# Public License, this file may be distributed as part of a program
6# that contains a configuration script generated by Autoconf, under
7# the same distribution terms as the rest of that program.
8#
9# Generated by gnulib-tool.
10#
11# This file represents the specification of how gnulib-tool is used.
12# It acts as a cache: It is written and read by gnulib-tool.
13# In projects that use version control, this file is meant to be put under
14# version control, like the configure.ac and various Makefile.am files.
15
16
17# Specification in the form of a command-line invocation:
18# gnulib-tool --import --dir=/home/nils/workspace/gnunet --lib=libgnu --source-base=src/util/libgnu --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --libtool --macro-prefix=gl strtok_r
19
20# Specification in the form of a few gnulib-tool.m4 macro invocations:
21gl_LOCAL_DIR([])
22gl_MODULES([
23 strtok_r
24])
25gl_AVOID([])
26gl_SOURCE_BASE([src/util/libgnu])
27gl_M4_BASE([m4])
28gl_PO_BASE([])
29gl_DOC_BASE([doc])
30gl_TESTS_BASE([tests])
31gl_LIB([libgnu])
32gl_MAKEFILE_NAME([])
33gl_LIBTOOL
34gl_MACRO_PREFIX([gl])
35gl_PO_DOMAIN([])
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
new file mode 100644
index 000000000..ecbf33694
--- /dev/null
+++ b/m4/gnulib-common.m4
@@ -0,0 +1,234 @@
1# gnulib-common.m4 serial 23
2dnl Copyright (C) 2007-2011 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
7# gl_COMMON
8# is expanded unconditionally through gnulib-tool magic.
9AC_DEFUN([gl_COMMON], [
10 dnl Use AC_REQUIRE here, so that the code is expanded once only.
11 AC_REQUIRE([gl_00GNULIB])
12 AC_REQUIRE([gl_COMMON_BODY])
13])
14AC_DEFUN([gl_COMMON_BODY], [
15 AH_VERBATIM([isoc99_inline],
16[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
17 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
18 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
19 __APPLE__ && __MACH__ test for MacOS X.
20 __APPLE_CC__ tests for the Apple compiler and its version.
21 __STDC_VERSION__ tests for the C99 mode. */
22#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
23# define __GNUC_STDC_INLINE__ 1
24#endif])
25 AH_VERBATIM([unused_parameter],
26[/* Define as a marker that can be attached to declarations that might not
27 be used. This helps to reduce warnings, such as from
28 GCC -Wunused-parameter. */
29#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
30# define _GL_UNUSED __attribute__ ((__unused__))
31#else
32# define _GL_UNUSED
33#endif
34/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
35 is a misnomer outside of parameter lists. */
36#define _UNUSED_PARAMETER_ _GL_UNUSED
37])
38 dnl Preparation for running test programs:
39 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
40 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
41 dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
42 LIBC_FATAL_STDERR_=1
43 export LIBC_FATAL_STDERR_
44])
45
46# gl_MODULE_INDICATOR_CONDITION
47# expands to a C preprocessor expression that evaluates to 1 or 0, depending
48# whether a gnulib module that has been requested shall be considered present
49# or not.
50AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1])
51
52# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
53# sets the shell variable that indicates the presence of the given module to
54# a C preprocessor expression that will evaluate to 1.
55AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
56[
57 GNULIB_[]m4_translit([[$1]],
58 [abcdefghijklmnopqrstuvwxyz./-],
59 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION
60])
61
62# gl_MODULE_INDICATOR([modulename])
63# defines a C macro indicating the presence of the given module
64# in a location where it can be used.
65# | Value | Value |
66# | in lib/ | in tests/ |
67# --------------------------------------------+---------+-----------+
68# Module present among main modules: | 1 | 1 |
69# --------------------------------------------+---------+-----------+
70# Module present among tests-related modules: | 0 | 1 |
71# --------------------------------------------+---------+-----------+
72# Module not present at all: | 0 | 0 |
73# --------------------------------------------+---------+-----------+
74AC_DEFUN([gl_MODULE_INDICATOR],
75[
76 AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
77 [abcdefghijklmnopqrstuvwxyz./-],
78 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
79 [gl_MODULE_INDICATOR_CONDITION],
80 [Define to a C preprocessor expression that evaluates to 1 or 0,
81 depending whether the gnulib module $1 shall be considered present.])
82])
83
84# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
85# defines a C macro indicating the presence of the given module
86# in lib or tests. This is useful to determine whether the module
87# should be tested.
88# | Value | Value |
89# | in lib/ | in tests/ |
90# --------------------------------------------+---------+-----------+
91# Module present among main modules: | 1 | 1 |
92# --------------------------------------------+---------+-----------+
93# Module present among tests-related modules: | 1 | 1 |
94# --------------------------------------------+---------+-----------+
95# Module not present at all: | 0 | 0 |
96# --------------------------------------------+---------+-----------+
97AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
98[
99 AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
100 [abcdefghijklmnopqrstuvwxyz./-],
101 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
102 [Define to 1 when the gnulib module $1 should be tested.])
103])
104
105# gl_ASSERT_NO_GNULIB_POSIXCHECK
106# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
107# and thereby enables an optimization of configure and config.h.
108# Used by Emacs.
109AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
110[
111 dnl Override gl_WARN_ON_USE_PREPARE.
112 AC_DEFUN([gl_WARN_ON_USE_PREPARE], [])
113])
114
115# gl_ASSERT_NO_GNULIB_TESTS
116# asserts that there will be no gnulib tests in the scope of the configure.ac
117# and thereby enables an optimization of config.h.
118# Used by Emacs.
119AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
120[
121 dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
122 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
123])
124
125# Test whether <features.h> exists.
126# Set HAVE_FEATURES_H.
127AC_DEFUN([gl_FEATURES_H],
128[
129 AC_CHECK_HEADERS_ONCE([features.h])
130 if test $ac_cv_header_features_h = yes; then
131 HAVE_FEATURES_H=1
132 else
133 HAVE_FEATURES_H=0
134 fi
135 AC_SUBST([HAVE_FEATURES_H])
136])
137
138# m4_foreach_w
139# is a backport of autoconf-2.59c's m4_foreach_w.
140# Remove this macro when we can assume autoconf >= 2.60.
141m4_ifndef([m4_foreach_w],
142 [m4_define([m4_foreach_w],
143 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
144
145# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
146# ----------------------------------------------------
147# Backport of autoconf-2.63b's macro.
148# Remove this macro when we can assume autoconf >= 2.64.
149m4_ifndef([AS_VAR_IF],
150[m4_define([AS_VAR_IF],
151[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
152
153# AC_PROG_MKDIR_P
154# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
155# for interoperability with automake-1.9.6 from autoconf-2.62.
156# Remove this macro when we can assume autoconf >= 2.62 or
157# autoconf >= 2.60 && automake >= 1.10.
158m4_ifdef([AC_PROG_MKDIR_P], [
159 dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
160 m4_define([AC_PROG_MKDIR_P],
161 m4_defn([AC_PROG_MKDIR_P])[
162 AC_SUBST([MKDIR_P])])], [
163 dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
164 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
165 [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
166 MKDIR_P='$(mkdir_p)'
167 AC_SUBST([MKDIR_P])])])
168
169# AC_C_RESTRICT
170# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61,
171# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
172# works.
173# This definition can be removed once autoconf >= 2.62 can be assumed.
174m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
175AC_DEFUN([AC_C_RESTRICT],
176[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
177 [ac_cv_c_restrict=no
178 # The order here caters to the fact that C++ does not require restrict.
179 for ac_kw in __restrict __restrict__ _Restrict restrict; do
180 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
181 [[typedef int * int_ptr;
182 int foo (int_ptr $ac_kw ip) {
183 return ip[0];
184 }]],
185 [[int s[1];
186 int * $ac_kw t = s;
187 t[0] = 0;
188 return foo(t)]])],
189 [ac_cv_c_restrict=$ac_kw])
190 test "$ac_cv_c_restrict" != no && break
191 done
192 ])
193 AH_VERBATIM([restrict],
194[/* Define to the equivalent of the C99 'restrict' keyword, or to
195 nothing if this is not supported. Do not define if restrict is
196 supported directly. */
197#undef restrict
198/* Work around a bug in Sun C++: it does not support _Restrict, even
199 though the corresponding Sun C compiler does, which causes
200 "#define restrict _Restrict" in the previous line. Perhaps some future
201 version of Sun C++ will work with _Restrict; if so, it'll probably
202 define __RESTRICT, just as Sun C does. */
203#if defined __SUNPRO_CC && !defined __RESTRICT
204# define _Restrict
205#endif])
206 case $ac_cv_c_restrict in
207 restrict) ;;
208 no) AC_DEFINE([restrict], []) ;;
209 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
210 esac
211])
212])
213
214# gl_BIGENDIAN
215# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
216# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
217# macros invoke AC_C_BIGENDIAN with arguments.
218AC_DEFUN([gl_BIGENDIAN],
219[
220 AC_C_BIGENDIAN
221])
222
223# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
224# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
225# output a spurious "(cached)" mark in the midst of other configure output.
226# This macro should be used instead of AC_CACHE_VAL when it is not surrounded
227# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
228AC_DEFUN([gl_CACHE_VAL_SILENT],
229[
230 saved_as_echo_n="$as_echo_n"
231 as_echo_n=':'
232 AC_CACHE_VAL([$1], [$2])
233 as_echo_n="$saved_as_echo_n"
234])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
new file mode 100644
index 000000000..eea83a226
--- /dev/null
+++ b/m4/gnulib-comp.m4
@@ -0,0 +1,219 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2002-2011 Free Software Foundation, Inc.
3#
4# This file is free software, distributed under the terms of the GNU
5# General Public License. As a special exception to the GNU General
6# Public License, this file may be distributed as part of a program
7# that contains a configuration script generated by Autoconf, under
8# the same distribution terms as the rest of that program.
9#
10# Generated by gnulib-tool.
11#
12# This file represents the compiled summary of the specification in
13# gnulib-cache.m4. It lists the computed macro invocations that need
14# to be invoked from configure.ac.
15# In projects that use version control, this file can be treated like
16# other built files.
17
18
19# This macro should be invoked from /home/nils/workspace/gnunet/configure.ac, in the section
20# "Checks for programs", right after AC_PROG_CC, and certainly before
21# any checks for libraries, header files, types and library functions.
22AC_DEFUN([gl_EARLY],
23[
24 m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
25 m4_pattern_allow([^gl_ES$])dnl a valid locale name
26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
28 AC_REQUIRE([AC_PROG_RANLIB])
29 # Code from module arg-nonnull:
30 # Code from module c++defs:
31 # Code from module extensions:
32 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
33 # Code from module include_next:
34 # Code from module stddef:
35 # Code from module string:
36 # Code from module strtok_r:
37 # Code from module warn-on-use:
38])
39
40# This macro should be invoked from /home/nils/workspace/gnunet/configure.ac, in the section
41# "Check for header files, types and library functions".
42AC_DEFUN([gl_INIT],
43[
44 AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
45 gl_cond_libtool=true
46 gl_m4_base='m4'
47 m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
48 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
49 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
50 m4_pushdef([gl_LIBSOURCES_LIST], [])
51 m4_pushdef([gl_LIBSOURCES_DIR], [])
52 gl_COMMON
53 gl_source_base='src/util/libgnu'
54 # Code from module arg-nonnull:
55 # Code from module c++defs:
56 # Code from module extensions:
57 # Code from module include_next:
58 # Code from module stddef:
59 gl_STDDEF_H
60 # Code from module string:
61 gl_HEADER_STRING_H
62 # Code from module strtok_r:
63 gl_FUNC_STRTOK_R
64 gl_STRING_MODULE_INDICATOR([strtok_r])
65 # Code from module warn-on-use:
66 # Code from module dummy:
67 # End of code from modules
68 m4_ifval(gl_LIBSOURCES_LIST, [
69 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
70 for gl_file in ]gl_LIBSOURCES_LIST[ ; do
71 if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then
72 echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2
73 exit 1
74 fi
75 done])dnl
76 m4_if(m4_sysval, [0], [],
77 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
78 ])
79 m4_popdef([gl_LIBSOURCES_DIR])
80 m4_popdef([gl_LIBSOURCES_LIST])
81 m4_popdef([AC_LIBSOURCES])
82 m4_popdef([AC_REPLACE_FUNCS])
83 m4_popdef([AC_LIBOBJ])
84 AC_CONFIG_COMMANDS_PRE([
85 gl_libobjs=
86 gl_ltlibobjs=
87 if test -n "$gl_LIBOBJS"; then
88 # Remove the extension.
89 sed_drop_objext='s/\.o$//;s/\.obj$//'
90 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
91 gl_libobjs="$gl_libobjs $i.$ac_objext"
92 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
93 done
94 fi
95 AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
96 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
97 ])
98 gltests_libdeps=
99 gltests_ltlibdeps=
100 m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ]))
101 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS]))
102 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
103 m4_pushdef([gltests_LIBSOURCES_LIST], [])
104 m4_pushdef([gltests_LIBSOURCES_DIR], [])
105 gl_COMMON
106 gl_source_base='tests'
107changequote(,)dnl
108 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
109changequote([, ])dnl
110 AC_SUBST([gltests_WITNESS])
111 gl_module_indicator_condition=$gltests_WITNESS
112 m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
113 m4_popdef([gl_MODULE_INDICATOR_CONDITION])
114 m4_ifval(gltests_LIBSOURCES_LIST, [
115 m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
116 for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
117 if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then
118 echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2
119 exit 1
120 fi
121 done])dnl
122 m4_if(m4_sysval, [0], [],
123 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
124 ])
125 m4_popdef([gltests_LIBSOURCES_DIR])
126 m4_popdef([gltests_LIBSOURCES_LIST])
127 m4_popdef([AC_LIBSOURCES])
128 m4_popdef([AC_REPLACE_FUNCS])
129 m4_popdef([AC_LIBOBJ])
130 AC_CONFIG_COMMANDS_PRE([
131 gltests_libobjs=
132 gltests_ltlibobjs=
133 if test -n "$gltests_LIBOBJS"; then
134 # Remove the extension.
135 sed_drop_objext='s/\.o$//;s/\.obj$//'
136 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
137 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
138 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
139 done
140 fi
141 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
142 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
143 ])
144])
145
146# Like AC_LIBOBJ, except that the module name goes
147# into gl_LIBOBJS instead of into LIBOBJS.
148AC_DEFUN([gl_LIBOBJ], [
149 AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl
150 gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext"
151])
152
153# Like AC_REPLACE_FUNCS, except that the module name goes
154# into gl_LIBOBJS instead of into LIBOBJS.
155AC_DEFUN([gl_REPLACE_FUNCS], [
156 m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
157 AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)])
158])
159
160# Like AC_LIBSOURCES, except the directory where the source file is
161# expected is derived from the gnulib-tool parameterization,
162# and alloca is special cased (for the alloca-opt module).
163# We could also entirely rely on EXTRA_lib..._SOURCES.
164AC_DEFUN([gl_LIBSOURCES], [
165 m4_foreach([_gl_NAME], [$1], [
166 m4_if(_gl_NAME, [alloca.c], [], [
167 m4_define([gl_LIBSOURCES_DIR], [src/util/libgnu])
168 m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ])
169 ])
170 ])
171])
172
173# Like AC_LIBOBJ, except that the module name goes
174# into gltests_LIBOBJS instead of into LIBOBJS.
175AC_DEFUN([gltests_LIBOBJ], [
176 AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl
177 gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext"
178])
179
180# Like AC_REPLACE_FUNCS, except that the module name goes
181# into gltests_LIBOBJS instead of into LIBOBJS.
182AC_DEFUN([gltests_REPLACE_FUNCS], [
183 m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
184 AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)])
185])
186
187# Like AC_LIBSOURCES, except the directory where the source file is
188# expected is derived from the gnulib-tool parameterization,
189# and alloca is special cased (for the alloca-opt module).
190# We could also entirely rely on EXTRA_lib..._SOURCES.
191AC_DEFUN([gltests_LIBSOURCES], [
192 m4_foreach([_gl_NAME], [$1], [
193 m4_if(_gl_NAME, [alloca.c], [], [
194 m4_define([gltests_LIBSOURCES_DIR], [tests])
195 m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ])
196 ])
197 ])
198])
199
200# This macro records the list of files which have been installed by
201# gnulib-tool and may be removed by future gnulib-tool invocations.
202AC_DEFUN([gl_FILE_LIST], [
203 build-aux/arg-nonnull.h
204 build-aux/c++defs.h
205 build-aux/warn-on-use.h
206 lib/dummy.c
207 lib/stddef.in.h
208 lib/string.in.h
209 lib/strtok_r.c
210 m4/00gnulib.m4
211 m4/extensions.m4
212 m4/gnulib-common.m4
213 m4/include_next.m4
214 m4/stddef_h.m4
215 m4/string_h.m4
216 m4/strtok_r.m4
217 m4/warn-on-use.m4
218 m4/wchar_t.m4
219])
diff --git a/m4/gnulib-tool.m4 b/m4/gnulib-tool.m4
new file mode 100644
index 000000000..ed41e9d41
--- /dev/null
+++ b/m4/gnulib-tool.m4
@@ -0,0 +1,57 @@
1# gnulib-tool.m4 serial 2
2dnl Copyright (C) 2004-2005, 2009-2011 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_LIBTOOL
48AC_DEFUN([gl_LIBTOOL], [])
49
50dnl Usage: gl_MACRO_PREFIX([PREFIX])
51AC_DEFUN([gl_MACRO_PREFIX], [])
52
53dnl Usage: gl_PO_DOMAIN([DOMAIN])
54AC_DEFUN([gl_PO_DOMAIN], [])
55
56dnl Usage: gl_VC_FILES([BOOLEAN])
57AC_DEFUN([gl_VC_FILES], [])
diff --git a/m4/include_next.m4 b/m4/include_next.m4
new file mode 100644
index 000000000..b3c784918
--- /dev/null
+++ b/m4/include_next.m4
@@ -0,0 +1,244 @@
1# include_next.m4 serial 18
2dnl Copyright (C) 2006-2011 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 From Paul Eggert and Derek Price.
8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
10dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise.
13dnl
14dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
15dnl supports it in the special case that it is the first include directive in
16dnl the given file, or to 'include' otherwise.
17dnl
18dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
19dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
20dnl '#pragma GCC system_header' has the same effect as if the file was found
21dnl through the include search path specified with '-isystem' options (as
22dnl opposed to the search path specified with '-I' options). Namely, gcc
23dnl does not warn about some things, and on some systems (Solaris and Interix)
24dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
25dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
26dnl of plain '__STDC__'.
27dnl
28dnl PRAGMA_COLUMNS can be used in files that override system header files, so
29dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
30dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
31dnl has the effect of truncating the lines of that file and all files that it
32dnl includes to 80 columns) and the gnulib file has lines longer than 80
33dnl columns.
34
35AC_DEFUN([gl_INCLUDE_NEXT],
36[
37 AC_LANG_PREPROC_REQUIRE()
38 AC_CACHE_CHECK([whether the preprocessor supports include_next],
39 [gl_cv_have_include_next],
40 [rm -rf conftestd1a conftestd1b conftestd2
41 mkdir conftestd1a conftestd1b conftestd2
42 dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
43 dnl AIX 6.1 support include_next when used as first preprocessor directive
44 dnl in a file, but not when preceded by another include directive. Check
45 dnl for this bug by including <stdio.h>.
46 dnl Additionally, with this same compiler, include_next is a no-op when
47 dnl used in a header file that was included by specifying its absolute
48 dnl file name. Despite these two bugs, include_next is used in the
49 dnl compiler's <math.h>. By virtue of the second bug, we need to use
50 dnl include_next as well in this case.
51 cat <<EOF > conftestd1a/conftest.h
52#define DEFINED_IN_CONFTESTD1
53#include_next <conftest.h>
54#ifdef DEFINED_IN_CONFTESTD2
55int foo;
56#else
57#error "include_next doesn't work"
58#endif
59EOF
60 cat <<EOF > conftestd1b/conftest.h
61#define DEFINED_IN_CONFTESTD1
62#include <stdio.h>
63#include_next <conftest.h>
64#ifdef DEFINED_IN_CONFTESTD2
65int foo;
66#else
67#error "include_next doesn't work"
68#endif
69EOF
70 cat <<EOF > conftestd2/conftest.h
71#ifndef DEFINED_IN_CONFTESTD1
72#error "include_next test doesn't work"
73#endif
74#define DEFINED_IN_CONFTESTD2
75EOF
76 gl_save_CPPFLAGS="$CPPFLAGS"
77 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
78dnl We intentionally avoid using AC_LANG_SOURCE here.
79 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
80 [gl_cv_have_include_next=yes],
81 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
82 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
83 [gl_cv_have_include_next=buggy],
84 [gl_cv_have_include_next=no])
85 ])
86 CPPFLAGS="$gl_save_CPPFLAGS"
87 rm -rf conftestd1a conftestd1b conftestd2
88 ])
89 PRAGMA_SYSTEM_HEADER=
90 if test $gl_cv_have_include_next = yes; then
91 INCLUDE_NEXT=include_next
92 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
93 if test -n "$GCC"; then
94 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
95 fi
96 else
97 if test $gl_cv_have_include_next = buggy; then
98 INCLUDE_NEXT=include
99 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
100 else
101 INCLUDE_NEXT=include
102 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
103 fi
104 fi
105 AC_SUBST([INCLUDE_NEXT])
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
107 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length],
109 [gl_cv_pragma_columns],
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
111 AC_EGREP_CPP([choke me],
112 [
113#ifdef __TANDEM
114choke me
115#endif
116 ],
117 [gl_cv_pragma_columns=yes],
118 [gl_cv_pragma_columns=no])
119 ])
120 if test $gl_cv_pragma_columns = yes; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else
123 PRAGMA_COLUMNS=
124 fi
125 AC_SUBST([PRAGMA_COLUMNS])
126])
127
128# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
129# ------------------------------------------
130# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
131# '<foo.h>'; otherwise define it to be
132# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
133# Also, if #include_next works as first preprocessing directive in a file,
134# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
135# be
136# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
137# That way, a header file with the following line:
138# #@INCLUDE_NEXT@ @NEXT_FOO_H@
139# or
140# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
141# behaves (after sed substitution) as if it contained
142# #include_next <foo.h>
143# even if the compiler does not support include_next.
144# The three "///" are to pacify Sun C 5.8, which otherwise would say
145# "warning: #include of /usr/include/... may be non-portable".
146# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
147# Note: This macro assumes that the header file is not empty after
148# preprocessing, i.e. it does not only define preprocessor macros but also
149# provides some type/enum definitions or function/variable declarations.
150#
151# This macro also checks whether each header exists, by invoking
152# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument.
153AC_DEFUN([gl_CHECK_NEXT_HEADERS],
154[
155 gl_NEXT_HEADERS_INTERNAL([$1], [check])
156])
157
158# gl_NEXT_HEADERS(HEADER1 HEADER2 ...)
159# ------------------------------------
160# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist.
161# This is suitable for headers like <stddef.h> that are standardized by C89
162# and therefore can be assumed to exist.
163AC_DEFUN([gl_NEXT_HEADERS],
164[
165 gl_NEXT_HEADERS_INTERNAL([$1], [assume])
166])
167
168# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS.
169AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
170[
171 AC_REQUIRE([gl_INCLUDE_NEXT])
172 AC_REQUIRE([AC_CANONICAL_HOST])
173
174 m4_if([$2], [check],
175 [AC_CHECK_HEADERS_ONCE([$1])
176 ])
177
178 m4_foreach_w([gl_HEADER_NAME], [$1],
179 [AS_VAR_PUSHDEF([gl_next_header],
180 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
181 if test $gl_cv_have_include_next = yes; then
182 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
183 else
184 AC_CACHE_CHECK(
185 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
186 m4_defn([gl_next_header]),
187 [m4_if([$2], [check],
188 [AS_VAR_PUSHDEF([gl_header_exists],
189 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
190 if test AS_VAR_GET(gl_header_exists) = yes; then
191 AS_VAR_POPDEF([gl_header_exists])
192 ])
193 AC_LANG_CONFTEST(
194 [AC_LANG_SOURCE(
195 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
196 )])
197 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
198 dnl files that contain only a #include of other header files and
199 dnl no non-comment tokens of their own. This leads to a failure
200 dnl to detect the absolute name of <dirent.h>, <signal.h>,
201 dnl <poll.h> and others. The workaround is to force preservation
202 dnl of comments through option -C. This ensures all necessary
203 dnl #line directives are present. GCC supports option -C as well.
204 case "$host_os" in
205 aix*) gl_absname_cpp="$ac_cpp -C" ;;
206 *) gl_absname_cpp="$ac_cpp" ;;
207 esac
208 dnl eval is necessary to expand gl_absname_cpp.
209 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
210 dnl so use subshell.
211 AS_VAR_SET([gl_next_header],
212 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
213 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
214 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
215 s#^/[^/]#//&#
216 p
217 q
218 }'`'"'])
219 m4_if([$2], [check],
220 [else
221 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
222 fi
223 ])
224 ])
225 fi
226 AC_SUBST(
227 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
228 [AS_VAR_GET([gl_next_header])])
229 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
230 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
231 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
232 else
233 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
234 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
235 fi
236 AC_SUBST(
237 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
238 [$gl_next_as_first_directive])
239 AS_VAR_POPDEF([gl_next_header])])
240])
241
242# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
243# this fallback is safe for all earlier autoconf versions.
244m4_define_default([AC_LANG_DEFINES_PROVIDED])
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
new file mode 100644
index 000000000..1942b6aa0
--- /dev/null
+++ b/m4/stddef_h.m4
@@ -0,0 +1,45 @@
1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
2# stddef_h.m4 serial 3
3dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_STDDEF_H],
9[
10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
11 AC_REQUIRE([gt_TYPE_WCHAR_T])
12 if test $gt_cv_c_wchar_t = no; then
13 HAVE_WCHAR_T=0
14 STDDEF_H=stddef.h
15 fi
16 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
17 [gl_cv_decl_null_works],
18 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
19 int test[2 * (sizeof NULL == sizeof (void *)) -1];
20]])],
21 [gl_cv_decl_null_works=yes],
22 [gl_cv_decl_null_works=no])])
23 if test $gl_cv_decl_null_works = no; then
24 REPLACE_NULL=1
25 STDDEF_H=stddef.h
26 fi
27 if test -n "$STDDEF_H"; then
28 gl_NEXT_HEADERS([stddef.h])
29 fi
30])
31
32AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
33[
34 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
35 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
36 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
37])
38
39AC_DEFUN([gl_STDDEF_H_DEFAULTS],
40[
41 dnl Assume proper GNU behavior unless another module says otherwise.
42 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
43 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
44 STDDEF_H=''; AC_SUBST([STDDEF_H])
45])
diff --git a/m4/string_h.m4 b/m4/string_h.m4
new file mode 100644
index 000000000..30ddfbc3a
--- /dev/null
+++ b/m4/string_h.m4
@@ -0,0 +1,115 @@
1# Configure a GNU-like replacement for <string.h>.
2
3# Copyright (C) 2007-2011 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# serial 19
9
10# Written by Paul Eggert.
11
12AC_DEFUN([gl_HEADER_STRING_H],
13[
14 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
15 dnl once only, before all statements that occur in other macros.
16 AC_REQUIRE([gl_HEADER_STRING_H_BODY])
17])
18
19AC_DEFUN([gl_HEADER_STRING_H_BODY],
20[
21 AC_REQUIRE([AC_C_RESTRICT])
22 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
23 gl_NEXT_HEADERS([string.h])
24
25 dnl Check for declarations of anything we want to poison if the
26 dnl corresponding gnulib module is not in use, and which is not
27 dnl guaranteed by C89.
28 gl_WARN_ON_USE_PREPARE([[#include <string.h>
29 ]],
30 [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
31 strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r
32 strsignal strverscmp])
33])
34
35AC_DEFUN([gl_STRING_MODULE_INDICATOR],
36[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
38 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40 dnl Define it also as a C macro, for the benefit of the unit tests.
41 gl_MODULE_INDICATOR_FOR_TESTS([$1])
42])
43
44AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
45[
46 GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR])
47 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
48 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
49 GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR])
50 GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR])
51 GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY])
52 GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
53 GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
54 GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP])
55 GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT])
56 GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP])
57 GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN])
58 GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK])
59 GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP])
60 GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR])
61 GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR])
62 GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R])
63 GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN])
64 GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN])
65 GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR])
66 GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR])
67 GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR])
68 GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP])
69 GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP])
70 GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP])
71 GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR])
72 GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN])
73 GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK])
74 GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN])
75 GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP])
76 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
77 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
78 GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R])
79 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
80 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
81 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
82 dnl Assume proper GNU behavior unless another module says otherwise.
83 HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
84 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
85 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
86 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
87 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
88 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
89 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
90 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
91 HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
92 HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
93 HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
94 HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
95 HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
96 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
97 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
98 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
99 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
100 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
101 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
102 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
103 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
104 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
105 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
106 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
107 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
108 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
109 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
110 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
111 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
112 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
113 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
114 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
115])
diff --git a/m4/strtok_r.m4 b/m4/strtok_r.m4
new file mode 100644
index 000000000..3f8a26fe7
--- /dev/null
+++ b/m4/strtok_r.m4
@@ -0,0 +1,74 @@
1# strtok_r.m4 serial 12
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_FUNC_STRTOK_R],
9[
10 dnl The strtok_r() declaration in lib/string.in.h uses 'restrict'.
11 AC_REQUIRE([AC_C_RESTRICT])
12
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15 AC_CHECK_FUNCS([strtok_r])
16 if test $ac_cv_func_strtok_r = yes; then
17 dnl glibc 2.7 has a bug in strtok_r that causes a segmentation fault
18 dnl when the second argument to strtok_r is a constant string that has
19 dnl exactly one byte and compiling with optimization. This bug is, for
20 dnl example, present in the glibc 2.7-18 package in Debian "lenny".
21 dnl See <http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614>.
22 AC_CACHE_CHECK([whether strtok_r works], [gl_cv_func_strtok_r_works],
23 [AC_RUN_IFELSE(
24 [AC_LANG_PROGRAM([[
25 #ifndef __OPTIMIZE__
26 # define __OPTIMIZE__ 1
27 #endif
28 #undef __OPTIMIZE_SIZE__
29 #undef __NO_INLINE__
30 #include <stdlib.h>
31 #include <string.h>
32 ]],
33 [[static const char dummy[] = "\177\01a";
34 char delimiters[] = "xxxxxxxx";
35 char *save_ptr = (char *) dummy;
36 strtok_r (delimiters, "x", &save_ptr);
37 strtok_r (NULL, "x", &save_ptr);
38 return 0;
39 ]])
40 ],
41 [gl_cv_func_strtok_r_works=yes],
42 [gl_cv_func_strtok_r_works=no],
43 [
44changequote(,)dnl
45 case "$host_os" in
46 # Guess no on glibc systems.
47 *-gnu*) gl_cv_func_strtok_r_works="guessing no";;
48 *) gl_cv_func_strtok_r_works="guessing yes";;
49 esac
50changequote([,])dnl
51 ])
52 ])
53 case "$gl_cv_func_strtok_r_works" in
54 *no)
55 dnl We could set REPLACE_STRTOK_R=1 and AC_LIBOBJ([strtok_r]) here,
56 dnl but it's only the macro version in <bits/string2.h> which is wrong.
57 dnl The code compiled into libc is fine.
58 UNDEFINE_STRTOK_R=1
59 ;;
60 esac
61 else
62 AC_LIBOBJ([strtok_r])
63 gl_PREREQ_STRTOK_R
64 fi
65 AC_CHECK_DECLS_ONCE([strtok_r])
66 if test $ac_cv_have_decl_strtok_r = no; then
67 HAVE_DECL_STRTOK_R=0
68 fi
69])
70
71# Prerequisites of lib/strtok_r.c.
72AC_DEFUN([gl_PREREQ_STRTOK_R], [
73 :
74])
diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4
new file mode 100644
index 000000000..e0d0f2764
--- /dev/null
+++ b/m4/warn-on-use.m4
@@ -0,0 +1,45 @@
1# warn-on-use.m4 serial 2
2dnl Copyright (C) 2010-2011 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
7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
8# ---------------------------------------
9# For each whitespace-separated element in the list of NAMES, define
10# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
11# even after being undefined as a macro.
12#
13# See warn-on-use.h for some hints on how to poison function names, as
14# well as ideas on poisoning global variables and macros. NAMES may
15# include global variables, but remember that only functions work with
16# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single
17# header, but if the replacement header pulls in other headers because
18# some systems declare functions in the wrong header, then INCLUDES
19# should do likewise.
20#
21# If you assume C89, then it is generally safe to assume declarations
22# for functions declared in that standard (such as gets) without
23# needing gl_WARN_ON_USE_PREPARE.
24AC_DEFUN([gl_WARN_ON_USE_PREPARE],
25[
26 m4_foreach_w([gl_decl], [$2],
27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
29 undefining macros.])])dnl
30 for gl_func in m4_flatten([$2]); do
31 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
32 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
33 gl_Symbol,
34 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
35[@%:@undef $gl_func
36 (void) $gl_func;])],
37 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
38 AS_VAR_IF(gl_Symbol, [yes],
39 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
40 dnl shortcut - if the raw declaration exists, then set a cache
41 dnl variable to allow skipping any later AC_CHECK_DECL efforts
42 eval ac_cv_have_decl_$gl_func=yes])
43 AS_VAR_POPDEF([gl_Symbol])dnl
44 done
45])
diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4
index cde2129a9..d2c03c42d 100644
--- a/m4/wchar_t.m4
+++ b/m4/wchar_t.m4
@@ -1,5 +1,5 @@
1# wchar_t.m4 serial 1 (gettext-0.12) 1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,11 +10,15 @@ dnl Prerequisite: AC_PROG_CC
10 10
11AC_DEFUN([gt_TYPE_WCHAR_T], 11AC_DEFUN([gt_TYPE_WCHAR_T],
12[ 12[
13 AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, 13 AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
14 [AC_TRY_COMPILE([#include <stddef.h> 14 [AC_COMPILE_IFELSE(
15 wchar_t foo = (wchar_t)'\0';], , 15 [AC_LANG_PROGRAM(
16 gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) 16 [[#include <stddef.h>
17 wchar_t foo = (wchar_t)'\0';]],
18 [[]])],
19 [gt_cv_c_wchar_t=yes],
20 [gt_cv_c_wchar_t=no])])
17 if test $gt_cv_c_wchar_t = yes; then 21 if test $gt_cv_c_wchar_t = yes; then
18 AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) 22 AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
19 fi 23 fi
20]) 24])