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