Skip to content

Commit

Permalink
external: new subdirectory for all external libraries and submodules.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Aug 29, 2017
1 parent c6976cd commit f42f34b
Show file tree
Hide file tree
Showing 363 changed files with 108 additions and 20,853 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
59 changes: 15 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

# We build libsodium, since Ubuntu xenial has one too old.
libsodium.a: libsodium/src/libsodium/libsodium.la
$(MAKE) -C libsodium install-exec

libsodium/src/libsodium/include/sodium.h:
git submodule update libsodium
[ -f $@ ] || git submodule update --init libsodium
ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS) $(EXTERNAL_LIBS)

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)
PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr

# 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
Expand All @@ -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)
Expand All @@ -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
Expand Down
16 changes: 0 additions & 16 deletions bitcoin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) $<
2 changes: 1 addition & 1 deletion bitcoin/base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
// 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"
#include <assert.h>
#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>

Expand Down
18 changes: 1 addition & 17 deletions cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
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 \
common/version.o

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)

Expand Down
2 changes: 1 addition & 1 deletion common/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion daemon/.gitignore

This file was deleted.

93 changes: 0 additions & 93 deletions daemon/Makefile

This file was deleted.

82 changes: 82 additions & 0 deletions external/Makefile
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f42f34b

Please sign in to comment.