#  1145, Wed 1 Jul 92
#
#  Makefile for AUND: Nevil's PC snmp daemon
#
#  Copywrite 1992,1994 Nevil Brownlee
#  Computer Centre, The 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'
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'

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

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

MAP    	= $*

#
#
#  list of executables
#
#

.c.snm:
	del $*.snm
	$(CC) $*.c
	tlib $(SNMPLIB) -+$*
	rename $*.obj $*.snm

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

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

SNMPOBJS = asn1.snm snmp.snm snmpagnt.snm snmpauth.snm \
	 snmpvars.snm chart.snm

all:  traffic.exe prtserv.exe ltest.exe test.exe
#all:  prtserv.exe
#all:  test.exe

	echo done $(TEXTMODEL) make with debugging $(TEXTDEBUG)

prtserv.exe :   prtserv.obj prtcom.obj prttn.obj ntasy.obj $(SNMPOBJS)
	$(LNKP) $(LNKHD) prtserv prtcom prttn ntasy,prtserv,$(MAP),$(TCPLIB) $(CLIB)

traffic.exe :   traffic.obj chart.obj treemon.obj snmptvar.obj $(SNMPOBJS)
	$(LNKP) $(LNKHD) traffic chart treemon snmptvar,traffic,$(MAP),$(SNMPLIB) $(TCPLIB) $(CLIB)

ltest.exe :   ltest.obj ntasy.obj
	$(LNKP) $(LNKHD) ltest ntasy,ltest,$(MAP),$(CLIB)

test.exe :   test.obj hwtimer.obj
	$(LNKP) $(LNKHD) test hwtimer,test,$(MAP),$(MLIB) $(CLIB)

