initial import
[glibc.git] / configure.in
blob4d03b808cddb4a194aa6eb12971a928adb6e1b64
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION([$Id$])
3 AC_PREREQ(2.1)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 AC_ARG_WITH(gnu-binutils, dnl
23   --with-gnu-binutils     if using GNU binutils (as and ld),
24             gnu_binutils=yes, gnu_binutils=no)
25 AC_ARG_WITH(gnu-ld, dnl
26   --with-gnu-ld           if using GNU ld (in the binutils package),
27             gnu_ld=yes, gnu_ld=no)
28 AC_ARG_WITH(gnu-as, dnl
29   --with-gnu-as           if using GNU as (in the binutils package),
30             gnu_as=yes, gnu_as=no)
31 test $gnu_binutils = yes && gnu_as=yes gnu_ld=yes
32 AC_ARG_WITH(elf, dnl
33   --with-elf              if using the ELF object format,
34             elf=yes, elf=no)
35 AC_ARG_WITH(weak-symbols, dnl
36   --with-weak-symbols     if weak symbols are available in as and ld,
37             weak=yes, weak=no)
39 AC_CANONICAL_HOST
40 # We keep the original values in `$config_*' and never modify them, so we
41 # can write them unchanged into config.make.  Everything else uses
42 # $machine, $vendor, and $os, and changes them whenever convenient.
43 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
45 sysdep_dir=$srcdir/sysdeps
46 AC_MSG_CHECKING(sysdep dirs)
47 AC_CACHE_VAL(libc_cv_sysdirs, [dnl
48 machine=$config_machine
49 vendor=$config_vendor
50 os=$config_os
52 dnl We need to use [ and ] for other purposes for a while now.
53 changequote(,)dnl
54 # Expand the configuration machine name into a subdirectory by architecture
55 # type and particular chip.
56 case "$machine" in
57 i[345]86)
58   machine=i386/$machine ;;
59 sparc[6789])
60   machine=sparc/$machine ;;
61 m68k)
62   machine=m68k/m68020 ;;
63 m680?0)
64   machine=m68k/$machine ;;
65 m88k)
66   machine=m88k/m88100 ;;
67 m88???)
68   machine=m88k/$machine ;;
69 mips64*)
70   machine=mips/mips64/$machine ;;
71 mips*)
72   machine=mips/$machine ;;
73 esac
75 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
76 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
78 case "$os" in
79 gnu*)
80   base_os=mach/hurd ;;
81 netbsd* | 386bsd*)
82   base_os=unix/bsd/bsd4.4 ;;
83 osf1* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
84   base_os=unix/bsd ;;
85 linux* | sysv* | isc* | esix* | sco* | minix* | irix4*)
86   base_os=unix/sysv ;;
87 solaris[2-9]*)
88   base_os=unix/sysv/sysv4 ;;
89 none)
90   base_os=standalone ;;
92   base_os='' ;;
93 esac
95 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
96 tail=$os
97 ostry=$os
98 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
99   ostry="$ostry /$o"
100   tail=$o
101 done  
102 o=`echo $tail | sed 's/[0-9]*$//'`
103 if test $o != $tail; then
104   ostry="$ostry /$o"
107 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
108 base=
109 tail=$base_os
110 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
111   set $b
112   base="$base /$1"
113   tail="$2"
114 done
116 # For sparc/sparc9, try sparc/sparc9 and then sparc.
117 mach=
118 tail=$machine
119 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
120   set $m
121   mach="$mach /$1"
122   tail="$2"
123 done
125 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
126 changequote([,])dnl
128 # Find what sysdep directories exist.
129 sysnames=
130 for b in $base ''; do
131   for m0 in $mach ''; do
132     for v in /$vendor ''; do
133       for o in /$ostry ''; do
134         for m in $mach ''; do
135           try="$m0$b$v$o$m"
136           if test -d $sysdep_dir$try; then
137             sysnames="$sysnames $try"
138             { test -n "$o" || test -n "$b"; } && os_used=t
139             { test -n "$m" || test -n "$m0"; } && machine_used=t
140           fi
141         done
142       done
143     done
144   done
145 done
147 if test -z "$os_used" && test "$os" != none; then
148   AC_MSG_ERROR(Operating system $os is not supported.)
150 if test -z "$machine_used" && test "$machine" != none; then
151   AC_MSG_ERROR(The $machine is not supported.)
154 # We have now validated the configuration.
156 # Remove the leading slashes.
157 sysnames="`echo $sysnames | sed -e 's@^/@@' -e 's@ /@ @g'`"
159 # Prepend the machine's FPU directory unless --without-fp.
160 if test "$with_fp" = no; then
161   fpu_dirs=
162   for m in $mach; do
163     if test -d $sysdep_dir$m/fpu; then
164       fpu_dirs="$fpu_dirs $m/fpu"
165     fi
166   done
167   sysnames="`echo $fpu_dirs | sed -e 's,^/,,' -e 's, /,,g'` $sysnames"
170 # Expand the list of system names into a full list of directories
171 # from each element's parent name and Implies file (if present).
172 set $sysnames
173 while test $# -gt 0; do
174   name=$1
175   shift
177   if test -f $sysdep_dir/$name/Implies; then
178     # Collect more names from the `Implies' file (removing comments).
179     implied="`sed 's/#.*$//' < $sysdep_dir/$name/Implies`"
180     for x in $implied; do
181       test -d $sysdep_dir/$x || echo "Warning: $name implies nonexistent $x">&2
182     done
183   else
184     implied=
185   fi
187   # Add NAME to the list of names.
188   names="$names $name"
190   # Find the parent of NAME, using the empty string if it has none.
191 changequote(,)dnl
192   parent="`echo $name | sed -n -e '/\//!q' -e 's=/[^/]*$==p'`"
193 changequote([,])dnl
195   # Add the names implied by NAME, and NAME's parent (if it has one), to
196   # the list of names to be processed (the argument list).  We prepend the
197   # implied names to the list and append the parent.  We want implied
198   # directories to come before further directories inferred from the
199   # configuration components; this ensures that for sysv4, unix/common
200   # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
201   # after sysv4).
202   sysnames="`echo $implied $* $parent`"
203   test -n "$sysnames" && set $sysnames
204 done
206 # Add the default directories.
207 names="$names generic stub"
209 # Now uniquize the list.
210 seen=
211 sysnames=
212 for name in $names; do
213   if echo "$seen" | fgrep -x $name >/dev/null; then
214     # Already in the list.
215     true;
216   else
217     # A new one.
218     if test -z "$seen"; then
219       seen="$name" sysnames="$name"
220     else
221       seen="$seen
222 $name"
223       sysnames="$sysnames $name"
224     fi
225   fi
226 done
227 libc_cv_sysdirs="$sysnames"])
228 AC_SUBST(sysnames) sysnames="$libc_cv_sysdirs"
229 AC_MSG_RESULT(${sysnames})
231 case "$host_os" in
232 gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
233   gnu_ld=yes gnu_as=yes
234 esac
235 case "$host_os" in
236 gnu*elf* | linux*elf* | sysv4* | solaris2*)
237   elf=yes
238 esac
240 AC_PROG_INSTALL
241 if test "$INSTALL" = "${srcdir}/install-sh"; then
242   # The makefiles need to use a different form to find it in $srcdir.
243   INSTALL='$(..)./install-sh'
246 AC_PROG_CC
247 AC_PROG_CPP
248 AC_CHECK_PROG(AR, ar, ar, ar)
249 AC_PROG_RANLIB
251 AC_MSG_CHECKING(signed size_t type)
252 AC_CACHE_VAL(libc_cv_signed_size_t, [dnl
253 echo '#include <stddef.h>
254 FOOBAR __SIZE_TYPE__ FOOBAR' > conftest.c
255 if eval "$ac_cpp conftest.c 2>/dev/null" \
256 | grep '^FOOBAR.*unsigned.*FOOBAR$' >/dev/null; then
257   libc_cv_signed_size_t=no
258 else
259   libc_cv_signed_size_t=yes
261 rm -f conftest*])
262 AC_MSG_RESULT($libc_cv_signed_size_t)
263 if test $libc_cv_signed_size_t = yes; then
264   dnl Do this by hand instead of AC_DEFINE so can add #undef to avoid warnings.
265   cat >> confdefs.h <<\EOF
266 #undef __SIZE_TYPE__
267 #define __SIZE_TYPE__ unsigned
271 AC_MSG_CHECKING(libc-friendly stddef.h)
272 AC_CACHE_VAL(libc_cv_friendly_stddef, [dnl
273 AC_TRY_COMPILE(dnl
274 [#define __need_size_t
275 #define __need_wchar_t
276 #include <stddef.h>
277 #define __need_NULL
278 #include <stddef.h>], [size_t size; wchar_t wchar;
279 #ifdef offsetof
280 #error stddef.h ignored __need_*
281 #endif
282 if (&size == NULL || &wchar == NULL) abort ();],
283                libc_cv_friendly_stddef=yes,
284                libc_cv_friendly_stddef=no)])
285 AC_MSG_RESULT($libc_cv_friendly_stddef)
286 if test $libc_cv_friendly_stddef = yes; then
287   config_vars="$config_vars
288 override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
291 AC_MSG_CHECKING(whether we need to use -P to assemble .S files)
292 AC_CACHE_VAL(libc_cv_need_minus_P, [dnl
293 cat > conftest.S <<EOF
294 #include "confdefs.h"
295 /* Nothing whatsoever.  */
297 if ${CC-cc} $CFLAGS -c conftest.S 2>/dev/null; then
298   libc_cv_need_minus_P=no
299 else
300   libc_cv_need_minus_P=yes
302 rm -f conftest*])
303 AC_MSG_RESULT($libc_cv_need_minus_P)
304 if test $libc_cv_need_minus_P = yes; then
305   config_vars="$config_vars
306 asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
309 # sysdeps configure fragments may set these with files to be linked below.
310 libc_link_dests=
311 libc_link_sources=
313 # Iterate over all the sysdep directories we will use, running their
314 # configure fragments, and looking for a uname implementation.
315 uname=
316 for dir in $sysnames; do
317   if test -r $sysdep_dir/$dir/configure; then
318     AC_MSG_RESULT(running configure fragment for $dir)
319     . $sysdep_dir/$dir/configure
320   fi
321   if test -z "$uname"; then
322     { test -r $sysdep_dir/$dir/uname.c || test -r $sysdep_dir/$dir/uname.S; } \
323     && uname=$dir
324   fi
325 done
327 AC_LINK_FILES(`echo $libc_link_sources`, `echo $libc_link_dests`)
329 # If we will use the generic uname implementation, we must figure out what
330 # it will say by examining the system, and write the results in config-name.h.
331 if test "$uname" = generic; then
333 changequote(,)dnl
334   uname_sysname=`echo $config_os | sed 's/[0-9.]*$//'`
335 changequote([,])dnl
336   if test $uname_sysname != $config_os; then
337     config_release=`echo $config_os | sed s/$uname_sysname//`
338   fi
340 AC_DEFUN(LIBC_KERNEL_ID, [dnl
341     if test -r /vmunix; then
342       kernel_id=`strings /vmunix | grep UNIX`
343     elif test -r /dynix; then
344       kernel_id=`strings /dynix | grep DYNIX`
345     else
346       kernel_id=
347     fi
348 ])dnl
350   AC_MSG_CHECKING(OS release for uname)
351   AC_CACHE_VAL(libc_cv_uname_release, [dnl
352 AC_REQUIRE([LIBC_KERNEL_ID])dnl
353 changequote(,)dnl
354   kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'`
355 changequote([,])dnl
356   if test x`echo "$config_release" | sed "s/^$kernel_release//"` \
357          != x$config_release; then
358     # The configuration release is a substring of the kernel release.
359     libc_cv_uname_release=$kernel_release
360   elif test x$config_release != x; then
361     libc_cv_uname_release=$config_release
362   elif test x$kernel_release != x; then
363     libc_cv_uname_release=$kernel_release
364   else
365     libc_cv_uname_release=unknown
366   fi])
367   AC_MSG_RESULT($libc_cv_uname_release)
368   uname_release="$libc_cv_uname_release"
370   AC_MSG_CHECKING(OS version for uname)
371   AC_CACHE_VAL(libc_cv_uname_version, [dnl
372 AC_REQUIRE([LIBC_KERNEL_ID])dnl
373 changequote(,)dnl
374   kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'`
375 changequote([,])dnl
376   if test -n "$kernel_version"; then
377     libc_cv_uname_version="$kernel_version"
378   else
379     libc_cv_uname_version=unknown
380   fi])
381   AC_MSG_RESULT($libc_cv_uname_version)
382   uname_version="$libc_cv_uname_version"
384 AC_SUBST(uname_sysname) AC_SUBST(uname_release) AC_SUBST(uname_version)dnl
385   config_uname=config-name.h:config-name.in
386 else
387   # For non-generic uname, we don't need to create config-name.h at all.
388   config_uname=
391 AC_SUBST(gnu_ld) AC_SUBST(gnu_as) AC_SUBST(elf) AC_SUBST(weak)
392 if test $gnu_ld = yes; then
393   AC_DEFINE(HAVE_GNU_LD)
395 if test $gnu_as = yes; then
396   AC_DEFINE(HAVE_GNU_AS)
398 if test $elf = yes; then
399   AC_DEFINE(HAVE_ELF)
401 if test $weak = yes; then
402   AC_DEFINE(HAVE_WEAK_SYMBOLS)
406 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
407   config_makefile=
408 else
409   config_makefile=Makefile
412 AC_OUTPUT(config.make ${config_makefile} ${config_uname}, ,
413           [echo '$config_vars' >> config.make])