davidvozdotnet

davidvoz.net source code
git clone https://git.davidvoz.net/davidvozdotnet.git
Log | Files | Refs

Makefile (958B)


      1 # Generates the source code
      2 # simple script to convert markdown to html format
      3 
      4 .POSIX:
      5 .PHONY: all build copy clean
      6 
      7 SHELL := bash
      8 .SHELLFLAGS := -eu -o pipefail -c
      9 OUT_DIR := output
     10 PANDOC_FORMAT  := -f markdown+link_attributes
     11 TEMPLATE := template.html
     12 RSYNC_OPTS := -av --delete
     13 DEPLOY_PATH := # add yours here
     14 RSYNC_IGNORE := --exclude=$(OUT_DIR) \
     15 				--exclude=$(TEMPLATE) \
     16 				--exclude=Makefile \
     17 				--exclude=".git*" \
     18 				--exclude="*.md"
     19 
     20 MD := $(shell find . -type f -name "*.md" -not -path "./$(OUT_DIR)/*")
     21 HTML := $(patsubst ./%.md,$(OUT_DIR)/%.html,$(MD))
     22 
     23 all: build copy
     24 
     25 build:
     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 
     36 copy:
     37 	rsync -a $(RSYNC_IGNORE) ./ $(OUT_DIR)/
     38 
     39 deploy:
     40 	rsync $(RSYNC_OPTS) $(OUT_DIR)/ $(DEPLOY_PATH)
     41 
     42 clean:
     43 	rm -rf $(OUT_DIR)