#  1220, Sun 4 May 97
#
#   NeTraMet makefile (OC3MON version)
#     CAUTION:  Uses -P to force C++ compile for NeTraMet sources
#               (don't need this for snmp or wattcp libraries)

DEBUG =     D            # E to enable, D to disable
PROCESSOR = 5            # 5 for Pentium only  << Don't try 3
CC = bcc32 -WX           # Flat memory model
ASM = tasm32 -dFUNC_L=0  # 32-bit Assembler

!if '$(DEBUG)'=='E'
CDEBUG= -v
ADEBUG= /zi  # intr2 doesn't like this <<<<<
TEXTDEBUG=enabled
!elif '$(DEBUG)'=='D'
TEXTDEBUG=disabled
!else
!error  DEBUG must be set to either E or D
!endif

!if '$(PROCESSOR)'=='5'
PROC= -5
APROC= -j.586P
!else
!error  PROCESSOR must be set to 5
!endif

# NETFLOW bits:
#     0 = NF_ASN_ATT     We have S/D ASN only 
#    1  = NF_OTHER_ATT   We have nf_meterID and S/D Prefix
#   2   = NF_CISCO_DATA  Packet handler builds pkt from NetFlow record
#  3    = NF_PC_BGP      Meter will get ASN by BGP lookup

#CFLAGS= $(PROC) -w-par -a- -P -Otcgabeimpv -O -Z  $(CDEBUG) \
#                       ^^^       ^^    ^^  disabled (see integrat\makefile)
#    -DAU_MSDOS -DOCXMON -DNEW_ATR -I..\netramet -I..\snmplib
CFLAGS= $(PROC) -w-par -P -Otabeiv -O -Z -vi -x- $(CDEBUG) \
   -DOCX -DOC3 -DDOS -I..\netramet -I..\snmplib  # Testing the old OC3 version
#   -DOCX -DDOS -I..\netramet -I..\snmplib  # No attempt at ASNs
#   -DOCX -DDOS -DNETFLOW=9 -DNEW_ATR -I..\netramet -I..\snmplib  # BGP + ASN
#                                CAUTION: OCX can't use NEW_ATR <<<<

# -3      generate 80386 instructions
# -WX     generate DPMI 32-bit executable
# -w-par  no 'unused parameter' warnings
# -a-     align byte (default)

# -Ot     optimize for speed
# -Oc     optimize common subexpressions locally
# -Og     optimize common subexpressions globally
# -Oa     assume no pointers are aliased (may be unsafe)
# -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)

# -O      reorganize loops and switches
# -Z      suppress redundant register loads

# -5      optimize for Pentium processor
# -P      force C++ compile
# -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 -5 -v -x- -vi  # Joel's OC3MON flags

AFLAGS= $(APROC) -mx -t -i..\wattcp $(ADEBUG)

all:     ntmOC3

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

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

.asm.obj:
    $(ASM) $(AFLAGS) $*

SRC = ..\netramet

far.obj:        ..\dpmi32\far.asm
intr.obj:       ..\dpmi32\intr.c
intr2.obj:      ..\dpmi32\intr2.asm
phys.obj:       ..\dpmi32\phys.c
realmode.obj:   ..\dpmi32\realmode.c
real2.obj:      ..\dpmi32\real2.asm
byteswap.obj:   ..\intel\byteswap.asm
timestmp.obj:   ..\intel\timestmp.cpp

tcp_objs =   far.obj intr.obj intr2.obj phys.obj realmode.obj real2.obj \
             timestmp.obj byteswap.obj  wattcp.lib upcalls.obj

flat.obj:       ..\integrat\flat.cpp ..\integrat\constant.h
buffer.obj:     ..\integrat\buffer.cpp ..\integrat\buffer.h  \
                    ..\integrat\constant.h
capture.obj:    ..\integrat\capture.cpp ..\integrat\buffer.h  \
                ..\integrat\constant.h ..\fore\pca200e.h \
                    ..\integrat\fs2flows.h
dump.obj:       ..\integrat\dump.cpp
fpu.obj:        ..\intel\fpu.c
cardstmp.obj:   ..\fore\cardstmp.cpp
pci32.obj:      ..\pci\pci32.asm

oc3_objs =   capture.obj dump.obj buffer.obj flat.obj cardstmp.obj \
             pci32.obj fpu.obj

ntm_incls =     $(SRC)\pktsnap.h $(SRC)\flowhash.h \
                    $(SRC)\met_vars.h $(SRC)\decnet.h

flowhash.obj:   $(SRC)\flowhash.c $(ntm_incls)
met_vars.obj:   $(SRC)\met_vars.c $(ntm_incls)
chart.obj:      $(SRC)\chart.cpp $(ntm_incls)

ntm_objs =   flowhash.obj met_vars.obj chart.obj

meter_oc.obj:   $(SRC)\meter_oc.c $(ntm_incls)

ntmoc3_objs =   meter_oc.obj $(ntm_objs) snmpv2c.lib $(tcp_objs) $(oc3_objs)

ntmOC3:  $(ntmoc3_objs)
    $(CC) -entmOC3 $(CFLAGS) @&&!
$(ntmoc3_objs)
!

scr_test.obj:   $(SRC)\scr_test.c
scr_test:  scr_test.obj $(oc3_objs)
    $(CC) $(CFLAGS) @&&!
scr_test.obj $(oc3_objs)
!

asn_test.obj:   $(SRC)\asn_test.c
asn_test:  asn_test.obj $(tcp_objs)
    $(CC) $(CFLAGS) @&&!
asn_test.obj $(ntm32_objs)
!

pkt_test.obj:   $(SRC)\pkt_test.c
pkt_test:  pkt_test.obj $(oc3_objs)
    $(CC) $(CFLAGS) @&&!
pkt_test.obj $(oc3_objs)
!

ping.obj:   ..\watapps\ping.cpp
ping:  ping.obj $(oc3_objs) ..\wattcp\upcalls.obj
    $(CC) $(CFLAGS) @&&!
ping.obj $(oc3_objs) ..\wattcp\upcalls.obj
!

meter_pc.obj:   $(SRC)\meter_pc.c $(ntm_incls)
ether_objs =    meter_pc.obj $(ntm_objs)

ntm32:   $(ether_objs)
    $(CC) -entm32 $(CFLAGS) @&&!
$(ether_objs)
!

clean:
    del *.obj
    del *.exe
    del *.lib
    del *.bak
    del *.tr
    del *.tr2
    del err*.*
