From 947cc4730c1bb8db4cb4692c52d135010466c49b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 8 Oct 2021 09:23:47 +1030 Subject: [PATCH] Makefile: be sure to build generated sources before tests. In particular, they are allowed to include .c files! Here's `make check-units` on a maintainer-clean tree: ``` onchaind/test/run-onchainstress.c:4:10: fatal error: ../../hsmd/hsmd_wiregen.c: No such file or directory 4 | #include "../../hsmd/hsmd_wiregen.c" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make: *** [Makefile:276: onchaind/test/run-onchainstress.o] Error 1 make: *** Waiting for unfinished jobs.... ``` Signed-off-by: Rusty Russell --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 01d3a83ce..a3c852fee 100644 --- a/Makefile +++ b/Makefile @@ -580,6 +580,9 @@ $(CCAN_OBJS) $(CDUMP_OBJS): $(CCAN_HEADERS) Makefile # Except for CCAN, we treat everything else as dependent on external/ bitcoin/ common/ wire/ and all generated headers, and Makefile $(ALL_OBJS): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(ALL_GEN_HEADERS) $(EXTERNAL_HEADERS) Makefile +# Test files can literally #include generated C files. +$(ALL_TEST_PROGRAMS:=.o): $(ALL_GEN_SOURCES) + update-ccan: mv ccan ccan.old DIR=$$(pwd)/ccan; cd ../ccan && ./tools/create-ccan-tree -a $$DIR `cd $$DIR.old/ccan && find * -name _info | sed s,/_info,, | $(SORT)` $(CCAN_NEW)