# "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 "printbig" library designed
# to test linking external code

.PHONY : all
all : mql.native buildin.o

# "make mql.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

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

buildin.o :
	cc -c -o buildin.o buildin.c -lm

# "make clean" removes all generated files

.PHONY : clean
clean :
	ocamlbuild -clean
	rm -rf testall.log ocamlllvm *.diff *.o *.out *.log *.ll


# Building the tarball

TESTS = \
  print


TESTFILES = $(TESTS:%=test-%.mql) $(TESTS:%=test-%.out) 

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

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