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

Last change on this file since 23356 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 *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.9 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, ,
139 [AC_CHECK_SIZEOF(unsigned char *, unsigned char *)
140 if test "$ac_cv_sizeof_unsigned_char_p" = 8
141 then
142 AC_MSG_WARN(I'm forcing you to use regex because I can't
143 find a local rx library and the one included with this
144 distribution doesn't work on 64-bit machines like yours)
145 AC_LIBOBJ([regex])
146 else
147 AC_LIBOBJ([rx])
148 fi]
149 )
150fi
151])
152
153
154## --------------------------------------- ##
155## Check if --with-gnu-readline was given. ##
156## --------------------------------------- ##
157
158AC_DEFUN(fp_WITH_GNU_READLINE,
159[AC_MSG_CHECKING(whether GNU readline requested)
160 AC_ARG_WITH(gnu_readline,
161 [ --with-gnu-readline compile with GNU readline support],
162 [if test "$withval" = yes; then
163 AC_MSG_RESULT(yes)
164 ac_with_gnu_readline=1
165 else
166 AC_MSG_RESULT(no)
167 fi],
168 AC_MSG_RESULT(no))
169
170 if test -n "$ac_with_gnu_readline"; then
171 AC_CHECK_HEADER(readline/readline.h, ac_mg_readline_header_found=1,
172 AC_MSG_WARN(Can't find GNU readline headers; configuring without \
173GNU readline support))
174 if test -n "$ac_mg_readline_header_found"; then
175 # first check whether we can find the readline library itself
176 AC_CHECK_LIB(readline, main,
177 [ac_mg_readline_lib_found=1
178 AC_DEFINE(WITH_GNU_READLINE)
179 LIBS="$LIBS -lreadline"],
180 AC_MSG_WARN(Can't find GNU readline library; configuring without \
181GNU readline support))
182 if test -n "$ac_mg_readline_lib_found"; then
183 # on some systems, readline needs curses. It is difficult to
184 # determine whether this is necessary on the current system,
185 # since other undefined symbols can be turned up by an
186 # AC_CHECK_LIB(readline, readline) test that are actually defined
187 # by mg itself (e.g. xmalloc, xrealloc). So, if we find libcurses,
188 # we just bung it on and hope for the best.
189 AC_CHECK_LIB(curses, main,
190 LIBS="$LIBS -lcurses")
191 fi
192 fi
193 fi
194])
195
196
197
198#AC_DEFUN(fp_WITH_GNU_READLINE,
199#[AC_MSG_CHECKING(whether GNU readline requested)
200# AC_ARG_WITH(gnu-readline,
201# [ --with-gnu-readline compile with GNU readline support],
202# [if test "$withval" = yes; then
203# AC_MSG_RESULT(yes)
204# ac_with_gnu_readline=1
205# else
206# AC_MSG_RESULT(no)
207# fi],
208# AC_MSG_RESULT(no))
209# if test -n "$ac_with_gnu_readline"; then
210# AC_CHECK_LIB(readline, main,
211# AC_CHECK_HEADER(readline/readline.h,
212# [AC_DEFINE(WITH_GNU_READLINE)
213## curses required on some systems (DEC OSF/1), but not on others (GNU/Linux,
214## Solaris 2.6). Forcing its inclusion is unsophisticated; if it causes
215## any actual problems on any UNIX platforms, let the maintainer know.
216# LIBS="$LIBS -lreadline -lcurses"],
217# AC_MSG_WARN(Can't find GNU readline headers: configuring \
218#without GNU readline support)
219# ),
220# AC_MSG_WARN(Can't find GNU readline library: configuring \
221#without GNU readline support)
222# )
223# fi
224#])
225dnl @synopsis AC_PROG_JAVAC
226dnl
227dnl AC_PROG_JAVAC tests an existing Java compiler. It uses the
228dnl environment variable JAVAC then tests in sequence various common
229dnl Java compilers. For political reasons, it starts with the free
230dnl ones.
231dnl
232dnl If you want to force a specific compiler:
233dnl
234dnl - at the configure.in level, set JAVAC=yourcompiler before calling
235dnl AC_PROG_JAVAC
236dnl
237dnl - at the configure level, setenv JAVAC
238dnl
239dnl You can use the JAVAC variable in your Makefile.in, with @JAVAC@.
240dnl
241dnl *Warning*: its success or failure can depend on a proper setting of
242dnl the CLASSPATH env. variable.
243dnl
244dnl TODO: allow to exclude compilers (rationale: most Java programs
245dnl cannot compile with some compilers like guavac).
246dnl
247dnl Note: This is part of the set of autoconf M4 macros for Java
248dnl programs. It is VERY IMPORTANT that you download the whole set,
249dnl some macros depend on other. Unfortunately, the autoconf archive
250dnl does not support the concept of set of macros, so I had to break it
251dnl for submission. The general documentation, as well as the sample
252dnl configure.in, is included in the AC_PROG_JAVA macro.
253dnl
254dnl @category Java
255dnl @author Stephane Bortzmeyer <[email protected]>
256dnl @version 2000-07-19
257dnl @license GPLWithACException
258
259AC_DEFUN([AC_PROG_JAVAC],[
260if test "x$JAVAC" = x ; then
261 AC_REQUIRE([AC_EXEEXT])dnl
262 if test "x$JAVAPREFIX" = x; then
263 test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT)
264 else
265 test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT, $JAVAPREFIX)
266 fi
267 test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
268else
269 echo "Checking for javac... $JAVAC"
270fi
271AC_SUBST(JAVAC)
272AC_PROG_JAVAC_WORKS
273AC_PROVIDE([$0])dnl
274])
275
276dnl @synopsis AC_PROG_JAVAC_WORKS
277dnl
278dnl Internal use ONLY.
279dnl
280dnl Note: This is part of the set of autoconf M4 macros for Java
281dnl programs. It is VERY IMPORTANT that you download the whole set,
282dnl some macros depend on other. Unfortunately, the autoconf archive
283dnl does not support the concept of set of macros, so I had to break it
284dnl for submission. The general documentation, as well as the sample
285dnl configure.in, is included in the AC_PROG_JAVA macro.
286dnl
287dnl @category Java
288dnl @author Stephane Bortzmeyer <[email protected]>
289dnl @version 2000-07-19
290dnl @license GPLWithACException
291
292AC_DEFUN([AC_PROG_JAVAC_WORKS],[
293AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
294JAVA_TEST=Test.java
295CLASS_TEST=Test.class
296cat << \EOF > $JAVA_TEST
297/* [#]line __oline__ "configure" */
298public class Test {
299}
300EOF
301if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
302 ac_cv_prog_javac_works=yes
303else
304 AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
305 echo "configure: failed program was:" >&AC_FD_CC
306 cat $JAVA_TEST >&AC_FD_CC
307fi
308rm -f $JAVA_TEST $CLASS_TEST
309])
310AC_PROVIDE([$0])dnl
311if test "x$JAVACFLAGS" = x ; then
312 JAVACFLAGS="-source 1.4 -target 1.4"
313fi
314AC_SUBST(JAVACFLAGS)
315])
316
317dnl @synopsis AC_PROG_JAVA
318dnl
319dnl Here is a summary of the main macros:
320dnl
321dnl AC_PROG_JAVAC: finds a Java compiler.
322dnl
323dnl AC_PROG_JAVA: finds a Java virtual machine.
324dnl
325dnl AC_CHECK_CLASS: finds if we have the given class (beware of
326dnl CLASSPATH!).
327dnl
328dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops
329dnl otherwise.
330dnl
331dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source.
332dnl
333dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source.
334dnl
335dnl AC_JAVA_OPTIONS: adds Java configure options.
336dnl
337dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the
338dnl environment variable JAVA then tests in sequence various common
339dnl Java virtual machines. For political reasons, it starts with the
340dnl free ones. You *must* call [AC_PROG_JAVAC] before.
341dnl
342dnl If you want to force a specific VM:
343dnl
344dnl - at the configure.in level, set JAVA=yourvm before calling
345dnl AC_PROG_JAVA
346dnl
347dnl (but after AC_INIT)
348dnl
349dnl - at the configure level, setenv JAVA
350dnl
351dnl You can use the JAVA variable in your Makefile.in, with @JAVA@.
352dnl
353dnl *Warning*: its success or failure can depend on a proper setting of
354dnl the CLASSPATH env. variable.
355dnl
356dnl TODO: allow to exclude virtual machines (rationale: most Java
357dnl programs cannot run with some VM like kaffe).
358dnl
359dnl Note: This is part of the set of autoconf M4 macros for Java
360dnl programs. It is VERY IMPORTANT that you download the whole set,
361dnl some macros depend on other. Unfortunately, the autoconf archive
362dnl does not support the concept of set of macros, so I had to break it
363dnl for submission.
364dnl
365dnl A Web page, with a link to the latest CVS snapshot is at
366dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
367dnl
368dnl This is a sample configure.in Process this file with autoconf to
369dnl produce a configure script.
370dnl
371dnl AC_INIT(UnTag.java)
372dnl
373dnl dnl Checks for programs.
374dnl AC_CHECK_CLASSPATH
375dnl AC_PROG_JAVAC
376dnl AC_PROG_JAVA
377dnl
378dnl dnl Checks for classes
379dnl AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
380dnl AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
381dnl
382dnl AC_OUTPUT(Makefile)
383dnl
384dnl @category Java
385dnl @author Stephane Bortzmeyer <[email protected]>
386dnl @version 2000-07-19
387dnl @license GPLWithACException
388
389AC_DEFUN([AC_PROG_JAVA],[
390if test "x$JAVA" = x ; then
391 AC_REQUIRE([AC_EXEEXT])dnl
392 if test x$JAVAPREFIX = x; then
393 test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT)
394 else
395 test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT, $JAVAPREFIX)
396 fi
397 test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
398fi
399AC_SUBST(JAVA)
400AC_PROG_JAVA_WORKS
401AC_PROVIDE([$0])dnl
402])
403
404dnl @synopsis AC_PROG_JAVA_WORKS
405dnl
406dnl Internal use ONLY.
407dnl
408dnl Note: This is part of the set of autoconf M4 macros for Java
409dnl programs. It is VERY IMPORTANT that you download the whole set,
410dnl some macros depend on other. Unfortunately, the autoconf archive
411dnl does not support the concept of set of macros, so I had to break it
412dnl for submission. The general documentation, as well as the sample
413dnl configure.in, is included in the AC_PROG_JAVA macro.
414dnl
415dnl @category Java
416dnl @author Stephane Bortzmeyer <[email protected]>
417dnl @version 2000-07-19
418dnl @license GPLWithACException
419
420AC_DEFUN([AC_PROG_JAVA_WORKS], [
421AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
422if test x$uudecode = xyes; then
423AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
424dnl /**
425dnl * Test.java: used to test if java compiler works.
426dnl */
427dnl public class Test
428dnl {
429dnl
430dnl public static void
431dnl main( String[] argv )
432dnl {
433dnl System.exit (0);
434dnl }
435dnl
436dnl }
437cat << \EOF > Test.uue
438begin-base64 644 Test.class
439yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
440bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
441bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
442YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
443aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
444AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
445AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
446====
447EOF
448if uudecode$EXEEXT Test.uue; then
449 ac_cv_prog_uudecode_base64=yes
450else
451 echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
452 echo "configure: failed file was:" >&AC_FD_CC
453 cat Test.uue >&AC_FD_CC
454 ac_cv_prog_uudecode_base64=no
455fi
456rm -f Test.uue])
457fi
458if test x$ac_cv_prog_uudecode_base64 != xyes; then
459 rm -f Test.class
460 AC_MSG_WARN([I have to compile Test.class from scratch])
461 if test x$ac_cv_prog_javac_works = xno; then
462 AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
463 fi
464 if test x$ac_cv_prog_javac_works = x; then
465 AC_PROG_JAVAC
466 fi
467fi
468AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
469JAVA_TEST=Test.java
470CLASS_TEST=Test.class
471TEST=Test
472changequote(, )dnl
473cat << \EOF > $JAVA_TEST
474/* [#]line __oline__ "configure" */
475public class Test {
476public static void main (String args[]) {
477 System.exit (0);
478} }
479EOF
480changequote([, ])dnl
481if test x$ac_cv_prog_uudecode_base64 != xyes; then
482 if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
483 :
484 else
485 echo "configure: failed program was:" >&AC_FD_CC
486 cat $JAVA_TEST >&AC_FD_CC
487 AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
488 fi
489fi
490if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
491 ac_cv_prog_java_works=yes
492else
493 echo "configure: failed program was:" >&AC_FD_CC
494 cat $JAVA_TEST >&AC_FD_CC
495 AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
496fi
497rm -fr $JAVA_TEST $CLASS_TEST Test.uue
498])
499AC_PROVIDE([$0])dnl
500]
501)
Note: See TracBrowser for help on using the repository browser.