export OCAMLOPT=ocamlopt
LTOP=../../../lurette/bin/lurettetop$(EXE)
LDBG=../../../lurette/bin/ldbg$(EXE)
LIB=../../../lurette/lib


LURETTETOP=$(LTOP)   --precision 2 \
	  --test-length 500  --step-mode Inside --local-var --no-gnuplot --no-sim2chro   \
	  --do-not-show-step -v 2

EXPDIR=`$(LTOP) --ocaml-version`
$(EXPDIR):
	[ -d $(EXPDIR) ] || (mkdir -p $(EXPDIR) ; make utest)


%.cmxs: %.ml
	 ocamlopt -shared -o $*.cmxs  -I $(LIB) graphics.cmxa ocamlRM.cmx rif_base.cmx $*.ml 

%.cmo: %.ml
	 ocamlc -c   -I $(LIB)  graphics.cma ocamlRM.cmo  $*.ml 


clean:
	rm -rf *.ec *.cm* *.log *~ .*~ *.o *rif0 *rif Data *.pp_luc *.plot *.gp $(MAIN).opt


test1.rif:$(EXPDIR) sut.cmxs env.cmxs
	rm -f test1.rif0 .lurette_rc
	$(LURETTETOP) -go  --output test1.rif0  -seed 33  \
	  -rp "sut:ocaml:sut.cmxs:" \
	  -rp "env:ocaml:env.cmxs:"  && \
	grep -v "lurette chronogram" test1.rif0  | \
	grep -v "lurette Version"   | \
	grep -v "The execution lasted"| sed -e "s/^M//" > test1.rif 


test1: test1.rif $(EXPDIR)
	rm -f test11.res
	diff -B -u -i  $(EXPDIR)/test1.rif.exp test1.rif > test1.res || true
	cat test1.res
	[ ! -s test1.res ]  && make clean

utest1:test1.rif
	cp test1.rif $(EXPDIR)/test1.rif.exp

test2.rif:  $(EXPDIR) sut.cmo env.cmo
	rm -f test2.rif0
	$(LDBG) -init test.ml >  test2.rif0  
	grep -v "lurette chronogram" test2.rif0  | \
	grep -v "This is ldbg Version" test2.rif0  | \
	sed -e "s/^M//" > test2.rif 

test2: test2.rif $(EXPDIR)
	rm -f test2.res
	diff -B -u -i  $(EXPDIR)/test2.rif.exp test2.rif > test2.res || true
	cat test2.res
	[ ! -s test2.res ]  && make clean

utest2:test2.rif
	cp test2.rif $(EXPDIR)/test2.rif.exp

test:test1 test2


