#############################################################################
#	Program Name:	LOADER for zebra
#
#	Filename:	Makefile
#
#	Creation Date:	5.8.91
#
#	Date:		5.8.91
#
#	Version:	1.0
#
#	Modifications:
#
#	Comments:	The makefile for the loader
#			This makefile will call all other makefiles 
#			to produce the loader image.  The directory
#			structures are:=
#
#			Makefile	This file
#				
#			main.c		The main function
#			booter/
#				system/	It contains the startup module,
#					fault table, interrupt table and
#					prob ...etc.
#
#	Copyright (c) 1991 by Hughes LAN Systems
#
#############################################################################
# Defaults to GNU/960 tool set:
#

.LOGFILE .c_v(.c)
.LOGFILE .s_v(.s)
.LOGFILE .h_v(.h)

CC	= gcc960			# gnu960 cross C compiler 
ARCH	= -ACA				# This is CA architecture
OPT	= -O3 -c -DSTANLEY -DZEBRA 	# O3 - optimization level 3
					# c  - compile only
VERSION	=
VER	=
CFLAGS	= ${ARCH} -I${IDIR1} -I${IDIR2} -I${IDIR3} ${OPT} -mstrict-align 
					#
					# I - 	specify the search path for
					# 	any include files
					# mstrict-align
					#	Sequences of smaller memory
					#	reference are used instead
					#	of larger ones which might
					#	not be correctly aligned.
AS	= gas960			# gnu960 assembler
ASFLAGS	= ${ARCH}
LD	= gld960  			# gnu960 linker
TOOLSET = ${GFLAG}

# Essential under System V, harmless elsewhere
SHELL = /bin/sh

# Standard rules
#
.c_v.c:
	=get $(GETOPTS) $<\($@\)

.h_v.h:
	=get $(GETOPTS) $<\($@\)

.s_v.s:
	=get $(GETOPTS) $<\($@\)

.c.o:
	${CC} ${CFLAGS} $*.c

.s.o:
	${AS} ${ASFLAGS} -o $*.o $*.s

.c.s:
	${CC} ${CFLAGS} -S -c $*.c

#------------------------------------------------------------------------------
# Where to find things (include files, ROM images)
#------------------------------------------------------------------------------
#ROOT	= /h/pvcs
PIDIR1	= ${ROOT}/bridge/include	# where the .h_v files are
PIDIR2	= ${ROOT}/i960/include
PSDIR	= ${ROOT}/bridge/booter		# where the .c_v and .s_v files are

IDIR1	= ../include
IDIR2	= ../../i960/include
IDIR3	= ../../i960/bp_ring
.PATH.h_v = ${PIDIR1} ;${PIDIR2} 
.PATH.h   = ${IDIR1} ;${IDIR2} 
.PATH.c_v = ${PSDIR}
.PATH.s_v = ${PSDIR}


#------------------------------------------------------------------------------
# TARG OBJECT FILES
#------------------------------------------------------------------------------
BOOTER = ../booter/booter
LOADER_OBJS= startup.o main.o system/system ../tr_util/hw_sled.o \
		../tester/ramtest.o ../tester/quadtest.o
TARG_IBR = system/imi.o

# Address at which 960CX Initial Boot Record must be linked
IBR_ADDR = 0xffffff00
LOADER_ADDR = 0xffff0000
LOADER_DATA = 0x2ffe0000

loader: startup.o main.o Makefile ${BOOTER}
	${LD} ${ARCH} -o loader -M -Ttext ${LOADER_ADDR} \
		-e _start_l -defsym _load_addr=${LOADER_ADDR} \
		 ${LOADER_OBJS} \
		-Tdata ${LOADER_DATA}

#	makenim loader
#	boutnim loader loader.nim
	${LD} ${ARCH} -o ibr -T ${IBR_ADDR} -R loader \
		-defsym _cs6=-_rom_prcb-_start_l ${TARG_IBR} 
#	grom960 -l0x40000 -m -i -oloader.bin /b/yan/fddi_ether/bridge/booter/booter loader,0x30000 ibr,0x3ff00
	grom960 -l0x80000 -m -i -ochboot.bin ${BOOTER} loader,0x70000 ibr,0x7ff00

startup.o:	Makefile

main.o:		Makefile ${IDIR2}/krnl.h ${IDIR1}/target.h  \
		${IDIR1}/memory.h ${IDIR2}/types.h \
		${IDIR2}/eeprom.h ${IDIR2}/nim960h.h ${IDIR2}/uart.h \
		${IDIR1}/dips.h ${IDIR1}/led.h ${IDIR1}/sys.h \
		${IDIR1}/eeprecs.h ${IDIR2}/sncvar.h ${IDIR2}/malloc.h \
		${IDIR2}/dbd.h ${IDIR1}/sys.h ${IDIR2}/sonic.h ${IDIR2}/inc.h
