# 1200, Sun 4 May 97
#
#  NETRAMET makefile (OC3MON version)
#    NB: -P compile option not set!

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

!if '$(DEBUG)'=='E'
CDEBUG= -v
TEXTDEBUG=enabled
!elif '$(DEBUG)'=='D'
TEXTDEBUG=disabled
!else
!error  DEBUG must be set to either E or D
!endif

!if '$(PROCESSOR)'=='3'
PROC= -3 -DCLK_86
APROC= -j.386P
!elif '$(PROCESSOR)'=='5'
PROC= -5
APROC= -j.586P
!else
!error  PROCESSOR must be set to either 3 or 5
!endif

#CFLAGS= $(PROC) -w-par -a- -Od -Z $(CDEBUG) \
CFLAGS= $(PROC) -w-par -a- -Otcgabeimpv -O -Z $(CDEBUG) \
   -DAU_MSDOS -DNEW_ATR -I..\netramet -I..\snmplib

# -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:     ntm32
#all:     test
#all:    pkt_test ping scr_test ntm32

.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

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_pc.obj:   $(SRC)\meter_pc.c $(ntm_incls)

ntm32_objs =    meter_pc.obj $(ntm_objs) snmpv2c.lib $(tcp_objs)

ntm32:   $(ntm32_objs)
    $(CC) -entm32p $(CFLAGS) @&&!
$(ntm32_objs)
!

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

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

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

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

clk_rate.obj:   clk_rate.cpp
clk_rate:  clk_rate.obj $(tcp_objs)
    $(CC) $(CFLAGS) @&&!
clk_rate.obj $(tcp_objs)
!

test.obj:     test.c
time_us.obj:  time_us.cpp

test:  test.obj time_us.obj $(tcp_objs)
    $(CC) $(CFLAGS) @&&!
test.obj time_us.obj $(tcp_objs)
!


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