Mercurial > hg > octave-kai > gnulib-hg
annotate lib/javacomp.c @ 7863:cb2590895141
New module 'fchdir'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 14 Jan 2007 11:32:10 +0000 |
parents | 066c3e27ecd1 |
children | a1d177cd9523 |
rev | line source |
---|---|
5628 | 1 /* Compile a Java program. |
6942
9e87d8474fb1
* lib/argp-pv.c: Remove a doubled word in a comment.
Jim Meyering <jim@meyering.net>
parents:
6761
diff
changeset
|
2 Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc. |
5628 | 3 Written by Bruno Haible <haible@clisp.cons.org>, 2001. |
4 | |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5628
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
5628 | 18 |
7304
1c4ed7637c24
Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents:
7022
diff
changeset
|
19 #include <config.h> |
5628 | 20 #include <alloca.h> |
21 | |
22 /* Specification. */ | |
23 #include "javacomp.h" | |
24 | |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
25 #include <errno.h> |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
26 #include <limits.h> |
5628 | 27 #include <stdio.h> |
28 #include <stdlib.h> | |
29 #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
|
30 #include <unistd.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/types.h> |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
32 #include <sys/stat.h> |
5628 | 33 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
34 #include "javaversion.h" |
5628 | 35 #include "execute.h" |
36 #include "pipe.h" | |
37 #include "wait-process.h" | |
38 #include "classpath.h" | |
39 #include "xsetenv.h" | |
40 #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
|
41 #include "binary-io.h" |
5628 | 42 #include "safe-read.h" |
43 #include "xalloc.h" | |
44 #include "xallocsa.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 "getline.h" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
46 #include "pathname.h" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
47 #include "fwriteerror.h" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
48 #include "clean-temp.h" |
5628 | 49 #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
|
50 #include "xvasprintf.h" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
51 #include "strstr.h" |
5628 | 52 #include "gettext.h" |
53 | |
54 #define _(str) gettext (str) | |
55 | |
7863 | 56 /* The results of open() in this file are not used with fchdir, |
57 therefore save some unnecessary work in fchdir.c. */ | |
58 #undef open | |
59 #undef close | |
60 | |
5628 | 61 |
62 /* Survey of Java compilers. | |
63 | |
64 A = does it work without CLASSPATH being set | |
65 C = option to set CLASSPATH, other than setting it in the environment | |
66 O = option for optimizing | |
67 g = option for debugging | |
68 T = test for presence | |
69 | |
70 Program from A C O g T | |
71 | |
72 $JAVAC unknown N n/a -O -g true | |
73 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 | |
74 javac JDK 1.1.8 Y -classpath P -O -g javac 2>/dev/null; test $? = 1 | |
75 javac JDK 1.3.0 Y -classpath P -O -g javac 2>/dev/null; test $? -le 2 | |
76 jikes Jikes 1.14 N -classpath P -O -g jikes 2>/dev/null; test $? = 1 | |
77 | |
78 All compilers support the option "-d DIRECTORY" for the base directory | |
79 of the classes to be written. | |
80 | |
81 The CLASSPATH is a colon separated list of pathnames. (On Windows: a | |
82 semicolon separated list of pathnames.) | |
83 | |
84 We try the Java compilers in the following order: | |
85 1. getenv ("JAVAC"), because the user must be able to override our | |
86 preferences, | |
87 2. "gcj -C", because it is a completely free compiler, | |
88 3. "javac", because it is a standard compiler, | |
89 4. "jikes", comes last because it has some deviating interpretation | |
90 of the Java Language Specification and because it requires a | |
91 CLASSPATH environment variable. | |
92 | |
93 We unset the JAVA_HOME environment variable, because a wrong setting of | |
94 this variable can confuse the JDK's javac. | |
95 */ | |
96 | |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
97 /* 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
|
98 static const char * |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
99 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
|
100 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
101 /* 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
|
102 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
|
103 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
|
104 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
|
105 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
106 /* 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
|
107 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
|
108 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
|
109 || !(java_version_cache[0] == '1' && java_version_cache[1] == '.' |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
110 && (java_version_cache[2] >= '1' && java_version_cache[2] <= '6') |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
111 && java_version_cache[3] == '\0')) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
112 java_version_cache = "1.1"; |
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 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
|
115 } |
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 /* ======================= Source version dependent ======================= */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
118 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
119 /* 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
|
120 #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
|
121 static unsigned int |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
122 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
|
123 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
124 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
|
125 && (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
|
126 && 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
|
127 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
|
128 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
|
129 return 0; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
130 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
131 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
132 /* 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
|
133 static const char * |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
134 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
|
135 { |
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.3") == 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 {}\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.4") == 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 { 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
|
140 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
|
141 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
|
142 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
|
143 return NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
144 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
145 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
146 /* 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
|
147 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
|
148 any compiler). */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
149 static const char * |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
150 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
|
151 { |
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.3") == 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 { 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
|
154 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
|
155 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
|
156 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
|
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 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
|
159 return NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
160 } |
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 /* ======================= Target version dependent ======================= */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
163 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
164 /* 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
|
165 #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
|
166 static unsigned int |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
167 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
|
168 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
169 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
|
170 && (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
|
171 && 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
|
172 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
|
173 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
|
174 return 0; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
175 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
176 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
177 /* 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
|
178 version. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
179 static int |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
180 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
|
181 { |
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.1") == 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
183 return 45; |
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.2") == 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
185 return 46; |
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.3") == 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
187 return 47; |
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.4") == 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
189 return 48; |
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.5") == 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
191 return 49; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
192 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
|
193 return 50; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
194 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
|
195 return 0; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
196 } |
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 /* ======================== Compilation subroutines ======================== */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
199 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
200 /* 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
|
201 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
|
202 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
203 compile_using_envjavac (const char *javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
204 const char * const *java_sources, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
205 unsigned int java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
206 const char *directory, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
207 bool optimize, bool debug, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
208 bool verbose, bool null_stderr) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
209 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
210 /* 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
|
211 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
|
212 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
|
213 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
|
214 bool err; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
215 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
|
216 char *command; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
217 char *argv[4]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
218 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
219 unsigned int i; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
220 char *p; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
221 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
222 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
|
223 if (optimize) |
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 (debug) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
226 command_length += 3; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
227 if (directory != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 command_length += 1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
232 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
233 command = (char *) xallocsa (command_length); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
234 p = command; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
235 /* 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
|
236 and options. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
237 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
|
238 p += strlen (javac); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
239 if (optimize) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
240 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
241 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
|
242 p += 3; |
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 if (debug) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
245 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
246 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
|
247 p += 3; |
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 if (directory != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
250 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
251 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
|
252 p += 4; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
253 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
|
254 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
255 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
|
256 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
257 *p++ = ' '; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
258 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
|
259 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
260 *p++ = '\0'; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
261 /* 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
|
262 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
|
263 abort (); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
264 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
265 if (verbose) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
266 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
|
267 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
268 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
|
269 argv[1] = "-c"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
270 argv[2] = command; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
271 argv[3] = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
272 exitstatus = execute (javac, "/bin/sh", argv, false, false, false, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
273 null_stderr, true, true); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
274 err = (exitstatus != 0); |
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 freesa (command); |
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 return err; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
279 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
280 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
281 /* 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
|
282 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
|
283 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
284 compile_using_gcj (const char * const *java_sources, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
285 unsigned int java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
286 bool no_assert_option, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
287 const char *directory, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
288 bool optimize, bool debug, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
289 bool verbose, bool null_stderr) |
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; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
295 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
296 unsigned int i; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
297 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
298 argc = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
299 2 + (no_assert_option ? 1 : 0) + (optimize ? 1 : 0) + (debug ? 1 : 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
300 + (directory != NULL ? 2 : 0) + java_sources_count; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
301 argv = (char **) xallocsa ((argc + 1) * sizeof (char *)); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
302 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
303 argp = argv; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
304 *argp++ = "gcj"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
305 *argp++ = "-C"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
306 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
|
307 *argp++ = "-fno-assert"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
308 if (optimize) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
309 *argp++ = "-O"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
310 if (debug) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
311 *argp++ = "-g"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
312 if (directory != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
313 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
314 *argp++ = "-d"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
315 *argp++ = (char *) directory; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
316 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
317 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
|
318 *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
|
319 *argp = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
320 /* 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
|
321 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
|
322 abort (); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
323 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
324 if (verbose) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
325 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
326 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
|
327 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
|
328 free (command); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
329 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
330 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
331 exitstatus = execute ("gcj", "gcj", argv, false, false, false, null_stderr, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
332 true, true); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
333 err = (exitstatus != 0); |
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 freesa (argv); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
336 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
337 return err; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
338 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
339 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
340 /* 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
|
341 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
|
342 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
343 compile_using_javac (const char * const *java_sources, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
344 unsigned int java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
345 bool source_option, 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
|
346 bool target_option, 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
|
347 const char *directory, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
348 bool optimize, bool debug, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
349 bool verbose, bool null_stderr) |
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 bool err; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
352 unsigned int argc; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
353 char **argv; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
354 char **argp; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
355 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
356 unsigned int i; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
357 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
358 argc = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
359 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
|
360 + (debug ? 1 : 0) + (directory != NULL ? 2 : 0) + java_sources_count; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
361 argv = (char **) xallocsa ((argc + 1) * sizeof (char *)); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
362 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
363 argp = argv; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
364 *argp++ = "javac"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
365 if (source_option) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
366 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
367 *argp++ = "-source"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
368 *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
|
369 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
370 if (target_option) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
371 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
372 *argp++ = "-target"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
373 *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
|
374 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
375 if (optimize) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
376 *argp++ = "-O"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
377 if (debug) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
378 *argp++ = "-g"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
379 if (directory != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
380 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
381 *argp++ = "-d"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
382 *argp++ = (char *) directory; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
383 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
384 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
|
385 *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
|
386 *argp = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
387 /* 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
|
388 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
|
389 abort (); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
390 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
391 if (verbose) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
392 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
393 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
|
394 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
|
395 free (command); |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
398 exitstatus = execute ("javac", "javac", argv, false, false, false, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
399 null_stderr, true, true); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
400 err = (exitstatus != 0); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
401 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
402 freesa (argv); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
403 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
404 return err; |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
407 /* 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
|
408 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
|
409 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
410 compile_using_jikes (const char * const *java_sources, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
411 unsigned int java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
412 const char *directory, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
413 bool optimize, bool debug, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
414 bool verbose, bool null_stderr) |
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 bool err; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
417 unsigned int argc; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
418 char **argv; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
419 char **argp; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
420 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
421 unsigned int i; |
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 argc = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
424 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
|
425 + java_sources_count; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
426 argv = (char **) xallocsa ((argc + 1) * sizeof (char *)); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
427 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
428 argp = argv; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
429 *argp++ = "jikes"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
430 if (optimize) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
431 *argp++ = "-O"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
432 if (debug) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
433 *argp++ = "-g"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
434 if (directory != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
435 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
436 *argp++ = "-d"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
437 *argp++ = (char *) directory; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
438 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
439 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
|
440 *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
|
441 *argp = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
442 /* 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
|
443 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
|
444 abort (); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
445 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
446 if (verbose) |
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 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
|
449 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
|
450 free (command); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
451 } |
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 exitstatus = execute ("jikes", "jikes", argv, false, false, false, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
454 null_stderr, true, true); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
455 err = (exitstatus != 0); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
456 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
457 freesa (argv); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
458 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
459 return err; |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
462 /* ====================== Usability test subroutines ====================== */ |
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 /* 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
|
465 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
|
466 yet. |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
467 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
|
468 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
469 write_temp_file (struct temp_dir *tmpdir, const char *file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
470 const char *contents) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
471 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
472 FILE *fp; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
473 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
474 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
|
475 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
|
476 if (fp == NULL) |
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 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
|
479 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
|
480 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
481 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
482 fputs (contents, fp); |
7412
066c3e27ecd1
Ensure temp file is closed before its directory is removed.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
483 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
|
484 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
485 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
|
486 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
487 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
488 return false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
489 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
490 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
491 /* 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
|
492 static int |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
493 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
|
494 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
495 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
|
496 int fd; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
497 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
498 /* 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
|
499 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
|
500 if (fd >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
501 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
502 /* 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
|
503 if (safe_read (fd, header, 8) == 8) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
504 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
505 /* Verify the class file signature. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
506 if (header[0] == 0xCA && header[1] == 0xFE |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
507 && header[2] == 0xBA && header[3] == 0xBE) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
508 return header[7]; |
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 close (fd); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
511 } |
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 /* 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
|
514 return INT_MAX; |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
517 /* 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
|
518 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
519 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
|
520 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
521 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
|
522 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
|
523 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
524 if (!envjavac_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
525 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
526 /* Test whether $JAVAC is gcj: |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
527 "$JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null" */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
528 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
|
529 char *command; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
530 char *argv[4]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
531 pid_t child; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
532 int fd[1]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
533 FILE *fp; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
534 char *line; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
535 size_t linesize; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
536 size_t linelen; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
537 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
538 char *p; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
539 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
540 /* 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
|
541 command_length = strlen (javac) + 1 + 9 + 1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
542 command = (char *) xallocsa (command_length); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
543 p = command; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
544 /* 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
|
545 and options. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
546 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
|
547 p += strlen (javac); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
548 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
|
549 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
|
550 /* 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
|
551 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
|
552 abort (); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
553 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
554 /* 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
|
555 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
|
556 argv[1] = "-c"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
557 argv[2] = command; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
558 argv[3] = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
559 child = create_pipe_in (javac, "/bin/sh", argv, DEV_NULL, true, true, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
560 false, fd); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
561 if (child == -1) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
562 goto failed; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
563 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
564 /* Retrieve its result. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
565 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
|
566 if (fp == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
567 goto failed; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
568 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
569 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
|
570 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
|
571 if (linelen == (size_t)(-1)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
572 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
573 fclose (fp); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
574 goto failed; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
575 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
576 envjavac_gcj = (strstr (line, "gcj") != NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
577 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
578 fclose (fp); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
579 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
580 /* Remove zombie process from process list, and retrieve exit status. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
581 exitstatus = wait_subprocess (child, javac, true, true, true, false); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
582 if (exitstatus != 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
583 envjavac_gcj = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
584 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
585 failed: |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
586 freesa (command); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
587 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
588 envjavac_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
589 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
590 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
591 return envjavac_gcj; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
592 } |
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 /* Test whether $JAVAC, known to be a version of gcj, can be used for |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
595 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
|
596 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
|
597 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
598 is_envjavac_gcj_14_14_usable (const char *javac, bool *usablep) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
599 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
600 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
|
601 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
|
602 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
603 if (!envjavac_tested) |
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 /* Try $JAVAC. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 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
|
610 struct stat statbuf; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
611 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
612 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
|
613 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
614 return true; |
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 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
617 concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
618 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
619 get_goodcode_snippet ("1.4"))) |
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 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
|
622 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
|
623 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
624 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
625 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
626 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
627 concatenated_pathname (tmpdir->dir_name, "conftest.class", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
628 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
|
629 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
630 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
|
631 if (!compile_using_envjavac (javac, java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
632 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
633 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
634 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
635 envjavac_usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
636 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
637 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
|
638 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
|
639 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
640 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
|
641 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
642 envjavac_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
643 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
644 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
645 *usablep = envjavac_usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
646 return false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
647 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
648 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
649 /* Test whether $JAVAC, known to be a version of gcj, can be used for |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
650 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
|
651 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
|
652 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
653 is_envjavac_gcj_14_13_usable (const char *javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
654 bool *usablep, bool *need_no_assert_option_p) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
655 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
656 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
|
657 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
|
658 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
|
659 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
660 if (!envjavac_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
661 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
662 /* Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
663 it makes a difference. (It could already be part of $JAVAC.) */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
664 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
|
665 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
|
666 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
|
667 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
|
668 struct stat statbuf; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
669 bool javac_works; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
670 char *javac_noassert; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
671 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
|
672 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
673 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
|
674 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
675 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
676 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
677 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
678 concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
679 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
680 get_goodcode_snippet ("1.3"))) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
681 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
682 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
|
683 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
|
684 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
685 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
686 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
687 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
688 concatenated_pathname (tmpdir->dir_name, "conftest.class", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
689 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
|
690 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
691 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
|
692 if (!compile_using_envjavac (javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
693 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
694 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
695 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
696 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
697 javac_works = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
698 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
699 javac_works = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
700 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
701 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
|
702 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
703 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
|
704 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
705 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
|
706 if (!compile_using_envjavac (javac_noassert, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
707 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
708 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
709 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
710 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
711 javac_noassert_works = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
712 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
713 javac_noassert_works = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
714 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
715 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
|
716 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
|
717 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
718 if (javac_works && javac_noassert_works) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
719 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
720 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
721 concatenated_pathname (tmpdir->dir_name, "conftestfail.java", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
722 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
723 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
724 get_failcode_snippet ("1.3"))) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
725 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
726 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
|
727 free (javac_noassert); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
728 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
|
729 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
730 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
731 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
732 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
733 concatenated_pathname (tmpdir->dir_name, "conftestfail.class", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
734 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
735 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
|
736 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
737 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
|
738 if (!compile_using_envjavac (javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
739 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
740 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
741 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
742 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
743 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
744 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
|
745 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
746 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
|
747 if (!(!compile_using_envjavac (javac_noassert, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
748 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
749 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
750 && stat (compiled_file_name, &statbuf) >= 0)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
751 /* Compilation failed. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
752 /* "$JAVAC -fno-assert" works better than $JAVAC. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
753 javac_works = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
754 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
755 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
756 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
|
757 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
|
758 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
759 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
760 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
|
761 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
762 if (javac_works) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
763 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
764 envjavac_usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
765 envjavac_need_no_assert_option = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
766 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
767 else if (javac_noassert_works) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
768 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
769 envjavac_usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
770 envjavac_need_no_assert_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
771 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
772 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
773 envjavac_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
774 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
775 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
776 *usablep = envjavac_usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
777 *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
|
778 return false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
779 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
780 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
781 /* 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
|
782 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
|
783 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
|
784 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
785 is_envjavac_nongcj_usable (const char *javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
786 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
|
787 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
|
788 bool *usablep, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
789 bool *source_option_p, bool *target_option_p) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
790 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
791 /* 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
|
792 struct result_t |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
793 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
794 bool tested; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
795 bool usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
796 bool source_option; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
797 bool target_option; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
798 }; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
799 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
|
800 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
|
801 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
802 resultp = &result_cache[source_version_index (source_version)] |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
803 [target_version_index (target_version)]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
804 if (!resultp->tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
805 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
806 /* Try $JAVAC. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
807 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
|
808 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
|
809 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
|
810 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
|
811 struct stat statbuf; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
812 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
813 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
|
814 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
815 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
816 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
817 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
818 concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
819 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
820 get_goodcode_snippet (source_version))) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
821 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
822 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
|
823 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
|
824 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
825 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
826 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
827 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
828 concatenated_pathname (tmpdir->dir_name, "conftest.class", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
829 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
|
830 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
831 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
|
832 if (!compile_using_envjavac (javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
833 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
834 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
835 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
836 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
837 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
838 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
839 /* $JAVAC compiled conftest.java successfully. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
840 /* Try adding -source option if it is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
841 char *javac_source = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
842 xasprintf ("%s -source %s", javac, source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
843 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
844 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
|
845 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
846 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
|
847 if (!compile_using_envjavac (javac_source, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
848 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
849 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
850 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
851 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
852 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
853 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
854 const char *failcode = get_failcode_snippet (source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
855 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
856 if (failcode != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
857 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
858 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
|
859 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
|
860 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
861 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
862 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
863 "conftestfail.java", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
864 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
865 if (write_temp_file (tmpdir, conftest_file_name, failcode)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
866 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
867 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
|
868 free (javac_source); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
869 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
|
870 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
871 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
872 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
873 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
874 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
875 "conftestfail.class", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
876 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
877 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
|
878 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
879 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
|
880 if (!compile_using_envjavac (javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
881 java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
882 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
883 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
884 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
885 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
886 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
|
887 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
888 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
|
889 if (compile_using_envjavac (javac_source, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
890 java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
891 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
892 false, false, false, true)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
893 /* $JAVAC compiled conftestfail.java successfully, and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
894 "$JAVAC -source $source_version" rejects it. So the |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
895 -source option is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
896 resultp->source_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
897 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
898 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
899 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
900 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
901 free (javac_source); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
902 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
903 resultp->usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
904 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
905 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
906 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
907 /* Try with -target option alone. (Sun javac 1.3.1 has the -target |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
908 option but no -source option.) */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
909 char *javac_target = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
910 xasprintf ("%s -target %s", javac, target_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
911 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
912 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
|
913 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
914 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
|
915 if (!compile_using_envjavac (javac_target, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
916 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
917 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
918 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
919 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
920 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
921 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
922 /* "$JAVAC -target $target_version" compiled conftest.java |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
923 successfully. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
924 /* Try adding -source option if it is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
925 char *javac_target_source = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
926 xasprintf ("%s -source %s", javac_target, source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
927 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
928 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
|
929 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
930 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
|
931 if (!compile_using_envjavac (javac_target_source, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
932 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
933 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
934 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
935 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
936 <= corresponding_classfile_version (target_version)) |
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 const char *failcode = get_failcode_snippet (source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
939 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
940 if (failcode != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
941 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
942 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
|
943 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
|
944 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
945 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
946 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
947 "conftestfail.java", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
948 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
949 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
950 failcode)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
951 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
952 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
|
953 free (javac_target_source); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
954 free (javac_target); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
955 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
|
956 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
957 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
958 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
959 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
960 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
961 "conftestfail.class", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
962 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
963 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
|
964 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
965 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
|
966 if (!compile_using_envjavac (javac_target, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
967 java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
968 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
969 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
970 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
971 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
972 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
|
973 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
974 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
|
975 if (compile_using_envjavac (javac_target_source, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
976 java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
977 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
978 false, false, false, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
979 true)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
980 /* "$JAVAC -target $target_version" compiled |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
981 conftestfail.java successfully, and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
982 "$JAVAC -target $target_version -source $source_version" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
983 rejects it. So the -source option is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
984 resultp->source_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
985 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
986 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
987 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
988 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
989 free (javac_target_source); |
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 resultp->target_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
992 resultp->usable = true; |
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 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
995 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
996 /* Maybe this -target option requires a -source option? Try with |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
997 -target and -source options. (Supported by Sun javac 1.4 and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
998 higher.) */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
999 char *javac_target_source = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1000 xasprintf ("%s -source %s", javac_target, source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1001 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1002 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
|
1003 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1004 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
|
1005 if (!compile_using_envjavac (javac_target_source, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1006 java_sources, 1, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1007 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1008 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1009 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1010 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1011 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1012 /* "$JAVAC -target $target_version -source $source_version" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1013 compiled conftest.java successfully. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1014 resultp->source_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1015 resultp->target_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1016 resultp->usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1017 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1018 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1019 free (javac_target_source); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1020 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1021 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1022 free (javac_target); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1023 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1024 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1025 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
|
1026 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
|
1027 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1028 resultp->tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1029 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1030 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1031 *usablep = resultp->usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1032 *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
|
1033 *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
|
1034 return false; |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1037 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1038 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
|
1039 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1040 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
|
1041 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
|
1042 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1043 if (!gcj_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1044 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1045 /* Test for presence of gcj: |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1046 "gcj --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
|
1047 sed -e 's,^[^0-9]*,,' -e 1q | \ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1048 sed -e '/^3\.[01]/d' | grep '^[3-9]' > /dev/null" */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1049 char *argv[3]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1050 pid_t child; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1051 int fd[1]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1052 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1053 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1054 argv[0] = "gcj"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1055 argv[1] = "--version"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1056 argv[2] = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1057 child = create_pipe_in ("gcj", "gcj", argv, DEV_NULL, true, true, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1058 false, fd); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1059 gcj_present = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1060 if (child != -1) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1061 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1062 /* Read the subprocess output, drop all lines except the first, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1063 drop all characters before the first digit, and test whether |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1064 the remaining string starts with a digit >= 3, but not with |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1065 "3.0" or "3.1". */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1066 char c[3]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1067 size_t count = 0; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1068 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1069 while (safe_read (fd[0], &c[count], 1) > 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1070 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1071 if (c[count] == '\n') |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1072 break; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1073 if (count == 0) |
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 if (!(c[0] >= '0' && c[0] <= '9')) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1076 continue; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1077 gcj_present = (c[0] >= '3'); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1078 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1079 count++; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1080 if (count == 3) |
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 if (c[0] == '3' && c[1] == '.' |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1083 && (c[2] == '0' || c[2] == '1')) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1084 gcj_present = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1085 break; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1086 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1087 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1088 while (safe_read (fd[0], &c[0], 1) > 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1089 ; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1090 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1091 close (fd[0]); |
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 /* Remove zombie process from process list, and retrieve exit |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1094 status. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1095 exitstatus = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1096 wait_subprocess (child, "gcj", false, true, true, false); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1097 if (exitstatus != 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1098 gcj_present = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1099 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1100 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1101 if (gcj_present) |
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 /* See if libgcj.jar is well installed. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1104 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
|
1105 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1106 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
|
1107 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1108 gcj_present = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1109 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1110 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1111 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
|
1112 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1113 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1114 concatenated_pathname (tmpdir->dir_name, "conftestlib.java", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1115 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1116 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1117 "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
|
1118 " 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
|
1119 " }\n" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1120 "}\n")) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1121 gcj_present = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1122 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1123 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1124 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
|
1125 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
|
1126 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1127 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1128 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1129 "conftestlib.class", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1130 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1131 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
|
1132 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1133 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
|
1134 if (compile_using_gcj (java_sources, 1, false, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1135 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1136 false, false, false, true)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1137 gcj_present = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1138 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1139 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
|
1140 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1141 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
|
1142 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1143 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
|
1144 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1145 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1146 gcj_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1147 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1148 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1149 return gcj_present; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1150 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1151 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1152 /* Test gcj can be used for compiling with target_version = 1.4 and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1153 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
|
1154 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
|
1155 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1156 is_gcj_14_14_usable (bool *usablep) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1157 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1158 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
|
1159 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
|
1160 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1161 if (!gcj_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1162 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1163 /* Try gcj. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1164 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
|
1165 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
|
1166 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
|
1167 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
|
1168 struct stat statbuf; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1169 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1170 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
|
1171 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1172 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1173 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1174 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1175 concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1176 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1177 get_goodcode_snippet ("1.4"))) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1178 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1179 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
|
1180 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
|
1181 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1182 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1183 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1184 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1185 concatenated_pathname (tmpdir->dir_name, "conftest.class", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1186 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
|
1187 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1188 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
|
1189 if (!compile_using_gcj (java_sources, 1, false, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1190 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1191 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1192 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1193 gcj_usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1194 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1195 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
|
1196 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
|
1197 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1198 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
|
1199 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1200 gcj_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1201 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1202 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1203 *usablep = gcj_usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1204 return false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1205 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1206 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1207 /* Test whether gcj can be used for compiling with target_version = 1.4 and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1208 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
|
1209 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
|
1210 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1211 is_gcj_14_13_usable (bool *usablep, bool *need_no_assert_option_p) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1212 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1213 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
|
1214 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
|
1215 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
|
1216 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1217 if (!gcj_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1218 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1219 /* Try gcj and "gcj -fno-assert". But add -fno-assert only if |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1220 it works (not gcj < 3.3). */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1221 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
|
1222 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
|
1223 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
|
1224 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
|
1225 struct stat statbuf; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1226 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1227 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
|
1228 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1229 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1230 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1231 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1232 concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1233 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1234 get_goodcode_snippet ("1.3"))) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1235 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1236 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
|
1237 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
|
1238 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1239 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1240 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1241 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1242 concatenated_pathname (tmpdir->dir_name, "conftest.class", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1243 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
|
1244 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1245 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
|
1246 if (!compile_using_gcj (java_sources, 1, true, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1247 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1248 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1249 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1250 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1251 gcj_usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1252 gcj_need_no_assert_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1253 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1254 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1255 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1256 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
|
1257 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1258 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
|
1259 if (!compile_using_gcj (java_sources, 1, false, tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1260 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1261 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1262 /* Compilation succeeded. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1263 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1264 gcj_usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1265 gcj_need_no_assert_option = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1266 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1267 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1268 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1269 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
|
1270 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
|
1271 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1272 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
|
1273 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1274 gcj_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1275 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1276 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1277 *usablep = gcj_usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1278 *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
|
1279 return false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1280 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1281 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1282 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1283 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
|
1284 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1285 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
|
1286 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
|
1287 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1288 if (!javac_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1289 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1290 /* 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
|
1291 char *argv[2]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1292 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1293 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1294 argv[0] = "javac"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1295 argv[1] = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1296 exitstatus = execute ("javac", "javac", argv, false, false, true, true, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1297 true, false); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1298 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
|
1299 javac_tested = true; |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1302 return javac_present; |
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 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1305 /* 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
|
1306 -target option. |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1307 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
|
1308 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1309 is_javac_usable (const char *source_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
|
1310 bool *usablep, bool *source_option_p, bool *target_option_p) |
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 /* 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
|
1313 struct result_t |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1314 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1315 bool tested; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1316 bool usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1317 bool source_option; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1318 bool target_option; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1319 }; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1320 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
|
1321 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
|
1322 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1323 resultp = &result_cache[source_version_index (source_version)] |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1324 [target_version_index (target_version)]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1325 if (!resultp->tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1326 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1327 /* Try javac. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1328 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
|
1329 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
|
1330 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
|
1331 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
|
1332 struct stat statbuf; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1333 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1334 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
|
1335 if (tmpdir == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1336 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1337 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1338 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1339 concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1340 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1341 get_goodcode_snippet (source_version))) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1342 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1343 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
|
1344 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
|
1345 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1346 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1347 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1348 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1349 concatenated_pathname (tmpdir->dir_name, "conftest.class", NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1350 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
|
1351 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1352 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
|
1353 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1354 false, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1355 false, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1356 tmpdir->dir_name, false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1357 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1358 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1359 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1360 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1361 /* javac compiled conftest.java successfully. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1362 /* Try adding -source option if it is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1363 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
|
1364 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1365 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
|
1366 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1367 true, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1368 false, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1369 tmpdir->dir_name, false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1370 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1371 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1372 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1373 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1374 const char *failcode = get_failcode_snippet (source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1375 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1376 if (failcode != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1377 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1378 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
|
1379 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
|
1380 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1381 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1382 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1383 "conftestfail.java", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1384 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1385 if (write_temp_file (tmpdir, conftest_file_name, failcode)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1386 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1387 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
|
1388 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
|
1389 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1390 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1391 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1392 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1393 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1394 "conftestfail.class", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1395 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1396 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
|
1397 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1398 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
|
1399 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1400 false, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1401 false, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1402 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1403 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1404 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1405 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1406 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
|
1407 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1408 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
|
1409 if (compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1410 true, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1411 false, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1412 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1413 false, false, false, true)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1414 /* javac compiled conftestfail.java successfully, and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1415 "javac -source $source_version" rejects it. So the |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1416 -source option is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1417 resultp->source_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1418 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1419 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1420 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1421 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1422 resultp->usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1423 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1424 else |
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 /* Try with -target option alone. (Sun javac 1.3.1 has the -target |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1427 option but no -source option.) */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1428 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
|
1429 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1430 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
|
1431 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1432 false, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1433 true, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1434 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1435 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1436 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1437 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1438 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1439 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1440 /* "javac -target $target_version" compiled conftest.java |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1441 successfully. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1442 /* Try adding -source option if it is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1443 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
|
1444 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1445 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
|
1446 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1447 true, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1448 true, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1449 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1450 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1451 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1452 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1453 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1454 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1455 const char *failcode = get_failcode_snippet (source_version); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1456 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1457 if (failcode != NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1458 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1459 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
|
1460 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
|
1461 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1462 conftest_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1463 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1464 "conftestfail.java", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1465 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1466 if (write_temp_file (tmpdir, conftest_file_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1467 failcode)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1468 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1469 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
|
1470 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
|
1471 return true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1472 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1473 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1474 compiled_file_name = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1475 concatenated_pathname (tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1476 "conftestfail.class", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1477 NULL); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1478 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
|
1479 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1480 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
|
1481 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1482 false, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1483 true, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1484 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1485 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1486 && stat (compiled_file_name, &statbuf) >= 0) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1487 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1488 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
|
1489 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1490 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
|
1491 if (compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1492 true, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1493 true, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1494 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1495 false, false, false, true)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1496 /* "javac -target $target_version" compiled |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1497 conftestfail.java successfully, and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1498 "javac -target $target_version -source $source_version" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1499 rejects it. So the -source option is useful. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1500 resultp->source_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1501 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1502 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1503 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1504 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1505 resultp->target_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1506 resultp->usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1507 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1508 else |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1509 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1510 /* Maybe this -target option requires a -source option? Try with |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1511 -target and -source options. (Supported by Sun javac 1.4 and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1512 higher.) */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1513 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
|
1514 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1515 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
|
1516 if (!compile_using_javac (java_sources, 1, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1517 true, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1518 true, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1519 tmpdir->dir_name, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1520 false, false, false, true) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1521 && stat (compiled_file_name, &statbuf) >= 0 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1522 && get_classfile_version (compiled_file_name) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1523 <= corresponding_classfile_version (target_version)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1524 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1525 /* "javac -target $target_version -source $source_version" |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1526 compiled conftest.java successfully. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1527 resultp->source_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1528 resultp->target_option = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1529 resultp->usable = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1530 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1531 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1532 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1533 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1534 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
|
1535 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
|
1536 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1537 resultp->tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1538 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1539 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1540 *usablep = resultp->usable; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1541 *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
|
1542 *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
|
1543 return false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1544 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1545 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1546 static bool |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1547 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
|
1548 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1549 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
|
1550 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
|
1551 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1552 if (!jikes_tested) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1553 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1554 /* 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
|
1555 char *argv[2]; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1556 int exitstatus; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1557 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1558 argv[0] = "jikes"; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1559 argv[1] = NULL; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1560 exitstatus = execute ("jikes", "jikes", argv, false, false, true, true, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1561 true, false); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1562 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
|
1563 jikes_tested = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1564 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1565 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1566 return jikes_present; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1567 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1568 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1569 /* ============================= Main function ============================= */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1570 |
5628 | 1571 bool |
1572 compile_java_class (const char * const *java_sources, | |
1573 unsigned int java_sources_count, | |
1574 const char * const *classpaths, | |
1575 unsigned int classpaths_count, | |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1576 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
|
1577 const char *target_version, |
5628 | 1578 const char *directory, |
1579 bool optimize, bool debug, | |
1580 bool use_minimal_classpath, | |
1581 bool verbose) | |
1582 { | |
1583 bool err = false; | |
1584 char *old_JAVA_HOME; | |
1585 | |
1586 { | |
1587 const char *javac = getenv ("JAVAC"); | |
1588 if (javac != NULL && javac[0] != '\0') | |
1589 { | |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1590 bool usable = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1591 bool no_assert_option = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1592 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
|
1593 bool target_option = false; |
5628 | 1594 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1595 if (target_version == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1596 target_version = default_target_version (); |
5628 | 1597 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1598 if (is_envjavac_gcj (javac)) |
5628 | 1599 { |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1600 /* It's a version of gcj. Ignore the version of the class files |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1601 that it creates. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1602 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
|
1603 && 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
|
1604 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1605 if (is_envjavac_gcj_14_14_usable (javac, &usable)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1606 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1607 err = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1608 goto done1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1609 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1610 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1611 else 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
|
1612 && 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
|
1613 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1614 if (is_envjavac_gcj_14_13_usable (javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1615 &usable, &no_assert_option)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1616 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1617 err = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1618 goto done1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1619 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1620 } |
5628 | 1621 } |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1622 else |
5628 | 1623 { |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1624 /* It's not gcj. Assume the classfile versions are correct. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1625 if (is_envjavac_nongcj_usable (javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1626 source_version, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1627 &usable, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1628 &source_option, &target_option)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1629 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1630 err = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1631 goto done1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1632 } |
5628 | 1633 } |
1634 | |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1635 if (usable) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1636 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1637 char *old_classpath; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1638 char *javac_with_options; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1639 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1640 /* Set CLASSPATH. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1641 old_classpath = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1642 set_classpath (classpaths, classpaths_count, false, verbose); |
5628 | 1643 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1644 javac_with_options = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1645 (no_assert_option |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1646 ? 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
|
1647 : xasprintf ("%s%s%s%s%s", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1648 javac, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1649 source_option ? " -source " : "", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1650 source_option ? source_version : "", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1651 target_option ? " -target " : "", |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1652 target_option ? target_version : "")); |
5628 | 1653 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1654 err = compile_using_envjavac (javac_with_options, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1655 java_sources, java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1656 directory, optimize, debug, verbose, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1657 false); |
5628 | 1658 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1659 free (javac_with_options); |
5628 | 1660 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1661 /* Reset CLASSPATH. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1662 reset_classpath (old_classpath); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1663 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1664 goto done1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1665 } |
5628 | 1666 } |
1667 } | |
1668 | |
1669 /* Unset the JAVA_HOME environment variable. */ | |
1670 old_JAVA_HOME = getenv ("JAVA_HOME"); | |
1671 if (old_JAVA_HOME != NULL) | |
1672 { | |
1673 old_JAVA_HOME = xstrdup (old_JAVA_HOME); | |
1674 unsetenv ("JAVA_HOME"); | |
1675 } | |
1676 | |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1677 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
|
1678 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1679 /* Test whether it supports the desired target-version and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1680 source-version. But ignore the version of the class files that |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1681 it creates. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1682 bool usable = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1683 bool no_assert_option = false; |
5628 | 1684 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1685 if (target_version == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1686 target_version = default_target_version (); |
5628 | 1687 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1688 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
|
1689 && 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
|
1690 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1691 if (is_gcj_14_14_usable (&usable)) |
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 err = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1694 goto done1; |
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 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1697 else 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
|
1698 && 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
|
1699 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1700 if (is_gcj_14_13_usable (&usable, &no_assert_option)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1701 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1702 err = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1703 goto done1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1704 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1705 } |
5628 | 1706 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1707 if (usable) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1708 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1709 char *old_classpath; |
5628 | 1710 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1711 /* Set CLASSPATH. We could also use the --CLASSPATH=... option |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1712 of gcj. Note that --classpath=... option is different: its |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1713 argument should also contain gcj's libgcj.jar, but we don't |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1714 know its location. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1715 old_classpath = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1716 set_classpath (classpaths, classpaths_count, use_minimal_classpath, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1717 verbose); |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1718 |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1719 err = compile_using_gcj (java_sources, java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1720 no_assert_option, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1721 directory, optimize, debug, verbose, false); |
5628 | 1722 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1723 /* Reset CLASSPATH. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1724 reset_classpath (old_classpath); |
5628 | 1725 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1726 goto done2; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1727 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1728 } |
5628 | 1729 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1730 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
|
1731 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1732 bool usable = false; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1733 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
|
1734 bool target_option = false; |
5628 | 1735 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1736 if (target_version == NULL) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1737 target_version = default_target_version (); |
5628 | 1738 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1739 if (is_javac_usable (source_version, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1740 &usable, &source_option, &target_option)) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1741 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1742 err = true; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1743 goto done1; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1744 } |
5628 | 1745 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1746 if (usable) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1747 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1748 char *old_classpath; |
5628 | 1749 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1750 /* Set CLASSPATH. We don't use the "-classpath ..." option because |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1751 in JDK 1.1.x its argument should also contain the JDK's |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1752 classes.zip, but we don't know its location. (In JDK 1.3.0 it |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1753 would work.) */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1754 old_classpath = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1755 set_classpath (classpaths, classpaths_count, use_minimal_classpath, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1756 verbose); |
5628 | 1757 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1758 err = compile_using_javac (java_sources, java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1759 source_option, source_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1760 target_option, target_version, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1761 directory, optimize, debug, verbose, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1762 false); |
5628 | 1763 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1764 /* Reset CLASSPATH. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1765 reset_classpath (old_classpath); |
5628 | 1766 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1767 goto done2; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1768 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1769 } |
5628 | 1770 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1771 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
|
1772 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1773 /* Test whether it supports the desired target-version and |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1774 source-version. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1775 bool usable = (strcmp (source_version, "1.3") == 0); |
5628 | 1776 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1777 if (usable) |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1778 { |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1779 char *old_classpath; |
5628 | 1780 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1781 /* Set CLASSPATH. We could also use the "-classpath ..." option. |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1782 Since jikes doesn't come with its own standard library, it |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1783 needs a classes.zip or rt.jar or libgcj.jar in the CLASSPATH. |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1784 To increase the chance of success, we reuse the current CLASSPATH |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1785 if the user has set it. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1786 old_classpath = |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1787 set_classpath (classpaths, classpaths_count, false, verbose); |
5628 | 1788 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1789 err = compile_using_jikes (java_sources, java_sources_count, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1790 directory, optimize, debug, verbose, |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1791 false); |
5628 | 1792 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1793 /* Reset CLASSPATH. */ |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1794 reset_classpath (old_classpath); |
5628 | 1795 |
7022
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1796 goto done2; |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1797 } |
987fd3cc122a
Update from GNU gettext 0.15. Accept source and target versions.
Bruno Haible <bruno@clisp.org>
parents:
6942
diff
changeset
|
1798 } |
5628 | 1799 |
1800 error (0, 0, _("Java compiler not found, try installing gcj or set $JAVAC")); | |
1801 err = true; | |
1802 | |
1803 done2: | |
1804 if (old_JAVA_HOME != NULL) | |
1805 { | |
1806 xsetenv ("JAVA_HOME", old_JAVA_HOME, 1); | |
1807 free (old_JAVA_HOME); | |
1808 } | |
1809 | |
1810 done1: | |
1811 return err; | |
1812 } |