# SCCSID = @(#)makefile 13.35 92/04/11
#################################################################################
#                                                                              #
# Makefile for OS/2 Multimedia extensions for Reel Magic  DD                   #
#                                                                              #
#   Generates an executable:                                                   #
#         vidrms.sys       - Reel Magic Device Driver                          #
#                                                                              #
# Modification History:                                                        #
#     Date      Name            Release Description                            #
#     -------   --------------- ------- -------------------------------------- #
#     1/18/94   Ken Lee         rel1.2  New                                    #
#                                                                              #
#################################################################################

.SUFFIXES:
.SUFFIXES: .com .sys .exe .obj .mbj .asm .inc .def .lrf .crf .ref \
           .lst .sym .map .c .h .lib .msg .pro .txt .cod .cvk

NAME=vidrms

#################################
# Compiler and Tools location
#################################
MMPM2=..\..
SRC=$(MMPM2)\SRC

HOME=..\..\..
H=$(HOME)\H
TOOLS=$(HOME)\TOOLS
SHIP_INC=$(MMPM2)\INC
INC=$(HOME)\INC
SHIP_H=$(MMPM2)\H
HPATH=$(H);$(SHIP_H);
COMMON=$(MMPM2)\H
LIB=$(HOME)\LIB
SHIP_LIB=$(MMPM2)\LIB
LIBPATH=$(LIB386);$(LIB);$(SHIP_LIB)
WH=$(WATCOM)\H

#
# Set the environmental variables for compiling
#

!if  [SET PATH=$(TOOLS);$(WATCOM)\BINP;$(WATCOM)\BINB;%PATH%]  || \
     [SET LIB=$(LIBPATH);$(WATCOM)\LIB386;%LIB%]               || \
     [SET INCLUDE=$(HPATH);$(INC);%INCLUDE%]
!endif

#################################
# Definitions for h2inc
#################################
HFLAGS=-c -f -g -t
HLOOK=-s $(H)\os2def.h -s $(SHIP_H)\os2medef.h -s $(H)\bsedos.h
ILOOK=

#################################
# Definitions for assembler
#################################
ASM=masm
AFLAGS=-MX -T -N $(ASM_DEBUG) $(ASM_LST) $(ASM_PTRACE) $(ASM_RAS) $(ASM_TIME)
AINC=-I. -I$(SHIP_INC) -i$(COMMON) -I$(INC)

#
# Options for C compiler, Watcom 16-bit
#  -bt=os2   = Build target OS is OS/2
#  -mc       = Memory model compact (one code, many data)
#  -3        = Enable use of 80386 instructions
#  -d1       = Include line number info in object
#              (necessary to produce assembler listing)
#  -d_PDD_   = Identify code as for PDD (for code shared with 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=wcc
CFLAGS=-mc -3 -bt=os2 -d1 -d_PDD_ -oirs -s -wx -zl -zfp -zgp -zq -zu $(DEBUG)
CINC=-i$(WH);$(WH)\SYS;$(H);
CINCI=-I$(WH) -I$(WH)\SYS -I$(H)

#################################
# Definitions for linker
#################################
LINK=link
LFLAGS= /NOE /MAP /NOD
LIBS=os2286p+doscalls

OBJS=ioctl.obj vend.obj aruntime.obj endof.obj init.obj

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

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


#################################
# Target Descriptions
#################################
!include        "$(H)\version.mak"

all: sys

##################################
# ssm.sys Target Descriptions
##################################
sys: $(NAME).sys

$(NAME).sys:   vidvci.inc $(OBJS) makefile $(NAME).lrf $(NAME).def
               $(LINK) $(LFLAGS) @$(NAME).lrf
               mapsym $(NAME).map

vidvci.inc:  $(COMMON)\vidvci.h makefile  \
             $(H)\os2def.h $(SHIP_H)\os2medef.h $(H)\bsedos.h
       h2inc $(HFLAGS) $(HLOOK) $(ILOOK) $(COMMON)\VIDVCI.h -o VIDVCI.inc

vc.inc:      vc.h makefile  \
             $(H)\os2def.h $(SHIP_H)\os2medef.h $(H)\bsedos.h
       h2inc $(HFLAGS) $(HLOOK) $(ILOOK) vc.h -o vc.inc

#
# Make DEF file
#
$(NAME).def: makefile $(H)\version.mak
        @echo Creating file <<$(@B).def
LIBRARY $(NAME)
DESCRIPTION '$(FILEVER)'
PROTMODE
DATA        PRELOAD
CODE        PRELOAD
<<keep

$(NAME).lrf: makefile
        @echo Creating file <<$(@B).lrf
$(OBJS)
$(NAME).sys
$(NAME).map /map /nod
$(LIBS)
$(NAME).def;
<<keep

