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


##################################################################################
#                  1 -- VARIABLES                                     
##################################################################################

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

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

all : \
	srv \
	allcli

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

alljdbc : \
	allclijdbc \
	srvjdbcj

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

allsqlj : \
	allclisqlj \
	srvsqlj

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

srv : \
	srvjdbcj \
	srvsqlj

#****************************************************************************
#                  2e - nmake srvjdbcj
#****************************************************************************

srvjdbcj : \
	V5Stp DB2Udf \
	MRSPsrv \
	Spserver \
	UDFsrv

#****************************************************************************
#                  2f - nmake srvsqlj
#****************************************************************************

srvsqlj : \
	Outsrv \
	Stserver

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

srvcli : \
	srvclijdbc \
	srvclisqlj

#****************************************************************************
#                  2h - nmake srvclijdbc
#****************************************************************************

srvclijdbc : \
	V5SpCli DB2UdCli \
	MRSPcli \
	Outcli \
	Spclient \
	UDFcli

#****************************************************************************
#                  2i - nmake srvclisqlj
#****************************************************************************

srvclisqlj : \
	RunUDFcli \
	Stclient \
	UDFclie

#****************************************************************************
#                  2j - nmake othercli(= oth_clijdbc + oth_clisqlj)
#****************************************************************************

othercli : \
	oth_clijdbc \
	oth_clisqlj

#****************************************************************************
#                  2k - nmake oth_clijdbc
#****************************************************************************

oth_clijdbc : \
	DB2Appl DB2Applt Dynamic \
	UseThrds \
	Varinp

#****************************************************************************
#                  2l - nmake oth_clisqlj
#****************************************************************************

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

allcli : \
	allclijdbc \
	allclisqlj

#****************************************************************************
#                  2n - nmake allclijdbc(= srvclijdbc + oth_clijdbc)
#****************************************************************************

allclijdbc : \
	srvclijdbc \
	oth_clijdbc

#****************************************************************************
#                  2o - nmake allclisqlj(= srvclisqlj + oth_clisqlj)
#****************************************************************************

allclisqlj : \
	srvclisqlj \
	oth_clisqlj

#****************************************************************************
#                  2p - nmake clean
#****************************************************************************

clean :	
	- $(ERASE) App.java Applt.java
	- $(ERASE) Cursor.java 
	- $(ERASE) Openftch.java OpF_Curs.java Outsrv.java
	- $(ERASE) Static.java Stclient.java Stserver.java StserverIterator.java
	- $(ERASE) Udf.java UDFclie.java Updat.java

#****************************************************************************
#                  2q - nmake cleanall
#****************************************************************************

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

	- $(ERASE) $(DB2PATH)\function\DB2Udf.class
	- $(ERASE) $(DB2PATH)\function\MRSPsrv.class
	- $(ERASE) $(DB2PATH)\function\Outsrv.class
	- $(ERASE) $(DB2PATH)\function\Outsrv_Cursor1.class
	- $(ERASE) $(DB2PATH)\function\Outsrv_SJProfileKeys.class
	- $(ERASE) $(DB2PATH)\function\Outsrv_SJProfile0.ser
	- $(ERASE) $(DB2PATH)\function\Person.class
	- $(ERASE) $(DB2PATH)\function\Spserver.class
	- $(ERASE) $(DB2PATH)\function\Stserver.class
	- $(ERASE) $(DB2PATH)\function\StserverEmployees.class
	- $(ERASE) $(DB2PATH)\function\StserverIterator.class
	- $(ERASE) $(DB2PATH)\function\StserverSalary.class
	- $(ERASE) $(DB2PATH)\function\Stserver_SJProfile0.ser
	- $(ERASE) $(DB2PATH)\function\Stserver_SJProfileKeys.class
	- $(ERASE) $(DB2PATH)\function\UDFsrv.class
	- $(ERASE) $(DB2PATH)\function\V5Stp.class

#############################################################################
#  3 -- COMMANDS TO MAKE INDIVIDUAL SAMPLES
#                  3a -  JDBC, non client/server samples
#                  3c -  SQLJ, non client/server samples
#                  3d -  client/server samples (mixed)
#                  3e -  applets (mixed)
#############################################################################

#****************************************************************************
#                  3a -  JDBC, non client/server samples 
#****************************************************************************

DB2Appl : DB2Appl.java
	javac DB2Appl.java

Dynamic : Dynamic.java
	javac Dynamic.java

UseThrds : UseThrds.java
	javac UseThrds.java

Varinp : Varinp.java
	javac Varinp.java

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

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

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

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

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

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

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

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

DB2UdCli : DB2UdCli.java
	javac DB2UdCli.java

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

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

MRSPcli : MRSPcli.java
	javac MRSPcli.java

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

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

Outcli : Outcli.java
	javac Outcli.java

Outsrv.class : Outsrv.sqlj
	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

#--------------------Spclient / Spserver------------------------------------#
# Note: before you execute Spclient for the first time, you must call the
# Spcreate.db2 CLP script to catalog the methods in Spserver as stored
# procedures

Spclient : Spclient.java
	javac Spclient.java

Spserver : Spserver.java
	javac Spserver.java
	- $(ERASE) $(DB2PATH)\function\Spserver.class
	$(COPY) Spserver.class $(DB2PATH)\function

#--------------------Stclient / Stserver------------------------------------#
# Note: before you execute Stclient for the first time, you must call the
# Stcreate.db2 CLP script to catalog the methods in Spserver as stored
# procedures

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

StserverIterator.class : StserverIterator.sqlj
	sqlj StserverIterator.sqlj
Stserver.class : Stserver.sqlj StserverIterator.class
	sqlj Stserver.sqlj
Stserver : StserverIterator.class Stserver.class
	embprep Stserver $(DB) $(UID) $(PWD)
	- $(ERASE) $(DB2PATH)\function\Stserver.class
	- $(ERASE) $(DB2PATH)\function\StserverEmployees.class
	- $(ERASE) $(DB2PATH)\function\StserverIterator.class
	- $(ERASE) $(DB2PATH)\function\StserverSalary.class
	- $(ERASE) $(DB2PATH)\function\Stserver_SJProfileKeys.class
	- $(ERASE) $(DB2PATH)\function\Stserver_SJProfile0.ser
	$(COPY) Stserver.class $(DB2PATH)\function
	$(COPY) StserverEmployees.class $(DB2PATH)\function
	$(COPY) StserverIterator.class $(DB2PATH)\function
	$(COPY) StserverSalary.class $(DB2PATH)\function
	$(COPY) Stserver_SJProfileKeys.class $(DB2PATH)\function
	$(COPY) Stserver_SJProfile0.ser $(DB2PATH)\function


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

UDFcli : UDFcli.java
	javac UDFcli.java

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

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

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

#--------------------V5SpCli / V5Stp--------------------------------------#

V5SpCli : V5SpCli.java
	javac V5SpCli.java

V5Stp : V5Stp.java 
	javac V5Stp.java
	- $(ERASE) $(DB2PATH)\function\V5Stp.class
	$(COPY) V5Stp.class $(DB2PATH)\function

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

DB2Applt : DB2Applt.java
	javac DB2Applt.java

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