# Vidy modified the 8 bit flash version to support 16 bit flash
# also added support for scc_3 debug
# file names with "_x" suffix stands for debugger port on scc "x"

# The debug mode is not supported, it is needed if rmon itself is to be
# debugged thru PassKey. But now I use bd32 from motorola with ICD cable
DEBUG = 0
ASM = asm68360
LST = lst\ 
OLS = ols\ 

!if $(DEBUG)
ASMOPS = -s -d -bl -g -P -err+ a.err
FORMOPS = rm.ab -x rm.xdb -f pm -err formt.err
OLSFILE = db_rm.ols
!else
#ASMOPS = -s -g -bl -P -err+ a_4.err
ASMOPS = -s -g -P -err+ a_4.err
FORMOPS_4 = rm_4.ab -f pm -err formt_4.err
OLSFILE_4 = rm_4.ols

FORMOPS_3e = rm_3.abs -f pm -err formt_3.err -b 0 2 -o rm_3e.hex
FORMOPS_3o = rm_3.abs -f pm -err formt_3.err -b 1 2 -o rm_3o.hex

OLSFILE_3 = rm_3.ols
!endif

#all: deler rm_4.bin rm_3.bin
all: deler rm_3.bin

rm_4.bin: $(OLS)rmain.ol $(OLS)io_drv_4.ol $(OLS)sys_go.ol $(OLS)sysstp.ol \
	$(OLS)diag_tbl.ol $(OLS)usrequ.ol
#	$(OLS)end.ol
	llink -i $(OLSFILE_4) -o rm_4.abs -c loc68k.cmd -v  
	form $(FORMOPS_4)	 
	gsmap rm_4.ab -n -o rm_4.map	
	\hilo\hexbin2 rm_4.hex rm_4.bin m 08000000 ffffffff 0

rm_3.bin: $(OLS)rmain.ol $(OLS)io_drv_3.ol $(OLS)sys_go.ol $(OLS)sysstp.ol \
	$(OLS)diag_tbl.ol $(OLS)usrequ.ol
#	$(OLS)end.ol
	llink -i $(OLSFILE_3) -o rm_3.abs -c loc68k.cmd -v -err+ -err
	form $(FORMOPS_3e)	 
	form $(FORMOPS_3o)	 
	gsmap rm_3.ab -n -o rm_3.map	
	\hilo\hexbin2 rm_3e.hex rm_3e.bin m 04000000 ffffffff 0
	\hilo\hexbin2 rm_3o.hex rm_3o.bin m 04000000 ffffffff 0

clean:
	del *.map
	del *.hex
	del *.ab
	del *.err
	del ols\*.ol
	del lst\*.lst

deler:
	del a.err

$(OLS)rmain.ol: rmain.68k a360def.h
	$(ASM) RMAIN.68K -o $(OLS)rmain.ol -l $(LST)RMAIN.LST $(ASMOPS)

$(OLS)io_drv_4.ol: io_drv_4.68k a360def.h
	$(ASM) IO_DRV_4.68K -o $(OLS)io_drv_4.ol -l $(LST)IO_DRV_4.LST $(ASMOPS)

$(OLS)io_drv_3.ol: io_drv_3.68k a360def.h
	$(ASM) IO_DRV_3.68K -o $(OLS)io_drv_3.ol -l $(LST)IO_DRV_3.LST $(ASMOPS)

$(OLS)sys_go.ol: sys_go.68k
	$(ASM) SYS_GO.68K -o $(OLS)sys_go.ol -l $(LST)SYS_GO.LST $(ASMOPS)

$(OLS)sysstp.ol: sysstp.68k
	$(ASM) SYSSTP.68K -o $(OLS)sysstp.ol -l $(LST)SYSSTP.LST $(ASMOPS)

$(OLS)usrequ.ol: usrequ.68k
	$(ASM) USREQU.68K -o $(OLS)usrequ.ol -l $(LST)USREQU.LST $(ASMOPS)

$(OLS)diag_tbl.ol: diag_tbl.68k
	$(ASM) DIAG_TBL.68K -o $(OLS)diag_tbl.ol -l $(LST)DIAG_TBL.LST $(ASMOPS)

#!if $(DEBUG)
#$(OLS)end.ol: end.c
#	c68360 end.c -o $(OLS)end.ol -l $(LST)end.ol -p -pw -do -pc -ps -d -os -err+ err
#!endif
