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