diff --git a/bootstrap b/bootstrap index 43625b2..d429495 100755 --- a/bootstrap +++ b/bootstrap @@ -14,6 +14,49 @@ AUTOMAKE="${AUTOMAKE} --foreign --add-missing --copy" export AUTOMAKE AUTOCONF ACLOCAL AUTOHEADER +# Get the avr-gcc to use. Do NOT assume the environment has CC set, +# because if the user exported CC before running bootstrap, that CC +# will remain in the environment after this script and might confuse +# other scripts. + +# Consume all arguments to support CC=$mypath/xgcc -B $mypath + +if test -z "$*"; then + CC="avr-gcc" +else + CC="$*" +fi + +# Check similar to the one in configure.ac to ensure we've got +# something that looks like avr-gcc. + +bad_cc () +{ + quot='"' + echo "error: wrong C compiler found or specified: ${quot}${CC}${quot}" + exit 1 +} + +case "${CC}" in + *gcc*) + case "X`${CC} -dumpmachine`X" in + XavrX) ;; + *) bad_cc ;; + esac ;; + *) bad_cc ;; +esac + +# Export CC so that devtools can use it. +export CC + +# Notify the user about the compiler version. +echo "avr compiler: `$CC --version | head -n 1`" + +# Write the compiler to a file so configure can pick it up. +# This is needed to make sure that bootstrap and configure +# are using the same compiler and same features. +echo "$CC" > cc.btstrp + # to see what is executed set -x diff --git a/configure.ac b/configure.ac index 174fbeb..5b6703d 100644 --- a/configure.ac +++ b/configure.ac @@ -136,6 +136,33 @@ m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64], # Checks for programs. +# The bootstrap scripts runs before this one and also runs autoconf. +# As bootstrap makes assumptions about the compiler, the following +# lines ensure that configure will use the same compiler as bootstrap. +# The nuisance is that autoconf does not provide any useful arguments +# to ship information from the caller of autoconf (bootstrap) to here, +# hence bootstrap wrote the used CC to cc.btstrp. Pick it up now. + +AC_MSG_CHECKING([which compiler was used during bootstrap]) + +if test -f ${srcdir}/cc.btstrp; then + cc_boot="`cat ${srcdir}/cc.btstrp`" + AC_MSG_RESULT([${cc_boot}]) +else + AC_MSG_RESULT([no bootstrap was run]) + AC_MSG_ERROR([you must run bootstrap before configure]) +fi + +if test -n "${CC}"; then + AC_MSG_ERROR([setting CC on the command line or in the environment is not + supported. if you want to use a special version of avr-gcc, please + run "bootstrap my-avr-gcc" before configure]) +fi + +CC="${cc_boot}" + +AC_MSG_NOTICE([bootstrap implies CC=${CC}]) + AC_PROG_CC AC_CHECK_TOOL(AS, as, as) AM_PROG_AS