#----------------------------------------------------------------------------
# MAKEFILE for the infrared directory
#
# SCCSID: src/wpsh/infrared/makefile, c.wpsh
#
# COMPONENT_NAME: infrared_print
#
# FUNCTIONS: infrared 32-bit bidi PM Port Driver used to print to IR printers
#
# ORIGINS: Linked to os2
#
# (C) COPYRIGHT International Business Machines Corp. 1994
# 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.
#----------------------------------------------------------------------------
# Change History:
# ---------------
# Defect # Date     By  Description
# -----------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
#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
#----------------------------------------------------------------------------
# Define this Component Specific Macros
#----------------------------------------------------------------------------
# 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.
#------------------------------------------------------------------------------

SUBSYS          = wpsh
SUBSYS_RELATIVE = infrared
SRC_RELATIVE    = src\$(SUBSYS)\$(SUBSYS_RELATIVE)
SRC_NL_RELATIVE = mri\$(NLV)\$(SUBSYS)\$(SUBSYS_RELATIVE)


#------------------------------------------------------------------------------
#  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.
#------------------------------------------------------------------------------
# \src\mm\misc\mmpmcrt is an example of the path for a specific component
# in the tree structure. Please change the path as applied to your component.
# Refer to Nmake documentation, if you have any questions about MAKEDIR
#------------------------------------------------------------------------------

ROOT            = $(MAKEDIR:\src\wpsh\infrared=)
!if "$(ROOT)"   == "$(MAKEDIR)"
ROOT            = $(MAKEDIR:\SRC\WPSH\INFRARED=)
!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=$(ROOT)\$(SRC_RELATIVE);$(ROOT)\$(SRC_RELATIVE)\irh;$(ROOT)\$(SRC_NL_RELATIVE);$(R_OS2P_HDR)
#CMP_HDR_SUFFIX = <specify non-default path(s) for back INCLUDE path>
CMP_HDR_SUFFIX=  $(SOM_COMP_HDR);$(R_OS2_HDR)\16bit
#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=


# Uncomment to use ibmc libs.  With this out, it uses the
# default metaware libs location.
USE_IBMC_LIB = 1


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


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

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

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

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

.SUFFIXES: .c .obj .dll .idl .h .ih .rc .res .i .ptr .ico .bmp

#----------------------------------------------------------------
# Set up the PATHs
#-----------------------------------------------------------------

#------------------------------------------------------------------------
# Please define all compiler, assembler, and linker flags here.
# Use if statement to define the flags for each type of builds.
#------------------------------------------------------------------------
# CFLAGS: WPOS - for WPOS build,  SOM2VERSION for SOM2 version
#------------------------------------------------------------------------

RFLAGS     = -cp $(P) -r -x -DSOM2VERSION -D_PPC_ -D_PPC
MFLAGS     = -DSOM2VERSION=1 -D_PPC_=1 -D_SQL_PPC_=1
RF         = -x -p


#---------------------------------------------------------------------
# Setup infrared features: These include:
# The default should be for a WPOS build for a  PPC or 386 proc.
#---------------------------------------------------------------------

!if "$(TARGET_PROC)"=="ppc"
!    if "$(BLD_TYPE)"=="retail"
DBG_CFLAGS=
!    else
DBG_CFLAGS= -g -DDEBUG
!    endif
DEFINES=-DNO_STRINGS_READONLY -D_OS2 -DINCL_32 -D_PPC_ -DLA_COMPATIBLE
DEFS = -DMETAWARE -DPOWERPC -DMICROKERNEL
CFLAGS= -c $(DBG_CFLAGS) $(SYSTEM_CFLAGS) $(MW_IBMC_DEFS) -o $@\
                         $(DEFINES)\
                         $(DEFS)\
                         -Hpragma=Offwarn(39,88,178,257,290,587,652)\
                         -Hpragma=Offwarn(344,657,675)\
                         -pic\
                         -Hon=Char_default_unsigned\
                         -Hpragma=os_id(4)\
                         -Hon=Char_is_rep
CMP_DLL_LFLAGS =
LIBS   = -L $(COMPILER_LIB) -L $(R_OS2_LIB) -lspc -los2 -los2p
!endif


!if "$(TARGET_PROC)"=="386"
!    if "$(BLD_TYPE)"=="retail"
DBG_CFLAGS=
!    else
DBG_CFLAGS= /Ti /DEBUG /DDEBUG /DDEBUG_ALERT
!    endif
ICCFLAGS=-Gd-e- -Sp1 -Ss+ -Ms -C+ -Fo$@ -Dcdecl= -D_cdecl= -Rn -O -Wpro -Q+ -Yp+
CFLAGS = /DBIDI $(DBG_CFLAGS) $(ICCFLAGS)
LFLAGS = /noi /map /nol /exepack:2 /packcode /packdata /align:2 /noe /segments:300
!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:
        @Echo -
        @Echo --------------------------------------------------------
        @Echo - Generating $(@)
        @Echo --------------------------------------------------------
         $(CC)  $(CFLAGS) $(@B).c

.asm.obj:
        @Echo -
        @Echo --------------------------------------------------------
        @Echo - Generating $(@)
        @Echo --------------------------------------------------------
         $(AS) $(AFLAGS) $(AINC) $(@B).asm ;

.c.i:
        @Echo -
        @Echo --------------------------------------------------------
        @Echo - Generating $(@)
        @Echo --------------------------------------------------------
         $(CC) $(CFLAGS) -P  $(@B).c

.rc.obj:
        @Echo -
        @Echo --------------------------------------------------------
        @Echo - Generating $(@)
        @Echo --------------------------------------------------------
         $(RC) $(RFLAGS) $(@B).rc



#------------------------------------------------------------------------
#Component defines start here.
#This builds infrared.pdr
#------------------------------------------------------------------------

!if "$(TARGET_PROC)"=="ppc"
InfraredLibs  = $(R_OS2P_LIB)\libos2p.a\
                $(R_OS2_LIB)\libos2.a\
                $(R_OS2P_LIB)\libdbcs.a\
                $(COMPILER_LIB)\libspc.a
!endif

!if "$(TARGET_PROC)"=="386"
InfraredLibs  = $(R_OS2P_LIB)\os2386p.lib\
                $(R_OS2_LIB)\os2386.lib\
                $(R_OS2_LIB)\dbcs32.lib\
                $(COMPILER_LIB)\dde4nbs.lib
!endif

!if "$(TARGET_PROD)"=="os2c"
InfraredLibs  = $(R_OS2_LIB)\os2386.lib
!endif

OBJS  =  $(O)\infrared.obj \
         $(O)\init.obj \
         $(O)\help.obj \
         $(O)\pdrapi.obj \
         $(O)\util.obj


#---------------------------------------------------------------------
# Setup Any Misc. Macros here
#---------------------------------------------------------------------

InfraredResource =   $(O_NLV)\infrared.o
!if "$(TARGET_PROC)"=="386"
InfraredResource =   $(O_NLV)\infrared.res
!endif


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

all: display_bld_info\
     create_paths\
     dep\
     $(DRIVERS_NLV)\infrared.pdr\
     $(DRIVERS_NLV)\infrared.hlp

display_bld_info:
        @Echo -
        @Echo --------------------------------------------------------
        @Echo - Building component infrared - (infrared.pdr PM Port Driver)
        @Echo - Target_Proc: $(TARGET_PROC)   Build_type: $(BLD_TYPE)
        @Echo - Host_Proc  : $(HOST_PROC)       Host_OS: $(HOST_OS)
        @Echo - Target Prod: $(TARGET_PROD)
        @Echo --------------------------------------------------------

#----------------------------------------------------------------------------
# Create Tree Structure
#----------------------------------------------------------------------------
# Use the following to create a directory structure that may not exist
#
# A path can be any pathname valid for a filename {without the filename and
# no trailing "\"}.
#
# makepath is an utility to create all subdirectories in the path.
#
# Use the createpaths target to make sure paths are created before
# other dependencies
#--------------------------------------------------------------------------

create_paths:
        @Echo --------------------------------------------------------
        @Echo - Creating paths
        @Echo --------------------------------------------------------
        $(MAKEPATH) $(DRIVERS_NLV) >nul 2>nul
        $(MAKEPATH) $(O_NLV)       >nul 2>nul
        $(MAKEPATH) $(O)           >nul 2>nul


#---------------------------------------------------------------------
#  infrared.DEF
#---------------------------------------------------------------------
$(O)\infrared.def: makefile
        @Echo --------------------------------------------------------
        @Echo - Generating $(O)\infrared.def
        @Echo --------------------------------------------------------
!if "$(TARGET_PROC)"=="ppc"
         Rem Create DEF file <<$(O)\infrared.def
LIBRARY INFRARED INITINSTANCE TERMINSTANCE
DESCRIPTION '$(FILEVER) Infrared PM Port Driver'
PROTMODE
DATA MULTIPLE NONSHARED LOADONCALL
CODE LOADONCALL
SEGMENTS
    .data          CLASS 'DATA'      SHARED
    .bss           CLASS 'DATA'      SHARED
EXPORTS
   SplPdEnumPort         @501
   SplPdInstallPort      @502
   SplPdGetPortIcon      @503
   SplPdQueryPort        @504
   SplPdSetPort          @505
   SplPdRemovePort       @506
   SplPdOpen             @508
   SplPdWrite            @509
   SplPdAbortDoc         @510
   SplPdNewPage          @511
   SplPdClose            @512
   SplPdQuery            @513
   SplPdSet              @514
   SplPdSendCmd          @515
   SplPdRemoteSetPort    @516
<<keep
!endif

!if "$(TARGET_PROC)"=="386"
         Rem Create DEF file <<$(O)\infrared.def
LIBRARY INFRARED INITINSTANCE TERMINSTANCE
DESCRIPTION '$(FILEVER) Infrared PM Port Driver'
PROTMODE
DATA MULTIPLE NONSHARED LOADONCALL
CODE LOADONCALL
EXPORTS
   SPLPDENUMPORT      = SplPdEnumPort         @501
   SPLPDINSTALLPORT   = SplPdInstallPort      @502
   SPLPDGETPORTICON   = SplPdGetPortIcon      @503
   SPLPDQUERYPORT     = SplPdQueryPort        @504
   SPLPDSETPORT       = SplPdSetPort          @505
   SPLPDREMOVEPORT    = SplPdRemovePort       @506
   SPLPDOPEN          = SplPdOpen             @508
   SPLPDWRITE         = SplPdWrite            @509
   SPLPDABORTDOC      = SplPdAbortDoc         @510
   SPLPDNEWPAGE       = SplPdNewPage          @511
   SPLPDCLOSE         = SplPdClose            @512
   SPLPDQUERY         = SplPdQuery            @513
   SPLPDSET           = SplPdSet              @514
   SPLPDSENDCMD       = SplPdSendCmd          @515
   SPLPDREMOTESETPORT = SplPdRemoteSetPort    @516
<<keep
!endif


#---------------------------------------------------------------------
# infrared.O or infrared.RES
#---------------------------------------------------------------------
$(InfraredResource): pdrconst.h $(ROOT)\$(SRC_NL_RELATIVE)\infrared.rc \
                                $(ROOT)\$(SRC_NL_RELATIVE)\infrared.dlg
        @Echo --------------------------------------------------------
        @Echo - Compiling Resource  $(InfraredResource)
        @Echo --------------------------------------------------------

!if "$(TARGET_PROC)"=="ppc"
        $(MRES) $(MRES_INC_PATHS) $(MFLAGS) -As,$(ROOT)\$(SRC_NL_RELATIVE)\infrared.rc -- $(O_NLV)\infrared.o
!endif
!if "$(TARGET_PROC)"=="386"
#       cd $(ICONPATH)
        $(RC) $(RFLAGS) $(ROOT)\$(SRC_NL_RELATIVE)\infrared.rc $(O_NLV)\infrared.res
        cd $(ROOT)\$(SRC_RELATIVE)
!endif

#---------------------------------------------------------------------
# infrared.hlp
#---------------------------------------------------------------------

$(DRIVERS_NLV)\infrared.hlp: $(ROOT)\$(SRC_NL_RELATIVE)\infrared.ipf
       $(IPF) $(ROOT)\$(SRC_NL_RELATIVE)\infrared.ipf /l=$(L) /codepage=$(P) /country=$(C)
       copy $(ROOT)\$(SRC_NL_RELATIVE)\infrared.hlp $(DRIVERS_NLV)\infrared.hlp
       del $(ROOT)\$(SRC_NL_RELATIVE)\infrared.hlp


#---------------------------------------------------------------------
# infrared.pdr
#---------------------------------------------------------------------
$(DRIVERS_NLV)\infrared.pdr: $(OBJS)\
                           $(O)\infrared.def\
                           $(InfraredResource)\
                           $(InfraredLibs)\
                           makefile
        @Echo --------------------------------------------------------
        @Echo - Linking $(@B).pdr
        @Echo --------------------------------------------------------
!if "$(TARGET_PROC)"=="ppc"
        $(LINK) $(DLL_LFLAGS)  @<<$(O_NLV)\$(@B).lnk
-o $@
-i$(O)\$(@B).def
$(O_NLV)\$(@B).o
$(O)\infrared.obj
$(HCLIB)
-lspc
-los2
-los2p
-ldbcs
$(DLL_FINI)
<<keep
!endif

!if "$(TARGET_PROC)"=="386"
        $(LINK) $(LFLAGS)  @<<$(O_NLV)\$(@B).lnk
$(LFLAGS) +
$(OBJS)
$(DRIVERS_NLV)\infrared.dll
$(O_NLV)\$(@B).map
$(InfraredLibs: =+^
)
$(O)\$(@B).def
<<keep
        copy $(DRIVERS_NLV)\infrared.dll $@
        del  $(DRIVERS_NLV)\infrared.dll
        $(RC) $(RF) $(O_NLV)\infrared.res $(DRIVERS_NLV)\$(@B).pdr
        ea2 -e OPTIONALDRIVERFILES=infrared.hlp,infrared.sym $(DRIVERS_NLV)\$(@B).pdr
        ea2 $(DRIVERS_NLV)\$(@B).pdr
        $(MAPSYM) $(O_NLV)\$(@B).map
        $(COPY) $(@B).sym $(O_NLV)\$(@B).sym
        $(COPY) $(@B).sym $(DRIVERS_NLV)\$(@B).sym
        del $(@B).sym
!endif




#**************************************************************************
#  Hand generated dependencies
#**************************************************************************



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

!include $(ROOT)\footer.mak



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