Portability changes from Uli Drepper. [!STDC_HEADERS && !defined(NULL)] Define NULL.
[glibc.git] / configure.in
blob6ae7cf81ed3a84591d2175b4f91ce932664f14db
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION([$CVSid$])
3 AC_PREREQ(2.2)dnl               dnl Minimum Autoconf version required.
4 AC_INIT(features.h)
5 AC_CONFIG_HEADER(config.h)
7 # This will get text that should go into config.make.
8 config_vars=
10 # Check for a --with-gmp argument and set gmp-srcdir in config.make.
11 AC_ARG_WITH(gmp, dnl
12   --with-gmp=DIRECTORY    find GMP source code in DIRECTORY (not needed),
13             [dnl
14 case "$with_gmp" in
15 yes) AC_MSG_ERROR(--with-gmp requires an argument; use --with-gmp=DIRECTORY) ;;
16 ''|no) ;;
17 *) config_vars="$config_vars
18 gmp-srcdir = $withval" ;;
19 esac
22 dnl Arguments to specify presence of other packages/features.
23 AC_ARG_WITH(fp, dnl
24   --with-fp               if using floating-point hardware,
25             with_fp=$withval, with_fp=yes)
26 AC_ARG_WITH(gnu-binutils, dnl
27   --with-gnu-binutils     if using GNU binutils (as and ld),
28             gnu_binutils=$withval, gnu_binutils=no)
29 AC_ARG_WITH(gnu-ld, dnl
30   --with-gnu-ld           if using GNU ld (in the binutils package),
31             gnu_ld=$withval, gnu_ld=no)
32 AC_ARG_WITH(gnu-as, dnl
33   --with-gnu-as           if using GNU as (in the binutils package),
34             gnu_as=$withval, gnu_as=no)
35 test $gnu_binutils = yes && gnu_as=yes gnu_ld=yes
36 AC_ARG_WITH(elf, dnl
37   --with-elf              if using the ELF object format,
38             elf=$withval, elf=no)
39 AC_ARG_WITH(weak-symbols, dnl
40   --with-weak-symbols     if weak symbols are available in as and ld,
41             weak=$withval, weak=no)
43 dnl Arguments to enable or disable building the shared, profiled, and
44 dnl -fomit-frame-pointer libraries.
45 AC_ARG_ENABLE(shared, dnl
46 [  --enable-shared         build shared library [default=yes if GNU ld & ELF]],
47             shared=$enableval, shared=default)
48 AC_ARG_ENABLE(profile, dnl
49 [  --enable-profile        build profiled library [default=yes]],
50             profile=$enableval, profile=yes)
51 AC_ARG_ENABLE(omitfp, dnl
52 [  --enable-omitfp       build undebuggable optimized library [default=no]],
53             omitfp=$enableval, omitfp=no)
55 AC_CANONICAL_HOST
56 # We keep the original values in `$config_*' and never modify them, so we
57 # can write them unchanged into config.make.  Everything else uses
58 # $machine, $vendor, and $os, and changes them whenever convenient.
59 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
61 # Some configurations imply other options.
62 case "$host_os" in
63 gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
64   # These systems always use GNU tools.
65   gnu_ld=yes gnu_as=yes
66 esac
67 case "$host_os" in
68 gnu* | linux* | sysv4* | solaris2*)
69   # These systems always use the ELF format.
70   elf=yes
71 esac
73 # Compute the list of sysdep directories for this configuration.
74 sysdep_dir=$srcdir/sysdeps
75 AC_MSG_CHECKING(sysdep dirs)
76 AC_CACHE_VAL(libc_cv_sysdirs, [dnl
77 machine=$config_machine
78 vendor=$config_vendor
79 os=$config_os
81 dnl We need to use [ and ] for other purposes for a while now.
82 changequote(,)dnl
83 # Expand the configuration machine name into a subdirectory by architecture
84 # type and particular chip.
85 case "$machine" in
86 i[345]86)
87   machine=i386/$machine ;;
88 sparc[6789])
89   machine=sparc/$machine ;;
90 m68k)
91   machine=m68k/m68020 ;;
92 m680?0)
93   machine=m68k/$machine ;;
94 m88k)
95   machine=m88k/m88100 ;;
96 m88???)
97   machine=m88k/$machine ;;
98 mips64*)
99   machine=mips/mips64/$machine ;;
100 mips*)
101   machine=mips/$machine ;;
102 esac
104 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
105 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
107 case "$os" in
108 gnu*)
109   base_os=mach/hurd ;;
110 netbsd* | 386bsd* | freebsd* | bsdi*)
111   base_os=unix/bsd/bsd4.4 ;;
112 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
113   base_os=unix/bsd ;;
114 linux* | sysv* | isc* | esix* | sco* | minix* | irix4*)
115   base_os=unix/sysv ;;
116 solaris[2-9]*)
117   base_os=unix/sysv/sysv4 ;;
118 none)
119   base_os=standalone ;;
121   base_os='' ;;
122 esac
124 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
125 tail=$os
126 ostry=$os
127 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
128   ostry="$ostry /$o"
129   tail=$o
130 done  
131 o=`echo $tail | sed 's/[0-9]*$//'`
132 if test $o != $tail; then
133   ostry="$ostry /$o"
136 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
137 base=
138 tail=$base_os
139 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
140   set $b
141   base="$base /$1"
142   tail="$2"
143 done
145 # For sparc/sparc9, try sparc/sparc9 and then sparc.
146 mach=
147 tail=$machine
148 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
149   set $m
150   # Prepend the machine's FPU directory unless --without-fp.
151   if test "$with_fp" = yes; then
152     mach="$mach /$1/fpu"
153   fi
154   mach="$mach /$1"
155   tail="$2"
156 done
158 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
159 changequote([,])dnl
161 # Find what sysdep directories exist.
162 sysnames=
163 for b in $base ''; do
164   for m0 in $mach ''; do
165     for v in /$vendor ''; do
166       for o in /$ostry ''; do
167         for m in $mach ''; do
168           try="$m0$b$v$o$m"
169           if test -d $sysdep_dir$try; then
170             sysnames="$sysnames $try"
171             { test -n "$o" || test -n "$b"; } && os_used=t
172             { test -n "$m" || test -n "$m0"; } && machine_used=t
173           fi
174         done
175       done
176     done
177   done
178 done
180 if test -z "$os_used" && test "$os" != none; then
181   AC_MSG_ERROR(Operating system $os is not supported.)
183 if test -z "$machine_used" && test "$machine" != none; then
184   AC_MSG_ERROR(The $machine is not supported.)
187 # We have now validated the configuration.
190 # If using ELF, look for an `elf' subdirectory of each machine directory.
191 # We prepend these rather than inserting them whereever the machine appears
192 # because things specified by the machine's ELF ABI should override
193 # OS-specific things, and should always be the same for any OS on the
194 # machine (otherwise what's the point of an ABI?).
195 if test "$elf" = yes; then
196   elf_dirs=
197   for m in $mach; do
198     if test -d $sysdep_dir$m/elf; then
199       elf_dirs="$elf_dirs $m/elf"
200     fi
201   done
202   sysnames="`echo $elf_dirs | sed -e 's,^/,,' -e 's, /,,g'` $sysnames"
206 # Remove the leading slashes.
207 sysnames="`echo $sysnames | sed -e 's@^/@@' -e 's@ /@ @g'`"
210 # Expand the list of system names into a full list of directories
211 # from each element's parent name and Implies file (if present).
212 set $sysnames
213 while test $# -gt 0; do
214   name=$1
215   shift
217   if test -f $sysdep_dir/$name/Implies; then
218     # Collect more names from the `Implies' file (removing comments).
219     implied="`sed 's/#.*$//' < $sysdep_dir/$name/Implies`"
220     for x in $implied; do
221       test -d $sysdep_dir/$x || echo "Warning: $name implies nonexistent $x">&2
222     done
223   else
224     implied=
225   fi
227   # Add NAME to the list of names.
228   names="$names $name"
230   # Find the parent of NAME, using the empty string if it has none.
231 changequote(,)dnl
232   parent="`echo $name | sed -n -e '/\//!q' -e 's=/[^/]*$==p'`"
233 changequote([,])dnl
235   # Add the names implied by NAME, and NAME's parent (if it has one), to
236   # the list of names to be processed (the argument list).  We prepend the
237   # implied names to the list and append the parent.  We want implied
238   # directories to come before further directories inferred from the
239   # configuration components; this ensures that for sysv4, unix/common
240   # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
241   # after sysv4).
242   sysnames="`echo $implied $* $parent`"
243   test -n "$sysnames" && set $sysnames
244 done
246 # Add the default directories.
247 names="$names generic stub"
249 # Now uniquize the list.
250 seen=
251 sysnames=
252 for name in $names; do
253   if echo "$seen" | fgrep -x $name >/dev/null; then
254     # Already in the list.
255     true;
256   else
257     # A new one.
258     if test -z "$seen"; then
259       seen="$name" sysnames="$name"
260     else
261       seen="$seen
262 $name"
263       sysnames="$sysnames $name"
264     fi
265   fi
266 done
267 libc_cv_sysdirs="$sysnames"])
268 AC_SUBST(sysnames) sysnames="$libc_cv_sysdirs"
269 AC_MSG_RESULT(${sysnames})
271 AC_PROG_INSTALL
272 if test "$INSTALL" = "${srcdir}/install-sh"; then
273   # The makefiles need to use a different form to find it in $srcdir.
274   INSTALL='$(..)./install-sh'
277 AC_CHECK_TOOL(CC, gcc)
278 AC_CHECK_TOOL(AR, ar)
279 AC_CHECK_TOOL(RANLIB, ranlib, :)
280 AC_PROG_CPP
282 AC_MSG_CHECKING(signed size_t type)
283 AC_CACHE_VAL(libc_cv_signed_size_t, [dnl
284 echo '#include <stddef.h>
285 FOOBAR __SIZE_TYPE__ FOOBAR' > conftest.c
286 if eval "$ac_cpp conftest.c 2>/dev/null" \
287 | grep '^FOOBAR.*unsigned.*FOOBAR$' >/dev/null; then
288   libc_cv_signed_size_t=no
289 else
290   libc_cv_signed_size_t=yes
292 rm -f conftest*])
293 AC_MSG_RESULT($libc_cv_signed_size_t)
294 if test $libc_cv_signed_size_t = yes; then
295   dnl Do this by hand instead of AC_DEFINE so can add #undef to avoid warnings.
296   cat >> confdefs.h <<\EOF
297 #undef __SIZE_TYPE__
298 #define __SIZE_TYPE__ unsigned
302 AC_MSG_CHECKING(libc-friendly stddef.h)
303 AC_CACHE_VAL(libc_cv_friendly_stddef, [dnl
304 AC_TRY_COMPILE(dnl
305 [#define __need_size_t
306 #define __need_wchar_t
307 #include <stddef.h>
308 #define __need_NULL
309 #include <stddef.h>], [size_t size; wchar_t wchar;
310 #ifdef offsetof
311 #error stddef.h ignored __need_*
312 #endif
313 if (&size == NULL || &wchar == NULL) abort ();],
314                libc_cv_friendly_stddef=yes,
315                libc_cv_friendly_stddef=no)])
316 AC_MSG_RESULT($libc_cv_friendly_stddef)
317 if test $libc_cv_friendly_stddef = yes; then
318   config_vars="$config_vars
319 override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
322 AC_MSG_CHECKING(whether we need to use -P to assemble .S files)
323 AC_CACHE_VAL(libc_cv_need_minus_P, [dnl
324 cat > conftest.S <<EOF
325 #include "confdefs.h"
326 /* Nothing whatsoever.  */
328 if ${CC-cc} $CFLAGS -c conftest.S 2>/dev/null; then
329   libc_cv_need_minus_P=no
330 else
331   libc_cv_need_minus_P=yes
333 rm -f conftest*])
334 AC_MSG_RESULT($libc_cv_need_minus_P)
335 if test $libc_cv_need_minus_P = yes; then
336   config_vars="$config_vars
337 asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
340 AC_MSG_CHECKING(for assembler global-symbol directive)
341 AC_CACHE_VAL(libc_cv_asm_global_directive, [dnl
342 libc_cv_asm_global_directive=UNKNOWN
343 for ac_globl in .globl .global; do
344   cat > conftest.s <<EOF
345 .text
346 ${ac_globl} foo
347 foo: .long 0
349   if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
350     libc_cv_asm_global_directive=${ac_globl}
351   fi
352   rm -f conftest*
353   test $libc_cv_asm_global_directive != UNKNOWN && break
354 done])
355 AC_MSG_RESULT($libc_cv_asm_global_directive)
356 if test $libc_cv_asm_global_directive = UNKNOWN; then
357   AC_MSG_ERROR(cannot determine asm global directive)
358 else
359   AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${libc_cv_asm_global_directive})
362 AC_MSG_CHECKING(for .set assembler directive)
363 AC_CACHE_VAL(libc_cv_asm_set_directive, [dnl
364 cat > conftest.s <<EOF
365 .text
366 foo: .long 0
367 .set glibc_conftest_frobozz,foo
368 $libc_cv_asm_global_directive glibc_conftest_frobozz
370 # The alpha-dec-osf1 assembler gives only a warning for `.set'
371 # (but it doesn't work), so we must do a linking check to be sure.
372 cat > conftest1.c <<\EOF
373 extern int glibc_conftest_frobozz;
374 main () { printf ("%d\n", glibc_conftest_frobozz); }
376 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
377             conftest.s conftest1.c 1>&AC_FD_CC 2>&AC_FD_CC; then
378   libc_cv_asm_set_directive=yes
379 else
380   libc_cv_asm_set_directive=no
382 rm -f conftest*])
383 AC_MSG_RESULT($libc_cv_asm_set_directive)
384 if test $libc_cv_asm_set_directive = yes; then
385   AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
389 # sysdeps configure fragments may set these with files to be linked below.
390 libc_link_dests=
391 libc_link_sources=
393 # Iterate over all the sysdep directories we will use, running their
394 # configure fragments, and looking for a uname implementation.
395 uname=
396 for dir in $sysnames; do
397   if test -r $sysdep_dir/$dir/configure; then
398     AC_MSG_RESULT(running configure fragment for $dir)
399     . $sysdep_dir/$dir/configure
400   fi
401   if test -z "$uname"; then
402     { test -r $sysdep_dir/$dir/uname.c || test -r $sysdep_dir/$dir/uname.S; } \
403     && uname=$dir
404   fi
405 done
407 AC_LINK_FILES(`echo $libc_link_sources`, `echo $libc_link_dests`)
409 # If we will use the generic uname implementation, we must figure out what
410 # it will say by examining the system, and write the results in config-name.h.
411 if test "$uname" = generic; then
413 changequote(,)dnl
414   uname_sysname=`echo $config_os | sed 's/[0-9.]*$//'`
415 changequote([,])dnl
416   if test $uname_sysname != $config_os; then
417     config_release=`echo $config_os | sed s/$uname_sysname//`
418   fi
420 AC_DEFUN(LIBC_KERNEL_ID, [dnl
421     if test -r /vmunix; then
422       kernel_id=`strings /vmunix | grep UNIX`
423     elif test -r /dynix; then
424       kernel_id=`strings /dynix | grep DYNIX`
425     else
426       kernel_id=
427     fi
428 ])dnl
430   AC_MSG_CHECKING(OS release for uname)
431   AC_CACHE_VAL(libc_cv_uname_release, [dnl
432 AC_REQUIRE([LIBC_KERNEL_ID])dnl
433 changequote(,)dnl
434   kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'`
435 changequote([,])dnl
436   if test x`echo "$config_release" | sed "s/^$kernel_release//"` \
437          != x$config_release; then
438     # The configuration release is a substring of the kernel release.
439     libc_cv_uname_release=$kernel_release
440   elif test x$config_release != x; then
441     libc_cv_uname_release=$config_release
442   elif test x$kernel_release != x; then
443     libc_cv_uname_release=$kernel_release
444   else
445     libc_cv_uname_release=unknown
446   fi])
447   AC_MSG_RESULT($libc_cv_uname_release)
448   uname_release="$libc_cv_uname_release"
450   AC_MSG_CHECKING(OS version for uname)
451   AC_CACHE_VAL(libc_cv_uname_version, [dnl
452 AC_REQUIRE([LIBC_KERNEL_ID])dnl
453 changequote(,)dnl
454   kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'`
455 changequote([,])dnl
456   if test -n "$kernel_version"; then
457     libc_cv_uname_version="$kernel_version"
458   else
459     libc_cv_uname_version=unknown
460   fi])
461   AC_MSG_RESULT($libc_cv_uname_version)
462   uname_version="$libc_cv_uname_version"
464 AC_SUBST(uname_sysname) AC_SUBST(uname_release) AC_SUBST(uname_version)dnl
465   config_uname=config-name.h:config-name.in
466 else
467   # For non-generic uname, we don't need to create config-name.h at all.
468   config_uname=
471 AC_SUBST(gnu_ld) AC_SUBST(gnu_as) AC_SUBST(elf) AC_SUBST(weak)
472 if test $gnu_ld = yes; then
473   AC_DEFINE(HAVE_GNU_LD)
475 if test $gnu_as = yes; then
476   AC_DEFINE(HAVE_GNU_AS)
478 if test $elf = yes; then
479   AC_DEFINE(HAVE_ELF)
481 if test $weak = yes; then
482   AC_DEFINE(HAVE_WEAK_SYMBOLS)
485 AC_SUBST(shared)
486 if test $shared = default; then
487   if test $gnu_ld = yes; then
488     shared=$elf
489   fi
491 AC_SUBST(profile)
492 AC_SUBST(omitfp)
495 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
496   config_makefile=
497 else
498   config_makefile=Makefile
501 AC_OUTPUT(config.make ${config_makefile} ${config_uname}, ,
502           [echo '$config_vars' >> config.make])