# only for the web page. use cabal if you actually want to run the program

OUT := /srv/www/lit/ips

STATICS != find style -type f
SRCS = ips.lhs
OUTPUTS = $(OUT)/ips.html \
          $(patsubst %,$(OUT)/%,$(STATICS))

HOST ?= rhiannon.website
SSH_PORT ?= 35353
REMOTE_USER ?= nginx
REMOTE_DIR ?= lit/ips


all: $(OUTPUTS)

clean:
	rm -rf $(OUT)/*

$(OUT)/%.html: %.lhs template.html ; $(pandoc)
$(OUT)/%:      %                   ; $(copy)

define copy
	mkdir -p $(dir $@)
	cp $< $@
endef

define pandoc
	mkdir -p $(dir $@)
	pandoc -M toc-title=contents --toc-depth 2 --toc \
	       --strip-comments \
	       --template template.html $< -o $@
endef

upload:
	rsync --recursive --partial --progress --copy-links \
	      --compress --human-readable --hard-links --size-only \
	      --delete --delete-after \
	      --rsh='ssh -l $(REMOTE_USER) -p $(SSH_PORT)' \
	      $(OUT)/ $(HOST):$(REMOTE_DIR)/
