New module 'mbsrchr'.
[gnulib.git] / m4 / javacomp.m4
1 # javacomp.m4 serial 9 (gettext-0.16.2)
2 dnl Copyright (C) 2001-2003, 2006-2007 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 # Prerequisites of javacomp.sh.
8 # gt_JAVACOMP([source-version], [target-version])
9 # Sets HAVE_JAVACOMP to nonempty if javacomp.sh will allow Java source code
10 # according to source-version to be compiled to Java bytecode classes in the
11 # target-version format.
12 #
13 # source-version can be:    support for
14 #           1.3             inner classes
15 #           1.4             assert keyword
16 #           1.5             generic classes and methods
17 #           1.6             (not yet supported)
18 #
19 # target-version can be:  classfile version:
20 #           1.1                 45.3
21 #           1.2                 46.0
22 #           1.3                 47.0
23 #           1.4                 48.0
24 #           1.5                 49.0
25 #           1.6                 50.0
26 # The classfile version of a .class file can be determined through the "file"
27 # command. More portably, the classfile major version can be determined through
28 # "od -A n -t d1 -j 7 -N 1 classfile".
29 # target-version can also be omitted. In this case, the required target-version
30 # is determined from the found JVM (see macro gt_JAVAEXEC):
31 #      target-version   for JVM
32 #           1.1         JDK 1.1, jview
33 #           1.2         JDK/JRE 1.2
34 #           1.3         JDK/JRE 1.3, gij 3.3, 3.4
35 #           1.4         JDK/JRE 1.4, gij 4.0, 4.1
36 #           1.5         JDK/JRE 1.5
37 #           1.6         JDK/JRE 1.6
38 # Note: gij >= 3.3 can in some cases handle classes compiled with -target 1.4,
39 # and gij >= 4.1 can in some cases partially handle classes compiled with
40 # -target 1.5, but I have no idea how complete this support is.
41 #
42 # Specifying target-version is useful when building a library (.jar) that is
43 # useful outside the given package. Omitting target-version is useful when
44 # building an application.
45 #
46 # It is unreasonable to ask for:
47 #   - target-version < 1.4 with source-version >= 1.4, or
48 #   - target-version < 1.5 with source-version >= 1.5, or
49 #   - target-version < 1.6 with source-version >= 1.6,
50 # because even Sun's javac doesn't support these combinations.
51 #
52 # It is redundant to ask for a target-version > source-version, since the
53 # smaller target-version = source-version will also always work and newer JVMs
54 # support the older target-versions too. Except for the case
55 # target-version = 1.4, source-version = 1.3, which allows gcj versions 3.0
56 # to 3.2 to be used.
57
58 AC_DEFUN([gt_JAVACOMP],
59 [
60   ifelse([$2], [], [AC_REQUIRE([gt_JAVAEXEC])], [])
61   AC_EGREP_CPP(yes, [
62 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
63   yes
64 #endif
65 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
66   source_version=$1
67   test -n "$source_version" || {
68     AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
69   }
70   ifelse([$2], [],
71     [if test -n "$HAVE_JAVAEXEC"; then
72        dnl Use $CONF_JAVA to determine the JVM's version.
73 changequote(,)dnl
74        cat > conftestver.java <<EOF
75 public class conftestver {
76   public static void main (String[] args) {
77     System.out.println(System.getProperty("java.specification.version"));
78   }
79 }
80 EOF
81 changequote([,])dnl
82        dnl A precompiled version of conftestver.java, compiled with
83        dnl "javac -target 1.1". This avoids having to compile conftestver.java
84        dnl during each test for a suitable Java compiler.
85        dnl For the conversion from binary to this ASCII encapsulation, avoiding
86        dnl to assume the presence of uudecode, use the command
87        dnl   $ od -A n -t o1 < conftestver.class | tr ' ' '\012'| sort | uniq | sed -e '/^$/d' -e 's,^,\\,' | tr -d '\012'
88        dnl and the long tr command in opposite direction.
89        echo 'xyvw!$!H!C,!)!2+!3!4*!5,!3!6,!7!8)!9)!:"!(LdhdmM"!$EFV"!%Ni_a"!1PdhaQngYakUXYfa"!%gXdh"!8EWPeXoXJfXhcJTmkdhcKFV"!,TinkZaOdfa"!2ZihbmalmoakIeXoX.!*!+)!;.!<!="!<eXoXIljaZdbdZXmdihIoakldih.!>!?)!@.!A!B"!-Zihbmalmoak"!2eXoXJfXhcJRYeaZm"!2eXoXJfXhcJTplmag"!$inm"!7PeXoXJdiJSkdhmTmkaXgK"!-camSkijakmp"!DEPeXoXJfXhcJTmkdhcKFPeXoXJfXhcJTmkdhcK"!5eXoXJdiJSkdhmTmkaXg"!)jkdhmfh"!7EPeXoXJfXhcJTmkdhcKFV!C!(!)!!!!!#!"!*!+!"!,!!!?!"!"!!!&Gt!"q!!!"!-!!!(!"!!!"!+!.!/!"!,!!!E!#!"!!!.r!#4$u!%s!&q!!!"!-!!!,!#!!!$!-!%!"!0!!!#!1' \
90          | tr -d '\012\015' \
91          | tr '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' '\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\055\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' \
92          > conftestver.class
93        target_version=`{
94          unset JAVA_HOME
95          echo "$as_me:__oline__: CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver" >&AS_MESSAGE_LOG_FD
96          CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver 2>&AS_MESSAGE_LOG_FD
97        }`
98        case "$target_version" in
99          1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6) ;;
100          null)
101            dnl JDK 1.1.X returns null.
102            target_version=1.1 ;;
103          *) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
104             target_version=1.1 ;;
105        esac
106      else
107        target_version="1.1"
108      fi
109     ],
110     [target_version=$2])
111   case "$source_version" in
112     1.3) goodcode='class conftest {}'
113          failcode='class conftestfail { static { assert(true); } }' ;;
114     1.4) goodcode='class conftest     { static { assert(true); } }'
115          failcode='class conftestfail<T> { T foo() { return null; } }' ;;
116     1.5) goodcode='class conftest<T>     { T foo() { return null; } }'
117          failcode='class conftestfail syntax error' ;;
118     *) AC_MSG_ERROR([invalid source-version argument to gt_@&t@JAVACOMP: $source_version]) ;;
119   esac
120   case "$target_version" in
121     1.1) cfversion=45 ;;
122     1.2) cfversion=46 ;;
123     1.3) cfversion=47 ;;
124     1.4) cfversion=48 ;;
125     1.5) cfversion=49 ;;
126     1.6) cfversion=50 ;;
127     *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
128   esac
129   # Function to output the classfile version of a file (8th byte) in decimal.
130   if od -A x < /dev/null >/dev/null 2>/dev/null; then
131     # Use POSIX od.
132     func_classfile_version ()
133     {
134       od -A n -t d1 -j 7 -N 1 "[$]1"
135     }
136   else
137     # Use BSD hexdump.
138     func_classfile_version ()
139     {
140       dd if="[$]1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
141       echo
142     }
143   fi
144   AC_MSG_CHECKING([for Java compiler])
145   dnl
146   dnl The support of GNU gcj for target-version and source-version:
147   dnl
148   dnl   gcj 3.0.4 to 4.2 does not have a way to specify the target-version.
149   dnl   It always assumes target-version=1.4 but labels the class files as 1.1.
150   dnl   One consequence of this is that gcj compiles GetURL.java to invalid
151   dnl   bytecode, which crashes with a VerifyError when executed by Sun Java
152   dnl   1.3.1. The bug is registered as java/7066, see
153   dnl   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
154   dnl   gcj 4.3 and newer has an option -ftarget=1.X.
155   dnl
156   dnl   For gcj < 3.3, the source-version always is 1.3.
157   dnl   For 3.3 <= gcj < 4.3, the source-version defaults to 1.4; option
158   dnl   "-fno-assert" switches to source-version 1.3.
159   dnl   gcj >= 4.3 has an option -fsource=1.X.
160   dnl
161   dnl The support of Sun javac for target-version and source-version:
162   dnl
163   dnl   javac 1.3:   -target 1.1 1.2 1.3               default: 1.1
164   dnl                                                  source always: 1.3
165   dnl
166   dnl   javac 1.4:   -target 1.1 1.2 1.3 1.4           default: 1.2
167   dnl                -source 1.3 1.4                   default: 1.3
168   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
169   dnl
170   dnl   javac 1.5:   -target 1.1 1.2 1.3 1.4 1.5       default: 1.5
171   dnl                -source 1.3 1.4 1.5               default: 1.5
172   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
173   dnl                -target 1.4 only possible with -source 1.3/1.4
174   dnl
175   dnl   javac 1.6:   -target 1.1 1.2 1.3 1.4 1.5 1.6   default: 1.6
176   dnl                -source 1.3 1.4 1.5 1.6           default: 1.5
177   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
178   dnl                -target 1.4 only possible with -source 1.3/1.4
179   dnl                -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
180   dnl
181   dnl The support of jikes for target-version and source-version:
182   dnl
183   dnl   jikes 1.14 does not have a way to specify the target-version. It
184   dnl   always assumes target-version=1.1.
185   dnl
186   dnl   For jikes 1.14, the source-version always is 1.3.
187   dnl
188   CONF_JAVAC=
189   HAVE_JAVAC_ENVVAR=
190   HAVE_GCJ_C=
191   HAVE_JAVAC=
192   HAVE_JIKES=
193   HAVE_JAVACOMP=
194 changequote(,)dnl
195   cat > conftestlib.java <<EOF
196 public class conftestlib {
197   public static void main (String[] args) {
198   }
199 }
200 EOF
201 changequote([,])dnl
202   echo "$goodcode" > conftest.java
203   echo "$failcode" > conftestfail.java
204   dnl If the user has set the JAVAC environment variable, use that, if it
205   dnl satisfies the constraints (possibly after adding -target and -source
206   dnl options).
207   if test -n "$JAVAC"; then
208     dnl Try the original $JAVAC.
209     if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
210       dnl It's a version of gcj.
211 changequote(,)dnl
212       if $JAVAC --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
213 changequote([,])dnl
214         dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
215         dnl Try $JAVAC.
216         rm -f conftest.class
217         if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
218              $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
219            } \
220            && test -f conftest.class \
221            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
222           dnl Try adding -fsource option if it is useful.
223           rm -f conftest.class
224           rm -f conftestfail.class
225           if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
226                $JAVAC -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
227              } \
228              && test -f conftest.class \
229              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
230              && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
231                   $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
232                 } \
233              && test -f conftestfail.class \
234              && ! { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
235                     $JAVAC -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
236                   }; then
237             CONF_JAVAC="$JAVAC -fsource=$source_version"
238             HAVE_JAVAC_ENVVAR=1
239             HAVE_JAVACOMP=1
240           else
241             CONF_JAVAC="$JAVAC"
242             HAVE_JAVAC_ENVVAR=1
243             HAVE_JAVACOMP=1
244           fi
245         else
246           dnl Try with -fsource and -ftarget options.
247           rm -f conftest.class
248           rm -f conftestfail.class
249           if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
250                $JAVAC -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
251              } \
252              && test -f conftest.class \
253              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
254             CONF_JAVAC="$JAVAC -fsource=$source_version -ftarget=$target_version"
255             HAVE_JAVAC_ENVVAR=1
256             HAVE_JAVACOMP=1
257           fi
258         fi
259       else
260         dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
261         if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
262           dnl Try $JAVAC.
263           rm -f conftest.class
264           if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
265                $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
266              } \
267              && test -f conftest.class; then
268             CONF_JAVAC="$JAVAC"
269             HAVE_JAVAC_ENVVAR=1
270             HAVE_JAVACOMP=1
271           fi
272         else
273           if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
274             dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
275             dnl it makes a difference. (It could already be part of $JAVAC.)
276             javac_works=
277             rm -f conftest.class
278             if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
279                  $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
280                } \
281                && test -f conftest.class; then
282               javac_works=1
283             fi
284             javac_noassert_works=
285             rm -f conftest.class
286             if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
287                  $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
288                } \
289                && test -f conftest.class; then
290               javac_noassert_works=1
291             fi
292             if test -n "$javac_works" && test -n "$javac_noassert_works"; then
293               rm -f conftestfail.class
294               if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
295                    $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
296                  } \
297                  && test -f conftestfail.class \
298                  && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
299                         $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
300                       }; then
301                 dnl "$JAVAC -fno-assert" works better than $JAVAC.
302                 javac_works=
303               fi
304             fi
305             if test -n "$javac_works"; then
306               CONF_JAVAC="$JAVAC"
307               HAVE_JAVAC_ENVVAR=1
308               HAVE_JAVACOMP=1
309             else
310               if test -n "$javac_noassert_works"; then
311                 CONF_JAVAC="$JAVAC -fno-assert"
312                 HAVE_JAVAC_ENVVAR=1
313                 HAVE_JAVACOMP=1
314               fi
315             fi
316           fi
317         fi
318       fi
319     else
320       dnl It's not gcj. Assume the classfile versions are correct.
321       dnl Try $JAVAC.
322       rm -f conftest.class
323       if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
324            $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
325          } \
326          && test -f conftest.class \
327          && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
328         dnl Try adding -source option if it is useful.
329         rm -f conftest.class
330         rm -f conftestfail.class
331         if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
332              $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
333            } \
334            && test -f conftest.class \
335            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
336            && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
337                 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
338               } \
339            && test -f conftestfail.class \
340            && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
341                   $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
342                 }; then
343           CONF_JAVAC="$JAVAC -source $source_version"
344           HAVE_JAVAC_ENVVAR=1
345           HAVE_JAVACOMP=1
346         else
347           CONF_JAVAC="$JAVAC"
348           HAVE_JAVAC_ENVVAR=1
349           HAVE_JAVACOMP=1
350         fi
351       else
352         dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
353         dnl option but no -source option.)
354         rm -f conftest.class
355         if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
356              $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
357            } \
358            && test -f conftest.class \
359            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
360           dnl Try adding -source option if it is useful.
361           rm -f conftest.class
362           rm -f conftestfail.class
363           if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
364                $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
365              } \
366              && test -f conftest.class \
367              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
368              && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
369                   $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
370                 } \
371              && test -f conftestfail.class \
372              && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
373                     $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
374                   }; then
375             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
376             HAVE_JAVAC_ENVVAR=1
377             HAVE_JAVACOMP=1
378           else
379             CONF_JAVAC="$JAVAC -target $target_version"
380             HAVE_JAVAC_ENVVAR=1
381             HAVE_JAVACOMP=1
382           fi
383         else
384           dnl Maybe this -target option requires a -source option? Try with
385           dnl -target and -source options. (Supported by Sun javac 1.4 and
386           dnl higher.)
387           rm -f conftest.class
388           if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
389                $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
390              } \
391              && test -f conftest.class \
392              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
393             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
394             HAVE_JAVAC_ENVVAR=1
395             HAVE_JAVACOMP=1
396           fi
397         fi
398       fi
399     fi
400   fi
401   if test -z "$HAVE_JAVACOMP"; then
402     pushdef([AC_MSG_CHECKING],[:])dnl
403     pushdef([AC_CHECKING],[:])dnl
404     pushdef([AC_MSG_RESULT],[:])dnl
405     AC_CHECK_PROG(HAVE_GCJ_IN_PATH, gcj, yes)
406     AC_CHECK_PROG(HAVE_JAVAC_IN_PATH, javac, yes)
407     AC_CHECK_PROG(HAVE_JIKES_IN_PATH, jikes, yes)
408     popdef([AC_MSG_RESULT])dnl
409     popdef([AC_CHECKING])dnl
410     popdef([AC_MSG_CHECKING])dnl
411     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
412       dnl Test for a good gcj version (>= 3.0).
413 changequote(,)dnl
414       if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
415 changequote([,])dnl
416         dnl See if libgcj.jar is well installed.
417         if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
418              gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
419            }; then
420           dnl OK, gcj works.
421 changequote(,)dnl
422           if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
423 changequote([,])dnl
424             dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
425             dnl Try gcj.
426             rm -f conftest.class
427             if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
428                  gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
429                } \
430                && test -f conftest.class \
431                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
432               dnl Try adding -fsource option if it is useful.
433               rm -f conftest.class
434               rm -f conftestfail.class
435               if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
436                    gcj -C -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
437                  } \
438                  && test -f conftest.class \
439                  && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
440                  && { echo "$as_me:__oline__: gcj -C -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
441                       gcj -C -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
442                     } \
443                  && test -f conftestfail.class \
444                  && ! { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
445                         gcj -C -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
446                       }; then
447                 CONF_JAVAC="gcj -C -fsource=$source_version"
448                 HAVE_JAVAC_ENVVAR=1
449                 HAVE_JAVACOMP=1
450               else
451                 CONF_JAVAC="gcj -C"
452                 HAVE_JAVAC_ENVVAR=1
453                 HAVE_JAVACOMP=1
454               fi
455             else
456               dnl Try with -fsource and -ftarget options.
457               rm -f conftest.class
458               rm -f conftestfail.class
459               if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
460                    gcj -C -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
461                  } \
462                  && test -f conftest.class \
463                  && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
464                 CONF_JAVAC="gcj -C -fsource=$source_version -ftarget=$target_version"
465                 HAVE_JAVAC_ENVVAR=1
466                 HAVE_JAVACOMP=1
467               fi
468             fi
469           else
470             dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
471             dnl Now test whether it supports the desired target-version and
472             dnl source-version.
473             if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
474               rm -f conftest.class
475               if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
476                    gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
477                  } \
478                  && test -f conftest.class; then
479                 CONF_JAVAC="gcj -C"
480                 HAVE_GCJ_C=1
481                 HAVE_JAVACOMP=1
482               fi
483             else
484               if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
485                 dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
486                 dnl it works (not gcj < 3.3).
487                 rm -f conftest.class
488                 if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
489                      gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
490                    } \
491                    && test -f conftest.class; then
492                   CONF_JAVAC="gcj -C -fno-assert"
493                   HAVE_GCJ_C=1
494                   HAVE_JAVACOMP=1
495                 else
496                   rm -f conftest.class
497                   if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
498                        gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
499                      } \
500                      && test -f conftest.class; then
501                     CONF_JAVAC="gcj -C"
502                     HAVE_GCJ_C=1
503                     HAVE_JAVACOMP=1
504                   fi
505                 fi
506               fi
507             fi
508           fi
509         fi
510       fi
511     fi
512     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
513       dnl Test whether javac is usable.
514       if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
515          && ( 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
516         dnl OK, javac works.
517         dnl Now test whether it supports the desired target-version and
518         dnl source-version.
519         rm -f conftest.class
520         if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
521              javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
522            } \
523            && test -f conftest.class \
524            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
525           dnl Try adding -source option if it is useful.
526           rm -f conftest.class
527           rm -f conftestfail.class
528           if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
529                javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
530              } \
531              && test -f conftest.class \
532              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
533              && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
534                   javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
535                 } \
536              && test -f conftestfail.class \
537              && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
538                     javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
539                   }; then
540             CONF_JAVAC="javac -source $source_version"
541             HAVE_JAVAC=1
542             HAVE_JAVACOMP=1
543           else
544             CONF_JAVAC="javac"
545             HAVE_JAVAC=1
546             HAVE_JAVACOMP=1
547           fi
548         else
549           dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
550           dnl option but no -source option.)
551           rm -f conftest.class
552           if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
553                javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
554              } \
555              && test -f conftest.class \
556              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
557             dnl Try adding -source option if it is useful.
558             rm -f conftest.class
559             rm -f conftestfail.class
560             if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
561                  javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
562                } \
563                && test -f conftest.class \
564                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
565                && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
566                     javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
567                   } \
568                && test -f conftestfail.class \
569                && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
570                       javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
571                     }; then
572               CONF_JAVAC="javac -target $target_version -source $source_version"
573               HAVE_JAVAC=1
574               HAVE_JAVACOMP=1
575             else
576               CONF_JAVAC="javac -target $target_version"
577               HAVE_JAVAC=1
578               HAVE_JAVACOMP=1
579             fi
580           else
581             dnl Maybe this -target option requires a -source option? Try with
582             dnl -target and -source options. (Supported by Sun javac 1.4 and
583             dnl higher.)
584             rm -f conftest.class
585             if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
586                  javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
587                } \
588                && test -f conftest.class \
589                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
590               CONF_JAVAC="javac -target $target_version -source $source_version"
591               HAVE_JAVAC=1
592               HAVE_JAVACOMP=1
593             fi
594           fi
595         fi
596       fi
597     fi
598     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
599       dnl Test whether jikes is usable.
600       if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
601          && (
602               # See if the existing CLASSPATH is sufficient to make jikes work.
603               unset JAVA_HOME
604               jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
605               error=$?
606               rm -f conftestlib.class
607               exit $error
608             ); then
609         dnl OK, jikes works.
610         dnl Now test whether it supports the desired target-version and
611         dnl source-version.
612         if test "$source_version" = 1.3; then
613           CONF_JAVAC="jikes"
614           HAVE_JIKES=1
615           HAVE_JAVACOMP=1
616         fi
617       fi
618     fi
619   fi
620   rm -f conftest*.java conftest*.class
621   if test -n "$HAVE_JAVACOMP"; then
622     ac_result="$CONF_JAVAC"
623   else
624     ac_result="no"
625   fi
626   AC_MSG_RESULT([$ac_result])
627   AC_SUBST(CONF_JAVAC)
628   AC_SUBST(CLASSPATH)
629   AC_SUBST(CLASSPATH_SEPARATOR)
630   AC_SUBST(HAVE_JAVAC_ENVVAR)
631   AC_SUBST(HAVE_GCJ_C)
632   AC_SUBST(HAVE_JAVAC)
633   AC_SUBST(HAVE_JIKES)
634 ])