# (C) COPYRIGHT International Business Machines Corp. 1995, 2000
# All Rights Reserved.
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
# makefile for DB2 Universal Database
# C++ sample programs -- Windows 32-bit operating systems
# Enter one of the following commands
#
# nmake <app_name> - Builds the program designated by <app_name>
#
# nmake all - Builds the all the supplied sample programs
# nmake udfspserver - Builds the examples that implement
# stored procedures and UDFs (on the server)
# nmake localclient - Builds the examples that can only be run
# successfully on a server
# nmake udfspclient - Builds the examples that call stored
# procedures and UDFs ( they can run remotely )
# nmake otherremoteclient - Builds the examples that will run successfully
# on a client platform ( others than udfspclient )
# nmake allremoteclient - Builds programs in udfspclient and otherremoteclient
# categories
#
# nmake clean - Erases intermediate files
# nmake cleanall - Erases all files produced in the build process,
# except the original source files
# The nmakefile contains the following sections:
# 1 -- COMPILERS + VARIABLES
# 2 -- MAKE CATEGORIES
# 3 -- COMMANDS TO MAKE INDIVIDUAL SAMPLES
##################################################################################
# 1 -- COMPILERS + VARIABLES
##################################################################################
# Note: The default compiler options are set for the Microsoft Visual C++
# compiler. If you use the IBM VisualAge C++ compiler, remove the
# "COMPILER=MS" below and uncomment "COMPILER=IBM" that follows.
# Set Compiler
COMPILER=MS
# COMPILER=IBM
!IF "$(COMPILER)" == "MS"
# Microsoft Visual C++ compiler
CC=cl
LINK=link
# Compile and link options.
CFLAGS=-Z7 -Od -c -W2 -D_X86_=1 -DWIN32 -I"$(DB2PATH)\include"
CFLAGSSRV=-Z7 -Od -c -W2 -D_X86_=1 -DWIN32 -I"$(DB2PATH)\include"
LFLAGS=-debug:full -debugtype:cv
LFLAGSSRV=-debug:full -debugtype:cv -dll
!ENDIF
!IF "$(COMPILER)" == "IBM"
# IBM VisualAge C++ compiler
CC=icc
LINK=ilink
CFLAGS=-c -Ti -W1
CFLAGSSRV=-c+ -Ti -Ge- -Gm+ -W1
LFLAGS=/MAP /DEBUG /ST:64000 /PM:VIO
LFLAGSSRV=/MAP /DEBUG /ST:64000 /PM:VIO /DLL
!ENDIF
LIBS="$(DB2PATH)\lib\db2api.lib"
LIBSUDF="$(DB2PATH)\lib\db2api.lib" "$(DB2PATH)\lib\db2apie.lib"
# To connect to a remote SAMPLE database cataloged on the client machine
# with another name, update the DB variable.
DB=sample
# Set UID and PWD if neccesary
UID=
PWD=
COPY=copy
ERASE=del
#############################################################################
# 2 -- MAKE CATEGORIES
# 2a - nmake all(= allremoteclient + localclient +udfspserver)
# 2b - nmake udfspserver
# 2c - nmake localclient
# 2d - nmake udfspclient
# 2e - nmake otherremoteclient
# 2f - nmake allremoteclient(= udfspclient + otherremoteclient)
# 2g - nmake clean
# 2h - nmake cleanall
#############################################################################
#****************************************************************************
# 2a - nmake all
#****************************************************************************
all : \
allremoteclient \
localclient \
udfspserver
#****************************************************************************
# 2b - nmake udfspserver
#****************************************************************************
udfspserver : \
spserver \
udf udfsrv
#****************************************************************************
# 2c - nmake localclient
#****************************************************************************
localclient : \
autocfg
#****************************************************************************
# 2d - nmake udfspclient
#****************************************************************************
udfspclient : \
calludf \
spclient udfcli
#****************************************************************************
# 2e - nmake otherremoteclient
#****************************************************************************
otherremoteclient : \
client cursor \
static \
updat
#****************************************************************************
# 2f - nmake allremoteclient
#****************************************************************************
allremoteclient : \
udfspclient \
otherremoteclient
#****************************************************************************
# 2g - nmake clean
#****************************************************************************
clean : \
cleangen \
cleanemb \
cleanclisrv
cleangen :
$(ERASE) *.obj *.ilk *.pdb *.map *.lib *.txt
cleanemb :
$(ERASE) autocfg.cxx
$(ERASE) cursor.cxx
$(ERASE) static.cxx
$(ERASE) updat.cxx
$(ERASE) utilemb.cxx
cleanclisrv :
$(ERASE) calludf.cxx
$(ERASE) udf.exp
$(ERASE) udfcli.cxx
$(ERASE) udfsrv.exp
$(ERASE) spclient.cxx
$(ERASE) spserver.cxx
$(ERASE) spserver.exp
$(ERASE) *.dll
#****************************************************************************
# 2h - nmake cleanall
#****************************************************************************
cleanall : \
clean
$(ERASE) *.bnd *.exe
$(ERASE) "$(DB2PATH)\function\udf.dll"
$(ERASE) "$(DB2PATH)\function\udfsrv.dll"
$(ERASE) "$(DB2PATH)\function\spserver.dll"
#############################################################################
# 3 -- COMMANDS TO MAKE INDIVIDUAL SAMPLES
# 3a - utilities
# 3b - non embedded SQL, non client/server samples
# 3c - embedded SQL, non client/server samples
# 3d - client/server samples (mixed)
#############################################################################
#****************************************************************************
# 3a - utilities
#****************************************************************************
utilapi.obj : utilapi.cxx
$(CC) $(CFLAGS) utilapi.cxx
utilemb.cxx : utilemb.sqx
embprep utilemb $(DB) $(UID) $(PWD)
utilemb.obj : utilemb.cxx
$(CC) $(CFLAGS) utilemb.cxx
#****************************************************************************
# 3b - non embedded SQL, non client/server samples
#****************************************************************************
client.obj : client.cxx
$(CC) $(CFLAGS) client.cxx
client : client.obj utilapi.obj
$(LINK) $(LFLAGS) -out:client.exe client.obj utilapi.obj $(LIBS)
#****************************************************************************
# 3c - embedded SQL non client/server samples
#****************************************************************************
autocfg.cxx : autocfg.sqx
embprep autocfg $(DB) $(UID) $(PWD)
autocfg.obj : autocfg.cxx
$(CC) $(CFLAGS) autocfg.cxx
autocfg : autocfg.obj utilemb.obj
$(LINK) $(LFLAGS) -out:autocfg.exe autocfg.obj utilemb.obj $(LIBS)
cursor.cxx : cursor.sqx
embprep cursor $(DB) $(UID) $(PWD)
cursor.obj : cursor.cxx
$(CC) $(CFLAGS) cursor.cxx
cursor : cursor.obj utilemb.obj
$(LINK) $(LFLAGS) -out:cursor.exe cursor.obj utilemb.obj $(LIBS)
static.cxx : static.sqx
embprep static $(DB) $(UID) $(PWD)
static.obj : static.cxx
$(CC) $(CFLAGS) static.cxx
static : static.obj utilemb.obj
$(LINK) $(LFLAGS) -out:static.exe static.obj utilemb.obj $(LIBS)
updat.cxx : updat.sqx
embprep updat $(DB) $(UID) $(PWD)
updat.obj : updat.cxx
$(CC) $(CFLAGS) updat.cxx
updat : updat.obj utilemb.obj
$(LINK) $(LFLAGS) -out:updat.exe updat.obj utilemb.obj $(LIBS)
#****************************************************************************
# 3d - client/server samples (mixed)
#****************************************************************************
#--------------------calludf/udf--------------------------------------------#
calludf.cxx : calludf.sqx
embprep calludf $(DB) $(UID) $(PWD)
calludf.obj : calludf.cxx
$(CC) $(CFLAGS) calludf.cxx
calludf : calludf.obj utilemb.obj
$(LINK) $(LFLAGS) -out:calludf.exe calludf.obj utilemb.obj $(LIBS)
udf.obj : udf.c
$(CC) $(CFLAGSSRV) udf.c
udf : udf.obj
!IF "$(COMPILER)" == "MS"
$(LINK) $(LFLAGSSRV) -out:udf.dll udf.obj $(LIBSUDF) -def:udf.def
!ELSE
ilib /GI udfva.def
$(LINK) $(LFLAGSSRV) udf.obj udf.exp $(LIBSUDF)
!ENDIF
copy udf.dll "$(DB2PATH)\function"
#-------------------- udfcli/udfsrv--------------------------------------------#
udfcli.cxx : udfcli.sqx
embprep udfcli $(DB) $(UID) $(PWD)
udfcli.obj : udfcli.cxx
$(CC) $(CFLAGS) udfcli.cxx
udfcli : udfcli.obj utilemb.obj
$(LINK) $(LFLAGS) -out:udfcli.exe udfcli.obj utilemb.obj $(LIBS)
udfsrv.obj : udfsrv.c
$(CC) $(CFLAGSSRV) udfsrv.c
udfsrv : udfsrv.obj
!IF "$(COMPILER)" == "MS"
$(LINK) $(LFLAGSSRV) -out:udfsrv.dll udfsrv.obj -def:udfsrv.def
!ELSE
ilib /GI udfsrvva.def
$(LINK) $(LFLAGSSRV) -out:udfsrv.dll udfsrv.obj udfsrv.exp $(LIBSAPI)
!ENDIF
$(COPY) udfsrv.dll "$(DB2PATH)\function"
#--------------------spclient/spserver---------------------------------------#
spclient.cxx : spclient.sqx
embprep spclient $(DB) $(UID) $(PWD)
spclient.obj : spclient.cxx
$(CC) $(CFLAGS) spclient.cxx
spclient : spclient.obj utilemb.obj
$(LINK) $(LFLAGS) -out:spclient.exe spclient.obj utilemb.obj $(LIBS)
spserver.cxx : spserver.sqx
embprep spserver $(DB) $(UID) $(PWD)
spserver.obj : spserver.cxx
$(CC) $(CFLAGSSRV) spserver.cxx
spserver : spserver.obj
!IF "$(COMPILER)" == "MS"
$(LINK) $(LFLAGSSRV) -out:spserver.dll spserver.obj $(LIBS) -def:spserver.def
!ELSE
ilib /GI spserverva.def
$(LINK) $(LFLAGSSRV) -out:spserver.dll spserver.obj spserver.exp $(LIBS)
!ENDIF
$(COPY) spserver.dll "$(DB2PATH)\function"