# 1200, Sun 4 May 97
#
#  NETRAMET makefile (16-bit version)

DEBUG =     E            # E to enable, D to disable
PROCESSOR = 3            # 3 for 386..Pentium, 5 for Pentium only
CC = bcc -ml             # Large memory model
ASM = tasm -dFUNC_L=1    # 16-bit Assembler, large model

!if '$(DEBUG)'=='E'
CDEBUG= -v
ADEBUG= -zi
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- -Otcgabeimpv -O -Z  $(CDEBUG) \
    -DAU_MSDOS -I..\netramet -I..\snmplib

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

# -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

all:     ntm16
#all:    pkt_test ping scr_test ntm16

.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 =   timestmp.obj byteswap.obj  wattcp.lib
#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)

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

ntm16:   $(ntm16_objs)
    $(CC) -entm16 $(CFLAGS) @&&!
$(ntm16_objs)
!

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


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)
!

ping.obj:   ..\watapps\ping.cpp

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

tim_test.obj:   ..\intel\tim_test.cpp

tim_test:  tim_test.obj $(tcp_objs) upcalls.obj
    $(CC) $(CFLAGS) @&&!
tim_test.obj $(tcp_objs) upcalls.obj
!
