SRCS = LangLex.hs LangParse.hs $(OSRCS)
OSRCS = Main.hs Automaton.hs AST.hs CST.hs Complementation.hs Util.hs Specialize.hs Value.hs
GHCOPT = # -prof -auto-all
.PHONY: doc clean opt
TARGET = bidirectionalizer_f

all : $(SRCS)
	ghc --make Main.hs -o $(TARGET) $(GHCOPT) 

opt : GHCOPT += -O2 -optc-O3 -optc-fomit-frame-pointer -optc-frename-registers -optc-finline-limit=1200
opt : all

tar : 
	mkdir -p bidirectionalizerf 
	cp $(OSRCS) \
	 Lang.x Lang.y Makefile \
	 samples/test1.txt samples/test2.txt samples/test3.txt\
	 samples/test4.txt samples/test5.txt samples/test6.txt samples/test8.txt samples/test9.txt samples/test10.txt samples/test11.txt\
	 bidirectionalizerf 
	tar czvf bidirectionalizer_f.tar.gz bidirectionalizerf
	rm -rf bidirectionalizerf

doc : $(OSRCS)
	mkdir -p ./doc
	haddock -h -o ./doc $(OSRCS)

.SUFFIXES: .hs .x .y

LangLex.hs : Lang.x
	alex -g -o LangLex.hs Lang.x

LangParse.hs : Lang.y
	happy -gca -ipout.txt -o LangParse.hs Lang.y

clean:
	rm -f $(TARGET).exe
	rm -f $(TARGET)
	rm -f *~
	rm -f LangLex.hs
	rm -f LangParse.hs
	rm -f *.hi
	rm -f *.o
	rm -f pout.txt
	rm -rf ./doc
