Skip to content
Snippets Groups Projects
configure.ac 102 KiB
Newer Older
  GCJ_FOR_BUILD=${GCJ_FOR_BUILD-gcj}
  GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
  GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo}
  DLLTOOL_FOR_BUILD=${DLLTOOL_FOR_BUILD-dlltool}
  LD_FOR_BUILD=${LD_FOR_BUILD-ld}
  NM_FOR_BUILD=${NM_FOR_BUILD-nm}
  RANLIB_FOR_BUILD=${RANLIB_FOR_BUILD-ranlib}
  WINDRES_FOR_BUILD=${WINDRES_FOR_BUILD-windres}
  WINDMC_FOR_BUILD=${WINDMC_FOR_BUILD-windmc}
Paolo Bonzini's avatar
Paolo Bonzini committed
else
  AR_FOR_BUILD="\$(AR)"
  AS_FOR_BUILD="\$(AS)"
Paolo Bonzini's avatar
Paolo Bonzini committed
  CC_FOR_BUILD="\$(CC)"
  CXX_FOR_BUILD="\$(CXX)"
  GCJ_FOR_BUILD="\$(GCJ)"
  GFORTRAN_FOR_BUILD="\$(GFORTRAN)"
  GOC_FOR_BUILD="\$(GOC)"
  DLLTOOL_FOR_BUILD="\$(DLLTOOL)"
  LD_FOR_BUILD="\$(LD)"
  NM_FOR_BUILD="\$(NM)"
  RANLIB_FOR_BUILD="\$(RANLIB)"
  WINDRES_FOR_BUILD="\$(WINDRES)"
  WINDMC_FOR_BUILD="\$(WINDMC)"
Paolo Bonzini's avatar
Paolo Bonzini committed

AC_PROG_CC
AC_PROG_CXX

# We must set the default linker to the linker used by gcc for the correct
# operation of libtool.  If LD is not defined and we are using gcc, try to
# set the LD default to the ld used by gcc.
if test -z "$LD"; then
  if test "$GCC" = yes; then
    case $build in
    *-*-mingw*)
      gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
    *)
      gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
    esac
    case $gcc_prog_ld in
    # Accept absolute paths.
    [[\\/]* | [A-Za-z]:[\\/]*)]
      LD="$gcc_prog_ld" ;;
    esac
  fi
Paolo Bonzini's avatar
Paolo Bonzini committed
fi

ACX_PROG_GNAT
ACX_PROG_CMP_IGNORE_INITIAL
Paolo Bonzini's avatar
Paolo Bonzini committed

# See if we are building gcc with C++.
AC_ARG_ENABLE(build-with-cxx,
[AS_HELP_STRING([--enable-build-with-cxx],
		[build with C++ compiler instead of C compiler])],
ENABLE_BUILD_WITH_CXX=$enableval,
ENABLE_BUILD_WITH_CXX=no)

# Used for setting $lt_cv_objdir
_LT_CHECK_OBJDIR

# Check for GMP, MPFR and MPC
Paolo Bonzini's avatar
Paolo Bonzini committed
have_gmp=no

# Specify a location for mpc
# check for this first so it ends up on the link line before mpfr.
AC_ARG_WITH(mpc,
[AS_HELP_STRING([--with-mpc=PATH],
		[specify prefix directory for installed MPC package.
		 Equivalent to --with-mpc-include=PATH/include
		 plus --with-mpc-lib=PATH/lib])])
AC_ARG_WITH(mpc-include,
[AS_HELP_STRING([--with-mpc-include=PATH],
		[specify directory for installed MPC include files])])
AC_ARG_WITH(mpc-lib,
[AS_HELP_STRING([--with-mpc-lib=PATH],
		[specify directory for the installed MPC library])])

if test "x$with_mpc" != x; then
  gmplibs="-L$with_mpc/lib $gmplibs"
  gmpinc="-I$with_mpc/include $gmpinc"
fi
if test "x$with_mpc_include" != x; then
  gmpinc="-I$with_mpc_include $gmpinc"
fi
if test "x$with_mpc_lib" != x; then
fi
if test "x$with_mpc$with_mpc_include$with_mpc_lib" = x && test -d ${srcdir}/mpc; then
  gmplibs='-L$$r/$(HOST_SUBDIR)/mpc/src/'"$lt_cv_objdir $gmplibs"
  # Do not test the mpc version.  Assume that it is sufficient, since
  # it is in the source tree, and the library has not been built yet
  # but it would be included on the link line in the version check below
  # hence making the test fail.
Paolo Bonzini's avatar
Paolo Bonzini committed

# Specify a location for mpfr
# check for this first so it ends up on the link line before gmp.
AC_ARG_WITH(mpfr-dir,
[AS_HELP_STRING([--with-mpfr-dir=PATH], [this option has been REMOVED])],
[AC_MSG_ERROR([The --with-mpfr-dir=PATH option has been removed.
Use --with-mpfr=PATH or --with-mpfr-include=PATH plus --with-mpfr-lib=PATH])])

AC_ARG_WITH(mpfr,
[AS_HELP_STRING([--with-mpfr=PATH],
		[specify prefix directory for installed MPFR package.
		 Equivalent to --with-mpfr-include=PATH/include
		 plus --with-mpfr-lib=PATH/lib])])
AC_ARG_WITH(mpfr-include,
[AS_HELP_STRING([--with-mpfr-include=PATH],
		[specify directory for installed MPFR include files])])
AC_ARG_WITH(mpfr-lib,
[AS_HELP_STRING([--with-mpfr-lib=PATH],
		[specify directory for the installed MPFR library])])

if test "x$with_mpfr" != x; then
  gmplibs="-L$with_mpfr/lib $gmplibs"
  gmpinc="-I$with_mpfr/include $gmpinc"
if test "x$with_mpfr_include" != x; then
  gmpinc="-I$with_mpfr_include $gmpinc"
fi
if test "x$with_mpfr_lib" != x; then
  gmplibs="-L$with_mpfr_lib $gmplibs"
fi
Paolo Bonzini's avatar
Paolo Bonzini committed
if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir $gmplibs"
Paolo Bonzini's avatar
Paolo Bonzini committed
  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir"
Paolo Bonzini's avatar
Paolo Bonzini committed
  # Do not test the mpfr version.  Assume that it is sufficient, since
  # it is in the source tree, and the library has not been built yet
  # but it would be included on the link line in the version check below
  # hence making the test fail.
  have_gmp=yes
fi
# Specify a location for gmp
AC_ARG_WITH(gmp-dir,
[AS_HELP_STRING([--with-gmp-dir=PATH], [this option has been REMOVED])],
[AC_MSG_ERROR([The --with-gmp-dir=PATH option has been removed.
Use --with-gmp=PATH or --with-gmp-include=PATH plus --with-gmp-lib=PATH])])

AC_ARG_WITH(gmp,
[AS_HELP_STRING([--with-gmp=PATH],
		[specify prefix directory for the installed GMP package.
		 Equivalent to --with-gmp-include=PATH/include
		 plus --with-gmp-lib=PATH/lib])])
AC_ARG_WITH(gmp-include,
[AS_HELP_STRING([--with-gmp-include=PATH],
		[specify directory for installed GMP include files])])
AC_ARG_WITH(gmp-lib,
[AS_HELP_STRING([--with-gmp-lib=PATH],
		[specify directory for the installed GMP library])])
if test "x$with_gmp" != x; then
  gmplibs="-L$with_gmp/lib $gmplibs"
  gmpinc="-I$with_gmp/include $gmpinc"
if test "x$with_gmp_include" != x; then
  gmpinc="-I$with_gmp_include $gmpinc"
fi
if test "x$with_gmp_lib" != x; then
  gmplibs="-L$with_gmp_lib $gmplibs"
fi
Paolo Bonzini's avatar
Paolo Bonzini committed
if test "x$with_gmp$with_gmp_include$with_gmp_lib" = x && test -d ${srcdir}/gmp; then
  gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir $gmplibs"
Paolo Bonzini's avatar
Paolo Bonzini committed
  gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
  extra_mpfr_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
  extra_mpc_gmp_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
Paolo Bonzini's avatar
Paolo Bonzini committed
  # Do not test the gmp version.  Assume that it is sufficient, since
  # it is in the source tree, and the library has not been built yet
  # but it would be included on the link line in the version check below
  # hence making the test fail.
  have_gmp=yes
fi
if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
Paolo Bonzini's avatar
Paolo Bonzini committed
  have_gmp=yes
  saved_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $gmpinc"
  # Check for the recommended and required versions of GMP.
  AC_MSG_CHECKING([for the correct version of gmp.h])
Paolo Bonzini's avatar
Paolo Bonzini committed
  AC_TRY_COMPILE([#include "gmp.h"],[
  #define GCC_GMP_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  #define GCC_GMP_VERSION GCC_GMP_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL)
  #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,2,0)
Paolo Bonzini's avatar
Paolo Bonzini committed
  #endif
  ], [AC_TRY_COMPILE([#include <gmp.h>],[
  #define GCC_GMP_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  #define GCC_GMP_VERSION GCC_GMP_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL)
  #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
  choke me
  #endif
  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
   [AC_MSG_RESULT([no]); have_gmp=no])
Paolo Bonzini's avatar
Paolo Bonzini committed

  # If we have GMP, check the MPFR version.
Paolo Bonzini's avatar
Paolo Bonzini committed
  if test x"$have_gmp" = xyes; then
    # Check for the recommended and required versions of MPFR.
    AC_MSG_CHECKING([for the correct version of mpfr.h])
    AC_TRY_COMPILE([#include <gmp.h>
Paolo Bonzini's avatar
Paolo Bonzini committed
    #include <mpfr.h>],[
    #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1)
Paolo Bonzini's avatar
Paolo Bonzini committed
    choke me
    #endif
    ], [AC_TRY_COMPILE([#include <gmp.h>
    #include <mpfr.h>],[
    #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,2)
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
     [AC_MSG_RESULT([no]); have_gmp=no])
  fi

  # Check for the MPC header version.
    # Check for the recommended and required versions of MPC.
    AC_MSG_CHECKING([for the correct version of mpc.h])
    AC_TRY_COMPILE([#include <mpc.h>],[
    #if MPC_VERSION < MPC_VERSION_NUM(0,8,0)
    ], [AC_TRY_COMPILE([#include <mpc.h>],[
    #if MPC_VERSION < MPC_VERSION_NUM(0,8,1)
    choke me
    #endif
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
     [AC_MSG_RESULT([no]); have_gmp=no])
  fi

  # Now check the MPFR library.
  if test x"$have_gmp" = xyes; then
    saved_LIBS="$LIBS"
    LIBS="$LIBS $gmplibs"
    AC_MSG_CHECKING([for the correct version of the gmp/mpfr/mpc libraries])
    AC_TRY_LINK([#include <mpc.h>],[
Matt Kraai's avatar
Matt Kraai committed
    mpfr_t n;
    mpfr_t x;
Paolo Bonzini's avatar
Paolo Bonzini committed
    int t;
Matt Kraai's avatar
Matt Kraai committed
    mpfr_init (n);
    mpfr_init (x);
Paolo Bonzini's avatar
Paolo Bonzini committed
    mpfr_atan2 (n, n, x, GMP_RNDN);
    mpfr_erfc (n, x, GMP_RNDN);
    mpfr_subnormalize (x, t, GMP_RNDN);
    mpfr_clear(n);
    mpfr_clear(x);
    mpc_init2 (c, 53);
    mpc_set_ui_ui (c, 1, 1, MPC_RNDNN);
    mpc_cosh (c, c, MPC_RNDNN);
    mpc_pow (c, c, c, MPC_RNDNN);
    mpc_acosh (c, c, MPC_RNDNN);
    mpc_clear (c);
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
    LIBS="$saved_LIBS"
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi
Paolo Bonzini's avatar
Paolo Bonzini committed
  CFLAGS="$saved_CFLAGS"
# The library versions listed in the error message below should match
# the HARD-minimums enforced above.
Paolo Bonzini's avatar
Paolo Bonzini committed
  if test x$have_gmp != xyes; then
    AC_MSG_ERROR([Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.])
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi
# Flags needed for both GMP, MPFR and/or MPC.
AC_SUBST(gmplibs)
AC_SUBST(gmpinc)
AC_SUBST(extra_mpc_gmp_configure_flags)
AC_SUBST(extra_mpc_mpfr_configure_flags)
# Allow host libstdc++ to be specified for static linking with PPL.
AC_ARG_WITH(host-libstdcxx,
[AS_HELP_STRING([--with-host-libstdcxx=L],
		[use linker arguments L to link with libstdc++
		 when linking with PPL])])

case $with_host_libstdcxx in
  no|yes)
    AC_MSG_ERROR([-with-host-libstdcxx needs an argument])
    ;;
esac
# Linker flags to use for stage1 or when not boostrapping.
AC_ARG_WITH(stage1-ldflags,
[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])],
[if test "$withval" = "no" -o "$withval" = "yes"; then
   stage1_ldflags=
 else
   stage1_ldflags=$withval
 fi],
[stage1_ldflags=])
AC_SUBST(stage1_ldflags)

# Libraries to use for stage1 or when not bootstrapping.
AC_ARG_WITH(stage1-libs,
[AS_HELP_STRING([--with-stage1-libs=LIBS], [libraries for stage1])],
[if test "$withval" = "no" -o "$withval" = "yes"; then
   stage1_libs=
 else
   stage1_libs=$withval
 fi],
[stage1_libs=$with_host_libstdcxx])
AC_SUBST(stage1_libs)

# Libraries to use for stage2 and later builds.  This defaults to the
# argument passed to --with-host-libstdcxx.
AC_ARG_WITH(boot-libs,
[AS_HELP_STRING([--with-boot-libs=LIBS], [libraries for stage2 and later])],
[if test "$withval" = "no" -o "$withval" = "yes"; then
   poststage1_libs=
 else
 fi],
[poststage1_libs=$with_host_libstdcxx])
AC_SUBST(poststage1_libs)

# Linker flags to use for stage2 and later builds.
AC_ARG_WITH(boot-ldflags,
[AS_HELP_STRING([--with-boot-ldflags=FLAGS],
		[linker flags for stage2 and later])],
[if test "$withval" = "no" -o "$withval" = "yes"; then
   poststage1_ldflags=
 else
   poststage1_ldflags=$withval
 fi],
[poststage1_ldflags=
 # In stages 2 and 3, default to linking libstdc++ and libgcc
 # statically.  But if the user explicitly specified the libraries to
 # use, trust that they are doing what they want.
 if test "$poststage1_libs" = ""; then
   poststage1_ldflags="-static-libstdc++ -static-libgcc"
 fi])
AC_SUBST(poststage1_ldflags)

# Check for PPL
Sebastian Pop's avatar
Sebastian Pop committed
ppllibs=
Sebastian Pop's avatar
Sebastian Pop committed
pwllib=
AC_ARG_WITH(ppl,
[AS_HELP_STRING([--with-ppl=PATH],
		[specify prefix directory for the installed PPL package.
		 Equivalent to --with-ppl-include=PATH/include
		 plus --with-ppl-lib=PATH/lib])])
AC_ARG_WITH(ppl-include,
[AS_HELP_STRING([--with-ppl-include=PATH],
		[specify directory for installed PPL include files])])
AC_ARG_WITH(ppl-lib,
[AS_HELP_STRING([--with-ppl-lib=PATH],
		[specify directory for the installed PPL library])])
Sebastian Pop's avatar
Sebastian Pop committed
AC_ARG_ENABLE(ppl-version-check,
[AS_HELP_STRING([--disable-ppl-version-check],
		[disable check for PPL version])])

case $with_ppl in
  yes | no | "")
Sebastian Pop's avatar
Sebastian Pop committed
    ppllibs="-L$with_ppl/lib"
Sebastian Pop's avatar
Sebastian Pop committed
    if test -d "$with_ppl/lib" && test -d "$with_ppl/include"; then
      with_ppl=yes
    else
      AC_MSG_ERROR([cannot find directories "$with_ppl/lib" or "$with_ppl/include"])
    fi
Sebastian Pop's avatar
Sebastian Pop committed

if test x"$with_ppl_include" != x; then
  pplinc="-I$with_ppl_include $pplinc"
Sebastian Pop's avatar
Sebastian Pop committed
  with_ppl=yes
if test "x$with_ppl_lib" != x; then
Sebastian Pop's avatar
Sebastian Pop committed
  ppllibs="-L$with_ppl_lib"
  with_ppl=yes
Sebastian Pop's avatar
Sebastian Pop committed

if test x"$with_ppl$with_ppl_include$with_ppl_lib" = x && test -d ${srcdir}/ppl; then
  if test x"$enable_watchdog" = xyes; then
    pwllib="-lpwl"
  fi
  ppllibs='-L$$r/$(HOST_SUBDIR)/ppl/interfaces/C/'"$lt_cv_objdir"' -L$$r/$(HOST_SUBDIR)/ppl/src/'"$lt_cv_objdir"
  pplinc='-I$$r/$(HOST_SUBDIR)/ppl/src -I$$r/$(HOST_SUBDIR)/ppl/interfaces/C '
  enable_ppl_version_check=no
Sebastian Pop's avatar
Sebastian Pop committed
  with_ppl=yes
Sebastian Pop's avatar
Sebastian Pop committed
if test "x$with_ppl" != xno; then
Sebastian Pop's avatar
Sebastian Pop committed
  if test "x$pwllib" = x; then
    saved_LIBS="$LIBS"
    LIBS="$LIBS $ppllibs -lstdc++ -lm"
    AC_CHECK_LIB(pwl, PWL_handle_timeout, [pwllib="-lpwl"])
    LIBS="$saved_LIBS"
Sebastian Pop's avatar
Sebastian Pop committed
  fi
Sebastian Pop's avatar
Sebastian Pop committed
  ppllibs="$ppllibs -lppl_c -lppl $pwllib -lgmpxx"

  if test "$enable_ppl_version_check" != no; then
    saved_CFLAGS="$CFLAGS"
    CFLAGS="$CFLAGS $pplinc $gmpinc"
    AC_MSG_CHECKING([for version 0.11 (revision 0 or later) of PPL])
    AC_TRY_COMPILE([#include "ppl_c.h"],[
    #if PPL_VERSION_MAJOR != 0 || PPL_VERSION_MINOR < 11
    choke me
    #endif
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); ppllibs= ; pplinc= ; with_ppl=no ])
    CFLAGS="$saved_CFLAGS"
  fi
# Flags needed for PPL
AC_SUBST(ppllibs)
AC_SUBST(pplinc)


# Check for CLOOG

dnl Provide configure switches and initialize clooginc & clooglibs
dnl with user input.
CLOOG_INIT_FLAGS
if test "x$with_ppl" = "xno"; then
  dnl Only execute fail-action, if CLooG has been requested.
  CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
  if test "${graphite_requested}" = yes; then
    AC_MSG_ERROR([Unable to find a usable PPL.  See config.log for details.])
if test "x${with_cloog}" = x && test "x${with_cloog_include}" = x \
  && test "x${with_cloog_lib}" = x && test -d ${srcdir}/cloog; then
  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
if test "x$with_cloog" != "xno"; then
  dnl The minimal version of CLooG required for Graphite.
  dnl If we use CLooG-Legacy, the provided version information is
  dnl ignored.
  CLOOG_CHECK_VERSION(0,16,1)
  dnl Only execute fail-action, if CLooG has been requested.
  CLOOG_IF_FAILED([
    AC_MSG_ERROR([Unable to find a usable CLooG.  See config.log for details.])])
# Check for LTO support.
AC_ARG_ENABLE(lto,
[AS_HELP_STRING([--enable-lto], [enable link time optimization support])],
enable_lto=$enableval,
enable_lto=yes; default_enable_lto=yes)

ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
  build_lto_plugin=yes
],[if test x"$default_enable_lto" = x"yes" ; then
      # On other non-ELF platforms, LTO has yet to be validated.
      *) enable_lto=no ;;
    esac
  # Apart from ELF platforms, only Windows and Darwin support LTO so far.
  # It would also be nice to check the binutils support, but we don't
  # have gcc_GAS_CHECK_FEATURE available here.  For now, we'll just
  # warn during gcc/ subconfigure; unless you're bootstrapping with
  # -flto it won't be needed until after installation anyway.
    case $target in
      *-cygwin* | *-mingw* | *-apple-darwin*) ;;
      *) if test x"$enable_lto" = x"yes"; then
	AC_MSG_ERROR([LTO support is not enabled for this target.])
        fi
      ;;
    esac
  fi
  # Among non-ELF, only Windows platforms support the lto-plugin so far.
  # Build it unless LTO was explicitly disabled.
    *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;;
# By default, C is the only stage 1 language.
# Target libraries that we bootstrap.
bootstrap_target_libs=,target-libgcc,
Paolo Bonzini's avatar
Paolo Bonzini committed
# Figure out what language subdirectories are present.
# Look if the user specified --enable-languages="..."; if not, use
# the environment variable $LANGUAGES if defined. $LANGUAGES might
# go away some day.
# NB:  embedded tabs in this IF block -- do not untabify
if test -d ${srcdir}/gcc; then
  if test x"${enable_languages+set}" != xset; then
    if test x"${LANGUAGES+set}" = xset; then
      enable_languages="${LANGUAGES}"
        echo configure.in: warning: setting LANGUAGES is deprecated, use --enable-languages instead 1>&2
    else
      enable_languages=all
    fi
  else
    if test x"${enable_languages}" = x ||
       test x"${enable_languages}" = xyes;
       then
      echo configure.in: --enable-languages needs at least one language argument 1>&2
      exit 1
    fi
  fi
  enable_languages=`echo "${enable_languages}" | sed -e 's/[[ 	,]][[ 	,]]*/,/g' -e 's/,$//'`

  # 'f95' is the old name for the 'fortran' language. We issue a warning
  # and make the substitution.
  case ,${enable_languages}, in
    *,f95,*)
      echo configure.in: warning: 'f95' as language name is deprecated, use 'fortran' instead 1>&2
      enable_languages=`echo "${enable_languages}" | sed -e 's/f95/fortran/g'`
      ;;
  esac

Paolo Bonzini's avatar
Paolo Bonzini committed
  # First scan to see if an enabled language requires some other language.
  # We assume that a given config-lang.in will list all the language
  # front ends it requires, even if some are required indirectly.
  for lang_frag in ${srcdir}/gcc/*/config-lang.in .. ; do
    case ${lang_frag} in
      ..) ;;
      # The odd quoting in the next line works around
      # an apparent bug in bash 1.12 on linux.
      ${srcdir}/gcc/[[*]]/config-lang.in) ;;
      *)
        # From the config-lang.in, get $language, $lang_requires, and
        # $lang_requires_boot_languages.
Paolo Bonzini's avatar
Paolo Bonzini committed
        language=
        lang_requires=
Paolo Bonzini's avatar
Paolo Bonzini committed
        . ${lang_frag}
        for other in ${lang_requires} ${lang_requires_boot_languages}; do
Paolo Bonzini's avatar
Paolo Bonzini committed
          case ,${enable_languages}, in
	    *,$other,*) ;;
	    *,all,*) ;;
	    *,$language,*)
	      echo " \`$other' language required by \`$language'; enabling" 1>&2
	      enable_languages="${enable_languages},${other}"
	      ;;
	  esac
        done
	for other in ${lang_requires_boot_languages} ; do
	  if test "$other" != "c"; then
	    case ,${enable_stage1_languages}, in
	      *,$other,*) ;;
	      *,all,*) ;;
	      *)
		case ,${enable_languages}, in
		  *,$language,*)
		    echo " '$other' language required by '$language' in stage 1; enabling" 1>&2
		    enable_stage1_languages="$enable_stage1_languages,${other}"
		    ;;
		esac
		;;
	    esac
          fi
        done
Paolo Bonzini's avatar
Paolo Bonzini committed
        ;;
    esac
  done

  new_enable_languages=,c,

  # If LTO is enabled, add the LTO front end.
  extra_host_libiberty_configure_flags=
  if test "$enable_lto" = "yes" ; then
    case ,${enable_languages}, in
      *,lto,*) ;;
      *) enable_languages="${enable_languages},lto" ;;
    esac
    if test "${build_lto_plugin}" = "yes" ; then
      configdirs="$configdirs lto-plugin"
      extra_host_libiberty_configure_flags=--enable-shared
    fi
  fi
  AC_SUBST(extra_host_libiberty_configure_flags)

Paolo Bonzini's avatar
Paolo Bonzini committed
  missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e s/,c,/,/ `
  potential_languages=,c,
Paolo Bonzini's avatar
Paolo Bonzini committed

Paolo Bonzini's avatar
Paolo Bonzini committed
  for lang_frag in ${srcdir}/gcc/*/config-lang.in .. ; do
    case ${lang_frag} in
      ..) ;;
      # The odd quoting in the next line works around
      # an apparent bug in bash 1.12 on linux.
      ${srcdir}/gcc/[[*]]/config-lang.in) ;;
      *)
        # From the config-lang.in, get $language, $target_libs, 
        # $lang_dirs, $boot_language, and $build_by_default
Paolo Bonzini's avatar
Paolo Bonzini committed
        language=
        target_libs=
        lang_dirs=
        boot_language=no
        build_by_default=yes
Paolo Bonzini's avatar
Paolo Bonzini committed
        . ${lang_frag}
        if test x${language} = x; then
          echo "${lang_frag} doesn't set \$language." 1>&2
          exit 1
        fi

	if test "$language" = "c++" \
	   && test "$ENABLE_BUILD_WITH_CXX" = "yes"; then
        case ,${enable_languages}, in
          *,${language},*)
Paolo Bonzini's avatar
Paolo Bonzini committed
            # Language was explicitly selected; include it.
            add_this_lang=yes
            ;;
          *,all,*)
            # 'all' was selected, select it if it is a default language
            add_this_lang=${build_by_default}
Paolo Bonzini's avatar
Paolo Bonzini committed
            ;;
          *)
            add_this_lang=no
            ;;
        esac
        # Disable languages that need other directories if these aren't available.
	for i in $subdir_requires; do
	  test -f "$srcdir/gcc/$i/config-lang.in" && continue
	  case ,${enable_languages}, in
            *,${language},*)
              # Specifically requested language; tell them.
              AC_MSG_ERROR([The gcc/$i directory contains parts of $language but is missing])
              ;;
            *)
              # Silently disable.
              add_this_lang=unsupported
        # Disable Ada if no preexisting GNAT is available.
        case ,${enable_languages},:${language}:${have_gnat} in
          *,${language},*:ada:no)
            # Specifically requested language; tell them.
            AC_MSG_ERROR([GNAT is required to build $language])
            ;;
          *:ada:no)
            # Silently disable.
            add_this_lang=unsupported
            ;;
        esac

	# Disable a language that is unsupported by the target.
	case " $unsupported_languages " in
	  *" $language "*)
	    add_this_lang=unsupported
	case $add_this_lang in
Paolo Bonzini's avatar
Paolo Bonzini committed
            # Remove language-dependent dirs.
	    disabled_target_libs="$disabled_target_libs $target_libs"
	    noconfigdirs="$noconfigdirs $lang_dirs"
	  no)
            # Remove language-dependent dirs; still show language as supported.
	    disabled_target_libs="$disabled_target_libs $target_libs"
	    noconfigdirs="$noconfigdirs $lang_dirs"
            potential_languages="${potential_languages}${language},"
	    ;;
          yes)
	    new_enable_languages="${new_enable_languages}${language},"
            potential_languages="${potential_languages}${language},"
	    missing_languages=`echo "$missing_languages" | sed "s/,$language,/,/"`
	    enabled_target_libs="$enabled_target_libs $target_libs"
	    case "${boot_language}:,$enable_stage1_languages," in
	      yes:* | *:*,$language,* | *:*,yes, | *:*,all,)
		# Add to (comma-separated) list of stage 1 languages.
		case ",$stage1_languages," in
		  *,$language,* | ,yes, | ,all,) ;;
		  *) stage1_languages="${stage1_languages}${language}," ;;
		esac
		# We need to bootstrap any supporting libraries.
		bootstrap_target_libs="${bootstrap_target_libs}${target_libs},"
Paolo Bonzini's avatar
Paolo Bonzini committed
        esac
        ;;
    esac
  done

  # Add target libraries which are only needed for disabled languages
  # to noconfigdirs.
  if test -n "$disabled_target_libs"; then
    for dir in $disabled_target_libs; do
      case " $enabled_target_libs " in
      *" ${dir} "*) ;;
      *) noconfigdirs="$noconfigdirs $dir" ;;
      esac
    done
  fi

  AC_ARG_ENABLE(stage1-languages,
  [AS_HELP_STRING([[--enable-stage1-languages[=all]]],
		  [choose additional languages to build during
		  stage1.  Mostly useful for compiler development])],
  [case ,${enable_stage1_languages}, in
    ,no,|,,)
      # Set it to something that will have no effect in the loop below
      enable_stage1_languages=c ;;
    ,yes,)
      enable_stage1_languages=`echo $new_enable_languages | \
	sed -e "s/^,//" -e "s/,$//" ` ;;
    *,all,*)
      enable_stage1_languages=`echo ,$enable_stage1_languages, | \
	sed -e "s/,all,/$new_enable_languages/" -e "s/^,//" -e "s/,$//" ` ;;
  esac

  # Add "good" languages from enable_stage1_languages to stage1_languages,
  # while "bad" languages go in missing_languages.  Leave no duplicates.
  for i in `echo $enable_stage1_languages | sed 's/,/ /g' `; do
    case $potential_languages in
      *,$i,*)
        case $stage1_languages in
          *,$i,*) ;;
          *) stage1_languages="$stage1_languages$i," ;;
        esac ;;
      *)
        case $missing_languages in
          *,$i,*) ;;
          *) missing_languages="$missing_languages$i," ;;
        esac ;;
     esac
  done])

  # Remove leading/trailing commas that were added for simplicity
  potential_languages=`echo "$potential_languages" | sed -e "s/^,//" -e "s/,$//"`
  missing_languages=`echo "$missing_languages" | sed -e "s/^,//" -e "s/,$//"`
  stage1_languages=`echo "$stage1_languages" | sed -e "s/^,//" -e "s/,$//"`
  new_enable_languages=`echo "$new_enable_languages" | sed -e "s/^,//" -e "s/,$//"`

Paolo Bonzini's avatar
Paolo Bonzini committed
  if test "x$missing_languages" != x; then
    AC_MSG_ERROR([
The following requested languages could not be built: ${missing_languages}
Supported languages are: ${potential_languages}])
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi
  if test "x$new_enable_languages" != "x$enable_languages"; then
    echo The following languages will be built: ${new_enable_languages}
    enable_languages="$new_enable_languages"
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi

  AC_SUBST(stage1_languages)
  ac_configure_args=`echo " $ac_configure_args" | sed -e "s/ '--enable-languages=[[^ ]]*'//g" -e "s/$/ '--enable-languages="$enable_languages"'/" `
Paolo Bonzini's avatar
Paolo Bonzini committed
fi

# Handle --disable-<component> generically.
for dir in $configdirs $build_configdirs $target_configdirs ; do
  dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g`
  varname=`echo $dirname | sed -e s/+/_/g`
  if eval test x\${enable_${varname}} "=" xno ; then
    noconfigdirs="$noconfigdirs $dir"
  fi
done

# Check for Boehm's garbage collector
AC_ARG_ENABLE(objc-gc,
[AS_HELP_STRING([--enable-objc-gc],
		[enable use of Boehm's garbage collector with the
		 GNU Objective-C runtime])],
[case ,${enable_languages},:${enable_objc_gc}:${noconfigdirs} in
  *,objc,*:*:yes:*target-boehm-gc*)
    AC_MSG_ERROR([Boehm's garbage collector was requested yet not supported in this configuration])
    ;;
esac])

# Make sure we only build Boehm's garbage collector if required.
case ,${enable_languages},:${enable_objc_gc} in
  *,objc,*:yes)
    # Keep target-boehm-gc if requested for Objective-C.
    ;;
  *)
    # Otherwise remove target-boehm-gc depending on target-libjava.
    if echo " ${noconfigdirs} " | grep "target-libjava" >/dev/null 2>&1; then
      noconfigdirs="$noconfigdirs target-boehm-gc"
    fi
# Remove the entries in $skipdirs and $noconfigdirs from $configdirs,
# $build_configdirs and $target_configdirs.
Paolo Bonzini's avatar
Paolo Bonzini committed
# If we have the source for $noconfigdirs entries, add them to $notsupp.

notsupp=""
for dir in . $skipdirs $noconfigdirs ; do
  dirname=`echo $dir | sed -e s/target-//g -e s/build-//g`
Paolo Bonzini's avatar
Paolo Bonzini committed
  if test $dir != .  && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
    configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"`
    if test -r $srcdir/$dirname/configure ; then
      if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
	true
      else
	notsupp="$notsupp $dir"
      fi
    fi
  fi
  if test $dir != .  && echo " ${build_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
    build_configdirs=`echo " ${build_configdirs} " | sed -e "s/ ${dir} / /"`
    if test -r $srcdir/$dirname/configure ; then
      if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
	true
      else
	notsupp="$notsupp $dir"
      fi
    fi
  fi
Paolo Bonzini's avatar
Paolo Bonzini committed
  if test $dir != . && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
    target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"`
    if test -r $srcdir/$dirname/configure ; then
      if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
	true
      else
	notsupp="$notsupp $dir"
      fi
    fi
  fi
done

# Sometimes the tools are distributed with libiberty but with no other
# libraries.  In that case, we don't want to build target-libiberty.
# Don't let libgcc imply libiberty either.
Paolo Bonzini's avatar
Paolo Bonzini committed
if test -n "${target_configdirs}" ; then
Paolo Bonzini's avatar
Paolo Bonzini committed
  others=
  for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
    if test "$i" = "libgcc"; then
      libgcc=target-libgcc
    elif test "$i" != "libiberty" ; then
Paolo Bonzini's avatar
Paolo Bonzini committed
      if test -r $srcdir/$i/configure ; then
	others=yes;
	break;
      fi
    fi
  done
  if test -z "${others}" ; then
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi
fi

# Quietly strip out all directories which aren't configurable in this tree.
# This relies on all configurable subdirectories being autoconfiscated, which
# is now the case.
build_configdirs_all="$build_configdirs"
build_configdirs=
for i in ${build_configdirs_all} ; do
  j=`echo $i | sed -e s/build-//g` 
  if test -f ${srcdir}/$j/configure ; then
    build_configdirs="${build_configdirs} $i"
  fi
done

Paolo Bonzini's avatar
Paolo Bonzini committed
configdirs_all="$configdirs"
configdirs=
for i in ${configdirs_all} ; do
  if test -f ${srcdir}/$i/configure ; then
    configdirs="${configdirs} $i"
  fi
done
Paolo Bonzini's avatar
Paolo Bonzini committed
target_configdirs_all="$target_configdirs"
target_configdirs=
for i in ${target_configdirs_all} ; do
  j=`echo $i | sed -e s/target-//g` 
  if test -f ${srcdir}/$j/configure ; then
    target_configdirs="${target_configdirs} $i"
  fi
done

# Produce a warning message for the subdirs we can't configure.
# This isn't especially interesting in the Cygnus tree, but in the individual
# FSF releases, it's important to let people know when their machine isn't
# supported by the one or two programs in a package.

if test -n "${notsupp}" && test -z "${norecursion}" ; then
  # If $appdirs is non-empty, at least one of those directories must still
  # be configured, or we error out.  (E.g., if the gas release supports a
  # specified target in some subdirs but not the gas subdir, we shouldn't
  # pretend that all is well.)
  if test -n "$appdirs" ; then
    for dir in $appdirs ; do
      if test -r $dir/Makefile.in ; then
	if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
	  appdirs=""
	  break
	fi
	if echo " ${target_configdirs} " | grep " target-${dir} " >/dev/null 2>&1; then
Paolo Bonzini's avatar
Paolo Bonzini committed
	  appdirs=""
	  break
	fi
      fi
    done
    if test -n "$appdirs" ; then
      echo "*** This configuration is not supported by this package." 1>&2
      exit 1
    fi
  fi
  # Okay, some application will build, or we don't care to check.  Still
  # notify of subdirs not getting built.
  echo "*** This configuration is not supported in the following subdirectories:" 1>&2
  echo "    ${notsupp}" 1>&2
  echo "    (Any other directories should still work fine.)" 1>&2
fi

case "$host" in
  *msdosdjgpp*)
    enable_gdbtk=no ;;
esac

# To find our prefix, in gcc_cv_tool_prefix.
ACX_TOOL_DIRS

Paolo Bonzini's avatar
Paolo Bonzini committed
copy_dirs=

AC_ARG_WITH([build-sysroot], 
  [AS_HELP_STRING([--with-build-sysroot=SYSROOT],
		  [use sysroot as the system root during the build])],
  [if test x"$withval" != x ; then
     SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
   fi],
  [SYSROOT_CFLAGS_FOR_TARGET=])
AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)

AC_ARG_WITH([debug-prefix-map],
  [AS_HELP_STRING([--with-debug-prefix-map='A=B C=D ...'],
		  [map A to B, C to D ... in debug information])],
  [if test x"$withval" != x; then
     DEBUG_PREFIX_CFLAGS_FOR_TARGET=
     for debug_map in $withval; do
       DEBUG_PREFIX_CFLAGS_FOR_TARGET="$DEBUG_PREFIX_CFLAGS_FOR_TARGET -fdebug-prefix-map=$debug_map"
     done
   fi],
  [DEBUG_PREFIX_CFLAGS_FOR_TARGET=])
AC_SUBST(DEBUG_PREFIX_CFLAGS_FOR_TARGET)

# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS
# might be empty or "-g".  We don't require a C++ compiler, so CXXFLAGS
# might also be empty (or "-g", if a non-GCC C++ compiler is in the path).
# We want to ensure that TARGET libraries (which we know are built with
# gcc) are built with "-O2 -g", so include those options when setting
# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
if test "x$CFLAGS_FOR_TARGET" = x; then
  CFLAGS_FOR_TARGET=$CFLAGS
  case " $CFLAGS " in
    *" -O2 "*) ;;
    *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;;
  esac
  case " $CFLAGS " in
    *" -g "* | *" -g3 "*) ;;
    *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
  esac
fi
AC_SUBST(CFLAGS_FOR_TARGET)

if test "x$CXXFLAGS_FOR_TARGET" = x; then
  CXXFLAGS_FOR_TARGET=$CXXFLAGS
  case " $CXXFLAGS " in
    *" -O2 "*) ;;
    *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;;
  esac
  case " $CXXFLAGS " in
    *" -g "* | *" -g3 "*) ;;
    *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;;
  esac
fi
AC_SUBST(CXXFLAGS_FOR_TARGET)

Paolo Bonzini's avatar
Paolo Bonzini committed
# Handle --with-headers=XXX.  If the value is not "yes", the contents of
# the named directory are copied to $(tooldir)/sys-include.