samples/Makefile
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jun 17 14:51:37 2007 +0000 (2007-06-17)
changeset 174 75f3f975e2ad
parent 167 d8b573409f2e
child 176 59676cfb4ada
permissions -rw-r--r--
The log file is no longer configurable: it is always "${CT_PREFIX_DIR}/build.log".
Add an option to compress the log file upon successfull build.
Make rendering the toolchain read-only optional.
A few eye-candy fixes.
     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_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    38 	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    39 	     make -C $(CT_TOP_DIR)                                                                          &&  \
    40 	     echo "Making tarball for sample \"$${samp}\""                                                  &&  \
    41 	     make -C $(CT_TOP_DIR) tarball                                                                  &&  \
    42 	     echo "Cleaning sample \"$${samp}\""                                                            &&  \
    43 	     make -C $(CT_TOP_DIR) distclean;                                                                   \
    44 	 done
    45 
    46 saveconfig:
    47 	$(CT_TOP_DIR)/scripts/saveSample.sh