#***********************************************************************
# The makefile for the IBMDEV32
#
#       IBM Confidential
#
#       Copyright (c) IBM Corporation 1987, 1989, 1991
#
#       All Rights Reserved
#
#*****************************************************************************

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

.SUFFIXES: .c .asm .dec .h .inc .mac .rc .res .obj .exe .def

#***********************************************************************
# Location of the Compilers (plus include and lib files) and other Tools,
# relative to the specified base directory.
#***********************************************************************

BASEDIR    = ..\..\..

H         = $(BASEDIR)\h
H386      = $(BASEDIR)\ibmc\cinclude
HGRE      = $(BASEDIR)\hgre
HIBM      = $(BASEDIR)\ibmh
INC       = $(BASEDIR)\inc32
INCENG    = $(BASEDIR)\src\pmgre32
INCGRE    = $(BASEDIR)\incgre
VGAINC    = ..\vgainc

LIB       = $(BASEDIR)\lib
LIB386    = $(BASEDIR)\ibmc\clib
LIBGRE    = $(BASEDIR)\libgre

LINKLIBS  = OS2386p.LIB OS2386.LIB
TOOLSPATH = $(BASEDIR)\..\ibmc\cbin;$(BASEDIR)\..\masm60\binp;$(BASEDIR)\..\tools;

#*****************************************************************************
# Build Files and Directories
#*****************************************************************************

#BASENAME   = ibmvga

#!IFDEF SEAMLESS               We will always build seamless
#SDEF        = S
#!ELSE
#SDEF        =
#!ENDIF

PROJDIR     = $(MAKEDIR)             # Project Directory

!IFDEF DEBUG
OBJDIR      = DEBUG
PROJ        = IBMDEVD
PROJ132     = IBM132D
!ELSE
OBJDIR      = RETAIL
PROJ        = IBMDEVR
PROJ132     = IBM132R
!ENDIF

PROJDEF     = IBMVG2S

#*****************************************************************************
# Assembler, Resource Compiler and Linker options
#*****************************************************************************

RC          = rc                    # Resource Compiler
RF          =                       # Flags
AS          = ML                    # Assembler being 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.

!IFDEF DEBUG
AFLAGS =    /c /Cp /Zi /Sg  \
            /I$(PROJDIR) \
            /DINCL_32\
            /DBITS_PEL=4 \
            /DSCAN_CNT=480 \
            /DSEAMLESS \
            /DDCAF \
            /DFIREWALLS /DVGA \
            /DINCL_OPTIONS
!ELSE
AFLAGS =    /c /Cp /Zi /Sg\
            /I$(PROJDIR)  \
            /DINCL_32 \
            /DBITS_PEL=4 \
            /DSEAMLESS \
            /DDCAF \
            /DSCAN_CNT=480 /DVGA \
#           /DVSCAN_CNT=813 \
            /DINCL_OPTIONS
!ENDIF

ASMD   = $(AS) $(AFLAGS) # Assembly Command


LINKER      = LINK386                       # Linker being used
LFLAGS      = /MAP /NOD /EXEPACK /ALIGN:4   # Link options

#*****************************************************************************
# Create Directories if they don't exist
#*****************************************************************************

!if [if not exist $(OBJDIR) mkdir $(OBJDIR)]
!endif

#*****************************************************************************
# Set up environment variables
#*****************************************************************************

!if [set INCLUDE=$(MAKEDIR);$(INCGRE);$(INCENG);$(VGAINC);$(INC)] || \
    [set LIB=$(LIB);$(LIBGRE)]                                     || \
    [set PATH=$(TOOLSPATH);$(PATH)]
!endif


#*****************************************************************************
# Object files
#*****************************************************************************

OBJS1 = $(OBJDIR)\BITBLT.OBJ $(OBJDIR)\BITBLT2.OBJ $(OBJDIR)\BMC_ETI.OBJ $(OBJDIR)\BMC_ITE.OBJ\
        $(OBJDIR)\BUILDSTR.OBJ $(OBJDIR)\CBLT.OBJ $(OBJDIR)\CELLBLT.OBJ

OBJS2 = $(OBJDIR)\CELLDRAW.OBJ $(OBJDIR)\CLRCONV.OBJ $(OBJDIR)\CMPLCODE.OBJ\
        $(OBJDIR)\CRITSEC.OBJ $(OBJDIR)\CURSORS.OBJ $(OBJDIR)\CURSOR2.OBJ

OBJS3 = $(OBJDIR)\DATADEV.OBJ $(OBJDIR)\DITHER.OBJ $(OBJDIR)\DRAWBITS.OBJ\
        $(OBJDIR)\EGAINIT.OBJ $(OBJDIR)\EGASTATE.OBJ $(OBJDIR)\PHYCOLOR.OBJ

OBJS3B = $(OBJDIR)\DATADEV.132 $(OBJDIR)\DITHER.OBJ $(OBJDIR)\DRAWBITS.OBJ\
         $(OBJDIR)\EGAINIT.132 $(OBJDIR)\EGASTATE.OBJ $(OBJDIR)\PHYCOLOR.OBJ

OBJS4 = $(OBJDIR)\PIXEL.OBJ $(OBJDIR)\POLYLINE.OBJ $(OBJDIR)\PLYSOLID.OBJ\
        $(OBJDIR)\POINTER.OBJ $(OBJDIR)\POINTER2.OBJ $(OBJDIR)\POLYBITM.OBJ

OBJS5 = $(OBJDIR)\POLYSTYL.OBJ $(OBJDIR)\STHUNK.OBJ $(OBJDIR)\RASTEROP.OBJ\
        $(OBJDIR)\RESOLVE.OBJ $(OBJDIR)\RLEBM.OBJ $(OBJDIR)\SCANLIN2.OBJ

OBJS6 = $(OBJDIR)\SCANLINE.OBJ $(OBJDIR)\SHORTLN.OBJ $(OBJDIR)\SMARTFIX.OBJ\
        $(OBJDIR)\SMARTPRO.OBJ $(OBJDIR)\SSB.OBJ $(OBJDIR)\STRBLT.OBJ

OBJS7 = $(OBJDIR)\STRBLTC.OBJ $(OBJDIR)\STRCHBLT.OBJ $(OBJDIR)\STRDRAW.OBJ\
        $(OBJDIR)\ENUMBANK.OBJ $(OBJDIR)\MYTHUNK.OBJ $(OBJDIR)\COLORTBL.OBJ \
        $(OBJDIR)\MKVALID.OBJ

OBJS8 = $(OBJDIR)\COMPRESS.OBJ $(OBJDIR)\SCRBITS.OBJ $(OBJDIR)\PACKING.OBJ

OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) $(OBJS8)

OBJS132 = $(OBJS1) $(OBJS2) $(OBJS3B) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7)

RESS = $(OBJDIR)\IBMDEV32.RES

#*****************************************************************************
# Inference rules                                                            *
#*****************************************************************************

{$(PROJDIR)}.ASM{$(OBJDIR)}.OBJ:
   $(ASMD) /Fo $@ $<

{$(PROJDIR)}.ASM{$(OBJDIR)}.132:
   $(ASMD) /DVGA132 /Fo $@ $<

{$(PROJDIR)}.RC{$(OBJDIR)}.RES:
   $(RC) -r -p -I $(HIBM) $< $@

{$(OBJDIR)}.OBJ{$(PROJDIR)}.BIN:
   link $(OBJDIR)\$(<B).obj,$(<B).exe;
   reloc $(<B) $(<B).bin
   erase $(<B).exe

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


all: debug retail

debug:
    $(MAKE) /f makefile DEBUG=1  makeall -$(MAKEFLAGS)

retail:
    $(MAKE) /f makefile RETAIL=1 makeall -$(MAKEFLAGS)


makeall: $(OBJDIR)\$(PROJ).dll $(OBJDIR)\$(PROJ132).dll

$(PROJDIR)\dispinfo.bin: $(OBJDIR)\DISPINFO.OBJ

$(RESS): $(PROJDIR)\dispinfo.bin $(PROJDIR)\IBMDEV32.RC

#****************************************************************************
#   Module Versioning
#****************************************************************************
$(OBJDIR)\$(PROJDEF).def: $(PROJDEF).def makefile
  cd $(OBJDIR)
  copy ..\$(PROJDEF).def $(PROJDEF).def
  echo #1 $(FILEVER) >  rep.in
  echo #2 $(OBJDIR)  >> rep.in
  rep -f rep.in $(PROJDEF).def
  cd ..

$(OBJDIR)\$(PROJ).dll: $(OBJS) $(RESS) $(OBJDIR)\$(PROJDEF).DEF
        $(LINKER) @<<$(@B).lnk
$(OBJS1)   +
$(OBJS2)   +
$(OBJS3)   +
$(OBJS4)   +
$(OBJS5)   +
$(OBJS6)   +
$(OBJS7)   +
$(OBJS8)
$@ $(LFLAGS)
$(OBJDIR)\$(PROJ).map
$(LINKLIBS)
$(OBJDIR)\$(PROJDEF).def
<<keep
        $(RC) -x -p $(OBJDIR)\ibmdev32.res $(@)
        cd $(OBJDIR)
        mapsym $(PROJ).map
        cd ..

$(OBJDIR)\$(PROJ132).dll: $(OBJS132) $(RESS) $(OBJDIR)\$(PROJDEF).DEF
        $(LINKER) @<<$(@B).lnk
$(OBJS1)   +
$(OBJS2)   +
$(OBJS3B)   +
$(OBJS4)   +
$(OBJS5)   +
$(OBJS6)   +
$(OBJS7)   +
$(OBJS8)
$@ $(LFLAGS)
$(OBJDIR)\$(PROJ132).map
$(LINKLIBS)
$(OBJDIR)\$(PROJDEF).def
<<keep
        $(RC) -x -p $(OBJDIR)\ibmdev32.res $(@)
        cd $(OBJDIR)
        mapsym $(PROJ132).map
        cd ..
        if exist vga2done.cmd vga2done

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