-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
61 lines (48 loc) · 2.22 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
55
56
57
58
59
60
61
MAKE_ := $(MAKE) -j1 --no-print-directory
LIB ?= emacs.d/init.el
SHELL := /bin/bash
PUBLISH_RCLONE_REMOTE ?= book
PUBLISH_RCLONE_DIRECTORY ?= book
RELEARN_THEME_SNAPSHOT ?= 735297478651be4fbe77be739214ed73afc2e0ba
RELEARN_THEME_TARBALL_URL_PREFIX ?= https://codeload.github.com/EnigmaCurry/hugo-theme-relearn/tar.gz/
.PHONY: build # Export notes.org to separate markdown files and build hugo site
build: clean build-md build-hugo
.PHONY: help # Show this help screen
help:
@grep -h '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/make \1 \t- \2/' | expand -t20
emacs-batch:
@emacs -batch --eval "(progn\
(load-file \"${LIB}\")\
(${FUNC} ${ARGS})\
)"
.PHONY: install # Install the hugo theme
install:
@test -d hugo/themes/relearn || (TMPDIR=$$(mktemp -d) && wget -O $${TMPDIR}/relearn-theme.tar.gz ${RELEARN_THEME_TARBALL_URL_PREFIX}${RELEARN_THEME_SNAPSHOT} && mkdir -p hugo/themes && tar xfv $${TMPDIR}/relearn-theme.tar.gz -C hugo/themes && rm -rf $${TMPDIR} && mv hugo/themes/hugo-theme-relearn-${RELEARN_THEME_SNAPSHOT} hugo/themes/relearn)
build-md:
PWD=$$(pwd) ${MAKE_} emacs-batch FUNC=build ARGS='\"$${PWD}\"'
build-hugo:
@_script/printable_books.sh
@cd hugo && hugo
.PHONY: serve # Build and serve the site on http://localhost:1313
serve: build
@cd hugo && hugo server --buildDrafts --disableFastRender
.PHONY: serve-prod
serve-prod: build
@cd hugo && hugo && hugo server --navigateToChanged
.PHONY: clean
clean:
rm -rf hugo/content public
.PHONY: publish # Publish changes to rclone remote
publish: build
@rclone listremotes | grep "^${PUBLISH_RCLONE_REMOTE}:$$" || (echo -e "Missing rclone remote: ${PUBLISH_RCLONE_REMOTE} \nPlease run 'rclone config' and create this remote." && false)
@echo "## Publishing books via rclone ... be patient ..."
time rclone sync public ${PUBLISH_RCLONE_REMOTE}:${PUBLISH_RCLONE_DIRECTORY}/public
@echo Done
.PHONY: pdf # Build PDF
pdf: build
# Sort Markdown files, concatenate them
@./_script/sort_md.sh portable-docker | tr '\0' '\n' | xargs cat > combined.md
# Escape backslashes so they are printed literally
@sed -i 's/\\/\\\\/g' combined.md
# Create the PDF using Pandoc
@pandoc combined.md -o portable-docker.pdf --toc --metadata title="Portable Docker" --pdf-engine=xelatex