FILES=hh_parse hh_lexer read mat_hh
FILES_CMO=$(addsuffix .cmo,$(FILES))
FILES_CMX=$(addsuffix .cmx,$(FILES))

all: mat_hh

mat_hh: $(addsuffix .cmx,hh_parse hh_lexer read mat_hh)
	ocamlopt -I +xml-light str.cmxa unix.cmxa xml-light.cmxa -o $@ $<

# Run "rlwrap ./top"
top: $(FILES_CMO) Makefile
	ocamlmktop nums.cma str.cma unix.cma xml-light.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 $<

%.cmo: %.ml
	ocamlc -c -I hh1 $<

clean:
	rm mat_hh -f *_lexer.ml *_parse.ml *.o *~

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

include .depend
