osmo-gsm-manuals/build/Makefile.asciidoc.inc

103 lines
3.7 KiB
PHP
Raw Normal View History

# USAGE:
#
# - define 'OSMO_GSM_MANUALS_DIR' to point at the osmo-gsm-manuals shared files
# installation path as returned by "pkg-config osmo-gsm-manuals --variable=osmogsmmanualsdir"
# (project specific repos set this with configure.ac),
# - define in 'ASCIIDOC' all root .adoc files,
# - optionally define in 'ASCIIDOC_DEPS' all dependencies common to all .adocs,
# - include this file,
# - optionally define further dependencies for individual .pdf targets.
#
# e.g.
#
# OSMO_GSM_MANUALS_DIR = ..
# ASCIIDOC = osmo_yada.adoc osmo_moo.adoc
# ASCIIDOC_DEPS = $(srcdir)/for_all/*.adoc
# include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.asciidoc.inc
# osmo_yada.pdf: yada/*.adoc yada/*.msc
BUILDDIR = $(OSMO_GSM_MANUALS_DIR)/build
COMMONDIR = $(OSMO_GSM_MANUALS_DIR)/common
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
GIT_DATE := $(shell $(OSMO_GSM_MANUALS_DIR)/build/unix-time-to-fmt.py `git log -n 1 "--pretty=%at" ../.`)
# prepend the document name with the version numbe suffix
#DOCS_VER = $(foreach P, $(ASCIIDOC_NAME), $(P)-v$(shell xmllint --recover --xpath "//revnumber[position()=last()]/text()" $(P)-docinfo.xml 2>/dev/null))
#PDFS = $(DOCS_VER:%=%.pdf)
# generate list of PDFs that we're supposed to render
ASCIIDOC_NAME = $(patsubst %.adoc,%,$(ASCIIDOC))
ASCIIDOC_PDF = $(ASCIIDOC_NAME:%=%.pdf)
ASCIIDOC_CHECKS = $(ASCIIDOC_NAME:%=%.check)
ASCIIDOCSTYLE ?= $(BUILDDIR)/custom-dblatex.sty
CLEAN_FILES += $(ASCIIDOC_NAME:%=%__*.png) $(ASCIIDOC_NAME:%=%__*.svg) $(ASCIIDOC_CHECKS)
CLEAN_FILES += $(ASCIIDOC_PDF) $(ASCIIDOC_NAME:%=%.html)
UPLOAD_FILES += $(ASCIIDOC_PDF)
fix srcdir to reflect $abs_srcdir When building .adoc files, we pass a srcdir variable to allow including files that are only in the source tree, but not in the build tree. However, so far {srcdir} is a relative path, and when an .adoc file includes an .adoc file in a subdir, then the directive include::{srcdir} is evaluated relative to the .adoc file in the subdir, not in the original make CWD. Hence the path ends up pointing at the wrong place. Fix this by passing an absolute path as srcdir instead. I discovered this here: osmo-hlr/doc/manuals/osmohlr-usermanual.adoc: include::{srcdir}/chapters/proxy_cache.adoc[] osmo-hlr/doc/manuals/chapters/proxy_cache.adoc: ["mscgen"] ---- include::{srcdir}/chapters/proxy_cache_attach.msc[] ---- (Note that I could have just removed "{srcdir}/chapters/" since .adoc and .msc are in the same dir, but the point of this patch is to make {srcdir} generally useful in all levels of included .adoc files.) The above resulted in: asciidoc: include: /n/s/dev/src/osmo-hlr/doc/manuals/chapters/proxy_cache.adoc asciidoc: osmohlr-usermanual.adoc: line 29: reading: /n/s/dev/src/osmo-hlr/doc/manuals/chapters/proxy_cache.adoc asciidoc: WARNING: proxy_cache.adoc: line 263: include file not found: /n/s/dev/src/src/osmo-hlr/doc/manuals/chapters/proxy_cache_attach.msc Note that /n/s/dev/src/src/osmo-hlr should only have one 'src' element. With $abs_srcdir this becomes: asciidoc: include: /n/s/dev/make/osmo-hlr/../../src/osmo-hlr/doc/manuals/chapters/proxy_cache.adoc asciidoc: osmohlr-usermanual.adoc: line 29: reading: /n/s/dev/make/osmo-hlr/../../src/osmo-hlr/doc/manuals/chapters/proxy_cache.adoc asciidoc: include: /n/s/dev/make/osmo-hlr/../../src/osmo-hlr/doc/manuals/chapters/proxy_cache_attach.msc asciidoc: proxy_cache.adoc: line 263: reading: /n/s/dev/make/osmo-hlr/../../src/osmo-hlr/doc/manuals/chapters/proxy_cache_attach.msc I have not investigated whether/why all the other 'include::' all over the place seem to be working -- maybe we never include .adoc in subdirectories that in turn use {srcdir}? Or we have lots of missing images we didn't notice yet? Todo: the missing include should have fatally broken the build, but it just builds the PDF with missing images. a) the mscgen plugin finding empty content and b) the missing .png files should have caused the build to abort? Change-Id: If847f16eab3ddba6009f67ed641b48805467eb1b
2020-01-24 04:00:32 +00:00
ASCIIDOC_OPTS := -f $(BUILDDIR)/mscgen-filter.conf -f $(BUILDDIR)/diag-filter.conf -f $(BUILDDIR)/docinfo-releaseinfo.conf -a srcdir='$(abs_srcdir)' -a commondir='$(COMMONDIR)'
DBLATEX_OPTS := -s $(ASCIIDOCSTYLE) -P draft.mode=yes -P draft.watermark=0
ifeq (,$(BUILD_RELEASE))
REVNUMBER := DRAFT $(GIT_VERSION)
else
REVNUMBER := $(GIT_VERSION)
endif
A2X_OPTS := -L --asciidoc-opts="$(ASCIIDOC_OPTS)" --dblatex-opts="$(DBLATEX_OPTS)" -a docinfo -a revnumber="$(REVNUMBER)" -a revdate="$(GIT_DATE)"
all: $(ASCIIDOC_PDF)
$(ASCIIDOC_PDF): %.pdf: %.adoc %-docinfo.xml \
$(ASCIIDOC_DEPS) \
$(ASCIIDOCSTYLE) \
$(COMMONDIR)/*/*.adoc \
$(COMMONDIR)/images/* \
build common
# a2x can't use a different output file. To support out-of-tree builds,
# we create a symlink at $(builddir)/srcfile.adoc pointing at
# $(srcdir)/srcfile.adoc. $< is the $(srcdir)/srcfile.adoc,
# $(notdir) is like basename from coreutils, and $(builddir) is $PWD.
if ! [ -f $(notdir $<) ]; then \
ln -s $< $(notdir $<); \
fi
# TEXINPUTS: find LaTeX includes like \includegraphics{./common/images/sysmocom.pdf}
# in $(OSMO_GSM_MANUALS_DIR).
@test -n "$(BUILD_RELEASE)" && echo -e "\n\n\
NOTE: TO REMOVE DRAFT MODE, YOU NEED TO EDIT build/custom-dblatex.sty\n\
and remove three lines starting with '% \"DRAFT\" on first page'\n" \
|| true
TEXINPUTS="$(OSMO_GSM_MANUALS_DIR)" \
a2x -vv $(A2X_OPTS) $(notdir $<)
check:
if [ -n "$$ASCIIDOC_WARNINGS_CHECK" ]; then \
$(MAKE) $(ASCIIDOC_CHECKS); \
fi
$(ASCIIDOC_CHECKS): %.check: %.adoc %-docinfo.xml \
$(ASCIIDOCSTYLE) \
$(COMMONDIR)/chapters/*.adoc \
$(ASCIIDOC_DEPS) \
build common
# out-of-tree building: use a symlink to the output file like done in
# the non-check build above, so the relative include paths work the
# same.
if ! [ -f $(notdir $<) ]; then \
ln -s $< $(notdir $<); \
fi
asciidoc -v $(ASCIIDOC_OPTS) $(notdir $<) > $(notdir $@) 2>&1
# Make absolutely sure that the %.check target is updated.
touch $(notdir $@)
# Do print the WARNING output but return error if any was found
# (grep -v would omit the WARNING output from the log).
@grep WARNING $(notdir $@) && exit 1 || exit 0