#	Makefile	(2.11BSD)	2.3	1997/8/11
#
#	The limitations on program size have been removed.  The addition
#	of disklabel support pushed 'restor' over the limit.  Even with
#	additional space saving measures it was impossible to fit restor
#	into 48kb.  'icheck' and 'restor' are now built with split I/D.
#
#	This is not as bad as it sounds - the kernel has not been able to
#	run on a non split machine for many years.  It made little sense 
#	to restrict the standalone utilities to non-split mode when the
#	operating system itself required split I/D.
#
#	It is still possible to hand craft a version of the utilities by leaving
#	out all but the necessary drivers. 
#
# 1997/8/11  - add -O to maketape and makesimtape compile commands
# 1997/1/24  - remove 'skel' from lists of directories.
# 1997/1/18  - add 'makesimtape' target.
# 1996/10/28 - added usr/sbin, usr/libexec and corresponding src directories.
# 1995/12/05 - add RX02 driver.
# 1995/06/05 - add disklabel program to Makefile.
# 1995/06/01 - use split I/D for icheck and restor.
# 1995/05/30 - Begin adding disklabel support.

ROOT=	
SBINSRC=${ROOT}/usr/src/sbin
MKFS=	${SBINSRC}/mkfs/mkfs.c
RESTOR=	${SBINSRC}/restor/restor.c
ICHECK=	${SBINSRC}/icheck/icheck.c

DEFS=	-DSTANDALONE -I${ROOT}/usr/include -I${ROOT}.
CFLAGS=	-O ${DEFS}
LDFLAGS= -lkern -lc

DRIVERS=prf.o sys.o label.o \
	xp.o rk.o rl.o rx.o br.o hk.o si.o ra.o vt.o

ALL=	vtboot tinyboot copy 211disklabel 211mkfs 211restor 211icheck

all: ${ALL}

.c.o:
	cc ${CFLAGS} -c $*.c

.s.o:
	/lib/cpp -P ${DEFS} $< | as -u -V -o $@

srt0-i.o: srt0.s
	/lib/cpp -P -DSPLIT_ID ${DEFS} srt0.s | as -u -V -o $@

libsa.a: ${DRIVERS}
	ar rv $@ $?
	ranlib $@

mkfs.o: ${MKFS}
	cc ${CFLAGS} -c ${MKFS}

restor.o: ${RESTOR}
	cc ${CFLAGS} -c ${RESTOR}

icheck.o: ${ICHECK}
	cc ${CFLAGS} -c ${ICHECK}

tinyboot: M.o tinyboot.o ubmapset.o tinysys.o vt.o prf.o
	ld -X -o a.out M.o tinyboot.o ubmapset.o tinysys.o vt.o prf.o ${LDFLAGS}
	strip a.out
	dd if=a.out of=tinyboot bs=16 skip=1

copy: copy.o srt0.o conf.o libsa.a
	ld -X -o $@ srt0.o conf.o $@.o libsa.a ${LDFLAGS}

211mkfs: srt0.o conf.o libsa.a mkfs.o
	ld -X -o $@ srt0.o conf.o mkfs.o libsa.a ${LDFLAGS}

211restor: srt0-i.o conf.o libsa.a restor.o
	ld -X -i -o $@ srt0-i.o conf.o restor.o libsa.a ${LDFLAGS}

211icheck: srt0-i.o conf.o libsa.a icheck.o
	ld -X -i -o $@ srt0-i.o conf.o icheck.o libsa.a ${LDFLAGS}

211disklabel: srt0.o conf.o libsa.a disklabel.o displaylab.o
	ld -X -o $@ srt0.o conf.o disklabel.o displaylab.o libsa.a ${LDFLAGS}

vtboot: vtboot.o
	strip $@.o
	dd if=$@.o of=vtboot bs=16 skip=1
	rm -f $@.o

tags: FRC
	rm -f tags
	ctags *.[ch]
	for i in M.s; do \
		${EGREP} '^[_a-zA-Z][_a-zA-Z0-9]*:' $$i \
		| ${SED} "s;\([^:]*\):\(.*\)$$;\1	$$i	/^\1:\2$$/;" \
		>> tags; \
	done
	sort -o tags tags

FRC:

clean:
	rm -f ${ALL} ${AUX} libsa.a *.o tags a.out

M.o:		M.s
boot.o:		boot.c
br.o:		br.c
cat.o:		cat.c
conf.o:		conf.c
copy.o:		copy.c
disklabel.o:	disklabel.c
displaylab.o:	displaylab.c
hk.o:		hk.c
label.o:	label.c
prf.o:		prf.c
ra.o:		ra.c
rk.o:		rk.c
rl.o:		rl.c
rx.c:		rx.c
si.o:		si.c
srt0-i.o:	srt0.s
srt0.o:		srt0.s
sys.o:		sys.c
tinyboot.o:	tinyboot.c
tinysys.o:	tinysys.c
ubmapset.o:	ubmapset.c
vt.o:		vt.c
vtboot.o:	vtboot.s
xp.o:		xp.c
