From: Daniel Richard G Date: Tue, 16 Aug 2011 13:19:14 +0000 (+0200) Subject: java: avoid compilation errors when CLASSPATH is empty X-Git-Tag: v1.11.1b~23^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=720f0a2e5ad7e232390e2c590c331773389e8a25;p=thirdparty%2Fautomake.git 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. --- diff --git a/ChangeLog b/ChangeLog index 8de3ebc4e..ca6411d07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-08-16 Daniel Richard G. (tiny change) + Stefano Lattarini + + 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 parallel-tests: no more spurious successes for FreeBSD make diff --git a/lib/am/java.am b/lib/am/java.am index d6eb45585..604df2229 100644 --- a/lib/am/java.am +++ b/lib/am/java.am @@ -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 index 000000000..230bb7cd3 --- /dev/null +++ b/tests/java-empty-classpath.test @@ -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 . + +# 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 < 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 + +: