-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathMakefile
55 lines (40 loc) · 1.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This Makefile knows how to build the various
# pieces of this repo, including converting
# Markdown to HTML.
README_INPUTS := $(shell find . -type f -name README.md)
README_OUTPUTS := $(README_INPUTS:README.md=index.html)
OTHER_INPUTS := $(shell find . -type f ! -name README.md ! -name index.md -name '*.md')
OTHER_OUTPUTS := $(OTHER_INPUTS:.md=.html)
INCLUDES := $(shell find includes -type f)
SITE_TITLE := [missing course]
PANDOC := pandoc -s --template includes/template.html -H includes/header.html
.PHONY: build
build: readmes others
.PHONY: build-container
build-container:
@docker run --mount src="${PWD}",target=/code,type=bind glesica/missing-course
.PHONY: container
container:
@docker build -t glesica/missing-course:latest .
.PHONY: readmes
readmes: ${README_OUTPUTS}
.PHONY: others
others: ${OTHER_OUTPUTS}
.PHONY: serve
serve:
@echo "Serving on http://localhost:8080"
@echo "Use ctrl-c to terminate the server"
@python3 -m http.server 8080
index.html: README.md ${INCLUDES}
@echo "building $<"
@${PANDOC} -V rooturl="." -M pagetitle:"/ ${SITE_TITLE}" -o "$@" "$<"
%/index.html: %/README.md ${INCLUDES} %/media
@echo "building $<"
@${PANDOC} -V rooturl="$$(realpath --relative-to=$(@D) .)" -M pagetitle:"/$(@D) ${SITE_TITLE}" -o "$@" "$<"
%.html: %.md ${INCLUDES}
@echo "building $<"
@${PANDOC} -V rooturl="$$(realpath --relative-to=$(@D) .)" -M pagetitle:"/$(@D) ${SITE_TITLE}" -o "$@" "$<"
.PRECIOUS: %/media
%/media: media
@echo "symlinking media $<"
@ln -s "$$(realpath --relative-to=$(@D) media)" "$@"