11
2- DOCKER ?= $(shell command -v docker)
3- PANDOC ?= $(shell command -v pandoc)
2+ DOCKER ?= $(shell command -v docker 2>/dev/null)
3+ PANDOC ?= $(shell command -v pandoc 2>/dev/null)
4+ ifeq "$(strip $(PANDOC ) ) " ''
5+ ifneq "$(strip $(DOCKER))" ''
6+ PANDOC = $(DOCKER) run \
7+ -it \
8+ --rm \
9+ -v $(shell pwd)/:/input/:ro \
10+ -v $(shell pwd)/output/:/output/ \
11+ -u $(shell id -u) \
12+ vbatts/pandoc
13+ PANDOC_SRC := /input/
14+ PANDOC_DST := /
15+ endif
16+ endif
17+
418# These docs are in an order that determines how they show up in the PDF/HTML docs.
519DOC_FILES := \
620 version.md \
@@ -25,25 +39,18 @@ default: docs
2539.PHONY : docs
2640docs : output/docs.pdf output/docs.html
2741
42+ ifeq "$(strip $(PANDOC ) ) " ''
43+ output/docs.pdf output/docs.html :
44+ $(error cannot build $@ without either pandoc or docker)
45+ else
2846output/docs.pdf : $(DOC_FILES )
2947 mkdir -p output/ && \
30- $(DOCKER ) run \
31- -it \
32- --rm \
33- -v $(shell pwd) /:/input/:ro \
34- -v $(shell pwd) /output/:/output/ \
35- -u $(shell id -u) \
36- $(PANDOC ) -f markdown_github -t latex -o /$@ $(patsubst % ,/input/% ,$(DOC_FILES ) )
48+ $(PANDOC ) -f markdown_github -t latex -o $(PANDOC_DST ) $@ $(patsubst % ,$(PANDOC_SRC ) % ,$(DOC_FILES ) )
3749
3850output/docs.html : $(DOC_FILES )
3951 mkdir -p output/ && \
40- $(DOCKER ) run \
41- -it \
42- --rm \
43- -v $(shell pwd) /:/input/:ro \
44- -v $(shell pwd) /output/:/output/ \
45- -u $(shell id -u) \
46- $(PANDOC ) -f markdown_github -t html5 -o /$@ $(patsubst % ,/input/% ,$(DOC_FILES ) )
52+ $(PANDOC ) -f markdown_github -t html5 -o $(PANDOC_DST ) $@ $(patsubst % ,$(PANDOC_SRC ) % ,$(DOC_FILES ) )
53+ endif
4754
4855code-of-conduct.md :
4956 curl -o $@ https://raw.githubusercontent.com/opencontainers/tob/d2f9d68c1332870e40693fe077d311e0742bc73d/code-of-conduct.md
0 commit comments