#  (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 -- OS/2 operating system
                         

# 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                                     
##################################################################################

# Compiler and linker definitions for IBM VisualAge C++ compiler.

COMPILER=IBM
CC=icc

CFLAGS=-C+ -O- -Ti+
CFLAGSSRV=-C+ -Ti+ -Ge- -Gm+ -W2

LINK=ilink 

LFLAGS=/NOFREE /NOI /DEBUG /ST:64000 /PM:VIO
LFLAGSSRV=/NOFREE /NOI /DEBUG /ST:64000 /PM:VIO /MAP

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 *.map *.lib *.dll

cleanemb :
	- $(ERASE) autocfg.cxx
	- $(ERASE) cursor.cxx
	- $(ERASE) static.cxx
	- $(ERASE) updat.cxx
	- $(ERASE) utilemb.cxx

cleanclisrv :
	- $(ERASE) calludf.cxx
	- $(ERASE) udfcli.cxx

	- $(ERASE) spclient.cxx
	- $(ERASE) spserver.cxx


#****************************************************************************
#                  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) client.obj utilapi.obj, client.exe,,$(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) autocfg.obj utilemb.obj, autocfg.exe,, $(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) cursor.obj utilemb.obj, cursor.exe,,$(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) static.obj utilemb.obj, static.exe,,$(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) updat.obj utilemb.obj, updat.exe,,$(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) calludf.obj utilemb.obj, calludf.exe,,$(LIBS);

udf.obj : udf.c
	$(CC) $(CFLAGSSRV) udf.c
udf     : udf.obj
	$(LINK) $(LFLAGSSRV) udf.obj,udf.dll,,$(LIBSUDF),udf.def;
	$(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) udfcli.obj utilemb.obj, udfcli.exe,, $(LIBS);

udfsrv.obj : udfsrv.c
	$(CC) $(CFLAGSSRV) udfsrv.c
udfsrv     : udfsrv.obj
	$(LINK) $(LFLAGSSRV) udfsrv.obj,udfsrv.dll,,$(LIBSUDF),udfsrv.def;
	$(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) spclient.obj utilemb.obj,spclient.exe,, $(LIBS);

spserver.cxx : spserver.sqx
	embprep spserver $(DB) $(UID) $(PWD)
spserver.obj : spserver.cxx 
	$(CC) $(CFLAGSSRV) spserver.cxx
spserver : spserver.obj
	$(LINK) $(LFLAGSSRV) spserver.obj,spserver.dll,,$(LIBSUDF), spserver.def;
	$(COPY) spserver.dll $(DB2PATH)\function