Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / doc / gettext / examples / build-aux / javacomp.m4
blobbbca618386c9a134f0feb2496edc812cc988f06b
1 # javacomp.m4 serial 12
2 dnl Copyright (C) 2001-2003, 2006-2007, 2009-2010 Free Software Foundation,
3 dnl Inc.
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
15 #           1.3             inner classes
16 #           1.4             assert keyword
17 #           1.5             generic classes and methods
18 #           1.6             (not yet supported)
20 # target-version can be:  classfile version:
21 #           1.1                 45.3
22 #           1.2                 46.0
23 #           1.3                 47.0
24 #           1.4                 48.0
25 #           1.5                 49.0
26 #           1.6                 50.0
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
33 #           1.1         JDK 1.1, jview
34 #           1.2         JDK/JRE 1.2
35 #           1.3         JDK/JRE 1.3, gij 3.3, 3.4
36 #           1.4         JDK/JRE 1.4, gij 4.0, 4.1
37 #           1.5         JDK/JRE 1.5
38 #           1.6         JDK/JRE 1.6
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
57 # to 3.2 to be used.
59 AC_DEFUN([gt_JAVACOMP],
61   ifelse([$2], [], [AC_REQUIRE([gt_JAVAEXEC])], [])
62   AC_EGREP_CPP([yes], [
63 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
64   yes
65 #endif
66 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
67   source_version=$1
68   test -n "$source_version" || {
69     AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
70   }
71   ifelse([$2], [],
72     [if test -n "$HAVE_JAVAEXEC"; then
73        dnl Use $CONF_JAVA to determine the JVM's version.
74 changequote(,)dnl
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"));
79   }
81 EOF
82 changequote([,])dnl
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' \
93          | tr -d '\012\015' \
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' \
95          > conftestver.class
96        target_version=`{
97          unset JAVA_HOME
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
100        }`
101        case "$target_version" in
102          1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6) ;;
103          null)
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 ;;
108        esac
109      else
110        target_version="1.1"
111      fi
112     ],
113     [target_version=$2])
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]) ;;
122   esac
123   case "$target_version" in
124     1.1) cfversion=45 ;;
125     1.2) cfversion=46 ;;
126     1.3) cfversion=47 ;;
127     1.4) cfversion=48 ;;
128     1.5) cfversion=49 ;;
129     1.6) cfversion=50 ;;
130     *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
131   esac
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
134     # Use POSIX od.
135     func_classfile_version ()
136     {
137       od -A n -t d1 -j 7 -N 1 "[$]1"
138     }
139   else
140     # Use BSD hexdump.
141     func_classfile_version ()
142     {
143       dd if="[$]1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
144       echo
145     }
146   fi
147   AC_MSG_CHECKING([for Java compiler])
148   dnl
149   dnl The support of GNU gcj for target-version and source-version:
150   dnl
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.
158   dnl
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.
163   dnl
164   dnl The support of Sun javac for target-version and source-version:
165   dnl
166   dnl   javac 1.3:   -target 1.1 1.2 1.3               default: 1.1
167   dnl                                                  source always: 1.3
168   dnl
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
172   dnl
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
177   dnl
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
183   dnl
184   dnl The support of jikes for target-version and source-version:
185   dnl
186   dnl   jikes 1.14 does not have a way to specify the target-version. It
187   dnl   always assumes target-version=1.1.
188   dnl
189   dnl   For jikes 1.14, the source-version always is 1.3.
190   dnl
191   CONF_JAVAC=
192   HAVE_JAVAC_ENVVAR=
193   HAVE_GCJ_C=
194   HAVE_JAVAC=
195   HAVE_JIKES=
196   HAVE_JAVACOMP=
197 changequote(,)dnl
198   cat > conftestlib.java <<EOF
199 public class conftestlib {
200   public static void main (String[] args) {
201   }
204 changequote([,])dnl
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
209   dnl options).
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.
214 changequote(,)dnl
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
216 changequote([,])dnl
217         dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
218         dnl Try $JAVAC.
219         rm -f conftest.class
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
222            } \
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.
226           rm -f conftest.class
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
230              } \
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
235                 } \
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
239                   }; then
240             CONF_JAVAC="$JAVAC -fsource=$source_version"
241             HAVE_JAVAC_ENVVAR=1
242             HAVE_JAVACOMP=1
243           else
244             CONF_JAVAC="$JAVAC"
245             HAVE_JAVAC_ENVVAR=1
246             HAVE_JAVACOMP=1
247           fi
248         else
249           dnl Try with -fsource and -ftarget options.
250           rm -f conftest.class
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
254              } \
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"
258             HAVE_JAVAC_ENVVAR=1
259             HAVE_JAVACOMP=1
260           fi
261         fi
262       else
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
265           dnl Try $JAVAC.
266           rm -f conftest.class
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
269              } \
270              && test -f conftest.class; then
271             CONF_JAVAC="$JAVAC"
272             HAVE_JAVAC_ENVVAR=1
273             HAVE_JAVACOMP=1
274           fi
275         else
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.)
279             javac_works=
280             rm -f conftest.class
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
283                } \
284                && test -f conftest.class; then
285               javac_works=1
286             fi
287             javac_noassert_works=
288             rm -f conftest.class
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
291                } \
292                && test -f conftest.class; then
293               javac_noassert_works=1
294             fi
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
299                  } \
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
303                       }; then
304                 dnl "$JAVAC -fno-assert" works better than $JAVAC.
305                 javac_works=
306               fi
307             fi
308             if test -n "$javac_works"; then
309               CONF_JAVAC="$JAVAC"
310               HAVE_JAVAC_ENVVAR=1
311               HAVE_JAVACOMP=1
312             else
313               if test -n "$javac_noassert_works"; then
314                 CONF_JAVAC="$JAVAC -fno-assert"
315                 HAVE_JAVAC_ENVVAR=1
316                 HAVE_JAVACOMP=1
317               fi
318             fi
319           fi
320         fi
321       fi
322     else
323       dnl It's not gcj. Assume the classfile versions are correct.
324       dnl Try $JAVAC.
325       rm -f conftest.class
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
328          } \
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.
332         rm -f conftest.class
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
336            } \
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
341               } \
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
345                 }; then
346           CONF_JAVAC="$JAVAC -source $source_version"
347           HAVE_JAVAC_ENVVAR=1
348           HAVE_JAVACOMP=1
349         else
350           CONF_JAVAC="$JAVAC"
351           HAVE_JAVAC_ENVVAR=1
352           HAVE_JAVACOMP=1
353         fi
354       else
355         dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
356         dnl option but no -source option.)
357         rm -f conftest.class
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
360            } \
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.
364           rm -f conftest.class
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
368              } \
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
373                 } \
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
377                   }; then
378             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
379             HAVE_JAVAC_ENVVAR=1
380             HAVE_JAVACOMP=1
381           else
382             CONF_JAVAC="$JAVAC -target $target_version"
383             HAVE_JAVAC_ENVVAR=1
384             HAVE_JAVACOMP=1
385           fi
386         else
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
389           dnl higher.)
390           rm -f conftest.class
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
393              } \
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"
397             HAVE_JAVAC_ENVVAR=1
398             HAVE_JAVACOMP=1
399           fi
400         fi
401       fi
402     fi
403   fi
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).
416 changequote(,)dnl
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
418 changequote([,])dnl
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
422            }; then
423           dnl OK, gcj works.
424 changequote(,)dnl
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
426 changequote([,])dnl
427             dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
428             dnl Try gcj.
429             rm -f conftest.class
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
432                } \
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.
436               rm -f conftest.class
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
440                  } \
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
445                     } \
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
449                       }; then
450                 CONF_JAVAC="gcj -C -fsource=$source_version"
451                 HAVE_JAVAC_ENVVAR=1
452                 HAVE_JAVACOMP=1
453               else
454                 CONF_JAVAC="gcj -C"
455                 HAVE_JAVAC_ENVVAR=1
456                 HAVE_JAVACOMP=1
457               fi
458             else
459               dnl Try with -fsource and -ftarget options.
460               rm -f conftest.class
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
464                  } \
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"
468                 HAVE_JAVAC_ENVVAR=1
469                 HAVE_JAVACOMP=1
470               fi
471             fi
472           else
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
475             dnl source-version.
476             if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
477               rm -f conftest.class
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
480                  } \
481                  && test -f conftest.class; then
482                 CONF_JAVAC="gcj -C"
483                 HAVE_GCJ_C=1
484                 HAVE_JAVACOMP=1
485               fi
486             else
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).
490                 rm -f conftest.class
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
493                    } \
494                    && test -f conftest.class; then
495                   CONF_JAVAC="gcj -C -fno-assert"
496                   HAVE_GCJ_C=1
497                   HAVE_JAVACOMP=1
498                 else
499                   rm -f conftest.class
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
502                      } \
503                      && test -f conftest.class; then
504                     CONF_JAVAC="gcj -C"
505                     HAVE_GCJ_C=1
506                     HAVE_JAVACOMP=1
507                   fi
508                 fi
509               fi
510             fi
511           fi
512         fi
513       fi
514     fi
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
519         dnl OK, javac works.
520         dnl Now test whether it supports the desired target-version and
521         dnl source-version.
522         rm -f conftest.class
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
525            } \
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.
529           rm -f conftest.class
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
533              } \
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
538                 } \
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
542                   }; then
543             CONF_JAVAC="javac -source $source_version"
544             HAVE_JAVAC=1
545             HAVE_JAVACOMP=1
546           else
547             CONF_JAVAC="javac"
548             HAVE_JAVAC=1
549             HAVE_JAVACOMP=1
550           fi
551         else
552           dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
553           dnl option but no -source option.)
554           rm -f conftest.class
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
557              } \
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.
561             rm -f conftest.class
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
565                } \
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
570                   } \
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
574                     }; then
575               CONF_JAVAC="javac -target $target_version -source $source_version"
576               HAVE_JAVAC=1
577               HAVE_JAVACOMP=1
578             else
579               CONF_JAVAC="javac -target $target_version"
580               HAVE_JAVAC=1
581               HAVE_JAVACOMP=1
582             fi
583           else
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
586             dnl higher.)
587             rm -f conftest.class
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
590                } \
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"
594               HAVE_JAVAC=1
595               HAVE_JAVACOMP=1
596             fi
597           fi
598         fi
599       fi
600     fi
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; } \
604          && (
605               # See if the existing CLASSPATH is sufficient to make jikes work.
606               unset JAVA_HOME
607               jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
608               error=$?
609               rm -f conftestlib.class
610               exit $error
611             ); then
612         dnl OK, jikes works.
613         dnl Now test whether it supports the desired target-version and
614         dnl source-version.
615         if test "$source_version" = 1.3; then
616           CONF_JAVAC="jikes"
617           HAVE_JIKES=1
618           HAVE_JAVACOMP=1
619         fi
620       fi
621     fi
622   fi
623   rm -f conftest*.java conftest*.class
624   if test -n "$HAVE_JAVACOMP"; then
625     ac_result="$CONF_JAVAC"
626   else
627     ac_result="no"
628   fi
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])