root/main/branches/64_bit_Greenstone/greenstone2/common-src/aclocal.m4

Revision 23356, 13.1 KB (checked in by sjm84, 9 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 *
Line 
1# Local additions to Autoconf macros.
2# Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
3# François Pinard <pinard@iro.umontreal.ca>, 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 <bortzmeyer@pasteur.fr>
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
187AC_SUBST(JAVAC)
188AC_PROG_JAVAC_WORKS
189AC_PROVIDE([$0])dnl
190])
191
192dnl @synopsis AC_PROG_JAVAC_WORKS
193dnl
194dnl Internal use ONLY.
195dnl
196dnl Note: This is part of the set of autoconf M4 macros for Java
197dnl programs. It is VERY IMPORTANT that you download the whole set,
198dnl some macros depend on other. Unfortunately, the autoconf archive
199dnl does not support the concept of set of macros, so I had to break it
200dnl for submission. The general documentation, as well as the sample
201dnl configure.in, is included in the AC_PROG_JAVA macro.
202dnl
203dnl @category Java
204dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
205dnl @version 2000-07-19
206dnl @license GPLWithACException
207
208AC_DEFUN([AC_PROG_JAVAC_WORKS],[
209AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
210JAVA_TEST=Test.java
211CLASS_TEST=Test.class
212cat << \EOF > $JAVA_TEST
213/* [#]line __oline__ "configure" */
214public class Test {
215}
216EOF
217if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
218  ac_cv_prog_javac_works=yes
219else
220  AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
221  echo "configure: failed program was:" >&AC_FD_CC
222  cat $JAVA_TEST >&AC_FD_CC
223fi
224rm -f $JAVA_TEST $CLASS_TEST
225])
226AC_PROVIDE([$0])dnl
227if test "x$JAVACFLAGS" = x ; then
228  JAVACFLAGS="-source 1.4 -target 1.4"
229fi
230AC_SUBST(JAVACFLAGS)
231])
232
233dnl @synopsis AC_PROG_JAVA
234dnl
235dnl Here is a summary of the main macros:
236dnl
237dnl AC_PROG_JAVAC: finds a Java compiler.
238dnl
239dnl AC_PROG_JAVA: finds a Java virtual machine.
240dnl
241dnl AC_CHECK_CLASS: finds if we have the given class (beware of
242dnl CLASSPATH!).
243dnl
244dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops
245dnl otherwise.
246dnl
247dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source.
248dnl
249dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source.
250dnl
251dnl AC_JAVA_OPTIONS: adds Java configure options.
252dnl
253dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the
254dnl environment variable JAVA then tests in sequence various common
255dnl Java virtual machines. For political reasons, it starts with the
256dnl free ones. You *must* call [AC_PROG_JAVAC] before.
257dnl
258dnl If you want to force a specific VM:
259dnl
260dnl - at the configure.in level, set JAVA=yourvm before calling
261dnl AC_PROG_JAVA
262dnl
263dnl   (but after AC_INIT)
264dnl
265dnl - at the configure level, setenv JAVA
266dnl
267dnl You can use the JAVA variable in your Makefile.in, with @JAVA@.
268dnl
269dnl *Warning*: its success or failure can depend on a proper setting of
270dnl the CLASSPATH env. variable.
271dnl
272dnl TODO: allow to exclude virtual machines (rationale: most Java
273dnl programs cannot run with some VM like kaffe).
274dnl
275dnl Note: This is part of the set of autoconf M4 macros for Java
276dnl programs. It is VERY IMPORTANT that you download the whole set,
277dnl some macros depend on other. Unfortunately, the autoconf archive
278dnl does not support the concept of set of macros, so I had to break it
279dnl for submission.
280dnl
281dnl A Web page, with a link to the latest CVS snapshot is at
282dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
283dnl
284dnl This is a sample configure.in Process this file with autoconf to
285dnl produce a configure script.
286dnl
287dnl    AC_INIT(UnTag.java)
288dnl
289dnl    dnl Checks for programs.
290dnl    AC_CHECK_CLASSPATH
291dnl    AC_PROG_JAVAC
292dnl    AC_PROG_JAVA
293dnl
294dnl    dnl Checks for classes
295dnl    AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
296dnl    AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
297dnl
298dnl    AC_OUTPUT(Makefile)
299dnl
300dnl @category Java
301dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
302dnl @version 2000-07-19
303dnl @license GPLWithACException
304
305AC_DEFUN([AC_PROG_JAVA],[
306if test "x$JAVA" = x ; then
307    AC_REQUIRE([AC_EXEEXT])dnl
308    if test x$JAVAPREFIX = x; then
309        test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT)
310    else
311        test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT, $JAVAPREFIX)
312    fi
313    test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
314fi
315AC_SUBST(JAVA)
316AC_PROG_JAVA_WORKS
317AC_PROVIDE([$0])dnl
318])
319
320dnl @synopsis AC_PROG_JAVA_WORKS
321dnl
322dnl Internal use ONLY.
323dnl
324dnl Note: This is part of the set of autoconf M4 macros for Java
325dnl programs. It is VERY IMPORTANT that you download the whole set,
326dnl some macros depend on other. Unfortunately, the autoconf archive
327dnl does not support the concept of set of macros, so I had to break it
328dnl for submission. The general documentation, as well as the sample
329dnl configure.in, is included in the AC_PROG_JAVA macro.
330dnl
331dnl @category Java
332dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
333dnl @version 2000-07-19
334dnl @license GPLWithACException
335
336AC_DEFUN([AC_PROG_JAVA_WORKS], [
337AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
338if test x$uudecode = xyes; then
339AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
340dnl /**
341dnl  * Test.java: used to test if java compiler works.
342dnl  */
343dnl public class Test
344dnl {
345dnl
346dnl public static void
347dnl main( String[] argv )
348dnl {
349dnl     System.exit (0);
350dnl }
351dnl
352dnl }
353cat << \EOF > Test.uue
354begin-base64 644 Test.class
355yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
356bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
357bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
358YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
359aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
360AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
361AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
362====
363EOF
364if uudecode$EXEEXT Test.uue; then
365        ac_cv_prog_uudecode_base64=yes
366else
367        echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
368        echo "configure: failed file was:" >&AC_FD_CC
369        cat Test.uue >&AC_FD_CC
370        ac_cv_prog_uudecode_base64=no
371fi
372rm -f Test.uue])
373fi
374if test x$ac_cv_prog_uudecode_base64 != xyes; then
375        rm -f Test.class
376        AC_MSG_WARN([I have to compile Test.class from scratch])
377        if test x$ac_cv_prog_javac_works = xno; then
378                AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
379        fi
380        if test x$ac_cv_prog_javac_works = x; then
381                AC_PROG_JAVAC
382        fi
383fi
384AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
385JAVA_TEST=Test.java
386CLASS_TEST=Test.class
387TEST=Test
388changequote(, )dnl
389cat << \EOF > $JAVA_TEST
390/* [#]line __oline__ "configure" */
391public class Test {
392public static void main (String args[]) {
393        System.exit (0);
394} }
395EOF
396changequote([, ])dnl
397if test x$ac_cv_prog_uudecode_base64 != xyes; then
398        if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
399                :
400        else
401          echo "configure: failed program was:" >&AC_FD_CC
402          cat $JAVA_TEST >&AC_FD_CC
403          AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
404        fi
405fi
406if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
407  ac_cv_prog_java_works=yes
408else
409  echo "configure: failed program was:" >&AC_FD_CC
410  cat $JAVA_TEST >&AC_FD_CC
411  AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
412fi
413rm -fr $JAVA_TEST $CLASS_TEST Test.uue
414])
415AC_PROVIDE([$0])dnl
416]
417)
Note: See TracBrowser for help on using the browser.