#******************************************************************************
#  Makefile for the VASPI directory
#
#       SCCSID = @(#)makefile   6.12 91/09/21
#
#       IBM Confidential
#
#       Copyright (c) IBM Corporation 1987, 1991
#       Copyright (c) Microsoft Corporation 1987, 1989
#
#       All Rights Reserved
#
#******************************************************************************

#
# ******  NOTE  ******
#
#
#        If you are using a SED command with TAB characters, many editors
#        will expand tabs causing unpredictable results in other programs.
#
#        Documentation:
#
#        Using SED command with TABS. Besure to invoke set tab save option
#        on your editor. If you don't, the program 'xyz' will not work
#        correctly.
#

#****************************************************************************
#  Dot directive definition area (usually just suffixes)
#****************************************************************************

.SUFFIXES:
.SUFFIXES:      .c .asm .h .obj .lst .def .lnk .lrf .exe .com .imt .inc
.SUFFIXES:      .doc .hpl .hp2 .ppr .ppx .txt .sci .sin .isu .stb .sym .map
.SUFFIXES:      .cga .ega .vga .mna .cgd .egd .vgd .mnd .cgl .egl .vgl .mnl
.SUFFIXES:      .lsd .ltb

#****************************************************************************
#  Environment Setup for the component(s).
#****************************************************************************

#
# Compiler Location w/ includes, libs and tools
#

H = ..\..\..\h
H386 = ..\..\..\h386
DISKH  = ..\..\dev\dasd\diskh
INC = ..\..\..\inc
LIB= ..\..\..\lib
TOOLSPATH=..\..\..\tools;\DevelopmentTools\Masm\BinB

#
# Define macros for language. If the macro is NOT defined, the default
# value will be the US.
#

!ifndef LANG
LANG=us
!endif

#
# Since the compiler/linker and other tools use environment
# variables ( INCLUDE, LIB, etc ) in order to get the location of files,
# the following line will check the environment for the LIFE of the
# makefile and will be specific to this set of instructions. All MAKEFILES
# are requested to use this format to insure that they are using the correct
# level of files and tools.
#

!if [set INCLUDE=$(H);$(H386);$(INC)] || \
    [set LIB=$(LIB)]                  || \
    [set PATH=$(TOOLSPATH)]
!endif

#
# Compiler/tools Macros
#

AS=masm
CC= cl386
IMPLIB=implib
IPF=ipfc
LIBUTIL=lib
LINK=link386
LINK16=link
MAPSYM=mapsym
RC=rc

#
# Compiler and Linker Options
#

PURE    = -p
GAFLAGS =
AFLAGS  = -Ml $(PURE) -t -Z $(GAFLAGS) $(FLAGS)
AINC    =  -I. -I$(H386) -I$(H) -I$(INC)
CINC    =  -I. -I$(H386) -I$(H) -I$(INC) -I$(DISKH)
DFLAGS  = -DVDDSTRICT -DVDHSTRICT -DVDDDEBUG
BFLAGS  = -DVDDSTRICT -DVDHSTRICT -DSTUB_VPIC
OFLAGS  = -Owait
SFLAGS  = -G3s -Zflp -Asnw -W2 -X $(CINC) -nologo -c $(GCFLAGS) $(BFLAGS)
CFLAGS  = -G3s -Zflp -Asnw -W2 -X $(CINC) -nologo -c $(GCFLAGS) $(FLAGS)
LFLAGS  = /noi /noe /nod /map:0 /exepack /align:16
L16FLAGS = /noi /noe /nod /map:0
RFLAGS  = -r

LIBS    = $(LIB)\vdh.lib
DEF     = $(LIB)\vdd.def
SINC    = sinc

#****************************************************************************
#   Setup the inference rules for compiling and assembling source code to
#   obejct code.
#****************************************************************************

.asm.obj:
        $(AS) $(AFLAGS) $(AINC) $< ;

.asm.obd:
        $(AS) $(AFLAGS) $(DFLAGS) $(AINC) $<, $*.obd;

.asm.lst:
        $(AS) -l -n $(AFLAGS) $(AINC) $< ;

.asm.lsd:
        $(AS) -l -n $(AFLAGS) $(DFLAGS) $(AINC) $< ;

.c.obj:
        $(CC) $(OFLAGS) $(CFLAGS) $< >>errors.out ;

.c.obd:
        $(CC) -Zi -Oi $(CFLAGS) $(DFLAGS) -Fo$@ $< ;

.c.lst:
        $(CC) $(OFLAGS) $(CFLAGS) -Fc$*.lst $< ;

.c.lsd:
        $(CC) -Zi -Oi $(CFLAGS) $(DFLAGS) -Fc$*.lst $< ;

.c.stb:
        $(CC) $(OFLAGS) $(SFLAGS) -Fo$@ $< ;

.c.ltb:
        $(CC) $(OFLAGS) $(SFLAGS) -Fc$*.lst $< ;

.c.i:
        $(CC) $(OFLAGS) $(CFLAGS) -E $< >$*.i

.rc.obj:
        $(RC) $(RFLAGS) $< ;

.asm.imt:
        msgprof $*.asm /txt /asm
#        extract $*.pro
        msgextrt $*.pro
        del $*.pro
        mkmsgf $*.txt $*.imt /asm
        del $*.txt

.lnk.lrf:
        tresp $*.lnk $*.lrf

.map.sym:
        mapsym $*.map

#       Rule for generating a .inc file from a .h file

.h.inc:
        tabify -d $*.h | sed -f $(TOOLSPATH)\h2inc32.sed | tabify >$*.inc

#       Rules for generating header documents from .sin files

.sci.sin:
        $(SINC) $(SINCFLAGS) $*.sci > $*.sin


#
# Conditional Setup Area and User Defined Macros
#

!ifdef DMAKE
MAKE=DMAKE
!endif


C2FLAG= -Gs -Zp -AS -W2 -nologo -c
MRI=MRI
MRIPATH=..\..\..\..\$(MRI)


#****************************************************************************
# Set up Macros that will contain all the different dependencies for the
# executables and dlls etc. that are generated.
#****************************************************************************

OBJS=vadata.obj vainit.obj vastub0.obj vaevent.obj varouter.obj vamem.obj vauser.obj
OBDS=vadata.obd vainit.obd vastub0.obj vaevent.obd varouter.obd vamem.obd vauser.obd

#****************************************************************************
#   Target Information
#****************************************************************************
#
# This is a very important step. The following small amount of code MUST
# NOT be removed from the program. The following directive will do
# dependency checking every time this component is built UNLESS the
# following is performed:
#                    A specific tag is used -- ie. all
#
# This allows the developer as well as the B & I group to perform incremental
# build with a degree of accuracy that has not been used before.
# There are some instances where certain types of INCLUDE files must be
# created first. This type of format will allow the developer to require
# that file to be created first. In order to achive that, all that has to
# be done is to make the DEPEND.MAK tag have your required target. Below is
# an example:
#
#    depend.mak:   { your file(s) } dephold
#
# Please DON'T remove the following line
#


#
# Should be the default tag for all general processing
#

all:    sys

sys:    vastub.h aspistub.s$(LANG) vaspi.sys

# Two-pass method to get VASTUB.OBJ  Pass 1 compiles the assembly code
# proper; pass two converts the output into another .ASM file which
# is compiled again, so that the stuff gets the right segment attributes.

vastub0.asm vastub.h: vastub.asm
              $(AS) $(AFLAGS) $(AINC) vastub.asm,vastub.obj,vastub.lst;
#             awk -f code2dat.awk vastub.lst >vastub0.asm
              code2dat vastub.lst vastub0.asm

vastub0.obj: vastub0.asm vastub.h
        $(AS) $(AFLAGS) $(AINC) vastub0.asm,vastub0.obj;

#????? Use hardcoded messages for now.
#????? Source
#?????
#stubdd.i$(LANG): $(MRIPATH)\txt\oso001.msg vastub.asm makefile
#   msgprof vastub.asm oso001.msg /asm /dos /txt /P$(MRIPATH)\txt /I..\..\..\..\inc
#   extract vastub.pro
#   mkmsgf vastub.txt stubdd.i$(LANG) /asm /I..\..\..\..\inc
#   del vastub.pro
#   del vastub.txt

#stubdd.s$(LANG): vastub.asm stubdd.i$(LANG)
#       copy stubdd.i$(LANG) stubdd.inc

aspistub.s$(LANG): vastub.asm stubdd.inc
        $(AS) -DSTUBDD $(AFLAGS) $(AINC) vastub.asm,aspistub.obj;
        $(LINK16) $(L16FLAGS) aspistub.obj,aspistub.exe;
        reloc aspistub.exe aspistub.sys
        copy aspistub.sys aspistub.s$(LANG)

clean:
        if exist *.obj del *.obj
        if exist *.obd del *.obd
        if exist *.stb del *.stb
        if exist *.lnk del *.lnk
        if exist *.sys del *.sys
        if exist *.sym del *.sym
        if exist *.exe del *.exe
        if exist *.com del *.com
        if exist *.lst del *.lst
        if exist *.lsd del *.lsd
        if exist *.ltb del *.ltb
        if exist *.sin del *.sin
        if exist *.map del *.map
        if exist *.old del *.old
        if exist *.cvk del *.cvk
        if exist vastub0.asm del vastub0.asm
        if exist vastub.h del vastub.h
        if exist errors.out del errors.out


#*****************************************************************************
#   Specific Description Block Information
#*****************************************************************************

# This section would only be for specific direction as to how to create
# unique elements that are necessary to the build process. This could
# be compiling or assembling, creation of DEF files and other unique
# files.
# If all compiler and assembly rules are the same, use an inference rule to
# perform the compilation.
#

vaspi.sys: $(OBJS) $(LIBS) $(DEF) makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(OBJS)
$@
$*.map
$(LIBS)
$(DEF)
<<keep
        $(MAPSYM) $*.map

# One day debug version will be created. Now it is same as vaspi.

vaspid.sys: $(OBDS) $(LIBS) $(DEF) makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(OBDS)
$@
$*.map
$(LIBS)
$(DEF)
<<keep
        $(MAPSYM) $*.map

#*****************************************************************************
#       List of documentation source files
#*****************************************************************************



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