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