2015-05-26 06:38:12 +02:00
|
|
|
#! /usr/bin/make
|
2015-08-08 13:15:49 +02:00
|
|
|
NAME=MtGox's Cold Wallet
|
2015-05-26 06:38:12 +02:00
|
|
|
|
|
|
|
# Needs to have oneof support: Ubuntu vivid's is too old :(
|
|
|
|
PROTOCC:=protoc-c
|
|
|
|
|
2015-08-07 05:15:30 +02:00
|
|
|
# Alpha has checksequenceverify, segregated witness+input-amount-in-sig+confidentual-transactions, schnorr, checklocktimeverify
|
|
|
|
FEATURES := -DHAS_CSV=1 -DALPHA_TXSTYLE=1 -DUSE_SCHNORR=1 -DHAS_CLTV=1
|
2015-09-30 03:24:11 +02:00
|
|
|
# Bitcoin uses DER for signatures (Add BIP68 if it's supported)
|
|
|
|
#FEATURES := -DSCRIPTS_USE_DER #-DHAS_BIP68
|
2015-06-25 06:20:16 +02:00
|
|
|
|
2015-09-24 07:33:20 +02:00
|
|
|
TEST_CLI_PROGRAMS := \
|
|
|
|
test-cli/check-commit-sig \
|
|
|
|
test-cli/close-channel \
|
|
|
|
test-cli/create-anchor-tx \
|
|
|
|
test-cli/create-close-tx \
|
|
|
|
test-cli/create-commit-spend-tx \
|
|
|
|
test-cli/create-commit-tx \
|
|
|
|
test-cli/create-htlc-spend-tx \
|
|
|
|
test-cli/create-steal-tx \
|
|
|
|
test-cli/get-anchor-depth \
|
|
|
|
test-cli/open-anchor \
|
|
|
|
test-cli/open-channel \
|
|
|
|
test-cli/open-commit-sig \
|
|
|
|
test-cli/txid-of \
|
|
|
|
test-cli/update-channel \
|
|
|
|
test-cli/update-channel-accept \
|
|
|
|
test-cli/update-channel-complete \
|
|
|
|
test-cli/update-channel-htlc \
|
|
|
|
test-cli/update-channel-htlc-complete \
|
|
|
|
test-cli/update-channel-htlc-remove \
|
|
|
|
test-cli/update-channel-signature
|
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
TEST_PROGRAMS := \
|
2015-09-30 03:24:55 +02:00
|
|
|
test/test_state_coverage \
|
|
|
|
test/test_onion
|
2015-09-25 04:21:18 +02:00
|
|
|
|
2015-09-24 07:33:20 +02:00
|
|
|
BITCOIN_OBJS := \
|
|
|
|
bitcoin/address.o \
|
|
|
|
bitcoin/base58.o \
|
|
|
|
bitcoin/pubkey.o \
|
|
|
|
bitcoin/script.o \
|
|
|
|
bitcoin/shadouble.o \
|
|
|
|
bitcoin/signature.o \
|
|
|
|
bitcoin/tx.o
|
|
|
|
|
|
|
|
HELPER_OBJS := \
|
|
|
|
close_tx.o \
|
|
|
|
commit_tx.o \
|
|
|
|
find_p2sh_out.o \
|
|
|
|
funding.o \
|
|
|
|
lightning.pb-c.o \
|
|
|
|
opt_bits.o \
|
|
|
|
permute_tx.o \
|
|
|
|
pkt.o \
|
|
|
|
protobuf_convert.o \
|
|
|
|
test-cli/gather_updates.o \
|
|
|
|
version.o
|
|
|
|
|
|
|
|
CCAN_OBJS := \
|
|
|
|
ccan-crypto-ripemd160.o \
|
|
|
|
ccan-crypto-sha256.o \
|
|
|
|
ccan-crypto-shachain.o \
|
|
|
|
ccan-err.o \
|
|
|
|
ccan-list.o \
|
|
|
|
ccan-noerr.o \
|
|
|
|
ccan-opt-helpers.o \
|
|
|
|
ccan-opt-parse.o \
|
|
|
|
ccan-opt-usage.o \
|
|
|
|
ccan-opt.o \
|
|
|
|
ccan-read_write_all.o \
|
|
|
|
ccan-str-hex.o \
|
|
|
|
ccan-str.o \
|
|
|
|
ccan-take.o \
|
|
|
|
ccan-tal-grab_file.o \
|
|
|
|
ccan-tal-str.o \
|
|
|
|
ccan-tal.o
|
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
# For tests
|
|
|
|
CCAN_EXTRA_OBJS := \
|
|
|
|
ccan-hash.o \
|
|
|
|
ccan-htable.o
|
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
CDUMP_OBJS := ccan-cdump.o ccan-strmap.o
|
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
PROGRAMS := $(TEST_CLI_PROGRAMS) $(TEST_PROGRAMS)
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
HEADERS := $(filter-out gen_*, $(wildcard *.h)) $(wildcard bitcoin/*.h) gen_state_names.h
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2015-06-12 05:59:06 +02:00
|
|
|
CCANDIR := ccan/
|
2015-06-26 04:24:07 +02:00
|
|
|
CFLAGS := -g -Wall -I $(CCANDIR) -I secp256k1/include/ -DVALGRIND_HEADERS=1 $(FEATURES)
|
2015-05-26 06:38:12 +02:00
|
|
|
LDLIBS := -lcrypto -lprotobuf-c
|
2015-06-12 04:49:59 +02:00
|
|
|
$(PROGRAMS): CFLAGS+=-I.
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2015-05-28 23:38:27 +02:00
|
|
|
default: $(PROGRAMS)
|
2015-05-26 06:38:12 +02:00
|
|
|
|
2015-09-29 09:32:02 +02:00
|
|
|
# These don't work in parallel, so we open-code them
|
|
|
|
test-cli-tests: $(TEST_CLI_PROGRAMS)
|
|
|
|
cd test-cli; scripts/shutdown.sh 2>/dev/null || true
|
|
|
|
set -e; cd test-cli; for args in "" --steal --unilateral --htlc-onchain; do scripts/setup.sh && scripts/test.sh $$args && scripts/shutdown.sh; done
|
|
|
|
|
2015-09-30 03:24:55 +02:00
|
|
|
test-onion: test/test_onion
|
|
|
|
set -e; for i in `seq 20`; do ./test/test_onion $$i; done
|
|
|
|
|
|
|
|
check: test-cli-tests test-onion
|
2015-09-29 09:32:02 +02:00
|
|
|
|
|
|
|
full-check: check $(TEST_PROGRAMS)
|
|
|
|
test/test_state_coverage
|
|
|
|
|
2015-06-04 08:16:39 +02:00
|
|
|
TAGS: FORCE
|
2015-06-12 05:14:31 +02:00
|
|
|
$(RM) TAGS; find . -name '*.[ch]' | xargs etags --append
|
2015-06-04 08:16:39 +02:00
|
|
|
FORCE::
|
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS)
|
|
|
|
|
|
|
|
gen_state_names.h: state_types.h ccan/ccan/cdump/tools/cdump-enumstr
|
|
|
|
ccan/ccan/cdump/tools/cdump-enumstr state_types.h > $@
|
|
|
|
|
2015-06-25 07:32:50 +02:00
|
|
|
# We build a static libsecpk1, since we need schnorr for alpha
|
|
|
|
# (and it's not API stable yet!).
|
2015-09-30 03:24:54 +02:00
|
|
|
libsecp256k1.a: secp256k1/libsecp256k1.la
|
|
|
|
|
|
|
|
secp256k1/libsecp256k1.la:
|
2015-09-30 03:24:55 +02:00
|
|
|
cd secp256k1 && ./autogen.sh && ./configure --enable-static=yes --enable-shared=no --enable-tests=no --enable-module-schnorr=yes --enable-module-ecdh=yes --libdir=`pwd`/..
|
2015-06-25 07:32:50 +02:00
|
|
|
$(MAKE) -C secp256k1 install-exec
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
lightning.pb-c.c lightning.pb-c.h: lightning.proto
|
|
|
|
$(PROTOCC) lightning.proto --c_out=.
|
|
|
|
|
2015-09-24 07:33:20 +02:00
|
|
|
$(TEST_CLI_PROGRAMS): % : %.o $(HELPER_OBJS) $(BITCOIN_OBJS) $(CCAN_OBJS) libsecp256k1.a
|
2015-09-25 04:21:18 +02:00
|
|
|
$(TEST_PROGRAMS): % : %.o $(BITCOIN_OBJS) $(CCAN_OBJS) $(CCAN_EXTRA_OBJS) version.o libsecp256k1.a
|
2015-06-05 03:35:05 +02:00
|
|
|
$(PROGRAMS:=.o) $(HELPER_OBJS): $(HEADERS)
|
2015-06-04 06:18:11 +02:00
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
$(CCAN_OBJS) $(HELPER_OBJS) $(PROGRAM_OBJS) $(BITCOIN_OBJS) $(CDUMP_OBJS): ccan/config.h
|
2015-06-12 05:59:06 +02:00
|
|
|
|
|
|
|
ccan/config.h: ccan/tools/configurator/configurator
|
|
|
|
$< > $@
|
|
|
|
|
2015-07-18 03:16:01 +02:00
|
|
|
doc/deployable-lightning.pdf: doc/deployable-lightning.lyx doc/bitcoin.bib
|
|
|
|
lyx -E pdf $@ $<
|
|
|
|
|
|
|
|
doc/deployable-lightning.tex: doc/deployable-lightning.lyx
|
|
|
|
lyx -E latex $@ $<
|
|
|
|
|
2015-09-25 04:21:18 +02:00
|
|
|
state-diagrams: doc/normal-states.svg doc/simplified-states.svg doc/error-states.svg doc/full-states.svg
|
|
|
|
|
|
|
|
%.svg: %.dot
|
|
|
|
dot -Tsvg $< > $@ || (rm -f $@; false)
|
|
|
|
|
|
|
|
doc/simplified-states.dot: test/test_state_coverage
|
|
|
|
test/test_state_coverage --dot --dot-simplify > $@
|
|
|
|
|
|
|
|
doc/normal-states.dot: test/test_state_coverage
|
|
|
|
test/test_state_coverage --dot > $@
|
|
|
|
|
|
|
|
doc/error-states.dot: test/test_state_coverage
|
|
|
|
test/test_state_coverage --dot-all --dot-include-errors > $@
|
|
|
|
|
|
|
|
doc/full-states.dot: test/test_state_coverage
|
|
|
|
test/test_state_coverage --dot-all --dot-include-errors --dot-include-nops > $@
|
|
|
|
|
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
|
|
|
|
@if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; fi
|
|
|
|
|
|
|
|
version.o: gen_version.h
|
|
|
|
|
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
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
distclean: clean
|
2015-09-30 03:24:54 +02:00
|
|
|
$(MAKE) -C secp256k1/ distclean || true
|
|
|
|
$(RM) libsecp256k1.a
|
2015-09-30 07:19:42 +02:00
|
|
|
|
|
|
|
maintainter-clean: distclean
|
|
|
|
@echo 'This command is intended for maintainers to use; it'
|
|
|
|
@echo 'deletes files that may need special tools to rebuild.'
|
2015-08-08 13:15:49 +02:00
|
|
|
$(RM) lightning.pb-c.c lightning.pb-c.h ccan/config.h gen_version.h
|
2015-07-18 03:16:01 +02:00
|
|
|
$(RM) doc/deployable-lightning.pdf
|
2015-05-26 06:38:12 +02:00
|
|
|
|
|
|
|
clean:
|
2015-09-30 03:24:54 +02:00
|
|
|
$(MAKE) -C secp256k1/ clean || true
|
|
|
|
$(RM) libsecp256k1.{a,la}
|
2015-07-03 06:30:54 +02:00
|
|
|
$(RM) $(PROGRAMS) test-cli/leak-anchor-sigs
|
2015-09-25 04:21:18 +02:00
|
|
|
$(RM) bitcoin/*.o *.o $(PROGRAMS:=.o) $(CCAN_OBJS) $(CCAN_EXTRA_OBJS)
|
2015-07-18 03:16:01 +02:00
|
|
|
$(RM) doc/deployable-lightning.{aux,bbl,blg,dvi,log,out,tex}
|
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 $@ $<
|
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 $@ $<
|
|
|
|
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 $@ $<
|
|
|
|
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 $@ $<
|
|
|
|
ccan-crypto-shachain.o: $(CCANDIR)/ccan/crypto/shachain/shachain.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
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 $@ $<
|
2015-09-25 04:21:18 +02:00
|
|
|
ccan-hash.o: $(CCANDIR)/ccan/hash/hash.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
ccan-htable.o: $(CCANDIR)/ccan/htable/htable.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2015-07-09 08:13:36 +02:00
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
|