yann@166: # Makefile to manage samples yann@63: yann@166: # Build the list of available samples yann@182: CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config)) yann@182: CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config))) yann@182: yann@605: CT_SAMPLES := $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)) yann@63: yann@176: help-config:: yann@333: @echo ' saveconfig - Save current config as a preconfigured target' yann@176: yann@176: help-samples:: yann@544: @echo ' list-samples - prints the list of all samples (for scripting)' yann@544: @echo ' show- - show a brief overview of (list below)' yann@544: @echo ' - preconfigure crosstool-NG with (list below)' yann@182: @$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES) yann@176: yann@176: help-build:: yann@333: @echo ' regtest[.#] - Regtest-build all samples' yann@333: @echo ' regtest-local[.#] - Regtest-build all local samples' yann@333: @echo ' regtest-global[.#] - Regtest-build all global samples' yann@63: yann@560: help-distrib:: yann@560: @echo ' wiki-samples - Print a DokuWiki table of samples' yann@560: yann@539: $(patsubst %,show-%,$(CT_SAMPLES)): yann@539: @$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@)) yann@539: yann@544: PHONY += list-samples yann@544: list-samples: .FORCE yann@539: @echo $(CT_SAMPLES) |sed -r -e 's/ /\n/g;' |sort yann@474: yann@166: # How we do build one sample yann@182: PHONY += $(CT_SAMPLES) yann@166: $(CT_SAMPLES): yann@286: @echo 'Configuring for "$@"' yann@230: @$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig yann@822: @if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \ yann@822: echo ''; \ yann@822: echo '***********************************************************'; \ yann@822: echo ''; \ yann@822: echo 'WARNING! This sample may enable experimental features.'; \ yann@822: echo ' Please be sure to review the configuration prior'; \ yann@822: echo ' to building and using your toolchain!'; \ yann@822: echo 'Now, you have been warned!'; \ yann@822: echo ''; \ yann@822: echo '***********************************************************'; \ yann@822: echo ''; \ yann@822: fi yann@286: @echo 'Execute "$(CT_NG) build" to build your toolchain' yann@182: yann@230: $(patsubst %,copy_config_%,$(CT_SAMPLES)): yann@230: @if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then \ yann@230: cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ yann@182: else \ yann@230: cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ yann@182: fi yann@166: yann@166: # And now for building all samples one after the other yann@230: PHONY += regtest regtest_local regtest_global yann@230: regtest: regtest-local regtest-global yann@230: yann@230: regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES)) yann@230: yann@230: regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES)) yann@230: yann@333: regtest.% regtest-local.% regtest-global.%: yann@333: @$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;') yann@333: yann@230: # One regtest per sample yann@166: # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't yann@166: # work because we want to save the samples as well. yann@166: # Also, we don't want to see anylog at all, save for the elapsed time, and we yann@166: # want to save the log file in a specific place yann@166: # Furthermore, force the location where the toolchain will be installed. yann@166: # Finaly, we can't use 'make sample-name' as we need to provide default values yann@166: # if the options set has changed, but oldconfig does not like when stdin is yann@166: # not a terminal (eg. it is a pipe). yann@230: $(patsubst %,regtest_%,$(CT_SAMPLES)): yann@230: @samp=$(patsubst regtest_%,%,$@) ; \ yann@230: echo -e "\rBuilding sample \"$${samp}\"" && \ yann@230: $(CT_NG) copy_config_$${samp} && \ yann@230: yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \ yann@230: sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config && \ yann@230: sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config && \ yann@230: sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config && \ yann@230: sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config && \ yann@230: sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config && \ yann@230: sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config && \ yann@230: yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \ yann@230: $(CT_NG) build && \ yann@230: echo -e "\rSuccessfully built sample \"$${samp}\"" && \ yann@230: echo -e "\rMaking tarball for sample \"$${samp}\"" && \ yann@230: $(CT_NG) tarball && \ yann@230: echo -e "\rSuccessfully built tarball for sample \"$${samp}\"" ; \ yann@230: echo -e "\rCleaning sample \"$${samp}\"" ; \ yann@230: $(CT_NG) distclean ; \ yann@230: echo -e "\r" yann@166: yann@63: saveconfig: yann@189: @$(CT_LIB_DIR)/scripts/saveSample.sh yann@560: yann@560: wiki-samples: yann@560: @$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)