Skip to content
Snippets Groups Projects
configure.ac 110 KiB
Newer Older
	      add_this_lang=${build_by_default}
	    fi
Paolo Bonzini's avatar
Paolo Bonzini committed
            ;;
        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
# Disable libcilkrts, libitm, libsanitizer, libvtv, liboffloadmic if we're not building C++
  *,c++,*)
    # Disable libcilkrts, libitm, libsanitizer if we're not building libstdc++
    case "${noconfigdirs}" in
      *target-libstdc++-v3*)
        noconfigdirs="$noconfigdirs target-libcilkrts target-libitm target-libsanitizer"
        ;;
      *) ;;
    esac
    ;;
    noconfigdirs="$noconfigdirs target-libcilkrts target-liboffloadmic target-libitm target-libsanitizer target-libvtv"
# 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

# 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

# Exclude target-zlib if target-libjava isn't built.
case ${target_configdirs} in
*target-libjava*)
  ;;
*)
  target_configdirs="`echo ${target_configdirs} | sed -e 's/target-zlib//'`"
  ;;
esac

# libiberty-linker-plugin is special: it doesn't have its own source directory,
# so we have to add it after the preceding checks.
if test x"$extra_linker_plugin_flags$extra_linker_plugin_configure_flags" != x
then
  case " $configdirs " in
    *" libiberty "*)
      # If we can build libiberty, we can also build libiberty-linker-plugin.
      configdirs="$configdirs libiberty-linker-plugin"
      extra_linker_plugin_configure_flags="$extra_linker_plugin_configure_flags \
        --with-libiberty=../libiberty-linker-plugin";;
    *)
      AC_MSG_ERROR([libiberty missing]);;
  esac
fi

# Sometimes we have special requirements for the host libiberty.
extra_host_libiberty_configure_flags=
extra_host_zlib_configure_flags=
case " $configdirs " in
  *" lto-plugin "* | *" libcc1 "*)
    # When these are to be built as shared libraries, the same applies to
    # libiberty.
    extra_host_libiberty_configure_flags=--enable-shared
    ;;
  *" bfd "*)
    # When bfd is to be built as a shared library, the same applies to
    # zlib.
    if test "$enable_shared" = "yes"; then
      extra_host_zlib_configure_flags=--enable-host-shared
    fi
    ;;
esac
AC_SUBST(extra_host_libiberty_configure_flags)
AC_SUBST(extra_host_zlib_configure_flags)
Paolo Bonzini's avatar
Paolo Bonzini committed
# 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
  if test "x${is_cross_compiler}" = xyes; then
    CFLAGS_FOR_TARGET="-g -O2"
  else
    CFLAGS_FOR_TARGET=$CFLAGS
    case " $CFLAGS " in
      *" -O2 "*) ;;
      *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
    esac
    case " $CFLAGS " in
      *" -g "* | *" -g3 "*) ;;
      *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
    esac
  fi
fi
AC_SUBST(CFLAGS_FOR_TARGET)

if test "x$CXXFLAGS_FOR_TARGET" = x; then
  if test "x${is_cross_compiler}" = xyes; then
    CXXFLAGS_FOR_TARGET="-g -O2"
  else
    CXXFLAGS_FOR_TARGET=$CXXFLAGS
    case " $CXXFLAGS " in
      *" -O2 "*) ;;
      *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
    esac
    case " $CXXFLAGS " in
      *" -g "* | *" -g3 "*) ;;
      *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
    esac
  fi
AC_SUBST(LDFLAGS_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.
if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
  if test x${is_cross_compiler} = xno ; then
    echo 1>&2 '***' --with-headers is only supported when cross compiling
    exit 1
  fi
  if test x"${with_headers}" != xyes ; then
    copy_dirs="${copy_dirs} ${with_headers} $x/${target_noncanonical}/sys-include"
Paolo Bonzini's avatar
Paolo Bonzini committed
  fi
fi

# Handle --with-libs=XXX.  If the value is not "yes", the contents of
# the name directories are copied to $(tooldir)/lib.  Multiple directories
# are permitted.
if test x"${with_libs}" != x && test x"${with_libs}" != xno ; then
  if test x${is_cross_compiler} = xno ; then
    echo 1>&2 '***' --with-libs is only supported when cross compiling
    exit 1
  fi
  if test x"${with_libs}" != xyes ; then
    # Copy the libraries in reverse order, so that files in the first named
    # library override files in subsequent libraries.
Paolo Bonzini's avatar
Paolo Bonzini committed
    for l in ${with_libs}; do
      copy_dirs="$l $x/${target_noncanonical}/lib ${copy_dirs}"
Paolo Bonzini's avatar
Paolo Bonzini committed
    done
  fi
fi

# Set with_gnu_as, with_gnu_ld, and with_system_zlib as appropriate.
#
# This is done by determining whether or not the appropriate directory
# is available, and by checking whether or not specific configurations
# have requested that this magic not happen.
# 
# The command line options always override the explicit settings in 
# configure.ac, and the settings in configure.ac override this magic.
#
# If the default for a toolchain is to use GNU as and ld, and you don't 
# want to do that, then you should use the --without-gnu-as and
# --without-gnu-ld options for the configure script.  Similarly, if
# the default is to use the included zlib and you don't want to do that,
# you should use the --with-system-zlib option for the configure script.

if test x${use_gnu_as} = x &&
   echo " ${configdirs} " | grep " gas " > /dev/null 2>&1 ; then
  with_gnu_as=yes
  extra_host_args="$extra_host_args --with-gnu-as"
fi

if test x${use_gnu_ld} = x &&
   echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
  with_gnu_ld=yes
  extra_host_args="$extra_host_args --with-gnu-ld"
fi

if test x${use_included_zlib} = x &&
   echo " ${configdirs} " | grep " zlib " > /dev/null 2>&1 ; then
  :
else
  with_system_zlib=yes
  extra_host_args="$extra_host_args --with-system-zlib"
fi

# If using newlib, add --with-newlib to the extra_host_args so that gcc/configure
# can detect this case.

if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 ; then
  with_newlib=yes
  extra_host_args="$extra_host_args --with-newlib"
fi

Paolo Bonzini's avatar
Paolo Bonzini committed
# Handle ${copy_dirs}
set fnord ${copy_dirs}
shift
while test $# != 0 ; do
  if test -f $2/COPIED && test x"`cat $2/COPIED`" = x"$1" ; then
    :
  else
    echo Copying $1 to $2

    # Use the install script to create the directory and all required
    # parent directories.
    if test -d $2 ; then
      :
    else
      echo >config.temp
      ${srcdir}/install-sh -c -m 644 config.temp $2/COPIED
    fi

    # Copy the directory, assuming we have tar.
    # FIXME: Should we use B in the second tar?  Not all systems support it.
    (cd $1; tar -cf - .) | (cd $2; tar -xpf -)

    # It is the responsibility of the user to correctly adjust all
    # symlinks.  If somebody can figure out how to handle them correctly
    # here, feel free to add the code.

    echo $1 > $2/COPIED
  fi
  shift; shift
done

# Determine a target-dependent exec_prefix that the installed
# gcc will search in.  Keep this list sorted by triplet, with
# the *-*-osname triplets last.
md_exec_prefix=
case "${target}" in
    md_exec_prefix=/dev/env/DJDIR/bin
    ;;
  *-*-hpux* | \
  *-*-nto-qnx* | \
extra_arflags_for_target=
extra_nmflags_for_target=
extra_ranlibflags_for_target=
target_makefile_frag=/dev/null
case "${target}" in
  spu-*-*)
    target_makefile_frag="config/mt-spu"
    ;;
  mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
Richard Sandiford's avatar
Richard Sandiford committed
    target_makefile_frag="config/mt-sde"
    ;;
  mipsisa*-*-elfoabi*)
    target_makefile_frag="config/mt-mips-elfoabi"
    ;;
  mips*-*-*linux* | mips*-*-gnu*)
    target_makefile_frag="config/mt-mips-gnu"
    ;;
  nios2-*-elf*)
    target_makefile_frag="config/mt-nios2-elf"
    ;;
  *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
    target_makefile_frag="config/mt-gnu"
  *-*-aix4.[[3456789]]* | *-*-aix[[56789]].*)
    # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm 
    # commands to handle both 32-bit and 64-bit objects.  These flags are
    # harmless if we're using GNU nm or ar.
    extra_arflags_for_target=" -X32_64"
    extra_nmflags_for_target=" -B -X32_64"
alphaieee_frag=/dev/null
case $target in
  alpha*-*-*)
    # This just makes sure to use the -mieee option to build target libs.
    # This should probably be set individually by each library.
    alphaieee_frag="config/mt-alphaieee"
# If --enable-target-optspace always use -Os instead of -O2 to build
# the target libraries, similarly if it is not specified, use -Os
# on selected platforms.
ospace_frag=/dev/null
case "${enable_target_optspace}:${target}" in
  yes:*)
  :m32r-* | :d10v-* | :fr30-* | :i?86*-*-elfiamcu)
    ;;
  no:* | :*)
    ;;
  *)
    echo "*** bad value \"${enable_target_optspace}\" for --enable-target-optspace flag; ignored" 1>&2
    ;;
esac
Jason Merrill's avatar
Jason Merrill committed

# Some systems (e.g., one of the i386-aix systems the gas testers are
# using) don't handle "\$" correctly, so don't use it here.
tooldir='${exec_prefix}'/${target_noncanonical}
build_tooldir=${tooldir}

# Create a .gdbinit file which runs the one in srcdir
# and tells GDB to look there for source files.

if test -r ${srcdir}/.gdbinit ; then
  case ${srcdir} in
    .) ;;
    *) cat > ./.gdbinit <<EOF
# ${NO_EDIT}
dir ${srcdir}
dir .
source ${srcdir}/.gdbinit
EOF
    ;;
  esac
fi

Jason Merrill's avatar
Jason Merrill committed
# Make sure that the compiler is able to generate an executable.  If it
# can't, we are probably in trouble.  We don't care whether we can run the
# executable--we might be using a cross compiler--we only care whether it
# can be created.  At this point the main configure script has set CC.
Jason Merrill's avatar
Jason Merrill committed
echo "int main () { return 0; }" > conftest.c
${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
if test $? = 0 ; then
  if test -s conftest || test -s conftest.exe ; then
    we_are_ok=yes
  fi
fi 
case $we_are_ok in
  no)
    echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
    echo 1>&2 "*** You must set the environment variable CC to a working compiler."
    rm -f conftest*
    exit 1
    ;;
esac
Jason Merrill's avatar
Jason Merrill committed
rm -f conftest*

# Decide which environment variable is used to find dynamic libraries.
case "${host}" in
  *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
  *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
  *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
  *) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
esac

# On systems where the dynamic library environment variable is PATH,
# gcc/ will put dynamic libraries into a subdirectory to avoid adding
# built executables to PATH.
if test "$RPATH_ENVVAR" = PATH; then
  GCC_SHLIB_SUBDIR=/shlib
else
  GCC_SHLIB_SUBDIR=
fi

# Adjust the toplevel makefile according to whether bootstrap was selected.
case $enable_bootstrap in
  yes)
    bootstrap_suffix=bootstrap
    BUILD_CONFIG=bootstrap-debug
    ;;
  no)
    bootstrap_suffix=no-bootstrap
    BUILD_CONFIG=
    ;;
esac

AC_MSG_CHECKING(for default BUILD_CONFIG)

AC_ARG_WITH([build-config],
  [AS_HELP_STRING([--with-build-config='NAME NAME2...'],
		  [use config/NAME.mk build configuration])],
  [case $with_build_config in
   yes) with_build_config= ;;
   no) with_build_config= BUILD_CONFIG= ;;
   esac])

if test "x${with_build_config}" != x; then
  BUILD_CONFIG=$with_build_config
else
  case $BUILD_CONFIG in
  bootstrap-debug)
    if echo "int f (void) { return 0; }" > conftest.c &&
       ${CC} -c conftest.c &&
       mv conftest.o conftest.o.g0 &&
       ${CC} -c -g conftest.c &&
       mv conftest.o conftest.o.g &&
       ${srcdir}/contrib/compare-debug conftest.o.g0 conftest.o.g > /dev/null 2>&1; then
      :
    else
      BUILD_CONFIG=
    fi
    rm -f conftest.c conftest.o conftest.o.g0 conftest.o.g
    ;;
  esac
fi
AC_MSG_RESULT($BUILD_CONFIG)
AC_SUBST(BUILD_CONFIG)

# Use same top-level configure hooks in libgcc/libstdc++/libvtv.
AC_MSG_CHECKING([for --enable-vtable-verify])
AC_ARG_ENABLE(vtable-verify,
[AS_HELP_STRING([--enable-vtable-verify],
		[Enable vtable verification feature])],
[case "$enableval" in
 yes) enable_vtable_verify=yes ;;
 no)  enable_vtable_verify=no ;;
 *)   enable_vtable_verify=no;;
 esac],
[enable_vtable_verify=no])
AC_MSG_RESULT($enable_vtable_verify)

# Record target_configdirs and the configure arguments for target and
# build configuration in Makefile.
target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
build_configdirs=`echo "${build_configdirs}" | sed -e 's/build-//g'`
# If we are building libgomp, bootstrap it.
if echo " ${target_configdirs} " | grep " libgomp " > /dev/null 2>&1 ; then
  bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
fi

# If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
# or bootstrap-ubsan, bootstrap it.
if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; then
  case "$BUILD_CONFIG" in
    *bootstrap-asan* | *bootstrap-ubsan* )
      bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
# If we are building libvtv and --enable-vtable-verify, bootstrap it.
if echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 &&
   test "$enable_vtable_verify" != no; then
  bootstrap_target_libs=${bootstrap_target_libs}target-libvtv,
fi

Ilya Enkovich's avatar
Ilya Enkovich committed
# If we are building libmpx, bootstrap it.
if echo " ${target_configdirs} " | grep " libmpx " > /dev/null 2>&1; then
  bootstrap_target_libs=${bootstrap_target_libs}target-libmpx,
fi

# Determine whether gdb needs tk/tcl or not.
# Use 'maybe' since enable_gdbtk might be true even if tk isn't available
# and in that case we want gdb to be built without tk.  Ugh!
# In fact I believe gdb is the *only* package directly dependent on tk,
# so we should be able to put the 'maybe's in unconditionally and
# leave out the maybe dependencies when enable_gdbtk is false.  I'm not
# 100% sure that that's safe though.
gdb_tk="maybe-all-tcl maybe-all-tk maybe-all-itcl maybe-all-libgui"
case "$enable_gdbtk" in
  no)
    GDB_TK="" ;;
    # Only add the dependency on gdbtk when GDBtk is part of the gdb
    # distro.  Eventually someone will fix this and move Insight, nee
    # gdbtk to a separate directory.
    if test -d ${srcdir}/gdb/gdbtk ; then
      GDB_TK="${gdb_tk}"
    else
      GDB_TK=""
    fi
    ;;
CONFIGURE_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-configure-/g`
INSTALL_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-install-/g`
# Strip out unwanted targets.
Nathanael Nerode's avatar
Nathanael Nerode committed

# While at that, we remove Makefiles if we were started for recursive
# configuration, so that the top-level Makefile reconfigures them,
# like we used to do when configure itself was recursive.

# Loop over modules.  We used to use the "$extrasub" feature from Autoconf
# but now we're fixing up the Makefile ourselves with the additional
# commands passed to AC_CONFIG_FILES.  Use separate variables
# extrasub-{build,host,target} not because there is any reason to split
# the substitutions up that way, but only to remain below the limit of
# 99 commands in a script, for HP-UX sed.
# Do not nest @if/@endif pairs, because configure will not warn you at all.
Nathanael Nerode's avatar
Nathanael Nerode committed

case "$enable_bootstrap:$ENABLE_GOLD: $configdirs :,$stage1_languages," in
  yes:yes:*\ gold\ *:*,c++,*) ;;
  yes:yes:*\ gold\ *:*)
    AC_MSG_ERROR([in a combined tree, bootstrapping with --enable-gold requires c++ in stage1_languages])
    ;;
esac

for module in ${build_configdirs} ; do
Nathanael Nerode's avatar
Nathanael Nerode committed
  if test -z "${no_recursion}" \
     && test -f ${build_subdir}/${module}/Makefile; then
    echo 1>&2 "*** removing ${build_subdir}/${module}/Makefile to force reconfigure"
    rm -f ${build_subdir}/${module}/Makefile
  fi
  extrasub_build="$extrasub_build
/^@endif build-$module\$/d
/^@if build-$module-$bootstrap_suffix\$/d
/^@endif build-$module-$bootstrap_suffix\$/d"
Nathanael Nerode's avatar
Nathanael Nerode committed
done
Nathanael Nerode's avatar
Nathanael Nerode committed
for module in ${configdirs} ; do
    for file in stage*-${module}/Makefile prev-${module}/Makefile ${module}/Makefile; do
      if test -f ${file}; then
	echo 1>&2 "*** removing ${file} to force reconfigure"
	rm -f ${file}
      fi
    done
Nathanael Nerode's avatar
Nathanael Nerode committed
  fi
  case ${module},${bootstrap_fixincludes} in
    fixincludes,no) host_bootstrap_suffix=no-bootstrap ;;
    *) host_bootstrap_suffix=$bootstrap_suffix ;;
  esac
  extrasub_host="$extrasub_host
/^@if $module-$host_bootstrap_suffix\$/d
/^@endif $module-$host_bootstrap_suffix\$/d"
Nathanael Nerode's avatar
Nathanael Nerode committed
done
extrasub_target=
Nathanael Nerode's avatar
Nathanael Nerode committed
for module in ${target_configdirs} ; do
  if test -z "${no_recursion}" \
     && test -f ${target_subdir}/${module}/Makefile; then
    echo 1>&2 "*** removing ${target_subdir}/${module}/Makefile to force reconfigure"
    rm -f ${target_subdir}/${module}/Makefile
  fi

  # We only bootstrap target libraries listed in bootstrap_target_libs.
  case $bootstrap_target_libs in
    *,target-$module,*) target_bootstrap_suffix=$bootstrap_suffix ;;
    *) target_bootstrap_suffix=no-bootstrap ;;
  esac

  extrasub_target="$extrasub_target
/^@if target-$module\$/d
/^@if target-$module-$target_bootstrap_suffix\$/d
/^@endif target-$module-$target_bootstrap_suffix\$/d"
# Do the final fixup along with target modules.
extrasub_target="$extrasub_target

# Create the serialization dependencies.  This uses a temporary file.

[AS_HELP_STRING([[--enable-serial-[{host,target,build}-]configure]],
		[force sequential configuration of
		 sub-packages for the host, target or build
		 machine, or all sub-packages])])

case ${enable_serial_configure} in
  yes)
    enable_serial_build_configure=yes
    enable_serial_host_configure=yes
    enable_serial_target_configure=yes
    ;;
esac
# These force 'configure's to be done one at a time, to avoid problems
# with contention over a shared config.cache.
rm -f serdep.tmp
test "x${enable_serial_build_configure}" = xyes &&
for item in ${build_configdirs} ; do
  case ${olditem} in
    "") ;;
    *) echo "configure-build-${item}: configure-build-${olditem}" >> serdep.tmp ;;
  esac
  olditem=${item}
done
olditem=
test "x${enable_serial_host_configure}" = xyes &&
for item in ${configdirs} ; do
  case ${olditem} in
    "") ;;
    *) echo "configure-${item}: configure-${olditem}" >> serdep.tmp ;;
  esac
  olditem=${item}
done
olditem=
test "x${enable_serial_target_configure}" = xyes &&
for item in ${target_configdirs} ; do
  case ${olditem} in
    "") ;;
    *) echo "configure-target-${item}: configure-target-${olditem}" >> serdep.tmp ;;
  esac
  olditem=${item}
done
serialization_dependencies=serdep.tmp
AC_SUBST_FILE(serialization_dependencies)
# Base args.  Strip norecursion, cache-file, srcdir, host, build,
# target, nonopt, and variable assignments.  These are the ones we
# might not want to pass down to subconfigures.  The exception being
# --cache-file=/dev/null, which is used to turn off the use of cache
# files altogether, and which should be passed on to subconfigures.
# Also strip program-prefix, program-suffix, and program-transform-name,
# so that we can pass down a consistent program-transform-name.
keep_next=no
skip_next=no
eval "set -- $ac_configure_args"
  if test X"$skip_next" = X"yes"; then
    skip_next=no
    continue
  fi
  if test X"$keep_next" = X"yes"; then
    case $ac_arg in
      *\'*)
	ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
    esac
    baseargs="$baseargs '$ac_arg'"
    keep_next=no
    continue
  fi

  # Handle separated arguments.  Based on the logic generated by
  # autoconf 2.59.
  case $ac_arg in
    *=* | --config-cache | -C | -disable-* | --disable-* \
      | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
      | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
      | -with-* | --with-* | -without-* | --without-* | --x)
      separate_arg=no
      ;;
    -*)
      separate_arg=yes
      ;;
    *)
      separate_arg=no
      ;;
  esac

  skip_targ=no
  case $ac_arg in
changequote(,)
  --with-* | --without-*)
    libopt=`echo "$ac_arg" | sed -e 's,^--[^-_]*[-_],,' -e 's,=.*$,,'`

    case $libopt in
    *[-_]include)
      lib=`echo "$libopt" | sed 's,[-_]include$,,'`
      ;;
    *[-_]lib)
      lib=`echo "$libopt" | sed 's,[-_]lib$,,'`
      ;;
    *)
      lib=$libopt
      ;;
    esac
changequote([,])

    case $lib in
Tobias Burnus's avatar
Tobias Burnus committed
    mpc | mpfr | gmp | isl)
      # If we're processing --with-$lib, --with-$lib-include or
      # --with-$lib-lib, for one of the libs above, and target is
      # different from host, don't pass the current argument to any
      # target library's configure.
      if test x$is_cross_compiler = xyes; then
        skip_targ=yes
      fi
      ;;
    esac
    ;;
  esac

    --cache-file=/dev/null | \
    -cache-file=/dev/null )
      # Handled here to avoid the test to skip args below.
      baseargs="$baseargs '$ac_arg'"
      # Assert: $separate_arg should always be no.
      keep_next=$separate_arg
      ;;
    --no*)
      continue
      ;;
    --c* | \
    --sr* | \
    --ho* | \
    --bu* | \
    --t* | \
    --program-* | \
    -cache_file* | \
    -srcdir* | \
    -host* | \
    -build* | \
    -target* | \
    -program-prefix* | \
    -program-suffix* | \
    -program-transform-name* )