~.town / ~cel

Makefile

Makefile: Makefile.html

WGET = wget -qO $@
DEJAVU_VERSION = 2.34
PATH := $(PATH):/home/cel/bin

DEPS  = fonts/dejavu-sans.ttf\
		tablesort.min.js

SRC_MD = $(filter-out %.comments.md,$(wildcard *.md))
SRC_SH = $(wildcard *.html.sh)

PAGES =\
	$(SRC_MD:.md=.html) \
	$(filter-out template.html,$(SRC_SH:.sh=)) \
	feed.xml\
	images/activity.png

SRC =\
	$(SRC_MD:.md=.md.html) \
	$(SRC_SH:.html.sh=.sh.html) \
	feed.sh.html\
	Makefile.html

ALL   = $(PAGES) $(DEPS) $(SRC)
LOGINTIME_DIR ?= ~/Code/logintime

get_md_title = $(shell sed -n '/^\[title\]/ s/.*(\(.*\))/\1/p' <$<)

all: site deps
deps: $(DEPS)
site: $(PAGES) $(SRC)

.gitignore: Makefile
	for dep in $(ALL); do echo $$dep; done >$@

%.sh.html: %.html.sh source.sh template.html.sh
	PAGE=$* ./source.sh $< >$@

%.html: %.html.sh template.html.sh %.comments.md
	PAGE=$(*:index=) SOURCE=$*.sh.html ./$< > $@

%.html: %.md template.html.sh %.comments.md
	markdown <$< | PAGE=$* SOURCE=$*.md.html TITLE="$(get_md_title)" \
		./template.html.sh >$@

%.html: %
	PAGE=$(basename $*) ./source.sh $< >$@

guestbook/guestbook.txt:
	touch $@

%.comments.md:
	touch $@

index.html: links.tsv links.awk \
	guestbook/guestbook.txt guestbook/guestbook-html.awk

.git/info/refs:
	git update-server-info

feed.xml: feed.sh xml.awk .git/info/refs
	./$< > $@

loginstats.html: tablesort.min.js $(LOGINTIME_DIR)/stats.awk $(LOGINTIME_DIR)/sfirst

images/activity.png:
	last1 /var/log/wtmp* | histogram 900 96 | pngspark $@ -c E9A934 -h 60 -s 0.9

update-loginstats:
	rm -f loginstats.html images/activity.png
	@make --no-print-directory loginstats.html images/activity.png

dejavu-sans.zip:
	$(WGET) http://sourceforge.net/projects/dejavu/files/dejavu/$(DEJAVU_VERSION)/dejavu-sans-ttf-$(DEJAVU_VERSION).zip/download

fonts/dejavu-sans.ttf: dejavu-sans.zip | fonts
	unzip -p $^ dejavu-sans-ttf-$(DEJAVU_VERSION)/ttf/DejaVuSans.ttf >$@

fonts:
	mkdir -p $@

tablesort.min.js:
	$(WGET) https://raw.githubusercontent.com/tristen/tablesort/gh-pages/tablesort.min.js

clean:
	rm -f $(PAGES) $(SRC)

clean-all:
	rm -f $(ALL)

.PHONY: all site deps

.INTERMEDIATE: dejavu-sans.zip