#
#       constructs timer.drv
#
#   Defines:
#       DEBUG   - Enable debug code
#       STRICT  - Build a version with STRICT enabled
#

NAME    =timer
EXT     =drv
OBJFIRST=$Zlibinit.obj
OBJ1    =$Ztimer.obj $Zlocal.obj $Zstartend.obj $Zapi.obj $Zmath.obj

OBJ     =$(OBJ1)
LIBS    =..\lib\libw ..\lib\mdllcew ..\lib\mmsystem
INCS    = -I. -I..\inc -I..\..\inc

OPT     = -Oxws

# work around stupid bug in RC 3.1 that doesn't allow rcpp.err to be
# in a directory that is greater than 128 chars down the path, even if
# rc 3.1 is running as an OS/2 app.

PATH    = ..\..\tools16;$(PATH)

#
#   build a retail build
#
!if "$(NTDEBUG)" == "" || "$(NTDEBUG)" == "retail"

CLOPT   =-I..\inc -I.\rinc -I..\..\inc
MASMOPT =-I..\inc -I..\..\inc
LINKOPT =
RC      =rc16 -i..\inc -i..\mmsystem\rinc
OBJD    =
Z       = .\retail^\
MMDEBUG =

#
#   build a full debug build
#
!else

!if "$(NTDEBUGTYPE)"=="windbg"
CDEBUG  =-Zi -Odi
ADEBUG  =-Zi
LDEBUG  =/CO
!else
CDEBUG  =-Zd -Odi
ADEBUG  =-Zd
LDEBUG  =/LI
!endif

CLOPT   =$(CDEBUG) -DDEBUG -I..\inc -I.\rinc -I..\..\inc
MASMOPT =$(ADEBUG) -DDEBUG -I..\inc -I..\..\inc
LINKOPT =$(LDEBUG)
RC      =rc16 -DDEBUG -i..\inc -i..\mmsystem\rinc
OBJD    =
Z       = .\debug^\
MMDEBUG = DEBUG=1

!endif


!if "$(STRICT)" == "YES"
TYPES	=-DSTRICT
!else
TYPES	=
!endif

#
# NOTE
#
# this code is compiled *without* windows prolog/epilog (no -Gw)
# thus all exported routines, must have _loadds
#

CC      = cl16 -c -Alnw -G2s -Zp -W3 $(CLOPT) $(OPT) $(TYPES)
ASM     = masm -Mx -t -D?QUIET $(MASMOPT)
LINK    = link16 /NOD/NOE/MAP/ALIGN:16 $(LINKOPT)

.c{$Z}.obj:
   $(CC) -Fo$*.obj $(@B).c

.asm{$Z}.obj:
   $(ASM) -DSEGNAME=_TEXT $(@B).asm, $*.obj;


###################################

goal:	$(NAME).$(EXT) $(NAME).sym

$(NAME).$(EXT): $(OBJFIRST) $(OBJ) $(NAME).def $(NAME).res
        $(LINK) @<<
$(OBJFIRST) +
$(OBJ1),
$(NAME).$(EXT),
$(NAME),
$(LIBS),
$(NAME).def
<<
        $(RC) -t $(NAME).res $(NAME).$(EXT)
	@mapsym /n $*.map
        -binplace timer.drv
        -binplace timer.sym

RES_DIR =.\messages\usa

$(NAME).rc: $(RES_DIR)\$(NAME).rc
	@copy $(RES_DIR)\$(NAME).rc

$(NAME).rcv:  $(RES_DIR)\$(NAME).rcv
        @copy $(RES_DIR)\$(NAME).rcv


$(NAME).res: $(NAME).rc $(NAME).rcv
        $(RC) -r $(NAME).rc



############## iclean ##############
iclean:
	-@del *.rc
	-@del *.dlg
        -@del *.res



############## clean ##############
clean:
	-@del $(NAME).$(EXT)
	-@del $(NAME).res
	-@del *.sym
	-@del *.map
	-@del *.lib
	-@del $Z*.cod
	-@del $Z*.obj
	-@del *.rcv
        -@del *.rc

# START Dependencies
api.obj: api.asm timer.inc

libinit.obj: libinit.asm timer.inc

local.obj: local.asm timer.inc

startend.obj: startend.asm timer.inc

timer.obj: timer.asm timer.inc

# END Dependencies
