+AC_SUBST(extra_mpfr_configure_flags)
+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)
+
+# 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],
+[if test "$ENABLE_BUILD_WITH_CXX" = "yes"; then
+ poststage1_ldflags=-static-libstdc++
+ else
+ poststage1_ldflags=
+ fi])
+AC_SUBST(poststage1_ldflags)
+
+# 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
+ poststage1_libs=$withval
+ fi],
+[poststage1_libs=$with_host_libstdcxx])
+AC_SUBST(poststage1_libs)
+
+# 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])
+
+case $with_ppl in
+ no)
+ ppllibs=
+ ;;
+ "" | yes)
+ ;;
+ *)
+ ppllibs="-L$with_ppl/lib -lppl_c -lppl -lgmpxx"
+ pplinc="-I$with_ppl/include $pplinc"
+ ;;
+esac
+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
+fi
+
+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
+ with_cloog=no
+fi
+
+case $with_cloog in
+ no)
+ clooglibs=
+ clooginc=
+ ;;
+ "" | yes)
+ ;;
+ *)
+ 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
+fi
+
+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 correct version of CLooG])
+ AC_TRY_COMPILE([#include "cloog/cloog.h"],[
+ #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15
+ 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"
+
+ else
+
+ 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"
+
+ fi
+
+ # Flags needed for libelf.
+ AC_SUBST(libelflibs)
+ AC_SUBST(libelfinc)
+fi
+