nis: Fix leak on realloc failure in nis_getnames [BZ #28150]
[glibc.git] / aclocal.m4
blobc195c4db567715ba1f4372932d615820dc839b5a
1 dnl We require that everyone use exactly the same Autoconf version so that
2 dnl the internal functions defined and used by the main configure script
3 dnl match those expected by the fragments.  When changing this version,
4 dnl install.texi also needs to be updated.
5 m4_define([GLIBC_AUTOCONF_VERSION], [2.69])
6 m4_if(m4_defn([AC_AUTOCONF_VERSION]), GLIBC_AUTOCONF_VERSION, [],
7       [m4_fatal(m4_flatten(
8 Exactly version GLIBC_AUTOCONF_VERSION of Autoconf is required but you have
9 m4_defn([AC_AUTOCONF_VERSION])
10 ), [63])])dnl
11 dnl
12 dnl We define the macro GLIBC_PROVIDES to do an AC_PROVIDE for each macro
13 dnl which appears in configure.ac before the sysdep configure scripts are run.
14 dnl Each sysdep configure.ac does GLIBC_PROVIDES first, to avoid any
15 dnl AC_REQUIREs or AC_BEFOREs duplicating their code.
16 dnl
17 define([GLIBC_PROVIDES], [dnl
18 AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
19 AC_PROVIDE([AC_CONFIG_SUBDIRS])dnl
20 AC_PROVIDE([_AS_ECHO_N_PREPARE])dnl
21 AC_PROVIDE([_AS_ECHO_PREPARE])dnl
22 AC_PROVIDE([_AS_CR_PREPARE])dnl
23 AC_PROVIDE([_AS_TR_SH_PREPARE])dnl
24 AC_PROVIDE([_AS_VAR_ARITH_PREPARE])dnl
25 AC_PROVIDE([AC_PROG_INSTALL])dnl
26 AC_PROVIDE([AC_PROG_CC])dnl
27 AC_PROVIDE([AC_PROG_CPP])dnl
28 AC_PROVIDE([_AS_PATH_SEPARATOR_PREPARE])dnl
29 AC_PROVIDE([_AS_TEST_PREPARE])dnl
30 AC_PROVIDE([_AS_BASENAME_PREPARE])dnl
31 AC_PROVIDE([_AS_ME_PREPARE])dnl
32 AC_PROVIDE([_AS_LINENO_PREPARE])dnl
33 AC_PROVIDE([AS_SHELL_FN_as_fn_set_status])dnl
34 AC_PROVIDE([AS_SHELL_FN_as_fn_exit])dnl
35 AC_PROVIDE([AS_SHELL_FN_as_fn_arith])dnl
36 AC_PROVIDE([AS_SHELL_FN_ac_fn_c_try_compile])dnl
37 AC_PROVIDE([AS_SHELL_FN_ac_fn_c_try_cpp])dnl
38 define([AS_MESSAGE_LOG_FD],5)dnl
39 define([AS_MESSAGE_FD],6)dnl
40 dnl Ripped out of AS_INIT, which does more cruft we do not want.
41 m4_wrap([m4_divert_pop([BODY])[]])
42 m4_divert_push([BODY])[]dnl
43 dnl End of ripped out of AS_INIT.
44 # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
45 define([_AC_LANG], [C])dnl
46 ])dnl
47 dnl
48 dnl Check for a symbol
49 dnl
50 AC_DEFUN([AC_CHECK_SYMBOL], [dnl
51 AC_MSG_CHECKING(for $1)
52 AC_CACHE_VAL(ac_cv_check_symbol_$1, [dnl
53 AC_TRY_LINK(,
54 changequote(,)dnl
55 extern char *$1[]; puts(*$1);,
56 changequote([,])dnl
57             ac_cv_check_symbol_$1=yes, ac_cv_check_symbol_$1=no)])
58 if test "$ac_cv_check_symbol_$1" = yes; then
59 changequote(,)dnl
60   ac_tr_symbol=`echo $1 | tr '[a-z]' '[A-Z]'`
61 changequote([,])dnl
62   AC_DEFINE_UNQUOTED(HAVE_${ac_tr_symbol})
64 AC_MSG_RESULT($ac_cv_check_symbol_$1)])dnl
65 dnl
67 dnl Locate a program and check that its version is acceptable.
68 dnl AC_PROG_CHECK_VER(var, namelist, version-switch,
69 dnl                   [version-extract-regexp], version-glob [, do-if-fail])
70 AC_DEFUN([AC_CHECK_PROG_VER],
71 [AC_CHECK_PROGS([$1], [$2])
72 if test -z "[$]$1"; then
73   ac_verc_fail=yes
74 else
75   # Found it, now check the version.
76   AC_MSG_CHECKING([version of [$]$1])
77 changequote(<<,>>)dnl
78   ac_prog_version=`<<$>>$1 $3 2>&1 ifelse(<<$4>>,,,
79                    <<| sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'>>)`
80   case $ac_prog_version in
81     '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
82     <<$5>>)
83 changequote([,])dnl
84        ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
85     *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
87   esac
88   AC_MSG_RESULT([$ac_prog_version])
90 ifelse([$6],,,
91 [if test $ac_verc_fail = yes; then
92   $6
93 fi])
96 dnl These modifications are to allow for an empty cross compiler tree.
97 define([_AC_COMPILER_EXEEXT], [EXEEXT=
100 AC_DEFUN([LIBC_PROG_FOO_GNU],
101 [# Most GNU programs take a -v and spit out some text including
102 # the word 'GNU'.  Some try to read stdin, so give them /dev/null.
103 if $1 -o conftest -v </dev/null 2>&1 | grep GNU > /dev/null 2>&1; then
104   $2
105 else
106   $3
108 rm -fr contest*])
110 AC_DEFUN([LIBC_PROG_BINUTILS],
111 [# Was a --with-binutils option given?
112 if test -n "$path_binutils"; then
113     # Make absolute; ensure a single trailing slash.
114     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
115     CC="$CC -B$path_binutils"
117 AS=`$CC -print-prog-name=as`
118 LD=`$CC -print-prog-name=ld`
119 AR=`$CC -print-prog-name=ar`
120 AC_SUBST(AR)
121 OBJDUMP=`$CC -print-prog-name=objdump`
122 AC_SUBST(OBJDUMP)
123 OBJCOPY=`$CC -print-prog-name=objcopy`
124 AC_SUBST(OBJCOPY)
125 GPROF=`$CC -print-prog-name=gprof`
126 AC_SUBST(GPROF)
128 # Determine whether we are using GNU binutils.
129 AC_CACHE_CHECK(whether $AS is GNU as, libc_cv_prog_as_gnu,
130 [LIBC_PROG_FOO_GNU($AS, libc_cv_prog_as_gnu=yes, libc_cv_prog_as_gnu=no)])
131 rm -f a.out
132 gnu_as=$libc_cv_prog_as_gnu
134 AC_CACHE_CHECK(whether $LD is GNU ld, libc_cv_prog_ld_gnu,
135 [LIBC_PROG_FOO_GNU($LD, libc_cv_prog_ld_gnu=yes, libc_cv_prog_ld_gnu=no)])
136 gnu_ld=$libc_cv_prog_ld_gnu
139 dnl Run a static link test with -nostdlib -nostartfiles.
140 dnl LIBC_TRY_LINK_STATIC([code], [action-if-true], [action-if-false])
141 AC_DEFUN([LIBC_TRY_LINK_STATIC],
142 [cat > conftest.c <<EOF
143 int _start (void) { return 0; }
144 int __start (void) { return 0; }
147 AS_IF([AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -o conftest
148                        conftest.c -static -nostartfiles -nostdlib
149                        1>&AS_MESSAGE_LOG_FD])],
150       [$2], [$3])
151 rm -f conftest*])
153 dnl Test a compiler option or options with an empty input file.
154 dnl LIBC_TRY_CC_OPTION([options], [action-if-true], [action-if-false])
155 AC_DEFUN([LIBC_TRY_CC_OPTION],
156 [AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])],
157         [$2], [$3])])
159 dnl Find and source sysdeps/*/preconfigure.
160 dnl LIBC_PRECONFIGURE([$srcdir], [for])
161 AC_DEFUN([LIBC_PRECONFIGURE], [dnl
162 if frags=`ls -d $1/sysdeps/*/preconfigure 2> /dev/null`
163 then
164   AC_MSG_CHECKING($2 preconfigure fragments)
165   for frag in $frags; do
166     name=`echo "$frag" | sed 's@/[[^/]]*[$]@@;s@^.*/@@'`
167     echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
168     . "$frag"
169   done
170   AC_MSG_RESULT()
171 fi])
173 # These two macros are taken from GCC's config/acx.m4.
174 dnl Support the --with-pkgversion configure option.
175 dnl ACX_PKGVERSION(default-pkgversion)
176 AC_DEFUN([ACX_PKGVERSION],[
177   AC_ARG_WITH(pkgversion,
178     AS_HELP_STRING([--with-pkgversion=PKG],
179                    [Use PKG in the version string in place of "$1"]),
180     [case "$withval" in
181       yes) AC_MSG_ERROR([package version not specified]) ;;
182       no)  PKGVERSION= ;;
183       *)   PKGVERSION="($withval) " ;;
184      esac],
185     PKGVERSION="($1) "
186   )
187   PKGVERSION_TEXI=`echo "$PKGVERSION" | sed 's/@/@@/g'`
188   AC_SUBST(PKGVERSION)
189   AC_SUBST(PKGVERSION_TEXI)
192 dnl Support the --with-bugurl configure option.
193 dnl ACX_BUGURL(default-bugurl)
194 AC_DEFUN([ACX_BUGURL],[
195   AC_ARG_WITH(bugurl,
196     AS_HELP_STRING([--with-bugurl=URL],
197                    [Direct users to URL to report a bug]),
198     [case "$withval" in
199       yes) AC_MSG_ERROR([bug URL not specified]) ;;
200       no)  BUGURL=
201            ;;
202       *)   BUGURL="$withval"
203            ;;
204      esac],
205      BUGURL="$1"
206   )
207   case ${BUGURL} in
208   "")
209     REPORT_BUGS_TO=
210     REPORT_BUGS_TEXI=
211     ;;
212   *)
213     REPORT_BUGS_TO="<$BUGURL>"
214     REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
215     ;;
216   esac;
217   AC_SUBST(REPORT_BUGS_TO)
218   AC_SUBST(REPORT_BUGS_TEXI)
221 dnl Check linker option support.
222 dnl LIBC_LINKER_FEATURE([ld_option], [cc_option], [action-if-true], [action-if-false])
223 AC_DEFUN([LIBC_LINKER_FEATURE],
224 [AC_MSG_CHECKING([for linker that supports $1])
225 libc_linker_feature=no
226 if test x"$gnu_ld" = x"yes"; then
227   libc_linker_check=`$LD -v --help 2>/dev/null | grep "\$1"`
228   if test -n "$libc_linker_check"; then
229     cat > conftest.c <<EOF
230 int _start (void) { return 42; }
232     if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
233                                 $2 -nostdlib -nostartfiles
234                                 -fPIC -shared -o conftest.so conftest.c
235                                 1>&AS_MESSAGE_LOG_FD])
236     then
237       libc_linker_feature=yes
238     fi
239     rm -f conftest*
240   fi
242 if test $libc_linker_feature = yes; then
243   $3
244 else
245   $4
247 AC_MSG_RESULT($libc_linker_feature)])
249 dnl Add a makefile variable, with value set from a shell string
250 dnl (expanded by the shell inside double quotes), to config.make.
251 dnl LIBC_CONFIG_VAR(make-variable, shell-value)
252 AC_DEFUN([LIBC_CONFIG_VAR],
253 [config_vars="$config_vars
254 $1 = $2"])
256 dnl Check that function FUNC was inlined as a builtin.  The code fragment
257 dnl CODE is compiled with additional options CC_OPTION.  If FUNC is
258 dnl not found in the assembly then it is assumed the compiler has support
259 dnl for this builtin and has inlined the call.  If the compiler has the
260 dnl feature then ACTION-IF-TRUE is called, otherwise ACTION-IF-FALSE.
261 dnl It is up to the caller to provide a CC_OPTION that ensures the
262 dnl builtin is inlined if present.
263 dnl Warning: This may not work for some machines. For example on ARM the
264 dnl ABI dictates that some functions should not be inlined and instead
265 dnl should be provided by a compiler helper library e.g. __aeabi_memcpy.
266 dnl This is done to reduce code size.
267 dnl LIBC_COMPILER_BUILTIN([func], [code], [cc_option], [action-if-true], [action-if-false])
268 AC_DEFUN([LIBC_COMPILER_BUILTIN_INLINED],
269 [AC_MSG_CHECKING([for compiler support of inlined builtin function $1])
270 libc_compiler_builtin_inlined=no
271 cat > conftest.c <<EOF
272 int _start (void) { $2 return 0; }
274 if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
275                      $3 -nostdlib -nostartfiles
276                      -S conftest.c -o - | fgrep "$1"
277                      1>&AS_MESSAGE_LOG_FD])
278 then
279   libc_compiler_builtin_inlined=yes
281 rm -f conftest*
282 if test $libc_compiler_builtin_inlined = yes; then
283   $4
284 else
285   $5
287 AC_MSG_RESULT($libc_compiler_builtin_inlined)])
289 dnl Default to slibdir named SLIBDIR instead of "lib", and rtlddir
290 dnl named RTLDDIR instead of "lib".  This is used to put 64-bit
291 dnl libraries in /lib64.
292 dnl LIBC_SLIBDIR_RTLDDIR([slibdir], [rtlddir])
293 AC_DEFUN([LIBC_SLIBDIR_RTLDDIR],
294 [test -n "$libc_cv_slibdir" ||
295 case "$prefix" in
296 /usr | /usr/)
297   libc_cv_slibdir='/$1'
298   libc_cv_rtlddir='/$2'
299   if test "$libdir" = '${exec_prefix}/lib'; then
300     libdir='${exec_prefix}/$1';
301     # Locale data can be shared between 32-bit and 64-bit libraries.
302     libc_cv_complocaledir='${exec_prefix}/lib/locale'
303   fi
304   ;;
305 esac])