From 26713d42100ebb0f949777060102b8fa20c22ffd Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sun, 1 Jul 2007 19:04:20 +0000 Subject: Merge the build system to trunk: ct-ng is now installable: - ./configure --prefix=/some/place - make - make install - export PATH="${PATH}:/some/place/bin" - ct-ng --- scripts/build/debug.sh | 2 +- scripts/build/tools.sh | 2 +- scripts/crosstool.sh | 34 +++++++--------- scripts/functions | 24 +++++++++++- scripts/saveSample.sh | 31 +++++++-------- scripts/showSamples.sh | 13 +++++-- scripts/tarball.sh | 98 ----------------------------------------------- scripts/tarball.sh.broken | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 158 insertions(+), 144 deletions(-) delete mode 100755 scripts/tarball.sh create mode 100755 scripts/tarball.sh.broken (limited to 'scripts') diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh index 4a3a6cf2..d2cca62f 100644 --- a/scripts/build/debug.sh +++ b/scripts/build/debug.sh @@ -2,7 +2,7 @@ # List all debug facilities, and parse their scripts CT_DEBUG_FACILITY_LIST= -for f in "${CT_TOP_DIR}/scripts/build/debug/"*.sh; do +for f in "${CT_LIB_DIR}/scripts/build/debug/"*.sh; do is_enabled= . "${f}" f=`basename "${f}" .sh` diff --git a/scripts/build/tools.sh b/scripts/build/tools.sh index ebc81316..e61b16f8 100644 --- a/scripts/build/tools.sh +++ b/scripts/build/tools.sh @@ -2,7 +2,7 @@ # List all tools facilities, and parse their scripts CT_TOOLS_FACILITY_LIST= -for f in "${CT_TOP_DIR}/scripts/build/tools/"*.sh; do +for f in "${CT_LIB_DIR}/scripts/build/tools/"*.sh; do is_enabled= . "${f}" f=`basename "${f}" .sh` diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh index 9b0fd955..4e4f2941 100755 --- a/scripts/crosstool.sh +++ b/scripts/crosstool.sh @@ -12,17 +12,8 @@ # options. It also checks the existing environment for un-friendly variables, # and builds the tools. -# CT_TOP_DIR is set by the makefile. If we don't have it, something's gone horribly wrong... -if [ -z "${CT_TOP_DIR}" -o ! -d "${CT_TOP_DIR}" ]; then - # We don't have the functions right now, because we don't have CT_TOP_DIR. - # Do the print stuff by hand: - echo "CT_TOP_DIR not set, or not a directory. Something's gone horribly wrong." - echo "Please send a bug report (see README)" - exit 1 -fi - # Parse the common functions -. "${CT_TOP_DIR}/scripts/functions" +. "${CT_LIB_DIR}/scripts/functions" CT_STAR_DATE=`CT_DoDate +%s%N` CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S` @@ -41,7 +32,7 @@ renice ${CT_NICE} $$ |CT_DoLog DEBUG CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" CT_DoStep DEBUG "Dumping crosstool-NG configuration" -cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG +cat "${CT_TOP_DIR}/.config" |egrep '^(# |)CT_' |CT_DoLog DEBUG CT_EndStep # Some sanity checks in the environment and needed tools @@ -143,7 +134,7 @@ CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"` CT_SYS_MACHINE=`uname -m` CT_SYS_PROCESSOR=`uname -p` CT_SYS_GCC=`gcc -dumpversion` -CT_SYS_TARGET=`${CT_TOP_DIR}/tools/config.guess` +CT_SYS_TARGET=`CT_DoConfigGuess` CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}" CT_DoLog EXTRA "Preparing working directories" @@ -225,7 +216,8 @@ esac if [ -z "${CT_RESTART}" ]; then # Determine build system if not set by the user CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}" - CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`" + CT_BUILD="${CT_BUILD:-`CT_DoConfigGuess`}" + CT_BUILD=`CT_DoConfigSub "${CT_BUILD}"` # Arrange paths depending on wether we use sys-root or not. if [ "${CT_USE_SYSROOT}" = "y" ]; then @@ -345,14 +337,14 @@ fi # Include sub-scripts instead of calling them: that way, we do not have to # export any variable, nor re-parse the configuration and functions files. -. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh" -. "${CT_TOP_DIR}/scripts/build/binutils.sh" -. "${CT_TOP_DIR}/scripts/build/libfloat.sh" -. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh" -. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh" -. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh" -. "${CT_TOP_DIR}/scripts/build/debug.sh" -. "${CT_TOP_DIR}/scripts/build/tools.sh" +. "${CT_LIB_DIR}/scripts/build/kernel_${CT_KERNEL}.sh" +. "${CT_LIB_DIR}/scripts/build/binutils.sh" +. "${CT_LIB_DIR}/scripts/build/libfloat.sh" +. "${CT_LIB_DIR}/scripts/build/libc_${CT_LIBC}.sh" +. "${CT_LIB_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh" +. "${CT_LIB_DIR}/scripts/build/cc_${CT_CC}.sh" +. "${CT_LIB_DIR}/scripts/build/debug.sh" +. "${CT_LIB_DIR}/scripts/build/tools.sh" if [ -z "${CT_RESTART}" ]; then CT_DoStep INFO "Retrieving needed toolchain components' tarballs" diff --git a/scripts/functions b/scripts/functions index d66fe22e..18ee9695 100644 --- a/scripts/functions +++ b/scripts/functions @@ -425,7 +425,9 @@ CT_ExtractAndPatch() { cd "${file}" fi - [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}" + official_patch_dir= + custom_patch_dir= + [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_LIB_DIR}/patches/${base_file}/${ver_file}" [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}" for patch_dir in "${official_patch_dir}" "${custom_patch_dir}"; do if [ -n "${patch_dir}" -a -d "${patch_dir}" ]; then @@ -442,6 +444,24 @@ CT_ExtractAndPatch() { CT_Popd } +# Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR. +# Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. +CT_DoConfigGuess() { + if [ -x "${CT_TOP_DIR}/tools/config.guess" ]; then + "${CT_TOP_DIR}/tools/config.guess" + else + "${CT_LIB_DIR}/tools/config.guess" + fi +} + +CT_DoConfigSub() { + if [ -x "${CT_TOP_DIR}/tools/config.sub" ]; then + "${CT_TOP_DIR}/tools/config.sub" "$@" + else + "${CT_LIB_DIR}/tools/config.sub" "$@" + fi +} + # Compute the target triplet from what is provided by the user # Usage: CT_DoBuildTargetTriplet # In fact this function takes the environment variables to build the target @@ -482,7 +502,7 @@ CT_DoBuildTargetTriplet() { glibc) CT_TARGET="${CT_TARGET}-gnu";; uClibc) CT_TARGET="${CT_TARGET}-uclibc";; esac - CT_TARGET="`${CT_TOP_DIR}/tools/config.sub ${CT_TARGET}`" + CT_TARGET=`CT_DoConfigSub "${CT_TARGET}"` } # This function does pause the build until the user strikes "Return" diff --git a/scripts/saveSample.sh b/scripts/saveSample.sh index 7a5b57cc..4aee0eba 100755 --- a/scripts/saveSample.sh +++ b/scripts/saveSample.sh @@ -8,7 +8,7 @@ # - the kernel .config file if specified # - the uClibc .config file if uClibc selected -. "${CT_TOP_DIR}/scripts/functions" +. "${CT_LIB_DIR}/scripts/functions" # Don't care about any log file exec >/dev/null @@ -31,12 +31,8 @@ CT_LOG_INFO=y CT_LOG_LEVEL_MAX="INFO" # Create the sample directory -# In case it was manually made, add it to svn -if [ -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then - # svn won't fail when adding a directory already managed by svn - svn add "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1 -else - svn mkdir "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1 +if [ ! -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then + mkdir -p "${CT_TOP_DIR}/samples/${CT_TARGET}" fi # Save the crosstool-NG config file @@ -53,19 +49,24 @@ CT_DoAddFileToSample() { if [ "${inode_s}" != "${inode_d}" ]; then cp "${source}" "${dest}" fi - svn add "${dest}" >/dev/null 2>&1 } +if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then + samp_top_dir="\${CT_LIB_DIR}" +else + samp_top_dir="\${CT_TOP_DIR}" +fi + # Save the kernel .config file if [ -n "${CT_KERNEL_LINUX_CONFIG_FILE}" ]; then # We save the file, and then point the saved sample to this file CT_DoAddFileToSample "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config" - sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \ + sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \ "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" else # remove any dangling files for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-"*.config; do - if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi + if [ -f "${f}" ]; then rm -f "${f}"; fi done fi @@ -73,17 +74,11 @@ fi if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then # We save the file, and then point the saved sample to this file CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config" - sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \ + sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \ "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" else # remove any dangling files for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-"*.config; do - if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi + if [ -f "${f}" ]; then rm -f "${f}"; fi done fi - -# We could svn add earlier, but it's better to -# add a frozen file than modifying it later -svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" >/dev/null 2>&1 - -svn stat "${CT_TOP_DIR}/samples/${CT_TARGET}" 2>/dev/null |CT_DoLog INFO diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh index ac05e911..f814940c 100755 --- a/scripts/showSamples.sh +++ b/scripts/showSamples.sh @@ -10,9 +10,16 @@ export GREP_OPTIONS= dump_single_sample() { local width="$1" local sample="$2" - printf " %-*s" ${width} "${sample}" - [ -f "${CT_TOP_DIR}/samples/${sample}/broken" ] && printf " (broken)" - echo + if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then + sample_top="${CT_TOP_DIR}" + sample_type="local" + else + sample_top="${CT_LIB_DIR}" + sample_type="global" + fi + printf " %-*s (%s" ${width} "${sample}" "${sample_type}" + [ -f "${sample_top}/samples/${sample}/broken" ] && printf ",broken" + echo ")" } # Get largest sample width diff --git a/scripts/tarball.sh b/scripts/tarball.sh deleted file mode 100755 index 8e6c3122..00000000 --- a/scripts/tarball.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -# This scripts makes a tarball of the configured toolchain -# Pre-requisites: -# - crosstool-NG is configured -# - components tarball are available -# - toolchain is built successfully - -# We need the functions first: -. "${CT_TOP_DIR}/scripts/functions" - -# Don't care about any log file -exec >/dev/null -rm -f "${tmp_log_file}" - -# Parse the configuration file: -. ${CT_TOP_DIR}/.config - -CT_DoBuildTargetTriplet - -# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR, -# re-parse them: -. "${CT_TOP_DIR}/.config" - -# Build a one-line list of files to include -CT_DoStep DEBUG "Building list of tarballs to add" -CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs" -CT_TARBALLS="" -for dir in '' tools debug; do - CT_DoStep DEBUG "Scanning directory \"${dir}\"" - for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do - CT_DoStep DEBUG "Testing component \"${script}\"" - [ -n "${script}" ] || continue - unset do_print_file_name - . "${script}" - for file in `do_print_filename`; do - CT_DoLog DEBUG "Finding tarball for \"${file}\"" - [ -n "${file}" ] || continue - ext=`CT_GetFileExtension "${file}"` - CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}" - CT_DoLog DEBUG "Found \"${file}${ext}\"" - CT_TARBALLS="${CT_TARBALLS} ${file}${ext}" - done - CT_EndStep - done - CT_EndStep -done -CT_EndStep - -# We need to emulate a build directory: -CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build" -mkdir -p "${CT_BUILD_DIR}" -CT_MktempDir tempdir - -# Save crosstool-ng, as it is configured for the current toolchain. -topdir=`basename "${CT_TOP_DIR}"` -CT_Pushd "${CT_TOP_DIR}/.." - -botdir=`pwd` - -# Build the list of files to exclude -CT_DoLog DEBUG "Building list of files to exclude" -exclude_list="${tempdir}/${CT_TARGET}.list" -{ echo ".svn"; \ - echo "${topdir}/log.*"; \ - echo "${topdir}/targets/src"; \ - echo "${topdir}/targets/tst"; \ - echo "${topdir}/targets/*-*-*-*"; \ - for t in `ls -1 "${topdir}/targets/tarballs/"`; do \ - case " ${CT_TARBALLS} " in \ - *" ${t} "*) ;; \ - *) echo "${topdir}/targets/tarballs/${t}";; \ - esac; \ - done; \ -} >"${exclude_list}" - -# Render the install directory writable -chmod u+w "${CT_PREFIX_DIR}" - -CT_DoLog INFO "Saving crosstool-ng into the toolchain directory" -tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" \ - --no-wildcards-match-slash \ - -X "${exclude_list}" \ - "${topdir}" 2>&1 |CT_DoLog ALL - -CT_Popd - -CT_DoLog INFO "Saving the toolchain" -tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}" 2>&1 |CT_DoLog ALL - -CT_DoLog DEBUG "Getting rid of working directories" -rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" -rm -rf "${tempdir}" - -if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then - # Render the install directory non-writable - chmod u-w "${CT_PREFIX_DIR}" -fi diff --git a/scripts/tarball.sh.broken b/scripts/tarball.sh.broken new file mode 100755 index 00000000..8e6c3122 --- /dev/null +++ b/scripts/tarball.sh.broken @@ -0,0 +1,98 @@ +#!/bin/bash + +# This scripts makes a tarball of the configured toolchain +# Pre-requisites: +# - crosstool-NG is configured +# - components tarball are available +# - toolchain is built successfully + +# We need the functions first: +. "${CT_TOP_DIR}/scripts/functions" + +# Don't care about any log file +exec >/dev/null +rm -f "${tmp_log_file}" + +# Parse the configuration file: +. ${CT_TOP_DIR}/.config + +CT_DoBuildTargetTriplet + +# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR, +# re-parse them: +. "${CT_TOP_DIR}/.config" + +# Build a one-line list of files to include +CT_DoStep DEBUG "Building list of tarballs to add" +CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs" +CT_TARBALLS="" +for dir in '' tools debug; do + CT_DoStep DEBUG "Scanning directory \"${dir}\"" + for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do + CT_DoStep DEBUG "Testing component \"${script}\"" + [ -n "${script}" ] || continue + unset do_print_file_name + . "${script}" + for file in `do_print_filename`; do + CT_DoLog DEBUG "Finding tarball for \"${file}\"" + [ -n "${file}" ] || continue + ext=`CT_GetFileExtension "${file}"` + CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}" + CT_DoLog DEBUG "Found \"${file}${ext}\"" + CT_TARBALLS="${CT_TARBALLS} ${file}${ext}" + done + CT_EndStep + done + CT_EndStep +done +CT_EndStep + +# We need to emulate a build directory: +CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build" +mkdir -p "${CT_BUILD_DIR}" +CT_MktempDir tempdir + +# Save crosstool-ng, as it is configured for the current toolchain. +topdir=`basename "${CT_TOP_DIR}"` +CT_Pushd "${CT_TOP_DIR}/.." + +botdir=`pwd` + +# Build the list of files to exclude +CT_DoLog DEBUG "Building list of files to exclude" +exclude_list="${tempdir}/${CT_TARGET}.list" +{ echo ".svn"; \ + echo "${topdir}/log.*"; \ + echo "${topdir}/targets/src"; \ + echo "${topdir}/targets/tst"; \ + echo "${topdir}/targets/*-*-*-*"; \ + for t in `ls -1 "${topdir}/targets/tarballs/"`; do \ + case " ${CT_TARBALLS} " in \ + *" ${t} "*) ;; \ + *) echo "${topdir}/targets/tarballs/${t}";; \ + esac; \ + done; \ +} >"${exclude_list}" + +# Render the install directory writable +chmod u+w "${CT_PREFIX_DIR}" + +CT_DoLog INFO "Saving crosstool-ng into the toolchain directory" +tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" \ + --no-wildcards-match-slash \ + -X "${exclude_list}" \ + "${topdir}" 2>&1 |CT_DoLog ALL + +CT_Popd + +CT_DoLog INFO "Saving the toolchain" +tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}" 2>&1 |CT_DoLog ALL + +CT_DoLog DEBUG "Getting rid of working directories" +rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" +rm -rf "${tempdir}" + +if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then + # Render the install directory non-writable + chmod u-w "${CT_PREFIX_DIR}" +fi -- cgit v1.2.3