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
3dnl match those expected by the fragments.  When changing this version,
4dnl install.texi also needs to be updated.
5m4_define([GLIBC_AUTOCONF_VERSION], [2.69])
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
12dnl We define the macro GLIBC_PROVIDES to do an AC_PROVIDE for each macro
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
15dnl AC_REQUIREs or AC_BEFOREs duplicating their code.
16dnl
17define([GLIBC_PROVIDES], [dnl
18AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
19AC_PROVIDE([AC_CONFIG_SUBDIRS])dnl
20AC_PROVIDE([_AS_ECHO_N_PREPARE])dnl
21AC_PROVIDE([_AS_ECHO_PREPARE])dnl
22AC_PROVIDE([_AS_CR_PREPARE])dnl
23AC_PROVIDE([_AS_TR_SH_PREPARE])dnl
24AC_PROVIDE([_AS_VAR_ARITH_PREPARE])dnl
25AC_PROVIDE([AC_PROG_INSTALL])dnl
26AC_PROVIDE([AC_PROG_CC])dnl
27AC_PROVIDE([AC_PROG_CPP])dnl
28AC_PROVIDE([_AS_PATH_SEPARATOR_PREPARE])dnl
29AC_PROVIDE([_AS_TEST_PREPARE])dnl
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
37AC_PROVIDE([AS_SHELL_FN_ac_fn_c_try_cpp])dnl
38define([AS_MESSAGE_LOG_FD],5)dnl
39define([AS_MESSAGE_FD],6)dnl
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.
44# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
45define([_AC_LANG], [C])dnl
46])dnl
47dnl
48dnl Check for a symbol
49dnl
50AC_DEFUN([AC_CHECK_SYMBOL], [dnl
51AC_MSG_CHECKING(for $1)
52AC_CACHE_VAL(ac_cv_check_symbol_$1, [dnl
53AC_TRY_LINK(,
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
66
67dnl Locate a program and check that its version is acceptable.
68dnl AC_PROG_CHECK_VER(var, namelist, version-switch,
69dnl 		      [version-extract-regexp], version-glob [, do-if-fail])
70AC_DEFUN([AC_CHECK_PROG_VER],
71[AC_CHECK_PROGS([$1], [$2])
72if test -z "[$]$1"; then
73  ac_verc_fail=yes
74else
75  # Found it, now check the version.
76  AC_MSG_CHECKING([version of [$]$1])
77changequote(<<,>>)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>>)
83changequote([,])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;;
86
87  esac
88  AC_MSG_RESULT([$ac_prog_version])
89fi
90ifelse([$6],,,
91[if test $ac_verc_fail = yes; then
92  $6
93fi])
94])
95
96dnl These modifications are to allow for an empty cross compiler tree.
97define([_AC_COMPILER_EXEEXT], [EXEEXT=
98])
99
100AC_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.
103if $1 -o conftest -v </dev/null 2>&1 | grep GNU > /dev/null 2>&1; then
104  $2
105else
106  $3
107fi
108rm -fr contest*])
109
110AC_DEFUN([LIBC_PROG_BINUTILS],
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%/*$%/%'`
115    CC="$CC -B$path_binutils"
116fi
117case "$CC" in
118    *fuse-ld=lld*) LDNAME=ld.lld;;
119    *)             LDNAME=ld;;
120esac
121AS=`$CC -print-prog-name=as`
122LD=`$CC -print-prog-name=$LDNAME`
123AR=`$CC -print-prog-name=ar`
124AC_SUBST(AR)
125OBJDUMP=`$CC -print-prog-name=objdump`
126AC_SUBST(OBJDUMP)
127OBJCOPY=`$CC -print-prog-name=objcopy`
128AC_SUBST(OBJCOPY)
129GPROF=`$CC -print-prog-name=gprof`
130AC_SUBST(GPROF)
131
132# Determine whether we are using GNU binutils.
133AC_CACHE_CHECK(whether $AS is GNU as, libc_cv_prog_as_gnu,
134[LIBC_PROG_FOO_GNU($AS, libc_cv_prog_as_gnu=yes, libc_cv_prog_as_gnu=no)])
135rm -f a.out
136gnu_as=$libc_cv_prog_as_gnu
137
138AC_CACHE_CHECK(whether $LD is GNU ld, libc_cv_prog_ld_gnu,
139[LIBC_PROG_FOO_GNU($LD, libc_cv_prog_ld_gnu=yes, libc_cv_prog_ld_gnu=no)])
140gnu_ld=$libc_cv_prog_ld_gnu
141])
142
143dnl Run a static link test with -nostdlib -nostartfiles.
144dnl LIBC_TRY_LINK_STATIC([code], [action-if-true], [action-if-false])
145AC_DEFUN([LIBC_TRY_LINK_STATIC],
146[cat > conftest.c <<EOF
147int _start (void) { return 0; }
148int __start (void) { return 0; }
149$1
150EOF
151AS_IF([AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -o conftest
152		       conftest.c -static -nostartfiles -nostdlib
153		       1>&AS_MESSAGE_LOG_FD])],
154      [$2], [$3])
155rm -f conftest*])
156
157dnl Test a compiler option or options with an empty input file.
158dnl LIBC_TRY_CC_OPTION([options], [action-if-true], [action-if-false])
159AC_DEFUN([LIBC_TRY_CC_OPTION],
160[AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])],
161	[$2], [$3])])
162
163dnl Find and source sysdeps/*/preconfigure.
164dnl LIBC_PRECONFIGURE([$srcdir], [for])
165AC_DEFUN([LIBC_PRECONFIGURE], [dnl
166if frags=`ls -d $1/sysdeps/*/preconfigure 2> /dev/null`
167then
168  AC_MSG_CHECKING($2 preconfigure fragments)
169  for frag in $frags; do
170    name=`echo "$frag" | sed 's@/[[^/]]*[$]@@;s@^.*/@@'`
171    echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
172    . "$frag"
173  done
174  AC_MSG_RESULT()
175fi])
176
177# These two macros are taken from GCC's config/acx.m4.
178dnl Support the --with-pkgversion configure option.
179dnl ACX_PKGVERSION(default-pkgversion)
180AC_DEFUN([ACX_PKGVERSION],[
181  AC_ARG_WITH(pkgversion,
182    AS_HELP_STRING([--with-pkgversion=PKG],
183                   [Use PKG in the version string in place of "$1"]),
184    [case "$withval" in
185      yes) AC_MSG_ERROR([package version not specified]) ;;
186      no)  PKGVERSION= ;;
187      *)   PKGVERSION="($withval) " ;;
188     esac],
189    PKGVERSION="($1) "
190  )
191  PKGVERSION_TEXI=`echo "$PKGVERSION" | sed 's/@/@@/g'`
192  AC_SUBST(PKGVERSION)
193  AC_SUBST(PKGVERSION_TEXI)
194])
195
196dnl Support the --with-bugurl configure option.
197dnl ACX_BUGURL(default-bugurl)
198AC_DEFUN([ACX_BUGURL],[
199  AC_ARG_WITH(bugurl,
200    AS_HELP_STRING([--with-bugurl=URL],
201                   [Direct users to URL to report a bug]),
202    [case "$withval" in
203      yes) AC_MSG_ERROR([bug URL not specified]) ;;
204      no)  BUGURL=
205	   ;;
206      *)   BUGURL="$withval"
207	   ;;
208     esac],
209     BUGURL="$1"
210  )
211  case ${BUGURL} in
212  "")
213    REPORT_BUGS_TO=
214    REPORT_BUGS_TEXI=
215    ;;
216  *)
217    REPORT_BUGS_TO="<$BUGURL>"
218    REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
219    ;;
220  esac;
221  AC_SUBST(REPORT_BUGS_TO)
222  AC_SUBST(REPORT_BUGS_TEXI)
223])
224
225dnl Check linker option support.
226dnl LIBC_LINKER_FEATURE([ld_option], [cc_option], [action-if-true], [action-if-false])
227AC_DEFUN([LIBC_LINKER_FEATURE],
228[AC_MSG_CHECKING([for linker that supports $1])
229libc_linker_feature=no
230if test x"$gnu_ld" = x"yes"; then
231  cat > conftest.c <<EOF
232int _start (void) { return 42; }
233EOF
234  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
235		    $2 -nostdlib -nostartfiles
236		    -fPIC -shared -o conftest.so conftest.c
237		    1>&AS_MESSAGE_LOG_FD])
238  then
239    if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp $2 -nostdlib \
240	-nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \
241	| grep "warning: $1 ignored" > /dev/null 2>&1; then
242      true
243    else
244      libc_linker_feature=yes
245    fi
246  fi
247  rm -f conftest*
248fi
249if test $libc_linker_feature = yes; then
250  $3
251else
252  $4
253fi
254AC_MSG_RESULT($libc_linker_feature)])
255
256dnl Add a makefile variable, with value set from a shell string
257dnl (expanded by the shell inside double quotes), to config.make.
258dnl LIBC_CONFIG_VAR(make-variable, shell-value)
259AC_DEFUN([LIBC_CONFIG_VAR],
260[config_vars="$config_vars
261$1 = $2"])
262
263dnl Check that function FUNC was inlined as a builtin.  The code fragment
264dnl CODE is compiled with additional options CC_OPTION.  If FUNC is
265dnl not found in the assembly then it is assumed the compiler has support
266dnl for this builtin and has inlined the call.  If the compiler has the
267dnl feature then ACTION-IF-TRUE is called, otherwise ACTION-IF-FALSE.
268dnl It is up to the caller to provide a CC_OPTION that ensures the
269dnl builtin is inlined if present.
270dnl Warning: This may not work for some machines. For example on ARM the
271dnl ABI dictates that some functions should not be inlined and instead
272dnl should be provided by a compiler helper library e.g. __aeabi_memcpy.
273dnl This is done to reduce code size.
274dnl LIBC_COMPILER_BUILTIN([func], [code], [cc_option], [action-if-true], [action-if-false])
275AC_DEFUN([LIBC_COMPILER_BUILTIN_INLINED],
276[AC_MSG_CHECKING([for compiler support of inlined builtin function $1])
277libc_compiler_builtin_inlined=no
278cat > conftest.c <<EOF
279int _start (void) { $2 return 0; }
280EOF
281if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
282		     $3 -nostdlib -nostartfiles
283		     -S conftest.c -o - | grep -F "$1"
284		     1>&AS_MESSAGE_LOG_FD])
285then
286  libc_compiler_builtin_inlined=yes
287fi
288rm -f conftest*
289if test $libc_compiler_builtin_inlined = yes; then
290  $4
291else
292  $5
293fi
294AC_MSG_RESULT($libc_compiler_builtin_inlined)])
295
296dnl Default to slibdir named SLIBDIR instead of "lib", and rtlddir
297dnl named RTLDDIR instead of "lib".  This is used to put 64-bit
298dnl libraries in /lib64.
299dnl LIBC_SLIBDIR_RTLDDIR([slibdir], [rtlddir])
300AC_DEFUN([LIBC_SLIBDIR_RTLDDIR],
301[test -n "$libc_cv_slibdir" ||
302case "$prefix" in
303/usr | /usr/)
304  libc_cv_slibdir='/$1'
305  libc_cv_rtlddir='/$2'
306  if test "$libdir" = '${exec_prefix}/lib'; then
307    libdir='${exec_prefix}/$1';
308    # Locale data can be shared between 32-bit and 64-bit libraries.
309    libc_cv_complocaledir='${exec_prefix}/lib/locale'
310  fi
311  ;;
312esac])
313