# <:t17,25:>

# DEBUG bitfields for things
#   1 - tracing enabled
#   2 - be more verbose
#   4 - verbose errors
#   8 - sanity checks
#  16 - NCP packet dumps
#  32 - SWI entry points
#  64 - IPX packet dumps
# 128 - more IPX packet dumps

#DEBUG=-DDEBUG=(1+2+4+8+32+64)
#OPTS=-DALLNETS

# 

ASOPTS=-c $(DEBUG) $(OPTS)

# The C compiler sometimes generates duff code on -O7
COPTS=-c -Iq:/hc.arm/inc/ -O7 -Hnoswst -H+w -Hic=1 -Kpic $(DEBUG) $(OPTS)
#COPTS=-c -Iq:/hc.arm/inc/ -O5 -Hnoswst -H+w -Hic=1 -Kpic $(DEBUG) $(OPTS)

# this line is used to make the dependencies files
#COPTS=-c -Iq:/hc.arm/inc/ -Hnoswst -H+w -Hic=1 -Kpic $(DEBUG) $(OPTS) -Hmakeof=$*.dep

# this is sometimes nice
# -Hkeepasm -Hanno

# 

.c.o :
                +q:\hc.arm\bin\hcarm $(COPTS) -I. -I/porting/clib/h $*.c 
                touch $*.o

.arm.o :
                inc $*.arm
                +q:\hc.arm\bin\asarm $(ASOPTS) $*.arm
                touch $*.o

.c.oe :
                +q:\hc.arm\bin\hcarm $(COPTS) -o $*.oe -DECONET -I. -I/porting/clib/h $*.c
                touch $*.oe

.arm.oe :
                +q:\hc.arm\bin\asarm $(ASOPTS) -o $*.oe -DECONET $*.arm
                touch $*.oe

.asm.obj :
                masm /Ml /Zi $*.asm;

# 

all:            _begin riscipx.m ecoipx.m nwclient.m nwfiler.m !
                gateway.m buftrace.m econot.m
                +rm -q nwclient.hex nwclient.rel nwclient.elf nwclient.map
                +rm -q riscipx.hex riscipx.rel riscipx.elf riscipx.map
                +rm -q ecoipx.hex ecoipx.rel ecoipx.elf ecoipx.map
                +rm -q nwfiler.hex nwfiler.rel nwfiler.elf nwfiler.map
                +rm -q gateway.hex gateway.rel gateway.elf gateway.map
                +rm -q buftrace.hex buftrace.rel buftrace.elf buftrace.map
                +rm -q econot.hex econot.rel econot.elf econot.map
                beep

distipx:        _begin dist
                inc ipx.i
                touch riscipx.arm nwclient.arm subipx.arm

dist:           _begin riscipx.m ecoipx.m nwclient.m
                +copy riscipx.m n:\login\!NWClient\RiscIPX   >nul
                +copy nwclient.m n:\login\!NWClient\NWClient >nul
                +copy ecoipx.m n:\login\!NWClient\EcoRiscIPX >nul
                +newline -c <!help >n:\login\!NWClient\!Help
                +newline -c <!help >n:\login\!Login\!Help
                +newline -c <program >n:\login\!NWClient\Program
                +newline -c <program >n:\login\!Login\Program
                settype n:\login\!NWClient\RiscIPX    ffa
                settype n:\login\!NWClient\EcoRiscIPX ffa
                settype n:\login\!NWClient\NWClient   ffa
                cvs commit
                inc ncp.i
                touch nwclient.arm

hack:           riscipx.m ecoipx.m nwclient.m
                +copy riscipx.m n:\login\!NWClient\RiscIPX   >nul
                +copy nwclient.m n:\login\!NWClient\NWClient >nul
                +copy ecoipx.m n:\login\!NWClient\EcoRiscIPX >nul
                +newline -c <!help >n:\login\!NWClient\!Help
                +newline -c <!help >n:\login\!login\!Help
                settype n:\login\!NWClient\RiscIPX    ffa
                settype n:\login\!NWClient\EcoRiscIPX ffa
                settype n:\login\!NWClient\NWClient   ffa

_begin:         makefile
                #systime
                +_echo "{split(\x242,a,\"-\");if(a[3]<90)a[3]+=100;print\"\\tdb\\t\\\"\"a[1]\" \"a[2]\" \"1900+a[3]\"\\\"\"}" >today.awk
                +_date | awk -f today.awk >today.i

riscipx.m:      riscipx.o ipx.o router.o packer.o subipx.o makebin.exe settype.exe
                +q:\hc.arm\bin\ldarm_44 -o riscipx.elf -D riscipx.dia -L.. -lmod > riscipx.map
                @grep "OUTPUT MODULE NAME" riscipx.map
                +q:\hc.arm\bin\elfdump -r riscipx.elf > riscipx.rel
                +q:\hc.arm\bin\elf2hex -o riscipx.hex riscipx.elf
                makebin riscipx.m riscipx.hex riscipx.rel -v
                +ren riscipx.m ___
                +ren ___ riscipx.m
                settype riscipx.m ffa

ecoipx.m:       riscipx.oe ipx.oe router.oe packer.oe subipx.oe makebin.exe settype.exe
                +q:\hc.arm\bin\ldarm_44 -o ecoipx.elf -D ecoipx.dia -L.. -lmod > ecoipx.map
                @grep "OUTPUT MODULE NAME" ecoipx.map
                +q:\hc.arm\bin\elfdump -r ecoipx.elf >ecoipx.rel
                +q:\hc.arm\bin\elf2hex -o ecoipx.hex ecoipx.elf
                makebin ecoipx.m ecoipx.hex ecoipx.rel -v
                +ren ecoipx.m ___
                +ren ___ ecoipx.m
                settype ecoipx.m ffa

nwclient.m:     nwclient.o ncp.o nwutil.o nwswis.o fileio.o stars.o !
                fsglue.o fsmain.o fsdirs.o ncperrs.o nwnds.o makebin.exe
                +q:\hc.arm\bin\ldarm_44 -o nwclient.elf -D nwclient.dia -L.. -lmod > nwclient.map
                @grep "OUTPUT MODULE NAME" nwclient.map
                +q:\hc.arm\bin\elfdump -r nwclient.elf >nwclient.rel
                +q:\hc.arm\bin\elf2hex -o nwclient.hex nwclient.elf
                makebin nwclient.m nwclient.hex nwclient.rel -v
                +ren nwclient.m ___
                +ren ___ nwclient.m
                settype nwclient.m ffa

nwfiler.m:      nwfiler.o filer.o subfiler.o makebin.exe settype.exe
                +q:\hc.arm\bin\ldarm_44 -o nwfiler.elf -D nwfiler.dia -L.. -lmod > nwfiler.map
                @grep "OUTPUT MODULE NAME" nwfiler.map
                +q:\hc.arm\bin\elfdump -r nwfiler.elf >nwfiler.rel
                +q:\hc.arm\bin\elf2hex -o nwfiler.hex nwfiler.elf
                makebin nwfiler.m nwfiler.hex nwfiler.rel -v
                +ren nwfiler.m ___
                +ren ___ nwfiler.m
                settype nwfiler.m ffa

gateway.m:      gateway.o gate.o subgate.o makebin.exe settype.exe
                +q:\hc.arm\bin\ldarm_44 -o gateway.elf -D gateway.dia -L.. -lmod >gateway.map
                @grep "OUTPUT MODULE NAME" gateway.map
                +q:\hc.arm\bin\elfdump -r gateway.elf >gateway.rel
                +q:\hc.arm\bin\elf2hex -o gateway.hex gateway.elf
                makebin gateway.m gateway.hex gateway.rel -v
                +ren gateway.m ___
                +ren ___ gateway.m
                settype gateway.m ffa

buftrace.m:     buftrace.o makebin.exe settype.exe
                +q:\hc.arm\bin\ldarm_44 -o buftrace.elf -D buftrace.dia >buftrace.map
                @grep "OUTPUT MODULE NAME" buftrace.map
                +q:\hc.arm\bin\elfdump -r buftrace.elf >buftrace.rel
                +q:\hc.arm\bin\elf2hex -o buftrace.hex buftrace.elf
                makebin buftrace.m buftrace.hex buftrace.rel -v
                +ren buftrace.m ___
                +ren ___ buftrace.m
                settype buftrace.m ffa

econot.m:       econot.o makebin.exe settype.exe
                +q:\hc.arm\bin\ldarm_44 -o econot.elf -D econot.dia >econot.map
                @grep "OUTPUT MODULE NAME" econot.map
                +q:\hc.arm\bin\elfdump -r econot.elf >econot.rel
                +q:\hc.arm\bin\elf2hex -o econot.hex econot.elf
                makebin econot.m econot.hex econot.rel -v
                +ren econot.m ___
                +ren ___ econot.m
                settype econot.m ffa

ipx.o:	ipx.c iriscipx.h lists.h errors.h riscipx.h mbuf.h 

router.o:	router.c iriscipx.h lists.h errors.h riscipx.h mbuf.h 

nwutil.o:	nwutil.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

nwswis.o:	nwswis.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

fileio.o:	fileio.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

stars.o:	stars.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

fsmain.o:	fsmain.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

fsdirs.o:	fsdirs.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

nwnds.o:	nwnds.c nwclient.h riscipx.h mbuf.h lists.h errors.h 

riscipx.arm ipx.c subipx.arm nwclient.arm subncp.arm: ipx.i

makebin.exe:    makebin.c
                ztc makebin
                +ren makebin.exe ___
                +ren ___ makebin.exe

settype.exe:    settype.c dosncp.obj
                ztc settype.c dosncp.obj -J -ms
                +ren settype.exe ___
                +ren ___ settype.exe

#  EOF 
