# run "make test" to compile everything and run the tests after make gwiz.native
.PHONY : test
test : all testall.sh
	./testall.sh

# run "make all" to build the executable 
.PHONY : all
all: gwiz.native  struct.o list.o parse_gpx.o

gwiz.native:
	opam config exec -- \
	ocamlbuild -use-ocamlfind gwiz.native 

# run "make clean" to remove all generated files 
.PHONY : clean 
clean : 
	ocamlbuild -clean
	rm -rf testall.log ocamlllvm *.diff *.ll *.exe *.s
	rm -rf *.o *.out

# make gpx parser binary file

parse_gpx.o: parse_gpx.c
	cc `xml2-config --cflags` -g -Wall   "-I/usr/local/opt/libxml2/include"  -c -o parse_gpx.o parse_gpx.c
        
struct: struct.c
	cc -o struct.o -DBUILD_TEST struct.c
list: list.c 
	cc -o list -DBUILD_TEST list.c 

TESTS = \
  arith1 arith2 arith3 arith4 array1 array2 \
  array3 arrayaccess double double 1 double 2 \
  func func2 func3 func4 func5 func6 gcd1 gcd2 \
  global1 global2 global3 gpx gpx1 gpx2 gpx3 \
  helloworld if1 if2 if3 if4 if5 if6 local1 local2 \
  math neg ops1 ops2 string1 struct struct1 var 1 \
  var2 while1 while2 \ 

FAILS = \
  array1 array2 array3 array4 array 5 array 6 \
  assign1 double1 expr file for1 for2 for3 \
  func1 func2 func3 func4 global1 global2 \
  if1 if2 print1 return struct1 struct2 var 1\
  while1 \

TESTFILES = $(TESTS:%=test-%.gw) $(TESTS:%=test-%.out) \
	     $(FAILS:%=fail-%.gw) $(FAILS:%=fail-%.err)

#TARFILES = ast.ml sast.ml codegen.ml Makefile _tags gwiz.ml gwizparse.mly \
#	README scanner.mll semant.ml testall.sh \
#	Dockerfile \
#	$(TESTFILES:%=tests/%)
