#
#  Make the standalone startup routine
#

DIR	=	..
#AR	=	ar
AR	=	$(DIR)/bin/ar11
CC	=	$(DIR)/bin/cc11
CFLAGS	=	-c
LD	=	$(DIR)/bin/ld11
LIBDIR	=	$(DIR)/lib/standalone
LORDER	=	$(DIR)/bin/lorder11
RANLIB	=	$(DIR)/bin/ranlib11
DLOADER	=	$(DIR)/bin/download

SFILES	=	aldiv.s almul.s alrem.s cerror.s csv.s \
		ldiv.s lmul.s lrem.s crtsa0.s

CFILES	=	printf.c sprintf.c

OFILES	=	aldiv.o almul.o alrem.o cerror.o csv.o \
		ldiv.o lmul.o lrem.o printf.o sprintf.o

all:		libsac.a crtsa0.o

install:	all
		cp libsac.a crtsa0.o $(LIBDIR)
		$(RANLIB) $(LIBDIR)/libsac.a

clean:
		rm -rf *.o *.a a.out *.core

libsac.a:	$(OFILES)
		rm -rf libsac.a
		$(AR) cr libsac.a $(OFILES)
		$(RANLIB) libsac.a

crtsa0.o:	crtsa0.s
		$(CC) -c crtsa0.s

demo:		a.out
		$(DLOADER) -s a.out
		@echo demo has been downloaded -- try it

demo.o:		demo.c
		$(CC) $(CFLAGS) demo.c

a.out:		demo.o crtsa0.o libsac.a
		$(LD) -e start crtsa0.o demo.o libsac.a

sprintf.o:	sprintf.c
		$(CC) $(CFLAGS) sprintf.c

printf.o:	printf.c
		$(CC) $(CFLAGS) printf.c

aldiv.o:	aldiv.s
		$(CC) -c aldiv.s

almul.o:	almul.s
		$(CC) -c almul.s

alrem.o:	alrem.s
		$(CC) -c alrem.s

cerror.o:	cerror.s
		$(CC) -c cerror.s

csv.o:		csv.s
		$(CC) -c csv.s

ldiv.o:		ldiv.s
		$(CC) -c ldiv.s

lmul.o:		lmul.s
		$(CC) -c lmul.s

lrem.o:		lrem.s
		$(CC) -c lrem.s
