#******************************************************************************
#  Makefile for the SVGA256 directory
#
#
#
#       IBM/Microsoft Confidential
#
#       Copyright (c) IBM Corporation 1987, 1989
#       Copyright (c) Microsoft Corporation 1987, 1989
#
#       All Rights Reserved
#
#  History:
#  --------
#
#  created: July 20, 1992 by Paul R. King
#  modified: September 21, 1992 by Scott Vouri
#            removed chip specific components
#
#******************************************************************************

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

.SUFFIXES:
.SUFFIXES: .OBJ .ASM .DEF .LNK .A .H .R .S .T .W .RES .RC

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

#
#  Defaults  (Command line options will override these default settings)
#

!IFNDEF DRIVERPREFIX
DRIVERPREFIX=SV
!ENDIF

!IFNDEF DRIVERSUFFIX
DRIVERSUFFIX=256
!ENDIF

!IFNDEF DEBUG
RETAIL=1
!ENDIF

!IFNDEF SCAN_CNT
SCAN_CNT=480
!ENDIF

SEAMLESS=1


#
# Conditional Setup Area and User Defines Macros
#

#  RD = Resolution Directory (Currently 480, 600, or 768)
#  RETAILDIR = the directory to put retail object files into
#  DEBUGDIR = the directory to put debug object files into
#  RESDIR = the directory for the resource files
#  O = the location of the object files (either RETAILDIR or DEBUGDIR)
#  S = the location of the source files (currently .)
#
!IFDEF PASS2

RD=$(SCAN_CNT)
RETAILDIRBASE=RETAIL
RETAILDIR=$(RD)\$(RETAILDIRBASE)
DEBUGDIRBASE=DEBUG
DEBUGDIR=$(RD)\$(DEBUGDIRBASE)
RESDIRBASE=RES
S=.
!IFDEF  LORES
RESDIR=LORES
RESOLUTIONFLAGS=/DLORES
!ENDIF
!IFDEF  HIRES
RESDIR=HIRES
RESOLUTIONFLAGS=/DHIRES
!ENDIF

!IFDEF DEBUG
O=$(DEBUGDIR)
!ENDIF

!IFDEF RETAIL
O=$(RETAILDIR)
!ENDIF

#
#  Create the necessary directories if they do not exist
#
!IF [IF NOT EXIST $(RD) MD $(RD)] || \
    [IF NOT EXIST $(RESDIR) MD $(RESDIR)] || \
    [IF NOT EXIST $(O) MD $(O)]
!ENDIF


DLLBASENAME = $(DRIVERPREFIX)$(SCAN_CNT)$(DRIVERSUFFIX)
DLLNAME     = $(O)\$(DLLBASENAME)
DEFFILE     = VG2S$(SCAN_CNT).DEF
LIBFILES    = OS2386P.LIB OS2386.LIB OS2286.LIB

!ENDIF  #PASS2


#
#   Define macro for language. If the language macro is not defined, the
#   default language is US.
#

!ifndef LANG
LANG=us
!endif


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

H =..\..\..\h
INC=..\..\..\inc
INC32=..\..\..\inc32
VGAINC=..\vgainc
HRC=..\$(H)

LIB=..\..\..\lib
PRIVATE =.
MRI=MRI
MRIPATH=
ICOPATH=..\..\..\$(MRI)\ICONS          # place all icons here
SRCPATH=.
# Set the dpath to point to the translated oso0001.msg file first
DPATH=..\..\..\$(MRI)\txt;$(DPATH)
TOOLSPATH=..\..\..\..\masm60\binp;..\..\..\..\tools;..\..\..\..\..\TOOLS;
L=ENU
P=437
C=01
QUIET=>nul 2>&1

#
# 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=$(PRIVATE);$(VGAINC);$(H);$(INC32);$(INC);$(HRC);] || \
    [set IPFC=$(TOOLSPATH);]                        || \
    [set PATH=$(TOOLSPATH)]                         || \
    [set LIB=$(LIB)]
!endif


#
# Compiler/tools Macros
#


#*****************************************************************************
# Assembler options
#*****************************************************************************
AS     = ML                         # Assembler BINAR used
# /c  Do not link.
# /Cp Preserve case of all user identifiers.
# /Zi Generates Codeview info.
# /Sg Turns on listing of Assembler generated code such as .IF, .WHILE...
#     /Sg is ignored unless the /Fl option is specified.
# /Fl Generates listing (.LST) file.
ASM  = $(AS)
LINK = LINK386  # Linker being used

#
# Compiler and Linker Options
#

# MASM Options
#     /c  Do not link.
#     /Cp Preserve case of all user identifiers.
#     /Fl Generates listing (.LST) file.
#     /Sg Turns on listing of Assembler generated code such as .IF, .WHILE...
#         /Sg is ignored unless the /Fl option is specified.
#     /Zi Generates Codeview info.
AFLAGS =    /c /Cp /Sg\
!IFDEF DEBUG
            /Zi /DFIREWALLS\
!ENDIF
!IFDEF LISTFILES
            /Fl \
!ENDIF
            /DINCL_32 $(RESOLUTIONFLAGS) \
            /DBITS_PEL=8 \
            /DCLR256=1 /DPALMGR2=1\
            /DSEAMLESS \
            /DSCAN_CNT=$(SCAN_CNT) /DVGA \
            /DDCAF \
#           /DINCL_S3 \
            /DINCL_OPTIONS

# LINK Options
#     MAP - create map file
#     MOD - Ignore default libraries
LFLAGS      = /MAP /NOD             # Link options (removed /FAR)

MAKEPARMS=PASS2= SEAMLESS=1 driver -$(MAKEFLAGS)

INCLUDESPARMS=-e -l -I. -I$(PRIVATE) -I$(VGAINC) -I$(H) -I$(INC32) -I$(INC) \
              -A=BLT -A=MAC -A=PAL -P$$(VGAINC)=$(VGAINC) -P$$(H)=$(H) \
              -P$$(INC32)=$(INC32) -P$$(INC)=$(INC) \

RES         = $(RESDIR)\IBMDEV32.RES

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

OBJS = $(O)\BITBLT.OBJ\
       $(O)\BITBLT2.OBJ\
       $(O)\BMC_ETI.OBJ\
       $(O)\BMC_ITE.OBJ\
       $(O)\BUILDSTR.OBJ\
       $(O)\CBLT.OBJ\
       $(O)\CELLBLT.OBJ\
       $(O)\CELLDRAW.OBJ\
       $(O)\CMPLCODE.OBJ\
       $(O)\CONVINT.OBJ\
       $(O)\CRITSEC.OBJ\
       $(O)\CURSORS.OBJ\
       $(O)\CURSOR2.OBJ\
       $(O)\DATADEV.OBJ\
       $(O)\DITHER.OBJ\
       $(O)\DRAWBITS.OBJ\
       $(O)\EGAINIT.OBJ\
       $(O)\EGASTATE.OBJ\
       $(O)\PHYCOLOR.OBJ\
       $(O)\PIXEL.OBJ\
       $(O)\POLYLINE.OBJ\
       $(O)\PLYSOLID.OBJ\
       $(O)\POINTER.OBJ\
       $(O)\POINTER2.OBJ\
       $(O)\POLYBITM.OBJ\
       $(O)\POLYSTYL.OBJ\
       $(O)\RASTEROP.OBJ\
       $(O)\RESOLVE.OBJ\
       $(O)\RLEBM.OBJ\
       $(O)\SCANLIN2.OBJ\
       $(O)\SCANLINE.OBJ\
       $(O)\SHORTLN.OBJ\
       $(O)\SMARTFIX.OBJ\
       $(O)\SMARTPRO.OBJ\
       $(O)\SSB.OBJ\
       $(O)\STRBLT.OBJ\
       $(O)\STRBLTC.OBJ\
       $(O)\STRCHBLT.OBJ\
       $(O)\STRDRAW.OBJ\
       $(O)\ENUMBANK.OBJ\
       $(O)\MYTHUNK.OBJ\
       $(O)\PALETTE.OBJ\
       $(O)\EDDCCTAB.OBJ\
       $(O)\EDDCSUBR.OBJ\
       $(O)\EDDCQERY.OBJ\
       $(O)\EDDCQTAB.OBJ\
       $(O)\PALDATA.OBJ\
       $(O)\MKVALID.OBJ\
!    IFDEF SEAMLESS
       $(O)\STHUNK.OBJ\
!    ENDIF
       $(O)\CTAB2.OBJ\
       $(O)\FUDGEPAL.OBJ\
       $(O)\EDDBPHNK.OBJ\
       $(O)\QUERYAP.OBJ\
       $(O)\BKMTRANS.OBJ\
       $(O)\COMPRESS.OBJ\
       $(O)\SCRBITS.OBJ\
       $(O)\PACKING.OBJ

POINTERS = $(RESDIR)\APPICON.PTR\
           $(RESDIR)\ARROW.PTR\
           $(RESDIR)\FILE.PTR\
           $(RESDIR)\FOLDER.PTR\
           $(RESDIR)\ICONERR.PTR\
           $(RESDIR)\ICONINFO.PTR\
           $(RESDIR)\ICONQUES.PTR\
           $(RESDIR)\ICONWARN.PTR\
           $(RESDIR)\ILLEGAL.PTR\
           $(RESDIR)\LCDARROW.PTR\
           $(RESDIR)\LCDTEXT.PTR\
           $(RESDIR)\MOVE.PTR\
           $(RESDIR)\MULTFILE.PTR\
           $(RESDIR)\PROGRAM.PTR\
           $(RESDIR)\SIZENESW.PTR\
           $(RESDIR)\SIZENS.PTR\
           $(RESDIR)\SIZENWSE.PTR\
           $(RESDIR)\SIZEWE.PTR\
           $(RESDIR)\TEXT.PTR\
           $(RESDIR)\WAIT.PTR\
           $(RESDIR)\WINARROW.PTR\
           $(RESDIR)\WINCROSS.PTR\
           $(RESDIR)\WINIBEAM.PTR\
           $(RESDIR)\WINICON.PTR\
           $(RESDIR)\WINSIZE.PTR\
           $(RESDIR)\WINSNESW.PTR\
           $(RESDIR)\WINSNS.PTR\
           $(RESDIR)\WINSNWSE.PTR\
           $(RESDIR)\WINSWE.PTR\
           $(RESDIR)\WINUP.PTR\
           $(RESDIR)\WINWAIT.PTR

BITMAPS = $(RESDIR)\BTNCORN.BMP\
          $(RESDIR)\CHKBOX.BMP\
          $(RESDIR)\DRIVE.BMP\
          $(RESDIR)\FILE.BMP\
          $(RESDIR)\FOLDER.BMP\
          $(RESDIR)\MENUATT.BMP\
          $(RESDIR)\MENUCHK.BMP\
          $(RESDIR)\OMAXBTN.BMP\
          $(RESDIR)\OMINBTN.BMP\
          $(RESDIR)\ORESTBTN.BMP\
          $(RESDIR)\OSBDOWN.BMP\
          $(RESDIR)\OSBLEFT.BMP\
          $(RESDIR)\OSBRIGHT.BMP\
          $(RESDIR)\OSBUP.BMP\
          $(RESDIR)\OSYSCHLD.BMP\
          $(RESDIR)\OSYSMENU.BMP\
          $(RESDIR)\PROGRAM.BMP\
          $(RESDIR)\SIZEBOX.BMP\
          $(RESDIR)\TREEMINS.BMP\
          $(RESDIR)\TREEPLUS.BMP

FONTS = $(RESDIR)\MARKER.FNT

RESOURCES = $(BITMAPS) $(FONTS) $(POINTERS)

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

.ASM{$(O)}.OBJ:
   @$(ASM) $(AFLAGS) /Fo $@ $<

.ASM.LST:
   @$(ASM) $(AFLAGS) /Fl $@ $<

{$(RESDIR)}.ASM{$(RESDIR)}.OBJ:
   @$(ASM) $(AFLAGS) /Fo $@ $<

{$(RESDIR)}.RC{$(RESDIR)}.RES:
   @CD $(RESDIR)
   @$(RC) -r -p $(<B).RC $(<B).RES
   @CD $(MAKEDIR)

{$(RESDIR)}.OBJ{$(RESDIR)}.BIN:
   @LINK $(RESDIR)\$(<B).obj,$(RESDIR)\$(<B).exe;
   @RELOC $(RESDIR)\$(<B) $(RESDIR)\$(<B).bin
   @DEL $(RESDIR)\$(<B).exe

#
# The following create the linker list file, .LNK, and the .DEF
# files, dynamically when the MAKEFILE changes.
#



#   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 lines
#

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

#
# Include a makefile with all the information about MRI Codepage, Language,
# and Country for IPFC.
#

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

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

# Create the retail and debug DLL's for the different resolutions
#       640 x 480 res
#       800 x 600 res
#      1024 x 768 res
#
# Directory structure:
#       \drf6\src\vga32\svga256\480\retail
#       \drf6\src\vga32\svga256\480\debug
#       \drf6\src\vga32\svga256\640\retail
#       \drf6\src\vga32\svga256\640\debug
#       \drf6\src\vga32\svga256\768\retail
#       \drf6\src\vga32\svga256\768\debug
#
all: 480 600 768

480: 480.deb 480.ret

600: 600.deb 600.ret

768: 768.deb 768.ret

debug:  480.deb 600.deb 768.deb

retail: 480.ret 600.ret 768.ret


# Recursively call nmake with SCAN_CNT set to 480 and any other resolutions
#       that are supported
480.ret:
    $(MAKE) RETAIL= SCAN_CNT=480 LORES= $(MAKEPARMS)

480.deb:
    $(MAKE) DEBUG=  SCAN_CNT=480 LORES= $(MAKEPARMS)

600.ret:
    $(MAKE) RETAIL= SCAN_CNT=600 LORES= $(MAKEPARMS)

600.deb:
    $(MAKE) DEBUG=  SCAN_CNT=600 LORES= $(MAKEPARMS)

768.ret:
    $(MAKE) RETAIL= SCAN_CNT=768 HIRES= $(MAKEPARMS)

768.deb:
    $(MAKE) DEBUG=  SCAN_CNT=768 HIRES= $(MAKEPARMS)


clean: clean480 clean600 clean768

clean480: clean480.deb clean480.ret
    -@rd  480           $(QUIET)

clean600: clean600.deb clean600.ret
    -@rd  600           $(QUIET)

clean768: clean768.deb clean768.ret
    -@rd  768           $(QUIET)

clean480.deb:
    -@del 480\debug /n  $(QUIET)
    -@rd  480\debug     $(QUIET)

clean480.ret:
    -@del 480\retail /n $(QUIET)
    -@rd  480\retail    $(QUIET)

clean600.deb:
    -@del 600\debug /n  $(QUIET)
    -@rd  600\debug     $(QUIET)

clean600.ret:
    -@del 600\retail /n $(QUIET)
    -@rd  600\retail    $(QUIET)

clean768.deb:
    -@del 768\debug /n  $(QUIET)
    -@rd  768\debug     $(QUIET)

clean768.ret:
    -@del 768\retail /n $(QUIET)
    -@rd  768\retail    $(QUIET)


#
# make the retail and debug dll of the resolution SCAN_CNT
# place the dll's under subdirectories SCAN_CNT\retail and SCAN_CNT\debug
# where SCAN_CNT is the vertical resolution 480, 600 and 768
# name the dll after the driver name and the resolution SCAN_CNT
#
driver: $(DLLNAME).dll

#******************************************************************************
#   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.
#

$(RESDIR)\DISPINFO.BIN: $(RESDIR)\DISPINFO.OBJ

$(RES): $(RESDIR)\DISPINFO.BIN $(RESDIR)\IBMDEV32.RC $(RESOURCES)

#****************************************************************************
#   Module Versioning
#****************************************************************************
$(O)\$(DEFFILE): $(DEFFILE) makefile
  cd $(O)
  copy ..\..\$(DEFFILE) $(DEFFILE)
  echo #1 $(FILEVER)     >  rep.in
  echo #2 $(DLLBASENAME) >> rep.in
  ..\..\..\..\..\..\tools\rep -f rep.in $(DEFFILE)
  cd ..\..

$(DLLNAME).DLL: $*.LNK $(OBJS) $(RES) $(O)\$(DEFFILE)
    @$(LINK) @$*.LNK
    @$(RC) -x -p $(RES) $@
    @MAPSYM $(DLLNAME)
    @COPY $(DLLBASENAME).SYM $(O)
    @DEL $(DLLBASENAME).SYM

$(DLLNAME).LNK: makefile $(O)\$(DEFFILE)
# The ": = +^" stuff replaces the spaces between the names in the OBJS
#    macro with a "+" and a carriage return
    @echo > NUL <<$@
$(OBJS: = +^
)
$*.DLL
$*.MAP $(LFLAGS)
$(LIBFILES)
$(O)\$(DEFFILE)
<<KEEP


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