2024-10-03 17:18:00 +02:00
|
|
|
MAKEFLAGS += --silent
|
2023-07-02 11:43:38 +02:00
|
|
|
PANDOC=pandoc
|
|
|
|
PANDOCOK := $(shell command -v ${PANDOC} 2> /dev/null)
|
2024-10-03 17:18:00 +02:00
|
|
|
PANDOCMINVER=3.1.7
|
2020-01-08 11:19:54 +01:00
|
|
|
|
2024-10-03 17:18:00 +02:00
|
|
|
ifdef PANDOCOK
|
|
|
|
PANDOCVER := $(shell ${PANDOC} -v | head -1 | cut -d ' ' -f 2)
|
|
|
|
PANDOCVEROK := $(shell printf '%s\n' ${PANDOCMINVER} ${PANDOCVER} | sort -C -V; echo $$?)
|
|
|
|
endif
|
2020-01-08 11:19:54 +01:00
|
|
|
|
2024-10-15 14:47:11 +02:00
|
|
|
none:
|
|
|
|
|
2023-07-02 11:43:38 +02:00
|
|
|
% : %.md
|
|
|
|
ifdef PANDOCOK
|
2024-10-03 17:18:00 +02:00
|
|
|
ifeq (${PANDOCVEROK}, 1)
|
|
|
|
echo "${PANDOC} ${PANDOCVER} < ${PANDOCMINVER}. $@ can create font warnings with man/groff" >/dev/stderr >&2
|
|
|
|
endif
|
2020-01-08 11:19:54 +01:00
|
|
|
# copy copyright notice
|
|
|
|
grep "^\.\\\\\"" $< > $@ || true
|
2023-07-02 11:43:38 +02:00
|
|
|
# run pandoc
|
|
|
|
$(eval SECTION := $(subst .,,$(suffix $@)))
|
|
|
|
$(eval BASENAME := $(basename $@))
|
|
|
|
$(eval TITLE := $(shell echo "${BASENAME}\(${SECTION}\)" | tr [:lower:] [:upper:]))
|
|
|
|
$(eval HEADER := "$(shell man ${SECTION} intro | head -1 | sed -e 's/^[^[:blank:]]*[[:blank:]]*//' -e 's/[[:blank:]]*[^[:blank:]]*$$//' )")
|
|
|
|
$(PANDOC) -standalone -M title=${TITLE} -M section=${SECTION} -M header=${HEADER} -M footer=${PANDOC_ORG} -M "date=`date +\"%B %Y\"`" --to man $< >> $@
|
2024-10-03 17:18:00 +02:00
|
|
|
# workaround for boldface rendering
|
|
|
|
sed -i -e 's/\\f\[CR\]/\\f\[CB\]/g' $@ || true
|
|
|
|
echo "$@ manpage updated" >/dev/stderr >&2
|
2020-01-08 11:19:54 +01:00
|
|
|
else
|
2023-07-02 11:43:38 +02:00
|
|
|
echo "${PANDOC} is not available. Manpage $@ cannot be updated" >/dev/stderr >&2
|
2020-01-08 11:19:54 +01:00
|
|
|
endif
|