summaryrefslogtreecommitdiff
path: root/Makefile
blob: 54f6d26800411c06b737efba1d99c688746815c4 (plain)
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
SHELL = bash -o pipefail

RUBYLIB=$(realpath .)/bin
export RUBYLIB

# Usage: $(call patsubst,PATTERN1 PATTERN2...,REPLACEMENT,TEXT)
#
# Like $(patsubst), but takes multiple patterns that are all replaced
# with the same replacement.
patsubst-all = $(if $1,$(call patsubst-all,$(wordlist 2,$(words $1),$1),$2,$(patsubst $(firstword $1),$2,$3)),$3)

# Which suffixes can we turn in to HTML?
html.suffixes = md org
# Find all source files with those suffixes
html.src = $(shell find src -type f \( -false $(foreach s,$(html.suffixes), -o -name '*.$s' ) \))
# Translate the source filenames into output filenames
html.out = $(call patsubst-all,$(addprefix src/%.,$(html.suffixes)),out/%.html,$(html.src))

all: $(html.out) out/main.css out/DND/DND.css

bin/page = bin/page bin/util.rb bin/pandoc.rb

out/%.html: src/%.md $(bin/page) bin/page.html.erb bin/write-atomic
	mkdir -p $(@D)
	bin/page html $< | bin/write-atomic $@
out/%.html: src/%.org $(bin/page) bin/page.html.erb bin/write-atomic
	mkdir -p $(@D)
	bin/page html $< | bin/write-atomic $@
out/%.css: src/%.scss
	mkdir -p $(@D)
	scss --stdin < $< > $@

#out/index.md  : index index.md.erb   .var.articles $(addsuffix .md,$(articles)) util.rb Makefile write-atomic
#	./index md $(filter %.md,$^) | ./write-atomic $@
#out/index.atom: index index.atom.erb .var.articles $(addsuffix .md,$(articles)) util.rb Makefile write-atomic
#	./index atom $(filter %.md,$^) | ./write-atomic $@

.DELETE_ON_ERROR:
.SECONDARY: