samples/Makefile
changeset 166 fe502496fc06
parent 74 7987069e8312
child 167 d8b573409f2e
     1.1 --- a/samples/Makefile	Tue May 08 10:57:34 2007 +0000
     1.2 +++ b/samples/Makefile	Sun Jun 17 11:13:48 2007 +0000
     1.3 @@ -1,15 +1,48 @@
     1.4 -# Build a list of all available samples
     1.5 +# Makefile to manage samples
     1.6  
     1.7 -CT_SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(filter-out %Makefile,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config)))
     1.8 -.PHONY: $(SAMPLES)
     1.9 -$(CT_SAMPLES):
    1.10 -	@cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config"
    1.11 -	@$(MAKE) oldconfig
    1.12 +# Build the list of available samples
    1.13 +CT_SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
    1.14  
    1.15  help::
    1.16  	@echo  'Preconfigured targets:'
    1.17  	@$(CT_TOP_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    1.18  	@echo  ''
    1.19  
    1.20 +# How we do build one sample
    1.21 +.PHONY: $(CT_SAMPLES)
    1.22 +$(CT_SAMPLES):
    1.23 +	@cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config"
    1.24 +	@$(MAKE) oldconfig
    1.25 +
    1.26 +# And now for building all samples one after the other
    1.27 +# We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    1.28 +# work because we want to save the samples as well.
    1.29 +# Also, we don't want to see anylog at all, save for the elapsed time, and we
    1.30 +# want to save the log file in a specific place
    1.31 +# Furthermore, force the location where the toolchain will be installed.
    1.32 +# Finaly, we can't use 'make sample-name' as we need to provide default values
    1.33 +# if the options set has changed, but oldconfig does not like when stdin is
    1.34 +# not a terminal (eg. it is a pipe).
    1.35 +.PHONY: regtest
    1.36 +regtest:
    1.37 +	@for samp in $(CT_SAMPLES); do                                                                          \
    1.38 +	     echo "Building sample \"$${samp}\""                                                            &&  \
    1.39 +	     cp "$(CT_TOP_DIR)/samples/$${samp}/crosstool.config" "$(CT_TOP_DIR)/.config"                   &&  \
    1.40 +	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    1.41 +	     sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config   &&  \
    1.42 +	     sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    1.43 +	     sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    1.44 +	     sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    1.45 +	     sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    1.46 +	     sed -i -r -e 's:^.*(CT_LOG_FILE).*$$:\1="$${CT_PREFIX_DIR}/build.log":;' .config               &&  \
    1.47 +	     sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    1.48 +	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    1.49 +	     make -C $(CT_TOP_DIR)                                                                          &&  \
    1.50 +	     make -C $(CT_TOP_DIR) tarball                                                                  &&  \
    1.51 +	     chmod -R u+w $(CT_TOP_DIR)/targets                                                             &&  \
    1.52 +	     rm -rf $(CT_TOP_DIR)/targets;                                                                      \
    1.53 +	 done
    1.54 +	@make distclean
    1.55 +
    1.56  saveconfig:
    1.57 -	@$(CT_TOP_DIR)/scripts/saveSample.sh
    1.58 +	$(CT_TOP_DIR)/scripts/saveSample.sh