# This makefile builds the website to be published.
# For the HTTP/HTML portion, that's pushed to Github pages.
# For the gemini portion, that's also pushed to my gemini server by this makefile.
source_files := $(shell find content/*.md)
target_files := $(patsubst content/%.md,gemini/%.gmi,$(source_files))

.PHONY: default
default: publish build-html

gemini/%.gmi: content/%.md
	lowdown -tgemini $< > $@

.PHONY: build-gemini
build-gemini: $(target_files)
	cp gemini/_index.gmi gemini/index.gmi
	for file in $(target_files) ; do \
		echo "=> $$file" | sed 's/gemini//' >> gemini/index.gmi ; \
	done

.PHONY: build-html
build-html:
	boot publish

.PHONY: clean
clean:
	echo ${target_files}

.PHONY: publish
publish: $(target_files)
	rsync -av content/img content/extra gemini/index.gmi $^ gemini.bgenc.net:/var/gemini/
