samples/samples.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Feb 17 22:08:06 2008 +0000 (2008-02-17)
changeset 431 8bde4c6ea47a
parent 286 983d9c3949e1
child 474 2904d77fe117
permissions -rw-r--r--
Robert P. J. DAY says:

apparently, the patchset for gcc 4.2.1 applies properly to the
source for gcc 4.2.2 and gcc 4.2.3. so, if you want, you can simply
add support for those last two just by augmenting menuconfig and
adding a couple symlinks for those two directories. seems like a
cheap way to add a couple new versions.
yann@166
     1
# Makefile to manage samples
yann@63
     2
yann@166
     3
# Build the list of available samples
yann@182
     4
CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
yann@182
     5
CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
yann@182
     6
yann@182
     7
CT_SAMPLES := $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)
yann@63
     8
yann@176
     9
help-config::
yann@333
    10
	@echo  '  saveconfig         - Save current config as a preconfigured target'
yann@176
    11
yann@176
    12
help-samples::
yann@182
    13
	@$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
yann@176
    14
yann@176
    15
help-build::
yann@333
    16
	@echo  '  regtest[.#]        - Regtest-build all samples'
yann@333
    17
	@echo  '  regtest-local[.#]  - Regtest-build all local samples'
yann@333
    18
	@echo  '  regtest-global[.#] - Regtest-build all global samples'
yann@63
    19
yann@166
    20
# How we do build one sample
yann@182
    21
PHONY += $(CT_SAMPLES)
yann@166
    22
$(CT_SAMPLES):
yann@286
    23
	@echo  'Configuring for "$@"'
yann@230
    24
	@$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig
yann@286
    25
	@echo  'Execute "$(CT_NG) build" to build your toolchain'
yann@182
    26
yann@230
    27
$(patsubst %,copy_config_%,$(CT_SAMPLES)):
yann@230
    28
	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then                    \
yann@230
    29
	      cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
yann@182
    30
	 else                                                                                                       \
yann@230
    31
	      cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
yann@182
    32
	 fi
yann@166
    33
yann@166
    34
# And now for building all samples one after the other
yann@230
    35
PHONY += regtest regtest_local regtest_global
yann@230
    36
regtest: regtest-local regtest-global
yann@230
    37
yann@230
    38
regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
yann@230
    39
yann@230
    40
regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
yann@230
    41
yann@333
    42
regtest.% regtest-local.% regtest-global.%:
yann@333
    43
	@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
yann@333
    44
yann@230
    45
# One regtest per sample
yann@166
    46
# We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
yann@166
    47
# work because we want to save the samples as well.
yann@166
    48
# Also, we don't want to see anylog at all, save for the elapsed time, and we
yann@166
    49
# want to save the log file in a specific place
yann@166
    50
# Furthermore, force the location where the toolchain will be installed.
yann@166
    51
# Finaly, we can't use 'make sample-name' as we need to provide default values
yann@166
    52
# if the options set has changed, but oldconfig does not like when stdin is
yann@166
    53
# not a terminal (eg. it is a pipe).
yann@230
    54
$(patsubst %,regtest_%,$(CT_SAMPLES)):
yann@230
    55
	@samp=$(patsubst regtest_%,%,$@)                                                                ;   \
yann@230
    56
	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
yann@230
    57
	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
yann@230
    58
	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
yann@230
    59
	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
yann@230
    60
	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
yann@230
    61
	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
yann@230
    62
	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
yann@230
    63
	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
yann@230
    64
	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
yann@230
    65
	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
yann@230
    66
	 $(CT_NG) build                                                                                 &&  \
yann@230
    67
	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
yann@230
    68
	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
yann@230
    69
	 $(CT_NG) tarball                                                                               &&  \
yann@230
    70
	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
yann@230
    71
	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
yann@230
    72
	 $(CT_NG) distclean                                                                             ;   \
yann@230
    73
	 echo -e "\r"
yann@166
    74
yann@63
    75
saveconfig:
yann@189
    76
	@$(CT_LIB_DIR)/scripts/saveSample.sh