source: main/trunk/greenstone2/runtime-src/aclocal.m4@ 27108

Last change on this file since 27108 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

  • Property svn:executable set to *
File size: 13.1 KB
Line 
1# Local additions to Autoconf macros.
2# Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
3# François Pinard <[email protected]>, 1992.
4
5# [TS:Aug/95] - chopped out the NLS stuff which I don't support
6
7## ------------------------------- ##
8## Check for function prototypes. ##
9## ------------------------------- ##
10
11AC_DEFUN(fp_C_PROTOTYPES,
12[AC_REQUIRE([fp_PROG_CC_STDC])
13AC_MSG_CHECKING([for function prototypes])
14if test "$ac_cv_prog_cc_stdc" != no; then
15 AC_MSG_RESULT(yes)
16 AC_DEFINE(PROTOTYPES)
17 U= ANSI2KNR=
18else
19 AC_MSG_RESULT(no)
20 U=_ ANSI2KNR=ansi2knr
21fi
22AC_SUBST(U)dnl
23AC_SUBST(ANSI2KNR)dnl
24])
25
26## ----------------------------------------- ##
27## ANSIfy the C compiler whenever possible. ##
28## ----------------------------------------- ##
29
30# @defmac AC_PROG_CC_STDC
31# @maindex PROG_CC_STDC
32# @ovindex CC
33# If the C compiler in not in ANSI C mode by default, try to add an option
34# to output variable @code{CC} to make it so. This macro tries various
35# options that select ANSI C on some system or another. It considers the
36# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
37# handles function prototypes correctly.
38#
39# If you use this macro, you should check after calling it whether the C
40# compiler has been set to accept ANSI C; if not, the shell variable
41# @code{ac_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
42# code in ANSI C, you can make an un-ANSIfied copy of it by using the
43# program @code{ansi2knr}, which comes with Ghostscript.
44# @end defmac
45
46AC_DEFUN(fp_PROG_CC_STDC,
47[AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
48AC_CACHE_VAL(ac_cv_prog_cc_stdc,
49[ac_cv_prog_cc_stdc=no
50ac_save_CFLAGS="$CFLAGS"
51# Don't try gcc -ansi; that turns off useful extensions and
52# breaks some systems' header files.
53# AIX -qlanglvl=ansi
54# Ultrix and OSF/1 -std1
55# HP-UX -Aa -D_HPUX_SOURCE
56# SVR4 -Xc
57for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc
58do
59 CFLAGS="$ac_save_CFLAGS $ac_arg"
60 AC_TRY_COMPILE(
61[#if !defined(__STDC__) || __STDC__ != 1
62choke me
63#endif
64], [int test (int i, double x);
65struct s1 {int (*f) (int a);};
66struct s2 {int (*f) (double a);};],
67[ac_cv_prog_cc_stdc="$ac_arg"; break])
68done
69CFLAGS="$ac_save_CFLAGS"
70])
71AC_MSG_RESULT($ac_cv_prog_cc_stdc)
72case "x$ac_cv_prog_cc_stdc" in
73 x|xno) ;;
74 *) CC="$CC $ac_cv_prog_cc_stdc" ;;
75esac
76])
77
78## --------------------------------------------------------- ##
79## Use AC_PROG_INSTALL, supplementing it with INSTALL_SCRIPT ##
80## substitution. ##
81## --------------------------------------------------------- ##
82
83AC_DEFUN(fp_PROG_INSTALL,
84[AC_PROG_INSTALL
85test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL} -m 755'
86AC_SUBST(INSTALL_SCRIPT)dnl
87])
88
89## ----------------------------------- ##
90## Check if --with-dmalloc was given. ##
91## ----------------------------------- ##
92
93# I just checked, and GNU rx seems to work fine with a slightly
94# modified GNU m4. So, I put out the test below in my aclocal.m4,
95# and will try to use it in my things. The idea is to distribute
96# rx.[hc] and regex.[hc] together, for a while. The WITH_REGEX symbol
97# (which should also be documented in acconfig.h) is used to decide
98# which of regex.h or rx.h should be included in the application.
99#
100# If `./configure --with-regex' is given, the package will use
101# the older regex. Else, a check is made to see if rx is already
102# installed, as with newer Linux'es. If not found, the package will
103# use the rx from the distribution. If found, the package will use
104# the system's rx which, on Linux at least, will result in a smaller
105# executable file.
106
107AC_DEFUN(fp_WITH_DMALLOC,
108[AC_MSG_CHECKING(if malloc debugging is wanted)
109AC_ARG_WITH(dmalloc,
110[ --with-dmalloc use dmalloc, as in
111 ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz],
112[if test "$withval" = yes; then
113 AC_MSG_RESULT(yes)
114 AC_DEFINE(WITH_DMALLOC)
115 LIBS="$LIBS -ldmalloc"
116 LDFLAGS="$LDFLAGS -g"
117else
118 AC_MSG_RESULT(no)
119fi], [AC_MSG_RESULT(no)])
120])
121
122## --------------------------------- ##
123## Check if --with-regex was given. ##
124## --------------------------------- ##
125
126AC_DEFUN(fp_WITH_REGEX,
127[AC_MSG_CHECKING(which of rx or regex is wanted)
128AC_ARG_WITH(regex,
129[ --with-regex use older regex in lieu of GNU rx for matching],
130[if test "$withval" = yes; then
131 ac_with_regex=1
132 AC_MSG_RESULT(regex)
133 AC_DEFINE(WITH_REGEX)
134 AC_LIBOBJ([regex])
135fi])
136if test -z "$ac_with_regex"; then
137 AC_MSG_RESULT(rx)
138 AC_CHECK_FUNC(re_rx_search, , [AC_LIBOBJ([rx])])
139fi
140])
141dnl @synopsis AC_PROG_JAVAC
142dnl
143dnl AC_PROG_JAVAC tests an existing Java compiler. It uses the
144dnl environment variable JAVAC then tests in sequence various common
145dnl Java compilers. For political reasons, it starts with the free
146dnl ones.
147dnl
148dnl If you want to force a specific compiler:
149dnl
150dnl - at the configure.in level, set JAVAC=yourcompiler before calling
151dnl AC_PROG_JAVAC
152dnl
153dnl - at the configure level, setenv JAVAC
154dnl
155dnl You can use the JAVAC variable in your Makefile.in, with @JAVAC@.
156dnl
157dnl *Warning*: its success or failure can depend on a proper setting of
158dnl the CLASSPATH env. variable.
159dnl
160dnl TODO: allow to exclude compilers (rationale: most Java programs
161dnl cannot compile with some compilers like guavac).
162dnl
163dnl Note: This is part of the set of autoconf M4 macros for Java
164dnl programs. It is VERY IMPORTANT that you download the whole set,
165dnl some macros depend on other. Unfortunately, the autoconf archive
166dnl does not support the concept of set of macros, so I had to break it
167dnl for submission. The general documentation, as well as the sample
168dnl configure.in, is included in the AC_PROG_JAVA macro.
169dnl
170dnl @category Java
171dnl @author Stephane Bortzmeyer <[email protected]>
172dnl @version 2000-07-19
173dnl @license GPLWithACException
174
175AC_DEFUN([AC_PROG_JAVAC],[
176if test "x$JAVAC" = x ; then
177 AC_REQUIRE([AC_EXEEXT])dnl
178 if test "x$JAVAPREFIX" = x; then
179 test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT)
180 else
181 test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT, $JAVAPREFIX)
182 fi
183 test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
184else
185 echo "Checking for javac... $JAVAC"
186fi
187
188AC_SUBST(JAVAC)
189AC_PROG_JAVAC_WORKS
190AC_PROVIDE([$0])dnl
191])
192
193dnl @synopsis AC_PROG_JAVAC_WORKS
194dnl
195dnl Internal use ONLY.
196dnl
197dnl Note: This is part of the set of autoconf M4 macros for Java
198dnl programs. It is VERY IMPORTANT that you download the whole set,
199dnl some macros depend on other. Unfortunately, the autoconf archive
200dnl does not support the concept of set of macros, so I had to break it
201dnl for submission. The general documentation, as well as the sample
202dnl configure.in, is included in the AC_PROG_JAVA macro.
203dnl
204dnl @category Java
205dnl @author Stephane Bortzmeyer <[email protected]>
206dnl @version 2000-07-19
207dnl @license GPLWithACException
208
209AC_DEFUN([AC_PROG_JAVAC_WORKS],[
210AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
211JAVA_TEST=Test.java
212CLASS_TEST=Test.class
213cat << \EOF > $JAVA_TEST
214/* [#]line __oline__ "configure" */
215public class Test {
216}
217EOF
218if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
219 ac_cv_prog_javac_works=yes
220else
221 AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
222 echo "configure: failed program was:" >&AC_FD_CC
223 cat $JAVA_TEST >&AC_FD_CC
224fi
225rm -f $JAVA_TEST $CLASS_TEST
226])
227AC_PROVIDE([$0])dnl
228if test "x$JAVACFLAGS" = x ; then
229 JAVACFLAGS="-source 1.4 -target 1.4"
230fi
231AC_SUBST(JAVACFLAGS)
232])
233
234dnl @synopsis AC_PROG_JAVA
235dnl
236dnl Here is a summary of the main macros:
237dnl
238dnl AC_PROG_JAVAC: finds a Java compiler.
239dnl
240dnl AC_PROG_JAVA: finds a Java virtual machine.
241dnl
242dnl AC_CHECK_CLASS: finds if we have the given class (beware of
243dnl CLASSPATH!).
244dnl
245dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops
246dnl otherwise.
247dnl
248dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source.
249dnl
250dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source.
251dnl
252dnl AC_JAVA_OPTIONS: adds Java configure options.
253dnl
254dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the
255dnl environment variable JAVA then tests in sequence various common
256dnl Java virtual machines. For political reasons, it starts with the
257dnl free ones. You *must* call [AC_PROG_JAVAC] before.
258dnl
259dnl If you want to force a specific VM:
260dnl
261dnl - at the configure.in level, set JAVA=yourvm before calling
262dnl AC_PROG_JAVA
263dnl
264dnl (but after AC_INIT)
265dnl
266dnl - at the configure level, setenv JAVA
267dnl
268dnl You can use the JAVA variable in your Makefile.in, with @JAVA@.
269dnl
270dnl *Warning*: its success or failure can depend on a proper setting of
271dnl the CLASSPATH env. variable.
272dnl
273dnl TODO: allow to exclude virtual machines (rationale: most Java
274dnl programs cannot run with some VM like kaffe).
275dnl
276dnl Note: This is part of the set of autoconf M4 macros for Java
277dnl programs. It is VERY IMPORTANT that you download the whole set,
278dnl some macros depend on other. Unfortunately, the autoconf archive
279dnl does not support the concept of set of macros, so I had to break it
280dnl for submission.
281dnl
282dnl A Web page, with a link to the latest CVS snapshot is at
283dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
284dnl
285dnl This is a sample configure.in Process this file with autoconf to
286dnl produce a configure script.
287dnl
288dnl AC_INIT(UnTag.java)
289dnl
290dnl dnl Checks for programs.
291dnl AC_CHECK_CLASSPATH
292dnl AC_PROG_JAVAC
293dnl AC_PROG_JAVA
294dnl
295dnl dnl Checks for classes
296dnl AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
297dnl AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
298dnl
299dnl AC_OUTPUT(Makefile)
300dnl
301dnl @category Java
302dnl @author Stephane Bortzmeyer <[email protected]>
303dnl @version 2000-07-19
304dnl @license GPLWithACException
305
306AC_DEFUN([AC_PROG_JAVA],[
307if test "x$JAVA" = x ; then
308 AC_REQUIRE([AC_EXEEXT])dnl
309 if test x$JAVAPREFIX = x; then
310 test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT)
311 else
312 test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT, $JAVAPREFIX)
313 fi
314 test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
315fi
316AC_SUBST(JAVA)
317AC_PROG_JAVA_WORKS
318AC_PROVIDE([$0])dnl
319])
320
321dnl @synopsis AC_PROG_JAVA_WORKS
322dnl
323dnl Internal use ONLY.
324dnl
325dnl Note: This is part of the set of autoconf M4 macros for Java
326dnl programs. It is VERY IMPORTANT that you download the whole set,
327dnl some macros depend on other. Unfortunately, the autoconf archive
328dnl does not support the concept of set of macros, so I had to break it
329dnl for submission. The general documentation, as well as the sample
330dnl configure.in, is included in the AC_PROG_JAVA macro.
331dnl
332dnl @category Java
333dnl @author Stephane Bortzmeyer <[email protected]>
334dnl @version 2000-07-19
335dnl @license GPLWithACException
336
337AC_DEFUN([AC_PROG_JAVA_WORKS], [
338AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
339if test x$uudecode = xyes; then
340AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
341dnl /**
342dnl * Test.java: used to test if java compiler works.
343dnl */
344dnl public class Test
345dnl {
346dnl
347dnl public static void
348dnl main( String[] argv )
349dnl {
350dnl System.exit (0);
351dnl }
352dnl
353dnl }
354cat << \EOF > Test.uue
355begin-base64 644 Test.class
356yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
357bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
358bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
359YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
360aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
361AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
362AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
363====
364EOF
365if uudecode$EXEEXT Test.uue; then
366 ac_cv_prog_uudecode_base64=yes
367else
368 echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
369 echo "configure: failed file was:" >&AC_FD_CC
370 cat Test.uue >&AC_FD_CC
371 ac_cv_prog_uudecode_base64=no
372fi
373rm -f Test.uue])
374fi
375if test x$ac_cv_prog_uudecode_base64 != xyes; then
376 rm -f Test.class
377 AC_MSG_WARN([I have to compile Test.class from scratch])
378 if test x$ac_cv_prog_javac_works = xno; then
379 AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
380 fi
381 if test x$ac_cv_prog_javac_works = x; then
382 AC_PROG_JAVAC
383 fi
384fi
385AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
386JAVA_TEST=Test.java
387CLASS_TEST=Test.class
388TEST=Test
389changequote(, )dnl
390cat << \EOF > $JAVA_TEST
391/* [#]line __oline__ "configure" */
392public class Test {
393public static void main (String args[]) {
394 System.exit (0);
395} }
396EOF
397changequote([, ])dnl
398if test x$ac_cv_prog_uudecode_base64 != xyes; then
399 if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
400 :
401 else
402 echo "configure: failed program was:" >&AC_FD_CC
403 cat $JAVA_TEST >&AC_FD_CC
404 AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
405 fi
406fi
407if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
408 ac_cv_prog_java_works=yes
409else
410 echo "configure: failed program was:" >&AC_FD_CC
411 cat $JAVA_TEST >&AC_FD_CC
412 AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
413fi
414rm -fr $JAVA_TEST $CLASS_TEST Test.uue
415])
416AC_PROVIDE([$0])dnl
417]
418)
Note: See TracBrowser for help on using the repository browser.