
#   ************************************************************************
#   *		   Makefile for DISKHOOK.D32 and DISKHOOK.VXD		   *
#   ************************************************************************

#   The source files for the VxD expect the VMM.INC header file supplied
#   with the Windows 95 DDK.  The INCLUDE environment variable should point
#   to a directory containing that header file.

#   The PATH variable should point to a directory containing an assembler
#   with MASM 6.x capabilities.  (If the assembler is not actually MASM 6.x
#   then consult the assembler's manual to determine switches that
#   correspond to the ones in this makefile.)

#   The PATH variable should point to a directory containing Microsoft's new
#   LINK.EXE (from a 32-bit language product, but preferably from the
#   Windows 95 DDK, since the one in versions 4.0 and 4.1 of Microsoft
#   Visual C++ cannot be relied on for building VxDs).

#   If the target operating system is Windows for Workgroups 3.11, then the
#   PATH should also point to a directory containing the ADDHDR utility from
#   the Windows 3.10 DDK.

#   ========================================================================

!IFDEF TARGET_PLATFORM

#   Subdirectories are used for building different intermediates for the
#   different target operating systems.

!IF "$(TARGET_PLATFORM)"=="WIN95"
BUILD_SUBDIR = WIN95
!ELSE
!IF "$(TARGET_PLATFORM)"=="WFW311"
BUILD_SUBDIR = WFW311
!ENDIF
!ENDIF

#   Different VxD types (static versus dynamic), file extensions and
#   required Windows version, depending on the target platform

!IF "$(TARGET_PLATFORM)"=="WIN95"
TARGET_EXETYPE = dynamic
TARGET_EXTENSION = vxd
TARGET_VERSION = 0400
!ELSE
!IF "$(TARGET_PLATFORM)"=="WFW311"
TARGET_EXETYPE = dynamic
TARGET_EXTENSION = d32
TARGET_VERSION = 030A		# anything higher is invalid to VXDLDR
!ENDIF
!ENDIF

#   Tools

AS = ml
LINK = link

#   Corresponding environment variables

ASMENV = ml
LNKENV = link

#   Command-line switches required for building a VxD with these tools

AFLAGS = /Cx /DMASM6 /coff /DBLD_COFF
LFLAGS = /vxd /exetype:$(TARGET_EXETYPE)

#   Command-line switches peculiar to this project

AFLAGS = $(AFLAGS) /DTARGET=$(TARGET_PLATFORM)

#   The Windows for Workgroups 3.11 version requires special include files
#   during assembly.  They are in the subdirectory that we use for the
#   build.

!IF "$(TARGET_PLATFORM)"=="WFW311"
AFLAGS = $(AFLAGS) /I$(BUILD_SUBDIR)
!ENDIF

!ENDIF		# IFDEF TARGET_PLATFORM

#   ************************************************************************

ALL : CLEAR SETTINGS TARGETS

CLEAR :
!IFDEF TARGET_PLATFORM
  set $(ASMENV)=
  set $(LNKENV)=
!ENDIF

#   ========================================================================

SETTINGS :
!IFDEF RESET
!IFDEF TARGET_PLATFORM
  -del diskhook.$(TARGET_EXTENSION)
  -del $(BUILD_SUBDIR)\*.obj
!ENDIF
!ENDIF

#   ========================================================================

!IFNDEF TARGET_PLATFORM

TARGETS :
!IFDEF RESET
  set reset=yes
!ENDIF
  $(MAKE) /$(MAKEFLAGS) TARGET_PLATFORM=WFW311
  $(MAKE) /$(MAKEFLAGS) TARGET_PLATFORM=WIN95

!ELSE		# IFDEF TARGET_PLATFORM

TARGETS : diskhook.$(TARGET_EXTENSION)

$(BUILD_SUBDIR)\control.obj : control.asm
  $(AS) /c $(AFLAGS) /Fo$@ $(*B).asm

$(BUILD_SUBDIR)\hook.obj : hook.asm
  $(AS) /c $(AFLAGS) /Fo$@ $(*B).asm

$(BUILD_SUBDIR)\iomgr.obj : iomgr.asm
  $(AS) /c $(AFLAGS) /Fo$@ $(*B).asm

$(BUILD_SUBDIR)\iosver.obj : iosver.asm
  $(AS) /c $(AFLAGS) /Fo$@ $(*B).asm

$(BUILD_SUBDIR)\play.obj : play.asm
  $(AS) /c $(AFLAGS) /Fo$@ $(*B).asm

diskhook.$(TARGET_EXTENSION) : $(BUILD_SUBDIR)\control.obj \
			       $(BUILD_SUBDIR)\hook.obj    \
			       $(BUILD_SUBDIR)\iomgr.obj   \
			       $(BUILD_SUBDIR)\iosver.obj  \
			       $(BUILD_SUBDIR)\play.obj    \
			       diskhook.def
  $(LINK) $(LFLAGS) @<<diskhook.lrf
/def:diskhook.def
/out:diskhook.$(TARGET_EXTENSION)
$(BUILD_SUBDIR)\control.obj
$(BUILD_SUBDIR)\hook.obj
$(BUILD_SUBDIR)\iomgr.obj
$(BUILD_SUBDIR)\iosver.obj
$(BUILD_SUBDIR)\play.obj
<<NOKEEP
  -del diskhook.exp
  -del diskhook.lib
!IF 0x$(TARGET_VERSION) < 0x0400
  addhdr /v:$(TARGET_VERSION) diskhook.$(TARGET_EXTENSION)
!ENDIF

!ENDIF		# IFDEF TARGET_PLATFORM

#   ************************************************************************

