Files
Rusty Russell e120f87083 Makefile: create a library containing common, wire and bitcoin objects.
This means we don't have to manually choose what to link against,
which is much of the complexity of our Makefiles: the compiler will
automatically use any object files it needs to link.

We already do this for ccan as libccan.a, now we have libcommon.a.

We don't link against it for *everything*, as some tests require their own
versions.

Notes:
1. I get rid of the weird plugins/test/Makefile2 (accidental commit?)
2. Many tests change due to update-mocks.
3. In some places I added the missing dependency on the Makefile itself, though most are in the next
   patch.

Before:
	Total program size:     221366528
	Total tests size:       364243856

After:
	Total program size:     190733656
	Total tests size:       337880888

Build time from make clean (RUST=0) (includes building external libs):

Before:
	real    0m38.227000-44.245000(41.8222+/-1.6)s
	user    3m2.105000-33.696000(23.1442+/-8.4)s
	sys     0m35.054000-42.269000(39.7231+/-2)s
After:
	real    0m38.944000-40.416000(40.1131+/-0.4)s
	user    3m6.790000-17.159000(15.0571+/-2.8)s
	sys     0m35.304000-37.336000(36.8942+/-0.57)s

Build time after touch config.vars (RUST=0):

Before:
	real    0m18.928000-22.776000(21.5084+/-1.1)s
	user    2m8.613000-36.567000(27.7281+/-7.7)s
	sys     0m20.458000-23.436000(22.3963+/-0.77)s

After:
	real    0m19.831000-21.862000(21.5528+/-0.58)s
	user    2m15.361000-30.731000(28.4798+/-4.4)s
	sys     0m21.056000-22.339000(22.0346+/-0.35)s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

rusty@rusty-Framework:~/devel/cvs/lightni
2025-10-23 06:44:04 +10:30

87 lines
2.5 KiB
Makefile

#! /usr/bin/make
LIGHTNINGD_SRC := \
lightningd/anchorspend.c \
lightningd/bitcoind.c \
lightningd/chaintopology.c \
lightningd/channel.c \
lightningd/channel_control.c \
lightningd/channel_gossip.c \
lightningd/closing_control.c \
lightningd/coin_mvts.c \
lightningd/dual_open_control.c \
lightningd/closed_channel.c \
lightningd/connect_control.c \
lightningd/onion_message.c \
lightningd/feerate.c \
lightningd/forwards.c \
lightningd/gossip_control.c \
lightningd/gossip_generation.c \
lightningd/hsm_control.c \
lightningd/htlc_end.c \
lightningd/htlc_set.c \
lightningd/invoice.c \
lightningd/io_loop_with_timers.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_common.c \
lightningd/opening_control.c \
lightningd/options.c \
lightningd/pay.c \
lightningd/peer_control.c \
lightningd/peer_fd.c \
lightningd/peer_htlcs.c \
lightningd/ping.c \
lightningd/plugin.c \
lightningd/plugin_control.c \
lightningd/plugin_hook.c \
lightningd/routehint.c \
lightningd/runes.c \
lightningd/subd.c \
lightningd/wait.c \
lightningd/watch.c
LIGHTNINGD_SRC_NOHDR := \
lightningd/configs.c \
lightningd/datastore.c \
lightningd/offer.c \
lightningd/signmessage.c
include wallet/Makefile
LIGHTNINGD_HDRS := \
$(LIGHTNINGD_SRC:.c=.h) \
lightningd/channel_state.h \
lightningd/channel_state_names_gen.h \
$(WALLET_HDRS)
LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o) $(LIGHTNINGD_SRC_NOHDR:.c=.o)
$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HDRS) $(LIGHTNINGD_CONTROL_HEADERS)
# Make sure these depend on everything.
ALL_C_SOURCES += $(LIGHTNINGD_SRC) $(LIGHTNINGD_SRC_NOHDR)
ALL_C_HEADERS += $(LIGHTNINGD_HDRS)
ALL_PROGRAMS += lightningd/lightningd
# We explicitly check header versions in lightningd.c
lightningd/lightningd.o: header_versions_gen.h
$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HDRS)
$(WALLET_OBJS): $(LIGHTNINGD_HDRS) $(DB_HEADERS)
# Only the plugin component needs to depend on this header.
lightningd/plugin.o: plugins/list_of_builtin_plugins_gen.h
lightningd/channel_state_names_gen.h: lightningd/channel_state.h ccan/ccan/cdump/tools/cdump-enumstr
ccan/ccan/cdump/tools/cdump-enumstr lightningd/channel_state.h > $@
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(WALLET_OBJS) $(LIGHTNINGD_CONTROL_OBJS) $(HSMD_CLIENT_OBJS) $(DB_OBJS) libcommon.a
include lightningd/test/Makefile