# $Id: Makefile,v 1.7 1996/08/01 02:08:31 paul Exp $
# Makefile for SunOS Minix, using environment variables $MX_INCL and $MX_LIB
# to locate the Minix include and library files on the SunOS file system
#
CC              = mcc
LDFLAGS 	= -M kernel.map -dn -e start
LIBS		=$l/libc.a
OTHER		=
CFLAGS          = -ansi -DALLOW_GAP_MESSAGES
LIB		=$(MX_LIB)
INC		=$(MX_INCL)
LD		=ld


h		=$(INC)/minix
i		=$(INC)
l		=$(LIB)
s		=$(INC)/sys
sun		=$(INC)/sun

a		=$h/config.h $i/ansi.h $s/types.h $h/const.h $h/type.h \
                 $h/syslib.h $i/string.h $i/limits.h \
		 $i/errno.h const.h type.h uc_offset.h proto.h glo.h
d               =driver.h $h/callnr.h $h/com.h $h/partition.h proc.h


START		= main.o

KEROBJS		= startSUN.o table.o mpx.o proc.o clock.o tty.o \
		  sunconsole.o system.o copySUN.o dmp.o sunkeyboard.o \
		  sunfloppy.o  memory.o misc.o sunprinter.o \
		  sunexception.o debug.o sunprotect.o logging.o \
                  driver.o pty.o sunsigio.o sunether.o

SOBJS		=

kernel: $(START) $(KEROBJS) $(LIBS)
	$(LD) $(LDFLAGS) -o kernel.elf $(START) $(KEROBJS) $(LIBS)
	elf2smx -S 0 kernel.elf kernel
	rm kernel.elf
	combine

.s.o:
	as -P -I$(MX_INCL) -o $*.o $*.s

clean:
	rm -f $(START) $(KEROBJS) $(SOBJS) a.out core kernel kernel.elf \
	    make_offset uc_offset.h

make_offset: make_offset.c
	gcc -o make_offset make_offset.c

uc_offset.h: make_offset
	./make_offset >uc_offset.h
	
clock.o:	$a
clock.o:	$i/signal.h
clock.o:	$h/callnr.h
clock.o:	$h/com.h
clock.o:	proc.h

copySUN.o:	$h/config.h
copySUN.o:	$h/const.h

debug.o:	$a
debug.o:	$(sun)/syscall.h

dmp.o:		$a
dmp.o:		$h/com.h
dmp.o:		proc.h
dmp.o:		tty.h
dmp.o:		logging.h

driver.o:       $a $d
driver.o:	$s/ioctl.h

logging.o:      $a
logging.o:      logging.h
logging.o:      $(sun)/syscall.h
logging.o:      proc.h

main.o:		$a
main.o:		$i/unistd.h
main.o:		$h/callnr.h
main.o:		$h/com.h
main.o:		$h/boot.h
main.o:		proc.h
main.o: 	$(sun)/syscall.h
main.o:		logging.h
main.o:		bootinfo.h

memory.o:	$a $d
memory.o:	driver.h

misc.o:		$a
misc.o:		$i/stdlib.h
misc.o:		$h/com.h
misc.o:		assert.h

mpx.o:		$(sun)/syscall.h
mpx.o:		$(sun)/signal.h
mpx.o:		$a
mpx.o:		proc.h

proc.o:		$a
proc.o:		$h/callnr.h
proc.o:		$h/com.h
proc.o:		proc.h
proc.o: 	logging.h

pty.o:  $a
pty.o:  $i/termios.h
pty.o:  $i/signal.h
pty.o:  $h/callnr.h
pty.o:  $h/com.h
pty.o:  tty.h
pty.o:  proc.h

sunconsole.o:	$a
sunconsole.o:	proc.h
sunconsole.o:	$h/callnr.h
sunconsole.o:	$h/com.h
sunconsole.o:	tty.h
sunconsole.o:	$i/signal.h
sunconsole.o:	$(sun)/syscall.h

sunether.o: 	$a
sunether.o:	$h/callnr.h
sunether.o:	$h/com.h
sunether.o:	$i/net/gen/ether.h
sunether.o:	$i/net/gen/eth_io.h
sunether.o: 	proc.h
sunether.o: 	assert.h
sunether.o:	$(sun)/syscall.h

sunexception.o: $a
sunexception.o: proc.h
sunexception.o: $(sun)/signal.h
sunexception.o: $(sun)/syscall.h

sunfloppy.o:	$a
sunfloppy.o:	$h/callnr.h
sunfloppy.o:	$h/com.h
sunfloppy.o:	$h/boot.h
sunfloppy.o:	$(sun)/syscall.h
sunfloppy.o:	$s/ioctl.h
sunfloppy.o:	driver.h

sunsigio.o:     $a
sunsigio.o:     $(sun)/syscall.h

sunkeyboard.o:	$a
sunkeyboard.o:	$h/callnr.h
sunkeyboard.o:	$h/com.h
sunkeyboard.o:	$i/termios.h
sunkeyboard.o:	tty.h
sunkeyboard.o:	proc.h
sunkeyboard.o:	$(sun)/syscall.h

sunprinter.o:	$a
sunprinter.o:	$h/callnr.h
sunprinter.o:	$h/com.h

sunprotect.o:   $a
sunprotect.o:   const.h
sunprotect.o:   $h/com.h
sunprotect.o:   $(sun)/syscall.h
sunprotect.o:	proc.h

system.o:	$a
system.o:	$i/signal.h
system.o:	$i/unistd.h
system.o:	$s/sigcontext.h
system.o:	$s/ptrace.h
system.o:	$h/boot.h
system.o:	$h/callnr.h
system.o:	$h/com.h
system.o:	proc.h
system.o:	logging.h

table.o:	$a
table.o:	$i/termios.h
table.o:	$h/com.h
table.o:	proc.h
table.o:	tty.h

tty.o:		$a
tty.o:		$i/termios.h
tty.o:		$i/sgtty.h
tty.o:		$s/ioctl.h
tty.o:		$i/signal.h
tty.o:		$h/callnr.h
tty.o:		$h/com.h
tty.o:		logging.h
tty.o:		proc.h
tty.o:		tty.h
tty.o:          assert.h
