# Generators in OCaml
#
# The library of generators requires the caml-shift library, 
# delimcc.cma and the corresponding .mli files. See caml-shift.tar.gz.
# Please adjust DELIMCC= below to point to the library.
#
# The typical command to use the OCaml top-level:
# $ ocaml -I caml-shift/ caml-shift/delimcc.cma
# and then do #load "generator.cmo";;

# $Id$

DELIMCC=caml-shift
OCAMLC=ocamlc
OCAMLOPT=ocamlopt

DELIMCCRUN=-I $(DELIMCC) -dllpath $(DELIMCC) $(DELIMCC)/delimcc.cma
DELIMCCINT=$(DELIMCC)/delimcc.cmi
DELIMCCOPT=-I $(DELIMCC)  $(DELIMCC)/delimcc.cmxa

LIB=generator.cmo
LIBOPT=generator.cmx

.SUFFIXES: .ml .mli .cmi .cmo .cmx .cmxa .dvi .pdf .ps .tex .eps .bbl

%.cmi: %.mli
	$(OCAMLC) -c -I $(DELIMCC) $<

%.cmo: %.ml %.cmi
	$(OCAMLC) -c -I $(DELIMCC) $<

%.cmx: %.ml %.cmi
	$(OCAMLOPT) -c -I $(DELIMCC) $<

.PHONY: lib libopt
lib: generator.cmi generator.cmo
libopt: generator.cmi generator.cmx

TESTS = test_gen

test: $(TESTS)

clean::
	rm -f *.cm[iox] *.[oa] *~ *.aux *.vrb


test_%: $(LIB) test_%.ml
	$(OCAMLC) -o $@ $(DELIMCCRUN) $(filter-out %.cmi,$^)
	./$@

clean::
	rm -f $(TESTS)
