external: new subdirectory for all external libraries and submodules.

You will want to 'make distclean' after this.

I also removed libsecp; we use the one in in libwally anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-08-29 01:41:01 +09:30 committed by Christian Decker
parent c6976cd947
commit f42f34b82d
363 changed files with 108 additions and 20853 deletions

6
.gitmodules vendored
View file

@ -1,9 +1,9 @@
[submodule "daemon/jsmn"]
path = daemon/jsmn
path = external/jsmn
url = https://github.com/zserge/jsmn
[submodule "bitcoin/libbase58"]
path = bitcoin/libbase58
path = external/libbase58
url = https://github.com/bitcoin/libbase58.git
[submodule "libsodium"]
path = libsodium
path = external/libsodium
url = https://github.com/jedisct1/libsodium.git

View file

@ -160,28 +160,22 @@ BITCOIN_HEADERS := bitcoin/address.h \
GEN_HEADERS := gen_version.h
LIBSODIUM_HEADERS := libsodium/src/libsodium/include/sodium.h
LIBWALLY_HEADERS := libwally-core/include/wally_bip32.h \
libwally-core/include/wally_core.h \
libwally-core/include/wally_crypto.h
LIBSECP_HEADERS := libwally-core/src/secp256k1/include/secp256k1_ecdh.h \
libwally-core/src/secp256k1/include/secp256k1.h
CDUMP_OBJS := ccan-cdump.o ccan-strmap.o
WIRE_GEN := tools/generate-wire.py
PROGRAMS := $(TEST_PROGRAMS)
PROGRAMS += $(TEST_PROGRAMS)
CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition
CDEBUGFLAGS := -std=gnu11 -g -fstack-protector
CFLAGS := $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) -I libwally-core/src/secp256k1/include/ -I libwally-core/include/ -I libsodium/src/libsodium/include/ -I . $(FEATURES) $(COVFLAGS) -DSHACHAIN_BITS=48
CFLAGS = $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . $(FEATURES) $(COVFLAGS) -DSHACHAIN_BITS=48
LDFLAGS := -Lexternal
LDLIBS := -lgmp -lsqlite3 $(COVFLAGS)
$(PROGRAMS): CFLAGS+=-I.
LDLIBS = -lgmp -lsqlite3 $(COVFLAGS) $(EXTERNAL_LDLIBS)
default: $(PROGRAMS) doc-all
default: $(TEST_PROGRAMS) doc-all
include external/Makefile
include common/Makefile
include doc/Makefile
include bitcoin/Makefile
@ -197,7 +191,7 @@ CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o
$(CCAN_OBJS) $(CDUMP_OBJS) $(HELPER_OBJS) $(BITCOIN_OBJS) $(TEST_PROGRAMS:=.o) ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS)
# Except for CCAN, everything depends on bitcoin, ccan, library and common headers.
$(HELPER_OBJS) $(COMMON_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(WALLET_LIB_OBJS) $(TEST_PROGRAMS:=.o): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(GEN_HEADERS) $(LIBBASE58_HEADERS) $(LIBSODIUM_HEADERS) $(LIBWALLY_HEADERS)
$(HELPER_OBJS) $(COMMON_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(WALLET_LIB_OBJS) $(TEST_PROGRAMS:=.o): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(GEN_HEADERS) $(EXTERNAL_HEADERS)
test-protocol: test/test_protocol
set -e; TMP=`mktemp`; for f in test/commits/*.script; do if ! $(VALGRIND) test/test_protocol < $$f > $$TMP; then echo "test/test_protocol < $$f FAILED" >&2; exit 1; fi; diff -u $$TMP $$f.expected; done; rm $$TMP
@ -257,28 +251,11 @@ TAGS: FORCE
$(RM) TAGS; find * -name test -type d -prune -o -name '*.[ch]' -print | xargs etags --append
FORCE::
ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS)
ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS) $(EXTERNAL_LIBS)
# We build libsodium, since Ubuntu xenial has one too old.
libsodium.a: libsodium/src/libsodium/libsodium.la
$(MAKE) -C libsodium install-exec
PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr
libsodium/src/libsodium/include/sodium.h:
git submodule update libsodium
[ -f $@ ] || git submodule update --init libsodium
libsodium/src/libsodium/libsodium.la: libsodium/src/libsodium/include/sodium.h
cd libsodium && ./autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --enable-tests=no --libdir=`pwd`/.. && $(MAKE)
# libsecp included in libwally.
# Wildcards here are magic. See http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file
libsecp256k1.% libwallycore.%: libwally-core/src/secp256k1/libsecp256k1.la libwally-core/src/libwallycore.la
$(MAKE) -C libwally-core install-exec
libwally-core/src/libwallycore.% libwally-core/src/secp256k1/libsecp256k1.%: $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS)
cd libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --libdir=`pwd`/.. && $(MAKE)
$(TEST_PROGRAMS): % : %.o $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) common/sphinx.o common/utils.o libwallycore.a libsecp256k1.a libsodium.a
$(TEST_PROGRAMS): % : %.o $(BITCOIN_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) common/sphinx.o common/utils.o
ccan/config.h: ccan/tools/configurator/configurator
if $< > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi
@ -289,6 +266,9 @@ gen_version.h: FORCE
version.o: gen_version.h
# All binaries require the external libs
$(PROGRAMS): $(EXTERNAL_LIBS)
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)
@ -308,23 +288,14 @@ update-secp256k1:
$(RM) -r secp256k1.old
distclean: clean
$(MAKE) -C secp256k1/ distclean || true
$(RM) libsecp256k1.a secp256k1/libsecp256k1.la
$(RM) libsodium.a libsodium.la libsodium/libsodium.la
$(RM) libwallycore.a libwallycore.la
$(RM) libwally-core/src/secp256k1/libsecp256k1.la libwally-core/src/libwallycore.la
cd libwally-core && tools/cleanup.sh
maintainer-clean: distclean
@echo 'This command is intended for maintainers to use; it'
@echo 'deletes files that may need special tools to rebuild.'
clean: wire-clean
$(MAKE) -C secp256k1/ clean || true
$(RM) libsecp256k1.{a,la}
$(RM) libsodium.{a,la}
$(RM) $(PROGRAMS)
$(RM) bitcoin/*.o *.o $(PROGRAMS:=.o) $(CCAN_OBJS)
$(RM) $(TEST_PROGRAMS)
$(RM) bitcoin/*.o *.o $(TEST_PROGRAMS:=.o) $(CCAN_OBJS)
$(RM) ccan/config.h gen_*.h
$(RM) ccan/ccan/cdump/tools/cdump-enumstr.o
$(RM) check-bolt tools/check-bolt tools/*.o

View file

@ -24,19 +24,3 @@ check-whitespace: $(BITCOIN_SRC:%=check-whitespace/%) $(BITCOIN_HEADERS:%=check-
bitcoin-tests: $(BITCOIN_TEST_PROGRAMS:%=unittest/%)
LIBBASE58_HEADERS := bitcoin/libbase58/libbase58.h
LIBBASE58_SRC := bitcoin/libbase58/base58.c
# Can't be inside submodule, as that makes git think it's dirty.
LIBBASE58_OBJS := bitcoin/libbase58.o
# Wildcards trick from http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file doesn't work with no dependency, so instead make one depend on the other:
$(LIBBASE58_SRC): $(LIBBASE58_HEADERS)
$(LIBBASE58_HEADERS):
git submodule update bitcoin/libbase58/ || true
[ -f $@ ] || git submodule update --init bitcoin/libbase58/
bitcoin/libbase58.o: bitcoin/libbase58/base58.c
$(COMPILE.c) $(OUTPUT_OPTION) $<

View file

@ -5,7 +5,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "address.h"
#include "base58.h"
#include "libbase58/libbase58.h"
#include "privkey.h"
#include "pubkey.h"
#include "shadouble.h"
@ -13,6 +12,7 @@
#include <ccan/build_assert/build_assert.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <libbase58.h>
#include <secp256k1.h>
#include <string.h>

View file

@ -1,9 +1,6 @@
LIGHTNING_CLI_SRC := cli/lightning-cli.c
LIGHTNING_CLI_OBJS := $(LIGHTNING_CLI_SRC:.c=.o)
JSMN_OBJS := daemon/jsmn.o
JSMN_HEADERS := daemon/jsmn/jsmn.h
LIGHTNING_CLI_COMMON_OBJS := \
common/configdir.o \
common/json.o \
@ -11,20 +8,7 @@ LIGHTNING_CLI_COMMON_OBJS := \
lightning-cli-all: cli/lightning-cli
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)
# Git submodules are seriously broken.
daemon/jsmn/jsmn.h:
git submodule update daemon/jsmn/
[ -f $@ ] || git submodule update --init daemon/jsmn/
# If we tell Make that the above builds both, it runs it twice in
# parallel. So we lie :(
daemon/jsmn/jsmn.c: daemon/jsmn/jsmn.h
[ -f $@ ]
daemon/jsmn.o: daemon/jsmn/jsmn.c
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS) $(EXTERNAL_HEADERS)
$(LIGHTNING_CLI_OBJS) $(JSMN_OBJS): $(JSMN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS)

View file

@ -8,7 +8,7 @@
#include <stdlib.h>
#define JSMN_STRICT 1
# include "daemon/jsmn/jsmn.h"
# include <external/jsmn/jsmn.h>
struct ipaddr;
struct json_result;

1
daemon/.gitignore vendored
View file

@ -1 +0,0 @@
lightningd

View file

@ -1,93 +0,0 @@
#! /usr/bin/make
LANG=C
LC_ALL=C
LC_CTYPE=C
# Designed to be run one level up
daemon-wrongdir:
$(MAKE) -C .. daemon-all
daemon-all: daemon/lightning-cli
DAEMON_LIB_SRC := \
daemon/configdir.c \
daemon/json.c \
daemon/log.c \
daemon/pseudorand.c
DAEMON_LIB_OBJS := $(DAEMON_LIB_SRC:.c=.o)
DAEMON_SRC := \
daemon/bitcoind.c \
daemon/broadcast.c \
daemon/chaintopology.c \
daemon/dns.c \
daemon/htlc_state.c \
daemon/invoice.c \
daemon/jsonrpc.c \
daemon/netaddr.c \
daemon/options.c \
daemon/opt_time.c \
daemon/routing.c \
daemon/timeout.c \
daemon/watch.c
DAEMON_OBJS := $(DAEMON_SRC:.c=.o)
DAEMON_JSMN_OBJS := daemon/jsmn.o
DAEMON_JSMN_HEADERS := daemon/jsmn/jsmn.hb
DAEMON_GEN_HEADERS := \
daemon/gen_htlc_state_names.h
DAEMON_HEADERS := \
daemon/bitcoind.h \
daemon/broadcast.h \
daemon/chaintopology.h \
daemon/configdir.h \
daemon/dns.h \
daemon/htlc.h \
daemon/htlc_state.h \
daemon/invoice.h \
daemon/json.h \
daemon/jsonrpc.h \
daemon/lightningd.h \
daemon/log.h \
daemon/netaddr.h \
daemon/opt_time.h \
daemon/options.h \
daemon/pseudorand.h \
daemon/routing.h \
daemon/timeout.h \
daemon/watch.h
daemon/gen_feechange_state_names.h: daemon/feechange_state.h ccan/ccan/cdump/tools/cdump-enumstr
ccan/ccan/cdump/tools/cdump-enumstr daemon/feechange_state.h > $@
daemon/gen_state_names.h: daemon/state_types.h ccan/ccan/cdump/tools/cdump-enumstr
ccan/ccan/cdump/tools/cdump-enumstr daemon/state_types.h > $@
# lightning.pb-c.h doesn't create a named enum, just a typedef. Hack it.
daemon/gen_pkt_names.h: lightning.pb-c.h ccan/ccan/cdump/tools/cdump-enumstr
(echo 'enum PktCase {'; grep '^ PKT__' lightning.pb-c.h; echo '};') | ccan/ccan/cdump/tools/cdump-enumstr - | sed 's/enum PktCase/Pkt__PktCase/' > $@
$(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS): $(DAEMON_JSMN_HEADERS) $(BITCOIN_HEADERS) $(CORE_HEADERS) $(CORE_TX_HEADERS) $(GEN_HEADERS) $(DAEMON_GEN_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(WIRE_GEN_HEADERS) $(LIBSODIUM_HEADERS) $(LIBBASE58_HEADERS)
$(DAEMON_JSMN_OBJS): $(DAEMON_JSMN_HEADERS)
$(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS): CFLAGS += -USHACHAIN_BITS
check-source: $(DAEMON_SRC:%=check-src-include-order/%)
check-source: $(DAEMON_LIB_SRC:%=check-src-include-order/%)
check-source: $(DAEMON_CLI_SRC:%=check-src-include-order/%)
check-source: $(DAEMON_HEADERS:%=check-hdr-include-order/%)
check-source-bolt: $(DAEMON_SRC:%=bolt-check/%) $(DAEMON_HEADERS:%=bolt-check/%)
check-whitespace: $(DAEMON_SRC:%=check-whitespace/%) $(DAEMON_HEADERS:%=check-whitespace/%) check-whitespace/daemon/Makefile
daemon/lightning-cli: $(DAEMON_CLI_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_JSMN_OBJS) $(CORE_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) libsecp256k1.a libsodium.a
daemon-clean:
$(RM) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS) $(DAEMON_JSMN_OBJS) $(DAEMON_GEN_HEADERS)
daemon-maintainer-clean:

82
external/Makefile vendored Normal file
View file

@ -0,0 +1,82 @@
LIBSODIUM_HEADERS := external/libsodium/src/libsodium/include/sodium.h
LIBWALLY_HEADERS := external/libwally-core/include/wally_bip32.h \
external/libwally-core/include/wally_core.h \
external/libwally-core/include/wally_crypto.h
LIBSECP_HEADERS := external/libwally-core/src/secp256k1/include/secp256k1_ecdh.h \
external/libwally-core/src/secp256k1/include/secp256k1.h
JSMN_HEADERS := external/jsmn/jsmn.h
LIBBASE58_HEADERS := external/libbase58/libbase58.h
EXTERNAL_HEADERS := $(LIBSODIUM_HEADERS) $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS) $(JSMN_HEADERS) $(LIBBASE58_HEADERS)
EXTERNAL_LIBS := external/libwallycore.a external/libsecp256k1.a external/libsodium.a external/libjsmn.a external/libbase58.a
EXTERNAL_INCLUDE_FLAGS := \
-I external/libsodium/src/libsodium/include \
-I external/libwally-core/include/ \
-I external/libwally-core/src/secp256k1/include/ \
-I external/jsmn/ \
-I external/libbase58/
EXTERNAL_LDLIBS := -Lexternal $(patsubst lib%.a,-l%, $(notdir $(EXTERNAL_LIBS)))
# We build libsodium, since Ubuntu xenial has one too old.
external/libsodium.a: external/libsodium/src/libsodium/libsodium.la
$(MAKE) -C external/libsodium install-exec
external/libsodium/src/libsodium/include/sodium.h:
git submodule update external/libsodium
[ -f $@ ] || git submodule update --init external/libsodium
external/libsodium/src/libsodium/libsodium.la: external/libsodium/src/libsodium/include/sodium.h
cd external/libsodium && ./autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --enable-tests=no --libdir=`pwd`/.. && $(MAKE)
# libsecp included in libwally.
# Wildcards here are magic. See http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file
external/libsecp256k1.% external/libwallycore.%: external/libwally-core/src/secp256k1/libsecp256k1.la external/libwally-core/src/libwallycore.la
$(MAKE) -C external/libwally-core install-exec
external/libwally-core/src/libwallycore.% external/libwally-core/src/secp256k1/libsecp256k1.%: $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS)
cd external/libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --libdir=`pwd`/.. && $(MAKE)
# Git submodules are seriously broken.
external/jsmn/jsmn.h:
git submodule update external/jsmn/
[ -f $@ ] || git submodule update --init external/jsmn/
# If we tell Make that the above builds both, it runs it twice in
# parallel. So we lie :(
external/jsmn/jsmn.c: external/jsmn/jsmn.h
[ -f $@ ]
external/jsmn.o: external/jsmn/jsmn.c
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<
external/libjsmn.a: external/jsmn.o
$(AR) rc $@ $<
LIBBASE58_SRC := external/libbase58/base58.c
$(LIBBASE58_SRC): $(LIBBASE58_HEADERS)
$(LIBBASE58_HEADERS):
git submodule update external/libbase58/ || true
[ -f $@ ] || git submodule update --init external/libbase58/
# Can't be inside submodule, as that makes git think it's dirty.
external/base58.o: $(LIBBASE58_SRC)
$(COMPILE.c) $(OUTPUT_OPTION) $<
external/libbase58.a: external/base58.o
$(AR) rc $@ $<
distclean: external-distclean
clean: external-clean
external-clean:
$(RM) $(EXTERNAL_LIBS)
external-distclean:
make -C external/libsodium distclean || true
make -C external/libbase64 distclean || true
$(RM) external/libsodium.la external/libsodium/src/libsodium/libsodium.la
$(RM) external/libwally-core/src/secp256k1/libsecp256k1.la external/libwally-core/src/libwallycore.la
cd external/libwally-core && tools/cleanup.sh

View file

View file

Some files were not shown because too many files have changed in this diff Show more