Makefiles: remove redundant dependencies, and have objects depend on their Makefile.
What changed, and why it matters
This commit is a routine cleanup of build files (Makefiles). It removes unnecessary dependency declarations and ensures object files are rebuilt when their Makefile changes. There is no change to the actual Lightning node software or its security behavior.
No security action required. Treat as normal build-system maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors Makefile dependency rules across bitcoin, cli, common, plugins, and tests/plugins directories. It removes redundant explicit dependencies on CCAN_HEADERS, COMMON_HEADERS, JSMN_HEADERS, JSMN_OBJS, and CCAN_OBJS (noting JSMN_OBJS and CCAN_OBJS are no longer set), relying instead on top-level Makefile dependencies. It also adds Makefile files themselves as dependencies for object files to force rebuilds when build rules change. No source code logic is modified.
Changed components
bitcoin/Makefilecli/Makefilecommon/Makefileplugins/Makefileplugins/askrene/Makefileplugins/renepay/Makefileplugins/xpay/Makefiletests/plugins/MakefileInspect captured patch +33 / −36
diff --git a/bitcoin/Makefile b/bitcoin/Makefile
index bf33ee54..fcf30e9a 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 3c83e781..4839e513 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 8348611d..2c407e7d 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 40b0779b..335e3847 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 d10e79e1..029234c5 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 455dab5b..d28ca330 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 7cc3d726..99441f18 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 7d724047..3a0c4685 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)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.