# (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 -- HP-UX 11 operating system
# Enter one of the following commands
#
# make <app_name> - Builds the program designated by <app_name>
#
# make all - Builds the all the supplied sample programs
# make udfspserver - Builds the examples that implement
# stored procedures and UDFs (on the server)
# make localclient - Builds the examples that can only be run
# successfully on a server
# make udfspclient - Builds the examples that call stored
# procedures and UDFs ( they can run remotely )
# make otherremoteclient - Builds the examples that will run successfully
# on a client platform ( others than udfspclient )
# make allremoteclient - Builds programs in udfspclient and otherremoteclient
# categories
#
# make clean - Erases intermediate files
# make cleanall - Erases all files produced in the build process,
# except the original source files
# The makefile contains the following sections:
# 1 -- COMPILERS + VARIABLES
# 2 -- MAKE CATEGORIES
# 3 -- COMMANDS TO MAKE INDIVIDUAL SAMPLES
##################################################################################
# 1 -- COMPILERS + VARIABLES
##################################################################################
# This file assumes the DB2 instance path is defined by the variable HOME.
# It also assumes DB2 is installed under the DB2 instance.
# If these statements are not correct, update the variable DB2PATH.
DB2PATH = $(HOME)/sqllib
# This makefile assumes you are using the HP C++ compiler.
CC=aCC
# The required compiler flags...
CFLAGS=+DAportable -ext -Aa -I$(DB2PATH)/include
# Flags for compiling multi-threaded applications.
CFLAGSMT=+DAportable -ext -I$(DB2PATH)/include -D_HPUX_SOURCE -DRWSTD_MULTI_THREAD -D_REENTRANT +W829
# The linker for shared libraries
LINKSL=aCC +DAportable -b
# The required libraries...
LIBS=-L$(DB2PATH)/lib -ldb2
# Linked Libraries for creating UDFs.
LIBSUDF=-L$(DB2PATH)/lib -ldb2 -ldb2apie
# Linked Libraries for creating multi-threaded applications.
LIBSMT=-L$(DB2PATH)/lib -ldb2 -lpthread
# 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=cp
ERASE=rm -f
#############################################################################
# 2 -- MAKE CATEGORIES
# 2a - make all(= allremoteclient + localclient +udfspserver)
# 2b - make udfspserver
# 2c - make localclient
# 2d - make udfspclient
# 2e - make otherremoteclient
# 2f - make allremoteclient(= udfspclient + otherremoteclient)
# 2g - make clean
# 2h - make cleanall
#############################################################################
#****************************************************************************
# 2a - make all
#****************************************************************************
all : \
allremoteclient \
localclient \
udfspserver
#****************************************************************************
# 2b - make udfspserver
#****************************************************************************
udfspserver : \
udf spserver udfsrv
#****************************************************************************
# 2c - make localclient
#****************************************************************************
localclient : \
autocfg
#****************************************************************************
# 2d - make udfspclient
#****************************************************************************
udfspclient : \
calludf spclient udfcli
#****************************************************************************
# 2e - make otherremoteclient
#****************************************************************************
otherremoteclient : \
client cursor \
static \
thdsrver \
updat
#****************************************************************************
# 2f - make allremoteclient
#****************************************************************************
allremoteclient : \
udfspclient \
otherremoteclient
#****************************************************************************
# 2g - make clean
#****************************************************************************
clean : \
cleangen \
cleanemb
cleangen :
$(ERASE) *.o *.map
cleanemb :
$(ERASE) autocfg.C
$(ERASE) calludf.C cursor.C
$(ERASE) static.C
$(ERASE) thdsrver.C
$(ERASE) updat.C utilemb.C
$(ERASE) spclient.C spserver.C
$(ERASE) udfcli.C
#****************************************************************************
# 2h - make cleanall
#****************************************************************************
cleanall : \
clean
$(ERASE) *.bnd
$(ERASE) autocfg
$(ERASE) calludf client cursor
$(ERASE) static
$(ERASE) thdsrver
$(ERASE) updat udf udfcli udfsrv
$(ERASE) spclient spserver
$(ERASE) $(DB2PATH)/function/udf
$(ERASE) $(DB2PATH)/function/udfsrv
$(ERASE) $(DB2PATH)/function/spserver
#############################################################################
# 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)
# 3e - multi-threaded samples
#############################################################################
#****************************************************************************
# 3a - utilities
#****************************************************************************
utilapi.o : utilapi.C
$(CC) -c utilapi.C $(CFLAGS)
utilemb.C : utilemb.sqC
./embprep utilemb $(DB) $(UID) $(PWD)
utilemb.o : utilemb.C
$(CC) -c utilemb.C $(CFLAGS)
#****************************************************************************
# 3b - non embedded SQL, non client/server samples
#****************************************************************************
client : client.C utilapi.o
$(CC) -o client client.C utilapi.o $(CFLAGS) $(LIBS)
#****************************************************************************
# 3c - embedded SQL non client/server samples
#****************************************************************************
autocfg.C : autocfg.sqC
./embprep autocfg $(DB) $(UID) $(PWD)
autocfg : autocfg.C utilemb.o
$(CC) -o autocfg autocfg.C utilemb.o $(CFLAGS) $(LIBS)
cursor.C : cursor.sqC
./embprep cursor $(DB) $(UID) $(PWD)
cursor : cursor.C utilemb.o
$(CC) -o cursor cursor.C utilemb.o $(CFLAGS) $(LIBS)
static.C : static.sqC
./embprep static $(DB) $(UID) $(PWD)
static : static.C utilemb.o
$(CC) -o static static.C utilemb.o $(CFLAGS) $(LIBS)
updat.C : updat.sqC
./embprep updat $(DB) $(UID) $(PWD)
updat : updat.C utilemb.o
$(CC) -o updat updat.C utilemb.o $(CFLAGS) $(LIBS)
#****************************************************************************
# 3d - client/server samples (mixed)
#****************************************************************************
#--------------------calludf/udf--------------------------------------------#
calludf.C : calludf.sqC
./embprep calludf $(DB) $(UID) $(PWD)
calludf : calludf.C utilemb.o
$(CC) -o calludf calludf.C utilemb.o $(CFLAGS) $(LIBS)
udf : udf.c
$(CC) +z -c udf.c $(CFLAGS)
$(LINKSL) -o udf udf.o $(LIBSUDF)
$(ERASE) $(DB2PATH)/function/udf
$(COPY) udf $(DB2PATH)/function/udf
#-------------------- udfcli/udfsrv----------------------------------------#
udfcli.C : udfcli.sqC
./embprep udfcli $(DB) $(UID) $(PWD)
udfcli : udfcli.C utilemb.o
$(CC) -o udfcli udfcli.C utilemb.o $(CFLAGS) $(LIBS)
udfsrv : udfsrv.c
$(CC) +z -c udfsrv.c $(CFLAGS)
$(LINKSL) -o udfsrv udfsrv.o $(LIBSUDF)
$(ERASE) $(DB2PATH)/function/udfsrv
$(COPY) udfsrv $(DB2PATH)/function/udfsrv
#--------------------spclient/spserver--------------------------------------#
spclient.C : spclient.sqC
./embprep spclient $(DB) $(UID) $(PWD)
spclient : spclient.C utilemb.o
$(CC) -o spclient spclient.C utilemb.o $(CFLAGS) $(LIBS)
spserver.C : spserver.sqC
./embprep spserver $(DB) $(UID) $(PWD)
spserver : spserver.C
$(CC) +z -c spserver.C $(CFLAGS)
$(LINKSL) -o spserver spserver.o $(LIBS)
$(ERASE) $(DB2PATH)/function/spserver
$(COPY) spserver $(DB2PATH)/function/spserver
#****************************************************************************
# 3e - multi-threaded samples
#****************************************************************************
thdsrver.C : thdsrver.sqC
./embprep thdsrver $(DB) $(UID) $(PWD)
thdsrver : thdsrver.C
$(CC) -o thdsrver thdsrver.C $(CFLAGSMT) $(LIBSMT)