1 # javacomp.m4 serial 12
2 dnl Copyright (C) 2001-2003, 2006-2007, 2009-2011 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
18 # 1.6 (not yet supported)
20 # target-version can be: classfile version:
27 # The classfile version of a .class file can be determined through the "file"
28 # command. More portably, the classfile major version can be determined through
29 # "od -A n -t d1 -j 7 -N 1 classfile".
30 # target-version can also be omitted. In this case, the required target-version
31 # is determined from the found JVM (see macro gt_JAVAEXEC):
32 # target-version for JVM
35 # 1.3 JDK/JRE 1.3, gij 3.3, 3.4
36 # 1.4 JDK/JRE 1.4, gij 4.0, 4.1
39 # Note: gij >= 3.3 can in some cases handle classes compiled with -target 1.4,
40 # and gij >= 4.1 can in some cases partially handle classes compiled with
41 # -target 1.5, but I have no idea how complete this support is.
43 # Specifying target-version is useful when building a library (.jar) that is
44 # useful outside the given package. Omitting target-version is useful when
45 # building an application.
47 # It is unreasonable to ask for:
48 # - target-version < 1.4 with source-version >= 1.4, or
49 # - target-version < 1.5 with source-version >= 1.5, or
50 # - target-version < 1.6 with source-version >= 1.6,
51 # because even Sun's javac doesn't support these combinations.
53 # It is redundant to ask for a target-version > source-version, since the
54 # smaller target-version = source-version will also always work and newer JVMs
55 # support the older target-versions too. Except for the case
56 # target-version = 1.4, source-version = 1.3, which allows gcj versions 3.0
59 AC_DEFUN([gt_JAVACOMP],
61 ifelse([$2], [], [AC_REQUIRE([gt_JAVAEXEC])], [])
63 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
66 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
68 test -n "$source_version" || {
69 AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
72 [if test -n "$HAVE_JAVAEXEC"; then
73 dnl Use $CONF_JAVA to determine the JVM's version.
75 cat > conftestver.java <<EOF
76 public class conftestver {
77 public static void main (String[] args) {
78 System.out.println(System.getProperty("java.specification.version"));
83 dnl A precompiled version of conftestver.java, compiled with
84 dnl "javac -target 1.1". This avoids having to compile conftestver.java
85 dnl during each test for a suitable Java compiler.
86 dnl For the conversion from binary to this ASCII encapsulation, avoiding
87 dnl to assume the presence of uudecode, use the command
88 dnl $ od -A n -t o1 < conftestver.class | tr ' ' '\012'| sort | uniq | sed -e '/^$/d' -e 's,^,\\,' | tr -d '\012'
89 dnl and the long tr command in opposite direction.
90 dnl Finally move the position corresponding to \055 to the last position,
91 dnl to work around a coreutils-5.x bug.
92 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' \
94 | 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' \
98 echo "$as_me:__oline__: CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver" >&AS_MESSAGE_LOG_FD
99 CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver 2>&AS_MESSAGE_LOG_FD
101 case "$target_version" in
102 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6) ;;
104 dnl JDK 1.1.X returns null.
105 target_version=1.1 ;;
106 *) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
107 target_version=1.1 ;;
114 case "$source_version" in
115 1.3) goodcode='class conftest {}'
116 failcode='class conftestfail { static { assert(true); } }' ;;
117 1.4) goodcode='class conftest { static { assert(true); } }'
118 failcode='class conftestfail<T> { T foo() { return null; } }' ;;
119 1.5) goodcode='class conftest<T> { T foo() { return null; } }'
120 failcode='class conftestfail syntax error' ;;
121 *) AC_MSG_ERROR([invalid source-version argument to gt_@&t@JAVACOMP: $source_version]) ;;
123 case "$target_version" in
130 *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
132 # Function to output the classfile version of a file (8th byte) in decimal.
133 if od -A x < /dev/null >/dev/null 2>/dev/null; then
135 func_classfile_version ()
137 od -A n -t d1 -j 7 -N 1 "[$]1"
141 func_classfile_version ()
143 dd if="[$]1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
147 AC_MSG_CHECKING([for Java compiler])
149 dnl The support of GNU gcj for target-version and source-version:
151 dnl gcj 3.0.4 to 4.2 does not have a way to specify the target-version.
152 dnl It always assumes target-version=1.4 but labels the class files as 1.1.
153 dnl One consequence of this is that gcj compiles GetURL.java to invalid
154 dnl bytecode, which crashes with a VerifyError when executed by Sun Java
155 dnl 1.3.1. The bug is registered as java/7066, see
156 dnl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
157 dnl gcj 4.3 and newer has an option -ftarget=1.X.
159 dnl For gcj < 3.3, the source-version always is 1.3.
160 dnl For 3.3 <= gcj < 4.3, the source-version defaults to 1.4; option
161 dnl "-fno-assert" switches to source-version 1.3.
162 dnl gcj >= 4.3 has an option -fsource=1.X.
164 dnl The support of Sun javac for target-version and source-version:
166 dnl javac 1.3: -target 1.1 1.2 1.3 default: 1.1
167 dnl source always: 1.3
169 dnl javac 1.4: -target 1.1 1.2 1.3 1.4 default: 1.2
170 dnl -source 1.3 1.4 default: 1.3
171 dnl -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
173 dnl javac 1.5: -target 1.1 1.2 1.3 1.4 1.5 default: 1.5
174 dnl -source 1.3 1.4 1.5 default: 1.5
175 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
176 dnl -target 1.4 only possible with -source 1.3/1.4
178 dnl javac 1.6: -target 1.1 1.2 1.3 1.4 1.5 1.6 default: 1.6
179 dnl -source 1.3 1.4 1.5 1.6 default: 1.5
180 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
181 dnl -target 1.4 only possible with -source 1.3/1.4
182 dnl -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
184 dnl The support of jikes for target-version and source-version:
186 dnl jikes 1.14 does not have a way to specify the target-version. It
187 dnl always assumes target-version=1.1.
189 dnl For jikes 1.14, the source-version always is 1.3.
198 cat > conftestlib.java <<EOF
199 public class conftestlib {
200 public static void main (String[] args) {
205 echo "$goodcode" > conftest.java
206 echo "$failcode" > conftestfail.java
207 dnl If the user has set the JAVAC environment variable, use that, if it
208 dnl satisfies the constraints (possibly after adding -target and -source
210 if test -n "$JAVAC"; then
211 dnl Try the original $JAVAC.
212 if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
213 dnl It's a version of gcj.
215 if $JAVAC --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
217 dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
220 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
221 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
223 && test -f conftest.class \
224 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
225 dnl Try adding -fsource option if it is useful.
227 rm -f conftestfail.class
228 if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
229 $JAVAC -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
231 && test -f conftest.class \
232 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
233 && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
234 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
236 && test -f conftestfail.class \
237 && ! { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
238 $JAVAC -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
240 CONF_JAVAC="$JAVAC -fsource=$source_version"
249 dnl Try with -fsource and -ftarget options.
251 rm -f conftestfail.class
252 if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
253 $JAVAC -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
255 && test -f conftest.class \
256 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
257 CONF_JAVAC="$JAVAC -fsource=$source_version -ftarget=$target_version"
263 dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
264 if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
267 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
268 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
270 && test -f conftest.class; then
276 if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
277 dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
278 dnl it makes a difference. (It could already be part of $JAVAC.)
281 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
282 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
284 && test -f conftest.class; then
287 javac_noassert_works=
289 if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
290 $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
292 && test -f conftest.class; then
293 javac_noassert_works=1
295 if test -n "$javac_works" && test -n "$javac_noassert_works"; then
296 rm -f conftestfail.class
297 if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
298 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
300 && test -f conftestfail.class \
301 && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
302 $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
304 dnl "$JAVAC -fno-assert" works better than $JAVAC.
308 if test -n "$javac_works"; then
313 if test -n "$javac_noassert_works"; then
314 CONF_JAVAC="$JAVAC -fno-assert"
323 dnl It's not gcj. Assume the classfile versions are correct.
326 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
327 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
329 && test -f conftest.class \
330 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
331 dnl Try adding -source option if it is useful.
333 rm -f conftestfail.class
334 if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
335 $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
337 && test -f conftest.class \
338 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
339 && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
340 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
342 && test -f conftestfail.class \
343 && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
344 $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
346 CONF_JAVAC="$JAVAC -source $source_version"
355 dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
356 dnl option but no -source option.)
358 if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
359 $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
361 && test -f conftest.class \
362 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
363 dnl Try adding -source option if it is useful.
365 rm -f conftestfail.class
366 if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
367 $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
369 && test -f conftest.class \
370 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
371 && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
372 $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
374 && test -f conftestfail.class \
375 && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
376 $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
378 CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
382 CONF_JAVAC="$JAVAC -target $target_version"
387 dnl Maybe this -target option requires a -source option? Try with
388 dnl -target and -source options. (Supported by Sun javac 1.4 and
391 if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
392 $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
394 && test -f conftest.class \
395 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
396 CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
404 if test -z "$HAVE_JAVACOMP"; then
405 pushdef([AC_MSG_CHECKING],[:])dnl
406 pushdef([AC_CHECKING],[:])dnl
407 pushdef([AC_MSG_RESULT],[:])dnl
408 AC_CHECK_PROG([HAVE_GCJ_IN_PATH], [gcj], [yes])
409 AC_CHECK_PROG([HAVE_JAVAC_IN_PATH], [javac], [yes])
410 AC_CHECK_PROG([HAVE_JIKES_IN_PATH], [jikes], [yes])
411 popdef([AC_MSG_RESULT])dnl
412 popdef([AC_CHECKING])dnl
413 popdef([AC_MSG_CHECKING])dnl
414 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
415 dnl Test for a good gcj version (>= 3.0).
417 if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
419 dnl See if libgcj.jar is well installed.
420 if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
421 gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
425 if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
427 dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
430 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
431 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
433 && test -f conftest.class \
434 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
435 dnl Try adding -fsource option if it is useful.
437 rm -f conftestfail.class
438 if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
439 gcj -C -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
441 && test -f conftest.class \
442 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
443 && { echo "$as_me:__oline__: gcj -C -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
444 gcj -C -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
446 && test -f conftestfail.class \
447 && ! { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
448 gcj -C -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
450 CONF_JAVAC="gcj -C -fsource=$source_version"
459 dnl Try with -fsource and -ftarget options.
461 rm -f conftestfail.class
462 if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
463 gcj -C -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
465 && test -f conftest.class \
466 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
467 CONF_JAVAC="gcj -C -fsource=$source_version -ftarget=$target_version"
473 dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
474 dnl Now test whether it supports the desired target-version and
476 if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
478 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
479 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
481 && test -f conftest.class; then
487 if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
488 dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
489 dnl it works (not gcj < 3.3).
491 if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
492 gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
494 && test -f conftest.class; then
495 CONF_JAVAC="gcj -C -fno-assert"
500 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
501 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
503 && test -f conftest.class; then
515 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
516 dnl Test whether javac is usable.
517 if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
518 && ( 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
520 dnl Now test whether it supports the desired target-version and
523 if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
524 javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
526 && test -f conftest.class \
527 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
528 dnl Try adding -source option if it is useful.
530 rm -f conftestfail.class
531 if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
532 javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
534 && test -f conftest.class \
535 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
536 && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
537 javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
539 && test -f conftestfail.class \
540 && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
541 javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
543 CONF_JAVAC="javac -source $source_version"
552 dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
553 dnl option but no -source option.)
555 if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
556 javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
558 && test -f conftest.class \
559 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
560 dnl Try adding -source option if it is useful.
562 rm -f conftestfail.class
563 if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
564 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
566 && test -f conftest.class \
567 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
568 && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
569 javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
571 && test -f conftestfail.class \
572 && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
573 javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
575 CONF_JAVAC="javac -target $target_version -source $source_version"
579 CONF_JAVAC="javac -target $target_version"
584 dnl Maybe this -target option requires a -source option? Try with
585 dnl -target and -source options. (Supported by Sun javac 1.4 and
588 if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
589 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
591 && test -f conftest.class \
592 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
593 CONF_JAVAC="javac -target $target_version -source $source_version"
601 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
602 dnl Test whether jikes is usable.
603 if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
605 # See if the existing CLASSPATH is sufficient to make jikes work.
607 jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
609 rm -f conftestlib.class
613 dnl Now test whether it supports the desired target-version and
615 if test "$source_version" = 1.3; then
623 rm -f conftest*.java conftest*.class
624 if test -n "$HAVE_JAVACOMP"; then
625 ac_result="$CONF_JAVAC"
629 AC_MSG_RESULT([$ac_result])
630 AC_SUBST([CONF_JAVAC])
631 AC_SUBST([CLASSPATH])
632 AC_SUBST([CLASSPATH_SEPARATOR])
633 AC_SUBST([HAVE_JAVAC_ENVVAR])
634 AC_SUBST([HAVE_GCJ_C])
635 AC_SUBST([HAVE_JAVAC])
636 AC_SUBST([HAVE_JIKES])