1 dnl Process this file with autoconf to produce a configure script.
3 AC_PREREQ(2.2)dnl dnl Minimum Autoconf version required.
5 AC_CONFIG_HEADER(config.h)
7 # This will get text that should go into config.make.
10 # Check for a --with-gmp argument and set gmp-srcdir in config.make.
12 --with-gmp=DIRECTORY find GMP source code in DIRECTORY (not needed),
15 yes) AC_MSG_ERROR(--with-gmp requires an argument; use --with-gmp=DIRECTORY) ;;
17 *) config_vars="$config_vars
18 gmp-srcdir = $withval" ;;
22 dnl Arguments to specify presence of other packages/features.
23 AC_ARG_WITH(gnu-binutils, dnl
24 --with-gnu-binutils if using GNU binutils (as and ld),
25 gnu_binutils=yes, gnu_binutils=no)
26 AC_ARG_WITH(gnu-ld, dnl
27 --with-gnu-ld if using GNU ld (in the binutils package),
28 gnu_ld=yes, gnu_ld=no)
29 AC_ARG_WITH(gnu-as, dnl
30 --with-gnu-as if using GNU as (in the binutils package),
31 gnu_as=yes, gnu_as=no)
32 test $gnu_binutils = yes && gnu_as=yes gnu_ld=yes
34 --with-elf if using the ELF object format,
36 AC_ARG_WITH(weak-symbols, dnl
37 --with-weak-symbols if weak symbols are available in as and ld,
40 dnl Arguments to enable or disable building the shared, profiled, and
41 dnl -fomit-frame-pointer libraries.
42 AC_ARG_ENABLE(shared, dnl
43 [ --enable-shared build shared library [default=yes if GNU ld & ELF]],
44 shared=yes, shared=no, shared=default)
45 AC_ARG_ENABLE(profile, dnl
46 [ --enable-profile build profiled library [default=yes]],
47 profile=yes, profile=no, profile=yes)
48 AC_ARG_ENABLE(omitfp, dnl
49 [ --enable-omitfp build undebuggable optimized library [default=no]],
50 omitfp=yes, omitfp=no, omitfp=no)
53 # We keep the original values in `$config_*' and never modify them, so we
54 # can write them unchanged into config.make. Everything else uses
55 # $machine, $vendor, and $os, and changes them whenever convenient.
56 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
58 sysdep_dir=$srcdir/sysdeps
59 AC_MSG_CHECKING(sysdep dirs)
60 AC_CACHE_VAL(libc_cv_sysdirs, [dnl
61 machine=$config_machine
65 dnl We need to use [ and ] for other purposes for a while now.
67 # Expand the configuration machine name into a subdirectory by architecture
68 # type and particular chip.
71 machine=i386/$machine ;;
73 machine=sparc/$machine ;;
75 machine=m68k/m68020 ;;
77 machine=m68k/$machine ;;
79 machine=m88k/m88100 ;;
81 machine=m88k/$machine ;;
83 machine=mips/mips64/$machine ;;
85 machine=mips/$machine ;;
88 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
89 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
95 base_os=unix/bsd/bsd4.4 ;;
96 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
98 linux* | sysv* | isc* | esix* | sco* | minix* | irix4*)
101 base_os=unix/sysv/sysv4 ;;
103 base_os=standalone ;;
108 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
111 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
115 o=`echo $tail | sed 's/[0-9]*$//'`
116 if test $o != $tail; then
120 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
123 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
129 # For sparc/sparc9, try sparc/sparc9 and then sparc.
132 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
138 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
141 # Find what sysdep directories exist.
143 for b in $base ''; do
144 for m0 in $mach ''; do
145 for v in /$vendor ''; do
146 for o in /$ostry ''; do
147 for m in $mach ''; do
149 if test -d $sysdep_dir$try; then
150 sysnames="$sysnames $try"
151 { test -n "$o" || test -n "$b"; } && os_used=t
152 { test -n "$m" || test -n "$m0"; } && machine_used=t
160 if test -z "$os_used" && test "$os" != none; then
161 AC_MSG_ERROR(Operating system $os is not supported.)
163 if test -z "$machine_used" && test "$machine" != none; then
164 AC_MSG_ERROR(The $machine is not supported.)
167 # We have now validated the configuration.
169 # Remove the leading slashes.
170 sysnames="`echo $sysnames | sed -e 's@^/@@' -e 's@ /@ @g'`"
172 # Prepend the machine's FPU directory unless --without-fp.
173 if test "$with_fp" = no; then
176 if test -d $sysdep_dir$m/fpu; then
177 fpu_dirs="$fpu_dirs $m/fpu"
180 sysnames="`echo $fpu_dirs | sed -e 's,^/,,' -e 's, /,,g'` $sysnames"
183 # Expand the list of system names into a full list of directories
184 # from each element's parent name and Implies file (if present).
186 while test $# -gt 0; do
190 if test -f $sysdep_dir/$name/Implies; then
191 # Collect more names from the `Implies' file (removing comments).
192 implied="`sed 's/#.*$//' < $sysdep_dir/$name/Implies`"
193 for x in $implied; do
194 test -d $sysdep_dir/$x || echo "Warning: $name implies nonexistent $x">&2
200 # Add NAME to the list of names.
203 # Find the parent of NAME, using the empty string if it has none.
205 parent="`echo $name | sed -n -e '/\//!q' -e 's=/[^/]*$==p'`"
208 # Add the names implied by NAME, and NAME's parent (if it has one), to
209 # the list of names to be processed (the argument list). We prepend the
210 # implied names to the list and append the parent. We want implied
211 # directories to come before further directories inferred from the
212 # configuration components; this ensures that for sysv4, unix/common
213 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
215 sysnames="`echo $implied $* $parent`"
216 test -n "$sysnames" && set $sysnames
219 # Add the default directories.
220 names="$names generic stub"
222 # Now uniquize the list.
225 for name in $names; do
226 if echo "$seen" | fgrep -x $name >/dev/null; then
227 # Already in the list.
231 if test -z "$seen"; then
232 seen="$name" sysnames="$name"
236 sysnames="$sysnames $name"
240 libc_cv_sysdirs="$sysnames"])
241 AC_SUBST(sysnames) sysnames="$libc_cv_sysdirs"
242 AC_MSG_RESULT(${sysnames})
245 gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
246 gnu_ld=yes gnu_as=yes
249 gnu*elf* | linux*elf* | sysv4* | solaris2*)
254 if test "$INSTALL" = "${srcdir}/install-sh"; then
255 # The makefiles need to use a different form to find it in $srcdir.
256 INSTALL='$(..)./install-sh'
259 AC_CHECK_TOOL(CC, gcc)
260 AC_CHECK_TOOL(AR, ar)
261 AC_CHECK_TOOL(RANLIB, ranlib, :)
264 AC_MSG_CHECKING(signed size_t type)
265 AC_CACHE_VAL(libc_cv_signed_size_t, [dnl
266 echo '#include <stddef.h>
267 FOOBAR __SIZE_TYPE__ FOOBAR' > conftest.c
268 if eval "$ac_cpp conftest.c 2>/dev/null" \
269 | grep '^FOOBAR.*unsigned.*FOOBAR$' >/dev/null; then
270 libc_cv_signed_size_t=no
272 libc_cv_signed_size_t=yes
275 AC_MSG_RESULT($libc_cv_signed_size_t)
276 if test $libc_cv_signed_size_t = yes; then
277 dnl Do this by hand instead of AC_DEFINE so can add #undef to avoid warnings.
278 cat >> confdefs.h <<\EOF
280 #define __SIZE_TYPE__ unsigned
284 AC_MSG_CHECKING(libc-friendly stddef.h)
285 AC_CACHE_VAL(libc_cv_friendly_stddef, [dnl
287 [#define __need_size_t
288 #define __need_wchar_t
291 #include <stddef.h>], [size_t size; wchar_t wchar;
293 #error stddef.h ignored __need_*
295 if (&size == NULL || &wchar == NULL) abort ();],
296 libc_cv_friendly_stddef=yes,
297 libc_cv_friendly_stddef=no)])
298 AC_MSG_RESULT($libc_cv_friendly_stddef)
299 if test $libc_cv_friendly_stddef = yes; then
300 config_vars="$config_vars
301 override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
304 AC_MSG_CHECKING(whether we need to use -P to assemble .S files)
305 AC_CACHE_VAL(libc_cv_need_minus_P, [dnl
306 cat > conftest.S <<EOF
307 #include "confdefs.h"
308 /* Nothing whatsoever. */
310 if ${CC-cc} $CFLAGS -c conftest.S 2>/dev/null; then
311 libc_cv_need_minus_P=no
313 libc_cv_need_minus_P=yes
316 AC_MSG_RESULT($libc_cv_need_minus_P)
317 if test $libc_cv_need_minus_P = yes; then
318 config_vars="$config_vars
319 asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
322 # sysdeps configure fragments may set these with files to be linked below.
326 # Iterate over all the sysdep directories we will use, running their
327 # configure fragments, and looking for a uname implementation.
329 for dir in $sysnames; do
330 if test -r $sysdep_dir/$dir/configure; then
331 AC_MSG_RESULT(running configure fragment for $dir)
332 . $sysdep_dir/$dir/configure
334 if test -z "$uname"; then
335 { test -r $sysdep_dir/$dir/uname.c || test -r $sysdep_dir/$dir/uname.S; } \
340 AC_LINK_FILES(`echo $libc_link_sources`, `echo $libc_link_dests`)
342 # If we will use the generic uname implementation, we must figure out what
343 # it will say by examining the system, and write the results in config-name.h.
344 if test "$uname" = generic; then
347 uname_sysname=`echo $config_os | sed 's/[0-9.]*$//'`
349 if test $uname_sysname != $config_os; then
350 config_release=`echo $config_os | sed s/$uname_sysname//`
353 AC_DEFUN(LIBC_KERNEL_ID, [dnl
354 if test -r /vmunix; then
355 kernel_id=`strings /vmunix | grep UNIX`
356 elif test -r /dynix; then
357 kernel_id=`strings /dynix | grep DYNIX`
363 AC_MSG_CHECKING(OS release for uname)
364 AC_CACHE_VAL(libc_cv_uname_release, [dnl
365 AC_REQUIRE([LIBC_KERNEL_ID])dnl
367 kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'`
369 if test x`echo "$config_release" | sed "s/^$kernel_release//"` \
370 != x$config_release; then
371 # The configuration release is a substring of the kernel release.
372 libc_cv_uname_release=$kernel_release
373 elif test x$config_release != x; then
374 libc_cv_uname_release=$config_release
375 elif test x$kernel_release != x; then
376 libc_cv_uname_release=$kernel_release
378 libc_cv_uname_release=unknown
380 AC_MSG_RESULT($libc_cv_uname_release)
381 uname_release="$libc_cv_uname_release"
383 AC_MSG_CHECKING(OS version for uname)
384 AC_CACHE_VAL(libc_cv_uname_version, [dnl
385 AC_REQUIRE([LIBC_KERNEL_ID])dnl
387 kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'`
389 if test -n "$kernel_version"; then
390 libc_cv_uname_version="$kernel_version"
392 libc_cv_uname_version=unknown
394 AC_MSG_RESULT($libc_cv_uname_version)
395 uname_version="$libc_cv_uname_version"
397 AC_SUBST(uname_sysname) AC_SUBST(uname_release) AC_SUBST(uname_version)dnl
398 config_uname=config-name.h:config-name.in
400 # For non-generic uname, we don't need to create config-name.h at all.
404 AC_SUBST(gnu_ld) AC_SUBST(gnu_as) AC_SUBST(elf) AC_SUBST(weak)
405 if test $gnu_ld = yes; then
406 AC_DEFINE(HAVE_GNU_LD)
408 if test $gnu_as = yes; then
409 AC_DEFINE(HAVE_GNU_AS)
411 if test $elf = yes; then
414 if test $weak = yes; then
415 AC_DEFINE(HAVE_WEAK_SYMBOLS)
419 if test $shared = default; then
420 if test $gnu_ld = yes; then
428 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
431 config_makefile=Makefile
434 AC_OUTPUT(config.make ${config_makefile} ${config_uname}, ,
435 [echo '$config_vars' >> config.make])