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@182: CT_SAMPLES := $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES) yann@63: yann@176: help-config:: yann@176: @echo ' saveconfig - Save current config as a preconfigured target' yann@176: yann@176: help-samples:: yann@182: @$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES) yann@176: yann@176: help-build:: yann@176: @echo ' regtest - Regtest-build all samples' yann@63: yann@166: # How we do build one sample yann@182: PHONY += $(CT_SAMPLES) yann@166: $(CT_SAMPLES): yann@182: @$(MAKE) -f $(CT_MAKEFILE) $(patsubst %,%_copy_config,$(@)) oldconfig yann@182: yann@182: $(patsubst %,%_copy_config,$(CT_SAMPLES)): yann@182: @if [ -f $(CT_TOP_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config ]; then \ yann@182: cp "$(CT_TOP_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ yann@182: else \ yann@182: 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@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@182: PHONY += regtest yann@166: regtest: yann@166: @for samp in $(CT_SAMPLES); do \ yann@179: echo -e "\rBuilding sample \"$${samp}\"" && \ yann@182: $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) $${samp}_copy_config && \ yann@182: yes "" |$(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) defoldconfig >/dev/null 2>&1 && \ yann@182: sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config && \ yann@166: sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config && \ yann@166: sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config && \ yann@166: sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config && \ yann@166: sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config && \ yann@166: sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config && \ yann@182: yes "" |$(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) defoldconfig >/dev/null 2>&1 && \ yann@182: $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) && \ yann@179: echo -e "\rMaking tarball for sample \"$${samp}\"" && \ yann@182: $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) tarball ; \ yann@182: echo -e "\rCleaning sample \"$${samp}\"" ; \ yann@182: $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) distclean ; \ yann@166: done yann@166: yann@63: saveconfig: yann@182: $(CT_LIB_DIR)/scripts/saveSample.sh