summaryrefslogblamecommitdiff
path: root/Makefile
blob: 2f15f3321efbab1c8d7b4bbb839a16a788c8cfc9 (plain) (tree)


























































                                                                                                                      
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}