PATH_TO_GENESIS=/home/rick/wleiden/genesis/nodes/

.PHONY: docs

all: static configs

static: static.ml
	ocamlopt -o static static.ml

stuffroutes: stuffroutes.c
	gcc -o stuffroutes stuffroutes.c -O -DEXTRAINFO -Wall

# fancy-schmancy print version of the code
static.ps: static.ml
	cp docs/preamble.tex temp.tex
	ocamlweb --no-preamble -s --no-index static.ml >> temp.tex
	echo "\end{document}" >> temp.tex
	cat temp.tex | perl docs/fixup.pl > static.tex
	rm temp.tex
	latex static.tex
	dvips -o static.ps static.dvi

configs: 
	svn up $(PATH_TO_GENESIS)
	svn info $(PATH_TO_GENESIS) | grep Revision | sed "s/^[^:]*: //g" > svnrev
	find $(PATH_TO_GENESIS) -name wleiden.conf > nodelist
	python parseconfs.py nodelist | sort > nodes
# cetim hacks. first patch up the master ip's to not be in the same subnet:
	sed -i'' -e "s/\(172.17.143.[0-9]*\)\/24/\1\/32/g" nodes
# then add a simplified proxy2 (note that 172.31.255/24 is handled by
# static.ml internally):
	echo "proxy2|172.17.143.4/32/1|172.16.254.4/28/1" >> nodes
	./static > routes
	python genscripts.py routes

check: check_up check_version

check_up:
	sh check_online.sh $(PATH_TO_GENESIS)

check_version:
	sh check_static-version.sh

docs:
	@echo
	@echo Als het volgende niet lukt is het jammer, dan heb je alleen
	@echo de documentatie van Ed Kikkert niet in docs/
	@echo
	cd docs && $(MAKE)

clean:
	rm -f a.out *.core static.cmi static static.cmx static.o