Skip to content

Commit 23bf8e9

Browse files
committed
Merge pull request #448 from wking/host-pandoc
Makefile: Fix native pandoc invocation
2 parents 878fac1 + 2e2073b commit 23bf8e9

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

Makefile

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
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.
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)