]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
java: avoid compilation errors when CLASSPATH is empty
authorDaniel Richard G <skunk@iskunk.org>
Tue, 16 Aug 2011 13:19:14 +0000 (15:19 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 18 Aug 2011 19:33:51 +0000 (21:33 +0200)
* lib/am/java.am (CLASSPATH_ENV): When redefining `$CLASSPATH',
do not append an empty component in case the previous value of
CLASSPATH is empty or unset.
* tests/java-empty-classpath.test: New test.
* tests/Makefile.am (TESTS): Update.

Fixes automake bug#9306.

ChangeLog
lib/am/java.am
tests/java-empty-classpath.test [new file with mode: 0755]

index 8de3ebc4ec0ae73d4b030a3011011c71dda920f5..ca6411d075ab7cee9536fe25fcc908de2876282b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-08-16  Daniel Richard G. <skunk@iskunk.org>  (tiny change)
+           Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       java: avoid compilation errors when CLASSPATH is empty
+       * lib/am/java.am (CLASSPATH_ENV): When redefining `$CLASSPATH',
+       do not append an empty component in case the previous value of
+       CLASSPATH is empty or unset.
+       * tests/java-empty-classpath.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+       Fixes automake bug#9306.
+
 2011-08-16  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        parallel-tests: no more spurious successes for FreeBSD make
index d6eb455854db2d9cd061c9a8cc35c9a1f8fe8245..604df222956c44811096cd8ebc01c2b2c8cdd4ff 100644 (file)
@@ -21,7 +21,7 @@
 ## ---------- ##
 
 JAVAC = javac
-CLASSPATH_ENV = CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH
+CLASSPATH_ENV = CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT)$${CLASSPATH:+":$$CLASSPATH"}
 JAVAROOT = $(top_builddir)
 
 class%DIR%.stamp: $(%DIR%_JAVA)
diff --git a/tests/java-empty-classpath.test b/tests/java-empty-classpath.test
new file mode 100755 (executable)
index 0000000..230bb7c
--- /dev/null
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Java compilation works also when CLASSPATH is unset or empty at
+# compilation time.  See automake bug#9306.
+
+required=javac
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_CONFIG_SRCDIR([org/gnu/bug/Library.java])
+AC_CONFIG_FILES([
+    org/Makefile
+    org/gnu/Makefile
+    org/gnu/bug/Makefile
+])
+AC_OUTPUT
+END
+
+mkdir org org/gnu org/gnu/bug
+cat > Makefile.am <<END
+CLEANFILES = *.class
+SUBDIRS = org
+END
+echo SUBDIRS = gnu > org/Makefile.am 
+echo SUBDIRS = bug > org/gnu/Makefile.am 
+cat > org/gnu/bug/Makefile.am <<'END'
+JAVAROOT = ../../..
+dist_noinst_JAVA = Library.java Application.java
+END
+
+cat > org/gnu/bug/Library.java <<'END'
+package org.gnu.bug;
+public class Library
+{
+    public Library ()
+    {
+      // Nothing to do.
+    }
+    public static void doSomethingUseful (String arg)
+    {
+      System.out.println (arg);
+    }
+}
+END
+
+cat > org/gnu/bug/Application.java <<'END'
+import org.gnu.bug.*;
+public class Application
+{
+    public static void main (String args[])
+    {
+        Library lib = new Library ();
+        lib.doSomethingUseful ("PLUGH");
+    }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+unset CLASSPATH || :
+$MAKE
+$MAKE clean
+
+CLASSPATH=''; export CLASSPATH
+$MAKE
+$MAKE clean
+
+unset CLASSPATH || :
+$MAKE distcheck
+
+: