#
# Set the environmental variables for compiling
#
!ifndef %WATCOM # if not defined in the environment
!error WATCOM must be set in the environment.
!endif
WATCOM=$(%WATCOM)

!ifndef %DDK # if not defined in the environment
!error DDK must be set in the environment.
!endif
DDK=$(%DDK)

VENDOR=Your Name
VERSION=1.00

!ifdef %DRV32KIT
DRV32KIT=$(%DRV32KIT)
!else
DRV32KIT=..
!endif

.ERASE

.SUFFIXES:
.SUFFIXES: .sys .exe .obj .asm .inc .def .lrf .lst .sym .map .cpp .c .h .lib .dbg .dll .itl .hlp

%PATH=$(DRV32KIT);$(DDK)\base\TOOLS;$(WATCOM)\BINP;$(WATCOM)\BINW;
%INCLUDE=.;$(DRV32KIT);$(WATCOM)\H;$(DDK)\base\h;$(DDK)\base32\h;$(DDK)\base\inc;
%LIB=$(WATCOM)\lib386;$(WATCOM)\lib386\os2;$(DDK)\base32\LIB;

CC=wcc386
ASM=wasm
LINK=wlink
CFLAGS=-q -bt=os2 -6s -bm -wx -s -obilmr -zp4 -zq -zm
C32DRVFLAGS=-q -bt=os2 -6s -obilmr -s -ze -zl -zq -zfp -zgp -ms -wx -zp4 -za99
CFLAGS=-q -bt=os2 -6s -bm -wx -s -obilmr -zp4 -zq -zm
AFLAGS=-q -6p -bt=os2 -wx -d1

# Inference rules
.c.obj: .AUTODEPEND
  $(CC) $(C32DRVFLAGS) $*.c
  wdis -l -s -e -p $*

.asm.obj: .AUTODEPEND
  $(ASM) $(AFLAGS) $*.asm
  wdis -l -s -e -p $*

.c.exe: .AUTODEPEND
  wcc386 $(CFLAGS) $*.c
  wlink debug all format os2 flat file $*.obj option eliminate,quiet

.map.sym:
  wat2map.cmd $[@ $^*.ma1
  @mapsym $^*.ma1
  @%erase $^*.ma1

all: Driver.sys Driver.sym BaseDev.sys BaseDev.sym

.obj.sys: makefile $(DRV32KIT)\Drv32.lib $(DDK)\base\lib\os2386p.lib
  @%create $^*.lrf
  @%append $^*.lrf name $^*.sys
  @%append $^*.lrf format os2 lx phys
  @%append $^*.lrf option mixed1632,nostub,align=4
  @%append $^*.lrf option quiet,map,int,verbose,caseexact,eliminate sort global
  @%append $^*.lrf option stack=0
  @%append $^*.lrf sort global
  @AddToFile.cmd $^*.lrf,option description,BLDLEVEL,$(VENDOR),$(VERSION),Required driver (c) %Y $(VENDOR)
  @%append $^*.lrf segment _TEXT PRELOAD CONFORMING IOPL DYNAMIC
  @%append $^*.lrf segment TYPE DATA SHARED
  @%append $^*.lrf file $(DRV32KIT)\Drv32.lib(header)
  @%append $^*.lrf file $[@
  @%append $^*.lrf library $(DRV32KIT)\Drv32.lib
  @%append $^*.lrf library $(DDK)\base32\lib\kee.lib
  @%append $^*.lrf library $(DDK)\base\lib\os2386p.lib
  $(LINK) @$^*.lrf
  @%erase $^*.lrf

clean: .symbolic
  @if exist *.map @del *.map
  @if exist *.lst @del *.lst
  @if exist *.obj @del *.obj
  @if exist *.sys @del *.sys
  @if exist *.sym @del *.sym
  @if exist *.exe @del *.exe

