#
#  Scheme->C compiler and runtime tests.
#

sccomp = ../scsc/sccomp
CC = cc
CFLAGS = -g
rt = ../scrt/libsc.a
n = n must be defined

.SUFFIXES:
.SUFFIXES: .sc .c .o

batch-c = test01.c test02.c test03.c test04.c test05.c \
	  test06.c test07.c test08.c test09.c test10.c \
	  test11.c test12.c test13.c test14.c test15.c \
	  test16.c test17.c test18.c test19.c test20.c \
	  test21.c test22.c test23.c

batch-o = test01.o test02.o test03.o test04.o test05.o \
	  test06.o test07.o test08.o test09.o test10.o \
	  test11.o test12.o test13.o test14.o test15.o \
	  test16.o test17.o test18.o test19.o test20.o \
	  test21.o test22.o test23.o

progs =	  test   test50 test51 test52 test53 test54\
	  test01 test02 test03 test04 test05 \
	  test06 test07 test08 test09 test10 \
	  test11 test12 test13 test14 test15 \
	  test16 test17 test18 test19 test20 \
	  test21 test22 test23

source =  test.sc   testchk.sc \
	  test01.sc test02.sc test03.sc test04.sc test05.sc \
	  test06.sc test07.sc test08.sc test09.sc test10.sc \
	  test11.sc test12.sc test13.sc test14.sc test15.sc \
	  test16.sc test17.sc test18.sc test19.sc test20.sc \
	  test20-input.sc     test20-make.sc \
	  test21.sc test22.sc test23.sc \
	  test50.sc test51.sc test52.sc test53.sc test54.sc test54c.c

.sc.c:
	${sccomp} -schf ${sccomp}.heap -C $*.sc

.c.o:
	${sccomp} -schf ${sccomp}.heap -c ${CFLAGS} $*.c

test:	test.c test.o testchk.c testchk.o ${batch-c} ${batch-o}
	${CC} -o test ${CFLAGS} test.o testchk.o ${batch-o} ${rt} -lm

testn:	testchk.c testchk.o ${rt} 
	${sccomp} -schf ${sccomp}.heap -i ${CFLAGS} -o test${n} test${n}.sc \
		  testchk.o ${rt}

test50:	test50.c test50.o
	${CC} -o test50 ${CFLAGS} test50.o ${rt} -lm

test51:	test51.c test51.o
	${CC} -o test51 ${CFLAGS} test51.o ${rt} -lm

test52:	test52.c test52.o
	${CC} -o test52 ${CFLAGS} test52.o ${rt} -lm

test53:	test53.sc
	${sccomp} -schf ${sccomp}.heap -i -o test53 ${CFLAGS} test53.sc \
		  ${rt} -lm

test54:	test54.c test54.o test54c.o testchk.o
	${CC} -o test54 ${CFLAGS} test54.o test54c.o testchk.o ${rt} -lm

port:

install:

clean:
	rm -f *.o *.BAK *.CKP core

clean-sc-to-c:
	rm -f ${batch-c} test.c testchk.c test50.c test51.c test52.c test53.c \
	      test54.c

noprogs:
	rm -f ${progs}

srcdist:
	rdist -c README makefile-tail *.c *.sc ${destdir}

all:
	make "sccomp = ${sccomp}" "CC = ${CC}" "CFLAGS = ${CFLAGS}" \
	     "rt = ${rt}" test test50 test51 test52 test54
	make "n = 53" testn

srclinks:
	for x in ${source}; \
	    do ln -s ${SRCDIR}/$$x $$x;\
	done

