JDBC build - take 2 - Mailing list pgsql-jdbc
From | Marko Kreen |
---|---|
Subject | JDBC build - take 2 |
Date | |
Msg-id | 20011022233400.A7895@l-t.ee Whole thread Raw |
Responses |
Re: JDBC build - take 2
Re: JDBC build - take 2 Re: JDBC build - take 2 Re: JDBC build - take 2 Re: JDBC build - take 2 |
List | pgsql-jdbc |
Here is updated patch: * fixed couple of typos. * installdirs and uninstall targets * converted contrib/retep to make too, now no parts of PostgreSQL source _require_ Ant. * made the JUnit tests work too -- marko Index: configure.in =================================================================== RCS file: /opt/cvs/pgsql/pgsql/configure.in,v retrieving revision 1.149 diff -u -r1.149 configure.in --- configure.in 20 Oct 2001 17:57:38 -0000 1.149 +++ configure.in 22 Oct 2001 21:16:18 -0000 @@ -32,6 +32,11 @@ AC_SUBST(VERSION) AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION") +VERSION_MAJOR=`echo $VERSION | sed 's/^\([[0-9]][[0-9]]*\)\..*\$/\1/'` +VERSION_MINOR=`echo $VERSION | sed 's/^[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\).*\$/\1/'` +AC_SUBST(VERSION_MAJOR) +AC_SUBST(VERSION_MINOR) + unset CDPATH AC_CANONICAL_HOST @@ -404,10 +409,8 @@ AC_MSG_CHECKING([whether to build Java/JDBC tools]) PGAC_ARG_BOOL(with, java, no, [ --with-java build JDBC interface and Java tools], [AC_MSG_RESULT(yes) -PGAC_PATH_ANT -if test -z "$ANT"; then - AC_MSG_ERROR([Ant is required to build Java components]) -fi], +PGAC_JAVA +], [AC_MSG_RESULT(no)]) AC_SUBST(with_java) Index: src/Makefile.global.in =================================================================== RCS file: /opt/cvs/pgsql/pgsql/src/Makefile.global.in,v retrieving revision 1.140 diff -u -r1.140 Makefile.global.in --- src/Makefile.global.in 13 Oct 2001 15:24:23 -0000 1.140 +++ src/Makefile.global.in 19 Oct 2001 17:12:34 -0000 @@ -30,6 +30,8 @@ # PostgreSQL version number VERSION = @VERSION@ +VERSION_MAJOR = @VERSION_MAJOR@ +VERSION_MINOR = @VERSION_MINOR@ # Support for VPATH builds abs_top_srcdir = @abs_top_srcdir@ @@ -244,6 +246,11 @@ DEF_PGPORT = @default_port@ WANTED_LANGUAGES = @WANTED_LANGUAGES@ +# Java +JAVA = @JAVA@ +JAVAC = @JAVAC@ +JAR = @JAR@ +JDBC_TYPE = @JDBC_TYPE@ ########################################################################## # Index: config/java.m4 =================================================================== RCS file: /opt/cvs/pgsql/pgsql/config/java.m4,v retrieving revision 1.3 diff -u -r1.3 java.m4 --- config/java.m4 4 Jul 2001 21:22:55 -0000 1.3 +++ config/java.m4 19 Oct 2001 17:20:39 -0000 @@ -59,3 +59,41 @@ AC_PATH_PROGS(ANT, [jakarta-ant ant ant.sh ant.bat]) _PGAC_PROG_ANT_WORKS ]) + + +AC_DEFUN([PGAC_JAVA], +[ + testf=src/interfaces/jdbc/utils/CheckVersion.java + test -f "$testf" || { echo "JDBC driver source not found..." ; exit 1 ; } + AC_PATH_PROGS(JAVA, [java]) + AC_PATH_PROGS(JAVAC, [javac jikes]) + AC_PATH_PROGS(JAR, [jar fastjar]) + AC_PATH_PROGS(ANT, [jakarta-ant ant ant.sh ant.bat]) + AC_CACHE_CHECK([for type of the JDBC driver], [pgac_cv_jdbc_type], + [ + pgac_cv_jdbc_type=bad + + pgac_cmd='$JAVAC -d . $testf 1>&2' + AC_TRY_EVAL(pgac_cmd) + pgac_save_status=$? + if test ! $pgac_save_status = 0 -o ! -f ./CheckVersion.class ; then + echo "configure: failed java program was: $testf" >&AC_FD_CC + AC_MSG_ERROR([Java compilation error. Check config.log for details.]) + fi + + pgac_cmd='$JAVA CheckVersion > conftest.jdbc' + AC_TRY_EVAL(pgac_cmd) + pgac_save_status=$? + test -f conftest.jdbc && pgac_cv_jdbc_type=`cat conftest.jdbc` + test "x$pgac_cv_jdbc_type" = "x" && pgac_cv_jdbc_type=bad + if test ! $pgac_save_status = 0 -o x"$pgac_cv_jdbc_type" = xbad ; then + echo "configure: failed java program was: $testf" >&AC_FD_CC + AC_MSG_ERROR([Java running error. Check config.log for details.]) + fi + + rm CheckVersion.class conftest.jdbc + ]) + JDBC_TYPE=$pgac_cv_jdbc_type + AC_SUBST(JDBC_TYPE) +]) + Index: contrib/retep/Makefile =================================================================== RCS file: /opt/cvs/pgsql/pgsql/contrib/retep/Makefile,v retrieving revision 1.1 diff -u -r1.1 Makefile --- contrib/retep/Makefile 6 Jul 2001 23:07:20 -0000 1.1 +++ contrib/retep/Makefile 22 Oct 2001 21:16:05 -0000 @@ -12,19 +12,36 @@ top_builddir = ../.. include $(top_builddir)/src/Makefile.global -all: - $(ANT) -buildfile $(srcdir)/build.xml all -install: installdirs - $(ANT) -buildfile $(srcdir)/build.xml install \ - -Dinstall.directory=$(javadir) +BUILDDIR := ./build +JARDIR := ./jars +PKGBASE := uk/org/retep +JARNAME := retepTools.jar + +SRCS := $(shell find $(srcdir)/$(PKGBASE) -name '*.java') +JARFILE := $(JARDIR)/$(JARNAME) + + +all: $(JARFILE) + +$(JARFILE): $(SRCS) + mkdir -p $(BUILDDIR) $(JARDIR) + @echo "" + @echo "Compiling uk.org.retep tools..." + @$(JAVAC) -d $(BUILDDIR) $(SRCS) + @echo "" + cp $(srcdir)/$(PKGBASE)/*.properties $(BUILDDIR)/$(PKGBASE) + $(JAR) -c0f $@ -C $(BUILDDIR) $(PKGBASE) + +clean distclean maintainer-clean: + rm -rf $(BUILDDIR) $(JARDIR) installdirs: $(mkinstalldirs) $(javadir) +install: $(JARFILE) installdirs + $(INSTALL_DATA) $(JARFILE) $(javadir) + uninstall: - $(ANT) -buildfile $(srcdir)/build.xml uninstall \ - -Dinstall.directory=$(javadir) + rm -f $(javadir)/$(JARNAME) -clean distclean maintainer-clean: - $(ANT) -buildfile $(srcdir)/build.xml clean Index: src/interfaces/jdbc/Makefile =================================================================== RCS file: /opt/cvs/pgsql/pgsql/src/interfaces/jdbc/Makefile,v retrieving revision 1.33 diff -u -r1.33 Makefile --- src/interfaces/jdbc/Makefile 6 Jul 2001 23:07:20 -0000 1.33 +++ src/interfaces/jdbc/Makefile 22 Oct 2001 21:17:05 -0000 @@ -12,30 +12,130 @@ top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -majorversion := $(shell echo $(VERSION) | sed 's/^\([0-9][0-9]*\)\..*$$/\1/') -minorversion := $(shell echo $(VERSION) | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$$/\1/') +IDL2JAVA = idltojava -fno-cpp -fno-tie -properties := -Dmajor=$(majorversion) -Dminor=$(minorversion) \ - -Dfullversion=$(VERSION) \ - -Ddef_pgport=$(DEF_PGPORT) - -all: - $(ANT) -buildfile $(srcdir)/build.xml all \ - $(properties) - -install: installdirs - $(ANT) -buildfile $(srcdir)/build.xml install \ - -Dinstall.directory=$(javadir) $(properties) +BUILDDIR := ./build +JARDIR := ./jars + +PGBASE := $(srcdir)/org/postgresql +JARFILE := $(JARDIR)/postgresql.jar +MANIFEST := $(srcdir)/manifest +TEST_JAR := $(JARDIR)/postgresql-test.jar +EXAMPLE_JAR := $(JARDIR)/postgresql-example.jar + +# Test vars +TEST_DATABASE := test +TEST_USERNAME := test +TEST_PASSWORD := test +JUNIT_UI := textui + +# +# default target +# +all: $(JARFILE) + +# +# Details about driver edition +# +include $(srcdir)/spec.$(JDBC_TYPE) + +# +# get sources +# +PKG_DIRS := $(foreach pkg,$(subst .,/,$(PKGS)),$(pkg)) +SRCS := $(foreach src,$(EXTRA_SRCS),$(srcdir)/$(src)) \ + $(foreach dir,$(PKG_DIRS),$(wildcard $(srcdir)/$(dir)/*.java)) + +TEST_DIRS := $(foreach pkg,$(subst .,/,$(TEST_PKGS)),$(pkg)) +TEST_SRCS := $(foreach dir,$(TEST_DIRS),$(wildcard $(srcdir)/$(dir)/*.java)) + +EXAMPLE_SRCS := $(foreach src,$(EXAMPLE_SRCS),$(srcdir)/$(src)) + +SEDSUBST := -e 's,@MAJORVERSION@,$(VERSION_MAJOR),g' \ + -e 's,@MINORVERSION@,$(VERSION_MINOR),g' \ + -e 's,@VERSION@,PostgreSQL $(VERSION) $(JDBC_EDITION),g' \ + -e 's,@JDBCCONNECTCLASS@,$(JDBC_CONNECTCLASS),g' \ + -e 's,@DEF_PGPORT@,$(DEF_PGPORT),g' \ + -e 's,@JAVA_DEST@,$(javadir),g' + +# +# meta targets +# +.PHONY: examples tests jdbc1 jdbc2 jdbc2e + +examples: $(EXAMPLE_JAR) + +tests: $(TEST_JAR) + +jdbc1: + $(MAKE) JDBC_TYPE=jdbc1 + +jdbc2: + $(MAKE) JDBC_TYPE=jdbc2 + +jdbc2e: + $(MAKE) JDBC_TYPE=jdbc2e + +# +# files +# +$(MANIFEST): $(MANIFEST).in + sed $(SEDSUBST) < $< > $@ + +# Driver.java is mentioned in spec.* +$(PGBASE)/Driver.java: $(PGBASE)/Driver.java.in + sed $(SEDSUBST) < $< > $@ + +$(srcdir)/ant.cfg: $(srcdir)/ant.cfg.in + sed $(SEDSUBST) < $< > $@ + +# +# JARs +# +$(JARFILE): $(MANIFEST) $(SRCS) + mkdir -p $(BUILDDIR) $(JARDIR) + rm -rf $(BUILDDIR)/org/postgresql/test + @echo "" + @echo "Compiling $(JDBC_EDITION) driver..." + @$(JAVAC) -d $(BUILDDIR) $(SRCS) + @echo "" + cp $(PGBASE)/*.properties $(BUILDDIR)/org/postgresql + $(JAR) -c0mf $(MANIFEST) $@ \ + -C $(BUILDDIR) org/postgresql + +$(EXAMPLE_JAR): $(EXAMPLE_SRCS) + mkdir -p $(BUILDDIR) $(JARDIR) + $(JAVAC) -d $(BUILDDIR) $(EXAMPLE_SRCS) + $(JAR) -c0f $@ -C $(BUILDDIR) example + +$(TEST_JAR): $(TEST_SRCS) + mkdir -p $(BUILDDIR) $(JARDIR) + $(JAVAC) -d $(BUILDDIR) $(TEST_SRCS) + $(JAR) -c0f $@ -C $(BUILDDIR) org/postgresql/test + +# +# other +# +clean distclean maintainer-clean: + find . -name "*~" -exec rm {} \; + rm -f $(PGBASE)/Driver.java + rm -f $(MANIFEST) $(srcdir)/ant.cfg + rm -rf $(BUILDDIR) $(JARDIR) + +check: $(JARFILE) $(TEST_JAR) + $(JAVA) -classpath $(JARFILE):$(TEST_JAR):$(CLASSPATH) \ + -Ddatabase=jdbc:postgresql:$(TEST_DATABASE) \ + -Dusername=$(TEST_USERNAME) -Dpassword=$(TEST_PASSWORD) \ + junit.$(JUNIT_UI).TestRunner org.postgresql.test.JDBC2Tests installdirs: $(mkinstalldirs) $(javadir) -uninstall: - $(ANT) -buildfile $(srcdir)/build.xml uninstall \ - -Dinstall.directory=$(javadir) +install: $(JARFILE) installdirs + $(INSTALL_DATA) $(JARFILE) $(javadir) -clean distclean maintainer-clean: - $(ANT) -buildfile $(srcdir)/build.xml clean +uninstall: + rm -f $(javadir)/postgresql.jar + rm -f $(javadir)/postgresql-test.jar + rm -f $(javadir)/postgresql-examples.jar -check: - $(ANT) -buildfile $(srcdir)/build.xml test Index: src/interfaces/jdbc/build.xml =================================================================== RCS file: /opt/cvs/pgsql/pgsql/src/interfaces/jdbc/build.xml,v retrieving revision 1.18 diff -u -r1.18 build.xml --- src/interfaces/jdbc/build.xml 23 Sep 2001 04:11:14 -0000 1.18 +++ src/interfaces/jdbc/build.xml 19 Oct 2001 17:12:34 -0000 @@ -20,6 +20,8 @@ <property name="builddir" value="build" /> <property name="package" value="org/postgresql" /> + <!-- Load autoconfed properties. --> + <property file="${srcdir}/ant.cfg" /> <!-- This is a simpler method than utils.CheckVersion Index: src/interfaces/jdbc/utils/CheckVersion.java =================================================================== RCS file: /opt/cvs/pgsql/pgsql/src/interfaces/jdbc/utils/CheckVersion.java,v retrieving revision 1.2 diff -u -r1.2 CheckVersion.java --- src/interfaces/jdbc/utils/CheckVersion.java 19 Dec 2000 17:33:39 -0000 1.2 +++ src/interfaces/jdbc/utils/CheckVersion.java 19 Oct 2001 17:12:34 -0000 @@ -1,5 +1,3 @@ -package utils; - /** * This little app checks to see what version of JVM is being used. * It does this by checking first the java.vm.version property, and @@ -41,12 +39,9 @@ { String vmversion = System.getProperty("java.vm.version"); - System.out.println("postgresql.jdbc="+System.getProperty("postgresql.jdbc")); - // We are running a 1.1 JVM if(vmversion.startsWith("1.1")) { System.out.println("jdbc1"); - //System.exit(0); } else // We are running a 1.2 or 1.3 JVM @@ -58,11 +53,10 @@ // Check to see if we have the standard extensions. If so, then // we want the enterprise edition, otherwise the jdbc2 driver. if(checkClass("javax.sql.DataSource")) - System.out.println("enterprise"); + System.out.println("jdbc2e"); else System.out.println("jdbc2"); - //System.exit(0); - } - System.setProperty("postgresql.jdbc","yoyo"); + } else + System.out.println("bad"); } } --- /dev/null Thu Jan 1 03:00:00 1970 +++ src/interfaces/jdbc/manifest.in Fri Oct 19 19:12:34 2001 @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + --- /dev/null Thu Jan 1 03:00:00 1970 +++ src/interfaces/jdbc/ant.cfg.in Fri Oct 19 19:12:34 2001 @@ -0,0 +1,8 @@ +# properties for Ant + +fullversion = @VERSION@ +major = @VERSION_MAJOR@ +minor = @VERSION_MINOR@ +def_pgport = @default_port@ +install.directory = @JAVA_DEST@ + --- /dev/null Thu Jan 1 03:00:00 1970 +++ src/interfaces/jdbc/spec.jdbc1 Mon Oct 22 23:17:05 2001 @@ -0,0 +1,32 @@ +# jdbc1 + +PKGS := org.postgresql.core \ + org.postgresql.fastpath \ + org.postgresql.geometric \ + org.postgresql.util \ + org.postgresql.jdbc1 + +EXTRA_SRCS := org/postgresql/Connection.java \ + org/postgresql/Driver.java \ + org/postgresql/Field.java \ + org/postgresql/PG_Stream.java \ + org/postgresql/ResultSet.java \ + org/postgresql/Statement.java \ + \ + org/postgresql/largeobject/BlobInputStream.java \ + org/postgresql/largeobject/BlobOutputStream.java \ + org/postgresql/largeobject/LargeObject.java \ + org/postgresql/largeobject/LargeObjectManager.java + +JDBC_CONNECTCLASS := org.postgresql.jdbc1.Connection + +JDBC_EDITION := JDBC1 + +EXAMPLE_SRCS := example/ImageViewer.java example/Unicode.java \ + example/basic.java example/datestyle.java \ + example/metadata.java example/psql.java \ + example/threadsafe.java + +# no tests for jdbc1... +TEST_PKGS := + --- /dev/null Thu Jan 1 03:00:00 1970 +++ src/interfaces/jdbc/spec.jdbc2 Mon Oct 22 23:17:05 2001 @@ -0,0 +1,26 @@ +# jdbc2 + +PKGS := org.postgresql.core \ + org.postgresql.fastpath \ + org.postgresql.geometric \ + org.postgresql.largeobject \ + org.postgresql.util \ + org.postgresql.jdbc2 + +EXTRA_SRCS := org/postgresql/Connection.java \ + org/postgresql/Driver.java \ + org/postgresql/Field.java \ + org/postgresql/PG_Stream.java \ + org/postgresql/ResultSet.java \ + org/postgresql/Statement.java + +JDBC_CONNECTCLASS := org.postgresql.jdbc2.Connection + +JDBC_EDITION := JDBC2 + +EXAMPLE_SRCS := example/ImageViewer.java example/Unicode.java \ + example/basic.java example/blobtest.java example/datestyle.java \ + example/metadata.java example/psql.java example/threadsafe.java + +TEST_PKGS := org.postgresql.test org.postgresql.test.jdbc2 + --- /dev/null Thu Jan 1 03:00:00 1970 +++ src/interfaces/jdbc/spec.jdbc2e Mon Oct 22 23:17:05 2001 @@ -0,0 +1,28 @@ +# jdbc2e + +PKGS := org.postgresql.core \ + org.postgresql.fastpath \ + org.postgresql.geometric \ + org.postgresql.largeobject \ + org.postgresql.util \ + org.postgresql.jdbc2 \ + org.postgresql.xa + +EXTRA_SRCS := org/postgresql/Connection.java \ + org/postgresql/Driver.java \ + org/postgresql/Field.java \ + org/postgresql/PG_Stream.java \ + org/postgresql/ResultSet.java \ + org/postgresql/Statement.java \ + org/postgresql/PostgresqlDataSource.java + +JDBC_CONNECTCLASS := org.postgresql.jdbc2.Connection + +JDBC_EDITION := JDBC2 Enterprise + +EXAMPLE_SRCS := example/ImageViewer.java example/Unicode.java \ + example/basic.java example/blobtest.java example/datestyle.java \ + example/metadata.java example/psql.java example/threadsafe.java + +TEST_PKGS := org.postgresql.test org.postgresql.test.jdbc2 +
pgsql-jdbc by date: