davidvozdotnet

davidvoz.net source code
git clone https://git.davidvoz.net/davidvozdotnet.git
index
logs
tree

Makefile
1# Generates the source code
2# simple script to convert markdown to html format
3
4.POSIX:
5.PHONY: all build copy clean
6
7SHELL := bash
8.SHELLFLAGS := -eu -o pipefail -c
9OUT_DIR := output
10PANDOC_FORMAT := -f markdown+link_attributes
11TEMPLATE := template.html
12RSYNC_OPTS := -av --delete
13DEPLOY_PATH := # add yours here
14RSYNC_IGNORE := --exclude=$(OUT_DIR) \
15 --exclude=$(TEMPLATE) \
16 --exclude=Makefile \
17 --exclude=".git*" \
18 --exclude="*.md"
19
20MD := $(shell find . -type f -name "*.md" -not -path "./$(OUT_DIR)/*")
21HTML := $(patsubst ./%.md,$(OUT_DIR)/%.html,$(MD))
22
23all: build copy
24
25build:
26 mkdir -p $(OUT_DIR)
27 for f in $(MD); do \
28 out="$(OUT_DIR)/$${f#./}"; \
29 out="$${out%.md}.html"; \
30 mkdir -p "$$(dirname "$$out")"; \
31 pandoc $(PANDOC_FORMAT) \
32 --template=$(TEMPLATE) \
33 "$$f" -s -o "$$out"; \
34 done
35
36copy:
37 rsync -a $(RSYNC_IGNORE) ./ $(OUT_DIR)/
38
39deploy:
40 rsync $(RSYNC_OPTS) $(OUT_DIR)/ $(DEPLOY_PATH)
41
42clean:
43 rm -rf $(OUT_DIR)