* lib/fnmatch.c (WIDE_CHAR_SUPPORT): Require HAVE_ISWCTYPE, too.
[gnulib.git] / m4 / javacomp.m4
1 # javacomp.m4 serial 8 (gettext-0.15)
2 dnl Copyright (C) 2001-2003, 2006 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.1 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   FIXME: Check new versions of gcj as they come out.
155   dnl
156   dnl   For gcj < 3.3, the source-version always is 1.3.
157   dnl   For gcj >= 3.3, the source-version defaults to 1.4; option
158   dnl   "-fno-assert" switches to source-version 1.3.
159   dnl
160   dnl The support of Sun javac for target-version and source-version:
161   dnl
162   dnl   javac 1.3:   -target 1.1 1.2 1.3               default: 1.1
163   dnl                                                  source always: 1.3
164   dnl
165   dnl   javac 1.4:   -target 1.1 1.2 1.3 1.4           default: 1.2
166   dnl                -source 1.3 1.4                   default: 1.3
167   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
168   dnl
169   dnl   javac 1.5:   -target 1.1 1.2 1.3 1.4 1.5       default: 1.5
170   dnl                -source 1.3 1.4 1.5               default: 1.5
171   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
172   dnl                -target 1.4 only possible with -source 1.3/1.4
173   dnl
174   dnl   javac 1.6:   -target 1.1 1.2 1.3 1.4 1.5 1.6   default: 1.6
175   dnl                -source 1.3 1.4 1.5 1.6           default: 1.5
176   dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
177   dnl                -target 1.4 only possible with -source 1.3/1.4
178   dnl                -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
179   dnl
180   dnl The support of jikes for target-version and source-version:
181   dnl
182   dnl   jikes 1.14 does not have a way to specify the target-version. It
183   dnl   always assumes target-version=1.1.
184   dnl
185   dnl   For jikes 1.14, the source-version always is 1.3.
186   dnl
187   CONF_JAVAC=
188   HAVE_JAVAC_ENVVAR=
189   HAVE_GCJ_C=
190   HAVE_JAVAC=
191   HAVE_JIKES=
192   HAVE_JAVACOMP=
193 changequote(,)dnl
194   cat > conftestlib.java <<EOF
195 public class conftestlib {
196   public static void main (String[] args) {
197   }
198 }
199 EOF
200 changequote([,])dnl
201   echo "$goodcode" > conftest.java
202   echo "$failcode" > conftestfail.java
203   dnl If the user has set the JAVAC environment variable, use that, if it
204   dnl satisfies the constraints (possibly after adding -target and -source
205   dnl options).
206   if test -n "$JAVAC"; then
207     dnl Try the original $JAVAC.
208     if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
209       dnl It's a version of gcj. Ignore the version of conftest.class.
210       if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
211         dnl Try $JAVAC.
212         rm -f conftest.class
213         if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
214              $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
215            } \
216            && test -f conftest.class; then
217           CONF_JAVAC="$JAVAC"
218           HAVE_JAVAC_ENVVAR=1
219           HAVE_JAVACOMP=1
220         fi
221       else
222         if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
223           dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
224           dnl it makes a difference. (It could already be part of $JAVAC.)
225           javac_works=
226           rm -f conftest.class
227           if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
228                $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
229              } \
230              && test -f conftest.class; then
231             javac_works=1
232           fi
233           javac_noassert_works=
234           rm -f conftest.class
235           if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
236                $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
237              } \
238              && test -f conftest.class; then
239             javac_noassert_works=1
240           fi
241           if test -n "$javac_works" && test -n "$javac_noassert_works"; then
242             rm -f conftestfail.class
243             if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
244                  $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
245                } \
246                && test -f conftestfail.class \
247                && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
248                       $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
249                     }; then
250               dnl "$JAVAC -fno-assert" works better than $JAVAC.
251               javac_works=
252             fi
253           fi
254           if test -n "$javac_works"; then
255             CONF_JAVAC="$JAVAC"
256             HAVE_JAVAC_ENVVAR=1
257             HAVE_JAVACOMP=1
258           else
259             if test -n "$javac_noassert_works"; then
260               CONF_JAVAC="$JAVAC -fno-assert"
261               HAVE_JAVAC_ENVVAR=1
262               HAVE_JAVACOMP=1
263             fi
264           fi
265         fi
266       fi
267     else
268       dnl It's not gcj. Assume the classfile versions are correct.
269       dnl Try $JAVAC.
270       rm -f conftest.class
271       if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
272            $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
273          } \
274          && test -f conftest.class \
275          && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
276         dnl Try adding -source option if it is useful.
277         rm -f conftest.class
278         rm -f conftestfail.class
279         if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
280              $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
281            } \
282            && test -f conftest.class \
283            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
284            && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
285                 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
286               } \
287            && test -f conftestfail.class \
288            && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
289                   $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
290                 }; then
291           CONF_JAVAC="$JAVAC -source $source_version"
292           HAVE_JAVAC_ENVVAR=1
293           HAVE_JAVACOMP=1
294         else
295           CONF_JAVAC="$JAVAC"
296           HAVE_JAVAC_ENVVAR=1
297           HAVE_JAVACOMP=1
298         fi
299       else
300         dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
301         dnl option but no -source option.)
302         rm -f conftest.class
303         if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
304              $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
305            } \
306            && test -f conftest.class \
307            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
308           dnl Try adding -source option if it is useful.
309           rm -f conftest.class
310           rm -f conftestfail.class
311           if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
312                $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
313              } \
314              && test -f conftest.class \
315              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
316              && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
317                   $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
318                 } \
319              && test -f conftestfail.class \
320              && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
321                     $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
322                   }; then
323             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
324             HAVE_JAVAC_ENVVAR=1
325             HAVE_JAVACOMP=1
326           else
327             CONF_JAVAC="$JAVAC -target $target_version"
328             HAVE_JAVAC_ENVVAR=1
329             HAVE_JAVACOMP=1
330           fi
331         else
332           dnl Maybe this -target option requires a -source option? Try with
333           dnl -target and -source options. (Supported by Sun javac 1.4 and
334           dnl higher.)
335           rm -f conftest.class
336           if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
337                $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
338              } \
339              && test -f conftest.class \
340              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
341             CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
342             HAVE_JAVAC_ENVVAR=1
343             HAVE_JAVACOMP=1
344           fi
345         fi
346       fi
347     fi
348   fi
349   if test -z "$HAVE_JAVACOMP"; then
350     pushdef([AC_MSG_CHECKING],[:])dnl
351     pushdef([AC_CHECKING],[:])dnl
352     pushdef([AC_MSG_RESULT],[:])dnl
353     AC_CHECK_PROG(HAVE_GCJ_IN_PATH, gcj, yes)
354     AC_CHECK_PROG(HAVE_JAVAC_IN_PATH, javac, yes)
355     AC_CHECK_PROG(HAVE_JIKES_IN_PATH, jikes, yes)
356     popdef([AC_MSG_RESULT])dnl
357     popdef([AC_CHECKING])dnl
358     popdef([AC_MSG_CHECKING])dnl
359     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
360       dnl Test for a good gcj version (>= 3.0).
361 changequote(,)dnl
362       if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
363 changequote([,])dnl
364         dnl See if libgcj.jar is well installed.
365         if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
366              gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
367            }; then
368           dnl OK, gcj works.
369           dnl Now test whether it supports the desired target-version and
370           dnl source-version. But ignore the version of conftest.class.
371           if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
372             rm -f conftest.class
373             if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
374                  gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
375                } \
376                && test -f conftest.class; then
377               CONF_JAVAC="gcj -C"
378               HAVE_GCJ_C=1
379               HAVE_JAVACOMP=1
380             fi
381           else
382             if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
383               dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
384               dnl it works (not gcj < 3.3).
385               rm -f conftest.class
386               if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
387                    gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
388                  } \
389                  && test -f conftest.class; then
390                 CONF_JAVAC="gcj -C -fno-assert"
391                 HAVE_GCJ_C=1
392                 HAVE_JAVACOMP=1
393               else
394                 rm -f conftest.class
395                 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
396                      gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
397                    } \
398                    && test -f conftest.class; then
399                   CONF_JAVAC="gcj -C"
400                   HAVE_GCJ_C=1
401                   HAVE_JAVACOMP=1
402                 fi
403               fi
404             fi
405           fi
406         fi
407       fi
408     fi
409     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
410       dnl Test whether javac is usable.
411       if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
412          && ( 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
413         dnl OK, javac works.
414         dnl Now test whether it supports the desired target-version and
415         dnl source-version.
416         rm -f conftest.class
417         if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
418              javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
419            } \
420            && test -f conftest.class \
421            && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
422           dnl Try adding -source option if it is useful.
423           rm -f conftest.class
424           rm -f conftestfail.class
425           if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
426                javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
427              } \
428              && test -f conftest.class \
429              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
430              && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
431                   javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
432                 } \
433              && test -f conftestfail.class \
434              && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
435                     javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
436                   }; then
437             CONF_JAVAC="javac -source $source_version"
438             HAVE_JAVAC=1
439             HAVE_JAVACOMP=1
440           else
441             CONF_JAVAC="javac"
442             HAVE_JAVAC=1
443             HAVE_JAVACOMP=1
444           fi
445         else
446           dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
447           dnl option but no -source option.)
448           rm -f conftest.class
449           if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
450                javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
451              } \
452              && test -f conftest.class \
453              && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
454             dnl Try adding -source option if it is useful.
455             rm -f conftest.class
456             rm -f conftestfail.class
457             if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
458                  javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
459                } \
460                && test -f conftest.class \
461                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
462                && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
463                     javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
464                   } \
465                && test -f conftestfail.class \
466                && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
467                       javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
468                     }; then
469               CONF_JAVAC="javac -target $target_version -source $source_version"
470               HAVE_JAVAC=1
471               HAVE_JAVACOMP=1
472             else
473               CONF_JAVAC="javac -target $target_version"
474               HAVE_JAVAC=1
475               HAVE_JAVACOMP=1
476             fi
477           else
478             dnl Maybe this -target option requires a -source option? Try with
479             dnl -target and -source options. (Supported by Sun javac 1.4 and
480             dnl higher.)
481             rm -f conftest.class
482             if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
483                  javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
484                } \
485                && test -f conftest.class \
486                && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
487               CONF_JAVAC="javac -target $target_version -source $source_version"
488               HAVE_JAVAC=1
489               HAVE_JAVACOMP=1
490             fi
491           fi
492         fi
493       fi
494     fi
495     if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
496       dnl Test whether jikes is usable.
497       if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
498          && (
499               # See if the existing CLASSPATH is sufficient to make jikes work.
500               unset JAVA_HOME
501               jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
502               error=$?
503               rm -f conftestlib.class
504               exit $error
505             ); then
506         dnl OK, jikes works.
507         dnl Now test whether it supports the desired target-version and
508         dnl source-version.
509         if test "$source_version" = 1.3; then
510           CONF_JAVAC="jikes"
511           HAVE_JIKES=1
512           HAVE_JAVACOMP=1
513         fi
514       fi
515     fi
516   fi
517   rm -f conftest*.java conftest*.class
518   if test -n "$HAVE_JAVACOMP"; then
519     ac_result="$CONF_JAVAC"
520   else
521     ac_result="no"
522   fi
523   AC_MSG_RESULT([$ac_result])
524   AC_SUBST(CONF_JAVAC)
525   AC_SUBST(CLASSPATH)
526   AC_SUBST(CLASSPATH_SEPARATOR)
527   AC_SUBST(HAVE_JAVAC_ENVVAR)
528   AC_SUBST(HAVE_GCJ_C)
529   AC_SUBST(HAVE_JAVAC)
530   AC_SUBST(HAVE_JIKES)
531 ])