#	START NEW ARIX SCCS HEADER
#
#	@(#) makefile: version 25.1 created on 11/27/91 at 14:47:18
#
#	Copyright (c) 1990 by Arix Corporation
#	All Rights Reserved
#
#	@(#)makefile	25.1	11/27/91 Copyright (c) 1990 by Arix Corporation
#
#	END NEW ARIX SCCS HEADER
#

# IROOT is provided by the driving makefile or script OR
# for stand alone makes, PWD provide as a command line varible or
# environment varible (ksh).

IROOT   = $(PWD)/..
SHELL   = /bin/sh
include $(IROOT)/macdefs

# Local defaults.
# Local users of this makefile can turn off asserts by setting DEBUGOPT=""

DEBUGOPT = -DASDEBUG=YES

MACH = M68040
UMACH = M68020

AS = $(SGS_ROOT)/bin/as3

LOCINC = $(IOPMINC)/sys
LOCAL_CFLAGS = -T3 $(DEBUGOPT) -DIOPM_OS -DIOPM -I$(LOCINC)

SRCFILES = \
		sys/buf.h \
		sys/buf_conf.h \
		sys/callo.h \
		sys/devsw.h \
		sys/dma.h \
		sys/iopm.h \
		sys/iopmconf.h \
		sys/str_conf.h \
		sys/sysmacros.h \
		sys/systm.h \
		sys/tcb.h \
		sys/user.h \
		os/bio.c \
		os/bufmgr.c \
		os/clock.c \
		os/config.c \
		os/css.c \
		os/iomap.c \
		os/kstream.c \
		os/machdep.c \
		os/malloc.c \
		os/prf.c \
		os/slp.c \
		os/space.c \
		os/startup.c \
		os/stream.c \
		os/strhd.c \
		os/strmgr.c \
		os/synch.c \
		os/tcb.c \
		os/tdb.c \
		os/trap.c \
		os/userio.c \
		db/bag.c \
		ml/build_addr.c \
		ml/misc.s \
		ml/start.s \
		ml/ttrap.s

# the file jmptbl.o must be first
FILELIST = jmptbl.o $(ML_OBJS) $(OS_OBJS) $(DEBUG_OBJS)

OS_OBJS = \
		os/bio.o \
		os/bufmgr.o \
		os/clock.o \
		os/config.o \
		os/css.o \
		os/iomap.o \
		os/kstream.o \
		os/machdep.o \
		os/malloc.o \
		os/prf.o \
		os/slp.o \
		os/startup.o \
		os/stream.o \
		os/strhd.o \
		os/strmgr.o \
		os/synch.o \
		os/tcb.o \
		os/tdb.o \
		os/trap.o \
		os/userio.o


DEBUG_OBJS = \
		db/bag.o

ML_OBJS = \
		ml/addr.o \
		ml/misc.o \
		ml/scb.o \
		ml/start.o \
		ml/ttrap.o

RELDIRS	= M68020/NDBG M68020/DBG M68040/NDBG M68040/DBG

default: jmplib.o iopm
	sh makemap iopm &

all: $(RELDIRS)
	$(MAKE) jmplib.o
	@echo --- Now making 68040 nonASSERTed iopm ---
	$(MAKE) clean
	$(MAKE) MACH=M68040 UMACH=M68020 DEBUGOPT="" iopm
	cp iopm.o iopm jmplib.o M68040/NDBG
	@echo --- Now making 68040 ASSERTed iopm ---
	$(MAKE) clean
	$(MAKE) MACH=M68040 UMACH=M68020 DEBUGOPT=-DASDEBUG=YES iopm
	cp iopm.o iopm jmplib.o M68040/DBG
	@echo --- Now making 68020 nonASSERTed iopm ---
	$(MAKE) clean
	$(MAKE) MACH=M68020 UMACH=M68040 DEBUGOPT="" iopm
	cp iopm.o iopm jmplib.o M68020/NDBG
	@echo --- Now making 68020 ASSERTed iopm ---
	$(MAKE) clean
	$(MAKE) MACH=M68020 UMACH=M68040 DEBUGOPT=-DASDEBUG=YES iopm
	cp iopm.o iopm jmplib.o M68020/DBG

iopm: iifile iopm.o os/space.o
	$(LD) -o iopm iifile iopm.o os/space.o

iopm.o: $(FILELIST)
	@echo "\tLinking"
	@$(LD) -r -o iopm.o $(FILELIST)

print:
	@pr -n $(SRCFILES)

lint:
	lint -un -DIOPM_OS -DIOPM -I$(LOCINC) -I$(PMINC) os/*.c > lintout

clobber: clean
	rm -f M68020/*/* M68040/*/*
	rm -f */tags tags lintout jmplib.s jmplib.o jmptbl.s

clean:
	rm -f $(FILELIST) os/space.o iopm.o iopm s iopm.map ml/addr.s

$(RELDIRS):
	mkdir $@

jmplib.o:	build_lib.c \
	$(PMINC)/sys/types.h
	$(CC) -I$(LOCINC) -I$(PMINC) build_lib.c -o build_lib
	./build_lib 1> jmplib.s 2> /dev/null
	$(CC) -c jmplib.s
	rm build_lib

jmptbl.o:	build_lib.c \
	$(PMINC)/sys/types.h
	$(CC) -I$(LOCINC) -I$(PMINC) build_lib.c -o build_lib
	./build_lib 2> jmptbl.s 1> /dev/null
	$(CC) -c jmptbl.s
	rm build_lib

ml/addr.o:	ml/build_addr.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/spm_mem.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(LOCINC)/iopm.h
	cd ml;\
	$(CC) $(CFLAGS) build_addr.c -o build_addr;\
	./build_addr > addr.s;\
	$(CC) -c addr.s;\
	rm build_addr

.c.o:
	cd $(<D); exec $(CC) $(CFLAGS) -c $(<F)

.c.s:
	cd $(<D); exec $(CC) $(CFLAGS) -S $(<F)

os/bio.o:	os/bio.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/buf.h \
	$(LOCINC)/iopm.h \
	$(PMINC)/sys/iopmcomm.h \
	$(LOCINC)/sysmacros.h \
	$(PMINC)/sys/iopmsltbl.h \
	$(PMINC)/sys/iopmbuf.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/map.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/bufstat.h \
	$(LOCINC)/buf.h \
	$(LOCINC)/devsw.h \
	$(LOCINC)/dma.h \
	$(PMINC)/sys/errno.h \
	$(LOCINC)/user.h \
	$(PMINC)/sys/param.h

os/bufmgr.o:	os/bufmgr.c \
	$(PMINC)/sys/open.h \
	$(PMINC)/sys/errno.h \
	$(PMINC)/sys/debug.h \
	$(LOCINC)/sysmacros.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/cmn_err.h \
	$(LOCINC)/tcb.h \
	$(LOCINC)/user.h \
	$(LOCINC)/proc.h \
	$(PMINC)/sys/mfs.h \
	$(PMINC)/sys/buf.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/iopmbuf.h \
	$(LOCINC)/buf.h \
	$(LOCINC)/devsw.h \
	$(LOCINC)/dma.h \
	$(PMINC)/sys/spm_mem.h \
	$(PMINC)/sys/sbus_spm.h \
	$(PMINC)/sys/iopmsltbl.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/iopmstat.h \
	$(LOCINC)/iopm.h

os/clock.o:	os/clock.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/param.h \
	$(LOCINC)/tcb.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(LOCINC)/callo.h

os/config.o:	os/config.c \
	$(LOCINC)/devsw.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/kmem.h \
	$(PMINC)/sys/types.h \
	$(LOCINC)/tcb.h \
	$(PMINC)/sys/errno.h \
	$(PMINC)/sys/sbus_pm.h \
	$(PMINC)/sys/spm_mem.h \
	$(LOCINC)/stream.h \
	$(PMINC)/sys/immu.h \
	$(LOCINC)/sysmacros.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/cmn_err.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(PMINC)/sys/ints.h \
	$(PMINC)/sys/iopmbuf.h \
	$(PMINC)/sys/iopmdebug.h \
	$(LOCINC)/buf_conf.h \
	$(LOCINC)/str_conf.h \
	$(LOCINC)/user.h \
	$(LOCINC)/sysinfo.h

os/css.o:	os/css.c \
	$(PMINC)/sys/iopmbuf.h \
	$(PMINC)/sys/kmem.h \
	$(PMINC)/sys/iopmcomm.h \
	$(LOCINC)/tcb.h \
	$(LOCINC)/buf.h \
	$(PMINC)/sys/sbus_pm.h \
	$(PMINC)/sys/spm_mem.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/ints.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/buf.h \
	$(PMINC)/sys/iopmstat.h

os/iomap.o:	os/iomap.c \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(PMINC)/sys/debug.h

os/kstream.o:	os/kstream.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/stream.h \
	$(PMINC)/sys/stropts.h \
	$(PMINC)/sys/strstat.h \
	$(PMINC)/sys/spm_mem.h \
	$(LOCINC)/stream.h \
	$(PMINC)/sys/iopmstream.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/iopmstat.h

os/machdep.o:	os/machdep.c \
	$(PMINC)/sys/types.h \
	$(LOCINC)/sysmacros.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/spm_mem.h \
	$(PMINC)/sys/kmem.h \
	$(PMINC)/sys/debug.h \
	$(LOCINC)/iopm.h \
	$(PMINC)/sys/iopm_mmu.h \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/systm.h \
	$(PMINC)/sys/map.h \
	$(PMINC)/sys/cmn_err.h \
	$(PMINC)/sys/iopmbuf.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/iopmdebug.h

os/malloc.o:	os/malloc.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/cmn_err.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/map.h \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/iopmcomm.h

os/prf.o:	os/prf.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/cmn_err.h

os/slp.o:	os/slp.c \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/cmn_err.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(LOCINC)/user.h \
	$(LOCINC)/proc.h \
	$(LOCINC)/tcb.h

os/space.o:	os/space.c \
	$(PMINC)/sys/types.h \
	$(LOCINC)/callo.h \
	$(PMINC)/sys/fs/s5param.h \
	$(PMINC)/sys/map.h \
	$(PMINC)/sys/iopmstat.h \
	$(LOCINC)/stream.h \
	$(LOCINC)/iopmconf.h \
	$(LOCINC)/buf.h \
	$(LOCINC)/tcb.h \
	$(LOCINC)/devsw.h

os/startup.o:	os/startup.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/kmem.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/spm_mem.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(PMINC)/sys/iopmstat.h \
	$(LOCINC)/iopm.h \
	$(LOCINC)/tcb.h

os/stream.o:	os/stream.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/param.h \
	$(LOCINC)/sysmacros.h \
	$(PMINC)/sys/cmn_err.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/map.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(LOCINC)/devsw.h \
	$(LOCINC)/stream.h \
	$(PMINC)/sys/strstat.h

os/strhd.o:	os/strhd.c \
	$(PMINC)/sys/errno.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/param.h \
	$(LOCINC)/sysmacros.h \
	$(PMINC)/sys/file.h \
	$(LOCINC)/user.h \
	$(LOCINC)/proc.h \
	$(PMINC)/sys/stream.h \
	$(LOCINC)/stream.h \
	$(PMINC)/sys/iopmstream.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/stropts.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/cmn_err.h \
	$(LOCINC)/tcb.h \
	$(LOCINC)/iopm.h \
	$(LOCINC)/devsw.h

os/strmgr.o:	os/strmgr.c \
	$(PMINC)/sys/errno.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/param.h \
	$(LOCINC)/sysmacros.h \
	$(LOCINC)/stream.h \
	$(PMINC)/sys/iopmstream.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/stropts.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/iopmstat.h \
	$(LOCINC)/devsw.h \
	$(PMINC)/sys/cmn_err.h

os/synch.o:	os/synch.c \
	$(PMINC)/sys/spm_mem.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/iopmcomm.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/synch.h

os/tcb.o:	os/tcb.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/cmn_err.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/map.h \
	$(LOCINC)/iopm.h \
	$(PMINC)/sys/iopmcomm.h \
	$(LOCINC)/stream.h \
	$(LOCINC)/user.h \
	$(LOCINC)/tcb.h \
	$(PMINC)/sys/iopmdebug.h \
	$(PMINC)/sys/bufstat.h

os/tdb.o:	os/tdb.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/state.h \
	$(PMINC)/sys/own.h \
	$(PMINC)/sys/trap.h \
	$(PMINC)/sys/psl.h \
	$(PMINC)/sys/debug.h \
	$(PMINC)/sys/errno.h \
	$(PMINC)/sys/iopmcomm.h

os/trap.o:	os/trap.c \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/psl.h \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/state.h \
	$(PMINC)/sys/sbus_iopm.h \
	$(PMINC)/sys/immu.h \
	$(LOCINC)/iopm.h \
	$(LOCINC)/tcb.h

os/userio.o:	os/userio.c \
	$(PMINC)/sys/iopmbuf.h \
	$(PMINC)/sys/errno.h \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/iopmdebug.h \
	$(LOCINC)/user.h \
	$(LOCINC)/buf.h

db/bag.o:	db/bag.c \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/types.h

ml/misc.o:	ml/misc.s
	m4 $(DEBUGFLAGS) $(PROC) ml/misc.s > m.s
	$(CC) $(CFLAGS) -c m.s
	rm m.s
	mv m.o ml/misc.o

$(LOCINC)/buf.h: \
	$(PMINC)/sys/buf.h \
	$(PMINC)/sys/types.h

$(LOCINC)/devsw.h: \
	$(PMINC)/sys/types.h

$(LOCINC)/tcb.h: \
	$(PMINC)/sys/user.h \
	$(PMINC)/sys/buf.h \
	$(PMINC)/sys/immu.h

$(PMINC)/user.h: \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/buf.h

$(PMINC)/sys/buf.h: \
	$(PMINC)/sys/types.h

$(PMINC)/sys/file.h: \
	$(PMINC)/sys/types.h

$(PMINC)/sys/immu.h: \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/vmem.h

$(PMINC)/sys/iopmbuf.h: \
	$(PMINC)/sys/types.h

$(PMINC)/sys/iopmcomm.h: \
	$(PMINC)/sys/buf.h \
	$(PMINC)/sys/stream.h \
	$(PMINC)/sys/strstat.h \
	$(PMINC)/sys/bufstat.h \
	$(PMINC)/sys/tdb.h \
	$(PMINC)/sys/sbus_iopm.h

$(PMINC)/sys/iopmstream.h: \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/stream.h

$(PMINC)/sys/kmem.h: \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/sbus_spm.h \
	$(PMINC)/sys/vmem.h \
	$(PMINC)/sys/pm_iomap.h \
	$(PMINC)/sys/M68020/Mkmem.h

$(PMINC)/sys/mfs.h: \
	$(PMINC)/sys/synch.h \
	$(PMINC)/sys/own.h

$(PMINC)/sys/own.h: \
	$(PMINC)/sys/proc.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/tdb.h \
	$(PMINC)/sys/state.h \
	$(PMINC)/sys/upkern.h

$(PMINC)/sys/param.h: \
	$(PMINC)/sys/fs/s5param.h

$(PMINC)/sys/pm_iomap.h: \
	$(PMINC)/sys/types.h

$(PMINC)/sys/proc.h: \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/region.h \
	$(PMINC)/sys/synch.h \
	$(PMINC)/sys/user.h

$(PMINC)/sys/region.h: \
	$(PMINC)/sys/immu.h

$(PMINC)/sys/sbus.h: \
	$(PMINC)/sys/types.h

$(PMINC)/sys/spm_mem.h:
	$(PMINC)/sys/stream.h \
	$(PMINC)/sys/synch.h \
	$(PMINC)/sys/strstat.h \
	$(PMINC)/sys/ints.h \
	$(PMINC)/sys/sbus.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/own.h

$(PMINC)/sys/stream.h: \
	$(PMINC)/sys/synch.h \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/stropts.h \
	$(PMINC)/sys/kmem.h

$(PMINC)/sys/synch.h: \
	$(PMINC)/sys/types.h

$(LOCINC)/sysmacros.h: \
	$(PMINC)/sys/types.h

$(PMINC)/sys/tdb.h: \
	$(PMINC)/sys/types.h \
	$(PMINC)/sys/state.h

$(PMINC)/sys/user.h: \
	$(PMINC)/sys/fpu.h \
	$(PMINC)/sys/fs/s5dir.h \
	$(PMINC)/sys/param.h \
	$(PMINC)/sys/signal.h \
	$(PMINC)/sys/immu.h \
	$(PMINC)/sys/state.h

$(PMINC)/sys/kmem.h: \
	$(PMINC)/sys/M68020/Mkmem.h
