#----------------------------------------------------------------------------
# MAKEFILE for the MINI DRIVER
#
# COMPONENT_NAME: MINI
#
# FUNCTIONS: MINI PRESENTATION DRIVER
#
# ORIGINS: Linked to os2
#
# (C) COPYRIGHT International Business Machines Corp. 1992
# All Rights Reserved
# Licensed Materials - Property of IBM
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#----------------------------------------------------------------------------
#
#General Rules for the developers.
#
#1. Use Absolute Paths from Root. The root is defined relatively.
#   The complexity of the tree can be overcome by
#   absolute paths($(ROOT)\src\) instead of relative path (..\..\..\src\ etc)
#   This makes the output readable.
#
#2. Please don't write generated output to the \src tree. The intermediate
#   output should go into the \obj tree and the release tree (\rel)
#   should contain the files that needs to be shipped. The location of files
#   in the release tree should be decided after discussions with the
#   install group.
#
#3. Include the compiler and flags that need to be used for each build option
#   in compiler.mak. This will give us a global way to change the compiler
#   options and flags for any given sub-system. For example, changing
#   from metaware, ibm C set++ etc.
#
#4. Development should give the build lab the list of components that
#   need to be built and the order in which they need to be built.
#   The wait dependencies for the components should be given, so that
#   components are not kicked off before libraries, tools, etc.(Dependencies)
#   Call the build lab if you have any questions regarding dependencies.
#
#5. Development should provide a mechanism to have all components associated
#   with public code (i.e. \src\public) to be built as soon as possible. This
#   list can be placed in the Build Lab's Makefile that invokes the development's
#   Component makefile. A psuedo-target called public can be used to list
#   the components necessary to be built. Again the component dependencies should
#   provided.
#
#6. All public headers and libs should be used from the "rel" tree.
#   You can't use files from other sub-systems source/output tree.
#
#7. Make Sure that the output paths exists. There will be a build break
#   if directory into which you are writing doesn't exist.
#   Use tools like "makepath", or macro "create_path" to create directory
#   structure. Some base paths are created in header.mak
#----------------------------------------------------------------------------
# SUBSYS is a macro to define the name of the subsystem that this makefile is a
# part of.   It is the name of the subdirectory that is above all of the
# individual components.
#
# SUBSYS_RELATIVE is a macro to define the name of this component.
# SRC_RELATIVE is the full path for the current directory from the
# ROOT.
#
# This uses the substitution feature which takes the current directory of
# this makefile (MAKEDIR) and removes the relative part of the directory to
# get the TOP level directory.
#
# The other macros are used to build directories in other levels of the tree.
#------------------------------------------------------------------------------

DRIVER    = mini
GPLNAME   = genplib
AUTHOR    = IBM Boca Raton
COMMENT   = $(PROGRAM) $(VERSION) $(AUTHOR)
PROGRAM   = Mini Printer Device Driver for OS/2
VERSION   = v1.0

!if [ echo Top of makefile ]
!endif

#------------------------------------------------------------------------------
# Modified by:
# Description:  Makefile for LJ PRINTER DRIVER
# Date       :  Jul 22, 1995
#------------------------------------------------------------------------------

MRIOUT                = $(O_NLV)
SUBSYS                = osdd
SUBSYS_RELATIVE       = $(DRIVER)
SRC_RELATIVE          = src\$(SUBSYS)\$(SUBSYS_RELATIVE)
SRC_GENP_RELATIVE     = src\$(SUBSYS)\genplib
SRC_NL_RELATIVE       = mri\$(NLV)\$(SUBSYS)\$(DRIVER)
TOOLDIR               = $(ROOT)\src\$(SUBSYS)\common\tools

USE_IBMC_LIB = 1

#------------------------------------------------------------------------------
#  Use built in macro "MAKEDIR" to establish "ROOT".  Due to case sensitivity
#  of nmake macro substitution, try all lowercase then all uppercase.  Fail if
#  current working directory path is mixed case.  This is a current nmake
#  limitation on macro substitutions but should not be a problem for most
#  people.  We are searching for a fix to this problem.
#------------------------------------------------------------------------------

ROOT            = $(MAKEDIR:\src\osdd\mini=)
!if "$(ROOT)" == "$(MAKEDIR)"
ROOT            = $(MAKEDIR:\SRC\OSDD\MINI=)
!endif
!if "$(ROOT)" == "$(MAKEDIR)"
!error Problem setting "ROOT"! Make sure current working directory is either all\
       uppercase or all lowercase!
!endif

#-----------------------------------------------------------------
# Set up component/subsystem specific macros for use in header.mak
# This allows you establish a search order for header and lib paths.  A
# prefix would be a path that you would like to add to the beginning of
# the standard path which is set in header.mak.  A suffix tags onto the
# end of the standard path.
#-----------------------------------------------------------------

#CMP_HDR_PREFIX = <specify non-default path(s) for front of INCLUDE path>
CMP_HDR_PREFIX  =
#CMP_HDR_SUFFIX = <specify non-default path(s) for back INCLUDE path>
CMP_HDR_SUFFIX  = $(ROOT)\$(SRC_GENP_RELATIVE);$(ROOT)\$(SRC_RELATIVE);$(ROOT)\$(SRC_NL_RELATIVE)
#CMP_LIB_PREFIX = <specify non-default path(s) for front of LIB path>
CMP_LIB_PREFIX  =
#CMP_LIB_SUFFIX = <specify non-default path(s) for back LIB path>
CMP_LIB_SUFFIX  =

#-----------------------------------------------------------------------------
# PUBLIC can be one of "ibmmk", "cps","os2".  Please define the below macros
# if you want to include the public files in a different order.  These macros
# would be used if you have a preference as to which directory gets searched
# first.  For example, you would like to search the OS2 header or include
# files before you search the ibmmk header or include files.  In this case,
# you would specify PUBLIC1 = OS2 and PUBLIC2= IBMMK and PUBLIC3 = CPS.
# These macros are then used in header.mak to set the path order.
#------------------------------------------------------------------------------

PUBLIC1 = os2
#PUBLIC2 = ibmmk
#PUBLIC3 = ibmmk\pns_runtime
#PUBLIC4 = cps

#------------------------------------------------------------------------------
# HOST_PROC and HOST_OS will be set in the environment by the build lab.
# Set them in your private builds.
# Please don't set these variables in the public build.
# HOST_PROC=386
# HOST_OS=OS2
#-----------------------------------------------------------------------------

!ifndef HOST_PROC
HOST_PROC=386
HOST_OS=OS2
!endif

#------------------------------------------------------------------------------
# header.mak is the public makefile that sets up all paths and options.  It
# should not be altered.  Additions or changes to header.mak for a component
# can be overwritten in this makefile.  Additions or changes to header.mak
# for an entire subsystem can be overwritten in subsys.mak
#-----------------------------------------------------------------------------

!include $(ROOT)\header.mak

!include $(ROOT)\src\$(SUBSYS)\common\version.mak

#-------------------------------------------------------------------------
# subsys.mak is used as a way for each subsystem to override any settings
# that were set in header.mak.  It is owned by development.
#-------------------------------------------------------------------------
# Line Below not used currently
!include $(ROOT)\src\$(SUBSYS)\common\subsys.mak

PRIV_HDR  = $(ROOT)\$(SRC_RELATIVE)

#-------------------------------------------------------------------------
# Insert any paths or macros that weren't defined in header.mak or
# subsys.mak here.
#--------------------------------------------------------------------------

MRIPATH = $(ROOT)\$(SRC_NL_RELATIVE)

# Power Libraries
!if "$(TARGET_PROC)"=="ppc"
GENPLIB = $(O)\..\$(GPLNAME)\$(NLV)\libgenp.a

# Intel Libraries
!else
GENPLIB = $(O)\..\$(GPLNAME)\$(NLV)\genplib.lib
!endif

#----------------------------------------------------------------
# Set up the list of suffixes, if the suffixes in header.mak are not
# sufficient.  Be sure to include the entire list.
#-----------------------------------------------------------------

.SUFFIXES:
.SUFFIXES: .c .cpp .asm .h .inc .obj .def .dll .lib .o .res .rc .drv

#------------------------------------------------------------------------
# Please define all compiler, assembler, and linker flags here.
# Use if statement to define the flags for each type of builds.
# See $(ROOT)\src\$(SUBSYS)\common\subsys.mak for defines.
#------------------------------------------------------------------------

# PPC pragma defintions are:
#   88 - Expression has no side-effects.
#  257 - '=' encountered where '==' may have been intended.
#  290 - Static function is not referenced.
#  587 - Linkage pragma not supported yet.
#  652 - Variable is never used.

#  Power Flags
!if "$(TARGET_PROC)"=="ppc"
!    if "$(BLD_TYPE)"=="retail"
MORE_CFLAGS=
# Power Debug flags
!    else
MORE_CFLAGS= -g
!    endif

#Power specific flags
CFLAGS = -c $(SYSTEM_CFLAGS) $(MW_IBMC_DEFS) $(DBG_CFLAGS) -o $@ -D_OS2 -DMACH \
         -DSWITCH -DINCL_32 -DWPOS_BLD -DIBMC -DPPC -DUNIX_BUILD -D__GNUASM \
         -DPOWERPC -DMETAWARE -DMACH_IPC_TYPED=0 $(CDEFINEFOREIGN) \
         -Hpragma=Offwarn(88,257,290,587,652) -pic -Hon=Char_default_unsigned \
         -Hpragma=os_id(4) -HL -Hinlsize=300 -Hon=Char_is_rep \
CFLAGSEXE = $(CFLAGS)

# Intel Retail specific Flags LEU removed $(CDEFINEFOREIGN)
#    Added /o+ and /packcode to old ppc makefile
!else
!    if "$(BLD_TYPE)"=="retail"
CDEFINES=/DINCL_32=1
MORE_CFLAGS=/O+
MORE_LFLAGS=/PACKCODE

# Intel Debug IPMD specific flags, LEU added /O-, /Ti, /COD, removed Ti+
!    else
CDEFINES=/DDEBUG=1 /DINCL_32=1
MORE_CFLAGS= /Ti /DIPMD
MORE_LFLAGS=/DEBUG

# Common Intel Flags
!    endif

!ifndef ddkbld
CFLAGS    = /C /Gn+ /Gs+ /W3 /Q+ /Ms /Ge- /Ss+ /Rn /Kb+ /Fo$*.obj  /I$(ROOT)\$(SRC_NL_RELATIVE) /I.;..\genplib
LFLAGS    =  /NOD /NOE /MAP
CFLAGSEXE = /C /Gn+ /Gs+ /W3 /Q+ /Ms /Ge- /Ss+ /Rn /Kb+ /Fo$*.obj  /I$(ROOT)\$(SRC_NL_RELATIVE) /I.;..\genplib
!else
CFLAGS    = /C /Gn+ /Gs+ /W0 /Q+ /Ms /Ge- /Ss+ /Rn /Kb+ /Fo$*.obj  /I$(ROOT)\$(SRC_NL_RELATIVE) /I.;..\genplib
LFLAGS    =  /NOD /NOE /MAP
CFLAGSEXE = /C /Gn+ /Gs+ /W0 /Q+ /Ms /Ge- /Ss+ /Rn /Kb+ /Fo$*.obj  /I$(ROOT)\$(SRC_NL_RELATIVE) /I.;..\genplib
!endif
LFLAGSEXE = /MAP
LIBOS2    = $(R206_LIB)\os2386.lib
LIBOS2P   = $(R206_LIB)\os2386p.lib
CLIBSDLL  = $(COMPILER_LIB)\dde4nbs.lib
!endif

#--------------------------------------------------------------------------
# If the Inference rules defined in header.mak are not sufficient, then
# define the inference rules necessary at this point.
# The following inference rules are just an example.
# You can delete this section if you don't need to add more inference rules.
#-------------------------------------------------------------------------

.c{$(O)}.obj:
        $(CC) $(MORE_CFLAGS) $(CFLAGS) $(@B).c

#------------------------------------------------------------------------
#Component defines start here. Example of som defines are attached in
#this template
#------------------------------------------------------------------------

# Power Libraries to be included for DLL
!if "$(TARGET_PROC)"=="ppc"
LIBSDLL = $(LIBOS2) $(LIBOS2P) $(CLIBSDLL) $(GENPLIB)

# Intel Libraries to be included for DLL
!else
LIBSDLL = $(LIBOS2) $(LIBOS2P) $(CLIBSDLL) $(GENPLIB)
!endif

# -----------------------------------------------------------
# write mini.def
!if [ echo Writing DEF file ]
!endif

$(DRIVER).def: makefile
  @echo Writing <<$(DRIVER).def
LIBRARY MINI INITINSTANCE TERMINSTANCE
DESCRIPTION '$(FILEVER) Mini Printer Driver Sample'
PROTMODE
DATA SINGLE READWRITE LOADONCALL
CODE LOADONCALL

SEGMENTS
  DDE4_DATA32 CLASS  'DATA' NONSHARED READWRITE
  global      CLASS  'DATA' SHARED
  perprocess  CLASS  'DATA' NONSHARED

EXPORTS
  OS2_PM_DRV_DEVMODE
  OS2_PM_DRV_DEVICENAMES
  OS2_PM_DRV_ENABLE
  JobPropertiesDlgProc

IMPORTS
  DebugOutput         = PMWIN.955
  Debug32Output       = PMWIN.955
  DosQueryModFromEIP  = DOSCALL1.360
<<KEEP

#---------------------------------------------------------------------------


OBJ01     = $(O)\assert.obj    $(O)\caps.obj    $(O)\dlg.obj       $(O)\driver.obj     $(O)\enable.obj   $(O)\escape.obj
OBJ02     = $(O)\handler.obj   $(O)\helper.obj  $(O)\initterm.obj  $(O)\newframe.obj

MINIOBJS = $(OBJ01) $(OBJ02)


#-----------------------------------------------------------------------------
# The all target is used to specify a list of targets that need to be built
#Please don't delete "dep" from the target list.  It is used to generate the
#depend.mak file
#Please look at the example for more details.
#-----------------------------------------------------------------------------

!if "$(TARGET_PROC)"=="ppc"
all: dep paths $(O)\$(DRIVER).drv
!    if "$(BLD_TYPE)"=="retail"
BUILD  = retppc
!    else
BUILD  = dbgppc
!    endif
!else

all: dep paths $(O)\$(DRIVER).drv
!    if "$(BLD_TYPE)"=="retail"
BUILD  = retos2c
!    else
BUILD  = dbgos2c
!    endif
!endif


paths:
  -makepath $(MRIOUT)


# PowerPC builds *.o file
!if "$(TARGET_PROC)"=="ppc"
$(MRIOUT)\$(DRIVER).o: \
# X386 builds *.res file
!else
$(MRIOUT)\$(DRIVER).res: \
!endif
            $(ROOT)\$(SRC_NL_RELATIVE)\*.rc                \
            $(ROOT)\$(SRC_NL_RELATIVE)\*.dlg               \
            $(ROOT)\$(SRC_RELATIVE)\def.h
  cd $(ROOT)\$(SRC_NL_RELATIVE)
!if "$(TARGET_PROC)"=="ppc"
  $(MRES) -As, $(ROOT)\$(SRC_NL_RELATIVE)\$(DRIVER).rc -- $(MRIOUT)\$(DRIVER).o

!else
  $(RC) $(CDEFINES) -r -cp $(P) -i $(ROOT)\$(SRC_NL_RELATIVE) $(DRIVER).rc $(MRIOUT)\$(DRIVER).res
!endif
  cd $(ROOT)\$(SRC_RELATIVE)

#Power *.drv build
!if "$(TARGET_PROC)"=="ppc"
$(O)\$(DRIVER).drv: makefile  $(MRIOUT)\$(DRIVER).o $(MINIOBJS) $(DRIVER).def
#      $(CREATE_PATH)
       $(LINK) $(DLL_LFLAGS) @<<$(O)\$(DRIVER).lnk
$(DLL_INIT)
$(MINIOBJS: =^
)
$(MRIOUT)\$(DRIVER).o
$(HCLIB)
-L$(O)\..\$(GPLNAME)
-lgenp
-lspc
-los2
-los2p
$(DLL_FINI)
-o $(O)\$(DRIVER).drv
-i $(DRIVER).def
<<keep
   elfstrip -o $(O)\$(DRIVER).dbg $(O)\$(DRIVER).drv

#Intel *.drv build
!else
$(O)\$(DRIVER).drv: makefile $(MRIOUT)\$(DRIVER).res $(MINIOBJS)  $(LIBSDLL) $(DRIVER).def
#      $(CREATE_PATH)
       $(LINK) $(LFLAGS) $(MORE_LFLAGS) @<<$(O)\$(DRIVER).RSP
$(MINIOBJS:.obj=.obj+
)
$(O)\$(DRIVER).DRV
$(O)\$(DRIVER).MAP
$(LIBSDLL:.lib=.lib+
)
$(@B).def
<<keep
       $(RC) $(CDEFINES) $(MRIOUT)\$(DRIVER).RES $(O)\$(DRIVER).DRV
       cd $(O)
       mapsym $(DRIVER).map
       call $(TOOLDIR)\ea.cmd -e .VERSION=$(_VERSION21) $(DRIVER).sym
       echo setea
       call $(TOOLDIR)\ea.cmd -e .VERSION=$(_VERSION21) $(DRIVER).drv
       call $(TOOLDIR)\ea.cmd -e RequiredDriverFiles=$(DRIVER).drv $(DRIVER).drv
       echo devnames
       $(TOOLDIR)\devnames -e$(O)\$(DRIVER).drv .
       cd $(ROOT)\$(SRC_NL_RELATIVE)
!endif

#***************************************************************************
# Include Footer.mak at this point.
#***************************************************************************

!include $(ROOT)\footer.mak

#****************************************************************************
#  Dependency generation and Checking
#****************************************************************************

# Includes is currently commented out for test purposes.

$(O)\depend.mak:  $(O)\dephold
        -$(CREATE_PATH)
        -$(TOUCH) $(O)\depchk
        -echo generate depend.mak
        makedep -A -DPS -TP $(O) $(HCINC:-I=-I ) -o $@ *.c
        -del $(O)\depchk

$(O)\dephold:
        -$(TOUCH) $@

#!include $(O)\depend.mak

