#==========================================================================

#----------------------------------------------------------------------------
# MAKEFILE for the parallel directory
#
# SCCSID: src/wpsh/parallel/makefile, wp.splr, c.splr	96/1/15
#
# COMPONENT_NAME: WPPO (parallel)		    (CVMC component name:WPPO)
#
# FUNCTIONS: Parallel PM Port Driver Interface
#
# 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
# -----------------------------------------------------------------------------
#		    RB	created this file
# 102906  10/18/94  TG	Remove instpath, non_var_args, and other things for
#			 Got/toc conversion
#		    RB	Changes for Common build
#------------------------------------------------------------------------------
#
#
#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 = parallel
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\parallel=)
!if "$(ROOT)"   == "$(MAKEDIR)"
ROOT		= $(MAKEDIR:\SRC\WPSH\PARALLEL=)
!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_NL_RELATIVE);$(R_OS2P_HDR)
#CMP_HDR_SUFFIX = <specify non-default path(s) for back INCLUDE path>
CMP_HDR_SUFFIX=  $(SOM_COMP_HDR)
#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

!ifndef HOST_PROC
HOST_PROC=386
HOST_OS=OS2
!endif

#-------------------------------------------------------------------------
# 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 WPPO features: These include:
#   SOM2VERSION, INSTOBJECT, CALL16BITDRV, OS2CBLD
# The default should be for a WPOS build for a	PPC or 386 proc.
#---------------------------------------------------------------------

!if "$(TARGET_PROC)"=="ppc"
!  if "$(TARGET_PROD)"=="os2c"
WPPOFEATURES = -DSOM2VERSION -DOS2CBLD
!  else
WPPOFEATURES = -DSOM2VERSION -DINSTOBJECT
!  endif
!endif

!if "$(TARGET_PROC)"=="386"
!  if "$(TARGET_PROD)"=="os2c"
WPPOFEATURES =	-DSOM2VERSION -DCALL16BITDRV -DOS2CBLD
!  else
WPPOFEATURES =	-DSOM2VERSION -DCALL16BITDRV -DINSTOBJECT
!  endif
!endif



!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)\
                         $(WPPOFEATURES)\
                         $(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=
DBG_LFLAGS=
!    else
DBG_CFLAGS= /Ti /DEBUG
DBG_LFLAGS=  /DE
!    endif
DEFINES= -DSOMRETAIL -DSOM_NoTest -DTEMPORARY
ICCFLAGS=-Gd-e- -Sp1 -Ss+ -Ms -C+ -Fo$@ -Dcdecl= -D_cdecl= -Rn -O -Wpro -Q+ -Yp+
RETOPTS=-DSOMRETAIL -DSOM_NoTest
CFLAGS =  $(DBG_CFLAGS) $(ICCFLAGS) $(RETOPTS) $(DEFINES) $(WPPOFEATURES)
LFLAGS = /noi /map /nol /exepack:2 /packcode /packdata /align:2 /noe /segments:300 $(DBG_LFLAGS)
!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.
#------------------------------------------------------------------------

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

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

!if "$(TARGET_PROD)"=="os2c"
ParallelLibs  = $(R_OS2_LIB)\os2386.lib\
                $(R_OS2P_LIB)\os2386p.lib\
                $(R_OS2_LIB)\dbcs32.lib
!endif

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

ParallelResource =   $(O_NLV)\parallel.o
!if "$(TARGET_PROC)"=="386"
ParallelResource =   $(O_NLV)\parallel.res
!endif


PDRICON = $(ROOT)\$(SRC_NL_RELATIVE)\icons

!if "$(TARGET_PROD)"=="ppc"
PDRICON=$(ICONPATH)
!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)\parallel.pdr

display_bld_info:
	@Echo -
	@Echo --------------------------------------------------------
	@Echo - Building component wppo - (Parallel Port PM Driver/parallel)
	@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


#---------------------------------------------------------------------
#  parallel.DEF
#---------------------------------------------------------------------
$(O)\parallel.def: makefile
	@Echo --------------------------------------------------------
	@Echo - Generating $(O)\parallel.def
	@Echo --------------------------------------------------------
!if "$(TARGET_PROC)"=="ppc"
	 Rem Create DEF file <<$(O)\parallel.def
LIBRARY PARALLEL INITINSTANCE TERMINSTANCE
DESCRIPTION '$(FILEVER) Parallel Port Library'
PROTMODE
DATA MULTIPLE NONSHARED LOADONCALL
CODE LOADONCALL
SEGMENTS
    .data	   CLASS 'DATA'      SHARED
    .bss	   CLASS 'DATA'      SHARED
EXPORTS
   SplPdEnumPort
   SplPdInitPort
   SplPdInstallPort
   SplPdGetPortIcon
   SplPdQueryPort
   SplPdSetPort
   SplPdRemovePort
   SplPdTermPort
<<keep
!endif

!if "$(TARGET_PROC)"=="386"
	 Rem Create DEF file <<$(O)\parallel.def
LIBRARY PARALLEL INITINSTANCE TERMINSTANCE
DESCRIPTION '$(FILEVER) Parallel Port Library'
PROTMODE
DATA MULTIPLE NONSHARED LOADONCALL
CODE LOADONCALL
EXPORTS
   SplPdEnumPort
   SplPdInitPort
   SplPdInstallPort
   SplPdGetPortIcon
   SplPdQueryPort
   SplPdSetPort
   SplPdRemovePort
   SplPdTermPort

   SPLPDENUMPORT      = SplPdEnumPort
   SPLPDINITPORT      = SplPdInitPort
   SPLPDINSTALLPORT   = SplPdInstallPort
   SPLPDGETPORTICON   = SplPdGetPortIcon
   SPLPDQUERYPORT     = SplPdQueryPort
   SPLPDSETPORT       = SplPdSetPort
   SPLPDREMOVEPORT    = SplPdRemovePort
   SPLPDTERMPORT      = SplPdTermPort
<<keep
!endif


#---------------------------------------------------------------------
# PARALLEL.O or PARALLEL.RES
#---------------------------------------------------------------------
$(ParallelResource): $(ROOT)\$(SRC_NL_RELATIVE)\parallel.rc\
                     $(ROOT)\$(SRC_NL_RELATIVE)\parallel.dlg\
                     $(PDRICON)\parallel.ico
	@Echo --------------------------------------------------------
	@Echo - Compiling Resource  $(ParallelResource)
	@Echo --------------------------------------------------------

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



#---------------------------------------------------------------------
# PARALLEL.PDR
#---------------------------------------------------------------------
$(DRIVERS_NLV)\parallel.pdr: $(O)\parallel.obj\
                           parallel.h\
                           $(O)\parallel.def\
                           $(ParallelResource)\
                           $(ParallelLibs)\
                           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)\parallel.obj
$(HCLIB)
-lspc
-los2
-los2p
-ldbcs
$(DLL_FINI)
<<keep
!endif

!if "$(TARGET_PROC)"=="386"
	$(LINK) $(LFLAGS)  @<<$(O_NLV)\$(@B).lnk
$(LFLAGS) +
$(O)\parallel.obj
$(DRIVERS_NLV)\parallel.dll
$(O_NLV)\$(@B).map
$(ParallelLibs: =+^
)
$(O)\$(@B).def
<<keep
	copy $(DRIVERS_NLV)\parallel.dll $@
	del  $(DRIVERS_NLV)\parallel.dll
	$(RC) $(RF) $(O_NLV)\parallel.res $(DRIVERS_NLV)\$(@B).pdr
	$(MAPSYM) $(O_NLV)\$(@B).map
	$(COPY) $(@B).sym $(O_NLV)\$(@B).sym
	del $(@B).sym
!endif




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



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

!include $(ROOT)\footer.mak



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