SRCS = src/List.hs src/Pretty.hs src/Expr.hs src/Expr/Var.hs src/Expr/Supply.hs src/Expr/Simplify.hs src/Main.hs src/Checks.hs src/List/Clip.hs src/Commutation.hs src/Patch.hs src/Seq.hs src/Commutation/Derived.hs src/List/Patch/Hunk.hs src/List/Patch/Move.hs src/List/Commutation/HunkHunk.hs src/List/Commutation/HunkMove.hs src/List/Commutation/MoveMove.hs src/Test.hs src/Language/DSEL/Bool.hs src/Language/DSEL/List.hs src/Language/DSEL/Prelude.hs src/Expr/Concrete.hs src/Expr/Op.hs src/Typed/Same.hs src/Typed/TOrd.hs src/Typed/TList.hs src/Expr/HOAS.hs src/Expr/Convert.hs src/Data/CatList.hs src/Data/IsListC.hs src/Commutation/Memoise.hs src/Diagrams.hs

# Careful, make clean wipes this out!
BUILDDIR = build/

GHC = ghc -isrc/ -odir $(BUILDDIR) -hidir $(BUILDDIR)

# a hack to work around some problems with my network filesystem
docat: $(SRCS)
	cat $(SRCS) > /dev/null

test_p: $(SRCS) docat
	$(GHC) -O --make -osuf .p_o -hisuf .p_hi -prof -auto-all -o test_p -main-is Test.main src/Test.hs

test_o: $(SRCS) docat
	$(GHC) -O -osuf .o_o -hisuf .o_hi --make -o test_o -main-is Test.main src/Test.hs

test: $(SRCS) docat
	$(GHC) --make -o test -main-is Test.main src/Test.hs

test_ghci:
	$(GHC) --interactive src/Test.hs

main_p: $(SRCS) docat
	$(GHC) --make -osuf .p_o -hisuf .p_hi -prof -auto-all -o main_p -main-is Main.main src/Main.hs

main_o: $(SRCS) docat
	$(GHC) -O -osuf .o_o -hisuf .o_hi --make -o main_o -main-is Main.main src/Main.hs

main: $(SRCS) docat
	$(GHC) --make -o main -main-is Main.main src/Main.hs

main_ghci:
	$(GHC) --interactive src/Main.hs

%.out: %
	./$< > $@

%.prof: %
	./$< +RTS -p -RTS

diff: main.out main_o.out
	diff -u main.out main_o.out

clean:
	rm -f main main_p main_o test test_p test_o
	rm -rf $(BUILDDIR)
