samples/Makefile
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jun 17 11:13:48 2007 +0000 (2007-06-17)
changeset 166 fe502496fc06
parent 74 7987069e8312
child 167 d8b573409f2e
permissions -rw-r--r--
Add the "regtest" make target: call "make regtest", and all samples wil be built, and a tarball made for each of them. First sample to fail causes the test to stop.
     1 # Makefile to manage samples
     2 
     3 # Build the list of available samples
     4 CT_SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
     5 
     6 help::
     7 	@echo  'Preconfigured targets:'
     8 	@$(CT_TOP_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
     9 	@echo  ''
    10 
    11 # How we do build one sample
    12 .PHONY: $(CT_SAMPLES)
    13 $(CT_SAMPLES):
    14 	@cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config"
    15 	@$(MAKE) oldconfig
    16 
    17 # And now for building all samples one after the other
    18 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    19 # work because we want to save the samples as well.
    20 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    21 # want to save the log file in a specific place
    22 # Furthermore, force the location where the toolchain will be installed.
    23 # Finaly, we can't use 'make sample-name' as we need to provide default values
    24 # if the options set has changed, but oldconfig does not like when stdin is
    25 # not a terminal (eg. it is a pipe).
    26 .PHONY: regtest
    27 regtest:
    28 	@for samp in $(CT_SAMPLES); do                                                                          \
    29 	     echo "Building sample \"$${samp}\""                                                            &&  \
    30 	     cp "$(CT_TOP_DIR)/samples/$${samp}/crosstool.config" "$(CT_TOP_DIR)/.config"                   &&  \
    31 	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    32 	     sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config   &&  \
    33 	     sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    34 	     sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    35 	     sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    36 	     sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    37 	     sed -i -r -e 's:^.*(CT_LOG_FILE).*$$:\1="$${CT_PREFIX_DIR}/build.log":;' .config               &&  \
    38 	     sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    39 	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    40 	     make -C $(CT_TOP_DIR)                                                                          &&  \
    41 	     make -C $(CT_TOP_DIR) tarball                                                                  &&  \
    42 	     chmod -R u+w $(CT_TOP_DIR)/targets                                                             &&  \
    43 	     rm -rf $(CT_TOP_DIR)/targets;                                                                      \
    44 	 done
    45 	@make distclean
    46 
    47 saveconfig:
    48 	$(CT_TOP_DIR)/scripts/saveSample.sh