.PRECIOUS: %.pdf GHC = ghc CC = ghc GHCFLAGS = -Wall -Werror -cpp -Isrc -odir build -hidir build -ibuild \ -fno-warn-name-shadowing \ -main-is Sudoku ifdef OPTIMIZE GHCFLAGS += -O2 -funbox-strict-fields -funfolding-use-threshold12 CFLAGS += -O2 endif sources = $(shell find src -name '*.lhs') docs = Sudoku.pdf all: build/Sudoku build/Sudoku: build/Sudoku.o $(GHC) $(GHCFLAGS) -o $@ $^ build/%.o: src/%.lhs @mkdir -p `dirname $@` @rm -f build/$*.lhs && cp src/$*.lhs build/$*.lhs @# So ghci can locate .lhs and .o in same dir, I should just fix ghci @chmod 400 build/$*.lhs $(GHC) $(GHCFLAGS) -c -o $@ $< build/%.hi: build/%.o; @true %.pdf: src/%.lhs lhs.sty TEXINPUTS="src:"; export TEXINPUTS; \ pdflatex $< && \ pdflatex $< rm -f "$*.log" "$*.aux" "$*.toc" "$*.bbl" clean: rm -rf build/* .depend: $(sources) @echo Rebuilding dependencies... @$(GHC) $(GHCFLAGS) -isrc -M -optdep-f -optdep$@ $^ pdf: pdf_Sudoku pdf_%: %.pdf @if [ "`uname -s`" = "Darwin" ]; then open $^; \ else xpdf $^; \ fi push: $(docs) darcs push charger.brianweb.net:/home/darcs/sudoku scp $(docs) charger.brianweb.net:/home/darcs/sudoku test: build/Sudoku time build/Sudoku include .depend