# "make test" Compiles everything and runs the regression tests

.PHONY : test
test : all testall.sh
	./testall.sh

# "make all" builds the executable as well as the "utils" library for array concatenation

.PHONY : all
all : seaflow.native utils.o

# "make seaflow.native" compiles the compiler
#
# The _tags file controls the operation of ocamlbuild, e.g., by including
# packages, enabling warnings
#
# See https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc

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

# "make clean" removes all generated files

.PHONY : clean
clean :
	ocamlbuild -clean
	rm -rf testall.log ocamlllvm *.diff
	rm -f *.cmo
	rm -f *.cmi
	rm -f seaflowparse.ml
	rm -f seaflowparse.mli
	rm -f seaflowparse.output
	rm -f *.o
	
# Building the array concatenation util

utils : utils.c
	cc -o utils utils.c

# Building the tarball

# TESTS = \
#   array/arr1 array/arr2 array/arr3 array/arr4 array/arr5 array/arr6  \
#   array/arr7 array/arr8 array/arr9 array/arr10 array/arr11 array/arr12 \
#   array/arr13 array/arr14 array/arr15 array/arr16

# FAILS = \
#   decl

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

TESTFILES = test/*

TARFILES = ast.ml sast.ml codegen.ml Makefile _tags seaflow.ml seaflowparse.mly \
	scanner.mll semant.ml testall.sh \
	utils.c Dockerfile \
	$(TESTFILES) 

seaflow.tar.gz : $(TARFILES)
	cd .. && tar czf seaflow/seaflow.tar.gz \
		$(TARFILES:%=seaflow/%)
