!include \rtrware\include\gblmkdef
SMALL_MEM_MAP = 1
CCFLAGS = $(CFLAGS) -I \rtrware\lsl

!if $(WEB_SERVER_INCLUDED)
CFLAGS = $(CFLAGS) -P WEB=1
!endif

!if $(SMALL_MEM_MAP)
mtr.hex : delerr $(OLS)rtrware.ol $(OLS)timer.ol $(OLS)pertimer.ol \
	$(OLS)buserr.ol $(OLS)lcpmain.ol $(OLS)initmicr.ol \
	$(OLS)flshwr.ol
!else
mtr.hex : delerr $(OLS)rtrware.ol $(OLS)timer.ol $(OLS)pertimer.ol \
	$(OLS)buserr.ol $(OLS)pmain.ol $(OLS)initmicr.ol \
	$(OLS)flshwr.ol
!endif
!if $(WEB_SERVER_INCLUDED)
!if $(SMALL_MEM_MAP)
	llink -b _rompOutSeg -rs idata -i lcmtr.ols -o mtrouter.ab -c lcwebloc.cmd -il mtrlibs -err+ err
!else
	llink -b _rompOutSeg -rs idata -i mtrouter.ols -o mtrouter.ab -c webloc.cmd -il mtrlibs -err+ err
!endif
!else
!if $(SMALL_MEM_MAP)
	@echo Webserver not included and small memmap
	llink -b _rompOutSeg -rs idata -i lcmtr.ols -o mtrouter.ab -c lcnwbloc.cmd -il mtrlibs -err+ err
!else
	llink -b _rompOutSeg -rs idata -i mtrouter.ols -o mtrouter.ab -c nowebloc.cmd -il mtrlibs -err+ err
!endif
!endif
	form mtrouter.ab -e S_BootBinIOPB idata udata S__buffer S_decode_stack -o mtr.hex -f xm  -err+ err
	gsmap mtrouter.ab -n -o mtrouter.map
!if $(SMALL_MEM_MAP)
	lcpcat
!else
	cat
!endif
	type err
!if 0
#   main mtrouter.bin
!if $(WEB_SERVER_INCLUDED)
   copy mtrouter.bin MTRWEB.BIN
   web.bat
!else
   copy mtrouter.bin MTRNOWEB.BIN
   noweb.bat
!endif
!endif
   
delerr :
	del err

$(OLS)rtrware.ol: rtrware.c $(INC)kstart.h $(INC)lslproto.h $(INC)v8022str.h \
	 $(INC)vethstr.h $(INC)defs.h vrtrwstr.h $(INC)serial.h $(INC)softquot.h $(INC)GBLMKDEF
	-$(CC) $(@B).c $(CCFLAGS) -i

$(OLS)buserr.ol: buserr.c $(INC)kstart.h $(INC)defs.h
	-$(CC) $(@B).c $(CCFLAGS) -i

$(OLS)timer.ol: timer.c $(INC)kstart.h
	-$(CC) $(@B).c $(CFLAGS)

$(OLS)pertimer.ol:pertimer.68k
	$(ASM) pertimer.68k -o $(OLS)pertimer.ol $(ASMFLG)

$(OLS)pmain.ol:pmain.68k
	$(ASM) pmain.68k -o $(OLS)pmain.ol $(ASMFLG)

$(OLS)lcpmain.ol:lcpmain.68k
	$(ASM) lcpmain.68k -o $(OLS)lcpmain.ol $(ASMFLG)

$(OLS)initmicr.ol:initmicr.68k ..\devdrvrs\include\a360def.h system.inc
	$(ASM) initmicr.68k -o $(OLS)initmicr.ol $(ASMFLG)

$(OLS)flshwr.ol: flshwr.c $(INC)kstart.h 
	-$(CC) $(@B).c $(CCFLAGS)

