(PAD): use return value of _IO_padn. (buffered_vfprintf): remove line buffer when...
[glibc.git] / configure.in
blob28314ca5a413fe73fded345ac67644619be24211
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(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
33 AC_ARG_WITH(elf, dnl
34   --with-elf              if using the ELF object format,
35             elf=yes, elf=no)
36 AC_ARG_WITH(weak-symbols, dnl
37   --with-weak-symbols     if weak symbols are available in as and ld,
38             weak=yes, weak=no)
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)
52 AC_CANONICAL_HOST
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
62 vendor=$config_vendor
63 os=$config_os
65 dnl We need to use [ and ] for other purposes for a while now.
66 changequote(,)dnl
67 # Expand the configuration machine name into a subdirectory by architecture
68 # type and particular chip.
69 case "$machine" in
70 i[345]86)
71   machine=i386/$machine ;;
72 sparc[6789])
73   machine=sparc/$machine ;;
74 m68k)
75   machine=m68k/m68020 ;;
76 m680?0)
77   machine=m68k/$machine ;;
78 m88k)
79   machine=m88k/m88100 ;;
80 m88???)
81   machine=m88k/$machine ;;
82 mips64*)
83   machine=mips/mips64/$machine ;;
84 mips*)
85   machine=mips/$machine ;;
86 esac
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'`"
91 case "$os" in
92 gnu*)
93   base_os=mach/hurd ;;
94 netbsd* | 386bsd*)
95   base_os=unix/bsd/bsd4.4 ;;
96 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
97   base_os=unix/bsd ;;
98 linux* | sysv* | isc* | esix* | sco* | minix* | irix4*)
99   base_os=unix/sysv ;;
100 solaris[2-9]*)
101   base_os=unix/sysv/sysv4 ;;
102 none)
103   base_os=standalone ;;
105   base_os='' ;;
106 esac
108 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
109 tail=$os
110 ostry=$os
111 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
112   ostry="$ostry /$o"
113   tail=$o
114 done  
115 o=`echo $tail | sed 's/[0-9]*$//'`
116 if test $o != $tail; then
117   ostry="$ostry /$o"
120 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
121 base=
122 tail=$base_os
123 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
124   set $b
125   base="$base /$1"
126   tail="$2"
127 done
129 # For sparc/sparc9, try sparc/sparc9 and then sparc.
130 mach=
131 tail=$machine
132 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
133   set $m
134   mach="$mach /$1"
135   tail="$2"
136 done
138 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
139 changequote([,])dnl
141 # Find what sysdep directories exist.
142 sysnames=
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
148           try="$m0$b$v$o$m"
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
153           fi
154         done
155       done
156     done
157   done
158 done
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
174   fpu_dirs=
175   for m in $mach; do
176     if test -d $sysdep_dir$m/fpu; then
177       fpu_dirs="$fpu_dirs $m/fpu"
178     fi
179   done
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).
185 set $sysnames
186 while test $# -gt 0; do
187   name=$1
188   shift
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
195     done
196   else
197     implied=
198   fi
200   # Add NAME to the list of names.
201   names="$names $name"
203   # Find the parent of NAME, using the empty string if it has none.
204 changequote(,)dnl
205   parent="`echo $name | sed -n -e '/\//!q' -e 's=/[^/]*$==p'`"
206 changequote([,])dnl
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 $*)
214   # after sysv4).
215   sysnames="`echo $implied $* $parent`"
216   test -n "$sysnames" && set $sysnames
217 done
219 # Add the default directories.
220 names="$names generic stub"
222 # Now uniquize the list.
223 seen=
224 sysnames=
225 for name in $names; do
226   if echo "$seen" | fgrep -x $name >/dev/null; then
227     # Already in the list.
228     true;
229   else
230     # A new one.
231     if test -z "$seen"; then
232       seen="$name" sysnames="$name"
233     else
234       seen="$seen
235 $name"
236       sysnames="$sysnames $name"
237     fi
238   fi
239 done
240 libc_cv_sysdirs="$sysnames"])
241 AC_SUBST(sysnames) sysnames="$libc_cv_sysdirs"
242 AC_MSG_RESULT(${sysnames})
244 case "$host_os" in
245 gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
246   gnu_ld=yes gnu_as=yes
247 esac
248 case "$host_os" in
249 gnu*elf* | linux*elf* | sysv4* | solaris2*)
250   elf=yes
251 esac
253 AC_PROG_INSTALL
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, :)
262 AC_PROG_CPP
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
271 else
272   libc_cv_signed_size_t=yes
274 rm -f conftest*])
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
279 #undef __SIZE_TYPE__
280 #define __SIZE_TYPE__ unsigned
284 AC_MSG_CHECKING(libc-friendly stddef.h)
285 AC_CACHE_VAL(libc_cv_friendly_stddef, [dnl
286 AC_TRY_COMPILE(dnl
287 [#define __need_size_t
288 #define __need_wchar_t
289 #include <stddef.h>
290 #define __need_NULL
291 #include <stddef.h>], [size_t size; wchar_t wchar;
292 #ifdef offsetof
293 #error stddef.h ignored __need_*
294 #endif
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
312 else
313   libc_cv_need_minus_P=yes
315 rm -f conftest*])
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.
323 libc_link_dests=
324 libc_link_sources=
326 # Iterate over all the sysdep directories we will use, running their
327 # configure fragments, and looking for a uname implementation.
328 uname=
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
333   fi
334   if test -z "$uname"; then
335     { test -r $sysdep_dir/$dir/uname.c || test -r $sysdep_dir/$dir/uname.S; } \
336     && uname=$dir
337   fi
338 done
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
346 changequote(,)dnl
347   uname_sysname=`echo $config_os | sed 's/[0-9.]*$//'`
348 changequote([,])dnl
349   if test $uname_sysname != $config_os; then
350     config_release=`echo $config_os | sed s/$uname_sysname//`
351   fi
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`
358     else
359       kernel_id=
360     fi
361 ])dnl
363   AC_MSG_CHECKING(OS release for uname)
364   AC_CACHE_VAL(libc_cv_uname_release, [dnl
365 AC_REQUIRE([LIBC_KERNEL_ID])dnl
366 changequote(,)dnl
367   kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'`
368 changequote([,])dnl
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
377   else
378     libc_cv_uname_release=unknown
379   fi])
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
386 changequote(,)dnl
387   kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'`
388 changequote([,])dnl
389   if test -n "$kernel_version"; then
390     libc_cv_uname_version="$kernel_version"
391   else
392     libc_cv_uname_version=unknown
393   fi])
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
399 else
400   # For non-generic uname, we don't need to create config-name.h at all.
401   config_uname=
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
412   AC_DEFINE(HAVE_ELF)
414 if test $weak = yes; then
415   AC_DEFINE(HAVE_WEAK_SYMBOLS)
418 AC_SUBST(shared)
419 if test $shared = default; then
420   if test $gnu_ld = yes; then
421     shared=$elf
422   fi
424 AC_SUBST(profile)
425 AC_SUBST(omitfp)
428 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
429   config_makefile=
430 else
431   config_makefile=Makefile
434 AC_OUTPUT(config.make ${config_makefile} ${config_uname}, ,
435           [echo '$config_vars' >> config.make])