Use a function to retrieve a sample directory.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Oct 14 19:40:12 2008 +0000 (2008-10-14)
changeset 933fb5a4a36e0da
parent 932 264d38e5b5ba
child 934 e2f4be0feb9d
Use a function to retrieve a sample directory.

/trunk/samples/samples.mk | 19 9 10 0 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
samples/samples.mk
     1.1 --- a/samples/samples.mk	Tue Oct 14 19:29:25 2008 +0000
     1.2 +++ b/samples/samples.mk	Tue Oct 14 19:40:12 2008 +0000
     1.3 @@ -30,11 +30,11 @@
     1.4  list-samples: .FORCE
     1.5  	@echo $(CT_SAMPLES) |sed -r -e 's/ /\n/g;' |sort
     1.6  
     1.7 -# How we do build one sample
     1.8 +# How we do recall one sample
     1.9  PHONY += $(CT_SAMPLES)
    1.10  $(CT_SAMPLES):
    1.11 -	@echo  'Configuring for "$@"'
    1.12 -	@$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig
    1.13 +	@cp $(call sample_dir,$@)/crosstool.config .config
    1.14 +	@$(MAKE) -rf $(CT_NG) oldconfig
    1.15  	@if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then        \
    1.16  	   echo  '';                                                            \
    1.17  	   echo  '***********************************************************'; \
    1.18 @@ -47,14 +47,13 @@
    1.19  	   echo  '***********************************************************'; \
    1.20  	   echo  '';                                                            \
    1.21  	 fi
    1.22 -	@echo  'Execute "$(CT_NG) build" to build your toolchain'
    1.23 +	@echo  'Now configured for "$@"'
    1.24  
    1.25 -$(patsubst %,copy_config_%,$(CT_SAMPLES)):
    1.26 -	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then                    \
    1.27 -	      cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    1.28 -	 else                                                                                                       \
    1.29 -	      cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    1.30 -	 fi
    1.31 +# The 'sample_dir' function prints the directory in which the sample is,
    1.32 +# searching first in local samples, then in global samples
    1.33 +define sample_dir
    1.34 +$$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
    1.35 +endef
    1.36  
    1.37  # And now for building all samples one after the other
    1.38  PHONY += regtest regtest_local regtest_global