TESTROOTDIR ?= .
TESTOBJDIR ?= testobj
#TESTOBJDIR ?= /tmp/testobj_nll
#TESTOBJDIR ?= $(HOME)/tmp/testobj_nll

NLL ?= nll

NLLOPT = -quit -no-run -no-argv

TESTSETDIR = $(TESTROOTDIR)/testset

all :		test

include $(TESTROOTDIR)/Makefile.syntax
include $(TESTROOTDIR)/Makefile.args
include $(TESTROOTDIR)/Makefile.let
include $(TESTROOTDIR)/Makefile.print
include $(TESTROOTDIR)/Makefile.goto
include $(TESTROOTDIR)/Makefile.prefix
include $(TESTROOTDIR)/Makefile.if
include $(TESTROOTDIR)/Makefile.goloop
include $(TESTROOTDIR)/Makefile.gosub
include $(TESTROOTDIR)/Makefile.return
include $(TESTROOTDIR)/Makefile.loop
include $(TESTROOTDIR)/Makefile.for
include $(TESTROOTDIR)/Makefile.gonext
include $(TESTROOTDIR)/Makefile.stack
include $(TESTROOTDIR)/Makefile.data
include $(TESTROOTDIR)/Makefile.formula
include $(TESTROOTDIR)/Makefile.string
include $(TESTROOTDIR)/Makefile.array
include $(TESTROOTDIR)/Makefile.pointer
include $(TESTROOTDIR)/Makefile.boolean
include $(TESTROOTDIR)/Makefile.static
include $(TESTROOTDIR)/Makefile.refer
include $(TESTROOTDIR)/Makefile.struct
include $(TESTROOTDIR)/Makefile.function
include $(TESTROOTDIR)/Makefile.labelcall
include $(TESTROOTDIR)/Makefile.value
include $(TESTROOTDIR)/Makefile.vector
include $(TESTROOTDIR)/Makefile.memory
include $(TESTROOTDIR)/Makefile.eval
include $(TESTROOTDIR)/Makefile.queue
include $(TESTROOTDIR)/Makefile.operate
include $(TESTROOTDIR)/Makefile.program
include $(TESTROOTDIR)/Makefile.graphic

# Floating point is unsupported on nlcc1
#include $(TESTROOTDIR)/Makefile.float

NSRC = $(CSRC:$(TESTSETDIR)/%=$(TESTOBJDIR)/%)

HOUT = $(CSRC:.nll=.hout)
NOUT = $(NSRC:.nll=.nout)

.SUFFIXES:
.SUFFIXES: .nout .hout .nll
.PRECIOUS: $(NSRC)

test :		nout

testset :	.testset

.testset :
		$(MAKE) allclean
		$(MAKE) hout
		$(MAKE) clean

$(NSRC) :
		mkdir -p `dirname $@`
		cp $(@:$(TESTOBJDIR)/%=$(TESTSETDIR)/%) $@

.nll.hout :
		$(NLL) $(NLLOPT) $< > $@

.nll.nout :
		$(NLL) $(NLLOPT) $< > $@
		diff -u -U 30 $(@:$(TESTOBJDIR)/%.nout=$(TESTSETDIR)/%.hout) $@

hout :		$(HOUT)

nsrc :		$(NSRC)

nout :		$(NOUT)

hout.clean :
		rm -f $(HOUT)

nsrc.clean :
		rm -f $(NSRC)

nout.clean :
		rm -f $(NOUT)

clean :		nsrc.clean nout.clean
		rm -fR $(TESTOBJDIR)

allclean :	clean hout.clean
