#	from: @(#)Makefile	8.1 (Berkeley) 6/10/93
#	     $Id: Makefile,v 1.2 1994/07/24 20:29:45 phil Exp $

DESTDIR=
STANDDIR=${DESTDIR}/stand
# load at 1.5Meg -- allow 1.4xx meg kernel, but below ram disk
# NOTE: alloc() function takes memory after _end
RELOC=	180000

CONS= -DSCNCONSOLE
DEFS= -DSTANDALONE ${CONS}
CFLAGS=	-O ${INCPATH} ${DEFS} -fwritable-strings

SRCS=   cons.c devopen.c scn.c scsi_low.c scsi_hi.c \
	conf.c prf.c tgets.c machdep.c sd.c filesystem.c

S=	${.CURDIR}/../../..

.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
.PATH: ${S}/stand ${S}/lib/libsa

INCPATH=-I${.CURDIR} -I${.CURDIR}/../.. -I${S} -I${S}/lib/libsa

### find out what to use for libkern
.include "$S/lib/libkern/Makefile.inc"
LIBKERN=	${KERNLIB}

.include "$S/lib/libsa/Makefile.inc"
LIBSA=	${SA_LIB}

LIBS=	${LIBSA} ${.OBJDIR}/libdrive.a \
	${LIBKERN} ${LIBSA} ${LIBKERN}

BOOTS=	boot
ALL=	${BOOTS}

all: ${ALL}

${BOOTS}: ${LIBS}

OBJS=	${SRCS:N*.h:R:S/$/.o/g}
${.OBJDIR}/libdrive.a: ${OBJS}
	ar crv $@ $?
	ranlib $@

# depend on DEFS

devopen.o machdep.o srt0.o: Makefile
cons.o: Makefile

# startups

srt0.o: ${.CURDIR}/srt0.s
	cpp ${INCPATH} ${DEFS} ${.CURDIR}/srt0.s | as -o srt0.o

# new boot
boot:	boot.o srt0.o ${LIBS}
	ld -z -T ${RELOC} -e begin srt0.o boot.o ${LIBS} -o $@
	@size boot

# new boot user mode test
TESTBOOT=	boot.o test.o $(SC) ${LIBS}
# objects from regular libc;
SC=	cerror.o syscall.o malloc.o sbrk.o getpagesize.o
testboot:	$(TESTBOOT)
	ld -o testboot /usr/lib/crt0.o $(TESTBOOT) ${LIBS} -o $@

$(SC): /usr/lib/libc.a
	ar x /usr/lib/libc.a $(SC)

# utilities

clean cleandir:
	rm -f *.o errs make.out
	rm -f a.out boot cat ls testboot
	rm -f *.core
	rm -f libdrive.a 

install: boot
	cp boot ${DESTDIR}/

.include <bsd.dep.mk>
.include <bsd.obj.mk>

FRC:
