#
# makefile:
#       makefile for TOOLS\STRRPL directory.
#       For use with IBM NMAKE, which comes with the IBM compilers,
#       the Developer's Toolkit, and the DDK.
#
#       All the makefiles have been restructured with V0.9.0.
#
#       Called from:    main makefile
#
#       Input:          files in this directory
#
#       Output:         strrpl.exe, copied to parent directory (TOOLS\).
#
#       Edit "setup.in" to set up the make process.
#

# Say hello to yourself.
!if [@echo +++++ Entering $(MAKEDIR)]
!endif

# include setup (compiler options etc.)
!include ..\..\setup.in

# First define the suffixes for files which NMAKE will work on.
# .SUFFIXES is a reserved NMAKE keyword ("pseudotarget") for
# defining file extensions that NMAKE will recognize in inference
# rules.

.SUFFIXES: .c .obj .dll .idl .h .ih .rc .res

HELPERS_BASE = $(CVS_WORK_ROOT)\xwphelpers
# set up helpers directories
HELPERS = $(HELPERS_BASE)\src\helpers
# helpers include path
HLPINC = $(HELPERS_BASE)\include\helpers

# set up include path
INCLUDE = $(INCLUDE);$(HELPERS_BASE)\include;..\..\include

# ICC environment variable for compiler options.
ICC     =
# /Wcnd- /Wgen- /Wcpy /Wobs- /Word- /Wcns+ /Wcnv-

# Compiler macro. This is used for each .OBJ file to be created.
CC      = icc /c /Ge /Gm- /Gd- /Re /O- /Oi- /ol- /q+ /Se /ss /Tn /w2 /Wcls+ /Wcpy+ /Wcmp+ /Wobs+ /Word+ /Wpro+ /Wrea+ /Wret+ /Wuni+ /Wuse+ /I$(PROJECT_INCLUDE)

# Some VisualAge C++ compiler options explained:
# /c:   compile only, no link (we'll call the linker explicitly)
# /fi+: precompile header files
# /gd-: link runtime statically
# /ge-: create DLL code
# /gi+: fast integer execution
# /Gl+: remove unreferenced functions (when comp.+link in 1 step)
# /gm+: multithread libraries
# /kc+: produce preprocessor warnings
# /o+:  optimization (inlining etc.)
# /oi-: no inlining (?)
# /ol+: use intermediate linker
# /q+:  suppress icc logo
# /Re : don't use subsystem libraries (!= Rn)
# /se:  all language extensions
# /si+: allow use of precompiled header files
# /ss:  allow double slashes comments in C too
# /ti+: debug code
# /tdp: compile everything as C++, even if it has a .C suffix
# /Tn:  add source line numbers to object files (for mapfile)
# /Wcls: class problems
# /Wcnd: conditional exprs problems (= / == etc.)
# /Wcmp: possible unsigned comparison redundancies
# /Wcns: operations involving constants
# /Wcnv: conversions
# /Wcpy: copy constructor problems
# /Wgen: generic debugging msgs
# /Wobs: obsolete features
# /Word: unspecified evaluation order
# /Wpar: list not-referenced parameters (annoying)
# /Wppc: list possible preprocessor problems (.h dependencies)
# /Wpro: warn if funcs have not been prototyped
# /Wrea: mark code that cannot be reached
# /Wret: check consistency of return levels
# /Wuni: uninitialized variables
# /Wuse: unused variables
# /w2:   produce error and warning messages, but no infos

LINK = ilink /map /nologo /linenumbers /optfunc

# /optfunc /debug

# The LIBS macro contains all the .LIB files, either from the compiler or
# others, which are needed for this project:
#   pmprintf    is for debugging (in /HELPERS)
# The other OS/2 libraries are used by default.
LIBS = $(HELPERS)\pmprintf.lib

# The HLPOBJS macro contains all the .OBJ files which need to be
# created from XFolder's HELPERS directory.
HLPOBJS = dosh.obj stringh.obj xstring.obj

# The HEADERS macro contains common header files. If one of these has
# been changed, everything will be recompiled.
HEADERS = $(HLPINC)\dosh.h $(HLPINC)\stringh.h $(HLPINC)\xstring.h

# Main targets
all: strrpl.exe
    @echo ----- Leaving $(MAKEDIR)

# 1) files in this directory
.c.obj:
        @ echo Compiling $*.c:
!ifndef PRECH
        $(CC) $*.c
!else
        $(CC) /fi"$(PRECH)\$*.pch" /si"$(PRECH)\$*.pch"  $*.c
!endif

# 2) same thing for the source files in /HELPERS; the .OBJ files
#    will be created in our directory too.
{$(HELPERS)}.c.obj:
        @ echo Compiling $*.c:
!ifndef PRECH
        $(CC) $(HELPERS)\$*.c
!else
        $(CC) /fi"$(PRECH)\$*.pch" /si"$(PRECH)\$*.pch" $(HELPERS)\$*.c
!endif

#
# Now define dependencies for all our .obj files by telling NMAKE
# which .OBJ file depends on what. For each .obj we define what files
# will enforce a recompilation when they've been changed.
#

# HELPERS
dosh.obj: $(HELPERS)\$*.c $(HEADERS)

stringh.obj: $(HELPERS)\$*.c $(HEADERS)

xstring.obj: $(HELPERS)\$*.c $(HEADERS)

# .OBJs for executables in this directory
strrpl.obj: $*.c $*.h $(HEADERS)

# "strrpl" executable: link and copy to parent (TOOLS) directory
strrpl.exe: $*.obj dosh.obj stringh.obj xstring.obj makefile
          $(LINK) /PMTYPE:VIO $*.obj dosh.obj stringh.obj xstring.obj $(LIBDIRS)
!ifdef LXLITEPATH
          $(LXLITEPATH)\lxlite strrpl.exe
!endif
          cmd.exe /c copy strrpl.exe ..
!ifndef WPI_DEBUG
!ifndef EMX
          cmd.exe /c copy strrpl.exe $(HELPERS_BASE)
!endif
!endif

