From f7d6e53e2b40bd70fdfcd6178ea6f57c64fabf9f Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Fri, 13 Nov 2015 18:47:13 -0800 Subject: Add update-samples target. Same as check-samples, but actually updates the crosstool.config. Signed-off-by: Alexey Neyman diff --git a/samples/samples.mk b/samples/samples.mk index c87e5fc..2d9a287 100644 --- a/samples/samples.mk +++ b/samples/samples.mk @@ -11,6 +11,10 @@ CT_SAMPLES := $(shell echo $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)) \ |$(sed) -r -e 's/(.*),(.*)/\2,\1/;' \ ) +# If set to yes on command line, updates the sample configuration +# instead of just dumping the diff. +CT_UPDATE_SAMPLES := no + # ---------------------------------------------------------- # This part deals with the samples help entries @@ -81,21 +85,29 @@ list-samples-short: FORCE # Check one sample PHONY += $(patsubst %,check-%,$(CT_SAMPLES)) -$(patsubst %,check-%,$(CT_SAMPLES)): config_files +$(patsubst %,check-%,$(CT_SAMPLES)): check-%: config_files @export KCONFIG_CONFIG=$$(pwd)/.config.sample; \ - CT_NG_SAMPLE=$(call sample_dir,$(patsubst check-%,%,$(@)))/crosstool.config; \ - $(CONF) --defconfig=$${CT_NG_SAMPLE} $(KCONFIG_TOP) >/dev/null; \ - $(CONF) --savedefconfig=$$(pwd)/.defconfig $(KCONFIG_TOP) >/dev/null; \ + CT_NG_SAMPLE=$(call sample_dir,$*)/crosstool.config; \ + $(CONF) -s --defconfig=$${CT_NG_SAMPLE} $(KCONFIG_TOP) &>/dev/null; \ + $(CONF) -s --savedefconfig=$$(pwd)/.defconfig $(KCONFIG_TOP) &>/dev/null; \ old_sha1=$$( sha1sum "$${CT_NG_SAMPLE}" |cut -d ' ' -f 1 ); \ new_sha1=$$( sha1sum .defconfig |cut -d ' ' -f 1 ); \ if [ $${old_sha1} != $${new_sha1} ]; then \ - echo "$(patsubst check-%,%,$(@)) needs update:"; \ - diff -du0 "$${CT_NG_SAMPLE}" .defconfig |tail -n +4; \ + if [ $(CT_UPDATE_SAMPLES) = yes ]; then \ + echo "Updating $*"; \ + mv .defconfig "$${CT_NG_SAMPLE}"; \ + else \ + echo "$* needs update:"; \ + diff -du0 "$${CT_NG_SAMPLE}" .defconfig |tail -n +4; \ + fi; \ fi @rm -f .config.sample* .defconfig check-samples: $(patsubst %,check-%,$(CT_SAMPLES)) +update-samples: + $(SILENT)$(MAKE) -rf $(CT_NG) check-samples CT_UPDATE_SAMPLES=yes + PHONY += wiki-samples wiki-samples: wiki-samples-pre $(patsubst %,wiki-%,$(CT_SAMPLES)) wiki-samples-post -- cgit v0.10.2-6-g49f6