##############################################################################
#
#  (c) Copyright Microsoft Corp. 1992-1993 All Rights Reserved
#
#  File:
#
#    makefile - makefile for spoly2.exe
#
#  Purpose:
#
#    Builds the OLE 2.0 sample IDispatch server, dispcalc.exe.
#
#
#  Usage:
#
#     NMAKE                 ; build with defaults
#     or: NMAKE option      ; build with the given option(s)
#     or: NMAKE clean       ; erase all compiled files
#
#     option:
#       DEBUG=[0|1]         ; DEBUG=1 is the default
#
#
#  Notes:
#
#    This makefile assumes that the PATH, INCLUDE and LIB environment
#    variables are setup properly.
#
##############################################################################

##########################################################################
#
# Default Settings
#

!if "$(DEBUG)" == ""
DEBUG = 1
!endif

##########################################################################
#
# WIN16 Settings
#

CC   = cl
LINK = link

RCFLAGS = /DWIN16
CFLAGS = /W3 /AM /GA /GEs /DWIN16
LINKFLAGS = /NOD /NOI /BATCH /ONERROR:NOEXE /STACK:10240

LIBS = libw.lib mlibcew.lib

!if "$(DEBUG)" == "1"
CFLAGS = $(CFLAGS) /Od /Zi /D_DEBUG
LINKFLAGS = $(LINKFLAGS) /COD
!else
CFLAGS = $(CFLAGS) /Ox
LINKFLAGS = $(LINKFLAGS) /FAR /PACKC
!endif

##########################################################################
#
# Build rules
#

.cpp.obj:
	$(CC) $(CFLAGS) /c $<

.c.obj:
	$(CC) $(CFLAGS) /c $<


##########################################################################
#
# Application Settings
#

APPS = dispcalc

LIBS = ole2.lib compobj.lib ole2disp.lib $(LIBS)

OBJS = \
	winmain.obj \
	idata.obj   \
	dispcalc.obj    \
	clsid.obj

##########################################################################
#
# Default Goal
#

goal : $(APPS).exe

##########################################################################
#
# Clean (erase) generated files
#
clean :
	if exist *.obj       del *.obj
	if exist $(APPS).exe del $(APPS).exe
	if exist $(APPS).map del $(APPS).map
	if exist $(APPS).res del $(APPS).res
	if exist $(APPS).rs  del $(APPS).rs


##########################################################################
#
# Application Build (WIN16 Specific)
#

$(APPS).exe : $(OBJS) $(APPS).def $(APPS).res $(APPS).ico
	link $(LINKFLAGS) @<<
$(OBJS),
$@,,
$(LIBS),
$(APPS).def
<<
	rc /k /t $(APPS).res $@

##########################################################################
#
# Application Build (Common)
#

$(APPS).res : $(APPS).rc
	rc  $(RCFLAGS) /r /fo$@ $?

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

winmain.obj: winmain.cpp dispcalc.h

idata.obj: idata.cpp dispcalc.h

dispcalc.obj: dispcalc.cpp dispcalc.h

clsid.obj: clsid.c clsid.h
