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 <stilor@att.net>
This commit is contained in:
Alexey Neyman 2016-12-13 22:18:50 -08:00
parent dc3f68c8a5
commit c0cc73cd6f
9 changed files with 105 additions and 109 deletions

View File

@ -157,7 +157,7 @@ uninstall: real-uninstall
build-bin: $(PROG_NAME) \
scripts/crosstool-NG.sh \
scripts/saveSample.sh \
scripts/showTuple.sh
scripts/showConfig.sh
@chmod 755 $^
build-lib: config/configure.in \
@ -262,8 +262,8 @@ clean-bin:
@rm -f scripts/crosstool-NG.sh
@echo " RM 'scripts/saveSample.sh'"
@rm -f scripts/saveSample.sh
@echo " RM 'scripts/showTuple.sh'"
@rm -f scripts/showTuple.sh
@echo " RM 'scripts/showConfig.sh'"
@rm -f scripts/showConfig.sh
clean-lib:
@echo " RM 'paths'"

View File

@ -43,7 +43,7 @@ config WORK_DIR
config PREFIX_DIR
string
prompt "Prefix directory" if ! BACKEND
default "${HOME}/x-tools/${CT_TARGET}"
default "${HOME}/x-tools/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
help
This is the path the toolchain will run from.

View File

@ -142,7 +142,7 @@ help-env::
$< >$@
show-tuple: .config.2
$(SILENT)$(bash) $(CT_LIB_DIR)/scripts/showTuple.sh
$(SILENT)$(bash) $(CT_LIB_DIR)/scripts/showConfig.sh '$${CT_TARGET}'
# Actual build
source: .config.2

2
scripts/.gitignore vendored
View File

@ -1,3 +1,3 @@
crosstool-NG.sh
saveSample.sh
showTuple.sh
showConfig.sh

View File

@ -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

View File

@ -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
)

View File

@ -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}"

15
scripts/showConfig.sh.in Normal file
View File

@ -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\""

View File

@ -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