1 # javacomp.m4 serial 13
2 dnl Copyright (C) 2001-2003, 2006-2007, 2009-2017 Free Software Foundation,
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Prerequisites of javacomp.sh.
9 # gt_JAVACOMP([source-version], [target-version])
10 # Sets HAVE_JAVACOMP to nonempty if javacomp.sh will allow Java source code
11 # according to source-version to be compiled to Java bytecode classes in the
12 # target-version format.
14 # source-version can be: support for
17 # 1.5 generic classes and methods
21 # Instead of source-version 1.6, use 1.5, since Java 6 did not introduce any
22 # language changes. See
23 # https://docs.oracle.com/javase/8/docs/technotes/guides/language/enhancements.html
25 # target-version can be: classfile version:
34 # The classfile version of a .class file can be determined through the "file"
35 # command. More portably, the classfile major version can be determined through
36 # "od -A n -t d1 -j 7 -N 1 classfile".
37 # target-version can also be omitted. In this case, the required target-version
38 # is determined from the found JVM (see macro gt_JAVAEXEC):
39 # target-version for JVM
42 # 1.3 JDK/JRE 1.3, gij 3.3, 3.4
43 # 1.4 JDK/JRE 1.4, gij 4.0, 4.1
48 # Note: gij >= 3.3 can in some cases handle classes compiled with -target 1.4,
49 # and gij >= 4.1 can in some cases partially handle classes compiled with
50 # -target 1.5, but I have no idea how complete this support is.
52 # Specifying target-version is useful when building a library (.jar) that is
53 # useful outside the given package. Omitting target-version is useful when
54 # building an application.
56 # It is unreasonable to ask for:
57 # - target-version < 1.4 with source-version >= 1.4, or
58 # - target-version < 1.5 with source-version >= 1.5, or
59 # - target-version < 1.6 with source-version >= 1.6,
60 # because even Sun's/Oracle's javac doesn't support these combinations.
62 # It is redundant to ask for a target-version > source-version, since the
63 # smaller target-version = source-version will also always work and newer JVMs
64 # support the older target-versions too. Except for the case
65 # target-version = 1.4, source-version = 1.3, which allows gcj versions 3.0
68 AC_DEFUN([gt_JAVACOMP],
70 ifelse([$2], [], [AC_REQUIRE([gt_JAVAEXEC])], [])
72 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
75 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
77 test -n "$source_version" || {
78 AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
81 [if test -n "$HAVE_JAVAEXEC"; then
82 dnl Use $CONF_JAVA to determine the JVM's version.
84 cat > conftestver.java <<EOF
85 public class conftestver {
86 public static void main (String[] args) {
87 System.out.println(System.getProperty("java.specification.version"));
92 dnl A precompiled version of conftestver.java, compiled with
93 dnl "javac -target 1.1". This avoids having to compile conftestver.java
94 dnl during each test for a suitable Java compiler.
95 dnl For the conversion from binary to this ASCII encapsulation, avoiding
96 dnl to assume the presence of uudecode, use the command
97 dnl $ od -A n -t o1 < conftestver.class | tr ' ' '\012'| sort | uniq | sed -e '/^$/d' -e 's,^,\\,' | tr -d '\012'
98 dnl and the long tr command in opposite direction.
99 dnl Finally move the position corresponding to \055 to the last position,
100 dnl to work around a coreutils-5.x bug.
101 echo 'yzwx!$!I!D,!)!3+!4!5*!6,!4!7,!8!9)!:)!;"!(MeienN"!$FGW"!%Ojab"!2QeibRohZblVYZgb"!%hYei"!9FXQfYpYKgYidKUnleidLGW"!,Ujol_bPegb"!3_jicnbmnpblJfYpY/!*!+)!</!=!>"!=fYpYJmkb_ece_YnejiJpblmeji/!?!@)!A/!B!C"!._jicnbmnpbl"!3fYpYKgYidKSZfb_n"!3fYpYKgYidKUqmnbh"!$jon"!8QfYpYKejKTleinUnlbYhL"!.dbnTljkblnq"!EFQfYpYKgYidKUnleidLGQfYpYKgYidKUnleidL"!6fYpYKejKTleinUnlbYh"!)kleingi"!8FQfYpYKgYidKUnleidLGW!D!(!)!!!!!#!"!*!+!"!,!!!@!"!"!!!&Hu!"r!!!"!.!!!(!"!!!"!+!/!0!"!,!!!F!#!"!!!/s!#5$v!%t!&r!!!"!.!!!,!#!!!$!.!%!"!1!!!#!2' \
103 | tr '!"#$%&()*+,./0123456789:;<=>?@ABCDEFGHJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzI' '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\046\050\051\052\056\057\073\074\076\103\106\114\116\117\120\123\124\126\133\141\142\143\144\145\146\147\151\152\154\155\156\157\160\162\163\164\165\166\171\261\262\266\267\270\272\276\312\376\055' \
107 echo "$as_me:__oline__: CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver" >&AS_MESSAGE_LOG_FD
108 CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver 2>&AS_MESSAGE_LOG_FD
110 case "$target_version" in
111 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6 | 1.7 | 1.8) ;;
113 dnl JDK 1.1.X returns null.
114 target_version=1.1 ;;
115 *) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
116 target_version=1.1 ;;
123 case "$source_version" in
124 1.3) goodcode='class conftest {}'
125 failcode='class conftestfail { static { assert(true); } }' ;;
126 1.4) goodcode='class conftest { static { assert(true); } }'
127 failcode='class conftestfail<T> { T foo() { return null; } }' ;;
128 1.5) goodcode='class conftest<T> { T foo() { return null; } }'
129 failcode='class conftestfail { void foo () { switch ("A") {} } }' ;;
130 1.7) goodcode='class conftest { void foo () { switch ("A") {} } }'
131 failcode='class conftestfail { void foo () { Runnable r = () -> {}; } }' ;;
132 1.8) goodcode='class conftest { void foo () { Runnable r = () -> {}; } }'
133 failcode='class conftestfail syntax error' ;;
134 *) AC_MSG_ERROR([invalid source-version argument to gt_@&t@JAVACOMP: $source_version]) ;;
136 case "$target_version" in
145 *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
147 # Function to output the classfile version of a file (8th byte) in decimal.
148 if od -A x < /dev/null >/dev/null 2>/dev/null; then
150 func_classfile_version ()
152 od -A n -t d1 -j 7 -N 1 "[$]1"
156 func_classfile_version ()
158 dd if="[$]1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
162 AC_MSG_CHECKING([for Java compiler])
164 dnl The support of GNU gcj for target-version and source-version:
166 dnl gcj 3.0.4 to 4.2 does not have a way to specify the target-version.
167 dnl It always assumes target-version=1.4 but labels the class files as 1.1.
168 dnl One consequence of this is that gcj compiles GetURL.java to invalid
169 dnl bytecode, which crashes with a VerifyError when executed by Sun Java
170 dnl 1.3.1. The bug is registered as java/7066, see
171 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
172 dnl gcj 4.3 and newer has an option -ftarget=1.X.
174 dnl For gcj < 3.3, the source-version always is 1.3.
175 dnl For 3.3 <= gcj < 4.3, the source-version defaults to 1.4; option
176 dnl "-fno-assert" switches to source-version 1.3.
177 dnl gcj >= 4.3 has an option -fsource=1.X.
179 dnl The support of Sun/Oracle javac for target-version and source-version:
181 dnl javac 1.3: -target 1.1 1.2 1.3 default: 1.1
182 dnl source always: 1.3
184 dnl javac 1.4: -target 1.1 1.2 1.3 1.4 default: 1.2
185 dnl -source 1.3 1.4 default: 1.3
186 dnl -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
188 dnl javac 1.5: -target 1.1 1.2 1.3 1.4 1.5 default: 1.5
189 dnl -source 1.3 1.4 1.5 default: 1.5
190 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
191 dnl -target 1.4 only possible with -source 1.3/1.4
193 dnl javac 1.6: -target 1.1 1.2 1.3 1.4 1.5 1.6 default: 1.6
194 dnl -source 1.3 1.4 1.5 1.6 default: 1.5
195 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
196 dnl -target 1.4 only possible with -source 1.3/1.4
197 dnl -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
199 dnl javac 1.7: -target 1.1 1.2 1.3 1.4 1.5 1.6 1.7 default: 1.7
200 dnl -source 1.3 1.4 1.5 1.6 1.7 default: 1.7
201 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
202 dnl -target 1.4 only possible with -source 1.3/1.4
203 dnl -target 1.5 only possible with -source 1.3/1.4/1.5
204 dnl -target 1.6 only possible with -source 1.3/1.4/1.5/1.6
206 dnl javac 1.8: -target 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 default: 1.8
207 dnl -source [1.3 1.4 1.5] 1.6 1.7 1.8 default: 1.8
208 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
209 dnl -target 1.4 only possible with -source 1.3/1.4
210 dnl -target 1.5 only possible with -source 1.3/1.4/1.5
211 dnl -target 1.6 only possible with -source 1.3/1.4/1.5/1.6
212 dnl -target 1.7 only possible with -source 1.3/1.4/1.5/1.6/1.7
214 dnl The support of jikes for target-version and source-version:
216 dnl jikes 1.14 does not have a way to specify the target-version. It
217 dnl always assumes target-version=1.1.
219 dnl For jikes 1.14, the source-version always is 1.3.
228 cat > conftestlib.java <<EOF
229 public class conftestlib {
230 public static void main (String[] args) {
235 echo "$goodcode" > conftest.java
236 echo "$failcode" > conftestfail.java
237 dnl If the user has set the JAVAC environment variable, use that, if it
238 dnl satisfies the constraints (possibly after adding -target and -source
240 if test -n "$JAVAC"; then
241 dnl Try the original $JAVAC.
242 if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
243 dnl It's a version of gcj.
245 if $JAVAC --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
247 dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
250 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
251 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
253 && test -f conftest.class \
254 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
255 dnl Try adding -fsource option if it is useful.
257 rm -f conftestfail.class
258 if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
259 $JAVAC -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
261 && test -f conftest.class \
262 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
263 && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
264 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
266 && test -f conftestfail.class \
267 && ! { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
268 $JAVAC -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
270 CONF_JAVAC="$JAVAC -fsource=$source_version"
279 dnl Try with -fsource and -ftarget options.
281 rm -f conftestfail.class
282 if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
283 $JAVAC -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
285 && test -f conftest.class \
286 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
287 CONF_JAVAC="$JAVAC -fsource=$source_version -ftarget=$target_version"
293 dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
294 if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
297 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
298 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
300 && test -f conftest.class; then
306 if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
307 dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
308 dnl it makes a difference. (It could already be part of $JAVAC.)
311 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
312 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
314 && test -f conftest.class; then
317 javac_noassert_works=
319 if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
320 $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
322 && test -f conftest.class; then
323 javac_noassert_works=1
325 if test -n "$javac_works" && test -n "$javac_noassert_works"; then
326 rm -f conftestfail.class
327 if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
328 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
330 && test -f conftestfail.class \
331 && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
332 $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
334 dnl "$JAVAC -fno-assert" works better than $JAVAC.
338 if test -n "$javac_works"; then
343 if test -n "$javac_noassert_works"; then
344 CONF_JAVAC="$JAVAC -fno-assert"
353 dnl It's not gcj. Assume the classfile versions are correct.
356 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
357 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
359 && test -f conftest.class \
360 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
361 dnl Try adding -source option if it is useful.
363 rm -f conftestfail.class
364 if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
365 $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
367 && test -f conftest.class \
368 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
369 && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
370 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
372 && test -f conftestfail.class \
373 && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
374 $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
376 CONF_JAVAC="$JAVAC -source $source_version"
385 dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
386 dnl option but no -source option.)
388 if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
389 $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
391 && test -f conftest.class \
392 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
393 dnl Try adding -source option if it is useful.
395 rm -f conftestfail.class
396 if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
397 $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
399 && test -f conftest.class \
400 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
401 && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
402 $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
404 && test -f conftestfail.class \
405 && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
406 $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
408 CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
412 CONF_JAVAC="$JAVAC -target $target_version"
417 dnl Maybe this -target option requires a -source option? Try with
418 dnl -target and -source options. (Supported by Sun javac 1.4 and
421 if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
422 $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
424 && test -f conftest.class \
425 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
426 CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
434 if test -z "$HAVE_JAVACOMP"; then
435 pushdef([AC_MSG_CHECKING],[:])dnl
436 pushdef([AC_CHECKING],[:])dnl
437 pushdef([AC_MSG_RESULT],[:])dnl
438 AC_CHECK_PROG([HAVE_GCJ_IN_PATH], [gcj], [yes])
439 AC_CHECK_PROG([HAVE_JAVAC_IN_PATH], [javac], [yes])
440 AC_CHECK_PROG([HAVE_JIKES_IN_PATH], [jikes], [yes])
441 popdef([AC_MSG_RESULT])dnl
442 popdef([AC_CHECKING])dnl
443 popdef([AC_MSG_CHECKING])dnl
444 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
445 dnl Test for a good gcj version (>= 3.0).
447 if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
449 dnl See if libgcj.jar is well installed.
450 if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
451 gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
455 if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
457 dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
460 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
461 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
463 && test -f conftest.class \
464 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
465 dnl Try adding -fsource option if it is useful.
467 rm -f conftestfail.class
468 if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
469 gcj -C -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
471 && test -f conftest.class \
472 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
473 && { echo "$as_me:__oline__: gcj -C -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
474 gcj -C -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
476 && test -f conftestfail.class \
477 && ! { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
478 gcj -C -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
480 CONF_JAVAC="gcj -C -fsource=$source_version"
489 dnl Try with -fsource and -ftarget options.
491 rm -f conftestfail.class
492 if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
493 gcj -C -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
495 && test -f conftest.class \
496 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
497 CONF_JAVAC="gcj -C -fsource=$source_version -ftarget=$target_version"
503 dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
504 dnl Now test whether it supports the desired target-version and
506 if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
508 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
509 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
511 && test -f conftest.class; then
517 if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
518 dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
519 dnl it works (not gcj < 3.3).
521 if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
522 gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
524 && test -f conftest.class; then
525 CONF_JAVAC="gcj -C -fno-assert"
530 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
531 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
533 && test -f conftest.class; then
545 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
546 dnl Test whether javac is usable.
547 if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
548 && ( if javac -help 2>&1 >/dev/null | grep at.dms.kjc.Main >/dev/null && javac -help 2>/dev/null | grep 'released.*2000' >/dev/null ; then exit 1; else exit 0; fi ); then
550 dnl Now test whether it supports the desired target-version and
553 if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
554 javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
556 && test -f conftest.class \
557 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
558 dnl Try adding -source option if it is useful.
560 rm -f conftestfail.class
561 if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
562 javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
564 && test -f conftest.class \
565 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
566 && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
567 javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
569 && test -f conftestfail.class \
570 && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
571 javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
573 CONF_JAVAC="javac -source $source_version"
582 dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
583 dnl option but no -source option.)
585 if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
586 javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
588 && test -f conftest.class \
589 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
590 dnl Try adding -source option if it is useful.
592 rm -f conftestfail.class
593 if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
594 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
596 && test -f conftest.class \
597 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
598 && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
599 javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
601 && test -f conftestfail.class \
602 && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
603 javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
605 CONF_JAVAC="javac -target $target_version -source $source_version"
609 CONF_JAVAC="javac -target $target_version"
614 dnl Maybe this -target option requires a -source option? Try with
615 dnl -target and -source options. (Supported by Sun javac 1.4 and
618 if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
619 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
621 && test -f conftest.class \
622 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
623 CONF_JAVAC="javac -target $target_version -source $source_version"
631 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
632 dnl Test whether jikes is usable.
633 if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
635 # See if the existing CLASSPATH is sufficient to make jikes work.
637 jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
639 rm -f conftestlib.class
643 dnl Now test whether it supports the desired target-version and
645 if test "$source_version" = 1.3; then
653 rm -f conftest*.java conftest*.class
654 if test -n "$HAVE_JAVACOMP"; then
655 ac_result="$CONF_JAVAC"
659 AC_MSG_RESULT([$ac_result])
660 AC_SUBST([CONF_JAVAC])
661 AC_SUBST([CLASSPATH])
662 AC_SUBST([CLASSPATH_SEPARATOR])
663 AC_SUBST([HAVE_JAVAC_ENVVAR])
664 AC_SUBST([HAVE_GCJ_C])
665 AC_SUBST([HAVE_JAVAC])
666 AC_SUBST([HAVE_JIKES])