diff options
Diffstat (limited to 'scripts/crosstool-NG.sh.in')
-rw-r--r-- | scripts/crosstool-NG.sh.in | 118 |
1 files changed, 82 insertions, 36 deletions
diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index a2032bc..ba30c4f 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -28,6 +28,29 @@ # Overide the locale early, in case we ever translate crosstool-NG messages [ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C +# Some sanity checks in the environment and needed tools +CT_DoLog INFO "Performing some trivial sanity checks" +CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}" +CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}" +CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}" +CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}" +export GREP_OPTIONS= + +# Some sanity checks on paths content +for d in \ + LOCAL_TARBALLS \ + WORK \ + PREFIX \ + INSTALL \ + ; do + eval dir="\${CT_${d}_DIR}" + case "${dir}" in + *" "*) + CT_Abort "'CT_${d}_DIR'='${dir}' contains a space in it.\nDon't use spaces in paths, it breaks things." + ;; + esac +done + # Where will we work? CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/targets}" CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}" @@ -37,6 +60,19 @@ CT_DoExecLog DEBUG touch "${CT_WORK_DIR}/foo" CT_TestAndAbort "Your file system in '${CT_WORK_DIR}' is *not* case-sensitive!" -f "${CT_WORK_DIR}/FOO" CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/foo" +# What's our shell? +# Will be plain /bin/sh on most systems, except if we have /bin/ash and we +# _explictly_ required using it +case "${CT_CONFIG_SHELL}" in + sh) CT_SHELL="/bin/sh";; + ash) CT_SHELL="/bin/ash";; + bash) CT_SHELL="${BASH}";; + custom) CT_SHELL="${CT_CONFIG_SHELL_CUSTOM_PATH}";; +esac + +# Check the user is using an existing SHELL to be used by ./configure and Makefiles +CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' (${CT_SHELL}) is not valid" -f "${CT_SHELL}" -a -x "${CT_SHELL}" + # Create the bin-overide early # Contains symlinks to the tools found by ./configure # Note: CT_DoLog and CT_DoExecLog do not use any of those tool, so @@ -48,12 +84,13 @@ cat "${CT_LIB_DIR}/paths.mk" |while read trash line; do tool="${line%%=*}" path="${line#*=}" CT_DoLog DEBUG " '${tool}' -> '${path}'" - printf "#${BANG}/bin/sh\nexec '${path}' \"\${@}\"\n" >"${CT_BIN_OVERIDE_DIR}/${tool}" + printf "#${BANG}${CT_SHELL}\nexec '${path}' \"\${@}\"\n" >"${CT_BIN_OVERIDE_DIR}/${tool}" CT_DoExecLog ALL chmod 700 "${CT_BIN_OVERIDE_DIR}/${tool}" done export PATH="${CT_BIN_OVERIDE_DIR}:${PATH}" # Start date. Can't be done until we know the locale +# Also requires the bin-override tools CT_STAR_DATE=$(CT_DoDate +%s%N) CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) @@ -67,20 +104,10 @@ CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" CT_DoExecLog DEBUG grep -E '^(# |)CT_' .config CT_EndStep -# Some sanity checks in the environment and needed tools -CT_DoLog INFO "Checking environment sanity" - CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS" unset MAKEFLAGS export MAKEFLAGS -# Other environment sanity checks -CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}" -CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}" -CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}" -CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}" -export GREP_OPTIONS= - CT_DoLog INFO "Building environment variables" # Include sub-scripts instead of calling them: that way, we do not have to @@ -91,6 +118,8 @@ CT_DoLog INFO "Building environment variables" . "${CT_LIB_DIR}/scripts/build/companion_libs/gmp.sh" . "${CT_LIB_DIR}/scripts/build/companion_libs/mpfr.sh" . "${CT_LIB_DIR}/scripts/build/companion_libs/ppl.sh" +. "${CT_LIB_DIR}/scripts/build/companion_libs/cloog.sh" +. "${CT_LIB_DIR}/scripts/build/companion_libs/mpc.sh" . "${CT_LIB_DIR}/scripts/build/binutils/binutils.sh" . "${CT_LIB_DIR}/scripts/build/binutils/elf2flt.sh" . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" @@ -113,7 +142,7 @@ CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}" CT_CC_CORE_EXTRA_CONFIG="${CT_ARCH_CC_CORE_EXTRA_CONFIG} ${CT_CC_CORE_EXTRA_CONFIG}" CT_CC_EXTRA_CONFIG="${CT_ARCH_CC_EXTRA_CONFIG} ${CT_CC_EXTRA_CONFIG}" -# Create the working directories +# Compute the working directories names CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" CT_SRC_DIR="${CT_WORK_DIR}/src" CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build" @@ -125,6 +154,10 @@ CT_CONFIG_DIR="${CT_BUILD_DIR}/configs" CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static" CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared" +# Set LD_LIBRARY_PATH to point to prefix/lib so we can find our own +# libraries; add as first path, so we get hit first by the dynamic linker +CT_SetLibPath "${CT_PREFIX_DIR}/lib" first + # We must ensure that we can restart if asked for! if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}" ]; then CT_DoLog ERROR "You asked to restart a non-restartable build" @@ -140,11 +173,6 @@ if [ ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then CT_SAVE_TARBALLS= fi -# Some more sanity checks now that we have all paths set up -case "${CT_LOCAL_TARBALLS_DIR},${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in - *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";; -esac - # Check now if we can write to the destination directory: if [ -d "${CT_INSTALL_DIR}" ]; then CT_TestAndAbort "Destination directory '${CT_INSTALL_DIR}' is not removable" ! -w $(dirname "${CT_INSTALL_DIR}") @@ -202,8 +230,10 @@ CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}" CT_DoExecLog ALL mkdir -p "${CT_CONFIG_DIR}" CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}" CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}" +if [ -z "${CT_CANADIAN}" ]; then + CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}" + CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}" +fi # Only create the state dir if asked for a restartable build [ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}" @@ -235,12 +265,6 @@ esac # Setting up the rest of the environment only if not restarting if [ -z "${CT_RESTART}" ]; then - # What's our shell? - # Will be plain /bin/sh on most systems, except if we have /bin/ash and we - # _explictly_ required using it - CT_SHELL="/bin/sh" - [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash" - # Arrange paths depending on wether we use sys-root or not. if [ "${CT_USE_SYSROOT}" = "y" ]; then CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/sys-root" @@ -257,6 +281,7 @@ if [ -z "${CT_RESTART}" ]; then else # plain old way. All libraries in prefix/target/lib CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}" + CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}" CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include" # hack! Always use --with-sysroot for binutils. # binutils 2.14 and later obey it, older binutils ignore it. @@ -280,8 +305,10 @@ if [ -z "${CT_RESTART}" ]; then CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib" CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib" - # Prevent gcc from installing its libraries outside of the sys-root - CT_DoExecLog ALL ln -sf "./${CT_SYSROOT_DIR_PREFIX}/sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib" + if [ "${CT_USE_SYSROOT}" = "y" ]; then + # Prevent gcc from installing its libraries outside of the sys-root + CT_DoExecLog ALL ln -sf "./${CT_SYSROOT_DIR_PREFIX}/sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib" + fi # Now, in case we're 64 bits, just have lib64/ be a symlink to lib/ # so as to have all libraries in the same directory (we can do that @@ -302,9 +329,18 @@ if [ -z "${CT_RESTART}" ]; then # Prepare mangling patterns to later modify BUILD and HOST (see below) case "${CT_TOOLCHAIN_TYPE}" in cross) + # A cross-compiler runs on the same machine it is built on CT_HOST="${CT_BUILD}" build_mangle="build_" host_mangle="build_" + target_mangle="" + install_build_tools_for="BUILD HOST" + ;; + canadian) + build_mangle="build_" + host_mangle="host_" + target_mangle="" + install_build_tools_for="BUILD HOST TARGET" ;; *) CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!" ;; @@ -313,11 +349,13 @@ if [ -z "${CT_RESTART}" ]; then # Save the real tuples to generate shell-wrappers to the real tools CT_REAL_BUILD="${CT_BUILD}" CT_REAL_HOST="${CT_HOST}" + CT_REAL_TARGET="${CT_TARGET}" # Canonicalise CT_BUILD and CT_HOST # Not only will it give us full-qualified tuples, but it will also ensure # that they are valid tuples (in case of typo with user-provided tuples) # That's way better than trying to rewrite config.sub ourselves... + # CT_TARGET is already made canonical in CT_DoBuildTargetTuple CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}") CT_HOST=$(CT_DoConfigSub "${CT_HOST}") @@ -327,12 +365,13 @@ if [ -z "${CT_RESTART}" ]; then # support canadain build, later... CT_BUILD="${CT_BUILD/-/-${build_mangle}}" CT_HOST="${CT_HOST/-/-${host_mangle}}" + CT_TARGET="${CT_TARGET/-/-${target_mangle}}" # Now we have mangled our BUILD and HOST tuples, we must fake the new # cross-tools for those mangled tuples. CT_DoLog DEBUG "Making build system tools available" - CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin" - for m in BUILD HOST; do + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/buildtools" + for m in ${install_build_tools_for}; do r="CT_REAL_${m}" v="CT_${m}" p="CT_${m}_PREFIX" @@ -368,12 +407,12 @@ if [ -z "${CT_RESTART}" ]; then # bally needed if [ -n "${where}" ]; then CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'" - printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${!v}-${tool}" - CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/${!v}-${tool}" + printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/buildtools/${!v}-${tool}" + CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/buildtools/${!v}-${tool}" else case "${tool}" in # We'll at least need some of them... - ar|as|gcc|ld|nm|objcopy|objdump|ranlib) + ar|as|gcc|g++|ld|nm|objcopy|objdump|ranlib) CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" ;; # Some are conditionnally required @@ -399,7 +438,8 @@ if [ -z "${CT_RESTART}" ]; then # Of course, neither cross-native nor canadian can run on BUILD, # so don't add those PATHs in this case... case "${CT_TOOLCHAIN_TYPE}" in - cross) export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";; + cross) export PATH="${CT_PREFIX_DIR}/buildtools:${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";; + canadian) export PATH="${CT_PREFIX_DIR}/buildtools:${PATH}";; *) ;; esac @@ -407,8 +447,8 @@ if [ -z "${CT_RESTART}" ]; then # Go ahead with those, by creating a wrapper that keeps partial files, and that # never fails: CT_DoLog DEBUG " 'makeinfo' -> '$(CT_Which makeinfo)'" - printf "#${BANG}/bin/sh\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_PREFIX_DIR}/bin/makeinfo" - CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/makeinfo" + printf "#${BANG}${CT_SHELL}\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_PREFIX_DIR}/buildtools/makeinfo" + CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/buildtools/makeinfo" # Help gcc CT_CFLAGS_FOR_HOST= @@ -419,7 +459,8 @@ if [ -z "${CT_RESTART}" ]; then # Set the shell to be used by ./configure scripts and by Makefiles (those # that support it!). - export CONFIG_SHELL="${CT_SHELL}" + export CONFIG_SHELL="${CT_SHELL}" # for ./configure + export SHELL="${CT_SHELL}" # for Makefiles # And help make go faster PARALLELMFLAGS= @@ -428,6 +469,7 @@ if [ -z "${CT_RESTART}" ]; then export PARALLELMFLAGS CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration" + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin" CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" CT_DoExecLog DEBUG sed -r -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" @@ -447,6 +489,8 @@ if [ -z "${CT_RESTART}" ]; then do_gmp_get do_mpfr_get do_ppl_get + do_cloog_get + do_mpc_get do_binutils_get do_cc_get do_libc_get @@ -464,6 +508,8 @@ if [ -z "${CT_RESTART}" ]; then do_gmp_extract do_mpfr_extract do_ppl_extract + do_cloog_extract + do_mpc_extract do_binutils_extract do_cc_extract do_libc_extract |