#
#  Make the standalone startup routine
#

AR	=	/bin/ar
DIR	=	/usr/ftp/pub/Xinu.8086
CC	=	$(DIR)/bin/cc86
CFLAGS	=	-c
LD	=	$(DIR)/bin/ld86
LIB	=	$(DIR)/lib
LORDER	=	$(DIR)/bin/lorder86
DLOADER	=	$(DIR)/bin/dl86

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

.s.o:
		$(CC) $(CFLAGS) $<

SFILES	=	arith.s startup.s 
CFILES	=	printf.c lowcore.c

OFILES	=	ioaccess.o printf.o arith.o

all:		libsa86.a standalone86.o

install:	all 
		cp libsa86.a $(LIB)
		$(DIR)/bin/ranlib86 $(LIB)/libsa86.a
		cp standalone86.o $(LIB)/standalone

clean:
		rm -nrf *.o *.a a86.out core

libsa86.a:	$(OFILES)
		rm -nrf libsa86.a
		$(AR) cr libsa86.a `$(LORDER) $(OFILES) | tsort`
		$(DIR)/bin/ranlib86 libsa86.a

standalone86.o:	startup.o lowcore.o
		$(LD) -r -o standalone86.o startup.o lowcore.o
		
demo:		a86.out
		$(DLOADER) a86.out
		@echo demo has been downloaded -- try it

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

a86.out:	demo.o libsa86.a  standalone86.o libsa86.a
		$(LD) -T 1000 -e _start -o a86.out standalone86.o demo.o libsa86.a

