MCFLAGS = --infer-all

# For the development version, we want fast compile times, hence dynamic
# linking
MCFLAGS += -O0
MGNUCFLAGS += --pic-reg
MLFLAGS += --shared

# For the production version, we want to enable optimization, and
# the executable that we ship as our final entry should be statically linked
###MCFLAGS += -O6 --intermodule-optimization
###MGNUCFLAGS = -DML_OMIT_MATH_DOMAIN_CHECKS
###MLFLAGS = --static

-include Mmake.params

MAIN_TARGET = main

# needed for fdopen()
MGNUCFLAGS-protocol = --no-ansi

depend : main.depend test_protocol.depend

tags: *.m
	mtags *.m

check: test_protocol.res

%.out: % %.inp
	./$* < $*.inp > $@ 2>&1

%.res: %.out %.exp
	diff -u $*.exp $*.out > $@ || cat $@

.PHONY: tar
tar: main
	-[ -d source ] || mkdir source
	cp *.m *.inp *.exp Mmakefile source
	tar --exclude=CVS -cf - buildme runme main README COPYING NOTES source \
		| gzip -9 > submission.tar.gz

info: tar
	ls -l submission.tar.gz
	echo "md5sum: `md5sum submission.tar.gz | awk '{print $$1;}'`"

###
### uncomment this and run `mmake email-submission' to submit the final entry
### Don't forget to set MLFLAGS = --static
###
#email-submission: tar info.txt
#	./submit.sh info.txt submission.tar.gz
