FILES=hh_term hh_lexer hh_parse toolbox read preprocess init pattern scoring 

FILES_CMO=$(addsuffix .cmo,$(FILES))
FILES_CMX=$(addsuffix .cmx,$(FILES))

all: align

OPTFLAGS=-inline 100

align: align.ml $(FILES_CMX) Makefile
	ocamlopt nums.cmxa str.cmxa unix.cmxa -o $@ $(OPTFLAGS) $(FILES_CMX) $<

# Run "rlwrap ./top -I ../hh1 -I .."
top: $(FILES_CMO) Makefile
	ocamlmktop nums.cma str.cma unix.cma -o $@ $(FILES_CMO)

%.ml: %.mly
	ocamlyacc $< # -v
	rm $(<:y=i)  # Removing a file

%_lexer.ml: %_lexer.mll %_parse.ml
	ocamllex $<

%.cmx: %.ml
	ocamlopt -c -I $(HH1_DIR) -I $(HH2_DIR) $<

%.cmo: %.ml
	ocamlc -c -I $(HH1_DIR) -I $(HH2_DIR) $<

clean:
	rm -f match *cmx *cmo *cmi *.o *~

.depend: $(addsuffix .ml,$(FILES))
	ocamldep $^ main.ml > $@

include .depend
