export OCAMLOPT=ocamlopt
LTOP=lurette_old
LIB= `ocamlfind query -r rdbg-plugin -i-format` \
	  `ocamlfind query -r lutin -i-format`  


MAIN=rabbit

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

LURETTE=lurette --test-length 500

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


CMXA=$(shell ocamlfind query lutin -a-format -r -predicates native) 

%.cmxs: %.ml
	 ocamlfind ocamlopt -shared -o $*.cmxs  $(LIB) $(CMXA) rdbg-plugin.cmxa graphics.cmxa  $*.ml 


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


test_old.rif:$(EXPDIR) rabbit.cmxs
	rm -f test_old.rif0 .lurette_rc
	$(LURETTETOP) -go  --output test_old.rif0  \
	  -rp "sut:ocaml:rabbit.cmxs:" \
	  -rp 'env:lutin:rabbit.lut:-main:rabbit:-seed:34:-L:libm.so.6:-loc' && \
	grep -v "lurette chronogram" test_old.rif0  | \
	grep -v "lurette Version"   | \
	grep -v "#seed"   | \
	grep -v "The execution lasted"| sed -e "s/^M//" > test_old.rif 


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

utest_old:test_old.rif
	cp test_old.rif $(EXPDIR)/test_old.rif.exp

test_new.rif:$(EXPDIR) rabbit.cmxs
	rm -f test_new.rif0 .lurette_rc
	$(LURETTE) --output test_new.rif0  \
	  -sut "ocaml rabbit.cmxs" \
	  -env "lutin rabbit.lut -main rabbit -seed 34 -L libm.so.6 -loc" && \
	grep -v "lurette chronogram" test_new.rif0  | \
	grep -v "lurette Version"   | \
	grep -v "#seed"   | \
	grep -v "The execution lasted"| sed -e "s/^M//" > test_new.rif 


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

utest:test_new.rif
	cp test_new.rif $(EXPDIR)/test_new.rif.exp

# A FAIRE
#
# 1 - determiner les sommets de l'obstacle avec get_vertices pour pouvoir afficher le vrai obstacle
# 2 - Colorer l'obstacle en bleu pour pouvoir remettre les anciens points de
# la trajectoire
# 3 - Faire se ballader l'obstacle un peu plus aleatoirement
# 
