From 1746406e41e72fbe3daa527435f9d34f2a6d564f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 31 Aug 2020 10:43:25 +0930 Subject: [PATCH] Makefile: normalize all the Makefiles We create ALL_PROGRAMS, ALL_TEST_PROGRAMS, ALL_C_SOURCES and ALL_C_HEADERS. Then the toplevel Makefile knows which are autogenerated (by wildcard), so it can have all the rules to clean them or check the source as necessary. Signed-off-by: Rusty Russell --- Makefile | 30 +++-- bitcoin/test/Makefile | 2 +- channeld/Makefile | 63 +++------- channeld/test/Makefile | 4 +- cli/Makefile | 21 +--- cli/test/Makefile | 2 +- closingd/Makefile | 57 ++------- common/Makefile | 3 +- common/test/Makefile | 2 +- connectd/Makefile | 53 ++------ connectd/test/Makefile | 12 +- devtools/Makefile | 24 ++-- gossipd/Makefile | 54 ++------ gossipd/test/Makefile | 8 +- hsmd/Makefile | 46 ++----- lightningd/Makefile | 130 ++++++++------------ lightningd/test/Makefile | 4 +- lightningd/test/run-invoice-select-inchan.c | 3 - onchaind/Makefile | 78 ++++-------- onchaind/test/Makefile | 8 +- openingd/Makefile | 61 ++------- plugins/Makefile | 21 +--- tests/plugins/Makefile | 12 +- tools/Makefile | 7 +- wallet/Makefile | 21 ++-- wallet/test/Makefile | 12 +- wire/Makefile | 50 +++----- wire/test/Makefile | 9 +- 28 files changed, 249 insertions(+), 548 deletions(-) diff --git a/Makefile b/Makefile index 6a11343b7..2d8753ee9 100644 --- a/Makefile +++ b/Makefile @@ -204,7 +204,11 @@ WIRE_GEN := $(BOLT_GEN) # If you use wiregen, you're dependent on the tool, its templates, and Makefile WIRE_GEN_DEPS := $(WIRE_GEN) Makefile $(wildcard tools/gen/*_template) -ALL_PROGRAMS = +# These are filled by individual Makefiles +ALL_PROGRAMS := +ALL_TEST_PROGRAMS := +ALL_C_SOURCES := +ALL_C_HEADERS := gen_header_versions.h gen_list_of_builtin_plugins.h gen_version.h CPPFLAGS += -DBINTOPKGLIBEXECDIR="\"$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))\"" CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(SQLITE3_CFLAGS) $(POSTGRES_INCLUDE) $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DBUILD_ELEMENTS=1 @@ -288,6 +292,14 @@ include tools/Makefile include plugins/Makefile include tests/plugins/Makefile +# We make pretty much everything depend on these. +ALL_GEN_HEADERS := $(filter gen%.h %printgen.h %wiregen.h,$(ALL_C_HEADERS)) +ALL_GEN_SOURCES := $(filter gen%.c %printgen.c %wiregen.c,$(ALL_C_SOURCES)) +ALL_NONGEN_SRCFILES := $(filter-out gen%.h %printgen.h %wiregen.h,$(ALL_C_HEADERS)) $(filter-out gen%.c %printgen.c %wiregen.c,$(ALL_C_SOURCES)) + +# Every single object file. +ALL_OBJS := $(ALL_C_SOURCES:.c=.o) + # Generated from PLUGINS definition in plugins/Makefile gen_list_of_builtin_plugins.h : plugins/Makefile Makefile @echo GEN $@ @@ -353,12 +365,12 @@ LOCAL_BOLTDIR=.tmp.lightningrfc bolt-precheck: @[ -d $(BOLTDIR) ] || exit 0; set -e; if [ -z "$(BOLTVERSION)" ]; then rm -rf $(LOCAL_BOLTDIR); ln -sf $(BOLTDIR) $(LOCAL_BOLTDIR); exit 0; fi; [ "$$(git -C $(LOCAL_BOLTDIR) rev-list --max-count=1 HEAD 2>/dev/null)" != "$(BOLTVERSION)" ] || exit 0; rm -rf $(LOCAL_BOLTDIR) && git clone -q $(BOLTDIR) $(LOCAL_BOLTDIR) && cd $(LOCAL_BOLTDIR) && git checkout -q $(BOLTVERSION) -check-source-bolt: $(ALL_TEST_PROGRAMS:%=bolt-check/%.c) +check-source-bolt: $(ALL_NONGEN_SRCFILES:%=bolt-check/%) check-whitespace/%: % @if grep -Hn '[ ]$$' $<; then echo Extraneous whitespace found >&2; exit 1; fi -check-whitespace: check-whitespace/Makefile check-whitespace/tools/check-bolt.c $(ALL_TEST_PROGRAMS:%=check-whitespace/%.c) +check-whitespace: check-whitespace/Makefile check-whitespace/tools/check-bolt.c $(ALL_NONGEN_SRCFILES:%=check-whitespace/%) check-markdown: @tools/check-markdown.sh @@ -440,9 +452,6 @@ gen_version.h: FORCE gen_header_versions.h: tools/headerversions @tools/headerversions $@ -# Rebuild the world if this changes. -ALL_GEN_HEADERS += gen_header_versions.h - # All binaries require the external libs, ccan and system library versions. $(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS): $(EXTERNAL_LIBS) $(CCAN_OBJS) @@ -462,8 +471,8 @@ $(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 -# We generate headers in two ways, so regen when either changes (or Makefile) -$(ALL_GEN_HEADERS): ccan/ccan/cdump/tools/cdump-enumstr Makefile +# Regen headers when Makefile changes +$(ALL_GEN_HEADERS): Makefile update-ccan: mv ccan ccan.old @@ -486,11 +495,12 @@ distclean: clean maintainer-clean: distclean @echo 'This command is intended for maintainers to use; it' @echo 'deletes files that may need special tools to rebuild.' + $(RM) $(ALL_GEN_HEADERS) $(ALL_GEN_SOURCES) clean: $(RM) $(CCAN_OBJS) $(CDUMP_OBJS) $(ALL_OBJS) - $(RM) $(ALL_PROGRAMS) $(ALL_PROGRAMS:=.o) - $(RM) $(ALL_TEST_PROGRAMS) $(ALL_TEST_PROGRAMS:=.o) + $(RM) $(ALL_PROGRAMS) + $(RM) $(ALL_TEST_PROGRAMS) $(RM) gen_*.h */gen_* ccan/tools/configurator/configurator $(RM) ccan/ccan/cdump/tools/cdump-enumstr.o find . -name '*gcda' -delete diff --git a/bitcoin/test/Makefile b/bitcoin/test/Makefile index 799d16f54..f3c541641 100644 --- a/bitcoin/test/Makefile +++ b/bitcoin/test/Makefile @@ -8,7 +8,7 @@ $(BITCOIN_TEST_PROGRAMS): $(CCAN_OBJS) $(BITCOIN_TEST_COMMON_OBJS) bitcoin/chain $(BITCOIN_TEST_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(BITCOIN_SRC) ALL_TEST_PROGRAMS += $(BITCOIN_TEST_PROGRAMS) -ALL_OBJS += $(BITCOIN_TEST_PROGRAMS:=.o) +ALL_C_SOURCES += $(BITCOIN_TEST_PROGRAMS:=.c) # This needs to know what level of optimization we're using. bitcoin/test/run-secret_eq_consttime.o: CFLAGS += -DCOPTFLAGS="\"${COPTFLAGS}\"" diff --git a/channeld/Makefile b/channeld/Makefile index 1ea83a1e3..f71296fab 100644 --- a/channeld/Makefile +++ b/channeld/Makefile @@ -1,38 +1,31 @@ #! /usr/bin/make -# Designed to be run one level up -channeld-wrongdir: - $(MAKE) -C ../.. lightningd/channel-all - -default: channeld-all - -channeld-all: lightningd/lightning_channeld - -LIGHTNINGD_CHANNEL_HEADERS_GEN := \ - channeld/gen_full_channel_error_names.h \ - channeld/channeld_wiregen.h - -LIGHTNINGD_CHANNEL_HEADERS_NOGEN := \ +CHANNELD_HEADERS := \ + channeld/gen_full_channel_error_names.h \ + channeld/channeld_wiregen.h \ channeld/channeld_htlc.h \ channeld/commit_tx.h \ channeld/full_channel.h \ channeld/full_channel_error.h \ channeld/watchtower.h -LIGHTNINGD_CHANNEL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN) $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN) - -LIGHTNINGD_CHANNEL_SRC := channeld/channeld.c \ +CHANNELD_SRC := channeld/channeld.c \ channeld/commit_tx.c \ channeld/full_channel.c \ channeld/channeld_wiregen.c \ channeld/watchtower.c -LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o) +CHANNELD_OBJS := $(CHANNELD_SRC:.c=.o) +$(CHANNELD_OBJS): $(CHANNELD_HEADERS) # Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_CHANNEL_OBJS) +ALL_C_SOURCES += $(CHANNELD_SRC) +ALL_C_HEADERS += $(CHANNELD_HEADERS) ALL_PROGRAMS += lightningd/lightning_channeld -ALL_GEN_HEADERS += $(LIGHTNINGD_CHANNEL_HEADERS_GEN) + +# Here's what lightningd depends on +LIGHTNINGD_CONTROL_HEADERS += channeld/channeld_wiregen.h +LIGHTNINGD_CONTROL_OBJS += channeld/channeld_wiregen.o # Common source we use. CHANNELD_COMMON_OBJS := \ @@ -96,37 +89,9 @@ CHANNELD_COMMON_OBJS := \ wire/fromwire.o \ wire/towire.o -LIGHTNINGD_CHANNEL_SRC_GEN := $(filter channeld/%_wiregen.c, $(LIGHTNINGD_CHANNEL_SRC)) - -LIGHTNINGD_CHANNEL_SRC_NOGEN := $(filter-out channeld/%_wiregen.c, $(LIGHTNINGD_CHANNEL_SRC)) - -# Control daemon uses this: -LIGHTNINGD_CHANNEL_CONTROL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN) -LIGHTNINGD_CHANNEL_CONTROL_SRC := $(LIGHTNINGD_CHANNEL_SRC_GEN) -LIGHTNINGD_CHANNEL_CONTROL_OBJS := $(LIGHTNINGD_CHANNEL_CONTROL_SRC:.c=.o) - -# Add to headers which any object might need. -LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CHANNEL_HEADERS_GEN) -LIGHTNINGD_HEADERS_NOGEN += $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN) - channeld/gen_full_channel_error_names.h: channeld/full_channel_error.h ccan/ccan/cdump/tools/cdump-enumstr ccan/ccan/cdump/tools/cdump-enumstr channeld/full_channel_error.h > $@ +lightningd/lightning_channeld: $(CHANNELD_OBJS) $(WIRE_ONION_OBJS) $(CHANNELD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS) -$(LIGHTNINGD_CHANNEL_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_GOSSIP_CONTROL_HEADERS) - -LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o) - -lightningd/lightning_channeld: $(LIGHTNINGD_CHANNEL_OBJS) $(WIRE_ONION_OBJS) $(CHANNELD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -check-source: $(LIGHTNINGD_CHANNEL_SRC_NOGEN:%=check-src-include-order/%) -check-source-bolt: $(LIGHTNINGD_CHANNEL_SRC:%=bolt-check/%) $(LIGHTNINGD_CHANNEL_HEADERS:%=bolt-check/%) - -check-whitespace: $(LIGHTNINGD_CHANNEL_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN:%=check-whitespace/%) - -clean: lightningd/channel-clean - -lightningd/channel-clean: - $(RM) $(LIGHTNINGD_CHANNEL_OBJS) - --include channeld/test/Makefile +include channeld/test/Makefile diff --git a/channeld/test/Makefile b/channeld/test/Makefile index 64e6815c7..95d95c1f2 100644 --- a/channeld/test/Makefile +++ b/channeld/test/Makefile @@ -4,8 +4,8 @@ CHANNELD_TEST_SRC := $(wildcard channeld/test/run-*.c) CHANNELD_TEST_OBJS := $(CHANNELD_TEST_SRC:.c=.o) CHANNELD_TEST_PROGRAMS := $(CHANNELD_TEST_OBJS:.o=) +ALL_C_SOURCES += $(CHANNELD_TEST_SRC) ALL_TEST_PROGRAMS += $(CHANNELD_TEST_PROGRAMS) -ALL_OBJS += $(CHANNELD_TEST_OBJS) CHANNELD_TEST_COMMON_OBJS := \ common/amount.o \ @@ -26,6 +26,6 @@ update-mocks: $(CHANNELD_TEST_SRC:%=update-mocks/%) $(CHANNELD_TEST_PROGRAMS): $(CCAN_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(CHANNELD_TEST_COMMON_OBJS) -$(CHANNELD_TEST_OBJS): $(LIGHTNINGD_CHANNEL_HEADERS) $(LIGHTNINGD_CHANNEL_SRC) +$(CHANNELD_TEST_OBJS): $(CHANNELD_HEADERS) $(CHANNELD_SRC) check-units: $(CHANNELD_TEST_PROGRAMS:%=unittest/%) diff --git a/cli/Makefile b/cli/Makefile index bd9c32a03..a032ee79b 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -1,6 +1,10 @@ LIGHTNING_CLI_SRC := cli/lightning-cli.c LIGHTNING_CLI_OBJS := $(LIGHTNING_CLI_SRC:.c=.o) +ALL_C_SOURCES += $(LIGHTNING_CLI_SRC) +ALL_C_HEADERS += +ALL_PROGRAMS += cli/lightning-cli + LIGHTNING_CLI_COMMON_OBJS := \ bitcoin/chainparams.o \ common/configdir.o \ @@ -9,23 +13,8 @@ LIGHTNING_CLI_COMMON_OBJS := \ common/utils.o \ common/version.o -lightning-cli-all: cli/lightning-cli - -$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS) $(EXTERNAL_HEADERS) - -$(LIGHTNING_CLI_OBJS) $(JSMN_OBJS): $(JSMN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) +$(LIGHTNING_CLI_OBJS): $(JSMN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) cli/lightning-cli: $(LIGHTNING_CLI_OBJS) $(LIGHTNING_CLI_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -# Make sure these depend on everything. -ALL_PROGRAMS += cli/lightning-cli -ALL_OBJS += $(LIGHTNING_CLI_OBJS) - -check-source: $(LIGHTNING_CLI_SRC:%=check-src-include-order/%) - -clean: lightning-cli-clean - -lightning-cli-clean: - $(RM) $(LIGHTNING-CLI_LIB_OBJS) $(DAEMON_JSMN_OBJS) - include cli/test/Makefile diff --git a/cli/test/Makefile b/cli/test/Makefile index eed5da394..82c451b1f 100644 --- a/cli/test/Makefile +++ b/cli/test/Makefile @@ -4,8 +4,8 @@ CLI_TEST_SRC := $(wildcard cli/test/run-*.c) CLI_TEST_OBJS := $(CLI_TEST_SRC:.c=.o) CLI_TEST_PROGRAMS := $(CLI_TEST_OBJS:.o=) +ALL_C_SOURCES += $(CLI_TEST_SRC) ALL_TEST_PROGRAMS += $(CLI_TEST_PROGRAMS) -ALL_OBJS += $(CLI_TEST_OBJS) CLI_TEST_COMMON_OBJS := \ common/configdir.o \ diff --git a/closingd/Makefile b/closingd/Makefile index ea1697d09..faa5c2c3b 100644 --- a/closingd/Makefile +++ b/closingd/Makefile @@ -1,44 +1,21 @@ #! /usr/bin/make -# Designed to be run one level up -closingd-wrongdir: - $(MAKE) -C ../.. closingd-all +CLOSINGD_HEADERS := closingd/closingd_wiregen.h -default: closingd-all +CLOSINGD_SRC := closingd/closingd.c \ + $(CLOSINGD_HEADERS:.h=.c) -closingd-all: lightningd/lightning_closingd - -# closingd needs these: -LIGHTNINGD_CLOSING_HEADERS_GEN := \ - closingd/closingd_wiregen.h - -LIGHTNINGD_CLOSING_HEADERS_NOGEN := - -LIGHTNINGD_CLOSING_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS_GEN) $(LIGHTNINGD_CLOSING_HEADERS_NOGEN) - -LIGHTNINGD_CLOSING_SRC := closingd/closingd.c \ - $(LIGHTNINGD_CLOSING_HEADERS:.h=.c) -LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) +CLOSINGD_OBJS := $(CLOSINGD_SRC:.c=.o) +$(CLOSINGD_OBJS): $(CLOSINGD_HEADERS) # Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_CLOSING_OBJS) +ALL_C_SOURCES += $(CLOSINGD_SRC) +ALL_C_HEADERS += $(CLOSINGD_HEADERS) ALL_PROGRAMS += lightningd/lightning_closingd -ALL_GEN_HEADERS += $(LIGHTNINGD_CLOSING_HEADERS_GEN) - -# Control daemon uses this: -LIGHTNINGD_CLOSING_CONTROL_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS) -LIGHTNINGD_CLOSING_CONTROL_SRC := $(LIGHTNINGD_CLOSING_HEADERS:.h=.c) -LIGHTNINGD_CLOSING_CONTROL_OBJS := $(LIGHTNINGD_CLOSING_CONTROL_SRC:.c=.o) - -LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/%wiregen.c, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC)) - -LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/%wiregen.c, $(LIGHTNINGD_CLOSING_SRC)) -# Add to headers which any object might need. -LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CLOSING_HEADERS_GEN) -LIGHTNINGD_HEADERS_NOGEN += $(LIGHTNINGD_CLOSING_HEADERS_NOGEN) - -$(LIGHTNINGD_CLOSING_OBJS): $(LIGHTNINGD_HEADERS) +# Here's what lightningd depends on +LIGHTNINGD_CONTROL_HEADERS += closingd/closingd_wiregen.h +LIGHTNINGD_CONTROL_OBJS += closingd/closingd_wiregen.o # Common source we use. CLOSINGD_COMMON_OBJS := \ @@ -84,18 +61,6 @@ CLOSINGD_COMMON_OBJS := \ common/wireaddr.o \ gossipd/gossipd_peerd_wiregen.o -LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) $(LIGHTNINGD_CLOSING_GEN_SRC:.c=.o) - -lightningd/lightning_closingd: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -check-source: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-src-include-order/%) -check-source-bolt: $(LIGHTNINGD_CLOSING_SRC:%=bolt-check/%) $(LIGHTNINGD_CLOSING_HEADERS:%=bolt-check/%) - -check-whitespace: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CLOSING_HEADERS_NOGEN:%=check-whitespace/%) - -clean: closingd-clean - -closingd-clean: - $(RM) $(LIGHTNINGD_CLOSING_OBJS) +lightningd/lightning_closingd: $(CLOSINGD_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS) -include closingd/test/Makefile diff --git a/common/Makefile b/common/Makefile index b75e89a75..19f92ad45 100644 --- a/common/Makefile +++ b/common/Makefile @@ -104,8 +104,7 @@ $(COMMON_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) $(COMMON_ # Only common/version.c can include this header. common/version.o: gen_version.h -ALL_GEN_HEADERS += $(COMMON_HEADERS_GEN) -ALL_OBJS += $(COMMON_OBJS) +ALL_C_HEADERS += $(COMMON_HEADERS) common/gen_htlc_state_names.h: common/htlc_state.h ccan/ccan/cdump/tools/cdump-enumstr ccan/ccan/cdump/tools/cdump-enumstr common/htlc_state.h > $@ diff --git a/common/test/Makefile b/common/test/Makefile index 1a33495f3..dfabba4d6 100644 --- a/common/test/Makefile +++ b/common/test/Makefile @@ -9,8 +9,8 @@ COMMON_TEST_COMMON_OBJS := \ $(COMMON_TEST_PROGRAMS): $(COMMON_TEST_COMMON_OBJS) $(BITCOIN_OBJS) $(COMMON_TEST_OBJS): $(COMMON_HEADERS) $(WIRE_HEADERS) $(COMMON_SRC) +ALL_C_SOURCES += $(COMMON_TEST_SRC) ALL_TEST_PROGRAMS += $(COMMON_TEST_PROGRAMS) -ALL_OBJS += $(COMMON_TEST_PROGRAMS:=.o) # Sphinx test wants to decode TLVs. common/test/run-sphinx: wire/onion_wiregen.o wire/towire.o wire/fromwire.o diff --git a/connectd/Makefile b/connectd/Makefile index f3b5e9f06..5b4e34327 100644 --- a/connectd/Makefile +++ b/connectd/Makefile @@ -1,18 +1,6 @@ #! /usr/bin/make -# Designed to be run one level up -connectd-wrongdir: - $(MAKE) -C .. connectd-all - -default: connectd-all - -# Control daemon uses this: -LIGHTNINGD_CONNECT_CONTROL_HEADERS := connectd/connectd_wiregen.h connectd/connectd_gossipd_wiregen.h -LIGHTNINGD_CONNECT_CONTROL_SRC := connectd/connectd_wiregen.c connectd/connectd_gossipd_wiregen.c -LIGHTNINGD_CONNECT_CONTROL_OBJS := $(LIGHTNINGD_CONNECT_CONTROL_SRC:.c=.o) - -# connectd needs these: -LIGHTNINGD_CONNECT_HEADERS := connectd/connectd_wiregen.h \ +CONNECTD_HEADERS := connectd/connectd_wiregen.h \ connectd/connectd_gossipd_wiregen.h \ connectd/connectd.h \ connectd/peer_exchange_initmsg.h \ @@ -20,20 +8,20 @@ LIGHTNINGD_CONNECT_HEADERS := connectd/connectd_wiregen.h \ connectd/netaddress.h \ connectd/tor_autoservice.h \ connectd/tor.h -LIGHTNINGD_CONNECT_SRC := $(LIGHTNINGD_CONNECT_HEADERS:.h=.c) -LIGHTNINGD_CONNECT_OBJS := $(LIGHTNINGD_CONNECT_SRC:.c=.o) + +CONNECTD_SRC := $(CONNECTD_HEADERS:.h=.c) connectd/connectd.c + +CONNECTD_OBJS := $(CONNECTD_SRC:.c=.o) +$(CONNECTD_OBJS): $(CONNECTD_HEADERS) # Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_CONNECT_OBJS) +ALL_C_SOURCES += $(CONNECTD_SRC) +ALL_C_HEADERS += $(CONNECTD_HEADERS) ALL_PROGRAMS += lightningd/lightning_connectd -ALL_GEN_HEADERS += connectd/connectd_wiregen.h connectd/connectd_gossipd_wiregen.h - -# For checking -LIGHTNINGD_CONNECT_ALLSRC_NOGEN := $(filter-out connectd/%wiregen.c, $(LIGHTNINGD_CONNECT_CLIENT_SRC) $(LIGHTNINGD_CONNECT_SRC)) -LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN := $(filter-out connectd/%wiregen.h, $(LIGHTNINGD_CONNECT_CLIENT_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS)) -# Add to headers which any object might need. -LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CONNECT_HEADERS) +# Here's what lightningd depends on +LIGHTNINGD_CONTROL_HEADERS += connectd/connectd_wiregen.h +LIGHTNINGD_CONTROL_OBJS += connectd/connectd_wiregen.o # Common source we use. CONNECTD_COMMON_OBJS := \ @@ -77,21 +65,6 @@ CONNECTD_COMMON_OBJS := \ lightningd/gossip_msg.o \ wire/onion_wiregen.o -$(LIGHTNINGD_CONNECT_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS) - -$(LIGHTNINGD_CONNECT_CONTROL_OBJS) : $(LIGHTNINGD_CONNECT_CONTROL_HEADERS) - -connectd-all: lightningd/lightning_connectd - -lightningd/lightning_connectd: $(LIGHTNINGD_CONNECT_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -check-source: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-hdr-include-order/%) -check-source-bolt: $(LIGHTNINGD_CONNECT_SRC:%=bolt-check/%) $(LIGHTNINGD_CONNECT_HEADERS:%=bolt-check/%) -check-whitespace: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-whitespace/%) - -clean: connectd-clean - -connectd-clean: - $(RM) $(LIGHTNINGD_CONNECT_OBJS) +lightningd/lightning_connectd: $(CONNECTD_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(HSMD_CLIENT_OBJS) --include connectd/test/Makefile +include connectd/test/Makefile diff --git a/connectd/test/Makefile b/connectd/test/Makefile index 765c1d7e8..1d9b2557d 100644 --- a/connectd/test/Makefile +++ b/connectd/test/Makefile @@ -1,5 +1,3 @@ -check-units: connectd-tests - # Note that these actually #include everything they need, except ccan/ and bitcoin/. # That allows for unit testing of statics, and special effects. CONNECTD_TEST_SRC := $(wildcard connectd/test/run-*.c) @@ -12,15 +10,15 @@ CONNECTD_TEST_COMMON_OBJS := \ common/type_to_string.o \ common/utils.o +ALL_C_SOURCES += $(CONNECT_TEST_SRC) +ALL_TEST_PROGRAMS += $(CONNECTD_TEST_PROGRAMS) + update-mocks: $(CONNECTD_TEST_SRC:%=update-mocks/%) $(CONNECTD_TEST_PROGRAMS): $(CONNECTD_TEST_COMMON_OBJS) $(BITCOIN_OBJS) # Test objects depend on ../ src and headers. -$(CONNECTD_TEST_OBJS): $(LIGHTNINGD_CONNECT_HEADERS) $(LIGHTNINGD_CONNECT_SRC) - -ALL_OBJS += $(CONNECTD_TEST_OBJS) -ALL_TEST_PROGRAMS += $(CONNECTD_TEST_PROGRAMS) +$(CONNECTD_TEST_OBJS): $(CONNECTD_HEADERS) $(CONNECTD_SRC) -connectd-tests: $(CONNECTD_TEST_PROGRAMS:%=unittest/%) +check-units: $(CONNECTD_TEST_PROGRAMS:%=unittest/%) diff --git a/devtools/Makefile b/devtools/Makefile index b62044dfe..ade001e35 100644 --- a/devtools/Makefile +++ b/devtools/Makefile @@ -6,10 +6,13 @@ ifeq ($(EXPERIMENTAL_FEATURES),1) DEVTOOLS += devtools/blindedpath endif -DEVTOOLS_TOOL_SRC := $(DEVTOOLS:=.c) -DEVTOOLS_TOOL_OBJS := $(DEVTOOLS_TOOL_SRC:.c=.o) devtools/clean_topo.o +DEVTOOLS_TOOL_SRC := $(DEVTOOLS:=.c) devtools/print_wire.c devtools/clean_topo.c +DEVTOOLS_TOOL_OBJS := $(DEVTOOLS_TOOL_SRC:.c=.o) -DEVTOOLS_BOLT_DEPS += $(BOLT_DEPS) tools/gen/print_impl_template tools/gen/print_header_template +# Make sure these depend on everything. +ALL_C_SOURCES += $(DEVTOOLS_TOOL_SRC) +ALL_C_HEADERS += +ALL_PROGRAMS += $(DEVTOOLS) DEVTOOLS_COMMON_OBJS := \ common/amount.o \ @@ -41,11 +44,9 @@ DEVTOOLS_COMMON_OBJS := \ wire/onion_wiregen.o \ wire/peer_wiregen.o -devtools-all: $(DEVTOOLS) - devtools/bolt11-cli: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o -devtools/decodemsg: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer_printgen.o wire/onion_printgen.o devtools/print_wire.o devtools/decodemsg.o +devtools/decodemsg: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) $(WIRE_PRINT_OBJS) wire/fromwire.o wire/towire.o devtools/print_wire.o devtools/decodemsg.o devtools/dump-gossipstore: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/dump-gossipstore.o gossipd/gossip_store_wiregen.o @@ -83,14 +84,3 @@ devtools/lightning-checkmessage: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_ devtools/route: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/tlvstream.o common/gossmap.o common/random_select.o common/route.o common/dijkstra.o devtools/clean_topo.o devtools/route.o devtools/topology: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/tlvstream.o common/gossmap.o common/random_select.o common/dijkstra.o common/route.o devtools/clean_topo.o devtools/topology.o - -# Make sure these depend on everything. -ALL_PROGRAMS += $(DEVTOOLS) -ALL_OBJS += $(DEVTOOLS_TOOL_OBJS) - -check-source: $(DEVTOOLS_SRC:%=check-src-include-order/%) $(DEVTOOLS_TOOLS_SRC:%=check-src-include-order/%) - -clean: devtools-clean - -devtools-clean: - $(RM) $(DEVTOOLS_TOOL_OBJS) $(DEVTOOLS) diff --git a/gossipd/Makefile b/gossipd/Makefile index 96d8a66d3..72c97eb7f 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -1,18 +1,6 @@ #! /usr/bin/make -# Designed to be run one level up -gossipd-wrongdir: - $(MAKE) -C .. gossipd-all - -default: gossipd-all - -# lightningd uses this: -LIGHTNINGD_GOSSIP_CONTROL_HEADERS := gossipd/gossipd_wiregen.h -LIGHTNINGD_GOSSIP_CONTROL_SRC := gossipd/gossipd_wiregen.c -LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o) - -# gossipd needs these: -LIGHTNINGD_GOSSIP_HEADERS_WSRC := gossipd/gossipd_wiregen.h \ +GOSSIPD_HEADERS_WSRC := gossipd/gossipd_wiregen.h \ gossipd/gossipd_peerd_wiregen.h \ gossipd/gossip_store_wiregen.h \ gossipd/gossipd.h \ @@ -21,21 +9,20 @@ LIGHTNINGD_GOSSIP_HEADERS_WSRC := gossipd/gossipd_wiregen.h \ gossipd/gossip_generation.h \ gossipd/routing.h \ gossipd/seeker.h -LIGHTNINGD_GOSSIP_HEADERS := $(LIGHTNINGD_GOSSIP_HEADERS_WSRC) gossipd/broadcast.h -LIGHTNINGD_GOSSIP_SRC := $(LIGHTNINGD_GOSSIP_HEADERS_WSRC:.h=.c) -LIGHTNINGD_GOSSIP_OBJS := $(LIGHTNINGD_GOSSIP_SRC:.c=.o) +GOSSIPD_HEADERS := $(GOSSIPD_HEADERS_WSRC) gossipd/broadcast.h + +GOSSIPD_SRC := $(GOSSIPD_HEADERS_WSRC:.h=.c) +GOSSIPD_OBJS := $(GOSSIPD_SRC:.c=.o) +$(GOSSIPD_OBJS): $(GOSSIPD_HEADERS) # Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_GOSSIP_OBJS) +ALL_C_SOURCES += $(GOSSIPD_SRC) +ALL_C_HEADERS += $(GOSSIPD_HEADERS) ALL_PROGRAMS += lightningd/lightning_gossipd -ALL_GEN_HEADERS += $(wildcard gossipd/*wiregen.h) - -# For checking -LIGHTNINGD_GOSSIP_ALLSRC_NOGEN := $(filter-out gossipd/%wiregen.c, $(LIGHTNINGD_GOSSIP_CLIENT_SRC) $(LIGHTNINGD_GOSSIP_SRC)) -LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN := $(filter-out gossipd/%wiregen.h, $(LIGHTNINGD_GOSSIP_CLIENT_HEADERS) $(LIGHTNINGD_GOSSIP_HEADERS)) -# Add to headers which any object might need. -LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_GOSSIP_HEADERS) +# Here's what lightningd depends on +LIGHTNINGD_CONTROL_HEADERS += gossipd/gossipd_wiregen.h +LIGHTNINGD_CONTROL_OBJS += gossipd/gossipd_wiregen.o # Common source we use. GOSSIPD_COMMON_OBJS := \ @@ -81,21 +68,6 @@ GOSSIPD_COMMON_OBJS := \ lightningd/gossip_msg.o \ wire/onion_wiregen.o -$(LIGHTNINGD_GOSSIP_OBJS) $(LIGHTNINGD_GOSSIP_CLIENT_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_GOSSIP_HEADERS) - -$(LIGHTNINGD_GOSSIP_CONTROL_OBJS) : $(LIGHTNINGD_GOSSIP_CONTROL_HEADERS) - -gossipd-all: lightningd/lightning_gossipd $(LIGHTNINGD_GOSSIP_CLIENT_OBJS) - -lightningd/lightning_gossipd: $(LIGHTNINGD_GOSSIP_OBJS) $(GOSSIPD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -check-source: $(LIGHTNINGD_GOSSIP_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN:%=check-hdr-include-order/%) -check-source-bolt: $(LIGHTNINGD_GOSSIP_SRC:%=bolt-check/%) $(LIGHTNINGD_GOSSIP_HEADERS:%=bolt-check/%) -check-whitespace: $(LIGHTNINGD_GOSSIP_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN:%=check-whitespace/%) - -clean: gossipd-clean - -gossipd-clean: - $(RM) $(LIGHTNINGD_GOSSIP_OBJS) +lightningd/lightning_gossipd: $(GOSSIPD_OBJS) $(GOSSIPD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(HSMD_CLIENT_OBJS) --include gossipd/test/Makefile +include gossipd/test/Makefile diff --git a/gossipd/test/Makefile b/gossipd/test/Makefile index 3396c415a..24d22f2ca 100644 --- a/gossipd/test/Makefile +++ b/gossipd/test/Makefile @@ -21,15 +21,15 @@ GOSSIPD_TEST_COMMON_OBJS := \ wire/fromwire.o \ wire/towire.o +ALL_C_SOURCES += $(GOSSIPD_TEST_SRC) +ALL_TEST_PROGRAMS += $(GOSSIPD_TEST_PROGRAMS) + update-mocks: $(GOSSIPD_TEST_SRC:%=update-mocks/%) $(GOSSIPD_TEST_PROGRAMS): $(GOSSIPD_TEST_COMMON_OBJS) $(BITCOIN_OBJS) # Test objects depend on ../ src and headers. -$(GOSSIPD_TEST_OBJS): $(LIGHTNINGD_GOSSIP_HEADERS) $(LIGHTNINGD_GOSSIP_SRC) - -ALL_OBJS += $(GOSSIPD_TEST_OBJS) -ALL_TEST_PROGRAMS += $(GOSSIPD_TEST_PROGRAMS) +$(GOSSIPD_TEST_OBJS): $(GOSSIPD_HEADERS) $(GOSSIPD_SRC) gossipd-tests: $(GOSSIPD_TEST_PROGRAMS:%=unittest/%) diff --git a/hsmd/Makefile b/hsmd/Makefile index 9e020aafa..2b5c0b291 100644 --- a/hsmd/Makefile +++ b/hsmd/Makefile @@ -1,15 +1,19 @@ #! /usr/bin/make -# Designed to be run one level up -hsmd-wrongdir: - $(MAKE) -C .. lightningd/hsm-all +HSMD_SRC := hsmd/hsmd.c \ + hsmd/hsmd_wiregen.c +HSMD_HEADERS := hsmd/hsmd_wiregen.h +HSMD_OBJS := $(HSMD_SRC:.c=.o) -default: hsmd-all +$(HSMD_OBJS): $(HSMD_HEADERS) -LIGHTNINGD_HSM_SRC := hsmd/hsmd.c \ - hsmd/hsmd_wiregen.c -LIGHTNINGD_HSM_HEADERS := hsmd/hsmd_wiregen.h -LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o) +# Other programs which use the hsm need this. +HSMD_CLIENT_OBJS := hsmd/hsmd_wiregen.o + +# Make sure these depend on everything. +ALL_C_SOURCES += $(HSMD_SRC) +ALL_C_HEADERS += $(HSMD_HEADERS) +ALL_PROGRAMS += lightningd/lightning_hsmd # Common source we use. HSMD_COMMON_OBJS := \ @@ -38,31 +42,7 @@ HSMD_COMMON_OBJS := \ common/version.o \ common/withdraw_tx.o -LIGHTNINGD_HSM_CLIENT_OBJS := hsmd/hsmd_wiregen.o - -# For checking -LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/%wiregen.c, $(LIGHTNINGD_HSM_SRC) $(LIGHTNINGD_HSM_SRC)) -LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/%wiregen.h, $(LIGHTNINGD_HSM_HEADERS)) - -$(LIGHTNINGD_HSM_OBJS): $(LIGHTNINGD_HEADERS) - -# Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_HSM_OBJS) -ALL_PROGRAMS += lightningd/lightning_hsmd -ALL_GEN_HEADERS += hsmd/hsmd_wiregen.h - -hsmd-all: lightningd/lightning_hsmd - -lightningd/lightning_hsmd: $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_LIB_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) - -check-source: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-hdr-include-order/%) -check-source-bolt: $(LIGHTNINGD_HSM_SRC:%=bolt-check/%) - -check-whitespace: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-whitespace/%) - -clean: lightningd/hsm-clean -lightningd/hsm-clean: - $(RM) $(LIGHTNINGD_HSM_OBJS) +lightningd/lightning_hsmd: $(HSMD_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) -include hsmd/test/Makefile diff --git a/lightningd/Makefile b/lightningd/Makefile index 644e34899..b3190950a 100644 --- a/lightningd/Makefile +++ b/lightningd/Makefile @@ -1,16 +1,56 @@ #! /usr/bin/make -# Designed to be run one level up -lightningd-wrongdir: - $(MAKE) -C .. lightningd-all +LIGHTNINGD_SRC := \ + lightningd/bitcoind.c \ + lightningd/chaintopology.c \ + lightningd/channel.c \ + lightningd/channel_control.c \ + lightningd/closing_control.c \ + lightningd/coin_mvts.c \ + lightningd/connect_control.c \ + lightningd/onion_message.c \ + lightningd/gossip_control.c \ + lightningd/gossip_msg.c \ + lightningd/hsm_control.c \ + lightningd/htlc_end.c \ + lightningd/htlc_set.c \ + lightningd/invoice.c \ + lightningd/io_loop_with_timers.c \ + lightningd/json.c \ + lightningd/jsonrpc.c \ + lightningd/lightningd.c \ + lightningd/log.c \ + lightningd/log_status.c \ + lightningd/memdump.c \ + lightningd/notification.c \ + lightningd/onchain_control.c \ + lightningd/opening_control.c \ + lightningd/options.c \ + lightningd/pay.c \ + lightningd/peer_control.c \ + lightningd/peer_htlcs.c \ + lightningd/ping.c \ + lightningd/plugin.c \ + lightningd/plugin_control.c \ + lightningd/plugin_hook.c \ + lightningd/subd.c \ + lightningd/watch.c -LIGHTNINGD_PROGRAM := lightningd/lightningd +LIGHTNINGD_SRC_NOHDR := \ + lightningd/signmessage.c -ALL_PROGRAMS += $(LIGHTNINGD_PROGRAM) +LIGHTNINGD_HEADERS := \ + $(LIGHTNINGD_SRC:.c=.h) \ + lightningd/channel_state.h \ + lightningd/gen_channel_state_names.h -lightningd-all: $(LIGHTNINGD_PROGRAM) +LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o) $(LIGHTNINGD_SRC_NOHDR:.c=.o) +$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CONTROL_HEADERS) -default: lightningd-all +# Make sure these depend on everything. +ALL_C_SOURCES += $(LIGHTNINGD_SRC) +ALL_C_HEADERS += $(LIGHTNINGD_HEADERS) +ALL_PROGRAMS += lightningd/lightningd # Common source we use. LIGHTNINGD_COMMON_OBJS := \ @@ -75,89 +115,19 @@ LIGHTNINGD_COMMON_OBJS := \ common/wireaddr.o \ common/withdraw_tx.o -LIGHTNINGD_SRC := \ - lightningd/bitcoind.c \ - lightningd/chaintopology.c \ - lightningd/channel.c \ - lightningd/channel_control.c \ - lightningd/closing_control.c \ - lightningd/coin_mvts.c \ - lightningd/connect_control.c \ - lightningd/onion_message.c \ - lightningd/gossip_control.c \ - lightningd/gossip_msg.c \ - lightningd/hsm_control.c \ - lightningd/htlc_end.c \ - lightningd/htlc_set.c \ - lightningd/invoice.c \ - lightningd/io_loop_with_timers.c \ - lightningd/json.c \ - lightningd/jsonrpc.c \ - lightningd/lightningd.c \ - lightningd/log.c \ - lightningd/log_status.c \ - lightningd/memdump.c \ - lightningd/notification.c \ - lightningd/onchain_control.c \ - lightningd/opening_control.c \ - lightningd/options.c \ - lightningd/pay.c \ - lightningd/peer_control.c \ - lightningd/peer_htlcs.c \ - lightningd/ping.c \ - lightningd/plugin.c \ - lightningd/plugin_control.c \ - lightningd/plugin_hook.c \ - lightningd/subd.c \ - lightningd/watch.c - -LIGHTNINGD_SRC_NOHDR := \ - lightningd/signmessage.c - -LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o) $(LIGHTNINGD_SRC_NOHDR:.c=.o) - -# Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_OBJS) - -# We accumulate all lightningd/ headers in these three: -LIGHTNINGD_HEADERS_NOGEN = \ - $(LIGHTNINGD_SRC:.c=.h) \ - lightningd/channel_state.h - -# Generated headers -LIGHTNINGD_HEADERS_GEN = \ - lightningd/gen_channel_state_names.h - -ALL_GEN_HEADERS += $(LIGHTNINGD_HEADERS_GEN) - include wallet/Makefile # All together in one convenient var LIGHTNINGD_HEADERS = $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) $(WALLET_LIB_HEADERS) -$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HEADERS) +$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HEADERS) $(WALLET_HDRS) # Only the plugin component needs to depend on this header. -lightningd/plugin.o : gen_list_of_builtin_plugins.h +lightningd/plugin.o: gen_list_of_builtin_plugins.h lightningd/gen_channel_state_names.h: lightningd/channel_state.h ccan/ccan/cdump/tools/cdump-enumstr ccan/ccan/cdump/tools/cdump-enumstr lightningd/channel_state.h > $@ -check-source: $(LIGHTNINGD_SRC:%=check-src-include-order/%) $(LIGHTNINGD_SRC_NOHDR:%=check-src-include-order/%) -check-source: $(LIGHTNINGD_HEADERS_NOGEN:%=check-hdr-include-order/%) -check-source-bolt: $(LIGHTNINGD_SRC:%=bolt-check/%) $(LIGHTNINGD_SRC_NOHDR:%=bolt-check/%) $(LIGHTNINGD_HEADERS_NOGEN:%=bolt-check/%) - -check-whitespace: $(LIGHTNINGD_SRC:%=check-whitespace/%) $(LIGHTNINGD_SRC_NOHDR:%=check-whitespace/%) $(LIGHTNINGD_HEADERS_NOGEN:%=check-whitespace/%) - -check-makefile: check-lightningd-makefile -check-lightningd-makefile: - @for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done - -lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) $(LIGHTNINGD_CONNECT_CONTROL_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -clean: lightningd-clean - -lightningd-clean: - $(RM) $(LIGHTNINGD_OBJS) $(LIGHTNINGD_JSMN_OBJS) $(LIGHTNINGD_PROGRAM) lightningd/gen* +lightningd/lightningd: $(LIGHTNINGD_OBJS) $(WALLET_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_CONTROL_OBJS) $(HSMD_CLIENT_OBJS) include lightningd/test/Makefile diff --git a/lightningd/test/Makefile b/lightningd/test/Makefile index 03fbd90e6..d43a2a483 100644 --- a/lightningd/test/Makefile +++ b/lightningd/test/Makefile @@ -4,8 +4,8 @@ LIGHTNINGD_TEST_SRC := $(wildcard lightningd/test/run-*.c) LIGHTNINGD_TEST_OBJS := $(LIGHTNINGD_TEST_SRC:.c=.o) LIGHTNINGD_TEST_PROGRAMS := $(LIGHTNINGD_TEST_OBJS:.o=) +ALL_C_SOURCES += $(LIGHTNINGD_TEST_SRC) ALL_TEST_PROGRAMS += $(LIGHTNINGD_TEST_PROGRAMS) -ALL_OBJS += $(LIGHTNINGD_TEST_OBJS) LIGHTNINGD_TEST_COMMON_OBJS := \ common/amount.o \ @@ -28,6 +28,6 @@ update-mocks: $(LIGHTNINGD_TEST_SRC:%=update-mocks/%) $(LIGHTNINGD_TEST_PROGRAMS): $(CCAN_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(LIGHTNINGD_TEST_COMMON_OBJS) -$(LIGHTNINGD_TEST_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_SRC) +$(LIGHTNINGD_TEST_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_SRC) $(LIGHTNINGD_SRC_NOHDR) check-units: $(LIGHTNINGD_TEST_PROGRAMS:%=unittest/%) diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 4023fe3c9..b0dc9ab1c 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -505,9 +505,6 @@ void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) /* Generated stub for towire_onchaind_dev_memleak */ u8 *towire_onchaind_dev_memleak(const tal_t *ctx UNNEEDED) { fprintf(stderr, "towire_onchaind_dev_memleak called!\n"); abort(); } -/* Generated stub for towire_temporary_node_failure */ -u8 *towire_temporary_node_failure(const tal_t *ctx UNNEEDED) -{ fprintf(stderr, "towire_temporary_node_failure called!\n"); abort(); } /* Generated stub for txfilter_add_scriptpubkey */ void txfilter_add_scriptpubkey(struct txfilter *filter UNNEEDED, const u8 *script TAKES UNNEEDED) { fprintf(stderr, "txfilter_add_scriptpubkey called!\n"); abort(); } diff --git a/onchaind/Makefile b/onchaind/Makefile index 350ed0a4a..1a9152dde 100644 --- a/onchaind/Makefile +++ b/onchaind/Makefile @@ -1,49 +1,34 @@ #! /usr/bin/make -# Designed to be run one level up -onchaind-wrongdir: - $(MAKE) -C ../.. onchaind-all - -default: onchaind-all - -onchaind-all: lightningd/lightning_onchaind - -onchaind/gen_onchain_types_names.h: onchaind/onchain_types.h ccan/ccan/cdump/tools/cdump-enumstr - ccan/ccan/cdump/tools/cdump-enumstr onchaind/onchain_types.h > $@ - -# onchaind needs these: -LIGHTNINGD_ONCHAIN_HEADERS_GEN := \ +ONCHAIND_HEADERS := \ onchaind/onchaind_wiregen.h \ - onchaind/gen_onchain_types_names.h - -LIGHTNINGD_ONCHAIN_HEADERS_NOGEN := \ + onchaind/gen_onchain_types_names.h \ onchaind/onchain_types.h \ onchaind/onchaind_wire.h -LIGHTNINGD_ONCHAIN_HEADERS := $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) $(LIGHTNINGD_ONCHAIN_HEADERS_NOGEN) +ONCHAIND_SRC := onchaind/onchaind.c \ + onchaind/onchaind_wiregen.c \ + onchaind/onchaind_wire.c \ + onchaind/onchaind.c -LIGHTNINGD_ONCHAIN_SRC := onchaind/onchaind.c \ - onchaind/onchaind_wiregen.c \ - onchaind/onchaind_wire.c - -LIGHTNINGD_ONCHAIN_OBJS := $(LIGHTNINGD_ONCHAIN_SRC:.c=.o) - -# Control daemon uses this: -LIGHTNINGD_ONCHAIN_CONTROL_HEADERS := \ - onchaind/onchaind_wiregen.h \ - onchaind/onchaind_wire.h -LIGHTNINGD_ONCHAIN_CONTROL_SRC := $(LIGHTNINGD_ONCHAIN_CONTROL_HEADERS:.h=.c) -LIGHTNINGD_ONCHAIN_CONTROL_OBJS := $(LIGHTNINGD_ONCHAIN_CONTROL_SRC:.c=.o) - -LIGHTNINGD_ONCHAIN_GEN_SRC := $(filter onchaind/%wiregen.c, $(LIGHTNINGD_ONCHAIN_SRC) $(LIGHTNINGD_ONCHAIN_CONTROL_SRC)) +onchaind/gen_onchain_types_names.h: onchaind/onchain_types.h ccan/ccan/cdump/tools/cdump-enumstr + ccan/ccan/cdump/tools/cdump-enumstr onchaind/onchain_types.h > $@ -LIGHTNINGD_ONCHAIN_SRC_NOGEN := $(filter-out onchaind/%wiregen.c, $(LIGHTNINGD_ONCHAIN_SRC)) +ONCHAIND_OBJS := $(ONCHAIND_SRC:.c=.o) +$(ONCHAIND_OBJS): $(ONCHAIND_HEADERS) -# Add to headers which any object might need. -LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) -LIGHTNINGD_HEADERS_NOGEN += $(LIGHTNINGD_ONCHAIN_HEADERS_NOGEN) +# Make sure these depend on everything. +ALL_C_SOURCES += $(ONCHAIND_SRC) +ALL_C_HEADERS += $(ONCHAIND_HEADERS) +ALL_PROGRAMS += lightningd/lightning_onchaind -$(LIGHTNINGD_ONCHAIN_OBJS): $(LIGHTNINGD_HEADERS) +# Here's what lightningd depends on +LIGHTNINGD_CONTROL_HEADERS += \ + onchaind/onchaind_wiregen.h \ + onchaind/onchaind_wire.h +LIGHTNINGD_CONTROL_OBJS += \ + onchaind/onchaind_wiregen.o \ + onchaind/onchaind_wire.o # Common source we use. ONCHAIND_COMMON_OBJS := \ @@ -78,23 +63,6 @@ ONCHAIND_COMMON_OBJS := \ common/version.o \ common/wallet.o -LIGHTNINGD_ONCHAIN_OBJS := $(LIGHTNINGD_ONCHAIN_SRC:.c=.o) $(LIGHTNINGD_ONCHAIN_GEN_SRC:.c=.o) - -# Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_ONCHAIN_OBJS) -ALL_PROGRAMS += lightningd/lightning_onchaind -ALL_GEN_HEADERS += $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) - -lightningd/lightning_onchaind: $(LIGHTNINGD_ONCHAIN_OBJS) $(WIRE_ONION_OBJS) $(ONCHAIND_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -check-source: $(LIGHTNINGD_ONCHAIN_SRC_NOGEN:%=check-src-include-order/%) -check-source-bolt: $(LIGHTNINGD_ONCHAIN_SRC:%=bolt-check/%) $(LIGHTNINGD_ONCHAIN_HEADERS:%=bolt-check/%) - -check-whitespace: $(LIGHTNINGD_ONCHAIN_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_ONCHAIN_HEADERS_NOGEN:%=check-whitespace/%) - -clean: onchaind-clean - -onchaind-clean: - $(RM) $(LIGHTNINGD_ONCHAIN_OBJS) +lightningd/lightning_onchaind: $(ONCHAIND_OBJS) $(WIRE_ONION_OBJS) $(ONCHAIND_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS) --include onchaind/test/Makefile +include onchaind/test/Makefile diff --git a/onchaind/test/Makefile b/onchaind/test/Makefile index ac7e5ae8d..4405874bb 100644 --- a/onchaind/test/Makefile +++ b/onchaind/test/Makefile @@ -6,6 +6,9 @@ ONCHAIND_TEST_SRC := $(wildcard onchaind/test/run-*.c) ONCHAIND_TEST_OBJS := $(ONCHAIND_TEST_SRC:.c=.o) ONCHAIND_TEST_PROGRAMS := $(ONCHAIND_TEST_OBJS:.o=) +ALL_C_SOURCES += $(ONCHAIND_TEST_SRC) +ALL_TEST_PROGRAMS += $(ONCHAIND_TEST_PROGRAMS) + ONCHAIND_TEST_COMMON_OBJS := \ common/amount.o \ common/features.o \ @@ -19,10 +22,7 @@ update-mocks: $(ONCHAIND_TEST_SRC:%=update-mocks/%) $(ONCHAIND_TEST_PROGRAMS): $(ONCHAIND_TEST_COMMON_OBJS) $(BITCOIN_OBJS) # Test objects depend on ../ src and headers. -$(ONCHAIND_TEST_OBJS): $(LIGHTNINGD_ONCHAIN_HEADERS) $(LIGHTNINGD_ONCHAIN_SRC) - -ALL_OBJS += $(ONCHAIND_TEST_OBJS) -ALL_TEST_PROGRAMS += $(ONCHAIND_TEST_PROGRAMS) +$(ONCHAIND_TEST_OBJS): $(ONCHAIND_HEADERS) $(ONCHAIND_SRC) onchaind-tests: $(ONCHAIND_TEST_PROGRAMS:%=unittest/%) diff --git a/openingd/Makefile b/openingd/Makefile index 6ee91d50a..585408d60 100644 --- a/openingd/Makefile +++ b/openingd/Makefile @@ -1,37 +1,21 @@ #! /usr/bin/make -# Designed to be run one level up -opening-wrongdir: - $(MAKE) -C ../.. opening-all +OPENINGD_HEADERS := openingd/openingd_wiregen.h -default: opening-all +OPENINGD_SRC := openingd/openingd.c \ + $(OPENINGD_HEADERS:.h=.c) -opening-all: lightningd/lightning_openingd +OPENINGD_OBJS := $(OPENINGD_SRC:.c=.o) +$(OPENINGD_OBJS): $(OPENINGD_HEADERS) -# opening needs these: -LIGHTNINGD_OPENING_HEADERS_GEN := \ - openingd/openingd_wiregen.h - -LIGHTNINGD_OPENING_HEADERS_NOGEN := - -LIGHTNINGD_OPENING_HEADERS := $(LIGHTNINGD_OPENING_HEADERS_GEN) $(LIGHTNINGD_OPENING_HEADERS_NOGEN) - -LIGHTNINGD_OPENING_SRC := openingd/openingd.c \ - $(LIGHTNINGD_OPENING_HEADERS:.h=.c) -LIGHTNINGD_OPENING_OBJS := $(LIGHTNINGD_OPENING_SRC:.c=.o) - -# Control daemon uses this: -LIGHTNINGD_OPENING_CONTROL_HEADERS := $(LIGHTNINGD_OPENING_HEADERS) -LIGHTNINGD_OPENING_CONTROL_SRC := $(LIGHTNINGD_OPENING_HEADERS:.h=.c) -LIGHTNINGD_OPENING_CONTROL_OBJS := $(LIGHTNINGD_OPENING_CONTROL_SRC:.c=.o) - -LIGHTNINGD_OPENING_GEN_SRC := $(filter openingd/%wiregen.c, $(LIGHTNINGD_OPENING_SRC) $(LIGHTNINGD_OPENING_CONTROL_SRC)) - -LIGHTNINGD_OPENING_SRC_NOGEN := $(filter-out openingd/%wiregen.c, $(LIGHTNINGD_OPENING_SRC)) +# Make sure these depend on everything. +ALL_C_SOURCES += $(OPENINGD_SRC) +ALL_C_HEADERS += $(OPENINGD_HEADERS) +ALL_PROGRAMS += lightningd/lightning_openingd -# Add to headers which any object might need. -LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_OPENING_HEADERS_GEN) -LIGHTNINGD_HEADERS_NOGEN += $(LIGHTNINGD_OPENING_HEADERS_NOGEN) +# Here's what lightningd depends on +LIGHTNINGD_CONTROL_HEADERS += openingd/openingd_wiregen.h +LIGHTNINGD_CONTROL_OBJS += openingd/openingd_wiregen.o # Common source we use. OPENINGD_COMMON_OBJS := \ @@ -85,25 +69,6 @@ OPENINGD_COMMON_OBJS := \ gossipd/gossipd_peerd_wiregen.o \ lightningd/gossip_msg.o -$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS) - -LIGHTNINGD_OPENING_OBJS := $(LIGHTNINGD_OPENING_SRC:.c=.o) $(LIGHTNINGD_OPENING_GEN_SRC:.c=.o) - -# Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_OPENING_OBJS) -ALL_PROGRAMS += lightningd/lightning_openingd -ALL_GEN_HEADERS += $(LIGHTNINGD_OPENING_HEADERS_GEN) - -lightningd/lightning_openingd: $(LIGHTNINGD_OPENING_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) - -check-source: $(LIGHTNINGD_OPENING_SRC_NOGEN:%=check-src-include-order/%) -check-source-bolt: $(LIGHTNINGD_OPENING_SRC:%=bolt-check/%) $(LIGHTNINGD_OPENING_HEADERS:%=bolt-check/%) - -check-whitespace: $(LIGHTNINGD_OPENING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_OPENING_HEADERS_NOGEN:%=check-whitespace/%) - -clean: opening-clean - -opening-clean: - $(RM) $(LIGHTNINGD_OPENING_OBJS) +lightningd/lightning_openingd: $(OPENINGD_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS) -include openingd/test/Makefile diff --git a/plugins/Makefile b/plugins/Makefile index 3a2c1510a..27160ef77 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -41,6 +41,11 @@ PLUGINS := \ plugins/keysend \ plugins/pay +# Make sure these depend on everything. +ALL_C_SOURCES += $(PLUGIN_ALL_SRC) +ALL_C_HEADERS += +ALL_PROGRAMS += $(PLUGINS) + PLUGIN_COMMON_OBJS := \ bitcoin/base58.o \ bitcoin/feerate.o \ @@ -94,19 +99,3 @@ plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion_wiregen.o $(P $(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) $(PLUGIN_ALL_OBJS): $(PLUGIN_LIB_HEADER) - -# Make sure these depend on everything. -ALL_PROGRAMS += $(PLUGINS) -ALL_OBJS += $(PLUGIN_ALL_OBJS) - -check-source: $(PLUGIN_ALL_SRC:%=check-src-include-order/%) -check-source: $(PLUGIN_ALL_HEADER:%=check-hdr-include-order/%) -check-source-bolt: $(PLUGIN_ALL_SRC:%=bolt-check/%) -check-source-bolt: $(PLUGIN_ALL_HEADER:%=bolt-check/%) -check-whitespace: $(PLUGIN_ALL_SRC:%=check-whitespace/%) -check-whitespace: $(PLUGIN_ALL_HEADER:%=check-whitespace/%) - -clean: plugin-clean - -plugin-clean: - $(RM) $(PLUGIN_ALL_OBJS) diff --git a/tests/plugins/Makefile b/tests/plugins/Makefile index 0b0eee0b4..daf35de32 100644 --- a/tests/plugins/Makefile +++ b/tests/plugins/Makefile @@ -6,13 +6,5 @@ tests/plugins/test_libplugin: bitcoin/chainparams.o $(PLUGIN_TESTLIBPLUGIN_OBJS) $(PLUGIN_TESTLIBPLUGIN_OBJS): $(PLUGIN_LIB_HEADER) # Make sure these depend on everything. -ALL_PROGRAMS += tests/plugins/test_libplugin -ALL_OBJS += $(PLUGIN_TESTLIBPLUGIN_OBJS) - -check-source: $(PLUGIN_TESTLIBPLUGIN_SRC:%=check-src-include-order/%) -check-whitespace: $(PLUGIN_TESTLIBPLUGIN_SRC:%=check-whitespace/%) - -clean: test-plugin-clean - -test-plugin-clean: - $(RM) $(PLUGIN_TESTLIBPLUGIN_OBJS) +ALL_TEST_PROGRAMS += tests/plugins/test_libplugin +ALL_C_SOURCES += $(PLUGIN_TESTLIBPLUGIN_SRC) diff --git a/tools/Makefile b/tools/Makefile index 917fb5c22..09bf5d30d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -2,8 +2,11 @@ TOOLS := tools/hsmtool tools/check-bolt TOOLS_SRC := $(TOOLS:=.c) TOOLS_OBJ := $(TOOLS_SRC:.c=.o) + +# Make sure these depend on everything. +ALL_C_SOURCES += $(TOOLS_SRC) +ALL_C_HEADERS += ALL_PROGRAMS += $(TOOLS) -ALL_OBJS += $(TOOLS_OBJ) TOOLS_COMMON_OBJS = common/utils.o @@ -22,8 +25,6 @@ tools/lightning-hsmtool: tools/hsmtool clean: tools-clean tools-clean: - $(RM) tools/check-bolt tools/*.o $(RM) tools/headerversions - $(RM) $(TOOLS_OBJ) $(TOOLS) tools/lightning-hsmtool include tools/test/Makefile diff --git a/wallet/Makefile b/wallet/Makefile index 0930596b6..70875740c 100644 --- a/wallet/Makefile +++ b/wallet/Makefile @@ -18,20 +18,15 @@ WALLET_DB_DRIVERS := \ wallet/db_postgres.c \ wallet/db_sqlite3.c -WALLET_LIB_OBJS := $(WALLET_LIB_SRC:.c=.o) $(WALLET_LIB_SRC_NOHDR:.c=.o) $(WALLET_DB_DRIVERS:.c=.o) -WALLET_LIB_HEADERS := $(WALLET_LIB_SRC:.c=.h) +WALLET_SRC := $(WALLET_LIB_SRC) $(WALLET_LIB_SRC_NOHDR) $(WALLET_DB_DRIVERS) +WALLET_HDRS := $(WALLET_LIB_SRC:.c=.h) -# Make sure these depend on everything. -ALL_OBJS += $(WALLET_LIB_OBJS) - -$(WALLET_LIB_OBJS): $(LIGHTNINGD_HEADERS_NOGEN) $(WALLET_LIB_HEADERS) +WALLET_OBJS := $(WALLET_SRC:.c=.o) +$(WALLET_OBJS): $(WALLET_HDRS) $(LIGHTNINGD_HEADERS) -check-whitespace: $(WALLET_LIB_SRC:%=check-whitespace/%) $(WALLET_LIB_HEADERS:%=check-whitespace/%) -check-source: $(WALLET_LIB_SRC:%=check-src-include-order/%) -check-source: $(WALLET_LIB_HEADERS:%=check-hdr-include-order/%) -check-source-bolt: $(WALLET_LIB_SRC:%=bolt-check/%) $(WALLET_LIB_HEADERS:%=bolt-check/%) - -clean: wallet-clean +# Make sure these depend on everything. +ALL_C_SOURCES += $(WALLET_SRC) +ALL_C_HEADERS += $(WALLET_HDRS) # Each database driver depends on its rewritten statements. wallet/db_sqlite3.o: wallet/gen_db_sqlite3.c @@ -51,8 +46,8 @@ wallet/statements.po: $(SQL_FILES) wallet/gen_db_%.c: wallet/statements.po devtools/sql-rewrite.py devtools/sql-rewrite.py wallet/statements.po $* > wallet/gen_db_$*.c +clean: wallet_clean wallet-clean: - $(RM) $(WALLET_LIB_OBJS) $(RM) wallet/statements.po $(RM) wallet/gen_db_sqlite3.c $(RM) wallet/gen_db_postgres.c diff --git a/wallet/test/Makefile b/wallet/test/Makefile index f57ae8f70..79fd890e6 100644 --- a/wallet/test/Makefile +++ b/wallet/test/Makefile @@ -2,6 +2,9 @@ WALLET_TEST_SRC := $(wildcard wallet/test/run-*.c) WALLET_TEST_OBJS := $(WALLET_TEST_SRC:.c=.o) WALLET_TEST_PROGRAMS := $(WALLET_TEST_OBJS:.o=) +ALL_C_SOURCES += $(WALLET_TEST_SRC) +ALL_TEST_PROGRAMS += $(WALLET_TEST_PROGRAMS) + WALLET_TEST_COMMON_OBJS := \ common/amount.o \ common/base32.o \ @@ -24,18 +27,11 @@ WALLET_TEST_COMMON_OBJS := \ wire/towire.o \ wire/fromwire.o -# Make sure these depend on everything. -ALL_TEST_PROGRAMS += $(WALLET_TEST_PROGRAMS) -ALL_OBJS += $(WALLET_LIB_OBJS) $(WALLET_TEST_OBJS) - $(WALLET_TEST_PROGRAMS): $(BITCOIN_OBJS) $(WALLET_TEST_COMMON_OBJS) -$(WALLET_TEST_OBJS): $(WALLET_LIB_HEADERS) $(WALLET_LIB_SRC) +$(WALLET_TEST_OBJS): $(WALLET_HDRS) $(WALLET_SRC) wallet/tests: $(WALLET_TEST_PROGRAMS:%=unittest/%) -$(WALLET_TEST_PROGRAMS): $(WALLET_TEST_COMMON_OBJS) $(BITCOIN_OBJS) -$(WALLET_TEST_OBJS): $(WALLET_SRC) - update-mocks: $(WALLET_TEST_SRC:%=update-mocks/%) check-units: $(WALLET_TEST_PROGRAMS:%=unittest/%) diff --git a/wire/Makefile b/wire/Makefile index 8b2f7441b..c0348e201 100644 --- a/wire/Makefile +++ b/wire/Makefile @@ -1,38 +1,39 @@ #! /usr/bin/make -# Designed to be run one level up -wire-wrongdir: - $(MAKE) -C .. wire-all - -WIRE_HEADERS_NOGEN := wire/onion_defs.h \ +WIRE_HEADERS := wire/onion_defs.h \ wire/peer_wire.h \ - wire/tlvstream.h \ + wire/tlvstream.h \ wire/wire.h \ wire/wire_sync.h \ - wire/wire_io.h -WIRE_GEN_HEADERS := wire/peer_wiregen.h \ + wire/wire_io.h \ + wire/peer_wiregen.h \ wire/onion_wiregen.h \ wire/common_wiregen.h \ wire/peer_printgen.h \ wire/onion_printgen.h -WIRE_GEN_SRC := wire/peer_wiregen.c wire/common_wiregen.c -WIRE_GEN_ONION_SRC := wire/onion_wiregen.c -WIRE_GEN_PRINT_SRC := wire/peer_printgen.c wire/onion_printgen.c - +# We don't include peer_printgen/onion_printgen here since most don't need it. WIRE_SRC := wire/wire_sync.c \ wire/wire_io.c \ wire/fromwire.c \ wire/peer_wire.c \ wire/tlvstream.c \ - wire/towire.c -WIRE_HEADERS := $(WIRE_HEADERS_NOGEN) $(WIRE_GEN_HEADERS) + wire/towire.c \ + wire/common_wiregen.c \ + wire/peer_wiregen.c \ + wire/onion_wiregen.c + +WIRE_PRINT_SRC := \ + wire/onion_printgen.c \ + wire/peer_printgen.c -WIRE_OBJS := $(WIRE_SRC:.c=.o) $(WIRE_GEN_SRC:.c=.o) -WIRE_ONION_OBJS := $(WIRE_GEN_ONION_SRC:.c=.o) +WIRE_OBJS := $(WIRE_SRC:.c=.o) +WIRE_PRINT_OBJS := $(WIRE_PRINT_SRC:.c=.o) +$(WIRE_OBJS) $(WIRE_PRINT_OBJS): $(WIRE_HEADERS) -ALL_OBJS += $(WIRE_OBJS) $(WIRE_ONION_OBJS) -ALL_GEN_HEADERS += $(WIRE_GEN_HEADERS) +# Make sure these depend on everything. +ALL_C_SOURCES += $(WIRE_SRC) $(WIRE_PRINT_SRC) +ALL_C_HEADERS += $(WIRE_HEADERS) # They may not have the bolts. BOLT_EXTRACT=$(LOCAL_BOLTDIR)/tools/extract-formats.py @@ -89,22 +90,9 @@ wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='b wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_payload -check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%) - -check-source-bolt: $(WIRE_SRC:%=bolt-check/%) $(WIRE_HEADERS_NOGEN:%=bolt-check/%) - -check-whitespace: $(WIRE_SRC:%=check-whitespace/%) $(WIRE_HEADERS_NOGEN:%=check-whitespace/%) check-whitespace/wire/Makefile - -clean: wire-clean - maintainer-clean: wire-maintainer-clean wire-maintainer-clean: $(RM) wire/gen_*_csv wire/extracted_*_experimental_csv -wire-all: $(WIRE_OBJS) $(WIRE_ONION_OBJS) - -wire-clean: - $(RM) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(WIRE_GEN_SRC) $(WIRE_GEN_ONION_SRC) $(WIRE_GEN_HEADERS) wire/gen_*_wire_csv - include wire/test/Makefile diff --git a/wire/test/Makefile b/wire/test/Makefile index 97e306986..db7bf7a54 100644 --- a/wire/test/Makefile +++ b/wire/test/Makefile @@ -6,6 +6,9 @@ WIRE_TEST_SRC := $(wildcard wire/test/run-*.c) WIRE_TEST_OBJS := $(WIRE_TEST_SRC:.c=.o) WIRE_TEST_PROGRAMS := $(WIRE_TEST_OBJS:.o=) +ALL_C_SOURCES += $(WIRE_TEST_SRC) +ALL_TEST_PROGRAMS += $(WIRE_TEST_PROGRAMS) + WIRE_TEST_COMMON_OBJS := \ common/utils.o @@ -14,11 +17,7 @@ update-mocks: $(WIRE_TEST_SRC:%=update-mocks/%) # run-tlvstream.c needs to reach into bitcoin/pubkey for SUPERVERBOSE $(WIRE_TEST_PROGRAMS): $(WIRE_TEST_COMMON_OBJS) $(filter-out bitcoin/pubkey.o,$(BITCOIN_OBJS)) -# Test objects require source to be generated, since they include .. -$(WIRE_TEST_OBJS): $(WIRE_GEN_SRC) $(WIRE_SRC) $(WIRE_HEADERS) - -ALL_OBJS += $(WIRE_TEST_OBJS) -ALL_TEST_PROGRAMS += $(WIRE_TEST_PROGRAMS) +$(WIRE_TEST_OBJS): $(WIRE_HEADERS) $(WIRE_SRC) $(WIRE_PRINT_SRC) wire-tests: $(WIRE_TEST_PROGRAMS:%=unittest/%)