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 <stilor@att.net>
This commit is contained in:
Alexey Neyman 2016-12-14 00:59:08 -08:00
parent 7fad393635
commit 832bee87c0
3 changed files with 21 additions and 26 deletions

View File

@ -40,10 +40,14 @@ config WORK_DIR
Do *NOT* change it if you don't know better. 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 config PREFIX_DIR
string string
prompt "Prefix directory" if ! BACKEND 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 help
This is the path the toolchain will run from. This is the path the toolchain will run from.

View File

@ -26,7 +26,7 @@ help-samples::
@echo ' show-<sample> - show a brief overview of <sample> (list with list-samples)' @echo ' show-<sample> - show a brief overview of <sample> (list with list-samples)'
@echo ' <sample> - preconfigure crosstool-NG with <sample> (list with list-samples)' @echo ' <sample> - preconfigure crosstool-NG with <sample> (list with list-samples)'
@echo ' build-all[.#] - Build *all* samples (list with list-samples) and install in' @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:: help-distrib::
@echo ' check-samples - Verify if samples need updates due to Kconfig changes' @echo ' check-samples - Verify if samples need updates due to Kconfig changes'
@ -177,14 +177,7 @@ $(CT_SAMPLES): config_files
# ---------------------------------------------------------- # ----------------------------------------------------------
# Some helper functions # 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 = , __comma = ,
prefix_dir = $(CT_PREFIX)/$(subst $(__comma),=,$(1))
host_triplet = $(if $(findstring $(__comma),$(1)),$(firstword $(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)) 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 define build_sample
@$(CT_ECHO) ' CONF $(1)' @$(CT_ECHO) ' CONF $(1)'
$(SILENT)$(CONF) -s --defconfig=$(call sample_dir,$(1))/crosstool.config $(KCONFIG_TOP) $(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_(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_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_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) $(SILENT)$(CONF) -s --oldconfig $(KCONFIG_TOP)
@$(CT_ECHO) ' BUILD $(1)' @$(CT_ECHO) ' BUILD $(1)'
$(SILENT)if [ ! -z "$(call host_triplet,$(1))" -a -d "$(call prefix_dir,$(call host_triplet,$(1)))" ]; then \ $(SILENT)h=$(call host_triplet,$(1)); \
PATH="$$PATH:$(call prefix_dir,$(call host_triplet,$(1)))/bin"; \ if [ -n "$${h}" -a -r ".build-all/PASS/$${h}/prefix" ]; then \
PATH=`cat .build-all/PASS/$${h}/prefix`/bin:$${PATH}; \
fi; \ fi; \
if $(MAKE) -rf $(CT_NG) V=0 build; then \ if $(MAKE) -rf $(CT_NG) V=0 build; then \
status=PASS; \ status=PASS; \
@ -214,7 +206,12 @@ define build_sample
printf '\r %-5s %s\n' $$status '$(1)'; \ printf '\r %-5s %s\n' $$status '$(1)'; \
mkdir -p .build-all/$$status/$(1); \ mkdir -p .build-all/$$status/$(1); \
bzip2 < build.log > .build-all/$$status/$(1)/build.log.bz2; \ 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 endef
# ---------------------------------------------------------- # ----------------------------------------------------------
@ -224,10 +221,6 @@ endef
ifneq ($(strip $(MAKECMDGOALS)),) ifneq ($(strip $(MAKECMDGOALS)),)
ifneq ($(strip $(filter $(patsubst %,build-%,$(CT_SAMPLES)) build-all,$(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 contains a build sample rule
endif # MAKECMDGOALS != "" endif # MAKECMDGOALS != ""

View File

@ -19,12 +19,12 @@
# - don't hash commands lookups, # - don't hash commands lookups,
. "${CT_LIB_DIR}/scripts/functions" . "${CT_LIB_DIR}/scripts/functions"
# Yes! We can do full logging from now on!
CT_LogEnable
# Read the sample settings # Read the sample settings
CT_LoadConfig CT_LoadConfig
# Yes! We can do full logging from now on!
CT_LogEnable
# Check running as root # Check running as root
if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then
if [ $(id -u) -eq 0 ]; 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 # Compute the working directories names
CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
CT_SRC_DIR="${CT_WORK_DIR}/src" CT_SRC_DIR="${CT_WORK_DIR}/src"
CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build" CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build"
CT_BUILDTOOLS_PREFIX_DIR="${CT_WORK_DIR}/${CT_TARGET}/buildtools" CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools"
CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" 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 # 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. # 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}" BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
CC_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 # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
# confused when $sysroot/usr/include is not present. # confused when $sysroot/usr/include is not present.
# Note: --prefix=/usr is magic! # Note: --prefix=/usr is magic!
@ -307,7 +306,6 @@ if [ -z "${CT_RESTART}" ]; then
# building libgcc, and you'll have no profiling # building libgcc, and you'll have no profiling
CC_CORE_SYSROOT_ARG="--without-headers" CC_CORE_SYSROOT_ARG="--without-headers"
CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}" CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
LIBC_SYSROOT_ARG="prefix="
fi fi
CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}"
CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}"