.EXTENSIONS:
.EXTENSIONS: .exe .dll .obj .c .cpp .asm .h .hpp .res .rc

!  loaddll wcc      wccd
!  loaddll wccaxp   wccdaxp
!  loaddll wcc386   wccd386
!  loaddll wpp      wppdi86

!  loaddll wppaxp   wppdaxp
!  loaddll wpp386   wppd386
!  loaddll wlink    wlink
!  loaddll wlib     wlibd


NAME = VC1                                               # this DLL's name
DESC = 'Virtual Cage DLL'                                # file description

# STL  = TRUE                                            # use STL or Watcom classes?
# UNICODE = TRUE

#--- object files
OBJS = 	vc.obj 						&
		hook.obj					&
		vcapi.obj					&
		debug.obj					&
		intercept.obj				&
		interceptor.obj				&
		managerconnection.obj		&
		convstr.obj					&
		version.obj

#--- compiler options
CC = wpp386 -zq											# 32 bit C++ compiler, no banner

#--- linker response file
cc.rsp: makefile.
    @%create $^@
    @%append $^@ -dNAME="$(NAME)"						# DLL name
    @%append $^@ -fh=vc.pch								# use precompiled header
    @%append $^@ -e3 									# max. 3 compiler errors until stop
    @%append $^@ -wx 									# max warning level
    @%append $^@ -t=4									# tab stop width 4
    @%append $^@ -zc									# place const data in code segment
!ifeq UNICODE TRUE
    @%append $^@ -d_UNICODE=1		 					# Unicode or SBCS/MBCS? -> TCHAR.H
    @%append $^@ -dUNICODE=1		 					# Unicode or SBCS/MBCS? -> WINDOWS.H
	@%append $^@ -zku=437								# codepage for compiler's conversion
!else
!endif	
    @%append $^@ -bt=NT									# compile for NT/Win9x
    @%append $^@ -bd									# DLL
    @%append $^@ -bm									# multi-threaded
    @%append $^@ -zp8									# pack QWORDs
    @%append $^@ -osai									# optimize: space, reordering, relax alias, inline functions
    @%append $^@ -6r									# optimize for PPro/PIII/..., args in registers
    @%append $^@ -s										# no stack checking
    @%append $^@ -zm 									# each function in separate segment (for "opt eliminate")
!ifeq STL TRUE
	@%append $^@ -ik:\src\stlport-3.12.3\stl -DUSE_STL=1 # STL?
!endif

#--- linker options
LK = wlink.exe op q										# 32 bit linker, no banner

#--- linker response file
lk.rsp: makefile
    @%create $^@
    @%append $^@ opt desc $(DESC)						# description
    @%append $^@ sys nt_dll initinstance terminstance  	# DLL, ...
    @%append $^@ runtime windows=4.0				   	# mark for NT 4/Win9x
    @%append $^@ name '$(NAME).DLL'						# DLL name
    @%append $^@ opt modname='$(NAME).DLL'			   	# module name
    @%append $^@ opt map							   	# map file
    @%append $^@ sort global                            # sort MAPfile
    @%append $^@ opt verbose                            # verbose MAPfile
    @%append $^@ opt eliminate						   	# eliminate unused functions
    @%append $^@ opt off=0x60000000						# default base address for this DLL
    @for %i in ($(OBJS)) do @%append $^@ file %i        # add object files
	@%append $^@ exp '_VcGetVersion@4'.1				# exports (in three flavors)
	@%append $^@ exp 'VcGetVersion@4'='_VcGetVersion@4'
	@%append $^@ exp 'VcGetVersion'='_VcGetVersion@4'
	@%append $^@ exp '_VcInstall@8'.2
	@%append $^@ exp 'VcInstall@8'='_VcInstall@8'
	@%append $^@ exp 'VcInstall'='_VcInstall@8'
	@%append $^@ exp '_VcUninstall@0'.3
	@%append $^@ exp 'VcUninstall@0'='_VcUninstall@0'
	@%append $^@ exp 'VcUninstall'='_VcUninstall@0'
	@%append $^@ exp '_VcEnable@4'.5
	@%append $^@ exp 'VcEnable@4'='_VcEnable@4'
	@%append $^@ exp 'VcEnable'='_VcEnable@4'

#--- general rule how to create an .OBJ file from a .C file
.c.obj:
    @echo compiling $[@
    @$(CC) @cc.rsp -d$(RELEASEMODE)=1 $[*

#--- the dependencies of the object files
$(OBJS): cc.rsp .AUTODEPEND

#--- target dependencies
vc1.dll: $(OBJS) lk.rsp
    @echo linking...
    @$(LK) @lk.rsp
	
ALL: vc1.dll

