#  1010, Thu 19 Aug 93
#
#  Makefile for ACCT: Nevil's PC Accounting Meter
#
#  Copyright (C) 1993 by Nevil Brownlee,
#  Computer Centre, University of Auckland
#

DEBUG	= D	# D for disable, E for enable
MODEL	= S     # L for large, S for small
VERSION	= T	# T for TurboC, B for Borland C

#
# auto configure section
#

!if '$(DEBUG)'=='E'
IDEBUG	= -v
TEXTDEBUG = enabled
LNKP	= tlink /m
!elif '$(DEBUG)'=='D'
IDEBUG	= -v-
TEXTDEBUG = disabled
LNKP	= tlink /m/s
#!else
#!error  DEBUG must be set to either E or D
!endif

!if '$(VERSION)'=='T'
TCD	= \tc
!elif '$(VERSION)'=='B'
TCD	= \borlandc
#!else
#!error  VERSION must be set to either T or B
!endif

!if '$(MODEL)'=='L'
ACTPLIB	= ..\lib\acctlg.lib
SNMPLIB	= ..\lib\snmplg.lib
TCPLIB	= ..\lib\wattcplg.lib
!if '$(VERSION)'=='T'
LNKHD	= $(TCD)\lib\c0l
MLIB    = $(TCD)\lib\emu $(TCD)\lib\mathl
CLIB    = $(TCD)\lib\cl
!elif '$(VERSION)'=='B'
LNKHD	= /L$(TCD)\lib $(TCD)\lib\c0l
MLIB    = emu mathl
CLIB    = cl
!endif
CMODEL	= -ml
TEXTMODEL = large

!elif '$(MODEL)'=='S'

ACTLIB	= ..\lib\acctsm.lib
SNMPLIB	= ..\lib\snmpsm.lib
TCPLIB	= ..\lib\wattcpsm.lib
!if '$(VERSION)'=='T'
LNKHD	= $(TCD)\lib\c0s
MLIB    = $(TCD)\lib\emu $(TCD)\lib\maths
CLIB    = $(TCD)\lib\cs
!elif '$(VERSION)'=='B'
LNKHD	= /L$(TCD)\lib $(TCD)\lib\c0s
MLIB    = emu maths
CLIB    = cs
!endif

CMODEL	= -ms
TEXTMODEL= small
!else
!error  MODEL must be set to either S or L
!endif

# Assembler flags
ASM	= tasm

INCLUDE	= include
SNMPINCL = ..\snmp\include
CFLAGS	= $(CMODEL) -G -r $(IDEBUG) -DAU_MSDOS -DCLNS -Ic:\tc\include -I..\include -I$(SNMPINCL) -I$(INCLUDE)
#CFLAGS	= $(CMODEL) -G -r- $(IDEBUG) -DAU_MSDOS -DCLNS -Ic:\tc\include -I..\include  -I$(SNMPINCL) -I$(INCLUDE)
CC	= tcc -c $(CFLAGS)
#CC	= tcc -S $(CFLAGS)
#  -S option generates .asm file (instead of .obj file)

MAP    	= $*

#
#  list of executables
#

.c.act:
	del $*.act
	$(CC) $*.c
	tlib $(ACTLIB) -+$*
	rename $*.obj $*.act

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

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

INCLUDES = $(INCLUDE)\flowhash.h $(INCLUDE)\met_vars.h \
	$(INCLUDE)\pktsnap.h $(INCLUDE)\decnet.h

ACTOBJS = flowhash.act met_vars.act  chart.act

all: NeTraMet.exe

NeTraMet.exe :   $(INCLUDES) meter_pc.obj $(ACTOBJS)
	$(LNKP) $(LNKHD) meter_pc,NeTraMet,$(MAP),$(ACTLIB) $(SNMPLIB) $(TCPLIB) $(CLIB)

snmptest.exe :   $(INCLUDES) snmptest.obj
	$(LNKP) $(LNKHD) snmptest,snmptest,$(MAP),$(SNMPLIB) $(TCPLIB) $(CLIB)

clean:
   del *.act
   del *.obj
   del $(ACTLIB)
   del *.exe
