Skip to content

Commit 65d9978

Browse files
committed
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 <[email protected]>
1 parent e120f87 commit 65d9978

File tree

8 files changed

+33
-36
lines changed

8 files changed

+33
-36
lines changed

bitcoin/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ BITCOIN_HEADERS := bitcoin/address.h \
3838
bitcoin/tx_parts.h \
3939
bitcoin/varint.h
4040

41-
# Bitcoin objects depends on bitcoin/ external/ and ccan
42-
$(BITCOIN_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS)
43-
4441
ALL_C_HEADERS += $(BITCOIN_HEADERS)
4542
ALL_C_SOURCES += $(BITCOIN_SRC)
4643

cli/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ALL_C_SOURCES += $(LIGHTNING_CLI_SRC)
55
ALL_C_HEADERS +=
66
ALL_PROGRAMS += cli/lightning-cli
77

8-
$(LIGHTNING_CLI_OBJS): $(JSMN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS)
8+
$(LIGHTNING_CLI_OBJS): cli/Makefile
99

10-
cli/lightning-cli: $(LIGHTNING_CLI_OBJS) $(JSMN_OBJS) libcommon.a libccan.a
10+
cli/lightning-cli: $(LIGHTNING_CLI_OBJS) libcommon.a
1111

1212
include cli/test/Makefile

common/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ check-common-files:
138138

139139
check-source: check-common-files
140140

141-
# Common objects depends on bitcoin/ external/ and ccan
142-
$(COMMON_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) $(COMMON_HEADERS_GEN)
143-
144141
# Only common/version.c can include this header.
145142
common/version.o: version_gen.h
146143

144+
# Rebuild objects should this file change.
145+
$(COMMON_OBJS): common/Makefile
146+
147147
# We make a static library, this way linker can discard unused parts.
148148
libcommon.a: $(COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS)
149149
@$(call VERBOSE, "ar $@", $(AR) r $@ $?)

plugins/Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,39 +168,39 @@ ALL_PROGRAMS += $(C_PLUGINS)
168168

169169
PLUGIN_ALL_OBJS := $(PLUGIN_ALL_SRC:.c=.o)
170170

171-
# Make all plugins depend on all plugin headers, for simplicity.
172-
$(PLUGIN_ALL_OBJS): $(PLUGIN_ALL_HEADER)
171+
# Make all plugins depend on all plugin headers, for simplicity (and this file!)
172+
$(PLUGIN_ALL_OBJS): $(PLUGIN_ALL_HEADER) plugins/Makefile
173173

174-
plugins/pay: $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(JSMN_OBJS) libcommon.a
174+
plugins/pay: $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a
175175

176-
plugins/autoclean: $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
176+
plugins/autoclean: $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
177177

178-
plugins/chanbackup: $(PLUGIN_chanbackup_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
178+
plugins/chanbackup: $(PLUGIN_chanbackup_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
179179

180-
plugins/commando: $(PLUGIN_COMMANDO_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
180+
plugins/commando: $(PLUGIN_COMMANDO_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
181181

182182
# Topology wants to decode node_announcement, and peer_wiregen which
183183
# pulls in some of bitcoin/.
184-
plugins/topology: $(PLUGIN_TOPOLOGY_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
184+
plugins/topology: $(PLUGIN_TOPOLOGY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
185185

186-
plugins/txprepare: $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
186+
plugins/txprepare: $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
187187

188-
plugins/exposesecret: $(PLUGIN_EXPOSESECRET_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
188+
plugins/exposesecret: $(PLUGIN_EXPOSESECRET_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
189189

190-
plugins/bcli: $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
190+
plugins/bcli: $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
191191

192-
plugins/keysend: $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(JSMN_OBJS) libcommon.a
192+
plugins/keysend: $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a
193193
$(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) libcommon.a
194194

195-
plugins/spenderp: $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
195+
plugins/spenderp: $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
196196

197-
plugins/offers: $(PLUGIN_OFFERS_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
197+
plugins/offers: $(PLUGIN_OFFERS_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
198198

199-
plugins/funder: $(PLUGIN_FUNDER_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
199+
plugins/funder: $(PLUGIN_FUNDER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
200200

201-
plugins/recover: $(PLUGIN_RECOVER_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
201+
plugins/recover: $(PLUGIN_RECOVER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
202202

203-
plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
203+
plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
204204

205205
# This covers all the low-level list RPCs which return simple arrays
206206
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)
231231
)
232232

233233
plugins/sql.o: plugins/sql-schema_gen.h
234-
plugins/sql: $(PLUGIN_SQL_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) gossipd/gossip_store_wiregen.o libcommon.a
234+
plugins/sql: $(PLUGIN_SQL_OBJS) $(PLUGIN_LIB_OBJS) gossipd/gossip_store_wiregen.o libcommon.a
235235

236236
# Generated from PLUGINS definition in plugins/Makefile
237237
ALL_C_HEADERS += plugins/list_of_builtin_plugins_gen.h

plugins/askrene/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ PLUGIN_ASKRENE_HEADER := \
2626

2727
PLUGIN_ASKRENE_OBJS := $(PLUGIN_ASKRENE_SRC:.c=.o)
2828

29-
$(PLUGIN_ASKRENE_OBJS): $(PLUGIN_ASKRENE_HEADER)
29+
$(PLUGIN_ASKRENE_OBJS): $(PLUGIN_ASKRENE_HEADER) plugins/askrene/Makefile
3030

3131
PLUGIN_ALL_SRC += $(PLUGIN_ASKRENE_SRC)
3232
PLUGIN_ALL_HEADER += $(PLUGIN_ASKRENE_HEADER)
3333

34-
plugins/cln-askrene: $(PLUGIN_ASKRENE_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) libcommon.a
34+
plugins/cln-askrene: $(PLUGIN_ASKRENE_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
3535

3636
include plugins/askrene/test/Makefile

plugins/renepay/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ PLUGIN_RENEPAY_OBJS := $(PLUGIN_RENEPAY_SRC:.c=.o)
4242
PLUGIN_ALL_SRC += $(PLUGIN_RENEPAY_SRC)
4343
PLUGIN_ALL_HEADER += $(PLUGIN_RENEPAY_HDRS)
4444

45-
# Make all plugins depend on all plugin headers, for simplicity.
46-
$(PLUGIN_RENEPAY_OBJS): $(PLUGIN_RENEPAY_HDRS)
45+
# Make all plugins depend on all plugin headers, for simplicity (and this file).
46+
$(PLUGIN_RENEPAY_OBJS): $(PLUGIN_RENEPAY_HDRS) plugins/renepay/Makefile
4747

48-
plugins/cln-renepay: $(PLUGIN_RENEPAY_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
48+
plugins/cln-renepay: $(PLUGIN_RENEPAY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
4949

5050
include plugins/renepay/test/Makefile

plugins/xpay/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PLUGIN_XPAY_OBJS := $(PLUGIN_XPAY_SRC:.c=.o)
99
ALL_C_SOURCES += $(PLUGIN_XPAY_SRC)
1010
ALL_C_HEADERS += $(PLUGIN_XPAY_HDRS)
1111

12-
# Make all plugins depend on all plugin headers, for simplicity.
13-
$(PLUGIN_XPAY_OBJS): $(PLUGIN_XPAY_HDRS)
12+
# Make all plugins depend on all plugin headers, for simplicity (and this file)
13+
$(PLUGIN_XPAY_OBJS): $(PLUGIN_XPAY_HDRS) plugins/xpay/Makefile
1414

15-
plugins/cln-xpay: $(PLUGIN_XPAY_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) libcommon.a
15+
plugins/cln-xpay: $(PLUGIN_XPAY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a

tests/plugins/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
PLUGIN_TESTLIBPLUGIN_SRC := tests/plugins/test_libplugin.c
22
PLUGIN_TESTLIBPLUGIN_OBJS := $(PLUGIN_TESTLIBPLUGIN_SRC:.c=.o)
33

4-
tests/plugins/test_libplugin: $(PLUGIN_TESTLIBPLUGIN_OBJS) $(PLUGIN_LIB_OBJS) $(JSMN_OBJS) libcommon.a
4+
tests/plugins/test_libplugin: $(PLUGIN_TESTLIBPLUGIN_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
55

6-
$(PLUGIN_TESTLIBPLUGIN_OBJS): $(PLUGIN_LIB_HEADER)
6+
$(PLUGIN_TESTLIBPLUGIN_OBJS): $(PLUGIN_LIB_HEADER) tests/plugins/Makefile
77

88
PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_SRC := tests/plugins/test_selfdisable_after_getmanifest.c
99
PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_OBJS := $(PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_SRC:.c=.o)
1010

11-
tests/plugins/test_selfdisable_after_getmanifest: $(PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_OBJS) $(JSMN_OBJS) libcommon.a
11+
tests/plugins/test_selfdisable_after_getmanifest: $(PLUGIN_TESTSELFDISABLE_AFTER_GETMANIFEST_OBJS) libcommon.a
1212

1313
PLUGIN_CHANNELD_FAKENET_SRC := tests/plugins/channeld_fakenet.c
1414
PLUGIN_CHANNELD_FAKENET_OBJS := $(PLUGIN_CHANNELD_FAKENET_SRC:.c=.o)

0 commit comments

Comments
 (0)