source: main/trunk/greenstone2/common-src/indexers/aclocal.m4@ 30402

Last change on this file since 30402 was 23356, checked in by sjm84, 13 years ago

Updated several configure scripts and Makefiles to make use of the JAVA, JAVAC and JAVACFLAGS environment variables, also added a --disable-java option to several of the configure scripts

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