44# Makefile for Java JDBC interface
55#
66# IDENTIFICATION
7- # $Id: Makefile,v 1.24 2000/09 /1204:58:46 momjian Exp $
7+ # $Id: Makefile,v 1.25 2000/10 /1208:55:23 peter Exp $
88#
99# -------------------------------------------------------------------------
1010
11+ subdir = src/interfaces
12+ top_builddir = ../../..
13+ include $(top_builddir ) /src/Makefile.global
14+
15+ CP = cp
1116FIND = find
1217IDL2JAVA = idltojava -fno-cpp -fno-tie
1318JAR = jar
@@ -17,6 +22,9 @@ JAVADOC= javadoc
1722RM = rm -f
1823TOUCH = touch
1924
25+ BUILDDRIVER = sh utils/buildDriver
26+ CHANGELOG = perl utils/changelog.pl
27+
2028# This defines how to compile a java class
2129.java.class :
2230$(JAVAC ) $<
@@ -28,25 +36,39 @@ TOUCH= touch
2836# postgresql to org/postgresql
2937PGBASE = org/postgresql
3038
39+ # New for 7.1: The jar filename
40+ JARFILE = postgresql.jar
41+
42+ # Yet another attempt to check the version. In theory, any JVM that fails
43+ # this is breaking the versioning specifications released by Javasoft.
44+ #
45+ all :utils/CheckVersion.class
46+ @$(MAKE ) ` $( JAVA) utils.CheckVersion`
47+
3148# For 6.5.3 and 7.0+, we need to select the correct JDBC API, so prompt
3249# for the version.
33- all :
50+ huho :
3451@echo ------------------------------------------------------------
3552@echo Due to problems with some JVMs that dontreturn a meaningful
3653@echo version number, we have had to make the choice of what jdbc
3754@echo version is built as a compiletime option.
3855@echo
3956@echo If you are using JDK1.1.x, you will need the JDBC1.2 driver.
4057@echo To compile, type:
41- @echo" make jdbc1 jar "
58+ @echo" make jdbc1"
4259@echo
4360@echo" If you are using JDK1.2 (aka Java2) you need the JDBC2."
4461@echo To compile, type:
45- @echo" make jdbc2 jar"
62+ @echo" make jdbc2"
63+ @echo
64+ @echo" If you are using the Java2 Enterprise Edition, you can use"
65+ @echo" either the standard driver above, or compile the standard"
66+ @echo" extensions version of the driver. Type:"
67+ @echo" make enterprise"
4668@echo
4769@echo Once you havedone this, a postgresql.jar file will be
4870@echo produced. This file will only work with that particular
49- @echoJVM .
71+ @echoversion of virtual machine .
5072@echo
5173@echo ------------------------------------------------------------
5274
7698@echo
7799@echo" To make the tests, type:"
78100@echo" make tests"
101+ @echo
102+ @echo" To build the GUI Shell, type:"
103+ @echo" make retepsql"
104+ @echo
79105@echo ------------------------------------------------------------
80106@echo
81107
93119# the jar file.
94120OBJ_COMMON =$(PGBASE ) /Connection.class\
95121$(PGBASE ) /Driver.class\
96- $(PGBASE ) /DriverClass.class\
97122$(PGBASE ) /Field.class\
98123$(PGBASE ) /PG_Stream.class\
99124$(PGBASE ) /ResultSet.class\
@@ -136,53 +161,79 @@ OBJ_JDBC2=$(PGBASE)/jdbc2/ResultSet.class \
136161$(PGBASE ) /jdbc2/Statement.class\
137162$(PGBASE ) /largeobject/PGblob.class
138163
164+ # These files are unique to the JDBC2 Enterprise driver
165+ OBJ_ENTER =$(OBJ_JDBC2 ) \
166+ $(PGBASE ) /PostgresqlDataSource.class\
167+ $(PGBASE ) /xa/ClientConnection.class\
168+ $(PGBASE ) /xa/TwoPhaseConnection.class\
169+ $(PGBASE ) /xa/TxConnection.class\
170+ $(PGBASE ) /xa/XAConnectionImpl.class\
171+ $(PGBASE ) /xa/XADataSourceImpl.class
172+
139173# This rule builds the JDBC1 compliant driver
140174jdbc1 :
141- (echo" package org.postgresql;" ; \
142- echo " public class DriverClass {" ; \
143- echo " public static String connectClass=\" org.postgresql.jdbc1.Connection\" ;" ; \
144- echo " }" \
145- )> $(PGBASE ) /DriverClass.java
175+ $(BUILDDRIVER ) $(VERSION ) org.postgresql.jdbc1.Connection JDBC1.1$(PGBASE ) /Driver.java
146176-$(RM ) postgresql.jar
147177@$(MAKE ) jdbc1real
148178
149179# This rule does the real work for JDBC1.2, however do not call it directly.
150180# This is because the JDBC driver relies on the org.postgresql.DriverClass
151181# class to determine the driver version.
152- jdbc1real :$(PGBASE ) /DriverClass.class\
153- $(OBJ_COMMON ) $(OBJ_JDBC1 ) postgresql.jar msg
182+ jdbc1real :$(OBJ_COMMON ) $(OBJ_JDBC1 ) $(JARFILE ) msg
154183
155184# This rule builds the JDBC2 compliant driver
156- jdbc2 :
157- (echo" package org.postgresql;" ; \
158- echo " public class DriverClass {" ; \
159- echo " public static String connectClass=\" org.postgresql.jdbc2.Connection\" ;" ; \
160- echo " }" \
161- )> $(PGBASE ) /DriverClass.java
185+ jdbc2 :
186+ @$(MAKE ) jdbc2internal msg
187+
188+ # This allows us to build the jdbc2 driver without displaying the msg
189+ # refer to the retepsql rule to see why.
190+ jdbc2internal :
191+ $(BUILDDRIVER ) $(VERSION ) org.postgresql.jdbc2.Connection Java2$(PGBASE ) /Driver.java
162192-$(RM ) postgresql.jar
163193@$(MAKE ) jdbc2real
164194
165195# This rule does the real work for JDBC2, however do not call it directly.
166196# This is because the JDBC driver relies on the org.postgresql.DriverClass
167197# class to determine the driver version.
168- jdbc2real :$(PGBASE ) /DriverClass.class\
169- $(OBJ_COMMON ) $(OBJ_JDBC2 ) postgresql.jar msg
198+ jdbc2real :$(OBJ_COMMON ) $(OBJ_JDBC2 ) $(JARFILE )
199+
200+ # This rule builds the enterprise edition of the driver
201+ enterprise :
202+ $(BUILDDRIVER ) $(VERSION ) org.postgresql.jdbc2.Connection Enterprise$(PGBASE ) /Driver.java
203+ -$(RM ) postgresql.jar
204+ @$(MAKE ) enterprisereal
170205
171- # If you have problems with this rule, replace the $( ) with ` ` as some
172- # shells (mainly sh under Solaris) doesn't recognise $( )
206+ # This rule does the real work for JDBC2 Enterprise Edition, however do not
207+ # call it directly. This is because the JDBC driver relies on the
208+ # org.postgresql.DriverClass class to determine the driver version.
209+ enterprisereal :$(OBJ_COMMON ) $(OBJ_ENTER ) $(JARFILE )
210+
211+ # We use the old `cmd` notation here as some older shells (mainly sh under
212+ # Solaris) don't recognise the newer $(cmd) syntax.
173213#
174- postgresql.jar :$(OBJ ) $(OBJ_COMMON )
214+ $( JARFILE ) :$(OBJ ) $(OBJ_COMMON )
175215$(JAR ) -c0f$@ ` $( FIND) $( PGBASE) -name" *.class" -print` \
176216$(wildcard $(PGBASE ) /* .properties)
177217
178218# This rule removes any temporary and compiled files from the source tree.
219+ #
179220clean :
180221$(FIND ) . -name" *~" -exec$(RM ) {}\;
181222$(FIND ) . -name" *.class" -exec$(RM ) {}\;
182- $(FIND ) . -name" *.html" -exec$(RM ) {}\;
183223-$(RM ) -rf stock example/corba/stock.built
184- -$(RM ) postgresql.jar org/postgresql/DriverClass .java
224+ -$(RM ) postgresql.jar org/postgresql/Driver .java
185225-$(RM ) -rf Package-postgresql* output
226+ -$(RM ) retepsql.jar manifest
227+
228+ # New for 7.1
229+ install :$(JARFILE )
230+ $(CP ) $(JARFILE ) $(libdir )
231+
232+ # This converts CHANGELOG into an html format - used by peter@retep.org.uk
233+ # to produce an online version
234+ changelog : changelog.html
235+ changelog.html : CHANGELOG
236+ $(CHANGELOG ) $< > $@
186237
187238# ######################################################################
188239# This helps make workout what classes are from what source files
@@ -311,3 +362,60 @@ example/corba/stock.built: example/corba/stock.idl
311362# tip: we cant use $(wildcard stock/*.java) in the above rule as a race
312363# condition occurs, where javac is passed no arguments
313364# ######################################################################
365+ #
366+ # JPGSqlThis isn't really an example, but an entire frontend
367+ # for PostgreSQL via Java & JDBC.
368+ #
369+ # Requirements:Java2 platform (JDK1.2.x or 1.3)
370+ #
371+ retepsql :jdbc2internal postgresql.jar
372+ -$(RM ) retepsql.jar
373+ @$(MAKE ) retepsql.jar
374+ @echo
375+ @echo" The retepsql application has now been built. To run, simply"
376+ @echo" type:"
377+ @echo
378+ @echo" java -jar retepsql.jar"
379+ @echo
380+ @echo" Note: Some operating systems recognise .jar as an executable,"
381+ @echo" so on those (and Windows is one of them), you can simply"
382+ @echo" double click the jar file to start it."
383+
384+ # All my classes have this prefix
385+ RETEP =uk/org/retep
386+
387+ # These classes form part of my personal swing library. I have placed these
388+ # into the public domain, so there are no license issues... enjoy...
389+ RETEPUTILS =$(RETEP ) /swing/SwingApplication.class\
390+ $(RETEP ) /swing/SwingApplication.class\
391+
392+ # This is my postgresql frontend. As it's never been released before, I've
393+ # decided not only to publish it under the same licence as the JDBC driver,
394+ # but also to put it along side the driver. To me it makes sense as it's the
395+ # best example I have on showing how to use the driver ;-)
396+ RETEPSQL =$(RETEP ) /sql/DBConnection.class\
397+ $(RETEP ) /sql/RetepSQL.class\
398+
399+ # Some ancilary files which are included in the jar file
400+ RETEPSQLAUX =$(RETEP ) /icons/\
401+
402+ # The big rule, this builds the jpgsql.jar file which contains the entire
403+ # application. DONT call this rule directly, but use the retepsql one, as
404+ # it ensures that jdbc is also compiled first.
405+ #
406+ # Note: We include the postgresql.jar contents in this as well. Also the
407+ # manifest entry MUST be immediately after $@ (note the -m option to jar).
408+ #
409+ retepsql.jar :$(RETEPUTILS ) \
410+ $(RETEPSQL )
411+ (echo" Manifest-Version: 1.0" ; \
412+ echo " Created-By: 1.2 (Sun Microsystems Inc.)" ; \
413+ echo " Main-Class: uk.org.retep.sql.RetepSQL" ; \
414+ )> manifest
415+ $(JAR ) -c0fm$@ manifest\
416+ ` $( FIND) $( PGBASE) -name" *.class" -print` \
417+ $(wildcard $(PGBASE ) /* .properties) \
418+ ` $( FIND) $( RETEP) -name" *.class" -print` \
419+ $(RETEPSQLAUX )
420+
421+ # ######################################################################