1# configure.in for GCC 2# Process this file with autoconf to generate a configuration script. 3 4# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 5 6#This file is part of GCC. 7 8#GCC is free software; you can redistribute it and/or modify it under 9#the terms of the GNU General Public License as published by the Free 10#Software Foundation; either version 2, or (at your option) any later 11#version. 12 13#GCC is distributed in the hope that it will be useful, but WITHOUT 14#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16#for more details. 17 18#You should have received a copy of the GNU General Public License 19#along with GCC; see the file COPYING. If not, write to the Free 20#Software Foundation, 59 Temple Place - Suite 330, Boston, MA 21#02111-1307, USA. 22 23# Initialization and defaults 24AC_PREREQ(2.60) 25AC_INIT(sdcpp.c) 26AC_CONFIG_HEADER(auto-host.h:config.in) 27 28remove=rm 29hard_link=ln 30symbolic_link='ln -s' 31copy=cp 32 33# Check for additional parameters 34 35# With GNU ld 36AC_ARG_WITH(gnu-ld, 37[ --with-gnu-ld arrange to work with GNU ld.], 38gnu_ld_flag="$with_gnu_ld", 39gnu_ld_flag=no) 40 41# With pre-defined ld 42AC_ARG_WITH(ld, 43[ --with-ld arrange to use the specified ld (full pathname)], 44DEFAULT_LINKER="$with_ld") 45if 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 49 gnu_ld_flag=yes 50 fi 51 AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER", 52 [Define to enable the use of a default linker.]) 53fi 54 55# With GNU as 56AC_ARG_WITH(gnu-as, 57[ --with-gnu-as arrange to work with GNU as], 58gas_flag="$with_gnu_as", 59gas_flag=no) 60 61AC_ARG_WITH(as, 62[ --with-as arrange to use the specified as (full pathname)], 63DEFAULT_ASSEMBLER="$with_as") 64if 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 68 gas_flag=yes 69 fi 70 AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER", 71 [Define to enable the use of a default assembler.]) 72fi 73 74# With stabs 75AC_ARG_WITH(stabs, 76[ --with-stabs arrange to use stabs instead of host debug format], 77stabs="$with_stabs", 78stabs=no) 79 80# With ELF 81AC_ARG_WITH(elf, 82[ --with-elf arrange to use ELF instead of host debug format], 83elf="$with_elf", 84elf=no) 85 86# Specify the local prefix 87local_prefix= 88AC_ARG_WITH(local-prefix, 89[ --with-local-prefix=DIR specifies directory to put local include], 90[case "${withval}" in 91yes) AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;; 92no) ;; 93*) local_prefix=$with_local_prefix ;; 94esac]) 95 96# Default local prefix if it is empty 97if test x$local_prefix = x; then 98 local_prefix=/usr/local 99fi 100 101AC_ARG_PROGRAM 102 103# Enable Multibyte Characters for C/C++ 104AC_ARG_ENABLE(c-mbchar, 105[ --enable-c-mbchar enable multibyte characters for C and C++], 106if test x$enable_c_mbchar != xno; then 107 AC_DEFINE(MULTIBYTE_CHARS, 1, 108 [Define if you want the C and C++ compilers to support multibyte 109 character sets for source code.]) 110fi) 111 112# Find the native compiler 113AC_PROG_CC 114AC_PROG_CC_C_O 115# autoconf is lame and doesn't give us any substitution variable for this. 116if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then 117 NO_MINUS_C_MINUS_O=yes 118else 119 OUTPUT_OPTION='-o $@' 120fi 121AC_SUBST(NO_MINUS_C_MINUS_O) 122AC_SUBST(OUTPUT_OPTION) 123 124AC_PROG_CPP 125AC_C_INLINE 126 127gcc_AC_C__BOOL 128 129# sizeof(char) is 1 by definition. 130gcc_AC_COMPILE_CHECK_SIZEOF(short) 131gcc_AC_COMPILE_CHECK_SIZEOF(int) 132gcc_AC_COMPILE_CHECK_SIZEOF(long) 133 134gcc_AC_C_CHARSET 135 136# If the native compiler is GCC, we can enable warnings even in stage1. 137# That's useful for people building cross-compilers, or just running a 138# quick `make'. 139warn_cflags= 140if test "x$GCC" = "xyes"; then 141 warn_cflags='$(GCC_WARN_CFLAGS)' 142fi 143AC_SUBST(warn_cflags) 144 145AC_PROG_MAKE_SET 146 147AC_MSG_CHECKING([whether a default assembler was specified]) 148if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then 149 if test x"$gas_flag" = x"no"; then 150 AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)]) 151 else 152 AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)]) 153 fi 154else 155 AC_MSG_RESULT(no) 156fi 157 158AC_MSG_CHECKING([whether a default linker was specified]) 159if test x"${DEFAULT_LINKER+set}" = x"set"; then 160 if test x"$gnu_ld_flag" = x"no"; then 161 AC_MSG_RESULT([yes ($DEFAULT_LINKER)]) 162 else 163 AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)]) 164 fi 165else 166 AC_MSG_RESULT(no) 167fi 168 169# Find some useful tools 170AC_PROG_AWK 171# We need awk to run opts.sh (to create options.c and options.h). 172# Bail out if it's missing. 173case ${AWK} in 174 "") AC_MSG_ERROR([can't build without awk, bailing out]) ;; 175esac 176 177gcc_AC_PROG_LN 178gcc_AC_PROG_LN_S 179AC_PROG_RANLIB 180gcc_AC_PROG_INSTALL 181 182AC_HEADER_STDC 183AC_HEADER_TIME 184gcc_AC_HEADER_STDBOOL 185gcc_AC_HEADER_STRING 186AC_HEADER_SYS_WAIT 187AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \ 188 fcntl.h unistd.h sys/file.h sys/time.h \ 189 sys/param.h sys/stat.h \ 190 direct.h malloc.h) 191 192# Check for thread headers. 193 194# These tests can't be done till we know if we have limits.h. 195gcc_AC_C_CHAR_BIT 196AC_C_BIGENDIAN 197 198# See if we have the mktemp command. 199AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no) 200 201AC_CHECK_PROG(STRIP, strip, strip, :) 202AC_CHECK_PROG(AR, ar, ar, :) 203 204# See if the stage1 system preprocessor understands the ANSI C 205# preprocessor stringification operator. (Used by symcat.h.) 206AC_C_STRINGIZE 207 208dnl Disabled until we have a complete test for buggy enum bitfields. 209dnl gcc_AC_C_ENUM_BF_UNSIGNED 210 211AC_CHECK_FUNCS(clock strsignal strchr strrchr lstat) 212 213AC_CHECK_TYPE(ssize_t, int) 214 215AC_FUNC_MMAP_ANYWHERE 216AC_FUNC_MMAP_FILE 217 218# We will need to find libiberty.h and ansidecl.h 219saved_CFLAGS="$CFLAGS" 220CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/libiberty -I${srcdir}/libcpp/include" 221gcc_AC_CHECK_DECLS(getenv abort strsignal errno \ 222 malloc realloc calloc free clock, , ,[ 223#include "ansidecl.h" 224#include "system.h"]) 225 226# Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. 227CFLAGS="$saved_CFLAGS" 228 229# Try to append a c99 flag 230AC_PROG_CC_C99 231if test "$ac_cv_prog_cc_c99" != "no"; then 232 CFLAGS="$ac_cv_prog_cc_c99 ${CFLAGS}" 233fi 234 235# mkdir takes a single argument on some systems. 236gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG 237 238# File extensions 239manext='.1' 240objext='.o' 241AC_SUBST(manext) 242AC_SUBST(objext) 243 244build_xm_file= 245build_xm_defines= 246build_install_headers_dir=install-headers-tar 247build_exeext= 248host_xm_file= 249host_xm_defines= 250host_xmake_file= 251host_truncate_target= 252host_exeext= 253 254# Decode the host machine, then the target machine. 255# For the host machine, we save the xm_file variable as host_xm_file; 256# then we decode the target machine and forget everything else 257# that came from the host machine. 258#for machine in $build $host $target; do 259# . ${srcdir}/config.gcc 260#done 261 262extra_objs="${host_extra_objs} ${extra_objs}" 263 264# Default the target-machine variables that were not explicitly set. 265if test x"$tm_file" = x 266then tm_file=$cpu_type/$cpu_type.h; fi 267 268if test x"$extra_headers" = x 269then extra_headers=; fi 270 271if test x$md_file = x 272then md_file=$cpu_type/$cpu_type.md; fi 273 274if test x$out_file = x 275then out_file=$cpu_type/$cpu_type.c; fi 276 277if test x"$tmake_file" = x 278then tmake_file=$cpu_type/t-$cpu_type 279fi 280 281if test x"$dwarf2" = xyes 282then tm_file="$tm_file tm-dwarf2.h" 283fi 284 285# Handle cpp installation. 286if test x$enable_cpp != xno 287then 288 tmake_file="$tmake_file t-install-cpp" 289fi 290 291# auto-host.h is the file containing items generated by autoconf and is 292# the first file included by config.h. 293# If host=build, it is correct to have hconfig include auto-host.h 294# as well. If host!=build, we are in error and need to do more 295# work to find out the build config parameters. 296if test x$host = x$build 297then 298 build_auto=auto-host.h 299else 300 # We create a subdir, then run autoconf in the subdir. 301 # To prevent recursion we set host and build for the new 302 # invocation of configure to the build for this invocation 303 # of configure. 304 tempdir=build.$$ 305 rm -rf $tempdir 306 mkdir $tempdir 307 cd $tempdir 308 case ${srcdir} in 309 /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};; 310 *) realsrcdir=../${srcdir};; 311 esac 312 CC=${CC_FOR_BUILD} ${realsrcdir}/configure \ 313 --target=$target --host=$build --build=$build 314 315 # We just finished tests for the build machine, so rename 316 # the file auto-build.h in the gcc directory. 317 mv auto-host.h ../auto-build.h 318 cd .. 319 rm -rf $tempdir 320 build_auto=auto-build.h 321fi 322 323tm_file="${tm_file} defaults.h" 324host_xm_file="auto-host.h ansidecl.h ${host_xm_file} ${tm_file}" 325build_xm_file="${build_auto} ansidecl.h ${build_xm_file} ${tm_file}" 326xm_file="ansidecl.h ${xm_file} ${tm_file}" 327 328# Truncate the target if necessary 329if test x$host_truncate_target != x; then 330 target=`echo $target | sed -e 's/\(..............\).*/\1/'` 331fi 332 333# Get the version trigger filename from the toplevel 334if test "${with_gcc_version_trigger+set}" = set; then 335 gcc_version_trigger=$with_gcc_version_trigger 336else 337 gcc_version_trigger=${srcdir}/version.c 338fi 339changequote(,)dnl 340gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*"\([^"]*\)".*/\1/'` 341gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'` 342 343changequote([,])dnl 344 345# Internationalization 346PACKAGE=sdcc 347VERSION="$gcc_version" 348AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", 349 [Define to the name of the distribution.]) 350AC_DEFINE_UNQUOTED(VERSION, "$VERSION", 351 [Define to the version of the distribution.]) 352AC_SUBST(PACKAGE) 353AC_SUBST(VERSION) 354 355ALL_LINGUAS="sv" 356 357# Get an absolute path to the GCC top-level source directory 358holddir=`pwd` 359cd $srcdir 360topdir=`pwd` 361cd $holddir 362 363out_object_file=`basename $out_file .c`.o 364 365# Figure out what assembler we will be using. 366AC_MSG_CHECKING(what assembler to use) 367gcc_cv_as= 368gcc_cv_gas_major_version= 369gcc_cv_gas_minor_version= 370gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas 371if test -x "$DEFAULT_ASSEMBLER"; then 372 gcc_cv_as="$DEFAULT_ASSEMBLER" 373elif test -x "$AS"; then 374 gcc_cv_as="$AS" 375elif test -x as$host_exeext; then 376 # Build using assembler in the current directory. 377 gcc_cv_as=./as$host_exeext 378elif test -f $gcc_cv_as_gas_srcdir/configure.in -a -f ../gas/Makefile; then 379 # Single tree build which includes gas. 380 for f in $gcc_cv_as_gas_srcdir/configure $gcc_cv_as_gas_srcdir/configure.in $gcc_cv_as_gas_srcdir/Makefile.in 381 do 382changequote(,)dnl 383 gcc_cv_gas_version=`grep '^VERSION=[0-9]*\.[0-9]*' $f` 384changequote([,])dnl 385 if test x$gcc_cv_gas_version != x; then 386 break 387 fi 388 done 389changequote(,)dnl 390 gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([0-9]*\)"` 391 gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[0-9]*\.\([0-9]*\)"` 392changequote([,])dnl 393fi 394 395if test "x$gcc_cv_as" = x -a x$host = x$target; then 396 # Native build. 397 # Search the same directories that the installed compiler will 398 # search. Else we may find the wrong assembler and lose. If we 399 # do not find a suitable assembler binary, then try the user's 400 # path. 401 # 402 # Also note we have to check MD_EXEC_PREFIX before checking the 403 # user's path. Unfortunately, there is no good way to get at the 404 # value of MD_EXEC_PREFIX here. So we do a brute force search 405 # through all the known MD_EXEC_PREFIX values. Ugh. This needs 406 # to be fixed as part of the make/configure rewrite too. 407 408 if test "x$exec_prefix" = xNONE; then 409 if test "x$prefix" = xNONE; then 410 test_prefix=/usr/local 411 else 412 test_prefix=$prefix 413 fi 414 else 415 test_prefix=$exec_prefix 416 fi 417 418 # If the loop below does not find an assembler, then use whatever 419 # one we can find in the users's path. 420 # user's path. 421 gcc_cv_as=as$host_exeext 422 423 test_dirs="$test_prefix/lib/gcc-lib/$target/$gcc_version \ 424 $test_prefix/lib/gcc-lib/$target \ 425 /usr/lib/gcc/$target/$gcc_version \ 426 /usr/lib/gcc/$target \ 427 $test_prefix/$target/bin/$target/$gcc_version \ 428 $test_prefix/$target/bin \ 429 /usr/libexec \ 430 /usr/ccs/gcc \ 431 /usr/ccs/bin \ 432 /udk/usr/ccs/bin \ 433 /bsd43/usr/lib/cmplrs/cc \ 434 /usr/cross64/usr/bin \ 435 /usr/lib/cmplrs/cc \ 436 /sysv/usr/lib/cmplrs/cc \ 437 /svr4/usr/lib/cmplrs/cc \ 438 /usr/bin" 439 440 for dir in $test_dirs; do 441 if test -f $dir/as$host_exeext; then 442 gcc_cv_as=$dir/as$host_exeext 443 break; 444 fi 445 done 446fi 447if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then 448 AC_MSG_RESULT("newly built gas") 449else 450 AC_MSG_RESULT($gcc_cv_as) 451fi 452 453# Figure out what nm we will be using. 454AC_MSG_CHECKING(what nm to use) 455if test -x nm$host_exeext; then 456 gcc_cv_nm=./nm$host_exeext 457elif test x$host = x$target; then 458 # Native build. 459 gcc_cv_nm=nm$host_exeext 460fi 461AC_MSG_RESULT($gcc_cv_nm) 462 463dnl Very limited version of automake's enable-maintainer-mode 464 465AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) 466 dnl maintainer-mode is disabled by default 467 AC_ARG_ENABLE(maintainer-mode, 468[ --enable-maintainer-mode 469 enable make rules and dependencies not useful 470 (and sometimes confusing) to the casual installer], 471 maintainer_mode=$enableval, 472 maintainer_mode=no) 473 474AC_MSG_RESULT($maintainer_mode) 475 476if test "$maintainer_mode" = "yes"; then 477 MAINT='' 478else 479 MAINT='#' 480fi 481AC_SUBST(MAINT)dnl 482 483# These (without "all_") are set in each config-lang.in. 484# `language' must be a single word so is spelled singularly. 485all_stagestuff= 486all_outputs='Makefile' 487# List of language makefile fragments. 488 489# Add the language fragments. 490# Languages are added via two mechanisms. Some information must be 491# recorded in makefile variables, these are defined in config-lang.in. 492# We accumulate them and plug them into the main Makefile. 493# The other mechanism is a set of hooks for each of the main targets 494# like `clean', `install', etc. 495 496language_fragments="Make-lang" 497 498# Define variables host_canonical and build_canonical 499# because some Cygnus local changes in the Makefile depend on them. 500build_canonical=${build} 501host_canonical=${host} 502target_subdir= 503if test "${host}" != "${target}" ; then 504 target_subdir=${target_alias}/ 505fi 506AC_SUBST(build_canonical) 507AC_SUBST(host_canonical) 508AC_SUBST(target_subdir) 509 510# Nothing to do for FLOAT_H, float_format already handled. 511objdir=`pwd` 512AC_SUBST(objdir) 513 514# -Wall c flag if GNU C 515if test "$ac_cv_c_compiler_gnu" = "yes"; then 516 WALL_FLAG="-Wall" 517else 518 WALL_FLAG= 519fi 520AC_SUBST(WALL_FLAG) 521 522# Substitute configuration variables 523AC_SUBST(all_stagestuff) 524AC_SUBST(build_exeext) 525AC_SUBST(build_install_headers_dir) 526AC_SUBST(build_xm_file_list) 527AC_SUBST(build_xm_file) 528AC_SUBST(build_xm_defines) 529AC_SUBST(check_languages) 530AC_SUBST(dep_host_xmake_file) 531AC_SUBST(dep_tmake_file) 532AC_SUBST(extra_c_flags) 533AC_SUBST(extra_headers_list) 534AC_SUBST(extra_objs) 535AC_SUBST(extra_parts) 536AC_SUBST(extra_passes) 537AC_SUBST(extra_programs) 538AC_SUBST(gcc_config_arguments) 539AC_SUBST(gcc_version) 540AC_SUBST(gcc_version_full) 541AC_SUBST(gcc_version_trigger) 542AC_SUBST(host_exeext) 543AC_SUBST(host_extra_gcc_objs) 544AC_SUBST(install) 545AC_SUBST(lang_tree_files) 546AC_SUBST(local_prefix) 547AC_SUBST(md_file) 548AC_SUBST(out_file) 549AC_SUBST(out_object_file) 550AC_SUBST(symbolic_link) 551AC_SUBST(thread_file) 552AC_SUBST(c_target_objs) 553 554#AC_SUBST_FILE(target_overrides) 555#AC_SUBST_FILE(host_overrides) 556#AC_SUBST(cross_defines) 557#AC_SUBST_FILE(cross_overrides) 558#AC_SUBST_FILE(build_overrides) 559 560# Create the Makefile 561# and configure language subdirectories 562AC_OUTPUT($all_outputs, 563[ 564case x$CONFIG_HEADERS in 565xauto-host.h:config.in) 566echo > cstamp-h ;; 567esac 568 569# Avoid having to add intl to our include paths. 570if test -f intl/libintl.h; then 571 echo creating libintl.h 572 echo '#include "intl/libintl.h"' >libintl.h 573fi 574], 575[ 576host='${host}' 577build='${build}' 578target='${target}' 579target_alias='${target_alias}' 580srcdir='${srcdir}' 581symbolic_link='${symbolic_link}' 582program_transform_set='${program_transform_set}' 583program_transform_name='${program_transform_name}' 584dep_host_xmake_file='${dep_host_xmake_file}' 585host_xmake_file='${host_xmake_file}' 586dep_tmake_file='${dep_tmake_file}' 587tmake_file='${tmake_file}' 588thread_file='${thread_file}' 589gcc_config_arguments='${gcc_config_arguments}' 590gcc_version='${gcc_version}' 591gcc_version_full='${gcc_version_full}' 592gcc_version_trigger='${gcc_version_trigger}' 593local_prefix='${local_prefix}' 594build_install_headers_dir='${build_install_headers_dir}' 595build_exeext='${build_exeext}' 596host_exeext='${host_exeext}' 597out_file='${out_file}' 598gdb_needs_out_file_path='${gdb_needs_out_file_path}' 599SET_MAKE='${SET_MAKE}' 600target_list='${target_list}' 601target_overrides='${target_overrides}' 602host_overrides='${host_overrides}' 603cross_defines='${cross_defines}' 604cross_overrides='${cross_overrides}' 605build_overrides='${build_overrides}' 606cpp_install_dir='${cpp_install_dir}' 607]) 608