1 # SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro
3 # ===========================================================================
4 # https://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html
5 # ===========================================================================
15 # Note: This is part of the set of autoconf M4 macros for Java programs.
16 # It is VERY IMPORTANT that you download the whole set, some macros depend
17 # on other. Unfortunately, the autoconf archive does not support the
18 # concept of set of macros, so I had to break it for submission. The
19 # general documentation, as well as the sample configure.in, is included
20 # in the AX_PROG_JAVA macro.
24 # Copyright (c) 2008 Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
26 # This program is free software; you can redistribute it and/or modify it
27 # under the terms of the GNU General Public License as published by the
28 # Free Software Foundation; either version 2 of the License, or (at your
29 # option) any later version.
31 # This program is distributed in the hope that it will be useful, but
32 # WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
34 # Public License for more details.
36 # You should have received a copy of the GNU General Public License along
37 # with this program. If not, see <https://www.gnu.org/licenses/>.
39 # As a special exception, the respective Autoconf Macro's copyright owner
40 # gives unlimited permission to copy, distribute and modify the configure
41 # scripts that are the output of Autoconf when processing the Macro. You
42 # need not follow the terms of the GNU General Public License when using
43 # or distributing such scripts, even though portions of the text of the
44 # Macro appear in them. The GNU General Public License (GPL) does govern
45 # all other use of the material that constitutes the Autoconf Macro.
47 # This special exception to the GPL applies to versions of the Autoconf
48 # Macro released by the Autoconf Archive. When you make and distribute a
49 # modified version of the Autoconf Macro, you may extend this special
50 # exception to the GPL to apply to your modified version as well.
54 AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS])
55 AC_DEFUN([AX_PROG_JAVA_WORKS], [
56 if test x$ac_cv_prog_javac_works = xno; then
57 AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
59 if test x$ac_cv_prog_javac_works = x; then
62 AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
67 cat << \EOF > $JAVA_TEST
68 /* [#]line __oline__ "configure" */
70 public static void main (String args[]) {
75 if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
78 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
79 cat $JAVA_TEST >&AS_MESSAGE_LOG_FD
80 AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
82 if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then
83 ac_cv_prog_java_works=yes
85 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
86 cat $JAVA_TEST >&AS_MESSAGE_LOG_FD
87 AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
89 rm -f $JAVA_TEST $CLASS_TEST