
ifndef GCC
  export GCC=gcc -fPIC
endif

LTOP=../../../bin/lurettetop

LURETTETOP=$(LTOP)    \
	   --test-length 100 --thick-draw 1 \
	  --draw-inside 0 --draw-edges 0 --draw-vertices 0 --draw-all-vertices  \
	  --step-mode Inside --local-var  --no-sim2chro  --seed 3 \
	  --do-not-show-step  


#

test: simple_sut$(EXE)
	rm -f test.rif0 .lurette_rc
	./simple_sut$(EXE) & 
	$(LURETTETOP) -go --output test.rif0 -l 9 \
	  -rp "sut:socket:127.0.0.1:2000:"  \
	  -rp "env:lutin:foo.lut:main" && \
	grep -v "lurette chronogram" test.rif0  | \
	grep -v "This is lurettop Version" test.rif0  | \
	grep -v "The execution lasted"| sed -e "s/^M//" > test.rif  &&\
	rm -f test.res
	diff -B -u -i  test.rif.exp test.rif > test.res || true
	cat test.res
	[ ! -s test.res ] && make clean

PORT=2015
PORT2=2016

# an alternative using the call-via-socket script (provided in the bin dir of the distrib)
# the following 3 rules needs to be launched in parallel
lu:
	../../../bin/lurettetop -go  --output test.rif0 -l 9 \
	  -rp "sut:socket:127.0.0.1:$(PORT):"  \
	  -rp "sut:socket:127.0.0.1:$(PORT2):"  \
	  -rp "env:lutin:foo.lut:main" 

sut2: simple_sut2
	call-via-socket -server -addr 127.0.0.1 -port $(PORT) ./simple_sut2

sut3:simple_sut3
	call-via-socket -server -addr 127.0.0.1 -port $(PORT2) ./simple_sut3



simple_sut$(EXE): simple_sut.c
	$(GCC) simple_sut.c -o $@ 




utest:
	cp test.rif test.rif.exp


clean:
	rm -rf *.ec *.log *~ .*~ *.o *rif0 *rif Data *.pp_luc *.plot *.gp



test_dontgo:
	rm -f test.rif0 .lurette_rc
	$(LURETTETOP)  --output test.rif0 env.lut && \
	grep -v "lurette chronogram" test.rif0  | \
	grep -v "The execution lasted"| sed -e "s/^M//" > test.rif  &&\
	rm -f test.res && diff -B -u -i  test.rif.exp test.rif > test.res
	[ ! -s test.res ] && make clean 


