summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2f15f3321efbab1c8d7b4bbb839a16a788c8cfc9 (plain) (blame)
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
BUCKET=rndm-www
S3_HOST="${BUCKET}.s3-website.fr-par.scw.cloud"
URL="https://random.sh"
SITE_NAME=random.sh

LAYOUT=includes/layout.tpl.html
STYLE=src/site.css
STYLE_LIBS=includes/css/modern-normalize.min.css
MARKDOWNFILES!=find src/ -type f -name '*.md'
ASSETS!=find src/ -type f -not -name '*.md' -not -name "site.css"

.export SITE_NAME BUCKET S3_HOST URL LAYOUT

.MAIN: all

all: sync

build: .build
sync: .published

resync:
	-rm .published
	${MAKE} sync

clean:
	-rm -r build/*

.PHONY: all build sync resync clean

# -- CSS
${STYLE:S/^src/build/}: ${STYLE} ${STYLE_LIBS}
	cat ${STYLE_LIBS} ${STYLE} > ${.TARGET}
BUILDS+=${STYLE:S/^src/build/}

# -- MD
.for __md in ${MARKDOWNFILES}
#.info "(markdown) ${__md} => ${__md:S/^src/build/:S/.md$/.html/}"
${__md:S/^src/build/:S/.md$/.html/}: ${__md} bin/render-markdown ${LAYOUT} ${STYLE:S/^src/build/}
	@mkdir -p "${.TARGET:H}"
	bin/render-markdown "${LAYOUT}" "${__md}" > "${.TARGET}"
BUILDS+=${__md:S/^src/build/:S/.md$/.html/}
.endfor

# -- Assets
.for __s in ${ASSETS}
#.info "(static) ${__s} => ${__s:S/^src/build/}"
${__s:S/^src/build/}: ${__s}
	@mkdir -p "${.TARGET:H}"
	ln -s ${__s:tA} ${.TARGET}
BUILDS+=${__s:S/^src/build/}
.endfor

.build: $(BUILDS)
	@touch ${.TARGET}

.published: .build
	aws s3 sync --delete "build/" "s3://${BUCKET}/"
	varnishadm -S /var/db/varnish.secret -T front.stairway.internal.random.sh:8081 ban "req.http.host ~ ${BUCKET}"
	@touch ${.TARGET}