external: build lowdown if not already found.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-09-06 13:40:32 +09:30 committed by neil saitug
parent 5112329a6b
commit 50d1043a91
5 changed files with 40 additions and 6 deletions

1
.gitmodules vendored
View File

@ -20,3 +20,4 @@
[submodule "external/lowdown"]
path = external/lowdown
url = https://github.com/kristapsdz/lowdown.git
ignore = dirty

9
configure vendored
View File

@ -105,7 +105,7 @@ check_command()
shift 1
echo -n "checking for $name... "
if "$@" >/dev/null 2>&1; then
if "$@" >/dev/null 2>&1 </dev/null; then
echo 'found'
return 0
fi
@ -425,6 +425,12 @@ else
HAVE_PYTHON3_MAKO=0
fi
if check_command 'lowdown' lowdown; then
HAVE_LOWDOWN=1
else
HAVE_LOWDOWN=0
fi
if echo | check_command sha256sum sha256sum; then
SHA256SUM=sha256sum
elif echo | check_command "shasum -a 256" shasum -a 256; then
@ -463,6 +469,7 @@ add_var ASAN "$ASAN"
add_var UBSAN "$UBSAN"
add_var TEST_NETWORK "$TEST_NETWORK"
add_var HAVE_PYTHON3_MAKO "$HAVE_PYTHON3_MAKO"
add_var HAVE_LOWDOWN "$HAVE_LOWDOWN"
add_var SHA256SUM "$SHA256SUM"
add_var FUZZING "$FUZZING"
add_var RUST "$RUST"

View File

@ -125,8 +125,19 @@ RBRACKET=)
$(MARKDOWN_WITH_SCHEMA): doc/lightning-%.7.md: doc/schemas/%.schema.json tools/fromschema.py
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE, "fromschema $@", tools/fromschema.py --markdownfile=$@ doc/schemas/$*.schema.json > $@.tmp && grep -v SHA256STAMP: $@.tmp > $@ && rm -f $@.tmp && $(call SHA256STAMP,[comment]: # $(LBRACKET),$(RBRACKET))); else touch $@; fi
# If we need to build lowdown, make tools/md2man.sh depend on it.
# That way it's not used in SHA256STAMP (which only uses direct
# dependencies), but make will be forced to build it.
ifeq ($(HAVE_LOWDOWN),0)
LOWDOWN := $(TARGET_DIR)/lowdown-build/bin/lowdown
tools/md2man.sh: $(LOWDOWN)
touch $@
else
LOWDOWN := lowdown
endif
$(MANPAGES): doc/%: doc/%.md tools/md2man.sh version_gen.h
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE, "md2man $<", VERSION=$(VERSION) tools/md2man.sh $< > $@ && $(call SHA256STAMP,\\\",)); else touch $@; fi
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE, "md2man $<", VERSION=$(VERSION) tools/md2man.sh $(LOWDOWN) $< > $@ && $(call SHA256STAMP,\\\",)); else touch $@; fi
$(MANPAGES): $(FORCE)
$(MARKDOWN_WITH_SCHEMA): $(FORCE)

14
external/Makefile vendored
View File

@ -6,6 +6,10 @@ SUBMODULES = \
external/libbacktrace \
external/lnprototest
ifeq ($(HAVE_LOWDOWN),0)
SUBMODULES += external/lowdown
endif
TOP := ../..
ifdef BUILD
CROSSCOMPILE_OPTS := --host="$(MAKE_HOST)" --build="$(BUILD)"
@ -29,6 +33,10 @@ LIBBACKTRACE_HEADERS := external/libbacktrace/backtrace.h
EXTERNAL_HEADERS := $(LIBSODIUM_HEADERS) $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS) $(JSMN_HEADERS) $(GHEAP_HEADERS) $(LIBBACKTRACE_HEADERS)
EXTERNAL_LIBS := ${TARGET_DIR}/libwallycore.a ${TARGET_DIR}/libsecp256k1.a ${TARGET_DIR}/libjsmn.a ${TARGET_DIR}/libbacktrace.a
ifeq ($(HAVE_LOWDOWN),0)
EXTERNAL_HEADERS += external/lowdown/lowdown.h
endif
EXTERNAL_INCLUDE_FLAGS := \
-I external/libwally-core/include/ \
-I external/libwally-core/src/secp256k1/include/ \
@ -106,6 +114,10 @@ $(TARGET_DIR)/libbacktrace.a: external/libbacktrace/backtrace.h
cd $(TARGET_DIR)/libbacktrace-build && $(TOP)/libbacktrace/configure CC="$(CC)" --enable-static=yes $(CROSSCOMPILE_OPTS) --enable-shared=no --prefix=/ --libdir=/ && $(MAKE)
$(MAKE) -C $(TARGET_DIR)/libbacktrace-build DESTDIR=$$(pwd)/$(TARGET_DIR) install-exec
$(TARGET_DIR)/lowdown-build/bin/lowdown: external/lowdown/lowdown.h
cd external/lowdown && CC="$(CC)" ./configure PREFIX=`pwd`/$(TOP)/$(TARGET_DIR)/lowdown-build/
$(MAKE) -C external/lowdown install
distclean: external-distclean
clean: external-clean
@ -116,8 +128,10 @@ external-clean:
if [ -f ${TARGET_DIR}/libwally-core-build/Makefile ]; then make -C ${TARGET_DIR}/libwally-core-build clean; fi
if [ -f ${TARGET_DIR}/libwally-core-build/src/Makefile ]; then make -C ${TARGET_DIR}/libwally-core-build/src clean; fi
if [ -f ${TARGET_DIR}/libbacktrace-build/Makefile ]; then make -C ${TARGET_DIR}/libbacktrace-build clean; fi
[ -f external/lowdown/Makefile.configure ] && $(MAKE) -C external/lowdown clean
external-distclean:
make -C external/libsodium distclean || true
[ -f external/lowdown/Makefile.configure ] && $(MAKE) -C external/lowdown distclean
$(RM) -rf ${TARGET_DIR}/libbacktrace-build ${TARGET_DIR}/libsodium-build ${TARGET_DIR}/libwally-core-build ${TARGET_DIR}/jsmn-build
$(RM) -r `git status --ignored --porcelain external/libwally-core | grep '^!! ' | cut -c3-`

View File

@ -1,10 +1,11 @@
#! /bin/sh
if [ $# != 1 ]; then
echo "Usage: $0 <markdownpage>" >&2
if [ $# != 2 ]; then
echo "Usage: $0 <lowdown> <markdownpage>" >&2
exit 1
fi
SOURCE=$1
LOWDOWN="$1"
SOURCE="$2"
SECTION="$(basename "$SOURCE" .md | cut -d. -f2-)"
TITLE="$(basename "$(basename "$SOURCE" .md)" ."$SECTION" | tr '[:lower:]' '[:upper:]')"
@ -12,4 +13,4 @@ TITLE="$(basename "$(basename "$SOURCE" .md)" ."$SECTION" | tr '[:lower:]' '[:up
# format. mrkd used to do this for us, lowdown(1) doesn't.
TITLELINE="$(head -n1 "$SOURCE")"
(echo "NAME"; echo "----"; echo "$TITLELINE"; tail -n +3 "$SOURCE") | lowdown -s --out-no-smarty -Tman -m "title:$TITLE" -m "section:$SECTION" -m "source:Core Lightning $VERSION" -m "shiftheadinglevelby:-1"
(echo "NAME"; echo "----"; echo "$TITLELINE"; tail -n +3 "$SOURCE") | $LOWDOWN -s --out-no-smarty -Tman -m "title:$TITLE" -m "section:$SECTION" -m "source:Core Lightning $VERSION" -m "shiftheadinglevelby:-1"