# ----------------------------------------------------------
#                        Copyright (C) 1999
#               Hiroshi Nakashima, Kazuhiko Ohno
#              Namiyo Sugiyama, Kiyokazu Yokoishi
#        and Department of Information and Computer Sciences 
#                 Toyohashi University of Technology
#-----------------------------------------------------------  

# ----------------------------------------------------------
#                        Copyright (C) 1998
#        Hiroshi Nakashima, Kazuhiko Ohno, Namiyo Sugiyama,
#        and Department of Information and Computer Sciences 
#                 Toyohashi University of Technology
# -----------------------------------------------------------  

# ---------------------------------------------------------- 
#   (C)1993,1994 Institute for New Generation Computer Technology 
#       (Read COPYRIGHT for detailed information.) 
#   (C)1996, 1997 Japan Information Processing Development Center
#       (Read COPYRIGHT-JIPDEC for detailed information.)
# ----------------------------------------------------------

SLEEP = sleep 1
PARALLEL = 0
LN = ln -s
KLIC = ../compiler/klic -P$(PARALLEL) \
	-v -K../compiler/kl1cmp -D../compiler/klicdb \
	-X. -I../include -L../runtime -g

KLIC_T = ../compiler/klic -P$(PARALLEL) \
	-v -1../compiler/kl1cmp-t1 -2../compiler/kl1cmp-t2 \
	-3../compiler/kl1cmp-t3 -G../compiler/ganalyzer \
	 -T -D../compiler/klicdb \
	-X. -I../include -L../runtime -g

KLICSYS = ../compiler/klic ../compiler/kl1cmp  \
    ../compiler/klicdb \
	../include/klic/* ../runtime/libklic.a

.SUFFIXES: $(.SUFFIXES) .tst .res

TESTS = \
	nrev.tst nrev-t.tst \
	fact.tst fact-t.tst  part.tst part-t.tst

TESTPROGS = \
	nrev nrev-t part part-t \
	fact fact-t 

TESTSRCS = \
	nrev.kl1 nrev-t.kl1 part1.kl1 part2.kl1 part1-t.kl1 part2-t.kl1 \
	fact.kl1 fact-t.kl1 

tests:	klicdb.init libklic.db $(TESTS)

klicdb.init:
	cp -p ../runtime/klic.db klicdb.init

libklic.db:
	cp -p ../runtime/libklic.db .

.res.tst:
	cmp $*.res $*.res.cmp

nrev.res: nrev
	./nrev > nrev.res
part.res: part
	./part > part.res
fact.res: fact
	./fact > fact.res

nrev:	nrev.kl1 $(KLICSYS)
	$(KLIC) -o nrev nrev.kl1; $(SLEEP)
part:	part1.kl1 part2.kl1 $(KLICSYS)
	$(KLIC) -o part part1.kl1 part2.kl1; $(SLEEP)
fact: fact.kl1 $(KLICSYS)
	$(KLIC) -o fact fact.kl1; $(SLEEP)

nrev-t.res: nrev-t
	./nrev-t > nrev-t.res
part-t.res: part-t
	./part-t > part-t.res
fact-t.res: fact-t
	./fact-t > fact-t.res

nrev-t:	nrev-t.kl1 $(KLICSYS)
	$(KLIC_T) -o nrev-t nrev-t.kl1; $(SLEEP)
part-t:	part1-t.kl1 part2-t.kl1 $(KLICSYS)
	$(KLIC_T) -o part-t part1-t.kl1 part2-t.kl1; $(SLEEP)
fact-t: fact-t.kl1 $(KLICSYS)
	$(KLIC_T) -o fact-t fact-t.kl1; $(SLEEP)

nrev-t.kl1: nrev.kl1
	$(LN) nrev.kl1 nrev-t.kl1
part1-t.kl1: part1.kl1
	$(LN) part1.kl1 part1-t.kl1
part2-t.kl1: part2.kl1
	$(LN) part2.kl1 part2-t.kl1
fact-t.kl1: fact.kl1
	$(LN) fact.kl1 fact-t.kl1

clean:
	/bin/rm -f *.c *.ext *.h *.o klic.db klicdb.init libklic.db \
		work* *~ core \
	*.ai0 *.ai1 *.ai2 *.mid

distclean: clean
	/bin/rm -f $(TESTPROGS) *.res *-t.kl1

realclean: distclean
