source: main/tags/3.04/indexers/aclocal.m4@ 21231

Last change on this file since 21231 was 19802, checked in by mdewsnip, 15 years ago

Added checks for Javac and Java to the configure script, and removed usage of "JAVA_HOME" from the Makefiles (this is often not set -- simpler just to expect javac and java are on the path).

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