# ============================================================================
# OLE 2.0 Sample Code
#
# makefile
#
# (c) Copyright Microsoft Corp. 1992 All Rights Reserved
#
# Makefile : Builds the OLE 2.0 Outline series sample apps
#        The Outline series includes:
#           Outline.exe  -- base version of app (w/o OLE functionality)
#           SvrOutl.exe  -- OLE 2.0 Server sample app
#           CntrOutl.exe -- OLE 2.0 Containter (Container) sample app
#           ISvrOtl.exe  -- OLE 2.0 In-Place Server sample app
#           ICntrOtl.exe -- OLE 2.0 In-Place Containter (Container) sample app
#        NOTE: apps are built in a subdir of same name as app.
#
# Usage:     NMAKE              (build outline.exe--non-OLE version)
#    or:     NMAKE APP=svroutl  (build svroutl.exe--server-only version)
#    or:     NMAKE APP=cntroutl (build cntroutl.exe--container-only version)
#    or:     NMAKE APP=isvrotl  (build isvrotl.exe--InPlace server version)
#    or:     NMAKE APP=icntrotl (build icntrotl.exe--InPlace container ver.)
#    or:     NMAKE clean        (erase all compiled files in $(APP) dir)
#    or:     NMAKE install      (copy $(APP).exe to $(SAMPBIN_DIR) dir)
#
# eg.:  nmake APP=cntroutl clean    (deletes compiled files in .\cntroutl )
#       nmake APP=svroutl install   (copies svroutl\svroutl.exe to
#                                       $(SAMPBIN_DIR) )
#       nmake                       (builds outline\outline.exe)
#       nmake install               (copies outline\outline.exe to
#                                       $(SAMPBIN_DIR) )
# Environment Variables:
#   SAMPBIN_DIR             --  Directory to install built .EXE file
#                               (Default: \ole2\samp\bin)
# ============================================================================

!if "$(app)" == "svroutl"
APP = svroutl
!elseif "$(app)" == "cntroutl"
APP = cntroutl
!elseif "$(app)" == "icntrotl"
APP = icntrotl
!elseif "$(app)" == "isvrotl"
APP = isvrotl
!elseif "$(app)" == "outline"
APP = outline
!else
APP = outline
!endif

SRC_DIR   = ..
BUILD_DIR = $(APP)

!ifndef SAMPBIN_DIR
SAMPBIN_DIR=..\bin
!endif

PCHFLAGS  = /Yuoutline.h /Fpprecomp.pch
CPPFLAGS  = /f /AM /GA /W3 /Zp /G2 /nologo /D_DEBUG /Od /Zi
LINKFLAGS = /NOD /NOE /ONERROR:NOEXE /CO /MAP:FULL /LINE /BATCH /STACK:10240
LIBS      = libw shell ole2 storage compobj ..\..\lib\outlui commdlg mlibcew \
	..\..\lib\gizmobar ..\..\lib\bttncur ..\..\lib\ctl3d

COMMONINCL =$(SRC_DIR)\outline.h $(SRC_DIR)\frametls.h \
	..\..\include\bttncur.h ..\..\include\gizmobar.h \
	$(SRC_DIR)\outlrc.h $(SRC_DIR)\status.h $(SRC_DIR)\cntroutl.h  \
	$(SRC_DIR)\cntrrc.h $(SRC_DIR)\svroutl.h $(SRC_DIR)\oleoutl.h

!if "$(USE_MSGFILTER)"=="1"
CPPFLAGS  = $(CPPFLAGS) /DUSE_MSGFILTER
!endif

##########################################################################
#
# main obj lists; add new obj files here
#

!if "$(APP)" == "cntroutl"
CPPFLAGS = $(CPPFLAGS) /DOLE_CNTR
APP_OBJS = precomp.obj main.obj memmgr.obj status.obj frametls.obj \
	   dialogs.obj debug.obj \
	   outlapp.obj outldoc.obj heading.obj \
	   outllist.obj outlline.obj outltxtl.obj \
	   outlntbl.obj outlname.obj \
	   oleapp.obj oledoc.obj classfac.obj debug2.obj \
	   dragdrop.obj clipbrd.obj linking.obj \
	   cntrbase.obj cntrline.obj
!elseif "$(APP)" == "svroutl"
CPPFLAGS = $(CPPFLAGS) /DOLE_SERVER
APP_OBJS = precomp.obj main.obj memmgr.obj status.obj frametls.obj \
	   dialogs.obj debug.obj \
	   outlapp.obj outldoc.obj heading.obj \
	   outllist.obj outlline.obj outltxtl.obj \
	   outlntbl.obj outlname.obj \
	   oleapp.obj oledoc.obj classfac.obj debug2.obj \
	   dragdrop.obj clipbrd.obj linking.obj \
	   svrbase.obj svrpsobj.obj
!elseif "$(APP)" == "icntrotl"
CPPFLAGS = $(CPPFLAGS) /DOLE_CNTR /DINPLACE_CNTR
APP_OBJS = precomp.obj main.obj memmgr.obj status.obj frametls.obj \
	   dialogs.obj debug.obj \
	   outlapp.obj outldoc.obj heading.obj \
	   outllist.obj outlline.obj outltxtl.obj \
	   outlntbl.obj outlname.obj \
	   oleapp.obj oledoc.obj classfac.obj debug2.obj \
	   dragdrop.obj clipbrd.obj linking.obj \
	   cntrbase.obj cntrline.obj cntrinpl.obj
!elseif "$(APP)" == "isvrotl"
CPPFLAGS = $(CPPFLAGS) /DOLE_SERVER /DINPLACE_SVR
APP_OBJS = precomp.obj main.obj memmgr.obj status.obj frametls.obj \
	   dialogs.obj debug.obj \
	   outlapp.obj outldoc.obj heading.obj \
	   outllist.obj outlline.obj outltxtl.obj \
	   outlntbl.obj outlname.obj \
	   oleapp.obj oledoc.obj classfac.obj debug2.obj \
	   dragdrop.obj clipbrd.obj linking.obj \
	   svrbase.obj svrpsobj.obj svrinpl.obj
!else
APP_OBJS = precomp.obj main.obj memmgr.obj status.obj frametls.obj \
	   dialogs.obj debug.obj \
	   outlapp.obj outldoc.obj heading.obj \
	   outllist.obj outlline.obj outltxtl.obj debug2.obj \
	   outlntbl.obj outlname.obj
!endif

##########################################################################
#
# overall goal; cd to build dir; build application; return to src dir
#
goal: cd_build $(APP).exe

cd_build:
	cd $(BUILD_DIR)

##########################################################################
#
# create precomiled header
#
precomp.obj : $(SRC_DIR)\precomp.c $(COMMONINCL)
	@echo Precompiling outline.h ...
	$(CPP) $(CPPFLAGS) /c /Ycoutline.h /Fpprecomp.pch /Foprecomp $(SRC_DIR)\precomp.c

##########################################################################
#
# link/res commands

$(APP).exe: $(APP_OBJS) $(SRC_DIR)\$(APP).def $(APP).res
	@echo Linking $@...
	link @<<
$(LINKFLAGS) +
$(APP_OBJS: = +^
)
$@
$(APP).map
$(LIBS)
$(SRC_DIR)\$(APP).def
<<
	mapsym $(APP).map
	@echo Adding resources to $@...
	rc /k /t /I$(SRC_DIR) $(RCFLAGS) $*.res $@

$(APP).res: $(SRC_DIR)\$(APP).rc $(SRC_DIR)\outlrc.h $(SRC_DIR)\cntrrc.h \
	$(SRC_DIR)\dialogs.dlg $(SRC_DIR)\debug.rc
	@echo Compiling resources...
	rc /r /I$(SRC_DIR) $(RCFLAGS) /fo$@ $(SRC_DIR)\$(APP).rc

##########################################################################
#
# build rules for src directory
#

{$(SRC_DIR)}.c{}.obj:
	$(CPP) $(CPPFLAGS) $(PCHFLAGS) /c $<

##########################################################################
#
# clean (erase) generated files

clean:
	if exist $(BUILD_DIR)\*.obj erase $(BUILD_DIR)\*.obj
	if exist $(BUILD_DIR)\$(APP).res erase $(BUILD_DIR)\$(APP).res
	if exist $(BUILD_DIR)\$(APP).exe erase $(BUILD_DIR)\$(APP).exe
	if exist $(BUILD_DIR)\$(APP).sym erase $(BUILD_DIR)\$(APP).sym
	if exist $(BUILD_DIR)\$(APP).map erase $(BUILD_DIR)\$(APP).map
	if exist $(BUILD_DIR)\$(APP).lnk erase $(BUILD_DIR)\$(APP).lnk

##########################################################################
#
# install built exe to $(SAMPBIN_DIR) dir

install:
	copy $(BUILD_DIR)\$(APP).exe $(SAMPBIN_DIR)
	copy $(BUILD_DIR)\$(APP).sym $(SAMPBIN_DIR)

#########################################################
# Dependencies
#########################################################

main.obj : $(COMMONINCL)

outlapp.obj : $(COMMONINCL)

outldoc.obj : $(COMMONINCL)

outllist.obj : $(COMMONINCL)

outlline.obj : $(COMMONINCL)

outltxtl.obj : $(COMMONINCL)

outlntbl.obj : $(COMMONINCL)

outlname.obj : $(COMMONINCL)

classfac.obj : $(COMMONINCL)

oleapp.obj : $(COMMONINCL)

oledoc.obj : $(COMMONINCL)

dragdrop.obj : $(COMMONINCL)

clipbrd.obj : $(COMMONINCL) ..\..\include\enumfetc.h

linking.obj : $(COMMONINCL)

cntrbase.obj : $(COMMONINCL)

cntrline.obj : $(COMMONINCL)

cntrinpl.obj : $(COMMONINCL)

svrpsobj.obj : $(COMMONINCL)

svrinpl.obj : $(COMMONINCL)

svrbase.obj : $(COMMONINCL)

status.obj : $(COMMONINCL) $(SRC_DIR)\message.h $(SRC_DIR)\status.h

frametls.obj : $(COMMONINCL)

heading.obj : $(COMMONINCL)

dialogs.obj : $(COMMONINCL)

debug.obj : $(COMMONINCL) ..\..\include\msgfiltr.h

debug2.obj : $(COMMONINCL)
