toolchain/crosstool-NG: move munging functions

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
This commit is contained in:
Yann E. MORIN 2010-11-27 21:50:44 +01:00 committed by Peter Korsgaard
parent 6aec5c2c19
commit 8749f92188

View File

@ -96,15 +96,46 @@ $(STAMP_DIR)/ct-ng-toolchain-built: $(CTNG_DIR)/.config
CTNG_FIX_DOT_CONFIG_SED :=
CTNG_FIX_DOT_CONFIG_PATHS_SED :=
# Note: a lot of the following tricks would become unneeded if one day
# buildroot and crosstool-NG had matching options, especially for the
# target description: arch name, bitness, endianness...
#--------------
# A few generic functions
# Note-2: missing conformity check between BR's .config and libc features.
# Use check_uclibc or check_glibc.
# Munge a config file, given a sed expression
# $1: the .config file to munge
# $2: the sed expression to apply
define ctng-fix-dot-config
$(Q)sed -r -e '$(2)' $(1) >$(1).sed
$(Q)cmp $(1) $(1).sed >/dev/null 2>&1 && rm -f $(1).sed || mv -f $(1).sed $(1)
endef
# This function checks the .config did actually change
# If not changed, then current .config will be touched with reference to the
# stamp file. If the configuration did change, nothing is done.
# $1: the current .config to check
# $2: the time-stamped .config file
define ctng-check-config-changed
$(Q)old_md5="$$( grep -v -E '^(#|$$)' $(2) 2>/dev/null \
|md5sum \
|cut -d ' ' -f 1 \
)"; \
new_md5="$$( grep -v -E '^(#|$$)' $(1) 2>/dev/null \
|md5sum \
|cut -d ' ' -f 1 \
)"; \
if [ $${old_md5} = $${new_md5} -a -f $(2) ]; then \
touch -r $(2) $(1); \
fi
endef
#--------------
# Massage BR2_ARCH so that it matches CT-NG's ARCH
#
# Note: a lot of the following tricks would become unneeded if one day
# buildroot and crosstool-NG had matching options, especially for the
# target description: arch name, bitness, endianness...
#
# Note-2: missing conformity check between BR's .config and libc features.
# Use check_uclibc or check_glibc.
# Defaults:
CTNG_ARCH := $(CTNG_BR2_ARCH)
CTNG_ENDIAN :=
@ -204,12 +235,6 @@ endif # LIBC is uClibc
#--------------
# Small functions to shoe-horn the above into crosstool-NG's .config
# $1: the .config file to munge
# $2: the sed expression to apply
define ctng-fix-dot-config
$(Q)sed -r -e '$(2)' $(1) >$(1).sed
$(Q)cmp $(1) $(1).sed >/dev/null 2>&1 && rm -f $(1).sed || mv -f $(1).sed $(1)
endef
# Function to update the .config
# We first munge the .config to shoe-horn defaults, then we push that unto
@ -228,25 +253,6 @@ define ctng-oldconfig
$(call ctng-fix-dot-config,$(1),$(CTNG_FIX_DOT_CONFIG_PATHS_SED))
endef
# This function checks the confguration of the toolchain did actually change
# If not changed, then current .config will be touched with reference to the
# stamp file. If the configuration did change, nothing is done.
# $1: the current .config to check
# $2: the time-stamped .config file
define ctng-check-config-changed
$(Q)old_md5="$$( grep -v -E '^(#|$$)' $(2) 2>/dev/null \
|md5sum \
|cut -d ' ' -f 1 \
)"; \
new_md5="$$( grep -v -E '^(#|$$)' $(1) 2>/dev/null \
|md5sum \
|cut -d ' ' -f 1 \
)"; \
if [ $${old_md5} = $${new_md5} -a -f $(2) ]; then \
touch -r $(2) $(1); \
fi
endef
# Default configuration
# Depends on top-level .config because it has options we have to shoe-horn
# into crosstool-NG's .config