1 # configure.in for GNU CC
2 # Process this file with autoconf to generate a configuration script.
4 # Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
6 #This file is part of GNU CC.
8 #GNU CC is free software; you can redistribute it and/or modify
9 #it under the terms of the GNU General Public License as published by
10 #the Free Software Foundation; either version 2, or (at your option)
13 #GNU CC is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU General Public License for more details.
18 #You should have received a copy of the GNU General Public License
19 #along with GNU CC; see the file COPYING. If not, write to
20 #the Free Software Foundation, 59 Temple Place - Suite 330,
21 #Boston, MA 02111-1307, USA.
23 # Initialization and defaults
26 AC_CONFIG_HEADER(auto-host.h:config.in)
33 # Check for additional parameters
37 [ --with-gnu-ld arrange to work with GNU ld.],
38 gnu_ld_flag="$with_gnu_ld",
43 [ --with-ld arrange to use the specified ld (full pathname)],
44 DEFAULT_LINKER="$with_ld")
45 if test x"${DEFAULT_LINKER+set}" = x"set"; then
46 if test ! -x "$DEFAULT_LINKER"; then
47 AC_MSG_WARN([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER])
48 elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
51 AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER",
52 [Define to enable the use of a default linker.])
57 [ --with-gnu-as arrange to work with GNU as],
58 gas_flag="$with_gnu_as",
62 [ --with-as arrange to use the specified as (full pathname)],
63 DEFAULT_ASSEMBLER="$with_as")
64 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
65 if test ! -x "$DEFAULT_ASSEMBLER"; then
66 AC_MSG_WARN([cannot execute: $DEFAULT_ASSEMBLER: check --with-as or env. var. DEFAULT_ASSEMBLER])
67 elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
70 AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER",
71 [Define to enable the use of a default assembler.])
76 [ --with-stabs arrange to use stabs instead of host debug format],
82 [ --with-elf arrange to use ELF instead of host debug format],
86 # Specify the local prefix
88 AC_ARG_WITH(local-prefix,
89 [ --with-local-prefix=DIR specifies directory to put local include],
91 yes) AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;;
93 *) local_prefix=$with_local_prefix ;;
96 # Default local prefix if it is empty
97 if test x$local_prefix = x; then
98 local_prefix=/usr/local
101 # Enable Multibyte Characters for C/C++
102 AC_ARG_ENABLE(c-mbchar,
103 [ --enable-c-mbchar enable multibyte characters for C and C++],
104 if test x$enable_c_mbchar != xno; then
105 AC_DEFINE(MULTIBYTE_CHARS, 1,
106 [Define if you want the C and C++ compilers to support multibyte
107 character sets for source code.])
110 # Find the native compiler
113 # autoconf is lame and doesn't give us any substitution variable for this.
114 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
115 NO_MINUS_C_MINUS_O=yes
117 OUTPUT_OPTION='-o $@'
119 AC_SUBST(NO_MINUS_C_MINUS_O)
120 AC_SUBST(OUTPUT_OPTION)
125 # sizeof(char) is 1 by definition.
126 gcc_AC_COMPILE_CHECK_SIZEOF(short)
127 gcc_AC_COMPILE_CHECK_SIZEOF(int)
128 gcc_AC_COMPILE_CHECK_SIZEOF(long)
132 # If the native compiler is GCC, we can enable warnings even in stage1.
133 # That's useful for people building cross-compilers, or just running a
136 if test "x$GCC" = "xyes"; then
137 warn_cflags='$(GCC_WARN_CFLAGS)'
139 AC_SUBST(warn_cflags)
143 AC_MSG_CHECKING([whether a default assembler was specified])
144 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
145 if test x"$gas_flag" = x"no"; then
146 AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)])
148 AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)])
154 AC_MSG_CHECKING([whether a default linker was specified])
155 if test x"${DEFAULT_LINKER+set}" = x"set"; then
156 if test x"$gnu_ld_flag" = x"no"; then
157 AC_MSG_RESULT([yes ($DEFAULT_LINKER)])
159 AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)])
165 AC_MSG_CHECKING(for GNU C library)
166 AC_CACHE_VAL(gcc_cv_glibc,
168 [#include <features.h>],[
169 #if ! (defined __GLIBC__ || defined __GNU_LIBRARY__)
170 #error Not a GNU C library system
174 AC_MSG_RESULT($gcc_cv_glibc)
175 if test $gcc_cv_glibc = yes; then
176 AC_DEFINE(_GNU_SOURCE, 1, [Always define this when using the GNU C Library])
179 # Find some useful tools
189 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \
190 fcntl.h unistd.h sys/file.h sys/time.h \
191 sys/resource.h sys/param.h sys/times.h sys/stat.h \
192 direct.h malloc.h langinfo.h)
194 # Check for thread headers.
196 # These tests can't be done till we know if we have limits.h.
198 gcc_AC_C_COMPILE_ENDIAN
200 # See if we have the mktemp command.
201 AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no)
203 # See if the stage1 system preprocessor understands the ANSI C
204 # preprocessor stringification operator. (Used by symcat.h.)
207 # Use <inttypes.h> only if it exists,
208 # doesn't clash with <sys/types.h>, and declares intmax_t.
209 AC_MSG_CHECKING(for inttypes.h)
210 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
212 [#include <sys/types.h>
213 #include <inttypes.h>],
215 [gcc_cv_header_inttypes_h=yes],
216 gcc_cv_header_inttypes_h=no)])
217 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
218 if test $gcc_cv_header_inttypes_h = yes; then
219 AC_DEFINE(HAVE_INTTYPES_H, 1,
220 [Define if you have a working <inttypes.h> header file.])
223 dnl Disabled until we have a complete test for buggy enum bitfields.
224 dnl gcc_AC_C_ENUM_BF_UNSIGNED
226 AC_CHECK_FUNCS(times clock strchr strrchr lstat)
228 AC_CHECK_TYPE(ssize_t, int)
230 AC_FUNC_MMAP_ANYWHERE
233 # We will need to find libiberty.h and ansidecl.h
234 saved_CFLAGS="$CFLAGS"
235 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
236 gcc_AC_CHECK_DECLS(getenv abort errno \
237 malloc realloc calloc free getopt clock, , ,[
238 #include "ansidecl.h"
239 #include "system.h"])
241 gcc_AC_CHECK_DECLS(times, , ,[
242 #include "ansidecl.h"
244 #ifdef HAVE_SYS_TIMES_H
245 #include <sys/times.h>
249 # More time-related stuff.
250 AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [
252 #include "ansidecl.h"
254 #ifdef HAVE_SYS_TIMES_H
255 #include <sys/times.h>
257 ], [struct tms tms;], ac_cv_struct_tms=yes, ac_cv_struct_tms=no)])
258 if test $ac_cv_struct_tms = yes; then
259 AC_DEFINE(HAVE_STRUCT_TMS, 1,
260 [Define if <sys/times.h> defines struct tms.])
263 # use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
264 # revisit after autoconf 2.50.
265 AC_CACHE_CHECK(for clock_t, gcc_cv_type_clock_t, [
267 #include "ansidecl.h"
269 ], [clock_t x;], gcc_cv_type_clock_t=yes, gcc_cv_type_clock_t=no)])
270 if test $gcc_cv_type_clock_t = yes; then
271 AC_DEFINE(HAVE_CLOCK_T, 1,
272 [Define if <time.h> defines clock_t.])
275 # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
276 CFLAGS="$saved_CFLAGS"
278 # mkdir takes a single argument on some systems.
279 gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
289 build_install_headers_dir=install-headers-tar
294 host_truncate_target=
297 # Decode the host machine, then the target machine.
298 # For the host machine, we save the xm_file variable as host_xm_file;
299 # then we decode the target machine and forget everything else
300 # that came from the host machine.
301 #for machine in $build $host $target; do
302 # . ${srcdir}/config.gcc
305 extra_objs="${host_extra_objs} ${extra_objs}"
307 # Default the target-machine variables that were not explicitly set.
308 if test x"$tm_file" = x
309 then tm_file=$cpu_type/$cpu_type.h; fi
311 if test x"$extra_headers" = x
312 then extra_headers=; fi
314 if test x$md_file = x
315 then md_file=$cpu_type/$cpu_type.md; fi
317 if test x$out_file = x
318 then out_file=$cpu_type/$cpu_type.c; fi
320 if test x"$tmake_file" = x
321 then tmake_file=$cpu_type/t-$cpu_type
324 if test x"$dwarf2" = xyes
325 then tm_file="$tm_file tm-dwarf2.h"
328 # Handle cpp installation.
329 if test x$enable_cpp != xno
331 tmake_file="$tmake_file t-install-cpp"
334 # auto-host.h is the file containing items generated by autoconf and is
335 # the first file included by config.h.
336 # If host=build, it is correct to have hconfig include auto-host.h
337 # as well. If host!=build, we are in error and need to do more
338 # work to find out the build config parameters.
339 if test x$host = x$build
341 build_auto=auto-host.h
343 # We create a subdir, then run autoconf in the subdir.
344 # To prevent recursion we set host and build for the new
345 # invocation of configure to the build for this invocation
352 /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
353 *) realsrcdir=../${srcdir};;
355 CC=${CC_FOR_BUILD} ${realsrcdir}/configure \
356 --target=$target --host=$build --build=$build
358 # We just finished tests for the build machine, so rename
359 # the file auto-build.h in the gcc directory.
360 mv auto-host.h ../auto-build.h
363 build_auto=auto-build.h
366 tm_file="${tm_file} defaults.h"
367 host_xm_file="auto-host.h ansidecl.h ${host_xm_file} ${tm_file}"
368 build_xm_file="${build_auto} ansidecl.h ${build_xm_file} ${tm_file}"
369 xm_file="ansidecl.h ${xm_file} ${tm_file}"
371 # Truncate the target if necessary
372 if test x$host_truncate_target != x; then
373 target=`echo $target | sed -e 's/\(..............\).*/\1/'`
376 # Get the version trigger filename from the toplevel
377 if test "${with_gcc_version_trigger+set}" = set; then
378 gcc_version_trigger=$with_gcc_version_trigger
380 gcc_version_trigger=${srcdir}/version.c
383 gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*"\([^"]*\)".*/\1/'`
384 gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
386 # Compile in configure arguments.
387 if test -f configargs.h ; then
388 # Being re-configured.
389 gcc_config_arguments=`grep configuration_arguments configargs.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
390 gcc_config_arguments="$gcc_config_arguments : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS"
392 gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS"
394 cat > configargs.h <<EOF
395 /* Generated automatically. */
396 static const char configuration_arguments[] = "$gcc_config_arguments";
397 static const char thread_model[] = "$thread_file";
401 # Internationalization
403 VERSION="$gcc_version"
404 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",
405 [Define to the name of the distribution.])
406 AC_DEFINE_UNQUOTED(VERSION, "$VERSION",
407 [Define to the version of the distribution.])
413 # Get an absolute path to the GCC top-level source directory
419 out_object_file=`basename $out_file .c`.o
421 # Figure out what assembler we will be using.
422 AC_MSG_CHECKING(what assembler to use)
424 gcc_cv_gas_major_version=
425 gcc_cv_gas_minor_version=
426 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
427 if test -x "$DEFAULT_ASSEMBLER"; then
428 gcc_cv_as="$DEFAULT_ASSEMBLER"
429 elif test -x "$AS"; then
431 elif test -x as$host_exeext; then
432 # Build using assembler in the current directory.
433 gcc_cv_as=./as$host_exeext
434 elif test -f $gcc_cv_as_gas_srcdir/configure.in -a -f ../gas/Makefile; then
435 # Single tree build which includes gas.
436 for f in $gcc_cv_as_gas_srcdir/configure $gcc_cv_as_gas_srcdir/configure.in $gcc_cv_as_gas_srcdir/Makefile.in
439 gcc_cv_gas_version=`grep '^VERSION=[0-9]*\.[0-9]*' $f`
441 if test x$gcc_cv_gas_version != x; then
446 gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([0-9]*\)"`
447 gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
451 if test "x$gcc_cv_as" = x -a x$host = x$target; then
453 # Search the same directories that the installed compiler will
454 # search. Else we may find the wrong assembler and lose. If we
455 # do not find a suitable assembler binary, then try the user's
458 # Also note we have to check MD_EXEC_PREFIX before checking the
459 # user's path. Unfortunately, there is no good way to get at the
460 # value of MD_EXEC_PREFIX here. So we do a brute force search
461 # through all the known MD_EXEC_PREFIX values. Ugh. This needs
462 # to be fixed as part of the make/configure rewrite too.
464 if test "x$exec_prefix" = xNONE; then
465 if test "x$prefix" = xNONE; then
466 test_prefix=/usr/local
471 test_prefix=$exec_prefix
474 # If the loop below does not find an assembler, then use whatever
475 # one we can find in the users's path.
477 gcc_cv_as=as$host_exeext
479 test_dirs="$test_prefix/lib/gcc-lib/$target/$gcc_version \
480 $test_prefix/lib/gcc-lib/$target \
481 /usr/lib/gcc/$target/$gcc_version \
482 /usr/lib/gcc/$target \
483 $test_prefix/$target/bin/$target/$gcc_version \
484 $test_prefix/$target/bin \
489 /bsd43/usr/lib/cmplrs/cc \
490 /usr/cross64/usr/bin \
492 /sysv/usr/lib/cmplrs/cc \
493 /svr4/usr/lib/cmplrs/cc \
496 for dir in $test_dirs; do
497 if test -f $dir/as$host_exeext; then
498 gcc_cv_as=$dir/as$host_exeext
503 if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
504 AC_MSG_RESULT("newly built gas")
506 AC_MSG_RESULT($gcc_cv_as)
509 # Figure out what nm we will be using.
510 AC_MSG_CHECKING(what nm to use)
511 if test -x nm$host_exeext; then
512 gcc_cv_nm=./nm$host_exeext
513 elif test x$host = x$target; then
515 gcc_cv_nm=nm$host_exeext
517 AC_MSG_RESULT($gcc_cv_nm)
519 dnl Very limited version of automake's enable-maintainer-mode
521 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
522 dnl maintainer-mode is disabled by default
523 AC_ARG_ENABLE(maintainer-mode,
524 [ --enable-maintainer-mode
525 enable make rules and dependencies not useful
526 (and sometimes confusing) to the casual installer],
527 maintainer_mode=$enableval,
530 AC_MSG_RESULT($maintainer_mode)
532 if test "$maintainer_mode" = "yes"; then
539 # These (without "all_") are set in each config-lang.in.
540 # `language' must be a single word so is spelled singularly.
542 all_outputs='Makefile'
543 # List of language makefile fragments.
545 # Add the language fragments.
546 # Languages are added via two mechanisms. Some information must be
547 # recorded in makefile variables, these are defined in config-lang.in.
548 # We accumulate them and plug them into the main Makefile.
549 # The other mechanism is a set of hooks for each of the main targets
550 # like `clean', `install', etc.
552 language_fragments="Make-lang"
554 # Define variables host_canonical and build_canonical
555 # because some Cygnus local changes in the Makefile depend on them.
556 build_canonical=${build}
557 host_canonical=${host}
559 if test "${host}" != "${target}" ; then
560 target_subdir=${target_alias}/
562 AC_SUBST(build_canonical)
563 AC_SUBST(host_canonical)
564 AC_SUBST(target_subdir)
566 # Nothing to do for FLOAT_H, float_format already handled.
570 # Substitute configuration variables
571 AC_SUBST(all_stagestuff)
572 AC_SUBST(build_exeext)
573 AC_SUBST(build_install_headers_dir)
574 AC_SUBST(build_xm_file_list)
575 AC_SUBST(build_xm_file)
576 AC_SUBST(build_xm_defines)
577 AC_SUBST(check_languages)
578 AC_SUBST(dep_host_xmake_file)
579 AC_SUBST(dep_tmake_file)
580 AC_SUBST(extra_c_flags)
581 AC_SUBST(extra_headers_list)
583 AC_SUBST(extra_parts)
584 AC_SUBST(extra_passes)
585 AC_SUBST(extra_programs)
586 AC_SUBST(gcc_config_arguments)
587 AC_SUBST(gcc_version)
588 AC_SUBST(gcc_version_full)
589 AC_SUBST(gcc_version_trigger)
590 AC_SUBST(host_exeext)
591 AC_SUBST(host_extra_gcc_objs)
593 AC_SUBST(lang_tree_files)
594 AC_SUBST(local_prefix)
597 AC_SUBST(out_object_file)
598 AC_SUBST(symbolic_link)
599 AC_SUBST(thread_file)
600 AC_SUBST(c_target_objs)
602 AC_SUBST_FILE(target_overrides)
603 AC_SUBST_FILE(host_overrides)
604 AC_SUBST(cross_defines)
605 AC_SUBST_FILE(cross_overrides)
606 AC_SUBST_FILE(build_overrides)
608 # Create the Makefile
609 # and configure language subdirectories
610 AC_OUTPUT($all_outputs,
612 case x$CONFIG_HEADERS in
613 xauto-host.h:config.in)
617 # Avoid having to add intl to our include paths.
618 if test -f intl/libintl.h; then
619 echo creating libintl.h
620 echo '#include "intl/libintl.h"' >libintl.h
627 target_alias='${target_alias}'
629 symbolic_link='${symbolic_link}'
630 program_transform_set='${program_transform_set}'
631 program_transform_name='${program_transform_name}'
632 dep_host_xmake_file='${dep_host_xmake_file}'
633 host_xmake_file='${host_xmake_file}'
634 dep_tmake_file='${dep_tmake_file}'
635 tmake_file='${tmake_file}'
636 thread_file='${thread_file}'
637 gcc_config_arguments='${gcc_config_arguments}'
638 gcc_version='${gcc_version}'
639 gcc_version_full='${gcc_version_full}'
640 gcc_version_trigger='${gcc_version_trigger}'
641 local_prefix='${local_prefix}'
642 build_install_headers_dir='${build_install_headers_dir}'
643 build_exeext='${build_exeext}'
644 host_exeext='${host_exeext}'
645 out_file='${out_file}'
646 gdb_needs_out_file_path='${gdb_needs_out_file_path}'
647 SET_MAKE='${SET_MAKE}'
648 target_list='${target_list}'
649 target_overrides='${target_overrides}'
650 host_overrides='${host_overrides}'
651 cross_defines='${cross_defines}'
652 cross_overrides='${cross_overrides}'
653 build_overrides='${build_overrides}'
654 cpp_install_dir='${cpp_install_dir}'