1 | dnl @synopsis AC_PROG_JAVAC
|
---|
2 | dnl
|
---|
3 | dnl AC_PROG_JAVAC tests an existing Java compiler. It uses the
|
---|
4 | dnl environment variable JAVAC then tests in sequence various common
|
---|
5 | dnl Java compilers. For political reasons, it starts with the free
|
---|
6 | dnl ones.
|
---|
7 | dnl
|
---|
8 | dnl If you want to force a specific compiler:
|
---|
9 | dnl
|
---|
10 | dnl - at the configure.in level, set JAVAC=yourcompiler before calling
|
---|
11 | dnl AC_PROG_JAVAC
|
---|
12 | dnl
|
---|
13 | dnl - at the configure level, setenv JAVAC
|
---|
14 | dnl
|
---|
15 | dnl You can use the JAVAC variable in your Makefile.in, with @JAVAC@.
|
---|
16 | dnl
|
---|
17 | dnl *Warning*: its success or failure can depend on a proper setting of
|
---|
18 | dnl the CLASSPATH env. variable.
|
---|
19 | dnl
|
---|
20 | dnl TODO: allow to exclude compilers (rationale: most Java programs
|
---|
21 | dnl cannot compile with some compilers like guavac).
|
---|
22 | dnl
|
---|
23 | dnl Note: This is part of the set of autoconf M4 macros for Java
|
---|
24 | dnl programs. It is VERY IMPORTANT that you download the whole set,
|
---|
25 | dnl some macros depend on other. Unfortunately, the autoconf archive
|
---|
26 | dnl does not support the concept of set of macros, so I had to break it
|
---|
27 | dnl for submission. The general documentation, as well as the sample
|
---|
28 | dnl configure.in, is included in the AC_PROG_JAVA macro.
|
---|
29 | dnl
|
---|
30 | dnl @category Java
|
---|
31 | dnl @author Stephane Bortzmeyer <[email protected]>
|
---|
32 | dnl @version 2000-07-19
|
---|
33 | dnl @license GPLWithACException
|
---|
34 |
|
---|
35 | AC_DEFUN([AC_PROG_JAVAC],[
|
---|
36 | if test "x$JAVAC" = x ; then
|
---|
37 | AC_REQUIRE([AC_EXEEXT])dnl
|
---|
38 | if test "x$JAVAPREFIX" = x; then
|
---|
39 | test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT)
|
---|
40 | else
|
---|
41 | test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT, $JAVAPREFIX)
|
---|
42 | fi
|
---|
43 | test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
|
---|
44 | else
|
---|
45 | echo "Checking for javac... $JAVAC"
|
---|
46 | fi
|
---|
47 | AC_SUBST(JAVAC)
|
---|
48 | AC_PROG_JAVAC_WORKS
|
---|
49 | AC_PROVIDE([$0])dnl
|
---|
50 | ])
|
---|
51 |
|
---|
52 | dnl @synopsis AC_PROG_JAVAC_WORKS
|
---|
53 | dnl
|
---|
54 | dnl Internal use ONLY.
|
---|
55 | dnl
|
---|
56 | dnl Note: This is part of the set of autoconf M4 macros for Java
|
---|
57 | dnl programs. It is VERY IMPORTANT that you download the whole set,
|
---|
58 | dnl some macros depend on other. Unfortunately, the autoconf archive
|
---|
59 | dnl does not support the concept of set of macros, so I had to break it
|
---|
60 | dnl for submission. The general documentation, as well as the sample
|
---|
61 | dnl configure.in, is included in the AC_PROG_JAVA macro.
|
---|
62 | dnl
|
---|
63 | dnl @category Java
|
---|
64 | dnl @author Stephane Bortzmeyer <[email protected]>
|
---|
65 | dnl @version 2000-07-19
|
---|
66 | dnl @license GPLWithACException
|
---|
67 |
|
---|
68 | AC_DEFUN([AC_PROG_JAVAC_WORKS],[
|
---|
69 | AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
|
---|
70 | JAVA_TEST=Test.java
|
---|
71 | CLASS_TEST=Test.class
|
---|
72 | cat << \EOF > $JAVA_TEST
|
---|
73 | /* [#]line __oline__ "configure" */
|
---|
74 | public class Test {
|
---|
75 | }
|
---|
76 | EOF
|
---|
77 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
|
---|
78 | ac_cv_prog_javac_works=yes
|
---|
79 | else
|
---|
80 | AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
|
---|
81 | echo "configure: failed program was:" >&AC_FD_CC
|
---|
82 | cat $JAVA_TEST >&AC_FD_CC
|
---|
83 | fi
|
---|
84 | rm -f $JAVA_TEST $CLASS_TEST
|
---|
85 | ])
|
---|
86 | AC_PROVIDE([$0])dnl
|
---|
87 | if test "x$JAVACFLAGS" = x ; then
|
---|
88 | JAVACFLAGS="-source 1.4 -target 1.4"
|
---|
89 | fi
|
---|
90 | AC_SUBST(JAVACFLAGS)
|
---|
91 | ])
|
---|
92 |
|
---|
93 | dnl @synopsis AC_PROG_JAVA
|
---|
94 | dnl
|
---|
95 | dnl Here is a summary of the main macros:
|
---|
96 | dnl
|
---|
97 | dnl AC_PROG_JAVAC: finds a Java compiler.
|
---|
98 | dnl
|
---|
99 | dnl AC_PROG_JAVA: finds a Java virtual machine.
|
---|
100 | dnl
|
---|
101 | dnl AC_CHECK_CLASS: finds if we have the given class (beware of
|
---|
102 | dnl CLASSPATH!).
|
---|
103 | dnl
|
---|
104 | dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops
|
---|
105 | dnl otherwise.
|
---|
106 | dnl
|
---|
107 | dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source.
|
---|
108 | dnl
|
---|
109 | dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source.
|
---|
110 | dnl
|
---|
111 | dnl AC_JAVA_OPTIONS: adds Java configure options.
|
---|
112 | dnl
|
---|
113 | dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the
|
---|
114 | dnl environment variable JAVA then tests in sequence various common
|
---|
115 | dnl Java virtual machines. For political reasons, it starts with the
|
---|
116 | dnl free ones. You *must* call [AC_PROG_JAVAC] before.
|
---|
117 | dnl
|
---|
118 | dnl If you want to force a specific VM:
|
---|
119 | dnl
|
---|
120 | dnl - at the configure.in level, set JAVA=yourvm before calling
|
---|
121 | dnl AC_PROG_JAVA
|
---|
122 | dnl
|
---|
123 | dnl (but after AC_INIT)
|
---|
124 | dnl
|
---|
125 | dnl - at the configure level, setenv JAVA
|
---|
126 | dnl
|
---|
127 | dnl You can use the JAVA variable in your Makefile.in, with @JAVA@.
|
---|
128 | dnl
|
---|
129 | dnl *Warning*: its success or failure can depend on a proper setting of
|
---|
130 | dnl the CLASSPATH env. variable.
|
---|
131 | dnl
|
---|
132 | dnl TODO: allow to exclude virtual machines (rationale: most Java
|
---|
133 | dnl programs cannot run with some VM like kaffe).
|
---|
134 | dnl
|
---|
135 | dnl Note: This is part of the set of autoconf M4 macros for Java
|
---|
136 | dnl programs. It is VERY IMPORTANT that you download the whole set,
|
---|
137 | dnl some macros depend on other. Unfortunately, the autoconf archive
|
---|
138 | dnl does not support the concept of set of macros, so I had to break it
|
---|
139 | dnl for submission.
|
---|
140 | dnl
|
---|
141 | dnl A Web page, with a link to the latest CVS snapshot is at
|
---|
142 | dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
|
---|
143 | dnl
|
---|
144 | dnl This is a sample configure.in Process this file with autoconf to
|
---|
145 | dnl produce a configure script.
|
---|
146 | dnl
|
---|
147 | dnl AC_INIT(UnTag.java)
|
---|
148 | dnl
|
---|
149 | dnl dnl Checks for programs.
|
---|
150 | dnl AC_CHECK_CLASSPATH
|
---|
151 | dnl AC_PROG_JAVAC
|
---|
152 | dnl AC_PROG_JAVA
|
---|
153 | dnl
|
---|
154 | dnl dnl Checks for classes
|
---|
155 | dnl AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
|
---|
156 | dnl AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
|
---|
157 | dnl
|
---|
158 | dnl AC_OUTPUT(Makefile)
|
---|
159 | dnl
|
---|
160 | dnl @category Java
|
---|
161 | dnl @author Stephane Bortzmeyer <[email protected]>
|
---|
162 | dnl @version 2000-07-19
|
---|
163 | dnl @license GPLWithACException
|
---|
164 |
|
---|
165 | AC_DEFUN([AC_PROG_JAVA],[
|
---|
166 | if test "x$JAVA" = x ; then
|
---|
167 | AC_REQUIRE([AC_EXEEXT])dnl
|
---|
168 | if test x$JAVAPREFIX = x; then
|
---|
169 | test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT)
|
---|
170 | else
|
---|
171 | test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT, $JAVAPREFIX)
|
---|
172 | fi
|
---|
173 | test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
|
---|
174 | fi
|
---|
175 | AC_SUBST(JAVA)
|
---|
176 | AC_PROG_JAVA_WORKS
|
---|
177 | AC_PROVIDE([$0])dnl
|
---|
178 | ])
|
---|
179 |
|
---|
180 | dnl @synopsis AC_PROG_JAVA_WORKS
|
---|
181 | dnl
|
---|
182 | dnl Internal use ONLY.
|
---|
183 | dnl
|
---|
184 | dnl Note: This is part of the set of autoconf M4 macros for Java
|
---|
185 | dnl programs. It is VERY IMPORTANT that you download the whole set,
|
---|
186 | dnl some macros depend on other. Unfortunately, the autoconf archive
|
---|
187 | dnl does not support the concept of set of macros, so I had to break it
|
---|
188 | dnl for submission. The general documentation, as well as the sample
|
---|
189 | dnl configure.in, is included in the AC_PROG_JAVA macro.
|
---|
190 | dnl
|
---|
191 | dnl @category Java
|
---|
192 | dnl @author Stephane Bortzmeyer <[email protected]>
|
---|
193 | dnl @version 2000-07-19
|
---|
194 | dnl @license GPLWithACException
|
---|
195 |
|
---|
196 | AC_DEFUN([AC_PROG_JAVA_WORKS], [
|
---|
197 | AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
|
---|
198 | if test x$uudecode = xyes; then
|
---|
199 | AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
|
---|
200 | dnl /**
|
---|
201 | dnl * Test.java: used to test if java compiler works.
|
---|
202 | dnl */
|
---|
203 | dnl public class Test
|
---|
204 | dnl {
|
---|
205 | dnl
|
---|
206 | dnl public static void
|
---|
207 | dnl main( String[] argv )
|
---|
208 | dnl {
|
---|
209 | dnl System.exit (0);
|
---|
210 | dnl }
|
---|
211 | dnl
|
---|
212 | dnl }
|
---|
213 | cat << \EOF > Test.uue
|
---|
214 | begin-base64 644 Test.class
|
---|
215 | yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
|
---|
216 | bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
|
---|
217 | bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
|
---|
218 | YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
|
---|
219 | aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
|
---|
220 | AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
|
---|
221 | AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
|
---|
222 | ====
|
---|
223 | EOF
|
---|
224 | if uudecode$EXEEXT Test.uue; then
|
---|
225 | ac_cv_prog_uudecode_base64=yes
|
---|
226 | else
|
---|
227 | echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
|
---|
228 | echo "configure: failed file was:" >&AC_FD_CC
|
---|
229 | cat Test.uue >&AC_FD_CC
|
---|
230 | ac_cv_prog_uudecode_base64=no
|
---|
231 | fi
|
---|
232 | rm -f Test.uue])
|
---|
233 | fi
|
---|
234 | if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
---|
235 | rm -f Test.class
|
---|
236 | AC_MSG_WARN([I have to compile Test.class from scratch])
|
---|
237 | if test x$ac_cv_prog_javac_works = xno; then
|
---|
238 | AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
|
---|
239 | fi
|
---|
240 | if test x$ac_cv_prog_javac_works = x; then
|
---|
241 | AC_PROG_JAVAC
|
---|
242 | fi
|
---|
243 | fi
|
---|
244 | AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
|
---|
245 | JAVA_TEST=Test.java
|
---|
246 | CLASS_TEST=Test.class
|
---|
247 | TEST=Test
|
---|
248 | changequote(, )dnl
|
---|
249 | cat << \EOF > $JAVA_TEST
|
---|
250 | /* [#]line __oline__ "configure" */
|
---|
251 | public class Test {
|
---|
252 | public static void main (String args[]) {
|
---|
253 | System.exit (0);
|
---|
254 | } }
|
---|
255 | EOF
|
---|
256 | changequote([, ])dnl
|
---|
257 | if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
---|
258 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
|
---|
259 | :
|
---|
260 | else
|
---|
261 | echo "configure: failed program was:" >&AC_FD_CC
|
---|
262 | cat $JAVA_TEST >&AC_FD_CC
|
---|
263 | AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
|
---|
264 | fi
|
---|
265 | fi
|
---|
266 | if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
|
---|
267 | ac_cv_prog_java_works=yes
|
---|
268 | else
|
---|
269 | echo "configure: failed program was:" >&AC_FD_CC
|
---|
270 | cat $JAVA_TEST >&AC_FD_CC
|
---|
271 | AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
|
---|
272 | fi
|
---|
273 | rm -fr $JAVA_TEST $CLASS_TEST Test.uue
|
---|
274 | ])
|
---|
275 | AC_PROVIDE([$0])dnl
|
---|
276 | ]
|
---|
277 | )
|
---|