#====START_GENERATED_PROLOG======================================
#
#
#   COMPONENT_NAME: odsamples
#
#   CLASSES: none
#
#   ORIGINS: 27
#
#
#   (C) COPYRIGHT International Business Machines Corp. 1995,1996
#   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.
#   	
#
#   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
#   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
#   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
#   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
#   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
#   OR PERFORMANCE OF THIS SOFTWARE.
#
#====END_GENERATED_PROLOG========================================
#
# @(#) 1.49 nt/src/samples/Platform.w95, odsamples, od96nt, odnt9712d 2/13/97 13:44:51 [ 3/21/97 17:25:11 ]
#
#--------------------------------------------------------------------------
#
# Note: This is the platform specific header for the OpenDoc nmake files
#       on Windows 95 using the VisualAge compiler or the Visual C++ compiler.
#	If both compilers are installed, the default will be the VisualAge
#	compiler.
#
# characters that can precede a make line:
#    @  suppresses display of the command
#    -  turns off error checking for the command
#    !  executes the command for each dependent file
#
# make macros:
#    $@   the target file	(d:/src/main.cpp)
#    $*   base name             (d:/src/main)
#    $**  dependent files (sources)
#    $?   sources newer than target
#    $<   single source newer than target
#    $$@  current NMAKE target
#    
# macro modifiers - you can modify all of the make macros above this way
#    $(@D) - directory only 	(d:/src)
#    $(@F) - file only          (main.cpp)
#    $(@B) - base filename only (main)
#    $(@R) - path, no extension (d:/src/main)
#    $(SOMETHING:a=b) - substitutes changes a's in $(SOMETHING) to b's
#
# shell programming:
#    echo .    - provides a spacer line (since echo. doesn't work)
#    for %%variable (or %variable) in (some set) do command:
#	Each %%variable (or %variable) is replaced with each string in (some 
#       set) until the command processes all files.  %% is used within a 
#       batch pgm.
#


# Important Note: The compile and link flags in this nmake file are the
#                 basic core set of flags.  If you want to build optimized
#                 code or debug code you will need to set the compiler
#                 specific environment variables.  Here are our suggestions:
#
#                 VisualAge Compiler         Visual C++ Compiler
#                  Optimized build            Optimized build
#                   set ICC = -O+ -Om-         set CL = -Ox
#                   set ILINK = -NOBROWSE      set LINK =
#
#                  Debug build                Debug build
#                   set ICC = -Ti+ -DDEBUG     set CL = -Ge -Zi -DDEBUG
#                   set ILINK = -DEBUG         set LINK = -DEBUG -DEBUGTYPE:BOTH


# Important Note: The VisualAge Compiler logic has the additional capability
#                 of letting you optionally link in your own runtime library.
#                 The default is to dynamically link in the compiler's runtime.
#                 To link in your own runtime, call nmake with the
#                 LocalRuntimeLibrary macro set to your runtime library.
#                 This macro triggers the logic that adjusts the compile and
#                 link flags to use your runtime library.
#                   %ODSRC%\src\runtime gives an example of building a local
#                 runtime library based off the description in "Creating
#                 Your Own Runtime Library DLLs" in the VisualAge C++
#                 Programming Guide. After creating iodrt.dll in
#                 %ODSRC%\src\runtime, you could build the IBM Samples, having
#                 them linked to the local runtime, by issuing the following
#                 nmake command:
#                    nmake "LocalRuntimeLibrary=%ODSRC%\lib\iodrt.lib %CPPMAIN%\lib\CPPWM35O.lib %CPPMAIN%\lib\CPPWOC3.lib"
#



#..............................................................................
#                       Macros used to re-set environment variables
#..............................................................................

# Whenever the som compiler is used, These become the new settings of
# SMNOTC and SMINCLUDE.
NmakeSMNOTC=
NmakeSMINCLUDE=

# Whenever the resource compiler is used, This becomes the new setting of
# INCLUDE.
NmakeINCLUDE=

# Whenever a package is built, this is used as the locale
!IF "$(LOCALE)"=="" || "$(LOCALE)"=="C"
NmakeLOCALE=en_US
!ELSE
NmakeLOCALE=$(LOCALE)
!ENDIF


# Whenever we build a lib or a dll, NMakePATH is put at the beginning of
# PATH, and NmakeLIB is put at the beginning of LIB.
!IFDEF CPPMAIN

#.............................
# VisualAge Compiler settings
#.............................

NmakePATH = $(ODSRCPATHS:;=\dll;)$(ODPARTPATHS:;=\dll;)$(ODBASEPATHS:;=\dll;)$(ODBASEPATHS:;=\bin;)$(CPPMAIN)\ODBC32;$(CPPMAIN)\ODBC32\WIN95;$(CPPMAIN)\MACROS;$(CPPMAIN)\SDK\BIN\WIN95;$(CPPMAIN)\SDK\BIN;$(CPPMAIN)\BIN;

NmakeLIB=$(ODSRCPATHS:;=\lib;)$(ODPARTPATHS:;=\lib;)$(ODBASEPATHS:;=\lib;)$(CPPMAIN)\LIB;$(CPPMAIN)\SDK\LIB;

!ELSE

!IFDEF MSDEVDIR

#.............................
# Visual C++ Compiler settings
#.............................

! IFDEF VCSOURCE

NmakePATH = $(ODSRCPATHS:;=\dll;)$(ODPARTPATHS:;=\dll;)$(ODBASEPATHS:;=\dll;)$(ODBASEPATHS:;=\bin;)$(MSDEVDIR)\BIN;$(MSDEVDIR)\BIN\WIN95;$(VCSOURCE)\BIN;$(VCSOURCE)\BIN\WIN95;

NmakeLIB=$(ODSRCPATHS:;=\lib;)$(ODPARTPATHS:;=\lib;)$(ODBASEPATHS:;=\lib;)$(MSDEVDIR)\LIB;$(MSDEVDIR)\MFC\LIB;$(VCSOURCE)\LIB;$(VCSOURCE)\MFC\LIB;

! ELSE

NmakePATH = $(ODSRCPATHS:;=\dll;)$(ODPARTPATHS:;=\dll;)$(ODBASEPATHS:;=\dll;)$(ODBASEPATHS:;=\bin;)$(MSDEVDIR)\BIN;$(MSDEVDIR)\BIN\WIN95;

NmakeLIB=$(ODSRCPATHS:;=\lib;)$(ODPARTPATHS:;=\lib;)$(ODBASEPATHS:;=\lib;)$(MSDEVDIR)\LIB;$(MSDEVDIR)\MFC\LIB;

! ENDIF

!ENDIF
!ENDIF


#..............................................................................
# set the LIB path for building the OpenDoc samples
#..............................................................................
LIB=$(NmakeLIB)


#..............................................................................
#			General use Macros
#..............................................................................

IncludeDir     = $(ODSRC)\include

# These are the list of Locales we know are valid
# LocaleList = de_DE es_ES en_US fr_FR ja_JP pt_BR zh_CN zh_TW
LocaleList = en_US ja_JP


SOMDefines     = -D_PLATFORM_WIN32_

SOMArgs        = -p -c -mchkexcept

SOMIncludes    = -I$(ODSRCPATHS:;=\include -I)$(ODPARTPATHS:;=\include -I)$(ODBASEPATHS:;=\include -I)$(SOMBASE)\BINDINGS -I$(SOMBASE)\INCLUDE

SOMOptions     = $(SOMArgs) $(SOMDefines) $(SOMIncludes)

SOPTS = $(SOMOptions) $(ExtraSOMCompileOptions)

CompileDefines = -D_PLATFORM_WIN32_ -DODDebug=0 -D_NATIVE_EXCEPTIONS_



!IFNDEF CPPMAIN
!IFNDEF MSDEVDIR

#.............................
# This nmake file ONLY supports IBM's VisualAge compiler and Microsoft's
# Visual C++ compiler.
#.............................

COMPILE = not_supported

ResourceCompiler = not_supported

StandardLibraryBuilder = not_supported

LINKER = not_supported

!ENDIF
!ENDIF



!IFDEF CPPMAIN

#.............................
# VisualAge Compiler settings
#.............................


# If nmake was called with a LocalRuntimeLibrary macro set to a local runtime
# library, don't link dynamically to the compiler runtime
! IF "$(LocalRuntimeLibrary)" != ""
CompileArgs    = -C+ -Gd+ -Gm+ -Gs- -Q+ -Ss+ -Su4 -Ge- -Gn+ $(ICC)
! ELSE
CompileArgs    = -C+ -Gd+ -Gm+ -Gs- -Q+ -Ss+ -Su4 -Ge- $(ICC)
! ENDIF

CompileIncludes=-I. -I$(ODSRCPATHS:;=\include -I)$(ODPARTPATHS:;=\include -I)$(ODBASEPATHS:;=\include -I)$(SOMBASE)\include -I$(SOMBASE)\bindings -I$(CPPMAIN)\ibmclass -I$(CPPMAIN)\sdk\winh -I$(CPPMAIN)\sdk\winh\winnt -I$(CPPMAIN)\sdk\winh\win95

COMPILE = icc

ResourceCompiler = $(CPPMAIN)\bin\irc

StandardLibraryBuilder = ilib /nobrowse /noext /nobackup /nologo /GENI:

# If nmake was called with a LocalRuntimeLibrary macro set to a local runtime
# library, disregard the default libraries
! IF "$(LocalRuntimeLibrary)" != ""
LinkOptions = /NOE /st:100000 /NOLogo /Se:512 /NOD $(ILINK)
! ELSE
LinkOptions = /NOE /st:100000 /NOLogo /Se:512 $(ILINK)
! ENDIF

LinkLibraries = $(CPPMAIN)/sdk/lib/gdi32.lib    \
      $(CPPMAIN)/sdk/lib/user32.lib  \
      $(CPPMAIN)/sdk/lib/kernel32.lib

LINKER = ilink



!ELSE
!IFDEF MSDEVDIR

#.............................
# Visual C++ Compiler settings
#.............................

CompileArgs    = /c /G5 /MD /X /GX /nologo $(CL)

! IFDEF VCSOURCE

CompileIncludes=-I. -I$(ODSRCPATHS:;=\include -I)$(ODPARTPATHS:;=\include -I)$(ODBASEPATHS:;=\include -I)$(MSDEVDIR)\include -I$(MSDEVDIR)\mfc\include -I$(VCSOURCE)\include -I$(VCSOURCE)\mfc\include -I$(SOMBASE)\include

! ELSE

CompileIncludes=-I. -I$(ODSRCPATHS:;=\include -I)$(ODPARTPATHS:;=\include -I)$(ODBASEPATHS:;=\include -I)$(MSDEVDIR)\include -I$(MSDEVDIR)\mfc\include -I$(SOMBASE)\include

! ENDIF

COMPILE = cl

ResourceCompiler = rc

StandardLibraryBuilder = lib /nologo /DEF:$(BaseNamePartOfTarget).mdf /OUT:

LinkOptions = /INCREMENTAL:NO /NOLogo /STACK:100000 /COMMENT:"Copyright (C) 1996 by IBM Corporation.  All rights reserved." $(LINK)

LinkLibraries = $(MSDEVDIR)/lib/gdi32.lib    \
      $(MSDEVDIR)/lib/user32.lib  \
      $(MSDEVDIR)/lib/kernel32.lib

LINKER = link

!ENDIF
!ENDIF


CompileOptions = $(CompileArgs) $(CompileDefines) $(CompileIncludes)

COPTS = $(CompileOptions) $(ExtraCompileOptions)

LOPTS = $(LinkOptions) $(ExtraLinkOptions)

REMOVE = erase

COPY = copy

# We use the Info-ZIP 32-bit compression code when we create packages.
# It's freely available from CompuServe in the IBMPRO forum and by
# anonymous ftp from the Internet site ftp.uu.net:/pub/archiving/zip/WIN32.
# If you decide to use it, this build logic will work after you
# set the NmakeZIP2EXE environment variable to the full path location
# of unzipsfx.exe.
#   If you decide to use any other 32-bit compression code, you will have
# adjust the ZIP and ZIP2EXE macros, and the logic that uses them, accordingly.
#
ZIP = zip -j
ZIP2EXE = copy /b $(NMAKEZIP2EXE)+$(RegMain:.dll=.zip) $(RegMain:.dll=.exe)


Platform = win32

# These suffixes are to help promote portable nmake files between platforms.
# When the suffixes change on different platforms, these suffixes are the
# only things that need to change.  All the sample nmake files that use these
# suffix macros, so they are portable between different platforms.
Exp = exp
Def = def
Obj = obj
LibSuffix = lib
Locale = locale


#..............................................................................
#			Default Targets
#..............................................................................
DefaultTarget : Idls Hdrs Libs Dlls


# Rule to copy the idls to samples
Idls : CheckEnvironmentVariables Idl
!   IF "$(Subdirs)"!=""
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f Idls
!   ENDIF

Idl  : $(IdlTargets)
!   IF "$(IdlTargets)"!="" 
    !$(COPY) $** $(IncludeDir)
!   ENDIF


# Rules to process the headers
Hdrs : CheckEnvironmentVariables Hdr
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f Hdrs
!   ENDIF

Hdr  :: $(MsgTargets)

Hdr  :: $(HdrTargets)
!	IF "$(HdrTargets)"!="" 
	   @FOR %%f IN ($(HdrTargets)) DO $(COPY) %%f $(IncludeDir)
!	ENDIF

Hdr  :: $(RcTargets)
!       IF "$(RcTargets)"!=""
	   @echo .
	   set INCLUDE=$(NmakeINCLUDE)
           @FOR %%f IN ($(RcTargets)) DO $(ResourceCompiler) $(CompileDefines) $(CompileIncludes) %%f
	   @set INCLUDE=$(INCLUDE)
!       ENDIF

Hdr  :: $(IdlTargets:.idl=.xh)


# Rule to make the libraries
Libs : CheckEnvironmentVariables Lib
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f Libs
!   ENDIF

Lib  : $(LibTargets)


# Rule to make the dlls
Dlls : CheckEnvironmentVariables Dll
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f Dlls
!   ENDIF

Dll  :: $(DllTargets)

Dll  :: $(ODCFG)\opendoc.ir $(CtypelibIDL:.idl=.tlb)


#..............................................................................
#			Default build rules and macros
#..............................................................................
.SUFFIXES: .cpp .CPP .idl .IDL .msg .MSG .tlb .TLB .hpj .HPJ


.cpp.obj:
	@echo .
	$(COMPILE) $(COPTS) -Fo$@ $<

.rc.res:
	@echo .
	set INCLUDE=$(NmakeINCLUDE)
	$(ResourceCompiler) $(CompileDefines) $(CompileIncludes) -fo$@ $<
	@set INCLUDE=$(INCLUDE)

.idl.xh:
	@echo .
	set SMNOTC=$(NmakeSMNOTC)
	set SMINCLUDE=$(NmakeSMINCLUDE)
	$(SOMBASE)\bin\sc -sxh -d$(IncludeDir) $(SOPTS) $**
	@set SMNOTC=$(SMNOTC)
	@set SMINCLUDE=$(SMINCLUDE)

.idl.xih:
	@echo .
	set SMNOTC=$(NmakeSMNOTC)
	set SMINCLUDE=$(NmakeSMINCLUDE)
	$(SOMBASE)\bin\sc -sxih $(SOPTS) $**
	@set SMNOTC=$(SMNOTC)
	@set SMINCLUDE=$(SMINCLUDE)

.msg.cat:
	@echo .
	set PATH=$(NmakePATH)%%PATH%%
	runcat $(**R)

.hpj.hlp:
	@echo .
	hcw /E /C /M $**

.idl.tlb:
	@echo .
!	IF ("$(CtypelibCmdLineArgsFile)"!="") && ("$(CtypelibDir)"!="")  && ("$(CtypelibIDL)"!="")
		set SMNOTC=$(NmakeSMNOTC)
		set SMINCLUDE=$(NmakeSMINCLUDE)
		$(SOMBASE)\bin\sc -sir -u -mnolock -ESOMIR="$(ODCFG)\opendoc.ir" $(SOPTS) $(CtypelibIDL)
		@set SMNOTC=$(SMNOTC)
		@set SMINCLUDE=$(SMINCLUDE)
		set PATH=$(NmakePATH)%%PATH%%
		@echo .
		ctypelib -f $(CtypelibCmdLineArgsFile) -t $(CtypelibDir:/=\)\$(@B)
!       ELSE
		@echo ERROR: typelib could not be created.
		@echo The CtypelibCmdLineArgsFile macro must be set to
		@echo		the name of the file that contains
		@echo		the input arguments to ctypelib
		@echo The CtypelibCmdDir macro must be set to the directory
		@echo		where the typelib is being built
		@echo The CtypelibIDL macro must be set to the idl
		@echo .
!       ENDIF


# Rule to re-register the idl when it has been modified
#
$(ODCFG)\opendoc.ir : $(RegIDL)
#
#       RegIDL being set means we have an OpenDoc part that needs
#       to be registered
!	IF "$(RegIDL)"!=""
!	   IF "$(RegClassName)"!=""
		@echo .
		set SMINCLUDE=$(NmakeLIB:\lib=\include)
		set INCLUDE=$(NmakeLIB:\lib=\include)
		set PATH=$(NmakePATH)%%PATH%%
		reg1part $(RegClassName) $(RegIDL:.idl=)
!	   ELSE
		@echo .
		@echo ERROR: A ClassName has to be identified for the RegIDL.
		@echo 	Set the RegClassName macro.
		@echo .
!	   ENDIF
!	ENDIF


# Rules to check the environment variables
#
CheckEnvironmentVariables : CheckForCPPMAIN CheckForODSRC

CheckForCPPMAIN:
!	IFNDEF CPPMAIN
!		IFNDEF MSDEVDIR
			@echo .........................................
			@echo The OpenDoc nmake files are written to be used
			@echo with either the IBM VisualAge compiler, or with
			@echo the Microsoft Visual C++ compiler.  It appears
			@echo neither compiler is installed.
			@echo If you *do* have the Visual C++ compiler installed,
			@echo and you are getting this message, run VCVARS32.BAT
			@echo to set the proper environment variables.
			@echo Building can not continue.
			@echo .........................................
			@abort
!		ENDIF
!	ENDIF

CheckForODSRC:
!	IFNDEF ODSRC
		@echo .........................................
		@echo ODSRC, one of the OpenDoc environment variables, is
		@echo not defined, it appears OpenDoc has not been
		@echo correctly installed.
		@echo Building the samples can not continue.
		@echo .........................................
		@abort
!	ENDIF

CheckForLOCALE:
!       IF "$(LOCALE)"=="" || "$(LOCALE)"=="C"
		@echo .........................................
!               IF "$(LOCALE)"==""
                   @echo  The LOCALE environment variable is currently not set.
!               ELSE
                   @echo  The LOCALE environment variable is currently set to "C".
!               ENDIF
                @echo  Because of this, the locale of the package will default to
                @echo  en_US.  If you wish to use a differnet locale, you must set
                @echo  the LOCALE environment variable to that locale.
		@echo .........................................
                @echo .
!       ENDIF

CheckForNmakeZIP2EXE:
!	IFNDEF NMAKEZIP2EXE
		@echo .........................................
		@echo NmakeZIP2EXE, the environment variable for
		@echo specifying the 32-bit compression code used
		@echo to make packages, is not defined.  This
		@echo environment variable is necessary to build packages.
		@echo   You will need to install some version of
		@echo 32-bit compression code.  We recommend the
		@echo Info-ZIP 32-bit compression code.  It's freely
		@echo available from CompuServe in the IBMPRO forum
		@echo and by anonymous ftp from the Internet site
		@echo ftp.uu.net:/pub/archiving/zip/WIN32.
		@echo   After it is installed, set the NmakeZIP2EXE
		@echo to the full path name of unzipsfx.exe.
		@echo   If you use any other 32-bit compression code,
		@echo you will have to edit Platform.w95 accordingly.
		@echo   Building the packages can not continue.
		@echo .........................................
		@abort
!	ENDIF



# ForceRegistrys and ForceRegistry are rules to force the registration
# of a part.  This rule is *not* part of the default target, so it doesn't
# happen automatically.  You have to run this as a separate build step.
#
ForceRegistrys : CheckEnvironmentVariables ForceRegistry
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f ForceRegistrys
!   ENDIF

ForceRegistry : $(RegIDL) $(RegeditTarget) $(CtypelibIDL:.idl=.tlb)
!	IF "$(RegIDL)"!=""
!	   IF "$(RegClassName)"!=""
		@echo .
		set SMINCLUDE=$(NmakeLIB:\lib=\include)
		set INCLUDE=$(NmakeLIB:\lib=\include)
		set PATH=$(NmakePATH)%%PATH%%
		reg1part $(RegClassName) $(RegIDL:.idl=)
!               IF "$(CtypelibIDL)"!=""
                        @echo .
                        scriptrg $(RegClassName) $(CtypelibDir:/=\)\$(CtypelibIDL:.idl=.tlb)
!               ENDIF
!	   ELSE
		@echo .
		@echo ERROR: A ClassName has to be identified for the RegIDL.
		@echo 	Set the RegClassName macro.
		@echo .
!	   ENDIF
!	ENDIF
!       IF "$(RegeditTarget)"!=""
                @echo .
                call regedit $(RegeditTarget)
!       ENDIF


# Pkgs, Pkg, $(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz), and
# $(RegMain:.dll=.odt) are rules to make a part to be installed.
# These rules are *not* part of the default target, so it doesn't happen
# automatically.  You have to run this as a separate build step.
#
Pkgs : CheckEnvironmentVariables Pkg
!   IF "$(Subdirs)"!=""
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f Pkgs
!   ENDIF


!IF "$(RegMain)"!=""

Pkg  : CheckForNmakeZIP2EXE CheckForLOCALE $(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz)
#
#     The package for the native locale was built as the source to this
#     target.  Now try to build the packages for the other locales.
#
	@--FOR %%g IN ($(LocaleList)) DO \
	    IF NOT "%%g" == "$(NmakeLOCALE)" \
		$(MAKE) /nologo "NmakeLOCALE = %%g" BuildPkgForSingleLocale


BuildPkgForSingleLocale :
	@echo .
	@$(ODSRC)\bin\NMakCpkg $(ODSRC)\locale\$(NmakeLOCALE) $(FilesCats) $(FilesHelps)
	@$(MAKE) /nologo "NmakeLOCALE = $(NmakeLOCALE)" $(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz)




!IFDEF CPPMAIN
FilesDefs = $(FilesLibs:.lib=.def)
!ELSE
!IFDEF MSDEVDIR
FilesDefs =
!ENDIF
!ENDIF
FilesExps = $(FilesLibs:.lib=.exp)

$(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz)  : CleanPkgParts {$(ODSRC)\dll}$(RegMain) $(RegMain:.dll=.odt)
	@echo .
	@$(ODSRC)\bin\NMakCpkg $(ODSRC)\dll $(FilesDlls)
	@$(ODSRC)\bin\NMakCpkg $(ODSRC)\include $(FilesIncs)
	@$(ODSRC)\bin\NMakCpkg $(ODSRC)\lib $(FilesLibs) $(FilesDefs) $(FilesExps)
!	IF "$(FilesCats)"!="" || "$(FilesHelps)"!=""
		@$(ODSRC)\bin\NMakCpkg $(ODSRC)\locale\$(NmakeLOCALE) $(FilesCats) $(FilesHelps)
!	ENDIF
	@$(ODSRC)\bin\NMakCpkg $(ODSRC)\work $(FilesStationery)
	@$(ODSRC)\bin\NMakCpkg . $(FilesTypeLibs)
	@echo Building: $@
	echo $(RegMain:.dll=.odt) > parts.lst
	$(ZIP) $(RegMain:.dll=.zip) parts.lst $(RegMain:.dll=.odt)
!	IF "$(FilesDlls)"!=""
	    @FOR %%f IN ($(FilesDlls)) DO \
		$(ZIP) $(RegMain:.dll=.zip) $(ODSRC)\dll\%%f
!	ENDIF
!	IF "$(FilesIncs)"!=""
	    @FOR %%f IN ($(FilesIncs)) DO \
		$(ZIP) $(RegMain:.dll=.zip) $(ODSRC)\include\%%f
!	ENDIF
!	IF "$(FilesLibs)"!=""
	    @FOR %%f IN ($(FilesLibs) $(FilesDefs) $(FilesExps)) DO \
		$(ZIP) $(RegMain:.dll=.zip) $(ODSRC)\lib\%%f
!	ENDIF
!	IF "$(FilesCats)"!="" || "$(FilesHelps)"!=""
	    @FOR %%f IN ($(FilesCats) $(FilesHelps)) DO \
		$(ZIP) $(RegMain:.dll=.zip) $(ODSRC)\locale\$(NmakeLOCALE)\%%f
!	ENDIF
!	IF "$(FilesStationery)"!=""
	    @FOR %%f IN ($(FilesStationery)) DO \
		$(ZIP) $(RegMain:.dll=.zip) $(ODSRC)\work\%%f
!	ENDIF
!	IF "$(FilesTypeLibs)"!=""
	    @FOR %%f IN ($(FilesTypeLibs)) DO \
		$(ZIP) $(RegMain:.dll=.zip) %%f
!	ENDIF
	$(ZIP2EXE)
	$(REMOVE) $(RegMain:.dll=.zip)
	IF EXIST $(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz) $(REMOVE) $(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz)
	move $(RegMain:.dll=.exe) $(ODSRC)\pkg\$(NmakeLOCALE)\$(RegMain:.dll=.odz)


$(RegMain:.dll=.odt) :
	@echo .
	@echo Building: $@
	echo IODPartPlatform=$(Platform) > $@
	echo IODPartLocale=$(NmakeLOCALE) >> $@
	echo IODPartFilesDlls=$(FilesDlls: =,) >> $@
	echo IODPartFilesIncs=$(FilesIncs: =,) >> $@

!	IF "$(FilesLibs)"!=""
		echo IODPartFilesLibs=$(FilesLibs: =,),$(FilesDefs: =,),$(FilesExps: =,) >> $@
!       ELSE
		echo IODPartFilesLibs= >> $@
!       ENDIF

	echo IODPartFilesCats=$(FilesCats: =,) >> $@
	echo IODPartFilesHelps=$(FilesHelps: =,) >> $@
	echo IODPartFilesStationery=$(FilesStationery: =,) >> $@

#       Put the optional parameter in only if the macro has been set
!       IF "$(FilesTypeLibs)"!=""
		echo IODPartFilesTypeLibs=$(FilesTypeLibs: =,) >> $@
!       ENDIF

	echo IODPartRegMain=$(RegMain) >> $@
	echo IODPartRegIDL=$(RegIDL: =,) >> $@
	echo IODPartRegClassName=$(RegClassName) >> $@
	echo IODPartRegKind=$(RegKind) >> $@

!ELSE
Pkg  :
	@echo No package to build.
!ENDIF



#..............................................................................
#                       Macros with associated rules
#..............................................................................


#
# The BuildCopyRule requires 2 macros be set:
#       Target = $@
#       Sources = $**
#
BuildCopyRule :
        $(COPY) $(Sources) $(Target:/=\)

# The following macro simplifies the recursive call to the BuildCopyRule
BuildCopy = $(MAKE) /nologo /$(MAKEFLAGS) "Sources = $**" "Target = $@" BuildCopyRule


#
# The BuildDefRule requires 3 macros be set:
#       Target = $@
#       BaseNamePartOfTarget = $(@B)
#       Sources = $**
#
BuildDefRule :
!	IFDEF CPPMAIN
	@echo .
        @echo Building: $(Target:/=\)
        @echo LIBRARY $(BaseNamePartOfTarget) > $(Target:/=\)
        @echo DESCRIPTION '$(BaseNamePartOfTarget).dll' >> $(Target:/=\)
        @echo EXPORTS >> $(Target:/=\)
        @FOR %%f IN ($(Sources)) DO cppfilt /B /P /Q /S %%f >> $(Target:/=\)
	@echo Leaving BuildDefRule
!	ENDIF

# The following macro simplifies the recursive call to the BuildDefRule
BuildDef = $(MAKE) /nologo /$(MAKEFLAGS) "Sources = $**" "Target = $@" "BaseNamePartOfTarget = $(@B)" BuildDefRule


#
# The BuildLibRule requires 3 macros be set:
#       Target = $@
#       BaseNamePartOfTarget = $(@B)
#       Sources = $**
#
BuildLibRule :
	@echo .
        @echo Building: $(Target)
	set PATH=$(NmakePATH)%%PATH%%
#	set LIB=$(NmakeLIB)%%LIB%%
	@echo .
	@echo 	$(StandardLibraryBuilder)$(Target)
        @echo 		$(Sources)
	@$(StandardLibraryBuilder)$(Target) @<<
 $(Sources)
<<
	@echo Leaving BuildLibRule

# The following macro simplifies the recursive call to the BuildLibRule
BuildLib = $(MAKE) /nologo /$(MAKEFLAGS) "Sources = $**" "Target = $(@:/=\)" "BaseNamePartOfTarget = $(@B)" BuildLibRule


#
# The BuildDllRule requires 2 macros be set:
#       Target = $@
#       Sources = $**
# In addition, there is 1 optional macro:
#       RecFile = the name of the resource file to be bound to the dll
#
BuildDllRule :
	@echo .
        @echo Building: $(Target)
	set PATH=$(NmakePATH)%%PATH%%
#	set LIB=$(NmakeLIB)%%LIB%%
	@echo 	$(LINKER) $(LOPTS) /DLL /OUT:$(Target) 
	@echo 		$(Sources) $(LocalRuntimeLibrary) $(RecFile)
	@echo 		$(LinkLibraries)
	@$(LINKER) $(LOPTS) /DLL /OUT:$(Target) @<<
 $(Sources) $(LocalRuntimeLibrary) $(RecFile)
 $(LinkLibraries)
<<
	@echo Leaving BuildDllRule

# The following macros simplify the recursive call to the BuildDllRule
BuildDll = $(MAKE) /nologo /$(MAKEFLAGS) "Sources = $**" "Target = $@" "LocalRuntimeLibrary=$(LocalRuntimeLibrary)" BuildDllRule

BuildDllWithRes = $(MAKE) /nologo /$(MAKEFLAGS) "Sources = $**" "Target = $@" "LocalRuntimeLibrary=$(LocalRuntimeLibrary)"




#..............................................................................
#			clean up rules
#..............................................................................


Cleans : Clean
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f Cleans
!   ENDIF

Clean : CleanHdr CleanIdl CleanLib CleanDll CleanPkg


CleanHdrs : CleanHdr
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f CleanHdrs
!   ENDIF

CleanHdr : CleanMsg
!	IF "$(HdrTargets)"!="" 
		@FOR %%f IN ($(HdrTargets)) DO IF EXIST $(IncludeDir)\%%f $(REMOVE) $(IncludeDir)\%%f
!	ENDIF
!	IF "$(IdlTargets)"!="" 
		@FOR %%f IN ($(IdlTargets:.idl=.xh)) DO IF EXIST $(IncludeDir)\%%f $(REMOVE) $(IncludeDir)\%%f
!	ENDIF
!       IF "$(RcTargets)"!=""
                @FOR %%f IN ($(RcTargets:.rc=.res)) DO IF EXIST %%f $(REMOVE) %%f
!       ENDIF


CleanMsg : $(MsgTargets)
!	IF "$(MsgTargets)"!="" 
		!IF EXIST $(**F) $(REMOVE) $(**F)
		!IF EXIST $(**B).h $(REMOVE) $(**B).h
                @FOR %%f IN ($(MsgTargets:/=\)) DO IF EXIST %%f $(REMOVE) %%f
!	ENDIF


CleanIdls : CleanIdl
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f CleanIdls
!   ENDIF

CleanIdl  : $(IdlTargets)
!	IF "$(IdlTargets)"!="" 
		!IF EXIST $(IncludeDir)\$** $(REMOVE) $(IncludeDir)\$**
!	ENDIF


WindowsLibTargets = $(LibTargets:/=\)

CleanLibs : CleanLib
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f CleanLibs
!   ENDIF

CleanLib :
!   IF "$(WindowsLibTargets)"!=""
	IF EXIST *.obj $(REMOVE) *.obj
	IF EXIST *.xih $(REMOVE) *.xih
	IF EXIST *.pdb $(REMOVE) *.pdb
	@FOR %%f IN ($(WindowsLibTargets)) DO IF EXIST %%f $(REMOVE) %%f
	@FOR %%f IN ($(WindowsLibTargets:.lib=.exp)) DO IF EXIST %%f $(REMOVE) %%f
	@FOR %%f IN ($(WindowsLibTargets:.lib=.def)) DO IF EXIST %%f $(REMOVE) %%f
!   ENDIF


WindowsDllTargets = $(DllTargets:/=\)

CleanDlls : CleanDll
!   IF "$(Subdirs)"!="" 
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f CleanDlls
!   ENDIF

CleanDll:
!   IF "$(WindowsDllTargets)"!=""
	@FOR %%f IN ($(WindowsDllTargets)) DO IF EXIST %%f $(REMOVE) %%f
	@FOR %%f IN ($(WindowsDllTargets:.dll=.pdb)) DO IF EXIST %%f $(REMOVE) %%f
!   ENDIF
!   IF "$(CtypelibIDL)"!=""
        IF EXIST $(CtypelibIDL:.idl=.tlb) $(REMOVE) $(CtypelibIDL:.idl=.tlb)
!   ENDIF


CleanPkgs : CleanPkg
!   IF "$(Subdirs)"!=""
	@set MAKEFLAGS=$(MAKEFLAGS) 
	@-FOR %%f IN ($(Subdirs)) DO call $(ODSRC)\bin\NMakSubd %%f CleanPkgs
!   ENDIF

CleanPkg: CleanPkgParts
!   IF "$(RegMain)"!=""
	@FOR %%f IN ($(LocaleList)) DO \
	    IF EXIST $(ODSRC)\pkg\%%f\$(RegMain:.dll=.odz) $(REMOVE) $(ODSRC)\pkg\%%f\$(RegMain:.dll=.odz)
!   ENDIF

CleanPkgParts:
!   IF "$(RegMain)"!=""
	IF EXIST $(RegMain:.dll=.odt) $(REMOVE) $(RegMain:.dll=.odt)
	IF EXIST $(RegMain:.dll=.ZIP) $(REMOVE) $(RegMain:.dll=.ZIP)
	IF EXIST $(RegMain:.dll=.EXE) $(REMOVE) $(RegMain:.dll=.EXE)
	IF EXIST parts.lst $(REMOVE) parts.lst
!   ENDIF


# end of file
