annotate lib/javacomp.c @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Compile a Java program.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
2 Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 9161
diff changeset
5 This program is free software: you can redistribute it and/or modify
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 9161
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 9161
diff changeset
8 (at your option) any later version.
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 9161
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
7304
1c4ed7637c24 Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 7022
diff changeset
18 #include <config.h>
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <alloca.h>
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 /* Specification. */
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include "javacomp.h"
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
24 #include <errno.h>
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
25 #include <limits.h>
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include <stdio.h>
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <stdlib.h>
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include <string.h>
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
29 #include <unistd.h>
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
30 #include <sys/types.h>
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
31 #include <sys/stat.h>
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
33 #include "javaversion.h"
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #include "execute.h"
13924
5be0c314f2f8 Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
35 #include "spawn-pipe.h"
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 #include "wait-process.h"
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 #include "classpath.h"
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #include "xsetenv.h"
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 #include "sh-quote.h"
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
40 #include "binary-io.h"
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 #include "safe-read.h"
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 #include "xalloc.h"
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
43 #include "xmalloca.h"
10391
f0a681493fa6 New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents: 10197
diff changeset
44 #include "concat-filename.h"
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
45 #include "fwriteerror.h"
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
46 #include "clean-temp.h"
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 #include "error.h"
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
48 #include "xvasprintf.h"
7974
ace01389ef5b Small optimization.
Bruno Haible <bruno@clisp.org>
parents: 7944
diff changeset
49 #include "c-strstr.h"
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 #include "gettext.h"
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 #define _(str) gettext (str)
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53
7863
cb2590895141 New module 'fchdir'.
Bruno Haible <bruno@clisp.org>
parents: 7412
diff changeset
54 /* The results of open() in this file are not used with fchdir,
cb2590895141 New module 'fchdir'.
Bruno Haible <bruno@clisp.org>
parents: 7412
diff changeset
55 therefore save some unnecessary work in fchdir.c. */
cb2590895141 New module 'fchdir'.
Bruno Haible <bruno@clisp.org>
parents: 7412
diff changeset
56 #undef open
cb2590895141 New module 'fchdir'.
Bruno Haible <bruno@clisp.org>
parents: 7412
diff changeset
57 #undef close
cb2590895141 New module 'fchdir'.
Bruno Haible <bruno@clisp.org>
parents: 7412
diff changeset
58
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 /* Survey of Java compilers.
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 A = does it work without CLASSPATH being set
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 C = option to set CLASSPATH, other than setting it in the environment
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 O = option for optimizing
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 g = option for debugging
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 T = test for presence
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 Program from A C O g T
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 $JAVAC unknown N n/a -O -g true
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 gcj -C GCC 3.2 Y --classpath=P -O -g gcj --version | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 javac JDK 1.1.8 Y -classpath P -O -g javac 2>/dev/null; test $? = 1
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 javac JDK 1.3.0 Y -classpath P -O -g javac 2>/dev/null; test $? -le 2
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 jikes Jikes 1.14 N -classpath P -O -g jikes 2>/dev/null; test $? = 1
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 All compilers support the option "-d DIRECTORY" for the base directory
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 of the classes to be written.
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 The CLASSPATH is a colon separated list of pathnames. (On Windows: a
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 semicolon separated list of pathnames.)
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 We try the Java compilers in the following order:
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 1. getenv ("JAVAC"), because the user must be able to override our
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
84 preferences,
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 2. "gcj -C", because it is a completely free compiler,
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 3. "javac", because it is a standard compiler,
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 4. "jikes", comes last because it has some deviating interpretation
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
88 of the Java Language Specification and because it requires a
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
89 CLASSPATH environment variable.
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 We unset the JAVA_HOME environment variable, because a wrong setting of
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 this variable can confuse the JDK's javac.
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 */
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
95 /* Return the default target_version. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
96 static const char *
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
97 default_target_version (void)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
98 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
99 /* Use a cache. Assumes that the PATH environment variable doesn't change
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
100 during the lifetime of the program. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
101 static const char *java_version_cache;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
102 if (java_version_cache == NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
103 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
104 /* Determine the version from the found JVM. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
105 java_version_cache = javaexec_version ();
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
106 if (java_version_cache == NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
107 || !(java_version_cache[0] == '1' && java_version_cache[1] == '.'
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
108 && (java_version_cache[2] >= '1' && java_version_cache[2] <= '6')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
109 && java_version_cache[3] == '\0'))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
110 java_version_cache = "1.1";
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
111 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
112 return java_version_cache;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
113 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
114
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
115 /* ======================= Source version dependent ======================= */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
116
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
117 /* Convert a source version to an index. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
118 #define SOURCE_VERSION_BOUND 3 /* exclusive upper bound */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
119 static unsigned int
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
120 source_version_index (const char *source_version)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
121 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
122 if (source_version[0] == '1' && source_version[1] == '.'
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
123 && (source_version[2] >= '3' && source_version[2] <= '5')
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
124 && source_version[3] == '\0')
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
125 return source_version[2] - '3';
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
126 error (EXIT_FAILURE, 0, _("invalid source_version argument to compile_java_class"));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
127 return 0;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
128 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
129
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
130 /* Return a snippet of code that should compile in the given source version. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
131 static const char *
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
132 get_goodcode_snippet (const char *source_version)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
133 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
134 if (strcmp (source_version, "1.3") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
135 return "class conftest {}\n";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
136 if (strcmp (source_version, "1.4") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
137 return "class conftest { static { assert(true); } }\n";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
138 if (strcmp (source_version, "1.5") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
139 return "class conftest<T> { T foo() { return null; } }\n";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
140 error (EXIT_FAILURE, 0, _("invalid source_version argument to compile_java_class"));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
141 return NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
142 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
143
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
144 /* Return a snippet of code that should fail to compile in the given source
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
145 version, or NULL (standing for a snippet that would fail to compile with
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
146 any compiler). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
147 static const char *
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
148 get_failcode_snippet (const char *source_version)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
149 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
150 if (strcmp (source_version, "1.3") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
151 return "class conftestfail { static { assert(true); } }\n";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
152 if (strcmp (source_version, "1.4") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
153 return "class conftestfail<T> { T foo() { return null; } }\n";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
154 if (strcmp (source_version, "1.5") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
155 return NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
156 error (EXIT_FAILURE, 0, _("invalid source_version argument to compile_java_class"));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
157 return NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
158 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
159
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
160 /* ======================= Target version dependent ======================= */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
161
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
162 /* Convert a target version to an index. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
163 #define TARGET_VERSION_BOUND 6 /* exclusive upper bound */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
164 static unsigned int
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
165 target_version_index (const char *target_version)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
166 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
167 if (target_version[0] == '1' && target_version[1] == '.'
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
168 && (target_version[2] >= '1' && target_version[2] <= '6')
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
169 && target_version[3] == '\0')
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
170 return target_version[2] - '1';
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
171 error (EXIT_FAILURE, 0, _("invalid target_version argument to compile_java_class"));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
172 return 0;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
173 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
174
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
175 /* Return the class file version number corresponding to a given target
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
176 version. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
177 static int
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
178 corresponding_classfile_version (const char *target_version)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
179 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
180 if (strcmp (target_version, "1.1") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
181 return 45;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
182 if (strcmp (target_version, "1.2") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
183 return 46;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
184 if (strcmp (target_version, "1.3") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
185 return 47;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
186 if (strcmp (target_version, "1.4") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
187 return 48;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
188 if (strcmp (target_version, "1.5") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
189 return 49;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
190 if (strcmp (target_version, "1.6") == 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
191 return 50;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
192 error (EXIT_FAILURE, 0, _("invalid target_version argument to compile_java_class"));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
193 return 0;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
194 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
195
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
196 /* ======================== Compilation subroutines ======================== */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
197
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
198 /* Try to compile a set of Java sources with $JAVAC.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
199 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
200 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
201 compile_using_envjavac (const char *javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
202 const char * const *java_sources,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
203 unsigned int java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
204 const char *directory,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
205 bool optimize, bool debug,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
206 bool verbose, bool null_stderr)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
207 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
208 /* Because $JAVAC may consist of a command and options, we use the
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
209 shell. Because $JAVAC has been set by the user, we leave all
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
210 environment variables in place, including JAVA_HOME, and we don't
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
211 erase the user's CLASSPATH. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
212 bool err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
213 unsigned int command_length;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
214 char *command;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
215 char *argv[4];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
216 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
217 unsigned int i;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
218 char *p;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
219
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
220 command_length = strlen (javac);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
221 if (optimize)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
222 command_length += 3;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
223 if (debug)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
224 command_length += 3;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
225 if (directory != NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
226 command_length += 4 + shell_quote_length (directory);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
227 for (i = 0; i < java_sources_count; i++)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
228 command_length += 1 + shell_quote_length (java_sources[i]);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
229 command_length += 1;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
230
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
231 command = (char *) xmalloca (command_length);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
232 p = command;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
233 /* Don't shell_quote $JAVAC, because it may consist of a command
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
234 and options. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
235 memcpy (p, javac, strlen (javac));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
236 p += strlen (javac);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
237 if (optimize)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
238 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
239 memcpy (p, " -O", 3);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
240 p += 3;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
241 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
242 if (debug)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
243 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
244 memcpy (p, " -g", 3);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
245 p += 3;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
246 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
247 if (directory != NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
248 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
249 memcpy (p, " -d ", 4);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
250 p += 4;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
251 p = shell_quote_copy (p, directory);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
252 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
253 for (i = 0; i < java_sources_count; i++)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
254 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
255 *p++ = ' ';
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
256 p = shell_quote_copy (p, java_sources[i]);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
257 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
258 *p++ = '\0';
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
259 /* Ensure command_length was correctly calculated. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
260 if (p - command > command_length)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
261 abort ();
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
262
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
263 if (verbose)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
264 printf ("%s\n", command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
265
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
266 argv[0] = "/bin/sh";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
267 argv[1] = "-c";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
268 argv[2] = command;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
269 argv[3] = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
270 exitstatus = execute (javac, "/bin/sh", argv, false, false, false,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
271 null_stderr, true, true, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
272 err = (exitstatus != 0);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
273
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
274 freea (command);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
275
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
276 return err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
277 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
278
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
279 /* Try to compile a set of Java sources with gcj.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
280 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
281 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
282 compile_using_gcj (const char * const *java_sources,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
283 unsigned int java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
284 bool no_assert_option,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
285 bool fsource_option, const char *source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
286 bool ftarget_option, const char *target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
287 const char *directory,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
288 bool optimize, bool debug,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
289 bool verbose, bool null_stderr)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
290 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
291 bool err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
292 unsigned int argc;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
293 char **argv;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
294 char **argp;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
295 char *fsource_arg;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
296 char *ftarget_arg;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
297 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
298 unsigned int i;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
299
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
300 argc =
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
301 2 + (no_assert_option ? 1 : 0) + (fsource_option ? 1 : 0)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
302 + (ftarget_option ? 1 : 0) + (optimize ? 1 : 0) + (debug ? 1 : 0)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
303 + (directory != NULL ? 2 : 0) + java_sources_count;
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
304 argv = (char **) xmalloca ((argc + 1) * sizeof (char *));
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
305
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
306 argp = argv;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
307 *argp++ = "gcj";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
308 *argp++ = "-C";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
309 if (no_assert_option)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
310 *argp++ = "-fno-assert";
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
311 if (fsource_option)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
312 {
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
313 fsource_arg = (char *) xmalloca (9 + strlen (source_version) + 1);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
314 memcpy (fsource_arg, "-fsource=", 9);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
315 strcpy (fsource_arg + 9, source_version);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
316 *argp++ = fsource_arg;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
317 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
318 else
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
319 fsource_arg = NULL;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
320 if (ftarget_option)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
321 {
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
322 ftarget_arg = (char *) xmalloca (9 + strlen (target_version) + 1);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
323 memcpy (ftarget_arg, "-ftarget=", 9);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
324 strcpy (ftarget_arg + 9, target_version);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
325 *argp++ = ftarget_arg;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
326 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
327 else
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
328 ftarget_arg = NULL;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
329 if (optimize)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
330 *argp++ = "-O";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
331 if (debug)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
332 *argp++ = "-g";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
333 if (directory != NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
334 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
335 *argp++ = "-d";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
336 *argp++ = (char *) directory;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
337 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
338 for (i = 0; i < java_sources_count; i++)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
339 *argp++ = (char *) java_sources[i];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
340 *argp = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
341 /* Ensure argv length was correctly calculated. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
342 if (argp - argv != argc)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
343 abort ();
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
344
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
345 if (verbose)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
346 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
347 char *command = shell_quote_argv (argv);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
348 printf ("%s\n", command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
349 free (command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
350 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
351
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
352 exitstatus = execute ("gcj", "gcj", argv, false, false, false, null_stderr,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
353 true, true, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
354 err = (exitstatus != 0);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
355
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
356 if (ftarget_arg != NULL)
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
357 freea (ftarget_arg);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
358 if (fsource_arg != NULL)
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
359 freea (fsource_arg);
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
360 freea (argv);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
361
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
362 return err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
363 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
364
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
365 /* Try to compile a set of Java sources with javac.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
366 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
367 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
368 compile_using_javac (const char * const *java_sources,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
369 unsigned int java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
370 bool source_option, const char *source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
371 bool target_option, const char *target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
372 const char *directory,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
373 bool optimize, bool debug,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
374 bool verbose, bool null_stderr)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
375 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
376 bool err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
377 unsigned int argc;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
378 char **argv;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
379 char **argp;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
380 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
381 unsigned int i;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
382
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
383 argc =
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
384 1 + (source_option ? 2 : 0) + (target_option ? 2 : 0) + (optimize ? 1 : 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
385 + (debug ? 1 : 0) + (directory != NULL ? 2 : 0) + java_sources_count;
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
386 argv = (char **) xmalloca ((argc + 1) * sizeof (char *));
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
387
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
388 argp = argv;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
389 *argp++ = "javac";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
390 if (source_option)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
391 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
392 *argp++ = "-source";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
393 *argp++ = (char *) source_version;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
394 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
395 if (target_option)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
396 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
397 *argp++ = "-target";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
398 *argp++ = (char *) target_version;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
399 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
400 if (optimize)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
401 *argp++ = "-O";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
402 if (debug)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
403 *argp++ = "-g";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
404 if (directory != NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
405 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
406 *argp++ = "-d";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
407 *argp++ = (char *) directory;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
408 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
409 for (i = 0; i < java_sources_count; i++)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
410 *argp++ = (char *) java_sources[i];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
411 *argp = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
412 /* Ensure argv length was correctly calculated. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
413 if (argp - argv != argc)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
414 abort ();
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
415
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
416 if (verbose)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
417 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
418 char *command = shell_quote_argv (argv);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
419 printf ("%s\n", command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
420 free (command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
421 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
422
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
423 exitstatus = execute ("javac", "javac", argv, false, false, false,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
424 null_stderr, true, true, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
425 err = (exitstatus != 0);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
426
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
427 freea (argv);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
428
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
429 return err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
430 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
431
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
432 /* Try to compile a set of Java sources with jikes.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
433 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
434 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
435 compile_using_jikes (const char * const *java_sources,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
436 unsigned int java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
437 const char *directory,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
438 bool optimize, bool debug,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
439 bool verbose, bool null_stderr)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
440 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
441 bool err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
442 unsigned int argc;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
443 char **argv;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
444 char **argp;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
445 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
446 unsigned int i;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
447
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
448 argc =
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
449 1 + (optimize ? 1 : 0) + (debug ? 1 : 0) + (directory != NULL ? 2 : 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
450 + java_sources_count;
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
451 argv = (char **) xmalloca ((argc + 1) * sizeof (char *));
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
452
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
453 argp = argv;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
454 *argp++ = "jikes";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
455 if (optimize)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
456 *argp++ = "-O";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
457 if (debug)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
458 *argp++ = "-g";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
459 if (directory != NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
460 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
461 *argp++ = "-d";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
462 *argp++ = (char *) directory;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
463 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
464 for (i = 0; i < java_sources_count; i++)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
465 *argp++ = (char *) java_sources[i];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
466 *argp = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
467 /* Ensure argv length was correctly calculated. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
468 if (argp - argv != argc)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
469 abort ();
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
470
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
471 if (verbose)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
472 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
473 char *command = shell_quote_argv (argv);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
474 printf ("%s\n", command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
475 free (command);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
476 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
477
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
478 exitstatus = execute ("jikes", "jikes", argv, false, false, false,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
479 null_stderr, true, true, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
480 err = (exitstatus != 0);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
481
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
482 freea (argv);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
483
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
484 return err;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
485 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
486
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
487 /* ====================== Usability test subroutines ====================== */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
488
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
489 /* Write a given contents to a temporary file.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
490 FILE_NAME is the name of a file inside TMPDIR that is known not to exist
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
491 yet.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
492 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
493 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
494 write_temp_file (struct temp_dir *tmpdir, const char *file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
495 const char *contents)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
496 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
497 FILE *fp;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
498
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
499 register_temp_file (tmpdir, file_name);
7412
066c3e27ecd1 Ensure temp file is closed before its directory is removed.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
500 fp = fopen_temp (file_name, "w");
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
501 if (fp == NULL)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
502 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
503 error (0, errno, _("failed to create \"%s\""), file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
504 unregister_temp_file (tmpdir, file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
505 return true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
506 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
507 fputs (contents, fp);
7412
066c3e27ecd1 Ensure temp file is closed before its directory is removed.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
508 if (fwriteerror_temp (fp))
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
509 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
510 error (0, errno, _("error while writing \"%s\" file"), file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
511 return true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
512 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
513 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
514 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
515
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
516 /* Return the class file version number of a class file on disk. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
517 static int
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
518 get_classfile_version (const char *compiled_file_name)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
519 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
520 unsigned char header[8];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
521 int fd;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
522
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
523 /* Open the class file. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
524 fd = open (compiled_file_name, O_RDONLY | O_BINARY, 0);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
525 if (fd >= 0)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
526 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
527 /* Read its first 8 bytes. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
528 if (safe_read (fd, header, 8) == 8)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
529 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
530 /* Verify the class file signature. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
531 if (header[0] == 0xCA && header[1] == 0xFE
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
532 && header[2] == 0xBA && header[3] == 0xBE)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
533 return header[7];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
534 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
535 close (fd);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
536 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
537
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
538 /* Could not get the class file version. Return a very large one. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
539 return INT_MAX;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
540 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
541
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
542 /* Return true if $JAVAC is a version of gcj. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
543 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
544 is_envjavac_gcj (const char *javac)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
545 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
546 static bool envjavac_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
547 static bool envjavac_gcj;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
548
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
549 if (!envjavac_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
550 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
551 /* Test whether $JAVAC is gcj:
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
552 "$JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null" */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
553 unsigned int command_length;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
554 char *command;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
555 char *argv[4];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
556 pid_t child;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
557 int fd[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
558 FILE *fp;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
559 char *line;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
560 size_t linesize;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
561 size_t linelen;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
562 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
563 char *p;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
564
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
565 /* Setup the command "$JAVAC --version". */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
566 command_length = strlen (javac) + 1 + 9 + 1;
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
567 command = (char *) xmalloca (command_length);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
568 p = command;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
569 /* Don't shell_quote $JAVAC, because it may consist of a command
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
570 and options. */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
571 memcpy (p, javac, strlen (javac));
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
572 p += strlen (javac);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
573 memcpy (p, " --version", 1 + 9 + 1);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
574 p += 1 + 9 + 1;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
575 /* Ensure command_length was correctly calculated. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
576 if (p - command > command_length)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
577 abort ();
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
578
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
579 /* Call $JAVAC --version 2>/dev/null. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
580 argv[0] = "/bin/sh";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
581 argv[1] = "-c";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
582 argv[2] = command;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
583 argv[3] = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
584 child = create_pipe_in (javac, "/bin/sh", argv, DEV_NULL, true, true,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
585 false, fd);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
586 if (child == -1)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
587 goto failed;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
588
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
589 /* Retrieve its result. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
590 fp = fdopen (fd[0], "r");
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
591 if (fp == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
592 goto failed;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
593
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
594 line = NULL; linesize = 0;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
595 linelen = getline (&line, &linesize, fp);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
596 if (linelen == (size_t)(-1))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
597 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
598 fclose (fp);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
599 goto failed;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
600 }
7974
ace01389ef5b Small optimization.
Bruno Haible <bruno@clisp.org>
parents: 7944
diff changeset
601 /* It is safe to call c_strstr() instead of strstr() here; see the
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
602 comments in c-strstr.h. */
7974
ace01389ef5b Small optimization.
Bruno Haible <bruno@clisp.org>
parents: 7944
diff changeset
603 envjavac_gcj = (c_strstr (line, "gcj") != NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
604
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
605 fclose (fp);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
606
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
607 /* Remove zombie process from process list, and retrieve exit status. */
10197
d079dd7b69bc Add termsigp argument to execute() and wait_process().
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
608 exitstatus =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
609 wait_subprocess (child, javac, true, true, true, false, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
610 if (exitstatus != 0)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
611 envjavac_gcj = false;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
612
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
613 failed:
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
614 freea (command);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
615
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
616 envjavac_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
617 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
618
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
619 return envjavac_gcj;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
620 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
621
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
622 /* Return true if $JAVAC, known to be a version of gcj, is a version >= 4.3
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
623 of gcj. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
624 static bool
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
625 is_envjavac_gcj43 (const char *javac)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
626 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
627 static bool envjavac_tested;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
628 static bool envjavac_gcj43;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
629
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
630 if (!envjavac_tested)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
631 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
632 /* Test whether $JAVAC is gcj:
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
633 "$JAVAC --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
634 | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null" */
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
635 unsigned int command_length;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
636 char *command;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
637 char *argv[4];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
638 pid_t child;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
639 int fd[1];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
640 FILE *fp;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
641 char *line;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
642 size_t linesize;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
643 size_t linelen;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
644 int exitstatus;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
645 char *p;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
646
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
647 /* Setup the command "$JAVAC --version". */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
648 command_length = strlen (javac) + 1 + 9 + 1;
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
649 command = (char *) xmalloca (command_length);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
650 p = command;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
651 /* Don't shell_quote $JAVAC, because it may consist of a command
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
652 and options. */
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
653 memcpy (p, javac, strlen (javac));
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
654 p += strlen (javac);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
655 memcpy (p, " --version", 1 + 9 + 1);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
656 p += 1 + 9 + 1;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
657 /* Ensure command_length was correctly calculated. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
658 if (p - command > command_length)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
659 abort ();
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
660
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
661 /* Call $JAVAC --version 2>/dev/null. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
662 argv[0] = "/bin/sh";
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
663 argv[1] = "-c";
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
664 argv[2] = command;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
665 argv[3] = NULL;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
666 child = create_pipe_in (javac, "/bin/sh", argv, DEV_NULL, true, true,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
667 false, fd);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
668 if (child == -1)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
669 goto failed;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
670
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
671 /* Retrieve its result. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
672 fp = fdopen (fd[0], "r");
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
673 if (fp == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
674 goto failed;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
675
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
676 line = NULL; linesize = 0;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
677 linelen = getline (&line, &linesize, fp);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
678 if (linelen == (size_t)(-1))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
679 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
680 fclose (fp);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
681 goto failed;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
682 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
683 p = line;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
684 while (*p != '\0' && !(*p >= '0' && *p <= '9'))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
685 p++;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
686 envjavac_gcj43 =
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
687 !(*p == '4' && p[1] == '.' && p[2] >= '0' && p[2] <= '2')
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
688 && (*p >= '4' && *p <= '9');
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
689
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
690 fclose (fp);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
691
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
692 /* Remove zombie process from process list, and retrieve exit status. */
10197
d079dd7b69bc Add termsigp argument to execute() and wait_process().
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
693 exitstatus =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
694 wait_subprocess (child, javac, true, true, true, false, NULL);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
695 if (exitstatus != 0)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
696 envjavac_gcj43 = false;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
697
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
698 failed:
8948
a162347a0232 Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents: 8251
diff changeset
699 freea (command);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
700
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
701 envjavac_tested = true;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
702 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
703
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
704 return envjavac_gcj43;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
705 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
706
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
707 /* Test whether $JAVAC, known to be a version of gcj >= 4.3, can be used, and
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
708 whether it needs a -fsource and/or -ftarget option.
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
709 Return a failure indicator (true upon error). */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
710 static bool
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
711 is_envjavac_gcj43_usable (const char *javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
712 const char *source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
713 const char *target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
714 bool *usablep,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
715 bool *fsource_option_p, bool *ftarget_option_p)
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
716 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
717 /* The cache depends on the source_version and target_version. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
718 struct result_t
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
719 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
720 bool tested;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
721 bool usable;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
722 bool fsource_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
723 bool ftarget_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
724 };
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
725 static struct result_t result_cache[SOURCE_VERSION_BOUND][TARGET_VERSION_BOUND];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
726 struct result_t *resultp;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
727
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
728 resultp = &result_cache[source_version_index (source_version)]
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
729 [target_version_index (target_version)];
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
730 if (!resultp->tested)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
731 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
732 /* Try $JAVAC. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
733 struct temp_dir *tmpdir;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
734 char *conftest_file_name;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
735 char *compiled_file_name;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
736 const char *java_sources[1];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
737 struct stat statbuf;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
738
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
739 tmpdir = create_temp_dir ("java", NULL, false);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
740 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
741 return true;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
742
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
743 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
744 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
745 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
746 get_goodcode_snippet (source_version)))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
747 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
748 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
749 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
750 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
751 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
752
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
753 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
754 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
755 register_temp_file (tmpdir, compiled_file_name);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
756
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
757 java_sources[0] = conftest_file_name;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
758 if (!compile_using_envjavac (javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
759 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
760 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
761 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
762 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
763 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
764 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
765 /* $JAVAC compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
766 /* Try adding -fsource option if it is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
767 char *javac_source =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
768 xasprintf ("%s -fsource=%s", javac, source_version);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
769
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
770 unlink (compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
771
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
772 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
773 if (!compile_using_envjavac (javac_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
774 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
775 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
776 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
777 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
778 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
779 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
780 const char *failcode = get_failcode_snippet (source_version);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
781
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
782 if (failcode != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
783 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
784 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
785 free (conftest_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
786
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
787 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
788 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
789 "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
790 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
791 if (write_temp_file (tmpdir, conftest_file_name, failcode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
792 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
793 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
794 free (javac_source);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
795 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
796 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
797 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
798
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
799 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
800 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
801 "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
802 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
803 register_temp_file (tmpdir, compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
804
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
805 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
806 if (!compile_using_envjavac (javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
807 java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
808 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
809 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
810 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
811 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
812 unlink (compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
813
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
814 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
815 if (compile_using_envjavac (javac_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
816 java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
817 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
818 false, false, false, true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
819 /* $JAVAC compiled conftestfail.java successfully, and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
820 "$JAVAC -fsource=$source_version" rejects it. So
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
821 the -fsource option is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
822 resultp->fsource_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
823 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
824 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
825 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
826
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
827 free (javac_source);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
828
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
829 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
830 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
831 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
832 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
833 /* Try with -fsource and -ftarget options. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
834 char *javac_target =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
835 xasprintf ("%s -fsource=%s -ftarget=%s",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
836 javac, source_version, target_version);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
837
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
838 unlink (compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
839
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
840 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
841 if (!compile_using_envjavac (javac_target,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
842 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
843 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
844 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
845 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
846 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
847 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
848 /* "$JAVAC -fsource $source_version -ftarget $target_version"
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
849 compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
850 resultp->fsource_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
851 resultp->ftarget_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
852 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
853 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
854
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
855 free (javac_target);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
856 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
857
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
858 free (compiled_file_name);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
859 free (conftest_file_name);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
860
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
861 resultp->tested = true;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
862 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
863
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
864 *usablep = resultp->usable;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
865 *fsource_option_p = resultp->fsource_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
866 *ftarget_option_p = resultp->ftarget_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
867 return false;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
868 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
869
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
870 /* Test whether $JAVAC, known to be a version of gcj < 4.3, can be used for
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
871 compiling with target_version = 1.4 and source_version = 1.4.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
872 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
873 static bool
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
874 is_envjavac_oldgcj_14_14_usable (const char *javac, bool *usablep)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
875 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
876 static bool envjavac_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
877 static bool envjavac_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
878
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
879 if (!envjavac_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
880 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
881 /* Try $JAVAC. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
882 struct temp_dir *tmpdir;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
883 char *conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
884 char *compiled_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
885 const char *java_sources[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
886 struct stat statbuf;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
887
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
888 tmpdir = create_temp_dir ("java", NULL, false);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
889 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
890 return true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
891
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
892 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
893 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
894 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
895 get_goodcode_snippet ("1.4")))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
896 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
897 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
898 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
899 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
900 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
901
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
902 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
903 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
904 register_temp_file (tmpdir, compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
905
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
906 java_sources[0] = conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
907 if (!compile_using_envjavac (javac, java_sources, 1, tmpdir->dir_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
908 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
909 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
910 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
911 envjavac_usable = true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
912
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
913 free (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
914 free (conftest_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
915
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
916 cleanup_temp_dir (tmpdir);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
917
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
918 envjavac_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
919 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
920
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
921 *usablep = envjavac_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
922 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
923 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
924
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
925 /* Test whether $JAVAC, known to be a version of gcj < 4.3, can be used for
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
926 compiling with target_version = 1.4 and source_version = 1.3.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
927 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
928 static bool
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
929 is_envjavac_oldgcj_14_13_usable (const char *javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
930 bool *usablep, bool *need_no_assert_option_p)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
931 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
932 static bool envjavac_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
933 static bool envjavac_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
934 static bool envjavac_need_no_assert_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
935
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
936 if (!envjavac_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
937 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
938 /* Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
939 it makes a difference. (It could already be part of $JAVAC.) */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
940 struct temp_dir *tmpdir;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
941 char *conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
942 char *compiled_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
943 const char *java_sources[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
944 struct stat statbuf;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
945 bool javac_works;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
946 char *javac_noassert;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
947 bool javac_noassert_works;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
948
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
949 tmpdir = create_temp_dir ("java", NULL, false);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
950 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
951 return true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
952
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
953 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
954 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
955 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
956 get_goodcode_snippet ("1.3")))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
957 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
958 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
959 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
960 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
961 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
962
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
963 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
964 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
965 register_temp_file (tmpdir, compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
966
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
967 java_sources[0] = conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
968 if (!compile_using_envjavac (javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
969 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
970 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
971 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
972 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
973 javac_works = true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
974 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
975 javac_works = false;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
976
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
977 unlink (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
978
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
979 javac_noassert = xasprintf ("%s -fno-assert", javac);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
980
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
981 java_sources[0] = conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
982 if (!compile_using_envjavac (javac_noassert,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
983 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
984 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
985 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
986 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
987 javac_noassert_works = true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
988 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
989 javac_noassert_works = false;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
990
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
991 free (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
992 free (conftest_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
993
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
994 if (javac_works && javac_noassert_works)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
995 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
996 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
997 xconcatenated_filename (tmpdir->dir_name, "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
998 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
999 if (write_temp_file (tmpdir, conftest_file_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1000 get_failcode_snippet ("1.3")))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1001 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1002 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1003 free (javac_noassert);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1004 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1005 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1006 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1007
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1008 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1009 xconcatenated_filename (tmpdir->dir_name, "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1010 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1011 register_temp_file (tmpdir, compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1012
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1013 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1014 if (!compile_using_envjavac (javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1015 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1016 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1017 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1018 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1019 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1020 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1021
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1022 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1023 if (!(!compile_using_envjavac (javac_noassert,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1024 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1025 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1026 && stat (compiled_file_name, &statbuf) >= 0))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1027 /* Compilation failed. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1028 /* "$JAVAC -fno-assert" works better than $JAVAC. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1029 javac_works = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1030 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1031
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1032 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1033 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1034 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1035
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1036 cleanup_temp_dir (tmpdir);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1037
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1038 if (javac_works)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1039 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1040 envjavac_usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1041 envjavac_need_no_assert_option = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1042 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1043 else if (javac_noassert_works)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1044 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1045 envjavac_usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1046 envjavac_need_no_assert_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1047 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1048
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1049 envjavac_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1050 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1051
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1052 *usablep = envjavac_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1053 *need_no_assert_option_p = envjavac_need_no_assert_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1054 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1055 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1056
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1057 /* Test whether $JAVAC, known to be not a version of gcj, can be used, and
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1058 whether it needs a -source and/or -target option.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1059 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1060 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1061 is_envjavac_nongcj_usable (const char *javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1062 const char *source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1063 const char *target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1064 bool *usablep,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1065 bool *source_option_p, bool *target_option_p)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1066 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1067 /* The cache depends on the source_version and target_version. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1068 struct result_t
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1069 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1070 bool tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1071 bool usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1072 bool source_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1073 bool target_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1074 };
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1075 static struct result_t result_cache[SOURCE_VERSION_BOUND][TARGET_VERSION_BOUND];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1076 struct result_t *resultp;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1077
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1078 resultp = &result_cache[source_version_index (source_version)]
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1079 [target_version_index (target_version)];
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1080 if (!resultp->tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1081 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1082 /* Try $JAVAC. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1083 struct temp_dir *tmpdir;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1084 char *conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1085 char *compiled_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1086 const char *java_sources[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1087 struct stat statbuf;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1088
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1089 tmpdir = create_temp_dir ("java", NULL, false);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1090 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1091 return true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1092
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1093 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1094 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1095 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1096 get_goodcode_snippet (source_version)))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1097 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1098 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1099 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1100 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1101 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1102
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1103 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1104 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1105 register_temp_file (tmpdir, compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1106
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1107 java_sources[0] = conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1108 if (!compile_using_envjavac (javac,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1109 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1110 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1111 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1112 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1113 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1114 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1115 /* $JAVAC compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1116 /* Try adding -source option if it is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1117 char *javac_source =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1118 xasprintf ("%s -source %s", javac, source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1119
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1120 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1121
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1122 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1123 if (!compile_using_envjavac (javac_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1124 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1125 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1126 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1127 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1128 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1129 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1130 const char *failcode = get_failcode_snippet (source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1131
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1132 if (failcode != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1133 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1134 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1135 free (conftest_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1136
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1137 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1138 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1139 "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1140 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1141 if (write_temp_file (tmpdir, conftest_file_name, failcode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1142 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1143 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1144 free (javac_source);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1145 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1146 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1147 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1148
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1149 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1150 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1151 "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1152 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1153 register_temp_file (tmpdir, compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1154
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1155 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1156 if (!compile_using_envjavac (javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1157 java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1158 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1159 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1160 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1161 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1162 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1163
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1164 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1165 if (compile_using_envjavac (javac_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1166 java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1167 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1168 false, false, false, true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1169 /* $JAVAC compiled conftestfail.java successfully, and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1170 "$JAVAC -source $source_version" rejects it. So the
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1171 -source option is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1172 resultp->source_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1173 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1174 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1175 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1176
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1177 free (javac_source);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1178
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1179 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1180 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1181 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1182 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1183 /* Try with -target option alone. (Sun javac 1.3.1 has the -target
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1184 option but no -source option.) */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1185 char *javac_target =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1186 xasprintf ("%s -target %s", javac, target_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1187
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1188 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1189
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1190 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1191 if (!compile_using_envjavac (javac_target,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1192 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1193 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1194 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1195 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1196 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1197 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1198 /* "$JAVAC -target $target_version" compiled conftest.java
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1199 successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1200 /* Try adding -source option if it is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1201 char *javac_target_source =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1202 xasprintf ("%s -source %s", javac_target, source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1203
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1204 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1205
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1206 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1207 if (!compile_using_envjavac (javac_target_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1208 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1209 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1210 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1211 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1212 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1213 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1214 const char *failcode = get_failcode_snippet (source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1215
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1216 if (failcode != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1217 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1218 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1219 free (conftest_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1220
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1221 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1222 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1223 "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1224 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1225 if (write_temp_file (tmpdir, conftest_file_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1226 failcode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1227 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1228 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1229 free (javac_target_source);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1230 free (javac_target);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1231 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1232 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1233 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1234
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1235 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1236 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1237 "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1238 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1239 register_temp_file (tmpdir, compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1240
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1241 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1242 if (!compile_using_envjavac (javac_target,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1243 java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1244 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1245 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1246 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1247 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1248 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1249
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1250 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1251 if (compile_using_envjavac (javac_target_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1252 java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1253 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1254 false, false, false,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1255 true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1256 /* "$JAVAC -target $target_version" compiled
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1257 conftestfail.java successfully, and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1258 "$JAVAC -target $target_version -source $source_version"
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1259 rejects it. So the -source option is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1260 resultp->source_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1261 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1262 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1263 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1264
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1265 free (javac_target_source);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1266
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1267 resultp->target_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1268 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1269 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1270 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1271 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1272 /* Maybe this -target option requires a -source option? Try with
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1273 -target and -source options. (Supported by Sun javac 1.4 and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1274 higher.) */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1275 char *javac_target_source =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1276 xasprintf ("%s -source %s", javac_target, source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1277
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1278 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1279
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1280 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1281 if (!compile_using_envjavac (javac_target_source,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1282 java_sources, 1, tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1283 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1284 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1285 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1286 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1287 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1288 /* "$JAVAC -target $target_version -source $source_version"
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1289 compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1290 resultp->source_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1291 resultp->target_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1292 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1293 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1294
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1295 free (javac_target_source);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1296 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1297
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1298 free (javac_target);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1299 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1300
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1301 free (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1302 free (conftest_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1303
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1304 resultp->tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1305 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1306
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1307 *usablep = resultp->usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1308 *source_option_p = resultp->source_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1309 *target_option_p = resultp->target_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1310 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1311 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1312
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1313 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1314 is_gcj_present (void)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1315 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1316 static bool gcj_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1317 static bool gcj_present;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1318
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1319 if (!gcj_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1320 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1321 /* Test for presence of gcj:
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1322 "gcj --version 2> /dev/null | \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1323 sed -e 's,^[^0-9]*,,' -e 1q | \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1324 sed -e '/^3\.[01]/d' | grep '^[3-9]' > /dev/null" */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1325 char *argv[3];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1326 pid_t child;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1327 int fd[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1328 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1329
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1330 argv[0] = "gcj";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1331 argv[1] = "--version";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1332 argv[2] = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1333 child = create_pipe_in ("gcj", "gcj", argv, DEV_NULL, true, true,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1334 false, fd);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1335 gcj_present = false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1336 if (child != -1)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1337 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1338 /* Read the subprocess output, drop all lines except the first,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1339 drop all characters before the first digit, and test whether
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1340 the remaining string starts with a digit >= 3, but not with
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1341 "3.0" or "3.1". */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1342 char c[3];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1343 size_t count = 0;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1344
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1345 while (safe_read (fd[0], &c[count], 1) > 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1346 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1347 if (c[count] == '\n')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1348 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1349 if (count == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1350 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1351 if (!(c[0] >= '0' && c[0] <= '9'))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1352 continue;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1353 gcj_present = (c[0] >= '3');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1354 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1355 count++;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1356 if (count == 3)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1357 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1358 if (c[0] == '3' && c[1] == '.'
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1359 && (c[2] == '0' || c[2] == '1'))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1360 gcj_present = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1361 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1362 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1363 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1364 while (safe_read (fd[0], &c[0], 1) > 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1365 ;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1366
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1367 close (fd[0]);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1368
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1369 /* Remove zombie process from process list, and retrieve exit
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1370 status. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1371 exitstatus =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1372 wait_subprocess (child, "gcj", false, true, true, false, NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1373 if (exitstatus != 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1374 gcj_present = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1375 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1376
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1377 if (gcj_present)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1378 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1379 /* See if libgcj.jar is well installed. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1380 struct temp_dir *tmpdir;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1381
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1382 tmpdir = create_temp_dir ("java", NULL, false);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1383 if (tmpdir == NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1384 gcj_present = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1385 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1386 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1387 char *conftest_file_name;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1388
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1389 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1390 xconcatenated_filename (tmpdir->dir_name, "conftestlib.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1391 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1392 if (write_temp_file (tmpdir, conftest_file_name,
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1393 "public class conftestlib {\n"
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1394 " public static void main (String[] args) {\n"
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1395 " }\n"
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1396 "}\n"))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1397 gcj_present = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1398 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1399 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1400 char *compiled_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1401 const char *java_sources[1];
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1402
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1403 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1404 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1405 "conftestlib.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1406 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1407 register_temp_file (tmpdir, compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1408
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1409 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1410 if (compile_using_gcj (java_sources, 1, false,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1411 false, NULL, false, NULL,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1412 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1413 false, false, false, true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1414 gcj_present = false;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1415
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1416 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1417 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1418 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1419 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1420 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1421 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1422
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1423 gcj_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1424 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1425
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1426 return gcj_present;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1427 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1428
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1429 static bool
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1430 is_gcj_43 (void)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1431 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1432 static bool gcj_tested;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1433 static bool gcj_43;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1434
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1435 if (!gcj_tested)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1436 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1437 /* Test for presence of gcj:
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1438 "gcj --version 2> /dev/null | \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1439 sed -e 's,^[^0-9]*,,' -e 1q | \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1440 sed -e '/^4\.[012]/d' | grep '^[4-9]'" */
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1441 char *argv[3];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1442 pid_t child;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1443 int fd[1];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1444 int exitstatus;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1445
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1446 argv[0] = "gcj";
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1447 argv[1] = "--version";
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1448 argv[2] = NULL;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1449 child = create_pipe_in ("gcj", "gcj", argv, DEV_NULL, true, true,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1450 false, fd);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1451 gcj_43 = false;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1452 if (child != -1)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1453 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1454 /* Read the subprocess output, drop all lines except the first,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1455 drop all characters before the first digit, and test whether
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1456 the remaining string starts with a digit >= 4, but not with
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1457 "4.0" or "4.1" or "4.2". */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1458 char c[3];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1459 size_t count = 0;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1460
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1461 while (safe_read (fd[0], &c[count], 1) > 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1462 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1463 if (c[count] == '\n')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1464 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1465 if (count == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1466 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1467 if (!(c[0] >= '0' && c[0] <= '9'))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1468 continue;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1469 gcj_43 = (c[0] >= '4');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1470 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1471 count++;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1472 if (count == 3)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1473 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1474 if (c[0] == '4' && c[1] == '.' && c[2] >= '0' && c[2] <= '2')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1475 gcj_43 = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1476 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1477 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1478 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1479 while (safe_read (fd[0], &c[0], 1) > 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1480 ;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1481
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1482 close (fd[0]);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1483
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1484 /* Remove zombie process from process list, and retrieve exit
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1485 status. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1486 exitstatus =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1487 wait_subprocess (child, "gcj", false, true, true, false, NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1488 if (exitstatus != 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1489 gcj_43 = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1490 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1491
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1492 gcj_tested = true;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1493 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1494
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1495 return gcj_43;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1496 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1497
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1498 /* Test whether gcj >= 4.3 can be used, and whether it needs a -fsource and/or
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1499 -ftarget option.
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1500 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1501 static bool
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1502 is_gcj43_usable (const char *source_version,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1503 const char *target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1504 bool *usablep,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1505 bool *fsource_option_p, bool *ftarget_option_p)
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1506 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1507 /* The cache depends on the source_version and target_version. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1508 struct result_t
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1509 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1510 bool tested;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1511 bool usable;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1512 bool fsource_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1513 bool ftarget_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1514 };
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1515 static struct result_t result_cache[SOURCE_VERSION_BOUND][TARGET_VERSION_BOUND];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1516 struct result_t *resultp;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1517
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1518 resultp = &result_cache[source_version_index (source_version)]
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1519 [target_version_index (target_version)];
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1520 if (!resultp->tested)
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1521 {
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1522 /* Try gcj. */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1523 struct temp_dir *tmpdir;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1524 char *conftest_file_name;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1525 char *compiled_file_name;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1526 const char *java_sources[1];
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1527 struct stat statbuf;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1528
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1529 tmpdir = create_temp_dir ("java", NULL, false);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1530 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1531 return true;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1532
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1533 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1534 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1535 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1536 get_goodcode_snippet (source_version)))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1537 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1538 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1539 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1540 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1541 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1542
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1543 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1544 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1545 register_temp_file (tmpdir, compiled_file_name);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1546
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1547 java_sources[0] = conftest_file_name;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1548 if (!compile_using_gcj (java_sources, 1, false, false, NULL, false, NULL,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1549 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1550 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1551 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1552 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1553 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1554 /* gcj compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1555 /* Try adding -fsource option if it is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1556 unlink (compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1557
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1558 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1559 if (!compile_using_gcj (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1560 false, true, source_version, false, NULL,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1561 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1562 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1563 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1564 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1565 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1566 const char *failcode = get_failcode_snippet (source_version);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1567
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1568 if (failcode != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1569 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1570 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1571 free (conftest_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1572
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1573 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1574 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1575 "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1576 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1577 if (write_temp_file (tmpdir, conftest_file_name, failcode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1578 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1579 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1580 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1581 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1582 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1583
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1584 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1585 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1586 "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1587 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1588 register_temp_file (tmpdir, compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1589
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1590 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1591 if (!compile_using_gcj (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1592 false, false, NULL, false, NULL,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1593 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1594 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1595 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1596 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1597 unlink (compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1598
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1599 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1600 if (compile_using_gcj (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1601 false, true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1602 false, NULL,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1603 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1604 false, false, false, true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1605 /* gcj compiled conftestfail.java successfully, and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1606 "gcj -fsource=$source_version" rejects it. So
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1607 the -fsource option is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1608 resultp->fsource_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1609 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1610 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1611 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1612
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1613 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1614 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1615 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1616 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1617 /* Try with -fsource and -ftarget options. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1618 unlink (compiled_file_name);
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1619
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1620 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1621 if (!compile_using_gcj (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1622 false, true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1623 true, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1624 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1625 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1626 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1627 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1628 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1629 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1630 /* "gcj -fsource $source_version -ftarget $target_version"
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1631 compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1632 resultp->fsource_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1633 resultp->ftarget_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1634 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1635 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1636 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1637
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1638 free (compiled_file_name);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1639 free (conftest_file_name);
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1640
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1641 resultp->tested = true;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1642 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1643
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1644 *usablep = resultp->usable;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1645 *fsource_option_p = resultp->fsource_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1646 *ftarget_option_p = resultp->ftarget_option;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1647 return false;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1648 }
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1649
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1650 /* Test whether gcj < 4.3 can be used for compiling with target_version = 1.4
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1651 and source_version = 1.4.
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1652 Return a failure indicator (true upon error). */
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1653 static bool
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1654 is_oldgcj_14_14_usable (bool *usablep)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1655 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1656 static bool gcj_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1657 static bool gcj_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1658
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1659 if (!gcj_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1660 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1661 /* Try gcj. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1662 struct temp_dir *tmpdir;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1663 char *conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1664 char *compiled_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1665 const char *java_sources[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1666 struct stat statbuf;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1667
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1668 tmpdir = create_temp_dir ("java", NULL, false);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1669 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1670 return true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1671
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1672 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1673 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1674 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1675 get_goodcode_snippet ("1.4")))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1676 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1677 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1678 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1679 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1680 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1681
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1682 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1683 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1684 register_temp_file (tmpdir, compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1685
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1686 java_sources[0] = conftest_file_name;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1687 if (!compile_using_gcj (java_sources, 1, false, false, NULL, false, NULL,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1688 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1689 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1690 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1691 gcj_usable = true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1692
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1693 free (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1694 free (conftest_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1695
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1696 cleanup_temp_dir (tmpdir);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1697
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1698 gcj_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1699 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1700
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1701 *usablep = gcj_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1702 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1703 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1704
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1705 /* Test whether gcj < 4.3 can be used for compiling with target_version = 1.4
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1706 and source_version = 1.3.
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1707 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1708 static bool
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1709 is_oldgcj_14_13_usable (bool *usablep, bool *need_no_assert_option_p)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1710 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1711 static bool gcj_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1712 static bool gcj_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1713 static bool gcj_need_no_assert_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1714
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1715 if (!gcj_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1716 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1717 /* Try gcj and "gcj -fno-assert". But add -fno-assert only if
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1718 it works (not gcj < 3.3). */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1719 struct temp_dir *tmpdir;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1720 char *conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1721 char *compiled_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1722 const char *java_sources[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1723 struct stat statbuf;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1724
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1725 tmpdir = create_temp_dir ("java", NULL, false);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1726 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1727 return true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1728
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1729 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1730 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1731 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1732 get_goodcode_snippet ("1.3")))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1733 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1734 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1735 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1736 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1737 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1738
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1739 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1740 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1741 register_temp_file (tmpdir, compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1742
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1743 java_sources[0] = conftest_file_name;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
1744 if (!compile_using_gcj (java_sources, 1, true, false, NULL, false, NULL,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1745 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1746 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1747 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1748 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1749 gcj_usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1750 gcj_need_no_assert_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1751 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1752 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1753 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1754 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1755
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1756 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1757 if (!compile_using_gcj (java_sources, 1, false,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1758 false, NULL, false, NULL,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1759 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1760 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1761 /* Compilation succeeded. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1762 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1763 gcj_usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1764 gcj_need_no_assert_option = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1765 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1766 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1767
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1768 free (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1769 free (conftest_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1770
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1771 cleanup_temp_dir (tmpdir);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1772
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1773 gcj_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1774 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1775
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1776 *usablep = gcj_usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1777 *need_no_assert_option_p = gcj_need_no_assert_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1778 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1779 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1780
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1781 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1782 is_javac_present (void)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1783 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1784 static bool javac_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1785 static bool javac_present;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1786
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1787 if (!javac_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1788 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1789 /* Test for presence of javac: "javac 2> /dev/null ; test $? -le 2" */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1790 char *argv[2];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1791 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1792
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1793 argv[0] = "javac";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1794 argv[1] = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1795 exitstatus = execute ("javac", "javac", argv, false, false, true, true,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1796 true, false, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1797 javac_present = (exitstatus == 0 || exitstatus == 1 || exitstatus == 2);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1798 javac_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1799 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1800
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1801 return javac_present;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1802 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1803
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1804 /* Test whether javac can be used and whether it needs a -source and/or
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1805 -target option.
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1806 Return a failure indicator (true upon error). */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1807 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1808 is_javac_usable (const char *source_version, const char *target_version,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1809 bool *usablep, bool *source_option_p, bool *target_option_p)
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1810 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1811 /* The cache depends on the source_version and target_version. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1812 struct result_t
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1813 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1814 bool tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1815 bool usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1816 bool source_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1817 bool target_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1818 };
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1819 static struct result_t result_cache[SOURCE_VERSION_BOUND][TARGET_VERSION_BOUND];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1820 struct result_t *resultp;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1821
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1822 resultp = &result_cache[source_version_index (source_version)]
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1823 [target_version_index (target_version)];
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1824 if (!resultp->tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1825 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1826 /* Try javac. */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1827 struct temp_dir *tmpdir;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1828 char *conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1829 char *compiled_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1830 const char *java_sources[1];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1831 struct stat statbuf;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1832
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1833 tmpdir = create_temp_dir ("java", NULL, false);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1834 if (tmpdir == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1835 return true;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1836
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1837 conftest_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1838 xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1839 if (write_temp_file (tmpdir, conftest_file_name,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1840 get_goodcode_snippet (source_version)))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1841 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1842 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1843 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1844 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1845 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1846
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1847 compiled_file_name =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1848 xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1849 register_temp_file (tmpdir, compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1850
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1851 java_sources[0] = conftest_file_name;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1852 if (!compile_using_javac (java_sources, 1,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1853 false, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1854 false, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1855 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1856 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1857 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1858 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1859 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1860 /* javac compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1861 /* Try adding -source option if it is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1862 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1863
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1864 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1865 if (!compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1866 true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1867 false, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1868 tmpdir->dir_name, false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1869 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1870 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1871 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1872 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1873 const char *failcode = get_failcode_snippet (source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1874
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1875 if (failcode != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1876 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1877 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1878 free (conftest_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1879
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1880 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1881 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1882 "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1883 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1884 if (write_temp_file (tmpdir, conftest_file_name, failcode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1885 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1886 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1887 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1888 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1889 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1890
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1891 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1892 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1893 "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1894 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1895 register_temp_file (tmpdir, compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1896
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1897 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1898 if (!compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1899 false, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1900 false, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1901 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1902 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1903 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1904 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1905 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1906
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1907 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1908 if (compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1909 true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1910 false, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1911 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1912 false, false, false, true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1913 /* javac compiled conftestfail.java successfully, and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1914 "javac -source $source_version" rejects it. So the
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1915 -source option is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1916 resultp->source_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1917 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1918 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1919 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1920
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1921 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1922 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1923 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1924 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1925 /* Try with -target option alone. (Sun javac 1.3.1 has the -target
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1926 option but no -source option.) */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1927 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1928
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1929 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1930 if (!compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1931 false, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1932 true, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1933 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1934 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1935 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1936 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1937 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1938 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1939 /* "javac -target $target_version" compiled conftest.java
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1940 successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1941 /* Try adding -source option if it is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1942 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1943
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1944 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1945 if (!compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1946 true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1947 true, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1948 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1949 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1950 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1951 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1952 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1953 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1954 const char *failcode = get_failcode_snippet (source_version);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1955
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1956 if (failcode != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1957 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1958 free (compiled_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1959 free (conftest_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1960
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1961 conftest_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1962 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1963 "conftestfail.java",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1964 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1965 if (write_temp_file (tmpdir, conftest_file_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1966 failcode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1967 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1968 free (conftest_file_name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1969 cleanup_temp_dir (tmpdir);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1970 return true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1971 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1972
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1973 compiled_file_name =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1974 xconcatenated_filename (tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1975 "conftestfail.class",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1976 NULL);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1977 register_temp_file (tmpdir, compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1978
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1979 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1980 if (!compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1981 false, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1982 true, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1983 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1984 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1985 && stat (compiled_file_name, &statbuf) >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1986 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1987 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
1988
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1989 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1990 if (compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1991 true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1992 true, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1993 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1994 false, false, false, true))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1995 /* "javac -target $target_version" compiled
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1996 conftestfail.java successfully, and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1997 "javac -target $target_version -source $source_version"
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1998 rejects it. So the -source option is useful. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
1999 resultp->source_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2000 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2001 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2002 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2003
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2004 resultp->target_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2005 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2006 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2007 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2008 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2009 /* Maybe this -target option requires a -source option? Try with
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2010 -target and -source options. (Supported by Sun javac 1.4 and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2011 higher.) */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2012 unlink (compiled_file_name);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2013
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2014 java_sources[0] = conftest_file_name;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2015 if (!compile_using_javac (java_sources, 1,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2016 true, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2017 true, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2018 tmpdir->dir_name,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2019 false, false, false, true)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2020 && stat (compiled_file_name, &statbuf) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2021 && get_classfile_version (compiled_file_name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2022 <= corresponding_classfile_version (target_version))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2023 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2024 /* "javac -target $target_version -source $source_version"
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2025 compiled conftest.java successfully. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2026 resultp->source_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2027 resultp->target_option = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2028 resultp->usable = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2029 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2030 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2031 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2032
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2033 free (compiled_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2034 free (conftest_file_name);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2035
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2036 resultp->tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2037 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2038
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2039 *usablep = resultp->usable;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2040 *source_option_p = resultp->source_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2041 *target_option_p = resultp->target_option;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2042 return false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2043 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2044
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2045 static bool
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2046 is_jikes_present (void)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2047 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2048 static bool jikes_tested;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2049 static bool jikes_present;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2050
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2051 if (!jikes_tested)
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2052 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2053 /* Test for presence of jikes: "jikes 2> /dev/null ; test $? = 1" */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2054 char *argv[2];
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2055 int exitstatus;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2056
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2057 argv[0] = "jikes";
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2058 argv[1] = NULL;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2059 exitstatus = execute ("jikes", "jikes", argv, false, false, true, true,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2060 true, false, NULL);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2061 jikes_present = (exitstatus == 0 || exitstatus == 1);
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2062 jikes_tested = true;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2063 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2064
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2065 return jikes_present;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2066 }
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2067
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2068 /* ============================= Main function ============================= */
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2069
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2070 bool
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2071 compile_java_class (const char * const *java_sources,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2072 unsigned int java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2073 const char * const *classpaths,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2074 unsigned int classpaths_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2075 const char *source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2076 const char *target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2077 const char *directory,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2078 bool optimize, bool debug,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2079 bool use_minimal_classpath,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2080 bool verbose)
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2081 {
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2082 bool err = false;
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2083 char *old_JAVA_HOME;
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2084
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2085 {
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2086 const char *javac = getenv ("JAVAC");
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2087 if (javac != NULL && javac[0] != '\0')
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2088 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2089 bool usable = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2090 bool no_assert_option = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2091 bool source_option = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2092 bool target_option = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2093 bool fsource_option = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2094 bool ftarget_option = false;
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2095
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2096 if (target_version == NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2097 target_version = default_target_version ();
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2098
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2099 if (is_envjavac_gcj (javac))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2100 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2101 /* It's a version of gcj. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2102 if (is_envjavac_gcj43 (javac))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2103 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2104 /* It's a version of gcj >= 4.3. Assume the classfile versions
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2105 are correct. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2106 if (is_envjavac_gcj43_usable (javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2107 source_version, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2108 &usable,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2109 &fsource_option, &ftarget_option))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2110 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2111 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2112 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2113 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2114 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2115 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2116 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2117 /* It's a version of gcj < 4.3. Ignore the version of the
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2118 class files that it creates. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2119 if (strcmp (target_version, "1.4") == 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2120 && strcmp (source_version, "1.4") == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2121 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2122 if (is_envjavac_oldgcj_14_14_usable (javac, &usable))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2123 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2124 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2125 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2126 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2127 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2128 else if (strcmp (target_version, "1.4") == 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2129 && strcmp (source_version, "1.3") == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2130 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2131 if (is_envjavac_oldgcj_14_13_usable (javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2132 &usable,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2133 &no_assert_option))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2134 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2135 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2136 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2137 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2138 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2139 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2140 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2141 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2142 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2143 /* It's not gcj. Assume the classfile versions are correct. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2144 if (is_envjavac_nongcj_usable (javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2145 source_version, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2146 &usable,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2147 &source_option, &target_option))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2148 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2149 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2150 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2151 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2152 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2153
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2154 if (usable)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2155 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2156 char *old_classpath;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2157 char *javac_with_options;
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2158
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2159 /* Set CLASSPATH. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2160 old_classpath =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2161 set_classpath (classpaths, classpaths_count, false, verbose);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2162
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2163 javac_with_options =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2164 (no_assert_option
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2165 ? xasprintf ("%s -fno-assert", javac)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2166 : xasprintf ("%s%s%s%s%s%s%s%s%s",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2167 javac,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2168 source_option ? " -source " : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2169 source_option ? source_version : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2170 target_option ? " -target " : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2171 target_option ? target_version : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2172 fsource_option ? " -fsource=" : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2173 fsource_option ? source_version : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2174 ftarget_option ? " -ftarget=" : "",
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2175 ftarget_option ? target_version : ""));
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2176
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2177 err = compile_using_envjavac (javac_with_options,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2178 java_sources, java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2179 directory, optimize, debug, verbose,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2180 false);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2181
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2182 free (javac_with_options);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2183
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2184 /* Reset CLASSPATH. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2185 reset_classpath (old_classpath);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2186
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2187 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2188 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2189 }
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2190 }
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2191
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2192 /* Unset the JAVA_HOME environment variable. */
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2193 old_JAVA_HOME = getenv ("JAVA_HOME");
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2194 if (old_JAVA_HOME != NULL)
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2195 {
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2196 old_JAVA_HOME = xstrdup (old_JAVA_HOME);
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2197 unsetenv ("JAVA_HOME");
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2198 }
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2199
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2200 if (is_gcj_present ())
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2201 {
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
2202 /* It's a version of gcj. */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2203 bool usable = false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2204 bool no_assert_option = false;
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
2205 bool fsource_option = false;
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
2206 bool ftarget_option = false;
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2207
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2208 if (target_version == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2209 target_version = default_target_version ();
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2210
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
2211 if (is_gcj_43 ())
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2212 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2213 /* It's a version of gcj >= 4.3. Assume the classfile versions
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2214 are correct. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2215 if (is_gcj43_usable (source_version, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2216 &usable, &fsource_option, &ftarget_option))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2217 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2218 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2219 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2220 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2221 }
8078
0a080a2d054b Make use of gcj-4.3's -fsource and -ftarget option.
Bruno Haible <bruno@clisp.org>
parents: 7974
diff changeset
2222 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2223 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2224 /* It's a version of gcj < 4.3. Ignore the version of the class
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2225 files that it creates.
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2226 Test whether it supports the desired target-version and
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2227 source-version. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2228 if (strcmp (target_version, "1.4") == 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2229 && strcmp (source_version, "1.4") == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2230 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2231 if (is_oldgcj_14_14_usable (&usable))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2232 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2233 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2234 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2235 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2236 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2237 else if (strcmp (target_version, "1.4") == 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2238 && strcmp (source_version, "1.3") == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2239 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2240 if (is_oldgcj_14_13_usable (&usable, &no_assert_option))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2241 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2242 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2243 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2244 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2245 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2246 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2247
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2248 if (usable)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2249 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2250 char *old_classpath;
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2251
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2252 /* Set CLASSPATH. We could also use the --CLASSPATH=... option
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2253 of gcj. Note that --classpath=... option is different: its
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2254 argument should also contain gcj's libgcj.jar, but we don't
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2255 know its location. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2256 old_classpath =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2257 set_classpath (classpaths, classpaths_count, use_minimal_classpath,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2258 verbose);
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2259
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2260 err = compile_using_gcj (java_sources, java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2261 no_assert_option,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2262 fsource_option, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2263 ftarget_option, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2264 directory, optimize, debug, verbose, false);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2265
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2266 /* Reset CLASSPATH. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2267 reset_classpath (old_classpath);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2268
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2269 goto done2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2270 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2271 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2272
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2273 if (is_javac_present ())
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2274 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2275 bool usable = false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2276 bool source_option = false;
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2277 bool target_option = false;
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2278
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2279 if (target_version == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2280 target_version = default_target_version ();
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2281
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2282 if (is_javac_usable (source_version, target_version,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2283 &usable, &source_option, &target_option))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2284 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2285 err = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2286 goto done1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2287 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2288
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2289 if (usable)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2290 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2291 char *old_classpath;
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2292
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2293 /* Set CLASSPATH. We don't use the "-classpath ..." option because
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2294 in JDK 1.1.x its argument should also contain the JDK's
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2295 classes.zip, but we don't know its location. (In JDK 1.3.0 it
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2296 would work.) */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2297 old_classpath =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2298 set_classpath (classpaths, classpaths_count, use_minimal_classpath,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2299 verbose);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2300
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2301 err = compile_using_javac (java_sources, java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2302 source_option, source_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2303 target_option, target_version,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2304 directory, optimize, debug, verbose,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2305 false);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2306
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2307 /* Reset CLASSPATH. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2308 reset_classpath (old_classpath);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2309
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2310 goto done2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2311 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2312 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2313
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2314 if (is_jikes_present ())
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2315 {
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2316 /* Test whether it supports the desired target-version and
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2317 source-version. */
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2318 bool usable = (strcmp (source_version, "1.3") == 0);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2319
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2320 if (usable)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2321 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2322 char *old_classpath;
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2323
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2324 /* Set CLASSPATH. We could also use the "-classpath ..." option.
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2325 Since jikes doesn't come with its own standard library, it
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2326 needs a classes.zip or rt.jar or libgcj.jar in the CLASSPATH.
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2327 To increase the chance of success, we reuse the current CLASSPATH
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2328 if the user has set it. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2329 old_classpath =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2330 set_classpath (classpaths, classpaths_count, false, verbose);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2331
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2332 err = compile_using_jikes (java_sources, java_sources_count,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2333 directory, optimize, debug, verbose,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2334 false);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2335
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2336 /* Reset CLASSPATH. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2337 reset_classpath (old_classpath);
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2338
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2339 goto done2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10391
diff changeset
2340 }
7022
987fd3cc122a Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents: 6942
diff changeset
2341 }
5628
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2342
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2343 error (0, 0, _("Java compiler not found, try installing gcj or set $JAVAC"));
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2344 err = true;
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2345
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2346 done2:
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2347 if (old_JAVA_HOME != NULL)
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2348 {
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2349 xsetenv ("JAVA_HOME", old_JAVA_HOME, 1);
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2350 free (old_JAVA_HOME);
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2351 }
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2352
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2353 done1:
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2354 return err;
0ceadee93518 New module 'javacomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2355 }