#
#  Makefile for the book version of Xinu
#

# ie; /usr/Xinu
DIR	=	../../..

BINDIR	=	/usr/local/32k/bin
RANTOUCH=	touch
RANLIB	=	$(BINDIR)/ranlib
AR	=	$(BINDIR)/ar
AS	=	$(BINDIR)/as
LD	=	$(BINDIR)/ld
CC	=	$(BINDIR)/gcc

CFLAGS	=	-c -I../h -I$(DIR)/include -I/usr/local/32k/include -DNS32K -W

LIB	=	$(DIR)/lib

CFILES=		chprio.c clkinit.c close.c conf.c	\
		control.c create.c freebuf.c freemem.c \
		getbuf.c getc.c getitem.c getmem.c	\
		getpid.c getprio.c getstk.c		\
		init.c initialize.c insert.c insertd.c	\
		ioerr.c ionull.c			\
		kill.c kprintf.c mark.c mdump.c mkpool.c \
		netinit.c newqueue.c			\
		open.c					\
		pcount.c pcreate.c pdelete.c pinit.c	\
		poolinit.c prdump.c preceive.c preset.c	\
		psend.c ptclear.c putc.c		\
		qdump.c queue.c				\
		read.c ready.c receive.c recvclr.c	\
		resched.c resume.c			\
		scount.c screate.c sdelete.c seek.c	\
		send.c sendf.c signal.c signaln.c	\
		sleep.c sleep10.c sreset.c ssclock.c	\
		suspend.c				\
		tdump.c ttycntl.c ttygetc.c ttyiin.c	\
		ttyinit.c ttyoin.c ttyputc.c ttyread.c	\
		ttywrite.c				\
		userret.c				\
		wait.c wakeup.c write.c			\
		xdone.c

SFILES=		clkint.s ctxsw.s			\
		duartint.s				\
		lowcore.s				\
		panic.s					\
		sizmem.s startup.s			\
		regdump.s

# csv.s 

OFILES=		chprio.o clkinit.o close.o		\
		control.o create.o			\
		clkint.o ctxsw.o			\
		duarthandlr.o duartint.o		\
		freebuf.o freemem.o 			\
		getbuf.o getc.o getitem.o getmem.o	\
		getpid.o getprio.o getstk.o	\
		init.o insert.o insertd.o		\
		ioerr.o ionull.o		\
		kill.o kprintf.o			\
		mark.o mdump.o mkpool.o			\
		newqueue.o				\
		open.o					\
		pcount.o pcreate.o pdelete.o pinit.o	\
		poolinit.o prdump.o preceive.o preset.o	\
		psend.o ptclear.o putc.o		\
		panic.o					\
		qdump.o queue.o				\
		read.o ready.o receive.o recvclr.o	\
		resched.o resume.o			\
		scount.o screate.o sdelete.o seek.o	\
		send.o sendf.o signal.o signaln.o	\
		sleep.o sleep10.o sreset.o ssclock.o	\
		suspend.o				\
		sizmem.o 				\
		tdump.o ttycntl.o ttygetc.o ttyiin.o	\
		ttyinit.o ttyoin.o ttyputc.o ttyread.o	\
		ttywrite.o				\
		userret.o				\
		wait.o wakeup.o write.o			\
		xdone.o 				\
		regdump.o

XOFILES=	startup.o lowcore.o initialize.o conf.o

HFILES=		../h/bufpool.h	\
		../h/conf.h	\
		../h/disk.h	\
		../h/dir.h	\
		../h/dlc.h	\
		../h/dtc.h	\
		../h/file.h	\
		../h/frame.h	\
		../h/iblock.h	\
		../h/io.h	\
		../h/kernel.h	\
		../h/mark.h	\
		../h/mem.h	\
		../h/ports.h	\
		../h/proc.h	\
		../h/q.h 	\
		../h/sem.h	\
		../h/sleep.h	\
		../h/slu.h	\
		../h/tty.h	\
		../h/xebec.h

it:		a.out

all:		libx.a xinu.o

install:
		cp libx.a $(LIB)/libx.a
		$(RANTOUCH) $(LIB)/libx.a
		cp xinu.o $(LIB)

clean:
		-rm -rf *.o ,* .,*
		-rm -rf libx.a a.out conf.c ../h/conf.h core make.out
		-rm -rf *.CKP ../h/*.CKP ../con/*.CKP

everything:	a.out xref checkup sizes lint

down:		a.out
		download -s

d:		a.out
		download -a4 ; odt

lint:		,lint

,lint:		$(CFILES)
		lint -n -I../h $(CFILES) | Flint > ,lint

print:
		cprint -c Cover ../h/*.h *.c *.s

listings:	xref sizes
		cprint -c Cover Configuration ../h/*.h *.c *.s \
		    ,xref ,sizes ,ssizes Makefile

checkup:
		Checkup

sizes:		,sizes ,ssizes

,sizes:		$(OFILES) $(XOFILES) a.out
		size11 *.o a.out > ,sizes

,ssizes:	$(CFILES) $(SFILES) $(HFILES)
		Dosizes

libx.a:		$(OFILES)
		/bin/rm -f  libx.a
		$(AR) -a libx.a	$(OFILES)
		$(RANLIB) libx.a

# basic lowcore stuff.. always loaded..
xinu.o:		$(XOFILES)
		$(LD) -r $(XOFILES) -o xinu.o

LIBXC=$(LIB)/libxc.a
LIBS=libx.a $(LIBXC) libx.a $(LIBXC)
TEST=test.o

ALL=xinu.o $(TEST) $(LIBS)

# cc -R?
version.o:	$(ALL)
		make-version > version.c
		$(CC) -c version.c

# RAM version, text at 0x200000, data following text
a.out:		$(ALL) version.o
		$(LD) -T 200000 -e start $(ALL) version.o
#Mknlist ,nm

rom:		$(ALL) version.o
		$(LD) -o rom -T 10000000 -D 1000 -e start $(ALL) version.o
		hexify rom

nm:		,nm

,nm:		a.out
		Mknlist ,nm

tags:		,tags

,tags:		$(CFILES) $(HFILES)
		ctags $(CFILES)	$(HFILES)
		mv tags ,tags

xref:		,xref

,xref:		,tags
		Doxref

../h/conf.h:	Configuration
		config
		rm -f $(DIR)/include/conf.h
		ln ../h/conf.h $(DIR)/include/conf.h

conf.c:		Configuration
		config

depend:
		grep '^#[ 	]*include' *.c ../h/*.h			\
		| sed	-e 's/</"..\/h\//;s/>/"/'		\
			-e 's/:[^"]*"\([^"]*\)".*/: \1/'	\
		| sed	's/\.c/.o/' >makedep
		echo '/^# DO NOT DELETE	THIS LINE/+2,$$d' >eddep
		echo '$$r makedep' >>eddep
		echo 'w' >>eddep
		cp Makefile .,oldmake
		cp Makefile ,Makefile
		ed - ,Makefile < eddep
		/bin/rm eddep makedep
		echo '#	DEPENDENCIES MUST END AT END OF	FILE' >>,Makefile
		echo '#	IF YOU PUT STUFF HERE IT WILL GO AWAY'>>,Makefile
		echo '#	see make depend	above'>>,Makefile
		/bin/mv ,Makefile Makefile

# DO NOT DELETE	THIS LINE
# DEPENDENCIES MUST END	AT END OF FILE
chprio.o: ../h/conf.h
chprio.o: ../h/kernel.h
chprio.o: ../h/proc.h
clkinit.o: ../h/conf.h
clkinit.o: ../h/kernel.h
clkinit.o: ../h/sleep.h
clkinit.o: ../h/quantum.h
clkinit.o: ../h/slu.h
close.o: ../h/conf.h
close.o: ../h/kernel.h
close.o: ../h/io.h
control.o: ../h/conf.h
control.o: ../h/kernel.h
control.o: ../h/io.h
create.o: ../h/conf.h
create.o: ../h/kernel.h
create.o: ../h/proc.h
create.o: ../h/mem.h
create.o: ../h/magic.h
duarthandlr.o: ../h/slu.h
duarthandlr.o: ../h/kernel.h
duarthandlr.o: ../h/tty.h
freebuf.o: ../h/conf.h
freebuf.o: ../h/kernel.h
freebuf.o: ../h/mark.h
freebuf.o: ../h/bufpool.h
freemem.o: ../h/conf.h
freemem.o: ../h/kernel.h
freemem.o: ../h/mem.h
getbuf.o: ../h/conf.h
getbuf.o: ../h/kernel.h
getbuf.o: ../h/mark.h
getbuf.o: ../h/bufpool.h
getc.o: ../h/conf.h
getc.o: ../h/kernel.h
getc.o: ../h/io.h
getitem.o: ../h/conf.h
getitem.o: ../h/kernel.h
getitem.o: ../h/q.h
getmem.o: ../h/conf.h
getmem.o: ../h/kernel.h
getmem.o: ../h/mem.h
getpid.o: ../h/conf.h
getpid.o: ../h/kernel.h
getpid.o: ../h/proc.h
getprio.o: ../h/conf.h
getprio.o: ../h/kernel.h
getprio.o: ../h/proc.h
getstk.o: ../h/conf.h
getstk.o: ../h/kernel.h
getstk.o: ../h/mem.h
init.o: ../h/conf.h
init.o: ../h/kernel.h
init.o: ../h/io.h
initialize.o: ../h/conf.h
initialize.o: ../h/kernel.h
initialize.o: ../h/proc.h
initialize.o: ../h/sem.h
initialize.o: ../h/mem.h
initialize.o: ../h/slu.h
initialize.o: ../h/tty.h
initialize.o: ../h/q.h
initialize.o: ../h/io.h
initialize.o: ../h/disk.h
initialize.o: ../h/magic.h
insert.o: ../h/conf.h
insert.o: ../h/kernel.h
insert.o: ../h/q.h
insertd.o: ../h/conf.h
insertd.o: ../h/kernel.h
insertd.o: ../h/q.h
ioerr.o: ../h/conf.h
ioerr.o: ../h/kernel.h
ionull.o: ../h/conf.h
ionull.o: ../h/kernel.h
kill.o: ../h/conf.h
kill.o: ../h/kernel.h
kill.o: ../h/proc.h
kill.o: ../h/sem.h
kill.o: ../h/mem.h
kprintf.o: ../h/conf.h
kprintf.o: ../h/kernel.h
kprintf.o: ../h/io.h
kprintf.o: ../h/slu.h
kprintf.o: ../h/tty.h
mark.o: ../h/conf.h
mark.o: ../h/kernel.h
mark.o: ../h/mark.h
mdump.o: ../h/kernel.h
mdump.o: ../h/mem.h
mkpool.o: ../h/conf.h
mkpool.o: ../h/kernel.h
mkpool.o: ../h/mark.h
mkpool.o: ../h/bufpool.h
newqueue.o: ../h/conf.h
newqueue.o: ../h/kernel.h
newqueue.o: ../h/q.h
open.o: ../h/conf.h
open.o: ../h/kernel.h
open.o: ../h/io.h
pcount.o: ../h/conf.h
pcount.o: ../h/kernel.h
pcount.o: ../h/mark.h
pcount.o: ../h/ports.h
pcreate.o: ../h/conf.h
pcreate.o: ../h/kernel.h
pcreate.o: ../h/mark.h
pcreate.o: ../h/ports.h
pdelete.o: ../h/conf.h
pdelete.o: ../h/kernel.h
pdelete.o: ../h/mark.h
pdelete.o: ../h/ports.h
pinit.o: ../h/conf.h
pinit.o: ../h/kernel.h
pinit.o: ../h/mark.h
pinit.o: ../h/ports.h
poolinit.o: ../h/conf.h
poolinit.o: ../h/kernel.h
poolinit.o: ../h/mark.h
poolinit.o: ../h/bufpool.h
prdump.o: ../h/conf.h
prdump.o: ../h/kernel.h
prdump.o: ../h/proc.h
prdump.o: ../h/q.h
preceive.o: ../h/conf.h
preceive.o: ../h/kernel.h
preceive.o: ../h/mark.h
preceive.o: ../h/ports.h
preset.o: ../h/conf.h
preset.o: ../h/kernel.h
preset.o: ../h/mark.h
preset.o: ../h/ports.h
psend.o: ../h/conf.h
psend.o: ../h/kernel.h
psend.o: ../h/mark.h
psend.o: ../h/ports.h
ptclear.o: ../h/conf.h
ptclear.o: ../h/kernel.h
ptclear.o: ../h/mark.h
ptclear.o: ../h/ports.h
putc.o: ../h/conf.h
putc.o: ../h/kernel.h
putc.o: ../h/io.h
qdump.o: ../h/conf.h
qdump.o: ../h/kernel.h
qdump.o: ../h/proc.h
qdump.o: ../h/q.h
queue.o: ../h/conf.h
queue.o: ../h/kernel.h
queue.o: ../h/q.h
read.o: ../h/conf.h
read.o: ../h/kernel.h
read.o: ../h/io.h
ready.o: ../h/conf.h
ready.o: ../h/kernel.h
ready.o: ../h/proc.h
ready.o: ../h/q.h
receive.o: ../h/conf.h
receive.o: ../h/kernel.h
receive.o: ../h/proc.h
recvclr.o: ../h/conf.h
recvclr.o: ../h/kernel.h
recvclr.o: ../h/proc.h
resched.o: ../h/conf.h
resched.o: ../h/kernel.h
resched.o: ../h/proc.h
resched.o: ../h/q.h
resched.o: ../h/magic.h
resched.o: ../h/quantum.h
resume.o: ../h/conf.h
resume.o: ../h/kernel.h
resume.o: ../h/proc.h
scount.o: ../h/conf.h
scount.o: ../h/kernel.h
scount.o: ../h/sem.h
screate.o: ../h/conf.h
screate.o: ../h/kernel.h
screate.o: ../h/proc.h
screate.o: ../h/q.h
screate.o: ../h/sem.h
sdelete.o: ../h/conf.h
sdelete.o: ../h/kernel.h
sdelete.o: ../h/proc.h
sdelete.o: ../h/q.h
sdelete.o: ../h/sem.h
seek.o: ../h/conf.h
seek.o: ../h/kernel.h
seek.o: ../h/io.h
send.o: ../h/conf.h
send.o: ../h/kernel.h
send.o: ../h/proc.h
sendf.o: ../h/conf.h
sendf.o: ../h/kernel.h
sendf.o: ../h/proc.h
signal.o: ../h/conf.h
signal.o: ../h/kernel.h
signal.o: ../h/proc.h
signal.o: ../h/q.h
signal.o: ../h/sem.h
signaln.o: ../h/conf.h
signaln.o: ../h/kernel.h
signaln.o: ../h/proc.h
signaln.o: ../h/q.h
signaln.o: ../h/sem.h
sleep.o: ../h/conf.h
sleep.o: ../h/kernel.h
sleep.o: ../h/proc.h
sleep.o: ../h/q.h
sleep.o: ../h/sleep.h
sleep10.o: ../h/conf.h
sleep10.o: ../h/kernel.h
sleep10.o: ../h/proc.h
sleep10.o: ../h/q.h
sleep10.o: ../h/sleep.h
sreset.o: ../h/conf.h
sreset.o: ../h/kernel.h
sreset.o: ../h/proc.h
sreset.o: ../h/q.h
sreset.o: ../h/sem.h
ssclock.o: ../h/conf.h
ssclock.o: ../h/kernel.h
ssclock.o: ../h/proc.h
ssclock.o: ../h/q.h
ssclock.o: ../h/sleep.h
suspend.o: ../h/conf.h
suspend.o: ../h/kernel.h
suspend.o: ../h/proc.h
tdump.o: ../h/conf.h
tdump.o: ../h/kernel.h
tdump.o: ../h/tty.h
test.o: ../h/kernel.h
test.o: ../h/conf.h
ttycntl.o: ../h/conf.h
ttycntl.o: ../h/kernel.h
ttycntl.o: ../h/tty.h
ttycntl.o: ../h/io.h
ttycntl.o: ../h/slu.h
ttygetc.o: ../h/conf.h
ttygetc.o: ../h/kernel.h
ttygetc.o: ../h/tty.h
ttygetc.o: ../h/io.h
ttygetc.o: ../h/slu.h
ttyiin.o: ../h/conf.h
ttyiin.o: ../h/kernel.h
ttyiin.o: ../h/tty.h
ttyiin.o: ../h/io.h
ttyiin.o: ../h/slu.h
ttyinit.o: ../h/conf.h
ttyinit.o: ../h/kernel.h
ttyinit.o: ../h/tty.h
ttyinit.o: ../h/io.h
ttyinit.o: ../h/slu.h
ttyoin.o: ../h/conf.h
ttyoin.o: ../h/kernel.h
ttyoin.o: ../h/tty.h
ttyoin.o: ../h/io.h
ttyoin.o: ../h/slu.h
ttyputc.o: ../h/conf.h
ttyputc.o: ../h/kernel.h
ttyputc.o: ../h/tty.h
ttyputc.o: ../h/io.h
ttyputc.o: ../h/slu.h
ttyread.o: ../h/conf.h
ttyread.o: ../h/kernel.h
ttyread.o: ../h/tty.h
ttyread.o: ../h/io.h
ttyread.o: ../h/slu.h
ttywrite.o: ../h/conf.h
ttywrite.o: ../h/kernel.h
ttywrite.o: ../h/tty.h
ttywrite.o: ../h/io.h
ttywrite.o: ../h/slu.h
userret.o: ../h/conf.h
userret.o: ../h/kernel.h
wait.o: ../h/conf.h
wait.o: ../h/kernel.h
wait.o: ../h/proc.h
wait.o: ../h/q.h
wait.o: ../h/sem.h
wakeup.o: ../h/conf.h
wakeup.o: ../h/kernel.h
wakeup.o: ../h/proc.h
wakeup.o: ../h/q.h
wakeup.o: ../h/sleep.h
write.o: ../h/conf.h
write.o: ../h/kernel.h
write.o: ../h/io.h
../h/disk.h: ../h/xebec.h
../h/disk.h: ../h/dtc.h
../h/file.h: ../h/iblock.h
../h/slu.h: ../h/dl11.h
../h/slu.h: ../h/duart681.h
../h/slu.h: ../h/duart681.h
#	DEPENDENCIES MUST END AT END OF	FILE
#	IF YOU PUT STUFF HERE IT WILL GO AWAY
#	see make depend	above
