#  (C) COPYRIGHT International Business Machines Corp. 1998, 1999
#  All Rights Reserved.
#
#  US Government Users Restricted Rights - Use, duplication or
#  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.


# DB2 Universal Database Version 6.1
# makefile for Java sample programs  
# AIX, HP-UX, SCO UnixWare, SGI IRIX, Solaris and Linux operating systems

                         
# 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 alljdbc           - Builds the all JDBC supplied sample programs
#   make allsqlj           - Builds the all SQLJ supplied sample programs
#
#   make srv               - Builds the examples that implement
#                            stored procedures and UDFs (on the server)
#   make srvjdbcj          - Builds the JDBC examples that implement
#                            stored procedures and UDFs (on the server)
#   make srvsqlj           - Builds the SQLJ examples that implement
#                            stored procedures and UDFs (on the server)
#
#   make srvcli            - Builds the examples that call stored 
#                            procedures and UDFs ( they can run remotely )
#   make srvclijdbc        - Builds the JDBC examples that call stored 
#                            procedures and UDFs ( they can run remotely )
#   make srvclisqlj        - Builds the SQLJ examples that call stored 
#                            procedures and UDFs ( they can run remotely )
#
#   make othercli          - Builds the examples that will run successfully
#                            on a client platform ( others than srvcli )
#   make otherclijdbc      - Builds the JDBC examples that will run successfully
#                            on a client platform ( others than srvclijdbc )
#   make otherclisqlj      - Builds the SQLJ examples that will run successfully
#                            on a client platform ( others than srvclisqlj )
#
#   make allcli            - Builds programs in srvcli and othercli
#                            categories
#   make allclijdbc        - Builds programs in srvclijdbc and otherclijdbc
#                            categories
#   make allclisqlj        - Builds programs in srvclisqlj and otherclisqlj
#                            categories
#
#   make ord               - Builds the examples for the ORDER scenario 
#                            ( they are JDBC samples and can run remotely )
#
#   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 -- VARIABLES
#    2 -- MAKE CATEGORIES
#    3 -- COMMANDS TO MAKE INDIVIDUAL SAMPLES


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

# 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(= allcli + srv)
#              2b - make alljdbc(= allclijdbc + srvjdbcj)
#              2c - make allsqlj(= allclisqlj + srvsqlj)
#
#              2d - make srv(= srvjdbcj + srvsqlj)
#              2e - make srvjdbcj
#              2f - make srvsqlj
#
#              2g - make srvcli(= srvclijdbc + srvclisqlj)
#              2h - make srvclijdbc
#              2i - make srvclisqlj
#
#              2j - make othercli(= otherclijdbc + otherclisqlj)
#              2k - make otherclijdbc
#              2l - make otherclisqlj
#
#              2m - make allcli(= allclijdbc + allclisqlj)
#              2n - make allclijdbc(= srvclijdbc + otherclijdbc)
#              2o - make allclisqlj(= srvclisqlj + otherclisqlj)
#
#              2p - make ord   
#
#              2q - make clean
#              2r - make cleanall
#############################################################################

#****************************************************************************
#                  2a - make all(= allcli + srv)
#****************************************************************************

all : \
	srv \
        allcli

#****************************************************************************
#                  2b - make alljdbc(= allclijdbc + srvjdbcj)
#****************************************************************************

alljdbc : \
	allclijdbc \
	srvjdbcj

#****************************************************************************
#                  2c - make allsqlj(= allclisqlj + srvsqlj)
#****************************************************************************

allsqlj : \
	allclisqlj \
	srvsqlj

#****************************************************************************
#                  2d - make srv(= srvjdbcj + srvsqlj)
#****************************************************************************

srv : \
	srvjdbcj \
	srvsqlj

#****************************************************************************
#                  2e - make srvjdbcj
#****************************************************************************

srvjdbcj : \
	DB2Stp DB2Udf \
	Inpsrv \
	MRSPsrv \
	UDFsrv

#****************************************************************************
#                  2f - make srvsqlj
#****************************************************************************

srvsqlj : \
	Outsrv \
	Stp

#****************************************************************************
#                  2g - make srvcli(= srvclijdbc + srvclisqlj)
#****************************************************************************

srvcli : \
	srvclijdbc \
	srvclisqlj

#****************************************************************************
#                  2h - make srvclijdbc
#****************************************************************************

srvclijdbc : \
	DB2SpCli DB2UdCli \
	Inpcli \
	MRSPcli \
	Outcli \
	StpCli \
	UDFcli

#****************************************************************************
#                  2i - make srvclisqlj
#****************************************************************************

srvclisqlj : \
	RunUDFcli \
	UDFclie

#****************************************************************************
#                  2j - make othercli(= otherclijdbc + otherclisqlj)
#****************************************************************************

othercli : \
	otherclijdbc \
	otherclisqlj

#****************************************************************************
#                  2k - make otherclijdbc
#****************************************************************************

otherclijdbc : \
	BasicCon Browser \
	ColPriv Columns Create CustIn \
	DB2Appl DB2Applt DropJava Dynamic \
	Embedded \
	GetAttrs GetData \
	JavaSamp JobUpdat \
	LookRes \
	MultiCon \
	OrdIn OrdRep \
	PartRep PicIn Prepare ProcCols Procs ProdIn ProdPart \
	ShowPic Simple \
	Tables TypeInfo \
	UseThrds \
	Varinp

#****************************************************************************
#                  2l - make otherclisqlj
#****************************************************************************

otherclisqlj : \
	App Applt \
	Cursor \
	Openftch \
	Static \
	Updat
	
#****************************************************************************
#                  2m - make allcli(= allclijdbc + allclisqlj)
#****************************************************************************

allcli : \
	allclijdbc \
	allclisqlj

#****************************************************************************
#                  2n - make allclijdbc(= srvclijdbc + otherclijdbc)
#****************************************************************************

allclijdbc : \
	srvclijdbc \
	otherclijdbc

#****************************************************************************
#                  2o - make allclisqlj(= srvclisqlj + otherclisqlj)
#****************************************************************************

allclisqlj : \
	srvclisqlj \
	otherclisqlj

#****************************************************************************
#                  2p - make ord
#****************************************************************************
# Run he following samples in the this order
ord : \
	Create CustIn ProdIn ProdPart OrdIn OrdRep PartRep DropJava
	
#****************************************************************************
#                  2q - make clean
#****************************************************************************

clean :	
	$(ERASE) App.java Applt.java
	$(ERASE) Cursor.java 
	$(ERASE) Openftch.java OpF_Curs.java Outsrv.java
	$(ERASE) Static.java Stp.java 
	$(ERASE) Udf.java UDFclie.java Updat.java

#****************************************************************************
#                  2r - make cleanall
#****************************************************************************

cleanall : \
	clean
	$(ERASE) *.class *.ser

	$(ERASE) $(DB2PATH)/function/*.class
	$(ERASE) $(DB2PATH)/function/*.ser

#############################################################################
#  3 -- COMMANDS TO MAKE INDIVIDUAL SAMPLES
#                  3a -  JDBC, non client/server samples that do not use
#                        the class Tools
#                  3b -  JDBC, non client/server samples that use
#                        the class Tools
#                  3c -  SQLJ, non client/server samples
#                  3d -  client/server samples (mixed)
#                  3e -  applets (mixed)
#############################################################################



#****************************************************************************
#                  3a -  JDBC, non client/server samples that do not use
#                        the class Tools
#****************************************************************************

DB2Appl : 
	javac DB2Appl.java

Dynamic : 
	javac Dynamic.java

Varinp : 
	javac Varinp.java

#****************************************************************************
#                  3b -  JDBC, non client/server samples that use
#                        the class Tools
#****************************************************************************

Tools.class : 
	javac Tools.java

#---------------- the ORDER scenario-----------------------------------------
# run the next samples following this order:

Create : Tools.class
	javac Create.java

CustIn : Tools.class
	javac CustIn.java

ProdIn : Tools.class
	javac ProdIn.java

ProdPart : Tools.class
	javac ProdPart.java

OrdIn : Tools.class
	javac OrdIn.java

OrdRep : Tools.class
	javac OrdRep.java

PartRep : Tools.class
	javac PartRep.java

DropJava : Tools.class
	javac DropJava.java

#---------------- END of the ORDER scenario----------------------------------

#---------------- other samples in the category 3b --------------------------

BasicCon : Tools.class
	javac BasicCon.java

Browser : Tools.class
	javac Browser.java

ColPriv : Tools.class
	javac ColPriv.java

Columns : Tools.class
	javac Columns.java

Embedded : Tools.class
	javac Embedded.java

GetAttrs : Tools.class
	javac GetAttrs.java

GetData : Tools.class
	javac GetData.java

JavaSamp : Tools.class
	javac JavaSamp.java

JobUpdat : Tools.class
	javac JobUpdat.java

LookRes : Tools.class
	javac LookRes.java

MultiCon : Tools.class
	javac MultiCon.java

PicIn : Tools.class
	javac PicIn.java

Prepare : Tools.class
	javac Prepare.java

ProcCols : Tools.class
	javac ProcCols.java

Procs : Tools.class
	javac Procs.java

ShowPic : Tools.class
	javac ShowPic.java

Simple : Tools.class
	javac Simple.java

Tables : Tools.class
	javac Tables.java

TypeInfo : Tools.class
	javac TypeInfo.java

UseThrds : Tools.class
	javac UseThrds.java

#****************************************************************************
#                  3c -  SQLJ, non client/server samples
#****************************************************************************

App.class :
	sqlj App.sqlj 
App : App.class
	embprep App $(DB) $(UID) $(PWD)

Cursor.class :
	sqlj Cursor.sqlj 
Cursor : Cursor.class
	embprep Cursor $(DB) $(UID) $(PWD)

OpF_Curs.class :
	sqlj OpF_Curs.sqlj
Openftch.class :
	sqlj Openftch.sqlj 
Openftch : OpF_Curs.class Openftch.class 
	embprep Openftch $(DB) $(UID) $(PWD)

Static.class :
	sqlj Static.sqlj 
Static : Static.class
	embprep Static $(DB) $(UID) $(PWD)

Updat.class :
	sqlj Updat.sqlj 
Updat : Updat.class
	embprep Updat $(DB) $(UID) $(PWD)

#****************************************************************************
#                  3d -  client/server samples (mixed)   
#****************************************************************************

#--------------------DB2SpCli / DB2Stp--------------------------------------#

DB2SpCli : 
	javac DB2SpCli.java

DB2Stp : 
	javac DB2Stp.java
	$(ERASE) $(DB2PATH)/function/DB2Stp.class
	$(COPY) DB2Stp.class $(DB2PATH)/function/DB2Stp.class

#--------------------DB2UdCli / DB2Udf--------------------------------------#

DB2UdCli : 
	javac DB2UdCli.java

DB2Udf : 
	javac DB2Udf.java
	$(ERASE) $(DB2PATH)/function/DB2Udf.class
	$(COPY) DB2Udf.class $(DB2PATH)/function/DB2Udf.class

#--------------------Inpcli / Inpsrv----------------------------------------#

Inpcli : 
	javac Inpcli.java

Inpsrv : 
	javac Inpsrv.java
	$(ERASE) $(DB2PATH)/function/Inpsrv.class
	$(COPY) Inpsrv.class $(DB2PATH)/function/Inpsrv.class

#--------------------MRSPcli / MRSPsrv--------------------------------------#

MRSPcli : 
	javac MRSPcli.java

MRSPsrv : 
	javac MRSPsrv.java
	$(ERASE) $(DB2PATH)/function/MRSPsrv.class
	$(COPY) MRSPsrv.class $(DB2PATH)/function/MRSPsrv.class

#--------------------Outcli / Outsrv----------------------------------------#

Outcli :  
	javac Outcli.java

Outsrv.class :
	sqlj Outsrv.sqlj
Outsrv : Outsrv.class
	embprep Outsrv $(DB) $(UID) $(PWD)
	$(ERASE) $(DB2PATH)/function/Outsrv.class
	$(ERASE) $(DB2PATH)/function/Outsrv_Cursor1.class
	$(ERASE) $(DB2PATH)/function/Outsrv_SJProfileKeys.class
	$(ERASE) $(DB2PATH)/function/Outsrv_SJProfile0.ser
	$(COPY) Outsrv.class $(DB2PATH)/function
	$(COPY) Outsrv_Cursor1.class $(DB2PATH)/function
	$(COPY) Outsrv_SJProfileKeys.class $(DB2PATH)/function
	$(COPY) Outsrv_SJProfile0.ser $(DB2PATH)/function

#--------------------StpCli / Stp ------------------------------------------#

StpCli : 
	javac StpCli.java

Stp.class :
	sqlj Stp.sqlj
Stp : Stp.class
	embprep Stp $(DB) $(UID) $(PWD)
	$(ERASE) $(DB2PATH)/function/Stp.class
	$(ERASE) $(DB2PATH)/function/Stp_Cursor1.class
	$(ERASE) $(DB2PATH)/function/Stp_Cursor2.class
	$(ERASE) $(DB2PATH)/function/Stp_SJProfileKeys.class
	$(ERASE) $(DB2PATH)/function/Stp_SJProfile0.ser
	$(COPY) Stp.class $(DB2PATH)/function/Stp.class
	$(COPY) Stp_Cursor1.class $(DB2PATH)/function/Stp_Cursor1.class
	$(COPY) Stp_Cursor2.class $(DB2PATH)/function/Stp_Cursor2.class
	$(COPY) Stp_SJProfileKeys.class $(DB2PATH)/function/Stp_SJProfileKeys.class
	$(COPY) Stp_SJProfile0.ser $(DB2PATH)/function/Stp_SJProfile0.ser

#--------------------UDFcli + UDFclie / UDFsrv------------------------------#
# Before you can make UDFclie, you must run UDFcli once
# 'make all' includes RunUDFcli, which runs UDFcli before making UDFclie

UDFcli : 
	javac UDFcli.java

RunUDFcli : UDFcli
	java UDFcli $(UID) $(PWD)

UDFclie.class :
	sqlj UDFclie.sqlj 
UDFclie : UDFclie.class
	embprep UDFclie $(DB) $(UID) $(PWD)

UDFsrv :
	javac UDFsrv.java
	$(ERASE) $(DB2PATH)/function/UDFsrv.class
	$(ERASE) $(DB2PATH)/function/Person.class
	$(COPY) UDFsrv.class $(DB2PATH)/function
	$(COPY) Person.class $(DB2PATH)/function

#****************************************************************************
#                  3e -  applets (mixed)
#****************************************************************************

DB2Applt : 
	javac DB2Applt.java

Applt.class :
	sqlj Applt.sqlj 
Applt : Applt.class
	embprep Applt $(DB) $(UID) $(PWD)