1# ===========================================================================
2#     https://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_PROG_JAVA_CC
8#
9# DESCRIPTION
10#
11#   Finds the appropriate java compiler on your path. By preference the java
12#   compiler is gcj, then jikes then javac.
13#
14#   The macro can take one argument specifying a space separated list of
15#   java compiler names.
16#
17#   For example:
18#
19#     AX_PROG_JAVA_CC(javac, gcj)
20#
21#   The macro also sets the compiler options variable: JAVA_CC_OPTS to
22#   something sensible:
23#
24#    - for GCJ it sets it to: @GCJ_OPTS@
25#      (if GCJ_OPTS is not yet defined then it is set to "-C")
26#
27#    - no other compiler has applicable options yet
28#
29#   Here's an example configure.in:
30#
31#     AC_INIT(Makefile.in)
32#     AX_PROG_JAVA_CC()
33#     AC_OUTPUT(Makefile)
34#     dnl End.
35#
36#   And here's the start of the Makefile.in:
37#
38#     PROJECT_ROOT      := @srcdir@
39#     # Tool definitions.
40#     JAVAC             := @JAVA_CC@
41#     JAVAC_OPTS        := @JAVA_CC_OPTS@
42#     JAR_TOOL          := @jar_tool@
43#
44# LICENSE
45#
46#   Copyright (c) 2008 Nic Ferrier <nferrier@tapsellferrier.co.uk>
47#
48#   This program is free software; you can redistribute it and/or modify it
49#   under the terms of the GNU General Public License as published by the
50#   Free Software Foundation; either version 2 of the License, or (at your
51#   option) any later version.
52#
53#   This program is distributed in the hope that it will be useful, but
54#   WITHOUT ANY WARRANTY; without even the implied warranty of
55#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
56#   Public License for more details.
57#
58#   You should have received a copy of the GNU General Public License along
59#   with this program. If not, see <https://www.gnu.org/licenses/>.
60#
61#   As a special exception, the respective Autoconf Macro's copyright owner
62#   gives unlimited permission to copy, distribute and modify the configure
63#   scripts that are the output of Autoconf when processing the Macro. You
64#   need not follow the terms of the GNU General Public License when using
65#   or distributing such scripts, even though portions of the text of the
66#   Macro appear in them. The GNU General Public License (GPL) does govern
67#   all other use of the material that constitutes the Autoconf Macro.
68#
69#   This special exception to the GPL applies to versions of the Autoconf
70#   Macro released by the Autoconf Archive. When you make and distribute a
71#   modified version of the Autoconf Macro, you may extend this special
72#   exception to the GPL to apply to your modified version as well.
73
74#serial 5
75
76# AX_PROG_JAVA_CC([COMPILER ...])
77# --------------------------
78# COMPILER ... is a space separated list of java compilers to search for.
79# This just gives the user an opportunity to specify an alternative
80# search list for the java compiler.
81AU_ALIAS([AC_PROG_JAVA_CC], [AX_PROG_JAVA_CC])
82AC_DEFUN([AX_PROG_JAVA_CC],
83[AC_ARG_VAR([JAVA_CC],                [java compiler command])dnl
84AC_ARG_VAR([JAVA_CC_FLAGS],           [java compiler flags])dnl
85m4_ifval([$1],
86      [AC_CHECK_TOOLS(JAVA_CC, [$1])],
87[AC_CHECK_TOOL(JAVA_CC, gcj)
88if test -z "$JAVA_CC"; then
89  AC_CHECK_TOOL(JAVA_CC, javac)
90fi
91if test -z "$JAVA_CC"; then
92  AC_CHECK_TOOL(JAVA_CC, jikes)
93fi
94])
95
96if test "$JAVA_CC" = "gcj"; then
97   if test "$GCJ_OPTS" = ""; then
98      AC_SUBST(GCJ_OPTS,-C)
99   fi
100   AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@,
101        [Define the compilation options for GCJ])
102fi
103test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH])
104])# AX_PROG_JAVA_CC
105