annotate lib/javacomp.c @ 8251:1e16373508e1

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