# HG changeset patch # User "Yann E. MORIN" # Date 1224013212 0 # Node ID fb5a4a36e0da465efec05722d26edd7164eb4fd2 # Parent 264d38e5b5ba904215d8354302ef30b37d15495d Use a function to retrieve a sample directory. /trunk/samples/samples.mk | 19 9 10 0 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff -r 264d38e5b5ba -r fb5a4a36e0da samples/samples.mk --- a/samples/samples.mk Tue Oct 14 19:29:25 2008 +0000 +++ b/samples/samples.mk Tue Oct 14 19:40:12 2008 +0000 @@ -30,11 +30,11 @@ list-samples: .FORCE @echo $(CT_SAMPLES) |sed -r -e 's/ /\n/g;' |sort -# How we do build one sample +# How we do recall one sample PHONY += $(CT_SAMPLES) $(CT_SAMPLES): - @echo 'Configuring for "$@"' - @$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig + @cp $(call sample_dir,$@)/crosstool.config .config + @$(MAKE) -rf $(CT_NG) oldconfig @if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \ echo ''; \ echo '***********************************************************'; \ @@ -47,14 +47,13 @@ echo '***********************************************************'; \ echo ''; \ fi - @echo 'Execute "$(CT_NG) build" to build your toolchain' + @echo 'Now configured for "$@"' -$(patsubst %,copy_config_%,$(CT_SAMPLES)): - @if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then \ - cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ - else \ - cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ - fi +# The 'sample_dir' function prints the directory in which the sample is, +# searching first in local samples, then in global samples +define sample_dir +$$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)") +endef # And now for building all samples one after the other PHONY += regtest regtest_local regtest_global