2018-06-06 05:33:27 +02:00
|
|
|
SUBMODULES = \
|
|
|
|
external/libsodium \
|
|
|
|
external/libwally-core \
|
|
|
|
external/jsmn \
|
|
|
|
external/libbacktrace
|
|
|
|
|
2017-08-28 18:11:01 +02:00
|
|
|
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
|
|
|
|
|
2019-04-30 23:07:31 +02:00
|
|
|
EXTERNAL_HEADERS := $(LIBSODIUM_HEADERS) $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS) $(JSMN_HEADERS)
|
2019-02-08 00:11:59 +01:00
|
|
|
EXTERNAL_LIBS := external/libwallycore.a external/libsecp256k1.a external/libjsmn.a external/libbacktrace.a
|
2017-08-28 18:11:01 +02:00
|
|
|
|
|
|
|
EXTERNAL_INCLUDE_FLAGS := \
|
|
|
|
-I external/libwally-core/include/ \
|
|
|
|
-I external/libwally-core/src/secp256k1/include/ \
|
|
|
|
-I external/jsmn/ \
|
2018-03-22 08:10:23 +01:00
|
|
|
-I external/libbacktrace/ \
|
|
|
|
-I external/libbacktrace-build
|
2017-08-28 18:13:01 +02:00
|
|
|
|
2019-02-07 21:36:50 +01:00
|
|
|
ifneq ($(HAVE_GOOD_LIBSODIUM),1)
|
|
|
|
EXTERNAL_INCLUDE_FLAGS += -I external/libsodium/src/libsodium/include
|
|
|
|
EXTERNAL_LIBS += external/libsodium.a
|
|
|
|
else
|
|
|
|
LDLIBS += -lsodium
|
|
|
|
endif
|
|
|
|
|
2017-08-28 18:13:01 +02:00
|
|
|
EXTERNAL_LDLIBS := -Lexternal $(patsubst lib%.a,-l%,$(notdir $(EXTERNAL_LIBS)))
|
2017-08-28 18:11:01 +02:00
|
|
|
|
2018-06-06 05:33:27 +02:00
|
|
|
submodcheck: FORCE
|
|
|
|
@tools/refresh-submodules.sh $(SUBMODULES)
|
2018-01-29 05:30:53 +01:00
|
|
|
|
2017-08-28 18:11:01 +02:00
|
|
|
# We build libsodium, since Ubuntu xenial has one too old.
|
|
|
|
external/libsodium.a: external/libsodium/src/libsodium/libsodium.la
|
2018-02-27 19:32:55 +01:00
|
|
|
$(MAKE) -C external/libsodium DESTDIR=$$(pwd)/external install-exec
|
2017-08-28 18:11:01 +02:00
|
|
|
|
2018-06-06 05:33:27 +02:00
|
|
|
external/libsodium/src/libsodium/include/sodium.h: submodcheck
|
2017-08-28 18:11:01 +02:00
|
|
|
|
|
|
|
external/libsodium/src/libsodium/libsodium.la: external/libsodium/src/libsodium/include/sodium.h
|
2018-05-17 21:20:03 +02:00
|
|
|
cd external/libsodium && ./autogen.sh && ./configure CC="$(CC)" --enable-static=yes --host="$(MAKE_HOST)" --build="$(BUILD)" --enable-shared=no --enable-tests=no --prefix=/ --libdir=/ && $(MAKE)
|
2017-08-28 18:11:01 +02:00
|
|
|
|
2018-06-06 05:33:27 +02:00
|
|
|
$(LIBWALLY_HEADERS) $(LIBSECP_HEADERS): submodcheck
|
2018-01-28 03:01:24 +01:00
|
|
|
|
2017-08-28 18:11:01 +02:00
|
|
|
# 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
|
2018-02-27 19:32:55 +01:00
|
|
|
$(MAKE) -C external/libwally-core DESTDIR=$$(pwd)/external install-exec
|
2017-08-28 18:11:01 +02:00
|
|
|
|
|
|
|
external/libwally-core/src/libwallycore.% external/libwally-core/src/secp256k1/libsecp256k1.%: $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS)
|
2018-05-17 21:20:03 +02:00
|
|
|
cd external/libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --host="$(MAKE_HOST)" --build="$(BUILD)" --enable-module-recovery --enable-shared=no --prefix=/ --libdir=/ && $(MAKE)
|
2017-08-28 18:11:01 +02:00
|
|
|
|
2018-06-06 05:33:27 +02:00
|
|
|
external/jsmn/jsmn.h: submodcheck
|
2017-08-28 18:11:01 +02:00
|
|
|
|
|
|
|
# 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 $@ ]
|
|
|
|
|
2018-01-20 05:27:13 +01:00
|
|
|
external/jsmn.o: external/jsmn/jsmn.c Makefile
|
2017-08-28 18:11:01 +02:00
|
|
|
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
external/libjsmn.a: external/jsmn.o
|
|
|
|
$(AR) rc $@ $<
|
|
|
|
|
2018-06-06 05:33:27 +02:00
|
|
|
external/libbacktrace/backtrace.h: submodcheck
|
2017-09-12 06:56:26 +02:00
|
|
|
|
|
|
|
# Need separate build dir: changes inside submodule make git think it's dirty.
|
|
|
|
external/libbacktrace.a: external/libbacktrace/backtrace.h
|
|
|
|
@mkdir external/libbacktrace-build 2>/dev/null || true
|
2018-05-17 21:20:03 +02:00
|
|
|
cd external/libbacktrace-build && ../libbacktrace/configure CC="$(CC)" --enable-static=yes --host="$(MAKE_HOST)" --build="$(BUILD)" --enable-shared=no --prefix=/ --libdir=/ && $(MAKE)
|
2018-02-27 19:32:55 +01:00
|
|
|
$(MAKE) -C external/libbacktrace-build DESTDIR=$$(pwd)/external install-exec
|
2017-09-12 06:56:26 +02:00
|
|
|
|
2017-08-28 18:11:01 +02:00
|
|
|
distclean: external-distclean
|
|
|
|
clean: external-clean
|
|
|
|
|
|
|
|
external-clean:
|
2017-11-23 04:03:07 +01:00
|
|
|
$(RM) $(EXTERNAL_LIBS) external/*.la external/*.o
|
2018-02-28 10:30:40 +01:00
|
|
|
if [ -f external/libsodium/Makefile ]; then make -C external/libsodium clean; fi
|
|
|
|
if [ -f external/libwally-core/Makefile ]; then make -C external/libwally-core clean; fi
|
|
|
|
if [ -f external/ibwally-core/src/Makefile ]; then make -C external/libwally-core/src clean; fi
|
2017-08-28 18:11:01 +02:00
|
|
|
|
|
|
|
external-distclean:
|
|
|
|
make -C external/libsodium distclean || true
|
2017-09-12 06:56:26 +02:00
|
|
|
$(RM) -rf external/libbacktrace-build
|
2017-11-23 04:03:07 +01:00
|
|
|
$(RM) external/libsodium/src/libsodium/libsodium.la
|
2017-08-28 18:11:01 +02:00
|
|
|
$(RM) external/libwally-core/src/secp256k1/libsecp256k1.la external/libwally-core/src/libwallycore.la
|
2017-11-23 04:03:07 +01:00
|
|
|
$(RM) -r `git status --ignored --porcelain external/libwally-core | grep '^!! ' | cut -c3-`
|