Add uninstall target to Java build.
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 11 Mar 2001 11:07:01 +0000 (11:07 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 11 Mar 2001 11:07:01 +0000 (11:07 +0000)
Respect default port setting in JDBC driver.
Pick up version number from Makefile.global.
Change installation directory to share/java/.
Document.

build.xml
contrib/retep/build.xml
doc/src/sgml/jdbc.sgml
src/interfaces/jdbc/Makefile
src/interfaces/jdbc/build.xml
src/interfaces/jdbc/org/postgresql/Driver.java.in

index 1818be4cc83a5e06b4296c4bd78542af3938b7b9..749a0382f59cfa2be03d50a9cd7c29cf17b18188 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -69,6 +69,12 @@ e.g.
     </antcall>
   </target>
 
+  <target name="uninstall" if="install.directory">
+    <antcall target="call">
+      <param name="target" value="uninstall" />
+    </antcall>
+  </target>
+
   <!--
        This actually calls the other two build.xml files.
        To use it, use the <antcall> tag, and pass the destination target
index 47bcf3ca52ee7bb13700d77b932774f6105bf2ef..85928f17dde20a305c44bea3ddc41aacad2f1bd1 100644 (file)
     </copy>
   </target>
 
-</project>
+  <target name="uninstall" if="install.directory">
+    <delete>
+      <fileset dir="${install.directory}">
+        <include name="**/*.jar" />
+      </fileset>
+    </delete>
+  </target>
 
+</project>
index 9b14a87252989e0a672f747c0a60c0f2d84c963d..8ef7e6c8ef823804c94750c52cbf2c23069e39db 100644 (file)
@@ -53,55 +53,49 @@ $Header$
 
    <para>
     Starting with <productname>PostgreSQL</productname> version 7.1,
-    the preferred way to build the <acronym>JDBC</acronym> driver is
-    using <productname>Ant</productname>, a special tool for building
+    the <acronym>JDBC</acronym> driver is built using
+    <application>Ant</application>, a special tool for building
     Java-based packages.  You should download
-    <productname>Ant</productname> from the <ulink
-    url="http://jakarta.apache.org/ant/index.html"><productname>Ant</productname>
-    web site</ulink> and install it before proceeding.
-   </para>
-
-   <para>
-    The build the driver, issue the command
-<screen>
-<prompt>$</prompt> <userinput>ant</userinput>
-</screen>
-    in the top level directory of the
-    <productname>PostgreSQL</productname> source distribution.
-   </para>
-
-   <para>
-    To install the driver, enter the command
-<screen>
-<prompt>$</prompt> <userinput>ant -Dinstall.directory=<replaceable>mydir</replaceable> install</userinput>
-</screen>
-    Replace <replaceable>mydir</replaceable> with a directory name of
-    your choice; the directory will be created if necessary.  The
-    <productname>PostgreSQL</productname> <acronym>JDBC</acronym>
-    driver consists of a <filename>postgresql.jar</filename> file that
-    will be copied to that directory.
+    <application>Ant</application> from the <ulink
+    url="http://jakarta.apache.org/ant/index.html"><application>Ant</application>
+    web site</ulink> and install it before proceeding.  Precompiled
+    <application>Ant</application> distributions are typically set up
+    to read a file <filename>.antrc</filename> in the current user's
+    home directory for configuration.  For example, to use a different
+    <acronym>JDK</acronym> than the default, this may work:
+<programlisting>
+JAVA_HOME=/usr/local/sun-jdk1.3
+JAVACMD=$JAVA_HOME/bin/java
+</programlisting>
    </para>
 
    <para>
-    Alternatively, you can use the old <command>make</command>-based
-    interface.  The driver's source is located in the <filename
-    class="directory">src/interfaces/jdbc</filename> directory of the
-    source tree. To compile, simply change directory to that
-    directory, and type:
+    The build the driver, add the <option>--with-java</option> option to your
+    <filename>configure</filename> command line, e.g.,
 <screen>
-<prompt>$</prompt> <userinput>gmake</userinput>
+<prompt>$</prompt> <userinput>./configure --prefix=<replaceable>xxx</replaceable> --with-java ...</userinput>
 </screen>
-    (Remember to use <acronym>GNU</acronym> make.)  Upon completion,
-    you will find the archive <filename>postgresql.jar</filename> in
-    the current directory. This is the <acronym>JDBC</acronym> driver,
-    which you can copy to an appropriate directory in your system.
+    This will build and install the driver along with the rest of the
+    <productname>PostgreSQL</productname> package when you issue the
+    <literal>gmake</literal> and <literal>gmake install</literal>
+    commands.  If you only want to build the driver and not the rest
+    of <productname>PostgreSQL</productname>, change into the
+    directory <filename
+    class="directory">src/interfaces/jdbc</filename> and issue the
+    respective <literal>make</literal> command there.  Refer to the
+    <productname>PostgreSQL</productname> installation instructions
+    for more information about the configuration and build process.
    </para>
 
    <note>
     <para>
-     You must not use <command>javac</command> directly, as the
-     driver uses some dynamic loading techniques for performance
-     reasons, and <command>javac</command> cannot cope.
+     Do not try to build by calling <command>javac</command> directly,
+     as the driver uses some dynamic loading techniques for
+     performance reasons, and <command>javac</command> cannot cope.
+     Do not try to run <command>ant</command> directly either, because
+     some configuration information is communicated through the
+     makefiles.  Running <command>ant</command> directly without
+     providing these parameters will result in a broken driver.
     </para>
    </note>
   </sect2>
@@ -114,7 +108,12 @@ $Header$
     <filename>postgresql.jar</filename> needs to be included in the
     class path, either by putting it in the <envar>CLASSPATH</envar>
     environment variable, or by using flags on the
-    <command>java</command> command line.
+    <command>java</command> command line.  By default, the jar archive
+    is installed in the directory <filename
+    class="directory">/usr/local/pgsql/share/java</filename>.  You may
+    have it in a different directory if you used the
+    <option>--prefix</option> option when you ran
+    <filename>configure</filename>.
    </para>
 
    <informalexample>
@@ -128,7 +127,7 @@ $Header$
      <filename>/usr/local/jdk1.1.6</filename>.  To run the
      application, I would use:
 <programlisting>
-export CLASSPATH=/usr/local/lib/finder.jar<co id="co.jdbc-finder">:/usr/local/lib/postgresql.jar:.
+export CLASSPATH=/usr/local/lib/finder.jar<co id="co.jdbc-finder">:/usr/local/pgsql/share/java/postgresql.jar:.
 java uk.org.retep.finder.Main
 </programlisting>
      <calloutlist>
index 097c61b9e7561724184d073d61743d31e6a5f589..2e3bcb7e5cb94d5122eb0e6e64bff1e65dcad01f 100644 (file)
@@ -12,17 +12,28 @@ subdir = src/interfaces/jdbc
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-all distprep:
-       @$(ANT) -buildfile $(top_builddir)/build.xml
+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/')
 
-install:
-       @$(ANT) -Dinstall.directory=$(DESTDIR)$(libdir)/java \
-               -buildfile $(top_builddir)/build.xml \
-               install
+properties := -Dmajor=$(majorversion) -Dminor=$(minorversion) \
+               -Dfullversion=$(VERSION) \
+               -Ddef_pgport=$(DEF_PGPORT)
 
-installdirs uninstall dep depend:
-       @echo Nothing for JDBC
+all:
+       $(ANT) -buildfile $(top_srcdir)/build.xml $(properties)
 
-clean distclean maintainer-clean:
-       @$(ANT) -buildfile $(top_builddir)/build.xml clean
+install: installdirs
+       $(ANT) -Dinstall.directory=$(DESTDIR)$(datadir)/java \
+               -buildfile $(top_srcdir)/build.xml \
+               install $(properties)
+
+installdirs:
+       $(mkinstalldirs) $(DESTDIR)$(datadir)/java
 
+uninstall:
+       $(ANT) -Dinstall.directory=$(DESTDIR)$(datadir)/java \
+               -buildfile $(top_srcdir)/build.xml \
+               uninstall
+
+clean distclean maintainer-clean:
+       $(ANT) -buildfile $(top_srcdir)/build.xml clean
index e6c02d1ac9938ae80b59e8258414ac6ab9e4ac9e..bc2660c143d90ab791a5b7e64e98855e2226c525 100644 (file)
@@ -14,8 +14,6 @@
   <property name="jars"    value="jars" />
   <property name="dest"    value="build" />
   <property name="package" value="org/postgresql" />
-  <property name="major" value="7" />
-  <property name="minor" value="1" />
 
   <!--
     defaults for the tests - overide these if required
@@ -68,8 +66,9 @@
     <!-- Some defaults -->
     <filter token="MAJORVERSION" value="${major}" />
     <filter token="MINORVERSION" value="${minor}" />
-    <filter token="VERSION" value="PostgreSQL ${major}.${minor} ${edition}" />
+    <filter token="VERSION" value="PostgreSQL ${fullversion} ${edition}" />
     <filter token="JDBCCONNECTCLASS" value="${connectclass}" />
+    <filter token="DEF_PGPORT" value="${def_pgport}" />
 
     <!-- Put a check for the current version here -->
 
     </copy>
   </target>
 
+  <!--
+    Uninstall the jar file.
+  -->
+  <target name="uninstall" if="install.directory">
+    <delete>
+      <fileset dir="${install.directory}">
+        <include name="**/*.jar" />
+      </fileset>
+    </delete>
+  </target>
+
   <!--
     This compiles and executes the JUnit tests
   -->
index d7452c6752fa05520f29648cf898d82e2153e58b..5d64a3f579b15e0efe697f37906e93ff00f322bb 100644 (file)
@@ -351,7 +351,7 @@ public class Driver implements java.sql.Driver
    */
   public int port()
   {
-    return Integer.parseInt(props.getProperty("PGPORT","5432"));
+    return Integer.parseInt(props.getProperty("PGPORT","@DEF_PGPORT@"));
   }
 
   /**