Skip to content
Snippets Groups Projects
configure.ac 121 KiB
Newer Older
Jason Merrill's avatar
Jason Merrill committed
    ;;
  *-*-phoenix*)
    noconfigdirs="$noconfigdirs target-libgloss"
    ;;
    # The tpf target doesn't support gdb yet.
  *-*-tpf*)
    noconfigdirs="$noconfigdirs gdb tcl tk libgui itcl"
    noconfigdirs="$noconfigdirs target-rda"
Jason Merrill's avatar
Jason Merrill committed
  *-*-vxworks*)
    ;;
Richard Henderson's avatar
Richard Henderson committed
  alpha*-dec-osf*)
    # ld works, but does not support shared libraries.
Jason Merrill's avatar
Jason Merrill committed
    # gas doesn't generate exception information.
    noconfigdirs="$noconfigdirs gas ld"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  alpha*-*-*vms*)
    noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  alpha*-*-*)
    # newlib is not 64 bit ready
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
Jose E. Marchesi's avatar
Jose E. Marchesi committed
  bpf-*-*)
    noconfigdirs="$noconfigdirs target-libobjc target-libbacktrace"
    ;;
  sh*-*-pe|mips*-*-pe|*arm-wince-pe)
    noconfigdirs="$noconfigdirs tcl tk itcl libgui sim"
  arc*-*-*)
    noconfigdirs="$noconfigdirs sim"
    ;;
Jason Merrill's avatar
Jason Merrill committed
  arm-*-pe*)
Jason Merrill's avatar
Jason Merrill committed
    ;;
  arm-*-riscix*)
    noconfigdirs="$noconfigdirs ld target-libgloss"
  avr-*-*)
    if test x${with_avrlibc} != xno; then
      noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    fi
    ;;
  c4x-*-* | tic4x-*-*)
    noconfigdirs="$noconfigdirs target-libgloss"
  tic54x-*-*)
    noconfigdirs="$noconfigdirs target-libgloss gdb"
Jason Merrill's avatar
Jason Merrill committed
  d10v-*-*)
    noconfigdirs="$noconfigdirs target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  d30v-*-*)
    noconfigdirs="$noconfigdirs gdb"
Jason Merrill's avatar
Jason Merrill committed
    ;;
Nick Clifton's avatar
Nick Clifton committed
  fr30-*-elf*)
Nick Clifton's avatar
Nick Clifton committed
    ;;
  ft32-*-*)
    noconfigdirs="$noconfigdirs target-rda gprof"
    ;;
  moxie-*-*)
    noconfigdirs="$noconfigdirs"
  h8300*-*-*)
Jason Merrill's avatar
Jason Merrill committed
  h8500-*-*)
    noconfigdirs="$noconfigdirs target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  hppa*64*-*-hpux*)
    noconfigdirs="$noconfigdirs gdb"
    ;;
  hppa*64*-*-linux*)
Jason Merrill's avatar
Jason Merrill committed
  hppa*-*-*elf* | \
  hppa*-*-openbsd* | \
Jason Merrill's avatar
Jason Merrill committed
    ;;
Jason Merrill's avatar
Jason Merrill committed
  hppa*-*-*)
Jason Merrill's avatar
Jason Merrill committed
    ;;
    noconfigdirs="$noconfigdirs gdb"
Jason Merrill's avatar
Jason Merrill committed
  ia64*-*-elf*)
    # No gdb support yet.
    noconfigdirs="$noconfigdirs readline libgui itcl gdb"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  ia64*-**-hpux*)
    noconfigdirs="$noconfigdirs gdb libgui itcl ld"
    # No ld support yet.
    noconfigdirs="$noconfigdirs libgui itcl ld"
  i[[3456789]]86-w64-mingw*)
    ;;
  i[[3456789]]86-*-mingw*)
    target_configdirs="$target_configdirs target-winsup"
Jason Merrill's avatar
Jason Merrill committed
  *-*-cygwin*)
    target_configdirs="$target_configdirs target-libtermcap target-winsup"
    noconfigdirs="$noconfigdirs target-libgloss"
    # always build newlib if winsup directory is present.
    if test -d "$srcdir/winsup/cygwin"; then
      skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
    elif test -d "$srcdir/newlib"; then
      echo "Warning: winsup/cygwin is missing so newlib can't be built."
  i[[3456789]]86-*-pe)
    noconfigdirs="$noconfigdirs target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  i[[3456789]]86-*-sco3.2v5*)
Jason Merrill's avatar
Jason Merrill committed
    # The linker does not yet know about weak symbols in COFF,
    # and is not configured to handle mixed ELF and COFF.
    noconfigdirs="$noconfigdirs ld target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  i[[3456789]]86-*-sco*)
    noconfigdirs="$noconfigdirs gprof target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  i[[3456789]]86-*-solaris2* | x86_64-*-solaris2.1[[0-9]]*)
    noconfigdirs="$noconfigdirs target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  i[[3456789]]86-*-sysv4*)
    noconfigdirs="$noconfigdirs target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  i[[3456789]]86-*-beos*)
    noconfigdirs="$noconfigdirs gdb"
Paolo Bonzini's avatar
Paolo Bonzini committed
  i[[3456789]]86-*-rdos*)
    noconfigdirs="$noconfigdirs gdb"
    noconfigdirs="$noconfigdirs sim"
    ;;
  nfp-*-*)
    noconfigdirs="$noconfigdirs ld gas gdb gprof sim"
    noconfigdirs="$noconfigdirs $target_libraries"
    ;;
  pdp11-*-*)
    noconfigdirs="$noconfigdirs gdb gprof"
    ;;
Jason Merrill's avatar
Jason Merrill committed
  powerpc-*-aix*)
    # copied from rs6000-*-* entry
    noconfigdirs="$noconfigdirs gprof"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  powerpc*-*-winnt* | powerpc*-*-pe*)
Jason Merrill's avatar
Jason Merrill committed
    target_configdirs="$target_configdirs target-winsup"
    noconfigdirs="$noconfigdirs gdb tcl tk target-libgloss itcl"
Jason Merrill's avatar
Jason Merrill committed
    # always build newlib.
    skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
    ;;
    # This is temporary until we can link against shared libraries
  powerpcle-*-solaris*)
    noconfigdirs="$noconfigdirs gdb sim tcl tk itcl"
Jason Merrill's avatar
Jason Merrill committed
    ;;
    noconfigdirs="$noconfigdirs gdb"
Jason Merrill's avatar
Jason Merrill committed
    ;;
Jason Merrill's avatar
Jason Merrill committed
  rs6000-*-lynxos*)
    noconfigdirs="$noconfigdirs gprof"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  rs6000-*-aix*)
    noconfigdirs="$noconfigdirs gprof"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  rs6000-*-*)
Jason Merrill's avatar
Jason Merrill committed
    ;;
  m68k-apollo-*)
    noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  microblaze*)
  mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
    if test x$with_newlib = xyes; then
      noconfigdirs="$noconfigdirs gprof"
    fi
    ;;
Jason Merrill's avatar
Jason Merrill committed
  mips*-*-irix5*)
    noconfigdirs="$noconfigdirs gprof target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  mips*-*-irix6*)
    noconfigdirs="$noconfigdirs gprof target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  mips*-*-bsd*)
    noconfigdirs="$noconfigdirs ld gas gprof target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  mips*-*-ultrix* | mips*-*-osf* | mips*-*-ecoff* | mips*-*-pe* \
  | mips*-*-irix* | mips*-*-lnews* | mips*-*-riscos*)
    noconfigdirs="$noconfigdirs ld gas gprof"
    ;;
Jason Merrill's avatar
Jason Merrill committed
  mips*-*-*)
Jason Merrill's avatar
Jason Merrill committed
    ;;
Bernd Schmidt's avatar
Bernd Schmidt committed
  nvptx*-*-*)
    noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
    ;;
    case "${target}" in
      sh*-*-elf)
Jason Merrill's avatar
Jason Merrill committed
    ;;
  sparc-*-sunos4*)
    if test x${is_cross_compiler} = xno ; then
Jason Merrill's avatar
Jason Merrill committed
           use_gnu_ld=no
    fi
    ;;
  tic6x-*-*)
    noconfigdirs="$noconfigdirs sim"
  tilepro*-*-* | tilegx*-*-*)
    noconfigdirs="$noconfigdirs sim"
    ;;
Jason Merrill's avatar
Jason Merrill committed
  v810-*-*)
    noconfigdirs="$noconfigdirs bfd binutils gas gdb ld opcodes target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  vax-*-*)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
Jason Merrill's avatar
Jason Merrill committed
    ;;
  wasm32-*-*)
    noconfigdirs="$noconfigdirs ld"
    ;;
  loongarch*-*-linux*)
    ;;
  loongarch*-*-*)
    noconfigdirs="$noconfigdirs gprof"
    ;;
Jason Merrill's avatar
Jason Merrill committed
esac

# If we aren't building newlib, then don't build libgloss, since libgloss
# depends upon some newlib header files.
case "${noconfigdirs}" in
  *target-libgloss*) ;;
  *target-newlib*) noconfigdirs="$noconfigdirs target-libgloss" ;;
Jason Merrill's avatar
Jason Merrill committed

# Work in distributions that contain no compiler tools, like Autoconf.
host_makefile_frag=/dev/null
if test -d ${srcdir}/config ; then
case "${host}" in
  i[[3456789]]86-*-msdosdjgpp*)
    host_makefile_frag="config/mh-djgpp"
    ;;
  *-cygwin*)
    host_makefile_frag="config/mh-cygwin"
    ;;
    host_makefile_frag="config/mh-mingw"
    host_makefile_frag="config/mh-alpha-linux"
    ;;
    host_makefile_frag="config/mh-pa"
    ;;
  hppa*-*)	
    host_makefile_frag="config/mh-pa"
    ;;
  i?86-*-darwin[[89]]* | i?86-*-darwin1[[0-7]]* | powerpc*-*-darwin*)
    host_makefile_frag="config/mh-darwin"
  powerpc-*-aix*)
    host_makefile_frag="config/mh-ppc-aix"
    ;;
  rs6000-*-aix*)
    host_makefile_frag="config/mh-ppc-aix"
    ;;
Paolo Bonzini's avatar
Paolo Bonzini committed
if test "${build}" != "${host}" ; then
  AR_FOR_BUILD=${AR_FOR_BUILD-ar}
  AS_FOR_BUILD=${AS_FOR_BUILD-as}
Paolo Bonzini's avatar
Paolo Bonzini committed
  CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
Pekka Seppänen's avatar
Pekka Seppänen committed
  CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CC_FOR_BUILD) -E}"
  CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
  DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
  GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
  GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo}
  GDC_FOR_BUILD=${GDC_FOR_BUILD-gdc}
  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)"
  GFORTRAN_FOR_BUILD="\$(GFORTRAN)"
  GOC_FOR_BUILD="\$(GOC)"
  GDC_FOR_BUILD="\$(GDC)"
  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_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

# Check whether -static-libstdc++ -static-libgcc is supported.
have_static_libs=no
if test "$GCC" = yes; then
  saved_LDFLAGS="$LDFLAGS"

  LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
  AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
  AC_LANG_PUSH(C++)
  AC_LINK_IFELSE([AC_LANG_SOURCE([
#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
#error -static-libstdc++ not implemented
#endif
    [AC_MSG_RESULT([yes]); have_static_libs=yes],
    [AC_MSG_RESULT([no])])
  AC_LANG_POP(C++)

  LDFLAGS="$saved_LDFLAGS"
fi

Paolo Bonzini's avatar
Paolo Bonzini committed
ACX_PROG_GNAT
ACX_PROG_CMP_IGNORE_INITIAL
Paolo Bonzini's avatar
Paolo Bonzini committed

AC_ARG_ENABLE([bootstrap],
[AS_HELP_STRING([--enable-bootstrap],
		[enable bootstrapping @<:@yes if native build@:>@])],,
enable_bootstrap=default)

# Issue errors and warnings for invalid/strange bootstrap combinations.
if test -r $srcdir/gcc/configure; then
  have_compiler=yes
else
  have_compiler=no
fi

case "$have_compiler:$host:$target:$enable_bootstrap" in
  *:*:*:no) ;;

  # Default behavior.  Enable bootstrap if we have a compiler
  # and we are in a native configuration.
  yes:$build:$build:default)
    enable_bootstrap=yes ;;

  *:*:*:default)
    enable_bootstrap=no ;;

  # We have a compiler and we are in a native configuration, bootstrap is ok
  yes:$build:$build:yes)
    ;;

  # Other configurations, but we have a compiler.  Assume the user knows
  # what he's doing.
  yes:*:*:yes)
    AC_MSG_WARN([trying to bootstrap a cross compiler])
    ;;

  # No compiler: if they passed --enable-bootstrap explicitly, fail
  no:*:*:yes)
    AC_MSG_ERROR([cannot bootstrap without a compiler]) ;;

  # Fail if wrong command line
  *)
    AC_MSG_ERROR([invalid option for --enable-bootstrap])
    ;;
esac

# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a
# C++11 compiler can still start the bootstrap.  Otherwise, if building GCC,
# require C++11 (or higher).
if test "$enable_bootstrap:$GXX" = "yes:yes"; then
  CXX="$CXX -std=c++11"
elif test "$have_compiler" = yes; then
  AX_CXX_COMPILE_STDCXX(11)

  if test "${build}" != "${host}"; then
    AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD])
  fi
AC_ARG_ENABLE([pgo-build],
[AS_HELP_STRING([--enable-pgo-build[[=lto]]],
		[enable the PGO build])],
[enable_pgo_build=$enableval],
[enable_pgo_build=no])

# Issue errors and warnings for invalid/strange PGO build combinations.
case "$have_compiler:$host:$target:$enable_pgo_build" in
  *:*:*:no) ;;

  # Allow the PGO build only if we aren't building a compiler and
  # we are in a native configuration.
  no:$build:$build:yes | no:$build:$build:lto) ;;

  # Disallow the PGO bootstrap if we are building a compiler.
  yes:*:*:yes | yes:*:*:lto)
    AC_MSG_ERROR([cannot perform the PGO bootstrap when building a compiler]) ;;

  *)
    AC_MSG_ERROR([invalid option for --enable-pgo-build])
    ;;
esac

if test "$enable_pgo_build" != "no"; then
  AC_MSG_CHECKING([whether the compiler supports -fprofile-generate])
  old_CFLAGS="$CFLAGS"
  PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
  CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
  AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
		    [PGO_BUILD_GEN_CFLAGS=])
  CFLAGS="$old_CFLAGS"
  if test -n "$PGO_BUILD_GEN_CFLAGS"; then
    AC_MSG_RESULT([yes])
    PGO_BUILD_USE_CFLAGS="-fprofile-use"
  else
    AC_MSG_RESULT([no])
    AC_MSG_ERROR([cannot perform the PGO build without -fprofile-generate])
  fi

  if test "$enable_pgo_build" = "lto"; then
    AC_MSG_CHECKING([whether the compiler supports -flto=jobserver -ffat-lto-objects])
    old_CFLAGS="$CFLAGS"
    PGO_BUILD_LTO_CFLAGS="-flto=jobserver -ffat-lto-objects"
    CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
    AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
		      [PGO_BUILD_LTO_CFLAGS=])
    CFLAGS="$old_CFLAGS"
    if test -n "$PGO_BUILD_LTO_CFLAGS"; then
      AC_MSG_RESULT([yes])
    else
      AC_MSG_RESULT([no])
      AC_MSG_WARN([LTO is disabled for the PGO build])
    fi
  fi
fi
AC_SUBST(PGO_BUILD_GEN_CFLAGS)
AC_SUBST(PGO_BUILD_USE_CFLAGS)
AC_SUBST(PGO_BUILD_LTO_CFLAGS)

# Used for setting $lt_cv_objdir
_LT_CHECK_OBJDIR

# Check for GMP, MPFR and MPC
require_gmp=no
require_mpc=no
if test -d ${srcdir}/gcc ; then
  require_gmp=yes
  require_mpc=yes
fi
if test -d ${srcdir}/gdb ; then
  if test "x$enable_gdb" != xno; then
   require_gmp=yes
  fi
fi

gmplibs="-lmpfr -lgmp"
if test x"$require_mpc" = "xyes" ; then
  gmplibs="-lmpc $gmplibs"
fi
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,
[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
  # MPFR v3.1.0 moved the sources into a src sub-directory.
  if ! test -d ${srcdir}/mpfr/src; then
    AC_MSG_ERROR([dnl
Building GCC with MPFR in the source tree is only handled for MPFR 3.1.0+.])
  fi
  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs"
  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc"
  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$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,
[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"
  extra_isl_gmp_configure_flags='--with-gmp-builddir=$$r/$(HOST_SUBDIR)/gmp'
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 "x$require_gmp" = xyes && 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,3)
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(3,1,0)
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(3,1,6)
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
     [AC_MSG_RESULT([no]); have_gmp=no])
  fi

  # Check for the MPC header version.
  if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes ; then
    # 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 libraries])
    AC_TRY_LINK([#include <mpfr.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);
    mpfr_atan2 (n, n, x, MPFR_RNDN);
    mpfr_erfc (n, x, MPFR_RNDN);
    mpfr_subnormalize (x, t, MPFR_RNDN);
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
    LIBS="$saved_LIBS"
  fi

  # Now check the MPC library
  if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes; then
    saved_LIBS="$LIBS"
    LIBS="$LIBS $gmplibs"
    AC_MSG_CHECKING([for the correct version of the mpc libraries])
    AC_TRY_LINK([#include <mpc.h>],[
    mpc_t c;
    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
    if test -d ${srcdir}/gcc ; then
      AC_MSG_ERROR([Building GCC requires GMP 4.2+, MPFR 3.1.0+ 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
https://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.])
    else
      AC_MSG_ERROR([Building GDB requires GMP 4.2+, and MPFR 3.1.0+.
Try the --with-gmp and/or --with-mpfr options to specify
their locations.  If you obtained GMP and/or MPFR 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.])
    fi
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)
AC_SUBST(extra_isl_gmp_configure_flags)
# 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=])
# Whether or not to use -static-libstdc++ and -static-libgcc.  The
# default is yes if gcc is being built; no otherwise.  The reason for
# this default is that gdb is sometimes linked against GNU Source
# Highlight, which is a shared library that uses C++ exceptions.  In
# this case, -static-libstdc++ will cause crashes.
AC_ARG_WITH(static-standard-libraries,
[AS_HELP_STRING([--with-static-standard-libraries],
                [use -static-libstdc++ and -static-libgcc (default=auto)])],
[], [with_static_standard_libraries=auto])
if test "$with_static_standard_libraries" = auto; then
  with_static_standard_libraries=$have_compiler
fi

# Linker flags to use for stage1 or when not bootstrapping.
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=
 # In stage 1, default to linking libstdc++ and libgcc statically with GCC
 # if supported.  But if the user explicitly specified the libraries to use,
 # trust that they are doing what they want.
 if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \
     -a "$have_static_libs" = yes; then
   stage1_ldflags="-static-libstdc++ -static-libgcc"
 fi])
AC_SUBST(stage1_ldflags)

# Libraries to use for stage2 and later builds.
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
[poststage1_libs=])
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)

Sebastian Pop's avatar
Sebastian Pop committed
# GCC GRAPHITE dependency isl.
Tobias Burnus's avatar
Tobias Burnus committed
# Basic setup is inlined here, actual checks are in config/isl.m4
Sebastian Pop's avatar
Sebastian Pop committed
   [Specify prefix directory for the installed isl package.
    Equivalent to --with-isl-include=PATH/include
    plus --with-isl-lib=PATH/lib])])

# Treat --without-isl as a request to disable
if test "x$with_isl" != "xno"; then
Sebastian Pop's avatar
Sebastian Pop committed
  # Check for isl
  dnl Provide configure switches and initialize islinc & isllibs
  dnl with user input.
  ISL_INIT_FLAGS
Sebastian Pop's avatar
Sebastian Pop committed
  dnl The versions of isl that work for Graphite
  ISL_CHECK_VERSION()
Sebastian Pop's avatar
Sebastian Pop committed
  dnl Only execute fail-action, if isl has been requested.
Sebastian Pop's avatar
Sebastian Pop committed
    AC_MSG_ERROR([Unable to find a usable isl.  See config.log for details.])])
Sebastian Pop's avatar
Sebastian Pop committed
# If the isl check failed, disable builds of in-tree variant of isl
if test "x$with_isl" = xno ||
   test "x$gcc_cv_isl" = xno; then
Tobias Burnus's avatar
Tobias Burnus committed
  noconfigdirs="$noconfigdirs isl"
# 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
      *-apple-darwin[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;;
      # 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
Andris Pavenis's avatar
Andris Pavenis committed
      *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
      *) 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 ;;
AC_ARG_ENABLE(linker-plugin-configure-flags,
  [AS_HELP_STRING([[--enable-linker-plugin-configure-flags=FLAGS]],
    [additional flags for configuring linker plugins @<:@none@:>@])],
  extra_linker_plugin_configure_flags=$enableval,
  extra_linker_plugin_configure_flags=)
AC_SUBST(extra_linker_plugin_configure_flags)
AC_ARG_ENABLE(linker-plugin-flags,
  [AS_HELP_STRING([[--enable-linker-plugin-flags=FLAGS]],
    [additional flags for configuring and building linker plugins @<:@none@:>@])],
  extra_linker_plugin_flags=$enableval,
  extra_linker_plugin_flags=)
AC_SUBST(extra_linker_plugin_flags)

# Handle --enable-host-pie
# If host PIE executables are the default (or must be forced on) for some host,
# we must pass that configuration to the gcc directory.
gcc_host_pie=
AC_ARG_ENABLE(host-pie,
[AS_HELP_STRING([--enable-host-pie],
		[build position independent host executables])],
[host_pie=$enableval
 case $host in
     if test x$host_pie != xyes ; then
       # for Darwin20+ this is required.
       AC_MSG_WARN([PIE executables are required for the configured host, host-pie setting ignored.])
     fi ;;
  *) ;;
 esac],
[case $host in
  *-*-darwin2*)
    # Default to PIE (mandatory for aarch64).
    host_pie=yes
    gcc_host_pie=--enable-host-pie
    ;;
  *) host_pie=no ;;
 esac])

AC_SUBST(host_pie)
# Enable --enable-host-shared.
# Checked early to determine whether jit is an 'all' language
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
		[build host code as shared libraries])],
   x86_64-*-darwin* | aarch64-*-darwin*)
     if test x$host_shared != xyes ; then
       # PIC is the default, and actually cannot be switched off.
       AC_MSG_WARN([PIC code is required for the configured host; host-shared setting ignored.])
     if test x$host_pie = xyes -a x$host_shared != xyes ; then
       AC_MSG_WARN([PIC code is required for PIE host executables host-shared setting ignored.])
       host_shared=yes
     fi ;;
  # 64B x86_64 and Aarch64 Darwin default to PIC.
  x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
  # 32B and powerpc64 Darwin must use PIC to link PIE exes.
  *-*-darwin*) host_shared=$host_pie ;;
  *) host_shared=no;;
if test x$host_shared = xyes; then
  case $host in
    *-*-darwin*)
      # Since host shared is the default for 64b Darwin, and also enabled for
      # host_pie, ensure that we present the PIE flag when host_pie is active.
      if test x$host_pie = xyes; then
        PICFLAG=-fPIE
      fi
      ;;
    *)
      PICFLAG=-fPIC
      ;;
  esac
elif test x$host_pie = xyes; then
  PICFLAG=-fPIE
else
  PICFLAG=
fi

AC_SUBST(PICFLAG)

# If we are building PIC/PIE host executables, and we are building dependent
# libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
# code.
host_libs_picflag=
if test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
host_libs_picflag='--with-pic'
fi
AC_SUBST(host_libs_picflag)

# By default, C and C++ are the only stage 1 languages.
# 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.