# @configure_input@

# DOTS is the path to M2/Macaulay2 from this directory
DOTS ?= ../../..

include $(DOTS)/../include/config.Makefile
VPATH = @srcdir@

CPPFLAGS := -I$(DOTS)/../include $(CPPFLAGS) 
CPPFLAGS += -I$(DOTS)/../libraries/final/include

LDFLAGS += -L$(DOTS)/../libraries/final/lib

TESTRESULTS := $(notdir $(patsubst %.m2, %.okay, $(wildcard @srcdir@/*.m2)))

all:
all:check
check: $(TESTRESULTS) check-gc

$(TESTRESULTS) : @pre_exec_prefix@/bin/M2@EXE@

ARGS := --silent -q --stop --no-core -e 'srcdir = "@srcdir@/"'

ifeq "@DEBUG@" "no"
TLIMIT ?= 20
MLIMIT ?= 600000
VLIMIT ?= 600000
else
TLIMIT ?= 60
MLIMIT ?= 700000
VLIMIT ?= 700000
endif

# make the stack limit always the same as it would be under MacOS
SLIMIT ?= 8192

LIMIT :=
ifeq (@ULIMIT_T@,yes)
LIMIT += ulimit -t $(TLIMIT) ;
endif
ifeq (@ULIMIT_M@,yes)
LIMIT += ulimit -m $(MLIMIT) ;
endif
ifeq (@ULIMIT_V@,yes)
LIMIT += ulimit -v $(VLIMIT) ;
endif
ifeq (@ULIMIT_S@,yes)
LIMIT += ulimit -s $(SLIMIT) ;
endif

%.okay : %.m2
	@ echo testing $<
	@ $(LIMIT) env @pre_exec_prefix@/bin/M2@EXE@ $(ARGS) $< -e 'exit 0'
	@ touch $@

clean::	; rm -f *.okay
LOADLIBES += @GC_LIBS@
testgc:
check-gc: testgc.okay
testgc.okay : testgc ; ./testgc && touch $@
clean::; rm -f testgc
clean::; rm -rf *.dSYM
Makefile : Makefile.in ; cd $(DOTS)/.. && ./config.status Macaulay2/packages/Macaulay2Doc/basictests/Makefile
distclean :clean; rm -f Makefile
check: check-return-code
check-return-code :; if echo 'error "foo"' | @pre_exec_prefix@/bin/M2@EXE@ $(ARGS) 2>/dev/null 1>&2 ; then false ; else true ; fi

# Local Variables:
# compile-command: "make -C $M2BUILDDIR/Macaulay2/packages/Macaulay2Doc/basictests "
# End:
.NOTPARALLEL:
