samples/samples.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 22 21:29:42 2007 +0000 (2007-07-22)
changeset 286 983d9c3949e1
parent 261 4b8cba298bf3
child 333 d647d0e6021e
permissions -rw-r--r--
Move CREDITS to docs/
Be a bit verbose when restoring a sample.
     1 # Makefile to manage samples
     2 
     3 # Build the list of available samples
     4 CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
     5 CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
     6 
     7 CT_SAMPLES := $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)
     8 
     9 help-config::
    10 	@echo  '  saveconfig     - Save current config as a preconfigured target'
    11 
    12 help-samples::
    13 	@$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    14 
    15 help-build::
    16 	@echo  '  regtest        - Regtest-build all samples'
    17 	@echo  '  regtest-local  - Regtest-build all local samples'
    18 	@echo  '  regtest-global - Regtest-build all global samples'
    19 
    20 # How we do build one sample
    21 PHONY += $(CT_SAMPLES)
    22 $(CT_SAMPLES):
    23 	@echo  'Configuring for "$@"'
    24 	@$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig
    25 	@echo  'Execute "$(CT_NG) build" to build your toolchain'
    26 
    27 $(patsubst %,copy_config_%,$(CT_SAMPLES)):
    28 	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then                    \
    29 	      cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    30 	 else                                                                                                       \
    31 	      cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    32 	 fi
    33 
    34 # And now for building all samples one after the other
    35 PHONY += regtest regtest_local regtest_global
    36 regtest: regtest-local regtest-global
    37 
    38 regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
    39 
    40 regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
    41 
    42 # One regtest per sample
    43 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    44 # work because we want to save the samples as well.
    45 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    46 # want to save the log file in a specific place
    47 # Furthermore, force the location where the toolchain will be installed.
    48 # Finaly, we can't use 'make sample-name' as we need to provide default values
    49 # if the options set has changed, but oldconfig does not like when stdin is
    50 # not a terminal (eg. it is a pipe).
    51 $(patsubst %,regtest_%,$(CT_SAMPLES)):
    52 	@samp=$(patsubst regtest_%,%,$@)                                                                ;   \
    53 	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    54 	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
    55 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    56 	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    57 	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    58 	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    59 	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    60 	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    61 	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    62 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    63 	 $(CT_NG) build                                                                                 &&  \
    64 	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
    65 	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
    66 	 $(CT_NG) tarball                                                                               &&  \
    67 	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
    68 	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
    69 	 $(CT_NG) distclean                                                                             ;   \
    70 	 echo -e "\r"
    71 
    72 saveconfig:
    73 	@$(CT_LIB_DIR)/scripts/saveSample.sh