From 65d997842e36a441dc04ffc2005f91e3a9cdf8b7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 22 Oct 2025 19:44:26 +1030 Subject: [PATCH] Makefiles: remove redundant dependencies, and have objects depend on their Makefile. 1. $(JSMN_OBJS) is not set anywhere. 2. You don't need to depend on CCAN_HEADERS, COMMON_HEADERS or JSMN_HEADERS: the top level Makefile has all object depedning on it. 3. Similarly, CCAN_OBJS. 4. Every object file should be rebuilt if its Makefile changes. Signed-off-by: Rusty Russell --- bitcoin/Makefile | 3 --- cli/Makefile | 4 ++-- common/Makefile | 6 +++--- plugins/Makefile | 34 +++++++++++++++++----------------- plugins/askrene/Makefile | 4 ++-- plugins/renepay/Makefile | 6 +++--- plugins/xpay/Makefile | 6 +++--- tests/plugins/Makefile | 6 +++--- 8 files changed, 33 insertions(+), 36 deletions(-) diff --git a/bitcoin/Makefile b/bitcoin/Makefile index bf33ee541..fcf30e9a2 100644 --- a/bitcoin/Makefile +++ b/bitcoin/Makefile @@ -38,9 +38,6 @@ BITCOIN_HEADERS := bitcoin/address.h \ bitcoin/tx_parts.h \ bitcoin/varint.h -# Bitcoin objects depends on bitcoin/ external/ and ccan -$(BITCOIN_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) - ALL_C_HEADERS += $(BITCOIN_HEADERS) ALL_C_SOURCES += $(BITCOIN_SRC) diff --git a/cli/Makefile b/cli/Makefile index 3c83e7819..4839e5138 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -5,8 +5,8 @@ ALL_C_SOURCES += $(LIGHTNING_CLI_SRC) ALL_C_HEADERS += ALL_PROGRAMS += cli/lightning-cli -$(LIGHTNING_CLI_OBJS): $(JSMN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) +$(LIGHTNING_CLI_OBJS): cli/Makefile -cli/lightning-cli: $(LIGHTNING_CLI_OBJS) $(JSMN_OBJS) libcommon.a libccan.a +cli/lightning-cli: $(LIGHTNING_CLI_OBJS) libcommon.a include cli/test/Makefile diff --git a/common/Makefile b/common/Makefile index 8348611d8..2c407e7d8 100644 --- a/common/Makefile +++ b/common/Makefile @@ -138,12 +138,12 @@ check-common-files: check-source: check-common-files -# Common objects depends on bitcoin/ external/ and ccan -$(COMMON_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) $(COMMON_HEADERS_GEN) - # Only common/version.c can include this header. common/version.o: version_gen.h +# Rebuild objects should this file change. +$(COMMON_OBJS): common/Makefile + # We make a static library, this way linker can discard unused parts. libcommon.a: $(COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) @$(call VERBOSE, "ar $@", $(AR) r $@ $?) diff --git a/plugins/Makefile b/plugins/Makefile index 40b0779b8..335e3847a 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -168,39 +168,39 @@ ALL_PROGRAMS += $(C_PLUGINS) PLUGIN_ALL_OBJS := $(PLUGIN_ALL_SRC:.c=.o) -# Make all plugins depend on all plugin headers, for simplicity. -$(PLUGIN_ALL_OBJS): $(PLUGIN_ALL_HEADER) +# Make all plugins depend on all plugin headers, for simplicity (and this file!) +$(PLUGIN_ALL_OBJS): $(PLUGIN_ALL_HEADER) plugins/Makefile -plugins/pay: $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/pay: $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a -plugins/autoclean: $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/autoclean: $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/chanbackup: $(PLUGIN_chanbackup_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/chanbackup: $(PLUGIN_chanbackup_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/commando: $(PLUGIN_COMMANDO_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/commando: $(PLUGIN_COMMANDO_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a # Topology wants to decode node_announcement, and peer_wiregen which # pulls in some of bitcoin/. -plugins/topology: $(PLUGIN_TOPOLOGY_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/topology: $(PLUGIN_TOPOLOGY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/txprepare: $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/txprepare: $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/exposesecret: $(PLUGIN_EXPOSESECRET_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/exposesecret: $(PLUGIN_EXPOSESECRET_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/bcli: $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/bcli: $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/keysend: $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/keysend: $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a $(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) libcommon.a -plugins/spenderp: $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/spenderp: $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/offers: $(PLUGIN_OFFERS_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/offers: $(PLUGIN_OFFERS_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/funder: $(PLUGIN_FUNDER_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/funder: $(PLUGIN_FUNDER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/recover: $(PLUGIN_RECOVER_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/recover: $(PLUGIN_RECOVER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a # This covers all the low-level list RPCs which return simple arrays SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listclosedchannels listtransactions listsendpays listchainmoves listchannelmoves bkpr-listaccountevents bkpr-listincome @@ -231,7 +231,7 @@ plugins/sql-schema_gen.h: $(SQL_SCHEMA_PARTS) ) plugins/sql.o: plugins/sql-schema_gen.h -plugins/sql: $(PLUGIN_SQL_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) gossipd/gossip_store_wiregen.o libcommon.a +plugins/sql: $(PLUGIN_SQL_OBJS) $(PLUGIN_LIB_OBJS) gossipd/gossip_store_wiregen.o libcommon.a # Generated from PLUGINS definition in plugins/Makefile ALL_C_HEADERS += plugins/list_of_builtin_plugins_gen.h diff --git a/plugins/askrene/Makefile b/plugins/askrene/Makefile index d10e79e1a..029234c53 100644 --- a/plugins/askrene/Makefile +++ b/plugins/askrene/Makefile @@ -26,11 +26,11 @@ PLUGIN_ASKRENE_HEADER := \ PLUGIN_ASKRENE_OBJS := $(PLUGIN_ASKRENE_SRC:.c=.o) -$(PLUGIN_ASKRENE_OBJS): $(PLUGIN_ASKRENE_HEADER) +$(PLUGIN_ASKRENE_OBJS): $(PLUGIN_ASKRENE_HEADER) plugins/askrene/Makefile PLUGIN_ALL_SRC += $(PLUGIN_ASKRENE_SRC) PLUGIN_ALL_HEADER += $(PLUGIN_ASKRENE_HEADER) -plugins/cln-askrene: $(PLUGIN_ASKRENE_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) libcommon.a +plugins/cln-askrene: $(PLUGIN_ASKRENE_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a include plugins/askrene/test/Makefile diff --git a/plugins/renepay/Makefile b/plugins/renepay/Makefile index 455dab5ba..d28ca3301 100644 --- a/plugins/renepay/Makefile +++ b/plugins/renepay/Makefile @@ -42,9 +42,9 @@ PLUGIN_RENEPAY_OBJS := $(PLUGIN_RENEPAY_SRC:.c=.o) PLUGIN_ALL_SRC += $(PLUGIN_RENEPAY_SRC) PLUGIN_ALL_HEADER += $(PLUGIN_RENEPAY_HDRS) -# Make all plugins depend on all plugin headers, for simplicity. -$(PLUGIN_RENEPAY_OBJS): $(PLUGIN_RENEPAY_HDRS) +# Make all plugins depend on all plugin headers, for simplicity (and this file). +$(PLUGIN_RENEPAY_OBJS): $(PLUGIN_RENEPAY_HDRS) plugins/renepay/Makefile -plugins/cln-renepay: $(PLUGIN_RENEPAY_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +plugins/cln-renepay: $(PLUGIN_RENEPAY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a include plugins/renepay/test/Makefile diff --git a/plugins/xpay/Makefile b/plugins/xpay/Makefile index 7cc3d7261..99441f18a 100644 --- a/plugins/xpay/Makefile +++ b/plugins/xpay/Makefile @@ -9,7 +9,7 @@ PLUGIN_XPAY_OBJS := $(PLUGIN_XPAY_SRC:.c=.o) ALL_C_SOURCES += $(PLUGIN_XPAY_SRC) ALL_C_HEADERS += $(PLUGIN_XPAY_HDRS) -# Make all plugins depend on all plugin headers, for simplicity. -$(PLUGIN_XPAY_OBJS): $(PLUGIN_XPAY_HDRS) +# Make all plugins depend on all plugin headers, for simplicity (and this file) +$(PLUGIN_XPAY_OBJS): $(PLUGIN_XPAY_HDRS) plugins/xpay/Makefile -plugins/cln-xpay: $(PLUGIN_XPAY_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) libcommon.a +plugins/cln-xpay: $(PLUGIN_XPAY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a diff --git a/tests/plugins/Makefile b/tests/plugins/Makefile index 7d7240471..3a0c46851 100644 --- a/tests/plugins/Makefile +++ b/tests/plugins/Makefile @@ -1,14 +1,14 @@ PLUGIN_TESTLIBPLUGIN_SRC := tests/plugins/test_libplugin.c PLUGIN_TESTLIBPLUGIN_OBJS := $(PLUGIN_TESTLIBPLUGIN_SRC:.c=.o) -tests/plugins/test_libplugin: $(PLUGIN_TESTLIBPLUGIN_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a +tests/plugins/test_libplugin: $(PLUGIN_TESTLIBPLUGIN_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a -$(PLUGIN_TESTLIBPLUGIN_OBJS): $(PLUGIN_LIB_HEADER) +$(PLUGIN_TESTLIBPLUGIN_OBJS): $(PLUGIN_LIB_HEADER) tests/plugins/Makefile PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_SRC := tests/plugins/test_selfdisable_after_getmanifest.c PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_OBJS := $(PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_SRC:.c=.o) -tests/plugins/test_selfdisable_after_getmanifest: $(PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_OBJS) $(JSMN_OBJS) libcommon.a +tests/plugins/test_selfdisable_after_getmanifest: $(PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_OBJS) libcommon.a PLUGIN_CHANNELD_FAKENET_SRC := tests/plugins/channeld_fakenet.c PLUGIN_CHANNELD_FAKENET_OBJS := $(PLUGIN_CHANNELD_FAKENET_SRC:.c=.o)