CC = gcc-dx10
AS = asm990
LD = lnk990
MKTAPE = mktape

LIBDIR = ..
CFLAGS = -O -I../include $(DEBUG)

LIBS = -L$(LIBDIR) -lm -lc $(EXTRALIBS) -ldxsci
CRT0 = $(LIBDIR)/crt0sci.o
EXTRALIBS = -lsoft

OBJS = hello1.o hello2.o hello3.o hello4.o hello5.o hello6.o \
	testio1.o testio2.o testio3.o testio4.o testio5.o \
	testio6.o testio7.o testio8.o testio9.o testio10.o \
	testio11.o testio12.o \
	testsleep.o testmalloc1.o testmalloc2.o \
	testtime.o testcalc.o testrela.o testfact.o testfrexp.o \
	testtrig.o testrand.o testsqrt.o testdir.o teststat.o \
	testexp.o testctype.o testpid.o dmpcmn.o common.o testtxdir.o \
	testgetenv.o testtmpfile.o

TARGETS = hello1.exe hello2.exe hello3.exe hello4.exe hello5.exe hello6.exe \
	testio1.exe testio2.exe testio3.exe testio4.exe testio5.exe \
	testio6.exe testio7.exe testio8.exe testio9.exe testio10.exe \
	testio11.exe testio12.exe \
	testsleep.exe testmalloc1.exe testmalloc2.exe \
	testtime.exe testcalc.exe testrela.exe testfact.exe testfrexp.exe \
	testtrig.exe testrand.exe testsqrt.exe testdir.exe teststat.exe \
	testexp.exe testctype.exe testpid.exe testgetenv.exe testtmpfile.exe

TXDSTARGETS = ${TARGETS} dmpcmn.exe testtxdir.exe

all dx10 dxsci: $(TARGETS)

dnos dnsci: 
	@make $(TARGETS) "CC = gcc-dnos" \
		"LIBS = -L$(LIBDIR) -lm -lc $(EXTRALIBS) -ldnsci"

os: 
	@make $(TARGETS) "LIBS = -L$(LIBDIR) -lm -lc $(EXTRALIBS)" \
		"CRT0 = $(LIBDIR)/crt0os.o"
txds: 
	@make $(TXDSTARGETS) "LIBS = -L$(LIBDIR) -ltxdir -lm -lc $(EXTRALIBS)" \
		"CFLAGS = -DTXDS -O -I../include $(DEBUG)" \
		"CRT0 = $(LIBDIR)/crt0tx.o"

sa standalone: 
	@make $(TARGETS) "LIBS = -L$(LIBDIR) -lm -lc $(EXTRALIBS) -lsa" \
		"CRT0 = $(LIBDIR)/crt0sa.o"

tape:
	$(MKTAPE) -n testexe.tap $(TARGETS)

clean:
	rm -f $(OBJS)
	rm -f $(TARGETS)
	rm -f *.lst *.map *.s *.tap *.exe

distclean: clean
	rm -f checkdir/*

hello1.exe : hello1.o
	$(LD) -mo hello1.map hello1.exe $(CRT0) hello1.o $(LIBS) 

hello2.exe : hello2.o
	$(LD) -mo hello2.map hello2.exe $(CRT0) hello2.o $(LIBS) 

hello3.exe : hello3.o
	$(LD) -mo hello3.map hello3.exe $(CRT0) hello3.o $(LIBS) 

hello4.exe : hello4.o
	$(LD) -mo hello4.map hello4.exe $(CRT0) hello4.o $(LIBS) 

hello5.exe : hello5.o
	$(LD) -mo hello5.map hello5.exe $(CRT0) hello5.o $(LIBS) 

hello6.exe : hello6.o
	$(LD) -mo hello6.map hello6.exe $(CRT0) hello6.o $(LIBS) 

testio1.exe : testio1.o
	$(LD) -mo testio1.map testio1.exe $(CRT0) testio1.o $(LIBS) 

testio2.exe : testio2.o
	$(LD) -mo testio2.map testio2.exe $(CRT0) testio2.o $(LIBS) 

testio3.exe : testio3.o
	$(LD) -mo testio3.map testio3.exe $(CRT0) testio3.o $(LIBS) 

testio4.exe : testio4.o
	$(LD) -mo testio4.map testio4.exe $(CRT0) testio4.o $(LIBS) 

testio5.exe : testio5.o
	$(LD) -mo testio5.map testio5.exe $(CRT0) testio5.o $(LIBS) 

testio6.exe : testio6.o
	$(LD) -mo testio6.map testio6.exe $(CRT0) testio6.o $(LIBS) 

testio7.exe : testio7.o
	$(LD) -mo testio7.map testio7.exe $(CRT0) testio7.o $(LIBS) 

testio8.exe : testio8.o
	$(LD) -mo testio8.map testio8.exe $(CRT0) testio8.o $(LIBS) 

testio9.exe : testio9.o
	$(LD) -mo testio9.map testio9.exe $(CRT0) testio9.o $(LIBS) 

testio10.exe : testio10.o
	$(LD) -mo testio10.map testio10.exe $(CRT0) testio10.o $(LIBS) 

testio11.exe : testio11.o
	$(LD) -mo testio11.map testio11.exe $(CRT0) testio11.o $(LIBS) 

testio12.exe : testio12.o
	$(LD) -mo testio12.map testio12.exe $(CRT0) testio12.o $(LIBS) 

testsleep.exe : testsleep.o
	$(LD) -i sleep -mo testsleep.map testsleep.exe \
		$(CRT0) testsleep.o $(LIBS) 

testtime.exe : testtime.o
	$(LD) -mo testtime.map testtime.exe $(CRT0) testtime.o $(LIBS) 

testmalloc1.exe : testmalloc1.o
	$(LD) -i malloc1 -mo testmalloc1.map testmalloc1.exe \
		$(CRT0) testmalloc1.o $(LIBS) 

testmalloc2.exe : testmalloc2.o
	$(LD) -i malloc2 -mo testmalloc2.map testmalloc2.exe \
		$(CRT0) testmalloc2.o $(LIBS) 

testcalc.exe : testcalc.o
	$(LD) -mo testcalc.map testcalc.exe $(CRT0) testcalc.o $(LIBS) 

testrela.exe : testrela.o
	$(LD) -mo testrela.map testrela.exe $(CRT0) testrela.o $(LIBS) 

testfact.exe : testfact.o
	$(LD) -mo testfact.map testfact.exe $(CRT0) testfact.o $(LIBS) 

testfrexp.exe : testfrexp.o
	$(LD) -mo testfrexp.map testfrexp.exe $(CRT0) testfrexp.o $(LIBS) 

testtrig.exe : testtrig.o
	$(LD) -mo testtrig.map testtrig.exe $(CRT0) testtrig.o $(LIBS) 

testexp.exe : testexp.o
	$(LD) -mo testexp.map testexp.exe $(CRT0) testexp.o $(LIBS) 

testrand.exe : testrand.o
	$(LD) -mo testrand.map testrand.exe $(CRT0) testrand.o $(LIBS) 

testsqrt.exe : testsqrt.o
	$(LD) -mo testsqrt.map testsqrt.exe $(CRT0) testsqrt.o $(LIBS) 

testdir.exe : testdir.o
	$(LD) -mo testdir.map testdir.exe $(CRT0) testdir.o $(LIBS) 

teststat.exe : teststat.o
	$(LD) -mo teststat.map teststat.exe $(CRT0) teststat.o $(LIBS) 

testctype.exe : testctype.o
	$(LD) -mo testctype.map testctype.exe $(CRT0) testctype.o $(LIBS) 

testpid.exe : testpid.o
	$(LD) -mo testpid.map testpid.exe $(CRT0) testpid.o $(LIBS) 

dmpcmn.exe : dmpcmn.o common.o
	$(LD) -mo dmpcmn.map dmpcmn.exe $(CRT0) dmpcmn.o common.o $(LIBS) 

testtxdir.exe : testtxdir.o
	$(LD) -mo testtxdir.map testtxdir.exe $(CRT0) testtxdir.o $(LIBS) 

testgetenv.exe : testgetenv.o
	$(LD) -mo testgetenv.map testgetenv.exe $(CRT0) testgetenv.o $(LIBS) 

testtmpfile.exe : testtmpfile.o
	$(LD) -mo testtmpfile.map testtmpfile.exe $(CRT0) testtmpfile.o $(LIBS) 

setcheck:
	@cp *.o checkdir/

check:
	@checkit

