Skip to content
Snippets Groups Projects
configure.ac 110 KiB
Newer Older
    tentative_cc=gcc
    ;;
  m88k-dg-dgux*)
    tentative_cc="gcc -Wall -ansi -D__using_DGUX"
    ;;
  m88k-harris-cxux*)
    # Under CX/UX, we want to tell the compiler to use ANSI mode.
    tentative_cc="cc -Xa"
    host_makefile_frag="config/mh-cxux"
    ;;
  m88k-motorola-sysv*)
    ;;
  mips*-dec-ultrix*)
    tentative_cc="cc -Wf,-XNg1000"
    host_makefile_frag="config/mh-decstation"
    ;;
  mips*-nec-sysv4*)
    # The C compiler on NEC MIPS SVR4 needs bigger tables.
    tentative_cc="cc -ZXNd=5000 -ZXNg=1000"
    host_makefile_frag="config/mh-necv4"
    ;;
  mips*-sgi-irix4*)
    # Tell compiler to use K&R C.  We can't compile under the SGI Ansi
    # environment.  Also bump switch table size so that cp-parse will
    # compile.  Bump string length limit so linker builds.
    tentative_cc="cc -cckr -Wf,-XNg1500 -Wf,-XNk1000 -Wf,-XNh2000 -Wf,-XNl8192"
    ;;
  mips*-*-sysv4*)
    host_makefile_frag="config/mh-sysv4"
    ;;
  mips*-*-sysv*)
    # This is for a MIPS running RISC/os 4.52C.

    # This is needed for GDB, but needs to be in the top-level make because
    # if a library is compiled with the bsd headers and gets linked with the
    # sysv system libraries all hell can break loose (e.g. a jmp_buf might be
    # a different size).
    # ptrace(2) apparently has problems in the BSD environment.  No workaround is
    # known except to select the sysv environment.  Could we use /proc instead?
    # These "sysv environments" and "bsd environments" often end up being a pain.
    #
    # This is not part of CFLAGS because perhaps not all C compilers have this
    # option.
    tentative_cc="cc -systype sysv"
    ;;
  i370-ibm-opened*)
    tentative_cc="c89"
    ;;
  i[[3456789]]86-*-sysv5*)
    host_makefile_frag="config/mh-sysv5"
    ;;
  i[[3456789]]86-*-dgux*)
    tentative_cc="gcc -Wall -ansi -D__using_DGUX"
    host_makefile_frag="config/mh-dgux386"
    ;;
  i[[3456789]]86-ncr-sysv4.3*)
    # The MetaWare compiler will generate a copyright message unless you
    # turn it off by adding the -Hnocopyr flag.
    tentative_cc="cc -Hnocopyr"
    ;;
  i[[3456789]]86-ncr-sysv4*)
    # for an NCR 3000 (i486/SVR4) system.
    # The NCR 3000 ships with a MetaWare compiler installed as /bin/cc.
    # This compiler not only emits obnoxious copyright messages every time
    # you run it, but it chokes and dies on a whole bunch of GNU source
    # files.  Default to using the AT&T compiler installed in /usr/ccs/ATT/cc.
    tentative_cc="/usr/ccs/ATT/cc"
    host_makefile_frag="config/mh-ncr3000"
    ;;
  i[[3456789]]86-*-sco3.2v5*)
  i[[3456789]]86-*-sco*)
    # The native C compiler botches some simple uses of const.  Unfortunately,
    # it doesn't defined anything like "__sco__" for us to test for in ansidecl.h.
    tentative_cc="cc -Dconst="
    host_makefile_frag="config/mh-sco"
    ;;
  i[[3456789]]86-*-udk*)
    host_makefile_frag="config/mh-sysv5"
    ;;
  i[[3456789]]86-*-solaris2*)
    host_makefile_frag="config/mh-sysv4"
    ;;
  i[[3456789]]86-*-msdosdjgpp*)
    host_makefile_frag="config/mh-djgpp"
    ;;
  *-cygwin*)
    host_makefile_frag="config/mh-cygwin"
    ;;
    host_makefile_frag="config/mh-mingw"
  *-interix*)
    host_makefile_frag="config/mh-interix"
    ;;
  vax-*-ultrix2*)
    # The old BSD pcc isn't up to compiling parts of gdb so use gcc
    tentative_cc=gcc
    ;;
  *-*-solaris2*)
    host_makefile_frag="config/mh-solaris"
    ;;
  m68k-sun-sunos*)
    # Sun's C compiler needs the -J flag to be able to compile cp-parse.c
    # without overflowing the jump tables (-J says to use a 32 bit table)
    tentative_cc="cc -J"
    ;;
    tentative_cc="cc -Wp,-H256000"
    host_makefile_frag="config/mh-pa-hpux10"
  hppa*-hp-hpux* | hppa*-*-hiux*)
    tentative_cc="cc -Wp,-H256000"
    host_makefile_frag="config/mh-pa"
    ;;
  hppa*-*)	
    host_makefile_frag="config/mh-pa"
    ;;
  *-hp-hpux* | *-*-hiux*)
    tentative_cc="cc -Wp,-H256000"
    ;;
  rs6000-*-lynxos*)
    # /bin/cc is less than useful for our purposes.  Always use GCC
    tentative_cc="/usr/cygnus/progressive/bin/gcc"
    host_makefile_frag="config/mh-lynxrs6k"
    ;;
  powerpc-*-darwin*)
    host_makefile_frag="config/mh-ppc-darwin"
    ;;
  powerpc-*-aix*)
    host_makefile_frag="config/mh-ppc-aix"
    ;;
  rs6000-*-aix*)
    host_makefile_frag="config/mh-ppc-aix"
    ;;
  *-*-lynxos*)
    # /bin/cc is less than useful for our purposes.  Always use GCC
    tentative_cc="/bin/gcc"
    ;;
  *-*-sysv4*)
    host_makefile_frag="config/mh-sysv4"
    ;;
  # This is placed last to prevent interfering with the cases above.
  i[[3456789]]86-*-*)
    # Build the stage2 and stage3 compilers with -fomit-frame-pointer.
    host_makefile_frag="config/mh-x86omitfp"
    ;;
Paolo Bonzini's avatar
Paolo Bonzini committed
# If we aren't going to be using gcc, see if we can extract a definition
# of CC from the fragment.
# Actually, use the 'pre-extracted' version above.
if test -z "${CC}" && test "${build}" = "${host}" ; then
  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
  found=
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/gcc; then
      found=yes
      break
    fi
  done
  IFS="$save_ifs"
  if test -z "${found}" && test -n "${tentative_cc}" ; then
    CC=$tentative_cc
  fi
fi

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}
  CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
  GCJ_FOR_BUILD=${GCJ_FOR_BUILD-gcj}
  GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
  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)"
  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,
[  --enable-build-with-cxx build with C++ compiler instead of C compiler],
ENABLE_BUILD_WITH_CXX=$enableval,
ENABLE_BUILD_WITH_CXX=no)

# Check for GMP, MPFR and MPC
Paolo Bonzini's avatar
Paolo Bonzini committed
gmplibs="-lmpfr -lgmp"
Paolo Bonzini's avatar
Paolo Bonzini committed
have_gmp=no
mpcinc=
have_mpc=no

# Specify a location for mpc
# check for this first so it ends up on the link line before mpfr.
AC_ARG_WITH(mpc, [  --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, [  --with-mpc-include=PATH
                          specify directory for installed MPC include files])
AC_ARG_WITH(mpc_lib, [  --with-mpc-lib=PATH    specify directory for the installed MPC library])

if test "x$with_mpc" != x; then
  mpclibs="-L$with_mpc/lib -lmpc"
  mpcinc="-I$with_mpc/include $mpcinc"
fi
if test "x$with_mpc_include" != x; then
  mpcinc="-I$with_mpc_include $mpcinc"
fi
if test "x$with_mpc_lib" != x; then
  mpclibs="-L$with_mpc_lib -lmpc"
fi
if test "x$with_mpc$with_mpc_include$with_mpc_lib" = x && test -d ${srcdir}/mpc; then
  mpclibs='-L$$r/$(HOST_SUBDIR)/mpc/src/.libs -L$$r/$(HOST_SUBDIR)/mpc/src/_libs -lmpc'
  mpcinc='-I$$s/mpc/src '"$mpcinc"
  # 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.
  have_mpc=yes
fi
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, [  --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, [  --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, [  --with-mpfr-include=PATH
                          specify directory for installed MPFR include files])
AC_ARG_WITH(mpfr_lib, [  --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"
fi
if test "x$with_mpfr_include" != x; then
  gmpinc="-I$with_mpfr_include"
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/.libs -L$$r/$(HOST_SUBDIR)/mpfr/_libs '"$gmplibs"
  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr'
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, [  --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, [  --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, [  --with-gmp-include=PATH specify directory for installed GMP include files])
AC_ARG_WITH(gmp_lib, [  --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/.libs -L$$r/$(HOST_SUBDIR)/gmp/_libs '"$gmplibs"
  gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
  extra_mpfr_configure_flags='--with-gmp-build=$$r/$(HOST_SUBDIR)/gmp'
  extra_mpc_gmp_configure_flags='--with-gmp-include=$$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 -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 GMP actually works
  AC_MSG_CHECKING([for correct version of gmp.h])
  AC_TRY_COMPILE([#include "gmp.h"],[
  #if __GNU_MP_VERSION < 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR < 2)
Paolo Bonzini's avatar
Paolo Bonzini committed
  #endif
  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])

  # If we have GMP, check the MPFR version.
Paolo Bonzini's avatar
Paolo Bonzini committed
  if test x"$have_gmp" = xyes; then
    dnl MPFR 2.3.1 is acceptable, but MPFR 2.3.2 is better.
Paolo Bonzini's avatar
Paolo Bonzini committed
    AC_MSG_CHECKING([for 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,3,2)
    choke me
    #endif
    ], [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"$have_mpc" != xyes ; then
    CFLAGS="$CFLAGS $mpcinc"
    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)
    choke me
    #endif
    ], [AC_MSG_RESULT([yes]); have_mpc=maybe],
       [AC_MSG_RESULT([no]); have_mpc=no; mpclibs= ; mpcinc= ])
  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 <gmp.h>
    #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);
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);
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
    LIBS="$saved_LIBS"
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi

  if test x"$have_mpc" = xmaybe; then
    saved_LIBS="$LIBS"
    LIBS="$LIBS $mpclibs $gmplibs"
    AC_MSG_CHECKING([for the correct version of the mpc library])
    AC_TRY_LINK([#include <mpc.h>],[
    mpc_t n;
    mpc_init2 (n, 53);
    mpc_set_ui_ui (n, 1, 1, MPC_RNDNN);
    mpc_sin (n, n, MPC_RNDNN);
    mpc_cos (n, n, MPC_RNDNN);
    mpc_tan (n, n, MPC_RNDNN);
    mpc_sinh (n, n, MPC_RNDNN);
    mpc_cosh (n, n, MPC_RNDNN);
    mpc_tanh (n, n, MPC_RNDNN);
    mpc_exp (n, n, MPC_RNDNN);
    mpc_log (n, n, MPC_RNDNN);
    mpc_sqrt (n, n, MPC_RNDNN);
    mpc_proj (n, n, MPC_RNDNN);
    mpc_neg (n, n, MPC_RNDNN);
    mpc_sqr (n, n, MPC_RNDNN);
    mpc_pow (n, n, n, MPC_RNDNN);
    mpc_acosh (n, n, MPC_RNDNN);
    mpc_clear (n);
    ], [AC_MSG_RESULT([yes]); have_mpc=yes],
       [AC_MSG_RESULT([no]); have_mpc=no; mpclibs= ; mpcinc= ])
    LIBS="$saved_LIBS"
  fi

Paolo Bonzini's avatar
Paolo Bonzini committed
  CFLAGS="$saved_CFLAGS"
Paolo Bonzini's avatar
Paolo Bonzini committed
  if test x$have_gmp != xyes; then
    AC_MSG_ERROR([Building GCC requires GMP 4.2+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code 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 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.])
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi
if test x$have_mpc != xyes ; then
  mpcinc=
  mpclibs=
fi

gmpinc="$mpcinc $gmpinc"
gmplibs="$mpclibs $gmplibs"

# 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, [  --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,
[  --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,
[  -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,
[  --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,
[  --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=
 # With --enable-build-with-cxx, 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 "$ENABLE_BUILD_WITH_CXX" = "yes" -a "$poststage1_libs" = ""; then
   poststage1_ldflags="-static-libstdc++ -static-libgcc"
 fi])
AC_SUBST(poststage1_ldflags)

# Check for PPL
ppl_major_version=0
ppl_minor_version=10
ppllibs=" -lppl_c -lppl -lgmpxx"
pplinc=

AC_ARG_WITH(ppl, [  --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, [  --with-ppl-include=PATH Specify directory for installed PPL include files])
AC_ARG_WITH(ppl_lib, [  --with-ppl-lib=PATH     Specify the directory for the installed PPL library])

    ppllibs="-L$with_ppl/lib -lppl_c -lppl -lgmpxx"
if test "x$with_ppl_include" != x; then
  pplinc="-I$with_ppl_include $pplinc"
fi
if test "x$with_ppl_lib" != x; then
  ppllibs="-L$with_ppl_lib -lppl_c -lppl -lgmpxx"
fi
if test "x$with_ppl$with_ppl_include$with_ppl_lib" = x && test -d ${srcdir}/ppl; then
  ppllibs='-L$$r/$(HOST_SUBDIR)/ppl/interfaces/C/.libs -L$$r/$(HOST_SUBDIR)/ppl/interfaces/C/_libs -L$$r/$(HOST_SUBDIR)/ppl/src/.libs -L$$r/$(HOST_SUBDIR)/ppl/src/_libs -lppl_c -lppl -lgmpxx '
  pplinc='-I$$r/$(HOST_SUBDIR)/ppl/src -I$$r/$(HOST_SUBDIR)/ppl/interfaces/C '
  enable_ppl_version_check=no
AC_ARG_ENABLE(ppl-version-check,
[  --disable-ppl-version-check    disable check for PPL version],
ENABLE_PPL_CHECK=$enableval,
ENABLE_PPL_CHECK=yes)

if test "x$with_ppl" != "xno" -a "${ENABLE_PPL_CHECK}" = "yes"; then
  saved_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $pplinc $gmpinc"
  AC_MSG_CHECKING([for version $ppl_major_version.$ppl_minor_version of PPL])
  AC_TRY_COMPILE([#include "ppl_c.h"],[
  #if PPL_VERSION_MAJOR != $ppl_major_version || PPL_VERSION_MINOR != $ppl_minor_version
  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
clooglibs=" -lcloog "
clooginc=" -DCLOOG_PPL_BACKEND "
AC_ARG_WITH(cloog, [  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
                          Equivalent to --with-cloog-include=PATH/include
                          plus --with-cloog-lib=PATH/lib])
AC_ARG_WITH(cloog_include, [  --with-cloog-include=PATH Specify directory for installed CLooG include files])
AC_ARG_WITH(cloog_lib, [  --with-cloog-lib=PATH   Specify the directory for the installed CLooG library])
if test "x$with_ppl" = "xno"; then
  *)
    clooglibs="-L$with_cloog/lib -lcloog"
    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
    ;;
esac
if test "x$with_cloog_include" != x; then
  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
fi
if test "x$with_cloog_lib" != x; then
  clooglibs="-L$with_cloog_lib -lcloog"
fi
if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/.libs -L$$r/$(HOST_SUBDIR)/cloog/_libs -lcloog '
  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
  enable_cloog_version_check=no
AC_ARG_ENABLE(cloog-version-check,
[  --disable-cloog-version-check  disable check for CLooG version],
ENABLE_CLOOG_CHECK=$enableval,
ENABLE_CLOOG_CHECK=yes)

if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
  saved_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
  AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
  AC_TRY_COMPILE([#include "cloog/cloog.h"],[
  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
  choke me
  #endif
  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
  CFLAGS="$saved_CFLAGS"
fi

# Flags needed for CLOOG
AC_SUBST(clooglibs)
AC_SUBST(clooginc)

# Check for LTO support.
AC_ARG_ENABLE(lto,
[  --enable-lto            enable link time optimization support],
enable_lto=$enableval,
enable_lto=yes; default_enable_lto=yes)

if test x"$enable_lto" = x"yes" ; then
  # Make sure that libelf.h and gelf.h are available.
  AC_ARG_WITH(libelf, [  --with-libelf=PATH       Specify prefix directory for the installed libelf package
                          Equivalent to --with-libelf-include=PATH/include
                          plus --with-libelf-lib=PATH/lib])

  AC_ARG_WITH(libelf_include, [  --with-libelf-include=PATH Specify directory for installed libelf include files])

  AC_ARG_WITH(libelf_lib, [  --with-libelf-lib=PATH   Specify the directory for the installed libelf library])

  saved_CFLAGS="$CFLAGS"
  saved_CPPFLAGS="$CPPFLAGS"
  saved_LIBS="$LIBS"

  case $with_libelf in 
    "")
      libelflibs="-lelf"
      libelfinc="-I/usr/include/libelf"
      ;;
    *)
      libelflibs="-L$with_libelf/lib -lelf"
      libelfinc="-I$with_libelf/include -I$with_libelf/include/libelf"
      LIBS="$libelflibs $LIBS"
      ;;
  esac

  if test "x$with_libelf_include" != x; then
    libelfinc="-I$with_libelf_include"
  fi

  if test "x$with_libelf_lib" != x; then
    libelflibs="-L$with_libelf_lib -lelf"
    LIBS="$libelflibs $LIBS"
  fi

  if test "x$with_libelf$with_libelf_include$with_libelf_lib" = x \
     && test -d ${srcdir}/libelf; then
    libelflibs='-L$$r/$(HOST_SUBDIR)/libelf/lib -lelf '
    libelfinc='-D__LIBELF_INTERNAL__ -I$$r/$(HOST_SUBDIR)/libelf/lib -I$$s/libelf/lib'
    LIBS="$libelflibs $LIBS"

  CFLAGS="$CFLAGS $libelfinc"
  CPPFLAGS="$CPPFLAGS $libelfinc"
  LIBS="$LIBS $libelflibs"

  AC_CHECK_HEADERS(libelf.h, [have_libelf_h=yes])
  AC_CHECK_HEADERS(gelf.h, [have_gelf_h=yes])

  AC_CHECK_HEADERS(libelf/libelf.h, [have_libelf_libelf_h=yes])
  AC_CHECK_HEADERS(libelf/gelf.h, [have_libelf_gelf_h=yes])

  # If we couldn't find libelf.h and the user forced it, emit an error.
  if test x"$have_libelf_h" != x"yes" \
     && test x"$have_libelf_libelf_h" != x"yes" ; then
    if test x"$default_enable_lto" != x"yes" ; then
      AC_MSG_ERROR([LTO support requires libelf.h or libelf/libelf.h.])
    else
      enable_lto=no
      libelflibs=
      libelfinc=
    fi
  fi

  # If we couldn't find gelf.h and the user forced it, emit an error.
  if test x"$have_gelf_h" != x"yes" \
     && test x"$have_libelf_gelf_h" != x"yes" ; then
    if test x"$default_enable_lto" != x"yes" ; then
      AC_MSG_ERROR([LTO support requires gelf.h or libelf/gelf.h.])
    else
      enable_lto=no
      libelflibs=
      libelfinc=
    fi
  fi

  # Check that the detected libelf has the functions we need.  We cannot
  # rely on just detecting the headers since they do not include 
  # versioning information.  Add functions, if needed.
  if test x"$enable_lto" = x"yes" ; then
    AC_MSG_CHECKING([for the correct version of libelf])
    AC_TRY_LINK(
      [#include <libelf.h>],[
      elf_errmsg (0);
      elf_getscn (0, 0);
      elf_nextscn (0, 0);
      elf_strptr (0, 0, 0);
      elf_getident (0, 0);
      elf_getshdrstrndx (0, 0);
      elf_begin (0, 0, 0);
      elf_ndxscn (0);
      elf_end (0);
      ],
      [AC_MSG_RESULT([yes]);],
      [AC_MSG_RESULT([no]); enable_lto=no; libelflibs= ; libelfinc= ]
    )

    # If we couldn't enable LTO and the user forced it, emit an error.
    if test x"$enable_lto" = x"no" \
       && test x"$default_enable_lto" != x"yes" ; then
      AC_MSG_ERROR([To enable LTO, GCC requires libelf v0.8.12+.
Try the --with-libelf, --with-libelf-include and --with-libelf-lib options
to specify its location.])
    fi
  fi

  CFLAGS="$saved_CFLAGS"
  CPPFLAGS="$saved_CPPFLAGS"
  LIBS="$saved_LIBS"

  # Flags needed for libelf.
  AC_SUBST(libelflibs)
  AC_SUBST(libelfinc)
fi

# 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
        language=
        lang_requires=
        . ${lang_frag}
        for other in ${lang_requires} ; do
          case ,${enable_languages}, in
	    *,$other,*) ;;
	    *,all,*) ;;
	    *,$language,*)
	      echo " \`$other' language required by \`$language'; enabling" 1>&2
	      enable_languages="${enable_languages},${other}"
	      ;;
	  esac
        done
        ;;
    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 "${ENABLE_GOLD}" = "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

  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.
            eval noconfigdirs='"$noconfigdirs "'\"$target_libs $lang_dirs\"
	    ;;
	  no)
            # Remove language-dependent dirs; still show language as supported.
            eval noconfigdirs='"$noconfigdirs "'\"$target_libs $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,/,/"`
	    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

  AC_ARG_ENABLE(stage1-languages,
[  --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`