This way version.h isn't generated when running $(make clean) but only when lib.c is about to be compiled. This simplifies packaging for Debian because the package building programs abort when there are additional files after $(make clean). --- Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a4653aa1b747..13b0f97f146e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,6 @@ VERSION=0.5.1 -# Generating file version.h if current version has changed SPARSE_VERSION:=$(shell git describe 2>/dev/null || echo '$(VERSION)') -VERSION_H := $(shell cat version.h 2>/dev/null) -ifneq ($(lastword $(VERSION_H)),"$(SPARSE_VERSION)") -$(info $(shell echo ' GEN 'version.h)) -$(shell echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h) -endif OS = linux @@ -215,6 +209,18 @@ pre-process.sc: CHECKER_FLAGS += -Wno-vla %.o: %.c $(LIB_H) $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +version.h: FORCE + $(QUIET_GEN)echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h.tmp; \ + if cmp -s version.h version.h.tmp; then \ + rm version.h.tmp; \ + else \ + mv version.h.tmp version.h; \ + fi + +.PHONY: FORCE + +lib.o: version.h + %.sc: %.c sparse $(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(ALL_CFLAGS) $< @@ -223,7 +229,7 @@ selfcheck: $(ALL_OBJS:.o=.sc) clean: clean-check - rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc + rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc version.h dist: @if test "$(SPARSE_VERSION)" != "v$(VERSION)" ; then \ -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html