#################################################################################
#
# Makefile - Generates VMAD16.sys - OS/2 VDD for OPTi MAD-16.
#
# Copyright (c) IBM Corporation 1995
# All Rights Reserved
#
# DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
# sample code created by IBM Corporation.
# It is provided to you solely for the purpose of assisting you in the
# development of your applications.
# The code is provided "AS IS", without warranty of any kind.
# IBM shall not be liable for any damages arising out of your use of
# the sample code, even if they have been advised of the possibility
# of such damages.
#
#@IBM: NAME       DATE        CHANGE
#@IBM: ---------- ----------- ------------------------------------------
#@IBM: Joe Nord   05-Dec-94   Creation - Build a VDD using Watcom 'C' compiler
#@IBM: Joe Nord   08-Feb-95   Ported from mme to basedd build tree
#################################################################################

.SUFFIXES:
.SUFFIXES: .exe .obj .asm .inc .def .lrf  \
           .lst .sym .map .c .h .lib .dlg .txt .cod  \
           .res .rc .lrf .dll

MODNAME=VMAD16
NAMESYS=VMAD16

#
# Compiler and Tools location
#
TOP=..\..\..\..
SRC=$(TOP)\SRC
LIB=$(TOP)\LIB
INC=$(TOP)\INC
H=$(TOP)\H
MAK=$(H)
TOOLS=$(TOP)\TOOLS

!include        "$(H)\version.mak"

!if "$(_VENDOR)" == "IBM"
DISKH=$(SRC)\dev\dasd\diskh
MAD16=$(SRC)\dev\mme\mad16
WATCOM=$(TOP)\WATCOM
!else
DISKH=
MAD16=..\MAD16
#Use definition from environment
#WATCOM=\WATCOM
!endif

WH=$(WATCOM)\h


#
# Set environment variables for compiling
#
!if [set PATH=$(TOOLS);$(WATCOM)\BINP;$(WATCOM)\BINB;$(IBMC)\CBIN;%PATH%] || \
    [set LIB=$(LIB);$(WATCOM)\LIB386;$(IBMC)\CLIB                         || \
    [set INCLUDE=]
!endif

!ifdef DEBUG
DEBUG=-DDEBUG
!endif

#
# Options for Watcom 16-bit C compiler
#  -bt=os2   = Build target OS is OS/2
#  -3        = Enable use of 80386 instructions
#  -d1       = Include line number info in object
#              (necessary to produce assembler listing)
#  -d_VDD_   = For code shared between PDD and VDD
#  -o        = Optimization - i = enable inline intrensic functions
#                             r = optimize for 80486 and pentium pipes
#                             s = space is preferred to time
#  -s        = Omit stack size checking from start of each function
#  -zl       = Place no library references into objects
#  -wx       = Warning level set to maximum (vs 1..4)
#  -zfp      = Prevent use of FS selector
#  -zgp      = Prevent use of GS selector
#  -zq       = Operate quietly
#  -zu       = Do not assume that SS contains segment of DGROUP
#
CC=wcc386
CFLAGS=-3 -bt=os2 -d1 -d_VDD_ -oirs -s -wx -zl -zfp -zgp -zq -zu $(DEBUG)

CINC=-i$(WH);$(WH)\SYS;$(H);$(MAD16)
CINCI=-I$(WH) -I$(WH)\SYS -I$(H) -I$(SRC)\DEV\MME\MAD16 -I$(DISKH)

#
# Definitions for assembler, Watcom WASM
#   -bt=os2  = Build target OS is OS/2
#   -d1      = Include line number info in object
#              (necessary to produce assembler listing)
#   -i       = Include list
#   -zq      = Operate quietly
#
# Cannot use wasm - version 10.0 patch level B for this VDD.
# wasm cannot handle the following instruction: "mov ax, seg flat:_data".
# Lacking this instruction, it is not possible to load the data selector
# which is necessary on entry to the device driver from IDC.
# MASM 5.1 and 6.0 handle the instruction and generate the
# appropropriate linker/loader fixup.
#
#ASM=wasm
#AFLAGS=-bt=os2 -mf -d1 -zq $(DEBUG)
#AINC=-i$(INC)
ASM=masm
AFLAGS=-Mx -p -t -l

#
# Definitions for linker
#
LINK    = LINK386
LFLAGS  = /NOE /NOD /M /BATCH
LIBS    = $(LIB)\vdh.lib

#################################
# Inference Rules
#################################
.c.obj:
     $(CC) $(CFLAGS) $(CINC) $(<B).c
     wdisasm -l -s $*

.asm.obj:
#    $(ASM) $(AFLAGS) $(AINC) $*.asm
#    wdisasm -l -s $*
     $(ASM) $(AFLAGS) $*.asm $*.obj;

#################################
# Object file lists
#################################
#OBJS = segs.obj t.obj events.obj audioreq.obj ddstring.obj utila.obj \
OBJS = data.obj events.obj audioreq.obj ddstring.obj utila.obj \
       globdata.obj init.obj


#################################
# Target Descriptions
#################################

all: $(NAMESYS).sys

$(NAMESYS).sys: $(OBJS) $(NAMESYS).lrf $(NAMESYS).def
        link386 $(LFLAGS) @$(NAMESYS).lrf
        mapsym $(NAMESYS)

#
# Make link response file
#
$(NAMESYS).lrf: makefile
        @echo Creating file <<$(@B).lrf
$(OBJS)
$(@B).sys
$(@B).map
$(LIBS)
$(@B).def;
<<keep

#
# Make DEF file
#
$(NAMESYS).def: makefile $(MAK)\version.mak
        @echo Creating file <<$(@B).def
VIRTUAL DEVICE
DESCRIPTION '$(FILEVER) OPTi/IBM MAD16 Virtual Device Driver'
PROTMODE

;STUB            'NULSTUB.EXE'


SEGMENTS
    CINIT_TEXT   CLASS 'CODE'      SHARED    DISCARDABLE     RESIDENT
    SWAPINSTDATA CLASS 'DATA'      NONSHARED NONDISCARDABLE
    _TEXT        CLASS 'CODE'      SHARED    NONDISCARDABLE
    CINIT_DATA   CLASS 'DATA'      SHARED    DISCARDABLE     RESIDENT
    _DATA        CLASS 'DATA'      SHARED    NONDISCARDABLE
<<keep


