2015-05-26 06:38:12 +02:00
|
|
|
#! /usr/bin/make
|
2016-11-21 01:09:13 +01:00
|
|
|
NAME=Bitcoin Savings & Trust Daily Interest II
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2017-12-06 15:12:04 +01:00
|
|
|
# TODO: Decide: c-lightning, lightningd, lightning?
|
|
|
|
PKGNAME = c-lightning
|
|
|
|
|
2016-01-21 21:08:08 +01:00
|
|
|
# We use our own internal ccan copy.
|
|
|
|
CCANDIR := ccan
|
|
|
|
|
2016-05-02 08:28:56 +02:00
|
|
|
# Where we keep the BOLT RFCs
|
2016-05-04 08:33:04 +02:00
|
|
|
BOLTDIR := ../lightning-rfc/
|
2017-11-15 05:07:45 +01:00
|
|
|
BOLTVERSION := 4f91f0bb2a9c176dda019f9c0618c10f9fa0acfd
|
2016-05-02 08:28:56 +02:00
|
|
|
|
2016-05-17 06:19:54 +02:00
|
|
|
# If you don't have (working) valgrind.
|
|
|
|
#NO_VALGRIND := 1
|
|
|
|
|
2016-12-02 08:40:13 +01:00
|
|
|
ifneq ($(NO_VALGRIND),1)
|
|
|
|
VALGRIND=valgrind -q --error-exitcode=7
|
2017-09-28 05:40:05 +02:00
|
|
|
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
|
2016-12-02 08:40:13 +01:00
|
|
|
endif
|
|
|
|
|
2017-10-24 04:06:14 +02:00
|
|
|
# By default, we are in DEVELOPER mode, use DEVELOPER= on cmdline to override.
|
|
|
|
DEVELOPER := 1
|
|
|
|
|
|
|
|
ifeq ($(DEVELOPER),1)
|
2017-12-15 11:16:54 +01:00
|
|
|
DEV_CFLAGS=-DDEVELOPER=1 -DCCAN_TAL_DEBUG=1 -DCCAN_TAKE_DEBUG=1
|
2017-10-24 04:06:14 +02:00
|
|
|
else
|
|
|
|
DEV_CFLAGS=-DDEVELOPER=0
|
|
|
|
endif
|
|
|
|
|
2017-01-06 18:53:11 +01:00
|
|
|
ifeq ($(COVERAGE),1)
|
|
|
|
COVFLAGS = --coverage
|
|
|
|
endif
|
|
|
|
|
2018-02-19 10:13:44 +01:00
|
|
|
ifeq ($(PIE),1)
|
|
|
|
PIE_CFLAGS=-fPIE -fPIC
|
|
|
|
PIE_LDFLAGS=-pie
|
|
|
|
endif
|
|
|
|
|
2017-11-09 14:36:56 +01:00
|
|
|
PYTEST := $(shell command -v pytest 2> /dev/null)
|
|
|
|
|
2016-11-10 14:00:35 +01:00
|
|
|
# This is where we add new features as bitcoin adds them.
|
2016-11-11 00:02:04 +01:00
|
|
|
FEATURES :=
|
2015-06-25 06:20:16 +02:00
|
|
|
|
2015-09-24 07:33:20 +02:00
|
|
|
CCAN_OBJS := \
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-asort.o \
|
|
|
|
ccan-autodata.o \
|
|
|
|
ccan-breakpoint.o \
|
|
|
|
ccan-crypto-hmac.o \
|
|
|
|
ccan-crypto-hkdf.o \
|
2015-09-24 07:33:20 +02:00
|
|
|
ccan-crypto-ripemd160.o \
|
|
|
|
ccan-crypto-sha256.o \
|
2017-08-28 18:10:01 +02:00
|
|
|
ccan-crypto-shachain.o \
|
2016-06-28 23:19:20 +02:00
|
|
|
ccan-crypto-siphash24.o \
|
2018-02-16 01:26:34 +01:00
|
|
|
ccan-daemonize.o \
|
2015-09-24 07:33:20 +02:00
|
|
|
ccan-err.o \
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-fdpass.o \
|
2016-01-21 21:11:46 +01:00
|
|
|
ccan-htable.o \
|
2016-01-21 21:08:09 +01:00
|
|
|
ccan-ilog.o \
|
2016-01-21 21:11:45 +01:00
|
|
|
ccan-io-io.o \
|
2017-01-24 14:33:15 +01:00
|
|
|
ccan-intmap.o \
|
2016-01-21 21:11:45 +01:00
|
|
|
ccan-io-poll.o \
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-io-fdpass.o \
|
2016-01-21 21:08:09 +01:00
|
|
|
ccan-isaac.o \
|
|
|
|
ccan-isaac64.o \
|
2015-09-24 07:33:20 +02:00
|
|
|
ccan-list.o \
|
2016-05-04 08:44:22 +02:00
|
|
|
ccan-mem.o \
|
2015-09-24 07:33:20 +02:00
|
|
|
ccan-noerr.o \
|
|
|
|
ccan-opt-helpers.o \
|
|
|
|
ccan-opt-parse.o \
|
|
|
|
ccan-opt-usage.o \
|
|
|
|
ccan-opt.o \
|
2016-01-21 21:11:45 +01:00
|
|
|
ccan-pipecmd.o \
|
2018-01-22 15:49:09 +01:00
|
|
|
ccan-ptr_valid.o \
|
2015-09-24 07:33:20 +02:00
|
|
|
ccan-read_write_all.o \
|
|
|
|
ccan-str-hex.o \
|
|
|
|
ccan-str.o \
|
|
|
|
ccan-take.o \
|
|
|
|
ccan-tal-grab_file.o \
|
2018-02-18 13:55:46 +01:00
|
|
|
ccan-tal-link.o \
|
2016-01-21 21:11:48 +01:00
|
|
|
ccan-tal-path.o \
|
2015-09-24 07:33:20 +02:00
|
|
|
ccan-tal-str.o \
|
2016-01-21 21:08:09 +01:00
|
|
|
ccan-tal.o \
|
2016-01-21 21:11:45 +01:00
|
|
|
ccan-time.o \
|
|
|
|
ccan-timer.o
|
2015-09-24 07:33:20 +02:00
|
|
|
|
2016-01-21 21:08:08 +01:00
|
|
|
CCAN_HEADERS := \
|
|
|
|
$(CCANDIR)/config.h \
|
|
|
|
$(CCANDIR)/ccan/alignof/alignof.h \
|
|
|
|
$(CCANDIR)/ccan/array_size/array_size.h \
|
|
|
|
$(CCANDIR)/ccan/asort/asort.h \
|
2017-01-04 03:46:47 +01:00
|
|
|
$(CCANDIR)/ccan/autodata/autodata.h \
|
|
|
|
$(CCANDIR)/ccan/breakpoint/breakpoint.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/build_assert/build_assert.h \
|
|
|
|
$(CCANDIR)/ccan/cast/cast.h \
|
|
|
|
$(CCANDIR)/ccan/cdump/cdump.h \
|
|
|
|
$(CCANDIR)/ccan/check_type/check_type.h \
|
|
|
|
$(CCANDIR)/ccan/compiler/compiler.h \
|
|
|
|
$(CCANDIR)/ccan/container_of/container_of.h \
|
2016-09-06 06:17:07 +02:00
|
|
|
$(CCANDIR)/ccan/cppmagic/cppmagic.h \
|
2017-01-04 03:46:47 +01:00
|
|
|
$(CCANDIR)/ccan/crypto/hkdf_sha256/hkdf_sha256.h \
|
|
|
|
$(CCANDIR)/ccan/crypto/hmac_sha256/hmac_sha256.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/crypto/ripemd160/ripemd160.h \
|
|
|
|
$(CCANDIR)/ccan/crypto/sha256/sha256.h \
|
|
|
|
$(CCANDIR)/ccan/crypto/shachain/shachain.h \
|
2016-06-28 23:19:20 +02:00
|
|
|
$(CCANDIR)/ccan/crypto/siphash24/siphash24.h \
|
2018-02-16 01:26:34 +01:00
|
|
|
$(CCANDIR)/ccan/daemonize/daemonize.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/endian/endian.h \
|
|
|
|
$(CCANDIR)/ccan/err/err.h \
|
2017-01-04 03:46:47 +01:00
|
|
|
$(CCANDIR)/ccan/fdpass/fdpass.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/htable/htable.h \
|
|
|
|
$(CCANDIR)/ccan/htable/htable_type.h \
|
|
|
|
$(CCANDIR)/ccan/ilog/ilog.h \
|
2017-01-24 14:33:15 +01:00
|
|
|
$(CCANDIR)/ccan/intmap/intmap.h \
|
2016-01-21 21:11:45 +01:00
|
|
|
$(CCANDIR)/ccan/io/backend.h \
|
2017-01-04 03:46:47 +01:00
|
|
|
$(CCANDIR)/ccan/io/fdpass/fdpass.h \
|
2016-01-21 21:11:45 +01:00
|
|
|
$(CCANDIR)/ccan/io/io.h \
|
|
|
|
$(CCANDIR)/ccan/io/io_plan.h \
|
2016-01-21 21:08:09 +01:00
|
|
|
$(CCANDIR)/ccan/isaac/isaac.h \
|
|
|
|
$(CCANDIR)/ccan/isaac/isaac64.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/likely/likely.h \
|
|
|
|
$(CCANDIR)/ccan/list/list.h \
|
|
|
|
$(CCANDIR)/ccan/mem/mem.h \
|
|
|
|
$(CCANDIR)/ccan/noerr/noerr.h \
|
|
|
|
$(CCANDIR)/ccan/opt/opt.h \
|
|
|
|
$(CCANDIR)/ccan/opt/private.h \
|
|
|
|
$(CCANDIR)/ccan/order/order.h \
|
2016-01-21 21:11:45 +01:00
|
|
|
$(CCANDIR)/ccan/pipecmd/pipecmd.h \
|
2017-01-04 03:46:47 +01:00
|
|
|
$(CCANDIR)/ccan/ptr_valid/ptr_valid.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/ptrint/ptrint.h \
|
|
|
|
$(CCANDIR)/ccan/read_write_all/read_write_all.h \
|
|
|
|
$(CCANDIR)/ccan/short_types/short_types.h \
|
|
|
|
$(CCANDIR)/ccan/str/hex/hex.h \
|
|
|
|
$(CCANDIR)/ccan/str/str.h \
|
|
|
|
$(CCANDIR)/ccan/str/str_debug.h \
|
|
|
|
$(CCANDIR)/ccan/strmap/strmap.h \
|
|
|
|
$(CCANDIR)/ccan/structeq/structeq.h \
|
|
|
|
$(CCANDIR)/ccan/take/take.h \
|
|
|
|
$(CCANDIR)/ccan/tal/grab_file/grab_file.h \
|
2018-02-18 13:55:46 +01:00
|
|
|
$(CCANDIR)/ccan/tal/link/link.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/tal/path/path.h \
|
|
|
|
$(CCANDIR)/ccan/tal/str/str.h \
|
|
|
|
$(CCANDIR)/ccan/tal/tal.h \
|
|
|
|
$(CCANDIR)/ccan/tcon/tcon.h \
|
2016-01-21 21:08:09 +01:00
|
|
|
$(CCANDIR)/ccan/time/time.h \
|
2016-01-21 21:11:45 +01:00
|
|
|
$(CCANDIR)/ccan/timer/timer.h \
|
2016-01-21 21:08:08 +01:00
|
|
|
$(CCANDIR)/ccan/typesafe_cb/typesafe_cb.h
|
|
|
|
|
2017-08-29 06:12:04 +02:00
|
|
|
ALL_GEN_HEADERS += gen_version.h
|
2016-01-21 21:08:08 +01:00
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
CDUMP_OBJS := ccan-cdump.o ccan-strmap.o
|
|
|
|
|
2017-01-04 04:39:20 +01:00
|
|
|
WIRE_GEN := tools/generate-wire.py
|
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
ALL_PROGRAMS =
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2017-12-31 17:30:40 +01:00
|
|
|
CPPFLAGS = -DBINTOPKGLIBEXECDIR='"'$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))'"'
|
2016-01-21 21:11:37 +01:00
|
|
|
CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition
|
2017-06-25 16:14:27 +02:00
|
|
|
CDEBUGFLAGS := -std=gnu11 -g -fstack-protector
|
2018-02-19 10:13:44 +01:00
|
|
|
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS)
|
2016-01-21 21:11:37 +01:00
|
|
|
|
2018-02-23 04:39:12 +01:00
|
|
|
LDFLAGS = $(PIE_LDFLAGS)
|
|
|
|
LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 $(COVFLAGS)
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2017-09-11 06:52:58 +02:00
|
|
|
default: all-programs all-test-programs
|
2016-09-06 09:17:41 +02:00
|
|
|
|
2017-08-28 18:11:01 +02:00
|
|
|
include external/Makefile
|
2016-12-20 01:04:59 +01:00
|
|
|
include bitcoin/Makefile
|
2017-08-28 18:13:01 +02:00
|
|
|
include common/Makefile
|
2016-12-20 01:04:59 +01:00
|
|
|
include wire/Makefile
|
2017-05-12 20:24:18 +02:00
|
|
|
include wallet/Makefile
|
2017-08-29 06:12:04 +02:00
|
|
|
include hsmd/Makefile
|
|
|
|
include gossipd/Makefile
|
|
|
|
include openingd/Makefile
|
|
|
|
include channeld/Makefile
|
|
|
|
include closingd/Makefile
|
|
|
|
include onchaind/Makefile
|
2017-01-10 06:07:51 +01:00
|
|
|
include lightningd/Makefile
|
2017-08-28 18:04:01 +02:00
|
|
|
include cli/Makefile
|
2017-08-28 18:13:01 +02:00
|
|
|
include test/Makefile
|
|
|
|
include doc/Makefile
|
2017-11-22 01:26:08 +01:00
|
|
|
include devtools/Makefile
|
2016-12-20 01:04:59 +01:00
|
|
|
|
2016-10-07 05:27:57 +02:00
|
|
|
# Git doesn't maintain timestamps, so we only regen if git says we should.
|
2016-11-08 12:30:55 +01:00
|
|
|
CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o x"`git diff $<`" != x"" ]
|
|
|
|
|
2017-12-21 14:12:51 +01:00
|
|
|
ifeq ($(TEST_GROUP_COUNT),)
|
|
|
|
TEST_GROUP=1
|
|
|
|
TEST_GROUP_COUNT=1
|
|
|
|
endif
|
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
check:
|
2017-12-31 02:42:27 +01:00
|
|
|
$(MAKE) installcheck
|
2017-02-02 04:04:08 +01:00
|
|
|
$(MAKE) pytest
|
2016-04-11 09:12:53 +02:00
|
|
|
|
2017-08-29 06:12:04 +02:00
|
|
|
pytest: $(ALL_PROGRAMS)
|
2017-11-09 14:36:56 +01:00
|
|
|
ifndef PYTEST
|
2018-01-03 20:20:57 +01:00
|
|
|
PYTHONPATH=contrib/pylightning:$$PYTHONPATH DEVELOPER=$(DEVELOPER) python3 tests/test_lightningd.py -f
|
2017-11-09 14:36:56 +01:00
|
|
|
else
|
2018-01-03 20:20:57 +01:00
|
|
|
PYTHONPATH=contrib/pylightning:$$PYTHONPATH TEST_DEBUG=1 DEVELOPER=$(DEVELOPER) $(PYTEST) -vx tests/test_lightningd.py --test-group=$(TEST_GROUP) --test-group-count=$(TEST_GROUP_COUNT)
|
2017-11-09 14:36:56 +01:00
|
|
|
endif
|
2017-01-14 20:33:07 +01:00
|
|
|
|
2016-01-21 21:08:09 +01:00
|
|
|
# Keep includes in alpha order.
|
|
|
|
check-src-include-order/%: %
|
|
|
|
@if [ "$$(grep '^#include' < $<)" != "$$(grep '^#include' < $< | LC_ALL=C sort)" ]; then echo "$<:1: includes out of order"; grep '^#include' < $<; echo VERSUS; grep '^#include' < $< | LC_ALL=C sort; exit 1; fi
|
|
|
|
|
|
|
|
# Keep includes in alpha order, after including "config.h"
|
|
|
|
check-hdr-include-order/%: %
|
|
|
|
@if [ "$$(grep '^#include' < $< | head -n1)" != '#include "config.h"' ]; then echo "$<:1: doesn't include config.h first"; exit 1; fi
|
|
|
|
@if [ "$$(grep '^#include' < $< | tail -n +2)" != "$$(grep '^#include' < $< | tail -n +2 | LC_ALL=C sort)" ]; then echo "$<:1: includes out of order"; exit 1; fi
|
|
|
|
|
|
|
|
# Make sure Makefile includes all headers.
|
2017-08-28 17:53:01 +02:00
|
|
|
check-makefile:
|
2016-01-21 21:08:09 +01:00
|
|
|
@if [ x"$(CCANDIR)/config.h `find $(CCANDIR)/ccan -name '*.h' | grep -v /test/ | LC_ALL=C sort | tr '\n' ' '`" != x"$(CCAN_HEADERS) " ]; then echo CCAN_HEADERS incorrect; exit 1; fi
|
|
|
|
|
2017-12-07 23:59:39 +01:00
|
|
|
# Any mention of BOLT# must be followed by an exact quote, modulo whitespace.
|
2017-08-22 07:04:11 +02:00
|
|
|
bolt-check/%: % bolt-precheck tools/check-bolt
|
|
|
|
@[ ! -d .tmp.lightningrfc ] || tools/check-bolt .tmp.lightningrfc $<
|
2017-01-04 04:39:20 +01:00
|
|
|
|
|
|
|
bolt-precheck:
|
2017-10-26 05:09:19 +02:00
|
|
|
@rm -rf .tmp.lightningrfc; if [ ! -d $(BOLTDIR) ]; then echo Not checking BOLT references: BOLTDIR $(BOLTDIR) does not exist >&2; exit 0; fi; set -e; if [ -n "$(BOLTVERSION)" ]; then git clone -q $(BOLTDIR) .tmp.lightningrfc && cd .tmp.lightningrfc && git checkout -q $(BOLTVERSION); else cp -a $(BOLTDIR) .tmp.lightningrfc; fi
|
2017-01-04 04:39:20 +01:00
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
check-source-bolt: $(ALL_TEST_PROGRAMS:%=bolt-check/%.c)
|
2016-05-02 08:28:56 +02:00
|
|
|
|
2017-08-22 07:04:11 +02:00
|
|
|
tools/check-bolt: tools/check-bolt.o $(CCAN_OBJS)
|
2016-05-02 08:28:56 +02:00
|
|
|
|
2017-08-22 07:04:11 +02:00
|
|
|
tools/check-bolt.o: $(CCAN_HEADERS)
|
2016-05-02 08:28:56 +02:00
|
|
|
|
2017-01-04 04:39:20 +01:00
|
|
|
check-whitespace/%: %
|
|
|
|
@if grep -Hn '[ ]$$' $<; then echo Extraneous whitespace found >&2; exit 1; fi
|
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
check-whitespace: check-whitespace/Makefile check-whitespace/tools/check-bolt.c $(ALL_TEST_PROGRAMS:%=check-whitespace/%.c)
|
2016-11-11 00:06:10 +01:00
|
|
|
|
2018-01-18 17:35:56 +01:00
|
|
|
check-markdown:
|
|
|
|
@tools/check-markdown.sh
|
|
|
|
|
2018-01-22 10:49:30 +01:00
|
|
|
check-spelling:
|
|
|
|
@tools/check-spelling.sh
|
|
|
|
|
|
|
|
check-source: check-makefile check-source-bolt check-whitespace check-markdown check-spelling
|
2016-01-21 21:08:09 +01:00
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
full-check: check check-source
|
2015-09-29 09:32:02 +02:00
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
coverage/coverage.info: check pytest
|
2017-01-09 11:18:11 +01:00
|
|
|
mkdir coverage || true
|
|
|
|
lcov --capture --directory . --output-file coverage/coverage.info
|
|
|
|
|
|
|
|
coverage: coverage/coverage.info
|
|
|
|
genhtml coverage/coverage.info --output-directory coverage
|
|
|
|
|
2017-01-04 03:47:47 +01:00
|
|
|
# Ignore test/ directories.
|
2015-06-04 08:16:39 +02:00
|
|
|
TAGS: FORCE
|
2017-01-04 03:47:47 +01:00
|
|
|
$(RM) TAGS; find * -name test -type d -prune -o -name '*.[ch]' -print | xargs etags --append
|
2015-06-04 08:16:39 +02:00
|
|
|
FORCE::
|
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS)
|
2017-01-11 00:12:26 +01:00
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
ALL_PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr
|
|
|
|
# Can't add to ALL_OBJS, as that makes a circular dep.
|
2018-01-20 05:27:13 +01:00
|
|
|
ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS) Makefile
|
2015-06-12 05:59:06 +02:00
|
|
|
|
|
|
|
ccan/config.h: ccan/tools/configurator/configurator
|
2018-02-19 10:45:54 +01:00
|
|
|
if $< $(CC) -static > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi
|
2015-06-12 05:59:06 +02:00
|
|
|
|
2015-08-08 13:15:49 +02:00
|
|
|
gen_version.h: FORCE
|
|
|
|
@(echo "#define VERSION \"`git describe --always --dirty`\"" && echo "#define VERSION_NAME \"$(NAME)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new
|
2016-09-13 21:52:41 +02:00
|
|
|
@if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; echo Version updated; fi
|
2015-08-08 13:15:49 +02:00
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
# All binaries require the external libs, ccan
|
|
|
|
$(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS): $(EXTERNAL_LIBS) $(CCAN_OBJS)
|
|
|
|
|
|
|
|
# Each test program depends on its own object.
|
|
|
|
$(ALL_TEST_PROGRAMS): %: %.o
|
2015-08-08 13:15:49 +02:00
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
# Without this rule, the (built-in) link line contains
|
|
|
|
# external/libwallycore.a directly, which causes a symbol clash (it
|
|
|
|
# uses some ccan modules internally). We want to rely on -lwallycore etc.
|
|
|
|
# (as per EXTERNAL_LDLIBS) so we filter them out here.
|
|
|
|
$(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS):
|
|
|
|
$(LINK.o) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) -o $@
|
|
|
|
|
2018-01-20 05:27:13 +01:00
|
|
|
# Everything depends on the CCAN headers, and Makefile
|
|
|
|
$(CCAN_OBJS) $(CDUMP_OBJS): $(CCAN_HEADERS) Makefile
|
2017-08-28 18:13:01 +02:00
|
|
|
|
2018-01-20 05:27:13 +01:00
|
|
|
# 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
|
2017-08-29 06:12:04 +02:00
|
|
|
|
2018-01-20 05:27:13 +01:00
|
|
|
# We generate headers in two ways, so regen when either changes (or Makefile)
|
|
|
|
$(ALL_GEN_HEADERS): ccan/ccan/cdump/tools/cdump-enumstr $(WIRE_GEN) Makefile
|
2017-08-28 18:11:01 +02:00
|
|
|
|
2015-07-09 07:38:17 +02:00
|
|
|
update-ccan:
|
|
|
|
mv ccan ccan.old
|
|
|
|
DIR=$$(pwd)/ccan; cd ../ccan && ./tools/create-ccan-tree -a $$DIR `cd $$DIR.old/ccan && find * -name _info | sed s,/_info,, | sort` $(CCAN_NEW)
|
|
|
|
mkdir -p ccan/tools/configurator
|
|
|
|
cp ../ccan/tools/configurator/configurator.c ccan/tools/configurator/
|
|
|
|
$(MAKE) ccan/config.h
|
|
|
|
grep -v '^CCAN version:' ccan.old/README > ccan/README
|
|
|
|
echo CCAN version: `git -C ../ccan describe` >> ccan/README
|
|
|
|
$(RM) -r ccan.old
|
2016-07-01 03:57:57 +02:00
|
|
|
|
2017-09-11 06:52:58 +02:00
|
|
|
# Now ALL_PROGRAMS is fully populated, we can expand it.
|
|
|
|
all-programs: $(ALL_PROGRAMS)
|
|
|
|
all-test-programs: $(ALL_TEST_PROGRAMS)
|
2015-07-09 07:38:17 +02:00
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
distclean: clean
|
2015-09-30 07:19:42 +02:00
|
|
|
|
2016-08-09 05:41:13 +02:00
|
|
|
maintainer-clean: distclean
|
2015-09-30 07:19:42 +02:00
|
|
|
@echo 'This command is intended for maintainers to use; it'
|
|
|
|
@echo 'deletes files that may need special tools to rebuild.'
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2017-08-28 18:04:01 +02:00
|
|
|
clean: wire-clean
|
2017-08-28 18:13:01 +02:00
|
|
|
$(RM) $(CCAN_OBJS) $(CDUMP_OBJS) $(ALL_OBJS)
|
|
|
|
$(RM) $(ALL_PROGRAMS) $(ALL_PROGRAMS:=.o)
|
|
|
|
$(RM) $(ALL_TEST_PROGRAMS) $(ALL_TEST_PROGRAMS:=.o)
|
2017-11-23 04:03:07 +01:00
|
|
|
$(RM) ccan/config.h gen_*.h ccan/tools/configurator/configurator
|
2016-09-08 08:27:33 +02:00
|
|
|
$(RM) ccan/ccan/cdump/tools/cdump-enumstr.o
|
2017-08-22 07:04:11 +02:00
|
|
|
$(RM) check-bolt tools/check-bolt tools/*.o
|
2017-01-09 11:18:11 +01:00
|
|
|
find . -name '*gcda' -delete
|
|
|
|
find . -name '*gcno' -delete
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2017-01-04 04:39:20 +01:00
|
|
|
update-mocks/%: %
|
2017-08-31 04:06:58 +02:00
|
|
|
@tools/update-mocks.sh "$*"
|
2017-01-04 04:39:20 +01:00
|
|
|
|
2016-12-02 08:40:13 +01:00
|
|
|
unittest/%: %
|
|
|
|
$(VALGRIND) $(VALGRIND_TEST_ARGS) $*
|
|
|
|
|
2017-12-06 15:12:04 +01:00
|
|
|
# Installation directories
|
|
|
|
prefix = /usr/local
|
|
|
|
exec_prefix = $(prefix)
|
|
|
|
bindir = $(exec_prefix)/bin
|
|
|
|
libexecdir = $(exec_prefix)/libexec
|
2017-12-31 17:30:40 +01:00
|
|
|
pkglibexecdir = $(libexecdir)/$(PKGNAME)
|
2017-12-06 15:12:04 +01:00
|
|
|
datadir = $(prefix)/share
|
|
|
|
docdir = $(datadir)/doc/$(PKGNAME)
|
|
|
|
mandir = $(datadir)/man
|
|
|
|
man1dir = $(mandir)/man1
|
|
|
|
man7dir = $(mandir)/man7
|
|
|
|
|
|
|
|
# Commands
|
|
|
|
MKDIR_P = mkdir -p
|
|
|
|
INSTALL = install
|
|
|
|
INSTALL_PROGRAM = $(INSTALL)
|
|
|
|
INSTALL_DATA = $(INSTALL) -m 644
|
|
|
|
|
|
|
|
# Tags needed by some package systems.
|
|
|
|
PRE_INSTALL = :
|
|
|
|
NORMAL_INSTALL = :
|
|
|
|
POST_INSTALL = :
|
|
|
|
PRE_UNINSTALL = :
|
|
|
|
NORMAL_UNINSTALL = :
|
|
|
|
POST_UNINSTALL = :
|
|
|
|
|
|
|
|
# Target to create directories.
|
|
|
|
installdirs:
|
|
|
|
@$(NORMAL_INSTALL)
|
|
|
|
$(MKDIR_P) $(DESTDIR)$(bindir)
|
2018-01-03 12:44:42 +01:00
|
|
|
$(MKDIR_P) $(DESTDIR)$(pkglibexecdir)
|
2017-12-06 15:12:04 +01:00
|
|
|
$(MKDIR_P) $(DESTDIR)$(man1dir)
|
|
|
|
$(MKDIR_P) $(DESTDIR)$(man7dir)
|
|
|
|
$(MKDIR_P) $(DESTDIR)$(docdir)
|
|
|
|
|
2018-01-03 12:44:42 +01:00
|
|
|
# Programs to install in bindir and pkglibexecdir.
|
2017-12-06 15:12:04 +01:00
|
|
|
# TODO: $(EXEEXT) support for Windows? Needs more coding for
|
|
|
|
# the individual Makefiles, however.
|
|
|
|
BIN_PROGRAMS = \
|
|
|
|
cli/lightning-cli \
|
2018-01-03 12:44:42 +01:00
|
|
|
lightningd/lightningd
|
|
|
|
PKGLIBEXEC_PROGRAMS = \
|
2017-12-06 15:12:04 +01:00
|
|
|
lightningd/lightning_channeld \
|
|
|
|
lightningd/lightning_closingd \
|
|
|
|
lightningd/lightning_gossipd \
|
|
|
|
lightningd/lightning_hsmd \
|
|
|
|
lightningd/lightning_onchaind \
|
|
|
|
lightningd/lightning_openingd
|
|
|
|
|
2018-01-03 12:44:42 +01:00
|
|
|
install-program: installdirs $(BIN_PROGRAMS) $(PKGLIBEXEC_PROGRAMS)
|
2017-12-06 15:12:04 +01:00
|
|
|
@$(NORMAL_INSTALL)
|
|
|
|
$(INSTALL_PROGRAM) $(BIN_PROGRAMS) $(DESTDIR)$(bindir)
|
2018-01-03 12:44:42 +01:00
|
|
|
$(INSTALL_PROGRAM) $(PKGLIBEXEC_PROGRAMS) $(DESTDIR)$(pkglibexecdir)
|
2017-12-06 15:12:04 +01:00
|
|
|
|
|
|
|
MAN1PAGES = $(filter %.1,$(MANPAGES))
|
|
|
|
MAN7PAGES = $(filter %.7,$(MANPAGES))
|
|
|
|
DOC_DATA = README.md doc/INSTALL.md doc/HACKING.md LICENSE
|
|
|
|
|
|
|
|
install-data: installdirs $(MAN1PAGES) $(MAN7PAGES) $(DOC_DATA)
|
|
|
|
@$(NORMAL_INSTALL)
|
|
|
|
$(INSTALL_DATA) $(MAN1PAGES) $(DESTDIR)$(man1dir)
|
|
|
|
$(INSTALL_DATA) $(MAN7PAGES) $(DESTDIR)$(man7dir)
|
|
|
|
$(INSTALL_DATA) $(DOC_DATA) $(DESTDIR)$(docdir)
|
|
|
|
|
|
|
|
install: install-program install-data
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
@$(NORMAL_UNINSTALL)
|
|
|
|
@for f in $(BIN_PROGRAMS); do \
|
|
|
|
echo rm -f $(DESTDIR)$(bindir)/`basename $$f`; \
|
|
|
|
rm -f $(DESTDIR)$(bindir)/`basename $$f`; \
|
|
|
|
done
|
2018-01-03 12:44:42 +01:00
|
|
|
@for f in $(PKGLIBEXEC_PROGRAMS); do \
|
|
|
|
echo rm -f $(DESTDIR)$(pkglibexecdir)/`basename $$f`; \
|
|
|
|
rm -f $(DESTDIR)$(pkglibexecdir)/`basename $$f`; \
|
|
|
|
done
|
2017-12-06 15:12:04 +01:00
|
|
|
@for f in $(MAN1PAGES); do \
|
|
|
|
echo rm -f $(DESTDIR)$(man1dir)/`basename $$f`; \
|
|
|
|
rm -f $(DESTDIR)$(man1dir)/`basename $$f`; \
|
|
|
|
done
|
|
|
|
@for f in $(MAN7PAGES); do \
|
|
|
|
echo rm -f $(DESTDIR)$(man7dir)/`basename $$f`; \
|
|
|
|
rm -f $(DESTDIR)$(man7dir)/`basename $$f`; \
|
|
|
|
done
|
|
|
|
@for f in $(DOC_DATA); do \
|
|
|
|
echo rm -f $(DESTDIR)$(docdir)/`basename $$f`; \
|
|
|
|
rm -f $(DESTDIR)$(docdir)/`basename $$f`; \
|
|
|
|
done
|
|
|
|
|
2017-12-31 02:42:27 +01:00
|
|
|
installcheck:
|
|
|
|
@rm -rf testinstall || true
|
|
|
|
$(MAKE) DESTDIR=testinstall install
|
|
|
|
testinstall$(bindir)/lightningd --test-daemons-only --lightning-dir=testinstall
|
|
|
|
$(MAKE) DESTDIR=testinstall uninstall
|
|
|
|
@if test `find testinstall '!' -type d | wc -l` -ne 0; then \
|
|
|
|
echo 'make uninstall left some files in testinstall directory!'; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@rm -rf testinstall || true
|
|
|
|
|
|
|
|
.PHONY: installdirs install-program install-data install uninstall \
|
|
|
|
installcheck
|
2017-12-06 15:12:04 +01:00
|
|
|
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-breakpoint.o: $(CCANDIR)/ccan/breakpoint/breakpoint.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-26 06:38:12 +02:00
|
|
|
ccan-tal.o: $(CCANDIR)/ccan/tal/tal.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-tal-str.o: $(CCANDIR)/ccan/tal/str/str.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2018-02-18 13:55:46 +01:00
|
|
|
ccan-tal-link.o: $(CCANDIR)/ccan/tal/link/link.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-01-21 21:11:48 +01:00
|
|
|
ccan-tal-path.o: $(CCANDIR)/ccan/tal/path/path.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-28 23:38:27 +02:00
|
|
|
ccan-tal-grab_file.o: $(CCANDIR)/ccan/tal/grab_file/grab_file.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-26 06:38:12 +02:00
|
|
|
ccan-take.o: $(CCANDIR)/ccan/take/take.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-list.o: $(CCANDIR)/ccan/list/list.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-06-14 17:25:07 +02:00
|
|
|
ccan-asort.o: $(CCANDIR)/ccan/asort/asort.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-autodata.o: $(CCANDIR)/ccan/autodata/autodata.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2018-01-22 15:49:09 +01:00
|
|
|
ccan-ptr_valid.o: $(CCANDIR)/ccan/ptr_valid/ptr_valid.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-26 06:38:12 +02:00
|
|
|
ccan-read_write_all.o: $(CCANDIR)/ccan/read_write_all/read_write_all.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-str.o: $(CCANDIR)/ccan/str/str.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-opt.o: $(CCANDIR)/ccan/opt/opt.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-opt-helpers.o: $(CCANDIR)/ccan/opt/helpers.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-opt-parse.o: $(CCANDIR)/ccan/opt/parse.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-opt-usage.o: $(CCANDIR)/ccan/opt/usage.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2018-02-16 01:26:34 +01:00
|
|
|
ccan-daemonize.o: $(CCANDIR)/ccan/daemonize/daemonize.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-26 06:38:12 +02:00
|
|
|
ccan-err.o: $(CCANDIR)/ccan/err/err.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-28 23:38:27 +02:00
|
|
|
ccan-noerr.o: $(CCANDIR)/ccan/noerr/noerr.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-05-26 06:38:12 +02:00
|
|
|
ccan-str-hex.o: $(CCANDIR)/ccan/str/hex/hex.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-crypto-hmac.o: $(CCANDIR)/ccan/crypto/hmac_sha256/hmac_sha256.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-crypto-hkdf.o: $(CCANDIR)/ccan/crypto/hkdf_sha256/hkdf_sha256.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2017-08-28 18:10:01 +02:00
|
|
|
ccan-crypto-shachain.o: $(CCANDIR)/ccan/crypto/shachain/shachain.c
|
2017-04-01 12:58:30 +02:00
|
|
|
$(CC) $(CFLAGS) -DSHACHAIN_BITS=48 -c -o $@ $<
|
2015-05-26 06:38:12 +02:00
|
|
|
ccan-crypto-sha256.o: $(CCANDIR)/ccan/crypto/sha256/sha256.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-07-09 08:13:36 +02:00
|
|
|
ccan-crypto-ripemd160.o: $(CCANDIR)/ccan/crypto/ripemd160/ripemd160.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-09-25 04:21:18 +02:00
|
|
|
ccan-cdump.o: $(CCANDIR)/ccan/cdump/cdump.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-strmap.o: $(CCANDIR)/ccan/strmap/strmap.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-06-28 23:19:20 +02:00
|
|
|
ccan-crypto-siphash24.o: $(CCANDIR)/ccan/crypto/siphash24/siphash24.c
|
2015-09-25 04:21:18 +02:00
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-htable.o: $(CCANDIR)/ccan/htable/htable.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-01-21 21:08:09 +01:00
|
|
|
ccan-ilog.o: $(CCANDIR)/ccan/ilog/ilog.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2017-01-24 14:33:15 +01:00
|
|
|
ccan-intmap.o: $(CCANDIR)/ccan/intmap/intmap.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-01-21 21:08:09 +01:00
|
|
|
ccan-isaac.o: $(CCANDIR)/ccan/isaac/isaac.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-isaac64.o: $(CCANDIR)/ccan/isaac/isaac64.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-01-21 21:08:09 +01:00
|
|
|
ccan-time.o: $(CCANDIR)/ccan/time/time.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-01-21 21:11:45 +01:00
|
|
|
ccan-timer.o: $(CCANDIR)/ccan/timer/timer.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-io-io.o: $(CCANDIR)/ccan/io/io.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-io-poll.o: $(CCANDIR)/ccan/io/poll.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-io-fdpass.o: $(CCANDIR)/ccan/io/fdpass/fdpass.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-01-21 21:11:45 +01:00
|
|
|
ccan-pipecmd.o: $(CCANDIR)/ccan/pipecmd/pipecmd.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-05-04 08:44:22 +02:00
|
|
|
ccan-mem.o: $(CCANDIR)/ccan/mem/mem.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2017-01-04 03:46:47 +01:00
|
|
|
ccan-fdpass.o: $(CCANDIR)/ccan/fdpass/fdpass.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|