#-----------------------------------------------------------------------------
# 
# make install	- creates the auxiliary microVAX CPU kernel, plus its
#		  bootstrap, and puts a copy of this into ../lib
# 
#-----------------------------------------------------------------------------

KDEFINES = -DKERNEL
DEFINES =
KCFLAGS =  $(KDEFINES) $(TRACE)
CFLAGS =  $(DEFINES) $(TRACE)

# redefine the basic rules for building these kernel level files

.s.o:
	$(CC) -E $(KDEFINES) $< | egrep -v '^#' | as -o $@

.c.o:
	$(CC) -c -S $(KCFLAGS) $<
	/lib/c2 $*.s | /sys/vax/inline/inline -s | as -o $@
	rm -f $*.s

OBJ = accvio.o debugger.o doorbell.o emulate.o ksdump.o main.o mem.o\
      printf.o pt.o regnames.o sig.o string.o syscall.o syscalls.o traps.o\
      udiv.o urem.o usercall.o usercrash.o version.o

NEED = 	minikernel stripboot2 slave.a 
ALL =	$(NEED) sboot sboot2 user debug printv clocktest

all: 	$(ALL)

install: $(NEED)
	cp stripboot2 ../lib/auxbootstrap
	cp minikernel ../lib/auxkernel

boot2: boot2.o
	ld -z -T 0 boot2.o -o boot2

stripboot2: boot2
	cp boot2 a.out
	strip a.out
	dd if=a.out of=stripboot2 bs=1024 skip=1
	rm -f a.out

basicProgram(sboot,sboot.o,)
basicProgram(sboot2,sboot2.o,)
basicProgram(debug,debug.o,)
basicProgram(printv,printv.o,)

minikernel: locore.o $(OBJ)
	ld -z -o minikernel -e start -T 80000000 locore.o $(OBJ) $(TRACE)

basicProgram(user,user.o slave.a,)
basicProgram(clocktest,clocktest.o crashMessage.o slave.a,)
basicProgram(crashtest,crashtest.o crashMessage.o slave.a,)

basicModule(user)
basicModule(clocktest)
basicModule(crashtest)
basicModule(sboot)
basicModule(sboot2)
basicModule(down)
basicModule(debug)
basicModule(printv)
basicModule(malloc)
basicModule(kalib)

slavesys.o: slavesys.s
	$(CC) -E $(DEFINES) slavesys.s | egrep -v '^#' | as -o slavesys.o

setjmp.o: setjmp.s
	$(CC) -E $(DEFINES) setjmp.s | egrep -v '^#' | as -o setjmp.o

bfill.o: bfill.s
	$(CC) -E $(DEFINES) bfill.s | egrep -v '^#' | as -o bfill.o

slave.a: slavesys.o kalib.o malloc.o setjmp.o bfill.o
	ar cr slave.a slavesys.o kalib.o malloc.o setjmp.o bfill.o
	ranlib slave.a

makeClean($(ALL) boot2 *test fixs)
makeDepend()
