CSI=csi -script
HTML=../music/index.html ../index.html ../writings/index.html ../about/index.html ../zb/index.html ../hacks/index.html ../hacks/dc/index.html ../hacks/brkout/index.html ../hacks/ultima6/index.html ../writings/proverbs.html ../writings/characters.html
INCS=3e8-html.scm simple-xml.scm
LIBS=        # simple-xml.so
ROOT=..
PRETTIFY_BUNDLE=$(ROOT)/js/prettify-bundle.js
PRETTIFY_FILES=$(ROOT)/js/prettify.js $(ROOT)/js/lang-*.js 

all: $(HTML) $(LIBS) $(PRETTIFY_BUNDLE)

$(ROOT)/music/index.html: music.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/writings/index.html: writings.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/about/index.html: about.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/zb/index.html: zb.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/hacks/index.html: hacks.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/hacks/dc/index.html: dc.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/hacks/brkout/index.html: brkout.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/hacks/ultima6/index.html: ultima6.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/writings/proverbs.html: proverbs.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/writings/characters.html: characters.scm $(INCS)
	$(CSI) $< > $@
$(ROOT)/index.html: index.scm $(INCS)
	$(CSI) $< $(ROOT) > $@ || rm $@
$(PRETTIFY_BUNDLE): $(PRETTIFY_FILES)
	cat $^ > $@

simple-xml.so: simple-xml.scm
	csc -s -O2 -d2 $<

test-sync:
	(cd .. && rsync -navi --exclude '.~' --exclude '*.so' --exclude "*.log" --exclude "nginx.*" --exclude "*_temp" --exclude .DS_Store * 3e8:/var/www/3e8.org/pages)
sync:
	(cd .. && rsync -avi --exclude '.~' --exclude '*.so' --exclude "*.log" --exclude "nginx.*" --exclude "*_temp" --exclude .DS_Store * 3e8:/var/www/3e8.org/pages)

nginx:
	(cd .. && nginx -c nginx.conf -p .)
signal-nginx:
	(cd .. && nginx -s $(SIGNAL) -c nginx.conf -p .)
reload-nginx:
	make signal-nginx SIGNAL=reload
