diff --git a/Makefile b/Makefile index 18e261b6e..2575184e8 100644 --- a/Makefile +++ b/Makefile @@ -280,12 +280,18 @@ else EXP := endif +# tools/update-mocks.sh does nasty recursive make, must not do this! +ifeq ($(SUPPRESS_GENERATION),1) +SHA256STAMP_CHANGED = false +SHA256STAMP = exit 1 +else # Git doesn't maintain timestamps, so we only regen if sources actually changed: # We place the SHA inside some generated files so we can tell if they need updating. # Usage: $(call SHA256STAMP_CHANGED) SHA256STAMP_CHANGED = [ x"`sed -n 's/.*SHA256STAMP://p' $@ 2>/dev/null`" != x"`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64`" ] # Usage: $(call SHA256STAMP,commentprefix) SHA256STAMP = echo '$(1) SHA256STAMP:'`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64` >> $@ +endif # generate-wire.py --page [header|impl] hdrfilename wirename < csv > file %_wiregen.h: %_wire.csv $(WIRE_GEN_DEPS) @@ -363,7 +369,7 @@ ALL_OBJS := $(ALL_C_SOURCES:.c=.o) # We always regen wiregen and printgen files, since SHA256STAMP protects against # spurious rebuilds. -$(filter %printgen.h %printgen.c %wiregen.h %wiregen.c, $(ALL_C_HEADERS) $(ALL_C_SOURCES)): FORCE +$(filter %printgen.h %printgen.c %wiregen.h %wiregen.c, $(ALL_C_HEADERS) $(ALL_C_SOURCES)): $(FORCE) ifneq ($(TEST_GROUP_COUNT),) PYTEST_OPTS += --test-group=$(TEST_GROUP) --test-group-count=$(TEST_GROUP_COUNT) @@ -527,9 +533,13 @@ ncc: ${TARGET_DIR}/libwally-core-build/src/libwallycore.la $(MAKE) CC="ncc -ncgcc -ncld -ncfabs" AR=nccar LD=nccld # Ignore test/ directories. -TAGS: FORCE +TAGS: $(RM) TAGS; find * -name test -type d -prune -o -name '*.[ch]' -print -o -name '*.py' -print | xargs etags --append + +ifneq ($(SUPPRESS_GENERATION),1) +FORCE = FORCE FORCE:: +endif ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS) @@ -537,7 +547,7 @@ ALL_PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr # Can't add to ALL_OBJS, as that makes a circular dep. ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS) Makefile -version_gen.h: FORCE +version_gen.h: $(FORCE) @(echo "#define VERSION \"$(VERSION)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new @if cmp $@.new $@ >/dev/null 2>&1; then rm -f $@.new; else mv $@.new $@; $(ECHO) Version updated; fi diff --git a/doc/Makefile b/doc/Makefile index 900aedaf3..525c65777 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -89,7 +89,7 @@ doc-all: $(MANPAGES) doc/index.rst $(MANPAGES): doc/%: doc/%.md @if $(call SHA256STAMP_CHANGED); then $(call VERBOSE, "mrkd $<", mrkd $< $@ && $(call SHA256STAMP,\")); else touch $@; fi -$(MANPAGES): FORCE +$(MANPAGES): $(FORCE) doc/protocol-%.svg: test/test_protocol test/test_protocol --svg < test/commits/$*.script > $@ diff --git a/external/Makefile b/external/Makefile index 590e6c568..975d4d259 100644 --- a/external/Makefile +++ b/external/Makefile @@ -48,7 +48,7 @@ endif EXTERNAL_LDLIBS := -L${TARGET_DIR} $(patsubst lib%.a,-l%,$(notdir $(EXTERNAL_LIBS))) -submodcheck: FORCE +submodcheck: $(FORCE) @tools/refresh-submodules.sh $(SUBMODULES) @cd external/libwally-core && ../../tools/refresh-submodules.sh src/secp256k1 diff --git a/tools/Makefile b/tools/Makefile index b4dc87710..64653331a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -12,7 +12,7 @@ TOOLS_COMMON_OBJS = common/utils.o # We force make to relink this every time, to detect version changes. # Do it atomically, otherwise parallel builds can get upset! -tools/headerversions: FORCE tools/headerversions.o $(CCAN_OBJS) +tools/headerversions: $(FORCE) tools/headerversions.o $(CCAN_OBJS) @trap "rm -f $@.tmp.$$$$" EXIT; $(LINK.o) tools/headerversions.o $(CCAN_OBJS) $(LOADLIBES) $(LDLIBS) -o $@.tmp.$$$$ && mv $@.tmp.$$$$ $@ tools/check-bolt: tools/check-bolt.o $(CCAN_OBJS) $(TOOLS_COMMON_OBJS) diff --git a/tools/update-mocks.sh b/tools/update-mocks.sh index 00c63afbb..4e071883e 100755 --- a/tools/update-mocks.sh +++ b/tools/update-mocks.sh @@ -13,7 +13,7 @@ START=$(grep -F -n '/* AUTOGENERATED MOCKS START */' "$FILE" | cut -d: -f1) END=$(grep -F -n '/* AUTOGENERATED MOCKS END */' "$FILE" | cut -d: -f1) function make_binary() { - $MAKE "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null + $MAKE SUPPRESS_GENERATION=1 "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null } if [ -n "$START" ]; then diff --git a/wallet/Makefile b/wallet/Makefile index 70ea1579a..705290d7a 100644 --- a/wallet/Makefile +++ b/wallet/Makefile @@ -36,12 +36,12 @@ SQL_FILES := \ wallet/test/run-db.c \ wallet/test/run-wallet.c \ -wallet/statements_gettextgen.po: $(SQL_FILES) FORCE +wallet/statements_gettextgen.po: $(SQL_FILES) $(FORCE) @if $(call SHA256STAMP_CHANGED); then if [ "$$NO_PYTHON" = 1 ]; then echo "Error: NO_PYTHON on $@"; exit 1; fi; \ $(call VERBOSE,"xgettext $@",xgettext -kNAMED_SQL -kSQL --add-location --no-wrap --omit-header -o $@ $(SQL_FILES) && $(call SHA256STAMP,# )); \ fi -wallet/db_%_sqlgen.c: wallet/statements_gettextgen.po devtools/sql-rewrite.py FORCE +wallet/db_%_sqlgen.c: wallet/statements_gettextgen.po devtools/sql-rewrite.py $(FORCE) @if $(call SHA256STAMP_CHANGED); then if [ "$$NO_PYTHON" = 1 ]; then echo "Error: NO_PYTHON on $@"; exit 1; fi; \ $(call VERBOSE,"sql-rewrite $@",devtools/sql-rewrite.py wallet/statements_gettextgen.po $* > $@ && $(call SHA256STAMP,//)); \ fi