Skip to content

Commit

Permalink
external: make submodule hacks more general, and common.
Browse files Browse the repository at this point in the history
We can't rely on the existence or not of a header, as Carl's
delete-and-make-submodule change showed.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jan 29, 2018
1 parent e624046 commit 7db88f0
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ EXTERNAL_INCLUDE_FLAGS := \

EXTERNAL_LDLIBS := -Lexternal $(patsubst lib%.a,-l%,$(notdir $(EXTERNAL_LIBS)))

# Might exist, but need updating. Nuke and rebuild.
submodcheck-%: FORCE
if git submodule status external/$* | grep -q '^[-+]'; then rm -rf external/$*; git submodule update --init external/$*; fi

# 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/include/sodium.h: submodcheck-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)

$(LIBWALLY_HEADERS) $(LIBSECP_HEADERS):
git submodule update external/libwally-core
[ -f $@ ] || git submodule update --init external/libwally-core
$(LIBWALLY_HEADERS) $(LIBSECP_HEADERS): submodcheck-libwally-core

# 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
Expand All @@ -43,10 +43,7 @@ external/libsecp256k1.% external/libwallycore.%: external/libwally-core/src/secp
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-module-recovery --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/
external/jsmn/jsmn.h: submodcheck-jsmn

# If we tell Make that the above builds both, it runs it twice in
# parallel. So we lie :(
Expand All @@ -63,9 +60,7 @@ 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/
$(LIBBASE58_HEADERS): submodcheck-libbase58

# Can't be inside submodule, as that makes git think it's dirty.
external/base58.o: $(LIBBASE58_SRC) Makefile
Expand All @@ -74,9 +69,7 @@ external/base58.o: $(LIBBASE58_SRC) Makefile
external/libbase58.a: external/base58.o
$(AR) rc $@ $<

external/libbacktrace/backtrace.h:
git submodule update external/libbacktrace/
[ -f $@ ] || git submodule update --init external/libbacktrace/
external/libbacktrace/backtrace.h: submodcheck-libbacktrace

# Need separate build dir: changes inside submodule make git think it's dirty.
external/libbacktrace.a: external/libbacktrace/backtrace.h
Expand Down

0 comments on commit 7db88f0

Please sign in to comment.