Skip to content

Commit be0c414

Browse files
wkingMa Shimiao
authored andcommitted
Makefile: Fix native pandoc invocation
In dc9daf9 (Makefile: Replace vbatts/pandoc with a PANDOC variable 2016-05-06, opencontainers#428) I'd misunderstood vbatts/pandoc as a call to a locally-installed pandoc, when it's actually the name of a Docker image [1,2]. With this commit, we prefer a local pandoc if one exists, fall back to Docker and vbatts/pandoc if a local 'docker' exists, and raise an error if neither 'pandoc' nor 'docker' exist. [1]: opencontainers#440 [2]: opencontainers#428 (comment) Reported-by: Qiang Huang <[email protected]> Reported-by: Lai Jiangshan <[email protected]> Signed-off-by: W. Trevor King <[email protected]>
1 parent c4c57fe commit be0c414

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

Makefile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11

22
DOCKER ?= $(shell command -v docker 2>/dev/null)
33
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.
519
DOC_FILES := \
620
version.md \
@@ -25,25 +39,18 @@ default: docs
2539
.PHONY: docs
2640
docs: 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
2846
output/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

3850
output/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

4855
code-of-conduct.md:
4956
curl -o $@ https://raw.githubusercontent.com/opencontainers/tob/d2f9d68c1332870e40693fe077d311e0742bc73d/code-of-conduct.md

0 commit comments

Comments
 (0)