Update version number, from gettext-0.17.
[gnulib.git] / m4 / javacomp.m4
1 # javacomp.m4 serial 10
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        dnl Finally move the position corresponding to \055 to the last position,
90        dnl to work around a coreutils-5.x bug.
91        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' \
92          | tr -d '\012\015' \
93          | tr '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzH' '\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' \
94          > conftestver.class
95        target_version=`{
96          unset JAVA_HOME
97          echo "$as_me:__oline__: CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver" >&AS_MESSAGE_LOG_FD
98          CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver 2>&AS_MESSAGE_LOG_FD
99        }`
100        case "$target_version" in
101          1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6) ;;
102          null)
103            dnl JDK 1.1.X returns null.
104            target_version=1.1 ;;
105          *) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
106             target_version=1.1 ;;
107        esac
108      else
109        target_version="1.1"
110      fi
111     ],
112     [target_version=$2])
113   case "$source_version" in
114     1.3) goodcode='class conftest {}'
115          failcode='class conftestfail { static { assert(true); } }' ;;
116     1.4) goodcode='class conftest     { static { assert(true); } }'
117          failcode='class conftestfail<T> { T foo() { return null; } }' ;;
118     1.5) goodcode='class conftest<T>     { T foo() { return null; } }'
119          failcode='class conftestfail syntax error' ;;
120     *) AC_MSG_ERROR([invalid source-version argument to gt_@&t@JAVACOMP: $source_version]) ;;
121   esac
122   case "$target_version" in
123     1.1) cfversion=45 ;;
124     1.2) cfversion=46 ;;
125     1.3) cfversion=47 ;;
126     1.4) cfversion=48 ;;
127     1.5) cfversion=49 ;;
128     1.6) cfversion=50 ;;
129     *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
130   esac
131   # Function to output the classfile version of a file (8th byte) in decimal.
132   if od -A x < /dev/null >/dev/null 2>/dev/null; then
133     # Use POSIX od.
134     func_classfile_version ()
135     {
136       od -A n -t d1 -j 7 -N 1 "[$]1"
137     }
138   else
139     # Use BSD hexdump.
140     func_classfile_version ()
141     {
142       dd if="[$]1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
143       echo
144     }
145   fi
146   AC_MSG_CHECKING([for Java compiler])
147   dnl
148   dnl The support of GNU gcj for target-version and source-version:
149   dnl
150   dnl   gcj 3.0.4 to 4.2 does not have a way to specify the target-version.
151   dnl   It always assumes target-version=1.4 but labels the class files as 1.1.
152   dnl   One consequence of this is that gcj compiles GetURL.java to invalid
153   dnl   bytecode, which crashes with a VerifyError when executed by Sun Java
154   dnl   1.3.1. The bug is registered as java/7066, see
155   dnl   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
156   dnl   gcj 4.3 and newer has an option -ftarget=1.X.
157   dnl
158   dnl   For gcj < 3.3, the source-version always is 1.3.
159   dnl   For 3.3 <= gcj < 4.3, the source-version defaults to 1.4; option
160   dnl   "-fno-assert" switches to source-version 1.3.
161   dnl   gcj >= 4.3 has an option -fsource=1.X.
162   dnl
163   dnl The support of Sun javac for target-version and source-version:
164   dnl
165   dnl   javac 1.3:   -target 1.1 1.2 1.3               default: 1.1
166   dnl                                                  source always: 1.3
167   dnl
168   dnl   javac 1.4:   -target 1.1 1.2 1.3 1.4           default: 1.2
169   dnl                -source 1.3 1.4                   default: 1.3
170   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
171   dnl
172   dnl   javac 1.5:   -target 1.1 1.2 1.3 1.4 1.5       default: 1.5
173   dnl                -source 1.3 1.4 1.5               default: 1.5
174   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
175   dnl                -target 1.4 only possible with -source 1.3/1.4
176   dnl
177   dnl   javac 1.6:   -target 1.1 1.2 1.3 1.4 1.5 1.6   default: 1.6
178   dnl                -source 1.3 1.4 1.5 1.6           default: 1.5
179   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
180   dnl                -target 1.4 only possible with -source 1.3/1.4
181   dnl                -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
182   dnl
183   dnl The support of jikes for target-version and source-version:
184   dnl
185   dnl   jikes 1.14 does not have a way to specify the target-version. It
186   dnl   always assumes target-version=1.1.
187   dnl
188   dnl   For jikes 1.14, the source-version always is 1.3.
189   dnl
190   CONF_JAVAC=
191   HAVE_JAVAC_ENVVAR=
192   HAVE_GCJ_C=
193   HAVE_JAVAC=
194   HAVE_JIKES=
195   HAVE_JAVACOMP=
196 changequote(,)dnl
197   cat > conftestlib.java <<EOF
198 public class conftestlib {
199   public static void main (String[] args) {
200   }
201 }
202 EOF
203 changequote([,])dnl
204   echo "$goodcode" > conftest.java
205   echo "$failcode" > conftestfail.java
206   dnl If the user has set the JAVAC environment variable, use that, if it
207   dnl satisfies the constraints (possibly after adding -target and -source
208   dnl options).
209   if test -n "$JAVAC"; then
210     dnl Try the original $JAVAC.
211     if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
212       dnl It's a version of gcj.
213 changequote(,)dnl
214       if $JAVAC --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
215 changequote([,])dnl
216         dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
217         dnl Try $JAVAC.
218         rm -f conftest.class
219         if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
220              $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
221            } \
222            && test -f conftest.class \
223            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
224           dnl Try adding -fsource option if it is useful.
225           rm -f conftest.class
226           rm -f conftestfail.class
227           if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
228                $JAVAC -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
229              } \
230              && test -f conftest.class \
231              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
232              && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
233                   $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
234                 } \
235              && test -f conftestfail.class \
236              && ! { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
237                     $JAVAC -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
238                   }; then
239             CONF_JAVAC="$JAVAC -fsource=$source_version"
240             HAVE_JAVAC_ENVVAR=1
241             HAVE_JAVACOMP=1
242           else
243             CONF_JAVAC="$JAVAC"
244             HAVE_JAVAC_ENVVAR=1
245             HAVE_JAVACOMP=1
246           fi
247         else
248           dnl Try with -fsource and -ftarget options.
249           rm -f conftest.class
250           rm -f conftestfail.class
251           if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
252                $JAVAC -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
253              } \
254              && test -f conftest.class \
255              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
256             CONF_JAVAC="$JAVAC -fsource=$source_version -ftarget=$target_version"
257             HAVE_JAVAC_ENVVAR=1
258             HAVE_JAVACOMP=1
259           fi
260         fi
261       else
262         dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
263         if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
264           dnl Try $JAVAC.
265           rm -f conftest.class
266           if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
267                $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
268              } \
269              && test -f conftest.class; then
270             CONF_JAVAC="$JAVAC"
271             HAVE_JAVAC_ENVVAR=1
272             HAVE_JAVACOMP=1
273           fi
274         else
275           if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
276             dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
277             dnl it makes a difference. (It could already be part of $JAVAC.)
278             javac_works=
279             rm -f conftest.class
280             if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
281                  $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
282                } \
283                && test -f conftest.class; then
284               javac_works=1
285             fi
286             javac_noassert_works=
287             rm -f conftest.class
288             if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
289                  $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
290                } \
291                && test -f conftest.class; then
292               javac_noassert_works=1
293             fi
294             if test -n "$javac_works" && test -n "$javac_noassert_works"; then
295               rm -f conftestfail.class
296               if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
297                    $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
298                  } \
299                  && test -f conftestfail.class \
300                  && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
301                         $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
302                       }; then
303                 dnl "$JAVAC -fno-assert" works better than $JAVAC.
304                 javac_works=
305               fi
306             fi
307             if test -n "$javac_works"; then
308               CONF_JAVAC="$JAVAC"
309               HAVE_JAVAC_ENVVAR=1
310               HAVE_JAVACOMP=1
311             else
312               if test -n "$javac_noassert_works"; then
313                 CONF_JAVAC="$JAVAC -fno-assert"
314                 HAVE_JAVAC_ENVVAR=1
315                 HAVE_JAVACOMP=1
316               fi
317             fi
318           fi
319         fi
320       fi
321     else
322       dnl It's not gcj. Assume the classfile versions are correct.
323       dnl Try $JAVAC.
324       rm -f conftest.class
325       if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
326            $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
327          } \
328          && test -f conftest.class \
329          && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
330         dnl Try adding -source option if it is useful.
331         rm -f conftest.class
332         rm -f conftestfail.class
333         if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
334              $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
335            } \
336            && test -f conftest.class \
337            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
338            && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
339                 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
340               } \
341            && test -f conftestfail.class \
342            && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
343                   $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
344                 }; then
345           CONF_JAVAC="$JAVAC -source $source_version"
346           HAVE_JAVAC_ENVVAR=1
347           HAVE_JAVACOMP=1
348         else
349           CONF_JAVAC="$JAVAC"
350           HAVE_JAVAC_ENVVAR=1
351           HAVE_JAVACOMP=1
352         fi
353       else
354         dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
355         dnl option but no -source option.)
356         rm -f conftest.class
357         if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
358              $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
359            } \
360            && test -f conftest.class \
361            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
362           dnl Try adding -source option if it is useful.
363           rm -f conftest.class
364           rm -f conftestfail.class
365           if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
366                $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
367              } \
368              && test -f conftest.class \
369              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
370              && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
371                   $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
372                 } \
373              && test -f conftestfail.class \
374              && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
375                     $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
376                   }; then
377             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
378             HAVE_JAVAC_ENVVAR=1
379             HAVE_JAVACOMP=1
380           else
381             CONF_JAVAC="$JAVAC -target $target_version"
382             HAVE_JAVAC_ENVVAR=1
383             HAVE_JAVACOMP=1
384           fi
385         else
386           dnl Maybe this -target option requires a -source option? Try with
387           dnl -target and -source options. (Supported by Sun javac 1.4 and
388           dnl higher.)
389           rm -f conftest.class
390           if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
391                $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
392              } \
393              && test -f conftest.class \
394              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
395             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
396             HAVE_JAVAC_ENVVAR=1
397             HAVE_JAVACOMP=1
398           fi
399         fi
400       fi
401     fi
402   fi
403   if test -z "$HAVE_JAVACOMP"; then
404     pushdef([AC_MSG_CHECKING],[:])dnl
405     pushdef([AC_CHECKING],[:])dnl
406     pushdef([AC_MSG_RESULT],[:])dnl
407     AC_CHECK_PROG(HAVE_GCJ_IN_PATH, gcj, yes)
408     AC_CHECK_PROG(HAVE_JAVAC_IN_PATH, javac, yes)
409     AC_CHECK_PROG(HAVE_JIKES_IN_PATH, jikes, yes)
410     popdef([AC_MSG_RESULT])dnl
411     popdef([AC_CHECKING])dnl
412     popdef([AC_MSG_CHECKING])dnl
413     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
414       dnl Test for a good gcj version (>= 3.0).
415 changequote(,)dnl
416       if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
417 changequote([,])dnl
418         dnl See if libgcj.jar is well installed.
419         if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
420              gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
421            }; then
422           dnl OK, gcj works.
423 changequote(,)dnl
424           if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
425 changequote([,])dnl
426             dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
427             dnl Try gcj.
428             rm -f conftest.class
429             if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
430                  gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
431                } \
432                && test -f conftest.class \
433                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
434               dnl Try adding -fsource option if it is useful.
435               rm -f conftest.class
436               rm -f conftestfail.class
437               if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
438                    gcj -C -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
439                  } \
440                  && test -f conftest.class \
441                  && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
442                  && { echo "$as_me:__oline__: gcj -C -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
443                       gcj -C -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
444                     } \
445                  && test -f conftestfail.class \
446                  && ! { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
447                         gcj -C -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
448                       }; then
449                 CONF_JAVAC="gcj -C -fsource=$source_version"
450                 HAVE_JAVAC_ENVVAR=1
451                 HAVE_JAVACOMP=1
452               else
453                 CONF_JAVAC="gcj -C"
454                 HAVE_JAVAC_ENVVAR=1
455                 HAVE_JAVACOMP=1
456               fi
457             else
458               dnl Try with -fsource and -ftarget options.
459               rm -f conftest.class
460               rm -f conftestfail.class
461               if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
462                    gcj -C -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
463                  } \
464                  && test -f conftest.class \
465                  && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
466                 CONF_JAVAC="gcj -C -fsource=$source_version -ftarget=$target_version"
467                 HAVE_JAVAC_ENVVAR=1
468                 HAVE_JAVACOMP=1
469               fi
470             fi
471           else
472             dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
473             dnl Now test whether it supports the desired target-version and
474             dnl source-version.
475             if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
476               rm -f conftest.class
477               if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
478                    gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
479                  } \
480                  && test -f conftest.class; then
481                 CONF_JAVAC="gcj -C"
482                 HAVE_GCJ_C=1
483                 HAVE_JAVACOMP=1
484               fi
485             else
486               if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
487                 dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
488                 dnl it works (not gcj < 3.3).
489                 rm -f conftest.class
490                 if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
491                      gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
492                    } \
493                    && test -f conftest.class; then
494                   CONF_JAVAC="gcj -C -fno-assert"
495                   HAVE_GCJ_C=1
496                   HAVE_JAVACOMP=1
497                 else
498                   rm -f conftest.class
499                   if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
500                        gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
501                      } \
502                      && test -f conftest.class; then
503                     CONF_JAVAC="gcj -C"
504                     HAVE_GCJ_C=1
505                     HAVE_JAVACOMP=1
506                   fi
507                 fi
508               fi
509             fi
510           fi
511         fi
512       fi
513     fi
514     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
515       dnl Test whether javac is usable.
516       if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
517          && ( 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
518         dnl OK, javac works.
519         dnl Now test whether it supports the desired target-version and
520         dnl source-version.
521         rm -f conftest.class
522         if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
523              javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
524            } \
525            && test -f conftest.class \
526            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
527           dnl Try adding -source option if it is useful.
528           rm -f conftest.class
529           rm -f conftestfail.class
530           if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
531                javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
532              } \
533              && test -f conftest.class \
534              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
535              && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
536                   javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
537                 } \
538              && test -f conftestfail.class \
539              && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
540                     javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
541                   }; then
542             CONF_JAVAC="javac -source $source_version"
543             HAVE_JAVAC=1
544             HAVE_JAVACOMP=1
545           else
546             CONF_JAVAC="javac"
547             HAVE_JAVAC=1
548             HAVE_JAVACOMP=1
549           fi
550         else
551           dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
552           dnl option but no -source option.)
553           rm -f conftest.class
554           if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
555                javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
556              } \
557              && test -f conftest.class \
558              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
559             dnl Try adding -source option if it is useful.
560             rm -f conftest.class
561             rm -f conftestfail.class
562             if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
563                  javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
564                } \
565                && test -f conftest.class \
566                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
567                && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
568                     javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
569                   } \
570                && test -f conftestfail.class \
571                && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
572                       javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
573                     }; then
574               CONF_JAVAC="javac -target $target_version -source $source_version"
575               HAVE_JAVAC=1
576               HAVE_JAVACOMP=1
577             else
578               CONF_JAVAC="javac -target $target_version"
579               HAVE_JAVAC=1
580               HAVE_JAVACOMP=1
581             fi
582           else
583             dnl Maybe this -target option requires a -source option? Try with
584             dnl -target and -source options. (Supported by Sun javac 1.4 and
585             dnl higher.)
586             rm -f conftest.class
587             if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
588                  javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
589                } \
590                && test -f conftest.class \
591                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
592               CONF_JAVAC="javac -target $target_version -source $source_version"
593               HAVE_JAVAC=1
594               HAVE_JAVACOMP=1
595             fi
596           fi
597         fi
598       fi
599     fi
600     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
601       dnl Test whether jikes is usable.
602       if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
603          && (
604               # See if the existing CLASSPATH is sufficient to make jikes work.
605               unset JAVA_HOME
606               jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
607               error=$?
608               rm -f conftestlib.class
609               exit $error
610             ); then
611         dnl OK, jikes works.
612         dnl Now test whether it supports the desired target-version and
613         dnl source-version.
614         if test "$source_version" = 1.3; then
615           CONF_JAVAC="jikes"
616           HAVE_JIKES=1
617           HAVE_JAVACOMP=1
618         fi
619       fi
620     fi
621   fi
622   rm -f conftest*.java conftest*.class
623   if test -n "$HAVE_JAVACOMP"; then
624     ac_result="$CONF_JAVAC"
625   else
626     ac_result="no"
627   fi
628   AC_MSG_RESULT([$ac_result])
629   AC_SUBST(CONF_JAVAC)
630   AC_SUBST(CLASSPATH)
631   AC_SUBST(CLASSPATH_SEPARATOR)
632   AC_SUBST(HAVE_JAVAC_ENVVAR)
633   AC_SUBST(HAVE_GCJ_C)
634   AC_SUBST(HAVE_JAVAC)
635   AC_SUBST(HAVE_JIKES)
636 ])