From c0cc73cd6f3040ea08dc09384aa289540b3fb2a2 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 13 Dec 2016 22:18:50 -0800 Subject: Install canadian crosses into a separate subdir. Makes them sorted out by host, and removes the need for similar hack in samples.mk. Change how canadian crosses are named: using `=' character resulted in Glibc build failure. Move loading config into a common function, CT_LoadConfig. Signed-off-by: Alexey Neyman --- scripts/.gitignore | 2 +- scripts/crosstool-NG.sh.in | 36 +++++-------------- scripts/functions | 90 ++++++++++++++++++++++++++++++++++++++-------- scripts/saveSample.sh.in | 31 +--------------- scripts/showConfig.sh.in | 15 ++++++++ scripts/showTuple.sh.in | 30 ---------------- 6 files changed, 100 insertions(+), 104 deletions(-) create mode 100644 scripts/showConfig.sh.in delete mode 100644 scripts/showTuple.sh.in (limited to 'scripts') diff --git a/scripts/.gitignore b/scripts/.gitignore index 07af16d7..a38259b8 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,3 +1,3 @@ crosstool-NG.sh saveSample.sh -showTuple.sh +showConfig.sh diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index ba36bc85..68716f81 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -17,13 +17,13 @@ # most notably: # - set trap handler on errors, # - don't hash commands lookups, -# - initialise logging. . "${CT_LIB_DIR}/scripts/functions" -# Parse the configuration file -# It has some info about the logging facility, so include it early -. .config.2 # Yes! We can do full logging from now on! +CT_LogEnable + +# Read the sample settings +CT_LoadConfig # Check running as root if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then @@ -126,7 +126,7 @@ CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) # Log real begining of build, now CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" -# We really need to extract from ,config and not .config.2, as we +# We really need to extract from .config and not .config.2, as we # do want the kconfig's values, not our mangled config with arrays. CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" CT_DoExecLog DEBUG ${grep} -E '^(# )?CT_' .config @@ -138,26 +138,6 @@ export MAKEFLAGS CT_DoLog INFO "Building environment variables" -# 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_LIB_DIR}/scripts/build/internals.sh" -. "${CT_LIB_DIR}/scripts/build/arch.sh" -. "${CT_LIB_DIR}/scripts/build/companion_tools.sh" -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" -. "${CT_LIB_DIR}/scripts/build/companion_libs.sh" -. "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" -. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" -. "${CT_LIB_DIR}/scripts/build/cc.sh" -. "${CT_LIB_DIR}/scripts/build/debug.sh" -. "${CT_LIB_DIR}/scripts/build/test_suite.sh" - -# Target tuple: CT_TARGET needs a little love: -CT_DoBuildTargetTuple - -# Kludge: If any of the configured options needs CT_TARGET, -# then rescan the options file now: -. .config.2 - # Sanity check some directories CT_TestAndAbort "'CT_PREFIX_DIR' is not set: where should I install?" -z "${CT_PREFIX_DIR}" @@ -691,12 +671,12 @@ CT_DoEnd INFO # From now-on, it can become impossible to log any time, because # either we're compressing the log file, or it can become RO any -# moment... Restore original stdout, stderr and stdin +# moment... CT_DoLog INFO "Finishing installation (may take a few seconds)..." -exec >&6 2>&7 <&8 +CT_LogDisable rm -f ${CT_PREFIX_DIR}/build.log.bz2 if [ "${CT_LOG_TO_FILE}" = "y" ]; then - cp "${tmp_log_file}" "${CT_PREFIX_DIR}/build.log" + cp "${CT_BUILD_LOG}" "${CT_PREFIX_DIR}/build.log" if [ "${CT_LOG_FILE_COMPRESS}" = y ]; then bzip2 -9 "${CT_PREFIX_DIR}/build.log" fi diff --git a/scripts/functions b/scripts/functions index cbef48b4..baaf51ee 100644 --- a/scripts/functions +++ b/scripts/functions @@ -4,6 +4,50 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package +CT_LoadConfig() { + # Parse the configuration file + # It has some info about the logging facility, so include it early + # It also sets KERNEL/ARCH/... for file inclusion below. Does not handle + # recursive definitions yet. + CT_TestOrAbort "Configuration file not found. Please create one." -r .config.2 + . .config.2 + + # 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_LIB_DIR}/scripts/build/internals.sh" + . "${CT_LIB_DIR}/scripts/build/arch.sh" + . "${CT_LIB_DIR}/scripts/build/companion_tools.sh" + . "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" + . "${CT_LIB_DIR}/scripts/build/companion_libs.sh" + . "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" + . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" + . "${CT_LIB_DIR}/scripts/build/cc.sh" + . "${CT_LIB_DIR}/scripts/build/debug.sh" + . "${CT_LIB_DIR}/scripts/build/test_suite.sh" + + # Target tuple: CT_TARGET needs a little love: + CT_DoBuildTargetTuple + + # Kludge: If any of the configured options needs CT_TARGET, + # then rescan the options file now. This also handles recursive variables; + # but we don't want to loop forever if there's a circular reference. + touch ${CT_TOP_DIR}/.config.out.1 + try=0 + while [ "$try" -le 10 ]; do + . .config.2 + set | ${grep} -E '^CT_' > ${CT_TOP_DIR}/.config.out.2 + if cmp -s ${CT_TOP_DIR}/.config.out.1 ${CT_TOP_DIR}/.config.out.2; then + break + fi + mv ${CT_TOP_DIR}/.config.out.2 ${CT_TOP_DIR}/.config.out.1 + try=$[ try + 1 ] + done + if [ "$try" -gt 10 ]; then + CT_Abort "Variables in .config recurse too deep." + fi + rm -f ${CT_TOP_DIR}/.config.out.[12] +} + # Prepare the fault handler CT_OnError() { local ret=$? @@ -48,7 +92,7 @@ CT_OnError() { old_trap="$(trap -p ERR)" trap -- ERR ( - exec >&6 2>&7 <&8 + CT_LogDisable # In this subshell printf "\r \n\nCurrent command" if [ -n "${cur_cmd}" ]; then printf ":\n %s\n" "${cur_cmd}" @@ -132,12 +176,22 @@ set +o hashall # Log policy: # - first of all, save stdout so we can see the live logs: fd #6 -# (also save stdin and stderr for use by CT_DEBUG_INTERACTIVE) -exec 6>&1 7>&2 8<&0 -# - then point stdout to the log file -tmp_log_file="${CT_TOP_DIR}/build.log" -rm -f "${tmp_log_file}" -exec >>"${tmp_log_file}" +# (also save stdin and stderr for use by CT_DEBUG_INTERACTIVE) +# FIXME: it doesn't look like anyone is overriding stdin/stderr. Do we need +# to save/restore them? +CT_LogEnable() { + exec 6>&1 7>&2 8<&0 + CT_BUILD_LOG="${CT_TOP_DIR}/build.log" + CT_LOG_ENABLED=y + rm -f "${CT_BUILD_LOG}" + exec >>"${CT_BUILD_LOG}" +} + +# Restore original stdout, stderr and stdin +CT_LogDisable() { + exec >&6 2>&7 <&8 + CT_LOG_ENABLED= +} # The different log levels: CT_LOG_LEVEL_ERROR=0 @@ -197,14 +251,20 @@ CT_DoLog() { *) cur_L="${LEVEL}"; cur_l="${level}";; esac # There will always be a log file (stdout, fd #1), be it /dev/null - printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" - if [ ${cur_l} -le ${max_level} ]; then - # Only print to console (fd #6) if log level is high enough. - printf "${CT_LOG_PROGRESS_BAR:+\r}[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" >&6 - fi - if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then - printf "\r[%02d:%02d] %s " $((SECONDS/60)) $((SECONDS%60)) "${_prog_bar[$((_prog_bar_cpt/10))]}" >&6 - _prog_bar_cpt=$(((_prog_bar_cpt+1)%40)) + if [ -n "${CT_LOG_ENABLED}" ]; then + printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" + # If log file has been set up, fd#6 is console and it only + # gets the most important messages. + if [ ${cur_l} -le ${max_level} ]; then + # Only print to console (fd #6) if log level is high enough. + printf "${CT_LOG_PROGRESS_BAR:+\r}[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" >&6 + fi + if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then + printf "\r[%02d:%02d] %s " $((SECONDS/60)) $((SECONDS%60)) "${_prog_bar[$((_prog_bar_cpt/10))]}" >&6 + _prog_bar_cpt=$(((_prog_bar_cpt+1)%40)) + fi + elif [ ${cur_l} -le ${CT_LOG_LEVEL_WARN} ]; then + printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" fi done ) diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in index a070dc2c..701c660b 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh.in @@ -10,29 +10,14 @@ # Parse the tools' paths configuration . "${CT_LIB_DIR}/paths.sh" - -# We'll need the stdout later, save it -exec 7>&1 - . "${CT_LIB_DIR}/scripts/functions" -# Don't care about any log file -exec >/dev/null -rm -f "${tmp_log_file}" - -# Parse the configuration file -# Don't use CT_TestOrAbort, it prints the test string to [DEBUG] -# Note: we just need the non-mangled .config, not .config.2 -if [ ! -f .config ]; then - CT_Abort "Configuration file not found. Please create one." -fi -. .config +CT_LoadConfig # We can not reliably save a sample which either uses local patches # and/or custom Linux kernel headers. Warn the user about this issue # and continue if he/she confirms sving the sample. if [ "${CT_CUSTOM_PATCH}" = "y" ]; then - exec >&7 echo "You are using local patches." echo "You will not be able to (easily) share this sample in this case." read -p "Press Ctrl-C to stop now, or Enter to continue..." @@ -41,17 +26,6 @@ fi # Do not use a progress bar unset CT_LOG_PROGRESS_BAR -# Parse architecture and kernel specific functions -. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" - -# Target tuple: CT_TARGET needs a little love: -CT_DoBuildTargetTuple - -# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR, -# re-parse them: -. .config - # Override log options unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL CT_LOG_WARN=y @@ -114,9 +88,6 @@ export KCONFIG_CONFIG="$(pwd)/.defconfig" ${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}" rm -f .defconfig -# Restore stdout now, to be interactive -exec >&7 - # Fill-in the reported-by info [ -f "${samp_dir}/reported.by" ] && . "${samp_dir}/reported.by" old_name="${reporter_name}" diff --git a/scripts/showConfig.sh.in b/scripts/showConfig.sh.in new file mode 100644 index 00000000..b4399959 --- /dev/null +++ b/scripts/showConfig.sh.in @@ -0,0 +1,15 @@ +#!@@CT_bash@@ + +# What we need: +# - the .config file + +# Parse the tools' paths configuration +. "${CT_LIB_DIR}/paths.sh" + +# Parse the common functions +. "${CT_LIB_DIR}/scripts/functions" + +# Read the sample settings +CT_LoadConfig + +eval "echo \"$1\"" diff --git a/scripts/showTuple.sh.in b/scripts/showTuple.sh.in deleted file mode 100644 index 53895392..00000000 --- a/scripts/showTuple.sh.in +++ /dev/null @@ -1,30 +0,0 @@ -#!@@CT_bash@@ - -# What we need: -# - the .config file - -# Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" - -# We'll need the stdout later, save it -exec 9>&1 - -# Parse the common functions -. "${CT_LIB_DIR}/scripts/functions" - -# Don't care about any log file -exec >/dev/null -rm -f "${tmp_log_file}" - -# Parse the configuration file -. .config.2 - -# Parse architecture and kernel specific functions -. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" - -# Build CT_TARGET -CT_DoBuildTargetTuple - -# All this for this single echo... :-( Sigh, I'll have to re-arrange things... -echo "${CT_TARGET}" >&9 -- cgit v1.2.3 From 955f5bc0b8a879ba5d1b9a65a31cc235c9fd9be8 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 13 Dec 2016 18:07:21 -0800 Subject: Get rid of .config.2. Now handled by CT_LoadConfig. Signed-off-by: Alexey Neyman --- .gitignore | 1 - ct-ng.in | 11 +++-------- scripts/crosstool-NG.sh.in | 4 ---- scripts/functions | 24 +++++++++++++++--------- scripts/saveSample.sh.in | 4 +--- 5 files changed, 19 insertions(+), 25 deletions(-) (limited to 'scripts') diff --git a/.gitignore b/.gitignore index 1a510d71..98480b07 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ paths.* !paths.in config.gen/ .config -.config.2 # Temporaries .*.swp diff --git a/ct-ng.in b/ct-ng.in index bc63bc8e..d856828f 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -136,19 +136,14 @@ help-env:: @echo "or configure an existing sample." @false -.config.2: .config - $(SILENT)$(sed) -r -e 's/^([^=]+_ARRAY)="(.*)"$$/\1=( \2 )/;' \ - -e '/^[^=]+_ARRAY=/s/\\(.)/\1/g;' \ - $< >$@ - -show-tuple: .config.2 +show-tuple: .config $(SILENT)$(bash) $(CT_LIB_DIR)/scripts/showConfig.sh '$${CT_TARGET}' # Actual build -source: .config.2 +source: .config $(SILENT)CT_SOURCE=y $(CT_LIB_DIR)/scripts/crosstool-NG.sh -build: .config.2 +build: .config $(SILENT)$(CT_LIB_DIR)/scripts/crosstool-NG.sh build.%: diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index 68716f81..303e5fcd 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -126,8 +126,6 @@ CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) # Log real begining of build, now CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" -# We really need to extract from .config and not .config.2, as we -# do want the kconfig's values, not our mangled config with arrays. CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" CT_DoExecLog DEBUG ${grep} -E '^(# )?CT_' .config CT_EndStep @@ -571,8 +569,6 @@ if [ -z "${CT_RESTART}" ]; then fi rm -f "${testc}" - # We need to save the real .config with kconfig's value, - # not our mangled .config.2 with arrays. 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" diff --git a/scripts/functions b/scripts/functions index baaf51ee..9aa4fc7a 100644 --- a/scripts/functions +++ b/scripts/functions @@ -5,12 +5,14 @@ # Licensed under the GPL v2. See COPYING in the root of this package CT_LoadConfig() { + local o + # Parse the configuration file # It has some info about the logging facility, so include it early # It also sets KERNEL/ARCH/... for file inclusion below. Does not handle - # recursive definitions yet. - CT_TestOrAbort "Configuration file not found. Please create one." -r .config.2 - . .config.2 + # recursive definitions yet. We don't need arrays at this point. + CT_TestOrAbort "Configuration file not found. Please create one." -r .config + . .config # 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. @@ -31,21 +33,25 @@ CT_LoadConfig() { # Kludge: If any of the configured options needs CT_TARGET, # then rescan the options file now. This also handles recursive variables; # but we don't want to loop forever if there's a circular reference. - touch ${CT_TOP_DIR}/.config.out.1 + oldvals="" try=0 while [ "$try" -le 10 ]; do - . .config.2 - set | ${grep} -E '^CT_' > ${CT_TOP_DIR}/.config.out.2 - if cmp -s ${CT_TOP_DIR}/.config.out.1 ${CT_TOP_DIR}/.config.out.2; then + . .config + vals=`set | ${grep} -E '^CT_'` + if [ "$oldvals" = "$vals" ]; then break fi - mv ${CT_TOP_DIR}/.config.out.2 ${CT_TOP_DIR}/.config.out.1 + oldvals="$vals" try=$[ try + 1 ] done if [ "$try" -gt 10 ]; then CT_Abort "Variables in .config recurse too deep." fi - rm -f ${CT_TOP_DIR}/.config.out.[12] + # Double eval: first eval substitutes option name, second eval unescapes quotes + # and whitespace. + for o in `set | sed -rn 's/^(CT_[A-Za-z0-9_]*_ARRAY)=.*/\1/p'`; do + eval "eval $o=(\"\$$o\")" + done } # Prepare the fault handler diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in index 701c660b..4fa1c876 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh.in @@ -40,9 +40,7 @@ esac samp_dir="samples/${samp_name}" mkdir -p "${samp_dir}" -# Tweak the .config file -# We need to be based on the real .config with kconfig's values, -# not our mangled .config.2 with shell arrays +# Tweak the .config file. cp .config .defconfig "${sed}" -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;' \ -e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;' \ -- cgit v1.2.3 From 3e4d4870c9b7506c7a114fdb8789f78fd551c171 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 13 Dec 2016 18:40:47 -0800 Subject: Simplify config saving. Instead of hardcoding defaults in saveSample.sh.in, have the same defaults in config. Then we can just remove them when saving the config. --- config/global/logging.in | 3 +-- config/global/paths.in | 4 ++-- scripts/saveSample.sh.in | 19 +++++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/config/global/logging.in b/config/global/logging.in index 0c77e88a..a7e7696e 100644 --- a/config/global/logging.in +++ b/config/global/logging.in @@ -5,8 +5,7 @@ comment "Logging" choice bool prompt "Maximum log level to see:" - default LOG_INFO if !DEBUG_CT - default LOG_DEBUG if DEBUG_CT + default LOG_EXTRA config LOG_ERROR bool diff --git a/config/global/paths.in b/config/global/paths.in index 5e9bcc42..308d8d11 100644 --- a/config/global/paths.in +++ b/config/global/paths.in @@ -5,7 +5,7 @@ comment "Paths" config LOCAL_TARBALLS_DIR string prompt "Local tarballs directory" if ! BACKEND - default "" + default "${HOME}/src" help If you have previously downloaded the tarballs, enter the PATH where you stored them here. @@ -14,7 +14,7 @@ config SAVE_TARBALLS bool prompt "Save new tarballs" if ! BACKEND depends on LOCAL_TARBALLS_DIR != "" || BACKEND - default y if BACKEND + default y help If you say 'y' here, new downloaded tarballs will be saved in the directory you entered above. diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in index 4fa1c876..646c1893 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh.in @@ -40,14 +40,17 @@ esac samp_dir="samples/${samp_name}" mkdir -p "${samp_dir}" -# Tweak the .config file. -cp .config .defconfig -"${sed}" -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;' \ - -e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;' \ - -e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \ - -e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;' \ - <.config \ - >.defconfig +# Tweak the .config file: remove the options that we want to keep +# at default setting in samples. +force_default_opts=( \ + PREFIX_DIR LOG_TO_FILE LOG_FILE_COMPRESS \ + LOCAL_TARBALLS_DIR SAVE_TARBALLS \ + LOG_ERROR LOG_WARN LOG_INFO LOG_EXTRA LOG_ALL LOG_DEBUG \ + LOG_PROGRESS_BAR + ) +regexp=${force_default_opts[*]} +regexp=${regexp// /|} +grep -v -E '^(# )?CT_('"${regexp}"')' .config > .defconfig # Function to copy a file to the sample directory # Needed in case the file is already there (think of a previously available sample) -- cgit v1.2.3 From 832bee87c03ce2fecdbf8b00996fc1fca8f2b2e0 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 14 Dec 2016 00:59:08 -0800 Subject: Make build-all rely on kconfig options. For that, make CT_BUILD_TOP_DIR a non-settable config option (so that it is recursively expanded with CT_HOST/CT_TARGET). Use a common prefix, with same default as for regular sample build. Use showConfig.sh to determine host toolchain path (for canadian crosses) and build directory to be removed. Remove LIBC_SYSROOT_ARG (unused). Signed-off-by: Alexey Neyman --- config/global/paths.in | 6 +++++- samples/samples.mk | 29 +++++++++++------------------ scripts/crosstool-NG.sh.in | 12 +++++------- 3 files changed, 21 insertions(+), 26 deletions(-) (limited to 'scripts') diff --git a/config/global/paths.in b/config/global/paths.in index 308d8d11..5313d0d0 100644 --- a/config/global/paths.in +++ b/config/global/paths.in @@ -40,10 +40,14 @@ config WORK_DIR Do *NOT* change it if you don't know better. +config BUILD_TOP_DIR + string + default "${CT_WORK_DIR}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" + config PREFIX_DIR string prompt "Prefix directory" if ! BACKEND - default "${HOME}/x-tools/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" + default "${CT_PREFIX:-${HOME}/x-tools}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" help This is the path the toolchain will run from. diff --git a/samples/samples.mk b/samples/samples.mk index bf51135f..5c8f130e 100644 --- a/samples/samples.mk +++ b/samples/samples.mk @@ -26,7 +26,7 @@ help-samples:: @echo ' show- - show a brief overview of (list with list-samples)' @echo ' - preconfigure crosstool-NG with (list with list-samples)' @echo ' build-all[.#] - Build *all* samples (list with list-samples) and install in' - @echo ' $${CT_PREFIX} (which you must set)' + @echo ' $${CT_PREFIX} (set to ~/x-tools by default)' help-distrib:: @echo ' check-samples - Verify if samples need updates due to Kconfig changes' @@ -177,14 +177,7 @@ $(CT_SAMPLES): config_files # ---------------------------------------------------------- # Some helper functions - -# Construct a CT_PREFIX_DIR path from the sample name. Sample names use -# comma as a separator between host and target triplets in canadian cross -# configurations, but ct-ng does not allow commas in the path. Substitute -# with = (equal sign). -# $1: sample __comma = , -prefix_dir = $(CT_PREFIX)/$(subst $(__comma),=,$(1)) host_triplet = $(if $(findstring $(__comma),$(1)),$(firstword $(subst $(__comma), ,$(1)))) target_triplet = $(if $(findstring $(__comma),$(1)),$(word 2,$(subst $(__comma), ,$(1))),$(1)) @@ -193,16 +186,15 @@ target_triplet = $(if $(findstring $(__comma),$(1)),$(word 2,$(subst $(__comma), define build_sample @$(CT_ECHO) ' CONF $(1)' $(SILENT)$(CONF) -s --defconfig=$(call sample_dir,$(1))/crosstool.config $(KCONFIG_TOP) - $(SILENT)$(sed) -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$(call prefix_dir,$(1))":;' .config + $(SILENT)[ -n "$(CT_PREFIX)" ] && $(sed) -i -r -e 's:^(CT_PREFIX=).*$$:\1"$(CT_PREFIX)":;' .config || : $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config $(SILENT)$(sed) -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config - $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config - $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config $(SILENT)$(CONF) -s --oldconfig $(KCONFIG_TOP) @$(CT_ECHO) ' BUILD $(1)' - $(SILENT)if [ ! -z "$(call host_triplet,$(1))" -a -d "$(call prefix_dir,$(call host_triplet,$(1)))" ]; then \ - PATH="$$PATH:$(call prefix_dir,$(call host_triplet,$(1)))/bin"; \ + $(SILENT)h=$(call host_triplet,$(1)); \ + if [ -n "$${h}" -a -r ".build-all/PASS/$${h}/prefix" ]; then \ + PATH=`cat .build-all/PASS/$${h}/prefix`/bin:$${PATH}; \ fi; \ if $(MAKE) -rf $(CT_NG) V=0 build; then \ status=PASS; \ @@ -214,7 +206,12 @@ define build_sample printf '\r %-5s %s\n' $$status '$(1)'; \ mkdir -p .build-all/$$status/$(1); \ bzip2 < build.log > .build-all/$$status/$(1)/build.log.bz2; \ - [ "$$status" = PASS -a -z "$(CT_PRESERVE_PASSED_BUILDS)" ] && rm -rf .build/$(call target_triplet,$(1)) || : + if [ "$$status" = PASS ]; then \ + blddir=`$(bash) $(CT_LIB_DIR)/scripts/showConfig.sh '$${CT_BUILD_TOP_DIR}'`; \ + [ -z "$(CT_PRESERVE_PASSED_BUILDS)" ] && rm -rf $${blddir}; \ + $(bash) $(CT_LIB_DIR)/scripts/showConfig.sh '$${CT_PREFIX_DIR}' > .build-all/PASS/$(1)/prefix; \ + fi; \ + : endef # ---------------------------------------------------------- @@ -224,10 +221,6 @@ endef ifneq ($(strip $(MAKECMDGOALS)),) ifneq ($(strip $(filter $(patsubst %,build-%,$(CT_SAMPLES)) build-all,$(MAKECMDGOALS))),) -ifeq ($(strip $(CT_PREFIX)),) -$(error Please set 'CT_PREFIX' to where you want to install generated toolchain samples!) -endif - endif # MAKECMDGOALS contains a build sample rule endif # MAKECMDGOALS != "" diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index 303e5fcd..eeb78005 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -19,12 +19,12 @@ # - don't hash commands lookups, . "${CT_LIB_DIR}/scripts/functions" -# Yes! We can do full logging from now on! -CT_LogEnable - # Read the sample settings CT_LoadConfig +# Yes! We can do full logging from now on! +CT_LogEnable + # Check running as root if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then if [ $(id -u) -eq 0 ]; then @@ -156,8 +156,8 @@ CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOL # 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" -CT_BUILDTOOLS_PREFIX_DIR="${CT_WORK_DIR}/${CT_TARGET}/buildtools" +CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build" +CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools" CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" # Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a # sub-dir. So we won't have to save/restore it, not even create it. @@ -288,7 +288,6 @@ if [ -z "${CT_RESTART}" ]; then BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - LIBC_SYSROOT_ARG="" # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get # confused when $sysroot/usr/include is not present. # Note: --prefix=/usr is magic! @@ -307,7 +306,6 @@ if [ -z "${CT_RESTART}" ]; then # building libgcc, and you'll have no profiling CC_CORE_SYSROOT_ARG="--without-headers" CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}" - LIBC_SYSROOT_ARG="prefix=" fi CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" -- cgit v1.2.3