CC= bcc32

# -P            force C++ compile
# -Ot           optimize for speed
# -Oc           optimize common subexpressions locally
# -Og           optimize common subexpressions globally
# -Oa           assume no pointers are aliased (may be unsafe)
# -O            reorganize loops and switches
# -Z            suppress redundant register loads
# -Ob           eliminate dead code (requires -Oe option)
# -Oe           enable global register allocation and variable live range analysis
# -Oi           inline some intrinsic functions (strXXX memXXX alloca fabs rotl rotr)
# -Om           move invariant code out of loops
# -Op           propagate what was assigned to a variable to assignments out of it
# -Ov           create induction variables and expression strength reduction (mostly for loops)
# -WX           generate DPMI 32-bit executable
# -5            optimize for Pentium processor
# -w-pro       #turns off warnings about calls to functions w/o prototypes
# -v            include debug symbols in object files and executable
# -vi          #allow inline functions
# -TD__DPMI32__ tell the assembler to define symbol "__DPMI32__" as 0
# -x-           disable exception handling
#
#CFLAGS= -Otcgabeimpv -O -Z -WX -5 -v -x- -vi
CFLAGS= -Otcgabeimpv -O -Z -WX -5 -v -x-

PROG=   capture.exe
SRCS=   capture.cpp dump.cpp flat.cpp buffer.cpp fs2flows.c queue.c util.c dostats.c

TRACEFLO_OBJS=   flat.obj fs2flows.obj queue.obj util.obj dostats.obj \
        portstat.obj netstats.obj subnet.obj readbgp.obj hoststat.obj \
        realmode.obj real2.obj far.obj intr.obj intr2.obj \
        timestmp.obj cardstmp.obj phys.obj byteswap.obj ..\wattcp\wattcp.lib

OBJS=   capture.obj $(TRACEFLO_OBJS) dump.obj buffer.obj \
        pci32.obj fpu.obj

#all:    $(PROG) traceswp.exe traceatm.exe traceip.exe traceflo.exe readbgp.exe
all:    $(PROG) traceswp.exe traceatm.exe traceip.exe traceflo.exe

clean:
    del *.obj
    del *.exe
    del *.tr
    del *.tr2
    del errors

.c.obj:
    $(CC) $(CFLAGS) -P -c $*.c

.cpp.obj:
    $(CC) $(CFLAGS) -c $*.cpp

.asm.obj:
    # ok     tasm32 /r /D__CDECL__ /m2 /ml intr2.asm
    # bad    tasm32 /Zi /m2 /ml intr2.asm
    # bad    tasm32 /D__CDECL__ /r /zi /m2 /ml intr2.asm
    tasm32 /r /D__CDECL__ /m2 /ml $*

flat.obj: flat.cpp constant.h ..\dpmi32\phys.h

buffer.obj: buffer.cpp buffer.h constant.h

capture.obj: capture.cpp buffer.h constant.h ..\fore\pca200e.h ..\fore\cardstmp.h fs2flows.h flat.h

fs2flows.obj: fs2flows.c fs2flows.h buffer.h constant.h dostats.h queue.h flat.h ..\wattcp\tcp.h ..\fore\cardstmp.h

dostats.obj: dostats.c dostats.h portstat.h netstats.h hoststat.h constant.h queue.h

portstat.obj: portstat.c dostats.h portstat.h constant.h queue.h

netstats.obj: netstats.c dostats.h netstats.h subnet.h constant.h queue.h

hoststat.obj: hoststat.c dostats.h hoststat.h constant.h queue.h

subnet.obj: subnet.c subnet.h

readbgp.obj: readbgp.c readbgp.h subnet.h

util.obj: util.c constant.h

fpu.obj: ..\intel\fpu.c

byteswap.obj: ..\intel\byteswap.asm

timestmp.obj: ..\intel\timestmp.cpp

cardstmp.obj: ..\fore\cardstmp.cpp ..\fore\cardstmp.h

intr.obj: ..\dpmi32\intr.c

phys.obj: ..\dpmi32\phys.c

intr2.obj: ..\dpmi32\intr2.asm

pci32.obj: ..\pci\pci32.asm

realmode.obj: ..\dpmi32\realmode.c

real2.obj: ..\dpmi32\real2.asm

far.obj: ..\dpmi32\far.asm

$(PROG):    $(OBJS)
    $(CC) $(CFLAGS) @&&!
$(OBJS)
!

traceflo.exe: traceflo.cpp constant.h trace.h $(TRACEFLO_OBJS)
    bcc32 -v -WX @&&!
$*.cpp $(TRACEFLO_OBJS)
!

traceatm.exe: traceatm.cpp constant.h flat.obj phys.obj trace.h
    bcc32 $(CFLAGS) $*.cpp cardstmp.obj byteswap.obj flat.obj phys.obj

traceip.exe: traceip.cpp constant.h byteswap.obj trace.h
    bcc32 -v -WX $*.cpp byteswap.obj

traceswp.exe: traceswp.cpp constant.h byteswap.obj trace.h
    bcc32 -v -WX $*.cpp byteswap.obj

#readbgp.exe: readbgp.c subnet.obj
#    bcc32 -v -WX -P $*.c subnet.obj byteswap.obj ..\wattcp\wattcp.lib flat.obj phys.obj
