samples/Makefile
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jun 17 16:24:23 2007 +0000 (2007-06-17)
changeset 176 59676cfb4ada
parent 174 75f3f975e2ad
child 179 ba6e7292f7bf
permissions -rw-r--r--
Rework the help system. For now, this is mostly a no-op (it only re-organise the help entries), but later, that may come in handy when we want ct-ng to be installable).
     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-config::
     7 	@echo  '  saveconfig     - Save current config as a preconfigured target'
     8 
     9 help-samples::
    10 	@$(CT_TOP_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    11 
    12 help-build::
    13 	@echo  '  regtest        - Regtest-build all samples'
    14 
    15 # How we do build one sample
    16 .PHONY: $(CT_SAMPLES)
    17 $(CT_SAMPLES):
    18 	@cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config"
    19 	@$(MAKE) oldconfig
    20 
    21 # And now for building all samples one after the other
    22 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    23 # work because we want to save the samples as well.
    24 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    25 # want to save the log file in a specific place
    26 # Furthermore, force the location where the toolchain will be installed.
    27 # Finaly, we can't use 'make sample-name' as we need to provide default values
    28 # if the options set has changed, but oldconfig does not like when stdin is
    29 # not a terminal (eg. it is a pipe).
    30 .PHONY: regtest
    31 regtest:
    32 	@for samp in $(CT_SAMPLES); do                                                                          \
    33 	     echo "Building sample \"$${samp}\""                                                            &&  \
    34 	     cp "$(CT_TOP_DIR)/samples/$${samp}/crosstool.config" "$(CT_TOP_DIR)/.config"                   &&  \
    35 	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    36 	     sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config   &&  \
    37 	     sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    38 	     sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    39 	     sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    40 	     sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    41 	     sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    42 	     yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1                                     &&  \
    43 	     make -C $(CT_TOP_DIR)                                                                          &&  \
    44 	     echo "Making tarball for sample \"$${samp}\""                                                  &&  \
    45 	     make -C $(CT_TOP_DIR) tarball                                                                  &&  \
    46 	     echo "Cleaning sample \"$${samp}\""                                                            &&  \
    47 	     make -C $(CT_TOP_DIR) distclean;                                                                   \
    48 	 done
    49 
    50 saveconfig:
    51 	$(CT_TOP_DIR)/scripts/saveSample.sh