Define flags with macros, to ensure unsignedness.
[cfd] / aclocal.glob
CommitLineData
b91e2391 1dnl -*-fundamental-*- *@--GLOB-HEADER--@*
2dnl
37dec778 3dnl $Id: aclocal.glob,v 1.10 2000/10/14 16:32:15 mdw Exp $
b91e2391 4dnl
5dnl Common library of autoconf macros
6dnl
7dnl (c) 1997 Mark Wooding, except for macros and documentation where noted.
8dnl
9
10dnl----- Licensing notice ---------------------------------------------------
11dnl
12dnl This file is part of the Common Files Distribution (`common')
13dnl
14dnl `Common' is free software; you can redistribute it and/or modify
15dnl it under the terms of the GNU General Public License as published by
16dnl the Free Software Foundation; either version 2 of the License, or
17dnl (at your option) any later version.
18dnl
19dnl `Common' is distributed in the hope that it will be useful,
20dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
21dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22dnl GNU General Public License for more details.
23dnl
24dnl You should have received a copy of the GNU General Public License
25dnl along with `common'; if not, write to the Free Software Foundation,
26dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
28dnl----- Revision history ---------------------------------------------------
29dnl
30dnl $Log: aclocal.glob,v $
37dec778 31dnl Revision 1.10 2000/10/14 16:32:15 mdw
32dnl Fixes from upstream.
33dnl
08f6362d 34dnl Revision 1.9 2000/08/15 21:37:49 mdw
35dnl New initialization macro for libraries, and a new base client macro for
36dnl finding libraries with an appropriate version.
37dnl
5ba1b8b8 38dnl Revision 1.8 1999/11/26 01:23:17 mdw
39dnl And support for MXD (not yet released).
40dnl
5a27eb4e 41dnl Revision 1.7 1999/11/11 20:03:58 mdw
42dnl Add support for mgLib too.
43dnl
17fc60ae 44dnl Revision 1.6 1999/11/11 17:49:33 mdw
45dnl New macros for configuring clients of mLib and Catacomb.
46dnl
6c1c6588 47dnl Revision 1.5 1999/07/27 18:27:37 mdw
48dnl Fix typo in header line for mdw_DECL_ENVIRON.
49dnl
a80cb8cc 50dnl Revision 1.4 1999/07/26 23:44:32 mdw
51dnl Reorder and tidy documentation.
52dnl
aaa99339 53dnl Revision 1.3 1999/07/17 10:27:44 mdw
54dnl More useful macros added.
55dnl
5b59e227 56dnl Revision 1.2 1999/05/13 22:57:23 mdw
57dnl Change `-ise' to `-ize' throughout.
58dnl
59dnl Revision 1.1.1.1 1999/05/05 19:23:47 mdw
60dnl New import. The old CVS repository was lost in a disk disaster.
b91e2391 61dnl
62
63dnl----- Common files distribution --------------------------- *@--NOTICE--@*
64dnl
37dec778 65dnl $Id: aclocal.glob,v 1.10 2000/10/14 16:32:15 mdw Exp $
b91e2391 66
67dnl --- *@-AC_PROG_CC_STDC-@* ---
68dnl
69dnl Author: Franc,ois Pinard
70dnl
71dnl Synopsis: AC_PROG_CC_STDC
72dnl
73dnl Arguments: ---
74dnl
75dnl Use: If the C compiler in not in ANSI C mode by default, try to
76dnl add an option to output variable `CC' to make it so. This
77dnl macro tries various options that select ANSI C on some system
78dnl or another. It considers the compiler to be in ANSI C mode
79dnl if it defines `__STDC__' to 1 and handles function prototypes
80dnl correctly.
81dnl
82dnl If you use this macro, you should check after calling it
83dnl whether the C compiler has been set to accept ANSI C; if not,
84dnl the shell variable `ac_cv_prog_cc_stdc' is set to `no'. If
85dnl you wrote your source code in ANSI C, you can make an
86dnl un-ANSIfied copy of it by using the program `ansi2knr', which
87dnl comes with Ghostscript.
88dnl
89dnl (documentation by Franc,ois Pinard)
90
91AC_DEFUN(AM_PROG_CC_STDC,
92[AC_REQUIRE([AC_PROG_CC])
93AC_BEFORE([$0], [AC_C_INLINE])
94AC_BEFORE([$0], [AC_C_CONST])
95AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
96AC_CACHE_VAL(am_cv_prog_cc_stdc,
97[am_cv_prog_cc_stdc=no
98ac_save_CC="$CC"
99# Don't try gcc -ansi; that turns off useful extensions and
100# breaks some systems' header files.
101# AIX -qlanglvl=ansi
102# Ultrix and OSF/1 -std1
103# HP-UX -Aa -D_HPUX_SOURCE
104# SVR4 -Xc -D__EXTENSIONS__
105for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
106do
107 CC="$ac_save_CC $ac_arg"
108 AC_TRY_COMPILE(
109[#if !defined(__STDC__) || __STDC__ != 1
110choke me
111#endif
112/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
113#ifdef _SEQUENT_
114# include <sys/types.h>
115# include <sys/stat.h>
116#endif
117], [
118int test (int i, double x);
119struct s1 {int (*f) (int a);};
120struct s2 {int (*f) (double a);};],
121[am_cv_prog_cc_stdc="$ac_arg"; break])
122done
123CC="$ac_save_CC"
124])
125if test -z "$am_cv_prog_cc_stdc"; then
126 AC_MSG_RESULT([none needed])
127else
128 AC_MSG_RESULT($am_cv_prog_cc_stdc)
129fi
130case "x$am_cv_prog_cc_stdc" in
131 x|xno) ;;
132 *) CC="$CC $am_cv_prog_cc_stdc" ;;
133esac
134])
135
136dnl----- AutoMake macros ------------------------------------- *@--IGNORE--@*
137
138dnl --- *@-AM_CONDITIONAL-@* ---
139dnl
140dnl Author: Unknown
141dnl
142dnl Synopsis: AM_CONDITIONAL(NAME, TEST)
143dnl
144dnl Arguments: NAME = name of the conditional
145dnl TEST = a shell list to execute
146dnl
147dnl Use: Allows conditional sections in Makefiles.
148
149AC_DEFUN(AM_CONDITIONAL,
150[AC_SUBST($1_TRUE)
151AC_SUBST($1_FALSE)
152if $2; then
153 $1_TRUE=
154 $1_FALSE='#'
155else
156 $1_TRUE='#'
157 $1_FALSE=
158fi])
159
160dnl --- *@-AM_CYGWIN32-@* ---
161dnl
162dnl Author: Cygnus (I guess)
163dnl
164dnl Synopsis: AM_CYGWIN32
165dnl
166dnl Arguments: ---
167dnl
168dnl Use: Check to see if we're running under Cygwin32, without using
169dnl AC_CANONICAL_*. If so, set output variable EXEEXT to
170dnl ".exe". Otherwise set it to "".
171
172dnl AM_CYGWIN32()
173dnl You might think we can do this by checking for a cygwin32-specific
174dnl cpp define. We can't, because cross-compilers that target
175dnl cygwin32 don't use the .exe suffix. I don't know why.
176AC_DEFUN(AM_CYGWIN32,
177[AC_CACHE_CHECK(for Cygwin32 environment, am_cv_cygwin32,
178[cat > conftest.$ac_ext << 'EOF'
179int main () {
180/* Nothing. */
181return 0; }
182EOF
183if AC_TRY_EVAL(ac_link) && test -s conftest.exe; then
184 am_cv_cygwin32=yes
185else
186 am_cv_cygwin32=no
187fi
188rm -f conftest*])
189EXEEXT=
190test "$am_cv_cygwin32" = yes && EXEEXT=.exe
191AC_SUBST(EXEEXT)])
192
193dnl --- *@-AM_WITH_DMALLOC-@* ---
194dnl
195dnl Author: Franc,ois Pinard
196dnl
197dnl Synopsis: AM_WITH_DMALLOC
198dnl
199dnl Arguments: ---
200dnl
201dnl Use: Links with `-dmalloc' if told to by the user.
202
203## ----------------------------------- ##
204## Check if --with-dmalloc was given. ##
205## From Franc,ois Pinard ##
206## ----------------------------------- ##
207
208# serial 1
209
210AC_DEFUN(AM_WITH_DMALLOC,
211[AC_MSG_CHECKING(if malloc debugging is wanted)
212AC_ARG_WITH(dmalloc,
213[ --with-dmalloc use dmalloc, as in
214 ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz],
215[if test "$withval" = yes; then
216 AC_MSG_RESULT(yes)
217 AC_DEFINE(WITH_DMALLOC)
218 LIBS="$LIBS -ldmalloc"
219 LDFLAGS="$LDFLAGS -g"
220else
221 AC_MSG_RESULT(no)
222fi], [AC_MSG_RESULT(no)])
223])
224
225dnl --- *@-AM_FUNC_ERROR_AT_LINE-@* ---
226dnl
227dnl Author: Jim Meyering
228dnl
229dnl Synopsis: AM_FUNC_ERROR_AT_LINE
230dnl
231dnl Arguments: ---
232dnl
233dnl Use: Use this if you use the GNU error.[ch].
234
235dnl FIXME: Migrate into libit
236
237AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
238[AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
239 [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
240 am_cv_lib_error_at_line=yes,
241 am_cv_lib_error_at_line=no)])
242 if test $am_cv_lib_error_at_line = no; then
243 LIBOBJS="$LIBOBJS error.o"
244 fi
245 AC_SUBST(LIBOBJS)dnl
246])
247
248dnl --- *@-AM_INIT_GUILE_MODULE-@* ---
249dnl
250dnl Author: Unknown
251dnl
252dnl Synopsis: AM_INIT_GUILE_MODULE(MODNAME)
253dnl
5b59e227 254dnl Arguments: MODNAME = value to initialize `module' variable with
b91e2391 255dnl
256dnl Use: This macro will automatically get the guile version from the
257dnl top-level srcdir, and will initialize automake. It also
258dnl defines the `module' variable.
259
260AC_DEFUN([AM_INIT_GUILE_MODULE],[
261. $srcdir/../GUILE-VERSION
262AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
263AC_CONFIG_AUX_DIR(..)
264module=[$1]
265AC_SUBST(module)])
266
267dnl --- *@-AM_CONFIG_HEADER-@* ---
268dnl
269dnl Author: Unknown
270dnl
271dnl Synopsis: AM_CONFIG_HEADER(HEADER ...)
272dnl
273dnl Arguments: HEADER = a header spec, as for AC_CONFIG_HEADER
274dnl
275dnl Use: Like AC_CONFIG_HEADER, but automatically create stamp file.
276
277AC_DEFUN(AM_CONFIG_HEADER,
278[AC_PREREQ([2.12])
279AC_CONFIG_HEADER([$1])
280dnl When config.status generates a header, we must update the stamp-h file.
281dnl This file resides in the same directory as the config header
282dnl that is generated. We must strip everything past the first ":",
283dnl and everything past the last "/".
284AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
285ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
286<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/
287\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
288<<am_indx=1
289for am_file in <<$1>>; do
290 case " <<$>>CONFIG_HEADERS " in
291 *" <<$>>am_file "*<<)>>
292 echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
293 ;;
294 esac
295 am_indx=`expr "<<$>>am_indx" + 1`
296done<<>>dnl>>)
297changequote([,]))])
298
299dnl --- *@-AM_INIT_AUTOMAKE-@*
300dnl
301dnl Author: Unknown
302dnl
303dnl Synopsis: AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
304dnl
305dnl Arguments: PACKAGE = package name
306dnl VERSION = version number
307dnl NO-DEFINE = if set, don't define package and version number
308dnl
309dnl Use: Do all the work for Automake. This macro actually does too
310dnl much -- some checks are only needed if your package does
311dnl certain things. But this isn't really a big deal.
312
313# serial 1
314
315AC_DEFUN(AM_INIT_AUTOMAKE,
37dec778 316[AC_REQUIRE([AC_PROG_INSTALL])
b91e2391 317PACKAGE=[$1]
318AC_SUBST(PACKAGE)
319VERSION=[$2]
320AC_SUBST(VERSION)
321dnl test to see if srcdir already configured
322if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
323 AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
324fi
325ifelse([$3],,
326AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
327AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
37dec778 328AC_REQUIRE([AM_SANITY_CHECK])
329AC_REQUIRE([AC_ARG_PROGRAM])
b91e2391 330dnl FIXME This is truly gross.
331missing_dir=`cd $ac_aux_dir && pwd`
332AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
333AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
334AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
335AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
336AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
37dec778 337AC_REQUIRE([AC_PROG_MAKE_SET])])
b91e2391 338
339dnl --- *@-AM_PROG_INSTALL-@* ---
340dnl
341dnl Author: Franc,ois Pinard
342dnl
343dnl Synopsis: AM_PROG_INSTALL
344dnl
345dnl Arguments: ---
346dnl
347dnl Use: Calls `AC_PROG_INSTALL' to find an installer. Then it sets
348dnl `INSTALL_SCRIPT' to a suitable value if necessary.
349
350# serial 1
351
352AC_DEFUN(AM_PROG_INSTALL,
353[AC_PROG_INSTALL
354test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL} -m 755'
355AC_SUBST(INSTALL_SCRIPT)dnl
356])
357
358dnl --- *@-AM_PROG_LEX-@* ---
359dnl
360dnl Author: Alexandre Oliva
361dnl
362dnl Synopsis: AM_PROG_LEX
363dnl
364dnl Arguments: ---
365dnl
366dnl Use: Replacement for AC_PROG_LEX and AC_DECL_YYTEXT
367
368dnl AM_PROG_LEX
369dnl Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT
370AC_DEFUN(AM_PROG_LEX,
371[missing_dir=ifelse([$1],,`cd $ac_aux_dir && pwd`,$1)
372AC_CHECK_PROGS(LEX, flex lex, "$missing_dir/missing flex")
373AC_PROG_LEX
374AC_DECL_YYTEXT])
375
376dnl --- *@-AM_PROG_LIBTOOL-@* ---
377dnl
378dnl Author: Unknown
379dnl
380dnl Synopsis: AM_PROG_LIBTOOL
381dnl
382dnl Arguments: ---
383dnl
384dnl Use: Configures `libtool' for the target architecture.
385
386##
387## Configure libtool for the target system.
388##
389# serial 1 AM_PROG_LIBTOOL
390AC_DEFUN(AM_PROG_LIBTOOL,
391[AC_REQUIRE([AC_CANONICAL_HOST])
392AC_REQUIRE([AC_PROG_CC])
393AC_REQUIRE([AC_PROG_RANLIB])
394
395# Always use our own libtool.
396LIBTOOL='$(top_builddir)/libtool'
397AC_SUBST(LIBTOOL)
398
399dnl Allow the --disable-shared flag to stop us from building shared libs.
400AC_ARG_ENABLE(shared,
401[ --enable-shared build shared libraries [default=yes]],
402test "$enableval" = no && libtool_shared=" --disable-shared",
403libtool_shared=)
404
405libtool_flags="$libtool_shared"
406test "$silent" = yes && libtool_flags="$libtool_flags --silent"
407test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
408
409# Actually configure libtool. ac_aux_dir is where install-sh is found.
410CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LD="$LD" RANLIB="$RANLIB" \
411$ac_aux_dir/ltconfig $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
412|| AC_MSG_ERROR([libtool configure failed])
413])
414
415dnl --- *@-AM_PATH_LISPDIR-@* ---
416dnl
417dnl Author: Ulrich Drepper
418dnl
419dnl Synopsis: AM_PATH_LISPDIR
420dnl
421dnl Arguments: ---
422dnl
423dnl Use: Sets the variable `lispdir' to point to a place to install
424dnl Emacs lisp files.
425
426## ------------------------
427## Emacs LISP file handling
428## From Ulrich Drepper
429## ------------------------
430
431# serial 1
432
433AC_DEFUN(AM_PATH_LISPDIR,
434 [# If set to t, that means we are running in a shell under Emacs.
435 # If you have an Emacs named "t", then use the full path.
436 test "$EMACS" = t && EMACS=
437 AC_PATH_PROG(EMACS, emacs xemacs, no)
438 if test $EMACS != "no"; then
439 AC_MSG_CHECKING([where .elc files should go])
440 dnl Set default value
441 lispdir="\$(datadir)/emacs/site-lisp"
442 if test "x$prefix" = "xNONE"; then
443 if test -d $ac_default_prefix/share/emacs/site-lisp; then
444 lispdir="\$(prefix)/share/emacs/site-lisp"
445 else
446 if test -d $ac_default_prefix/lib/emacs/site-lisp; then
447 lispdir="\$(prefix)/lib/emacs/site-lisp"
448 fi
449 fi
450 else
451 if test -d $prefix/share/emacs/site-lisp; then
452 lispdir="\$(prefix)/share/emacs/site-lisp"
453 else
454 if test -d $prefix/lib/emacs/site-lisp; then
455 lispdir="\$(prefix)/lib/emacs/site-lisp"
456 fi
457 fi
458 fi
459 AC_MSG_RESULT($lispdir)
460 fi
461 AC_SUBST(lispdir)])
462
463dnl --- *@-AM_MAINTAINTER_MODE-@* ---
464dnl
465dnl Author: Jim Meyering
466dnl
467dnl Synopsis: jm_MAINTAINER_MODE
468dnl
469dnl Arguments: ---
470dnl
471dnl Use: Provides an option `--enable-maintainer-mode' which turns
472dnl on rules which might normally be commented out. The
473dnl substitution variable `MAINT' is set to be a comment when
474dnl this option is disabled, which it is by default.
475
476# serial 1
477
478AC_DEFUN(AM_MAINTAINER_MODE,
479[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
480 dnl maintainer-mode is disabled by default
481 AC_ARG_ENABLE(maintainer-mode,
482[ --enable-maintainer-mode enable make rules and dependencies not useful
483 (and sometimes confusing) to the casual installer],
484 USE_MAINTAINER_MODE=$enableval,
485 USE_MAINTAINER_MODE=no)
486 AC_MSG_RESULT($USE_MAINTAINER_MODE)
487 if test $USE_MAINTAINER_MODE = yes; then
488 MAINT=
489 else
490 MAINT='#M#'
491 fi
492 AC_SUBST(MAINT)dnl
493]
494)
495
496dnl --- *@-AM_MISSING_PROG-@* ---
497dnl
498dnl Author: Unknown
499dnl
500dnl Synopsis: AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
501dnl
502dnl Arguments: NAME = variable to set to the file's location
503dnl PROGRAM = name of program to find
504dnl DIRECTORY = directory to look in
505dnl
506dnl Use: Fakes existence of a useful GNU maintainer tool.
507
508AC_DEFUN(AM_MISSING_PROG,
509[AC_MSG_CHECKING(for working $2)
510# Run test in a subshell; some versions of sh will print an error if
511# an executable is not found, even if stderr is redirected.
512# Redirect stdin to placate older versions of autoconf. Sigh.
513if ($2 --version) < /dev/null > /dev/null 2>&1; then
514 $1=$2
515 AC_MSG_RESULT(found)
516else
517 $1="$3/missing $2"
518 AC_MSG_RESULT(missing)
519fi
520AC_SUBST($1)])
521
522dnl --- *@-AM_FUNC_MKTIME-@* ---
523dnl
524dnl Author: Jim Meyering
525dnl
526dnl Synopsis: AM_FUNC_MKTIME
527dnl
528dnl Arguments: ---
529dnl
530dnl Use: Checks for a working mktime function.
531
532AC_DEFUN(AM_FUNC_MKTIME,
533[AC_REQUIRE([AC_HEADER_TIME])dnl
534 AC_CHECK_HEADERS(sys/time.h)
535 AC_CACHE_CHECK([for working mktime], am_cv_func_working_mktime,
536 [AC_TRY_RUN(
537changequote(<<, >>)dnl
538<</* Test program from Paul Eggert (eggert@twinsun.com)
539 and Tony Leneis (tony@plaza.ds.adp.com). */
540#if TIME_WITH_SYS_TIME
541# include <sys/time.h>
542# include <time.h>
543#else
544# if HAVE_SYS_TIME_H
545# include <sys/time.h>
546# else
547# include <time.h>
548# endif
549#endif
550
551static time_t time_t_max;
552
553/* Values we'll use to set the TZ environment variable. */
554static const char *const tz_strings[] = {
555 NULL, "GMT0", "JST-9", "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
556};
557#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
558
559static void
560mktime_test (now)
561 time_t now;
562{
563 if (mktime (localtime (&now)) != now)
564 exit (1);
565 now = time_t_max - now;
566 if (mktime (localtime (&now)) != now)
567 exit (1);
568}
569
570int
571main ()
572{
573 time_t t, delta;
574 int i;
575
576 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
577 continue;
578 time_t_max--;
579 delta = time_t_max / 997; /* a suitable prime number */
580 for (i = 0; i < N_STRINGS; i++)
581 {
582 if (tz_strings[i])
583 putenv (tz_strings[i]);
584
585 for (t = 0; t <= time_t_max - delta; t += delta)
586 mktime_test (t);
587 mktime_test ((time_t) 60 * 60);
588 mktime_test ((time_t) 60 * 60 * 24);
589 }
590 exit (0);
591}
592 >>,
593changequote([, ])dnl
594 am_cv_func_working_mktime=yes, am_cv_func_working_mktime=no,
595 dnl When crosscompiling, assume mktime is missing or broken.
596 am_cv_func_working_mktime=no)
597 ])
598 if test $am_cv_func_working_mktime = no; then
599 LIBOBJS="$LIBOBJS mktime.o"
600 fi
601])
602
603dnl --- *@-AM_FUNC_OBSTACK-@* ---
604dnl
605dnl Author: Jim Meyering
606dnl
607dnl Synopsis: AM_FUNC_OBSTACK
608dnl
609dnl Arguments: ---
610dnl
611dnl Use: Checks for GNU obstacks.
612
613AC_DEFUN(AM_FUNC_OBSTACK,
614[AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
615 [AC_TRY_LINK([#include "obstack.h"],
616 [struct obstack *mem;obstack_free(mem,(char *) 0)],
617 am_cv_func_obstack=yes,
618 am_cv_func_obstack=no)])
619 if test $am_cv_func_obstack = yes; then
620 AC_DEFINE(HAVE_OBSTACK)
621 else
622 LIBOBJS="$LIBOBJS obstack.o"
623 fi
624])
625
626dnl --- *@-AC_C_PROTOTYPES-@* ---
627dnl
628dnl Author: Franc,ois Pinard
629dnl
630dnl Synopsis: AC_C_PROTOTYPES
631dnl
632dnl Arguments: ---
633dnl
634dnl Use: If the C compiler understands ANSI C, define `PROTOTYPES',
635dnl and clear the `U' and `ANSI2KNR' variables. Otherwise,
636dnl set `U' to be `_' and `ANSI2KNR' to be `./ansi2knr'.
637
638# serial 1
639
640AC_DEFUN(fp_C_PROTOTYPES,
641[AC_REQUIRE([fp_PROG_CC_STDC])
642AC_MSG_CHECKING([for function prototypes])
643if test "$ac_cv_prog_cc_stdc" != no; then
644 AC_MSG_RESULT(yes)
645 AC_DEFINE(PROTOTYPES)
646 U= ANSI2KNR=
647else
648 AC_MSG_RESULT(no)
649 U=_ ANSI2KNR=./ansi2knr
650fi
651AC_SUBST(U)dnl
652AC_SUBST(ANSI2KNR)dnl
653])
654
655dnl --- *@-AM_PATH_GTK-@* ---
656dnl
657dnl Author: Owen Taylor
658dnl
659dnl Synopsis: AM_PATH_GTK(MIN-VERSION, [ACTION-IF-FOUND], [ACTION-IF-NOT])
660dnl
661dnl Arguments: MIN-VERSION = minimum version of GTK required
662dnl ACTION-IF-FOUND = executed if GTK found OK
663dnl ACTION-IF-NOT-FOUND = what to do if GTK not available
664dnl
665dnl Use: Sets up compilation environment suitably for GTK programming.
666
667# Configure paths for GTK+
668# Owen Taylor 97-11-3
669
670dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
671dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
672dnl
673AC_DEFUN(AM_PATH_GTK,
674[dnl
675dnl Get the cflags and libraries from the gtk-config script
676dnl
677AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
678 gtk_config_prefix="$withval", gtk_config_prefix="")
679AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
680 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
681AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
682 , enable_gtktest=yes)
683
684 if test x$gtk_config_exec_prefix != x ; then
685 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
686 if test x${GTK_CONFIG+set} != xset ; then
687 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
688 fi
689 fi
690 if test x$gtk_config_prefix != x ; then
691 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
692 if test x${GTK_CONFIG+set} != xset ; then
693 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
694 fi
695 fi
696
697 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
698 min_gtk_version=ifelse([$1], ,0.99.7,$1)
699 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
700 no_gtk=""
701 if test "$GTK_CONFIG" = "no" ; then
702 no_gtk=yes
703 else
704 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
705 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
706 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
707 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
708 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
709 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
710 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
711 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
712 if test "x$enable_gtktest" = "xyes" ; then
713 ac_save_CFLAGS="$CFLAGS"
714 ac_save_LIBS="$LIBS"
715 CFLAGS="$CFLAGS $GTK_CFLAGS"
716 LIBS="$LIBS $GTK_LIBS"
717dnl
718dnl Now check if the installed GTK is sufficiently new. (Also sanity
719dnl checks the results of gtk-config to some extent
720dnl
721 rm -f conf.gtktest
722 AC_TRY_RUN([
723#include <gtk/gtk.h>
724#include <stdio.h>
725
726int
727main ()
728{
729 int major, minor, micro;
730 char *tmp_version;
731
732 system ("touch conf.gtktest");
733
734 /* HP/UX 9 (%@#!) writes to sscanf strings */
735 tmp_version = g_strdup("$min_gtk_version");
736 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
737 printf("%s, bad version string\n", "$min_gtk_version");
738 exit(1);
739 }
740
741 if ((gtk_major_version != $gtk_config_major_version) ||
742 (gtk_minor_version != $gtk_config_minor_version) ||
743 (gtk_micro_version != $gtk_config_micro_version))
744 {
745 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
746 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
747 gtk_major_version, gtk_minor_version, gtk_micro_version);
748 printf ("*** was found! If gtk-config was correct, then it is best\n");
749 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
750 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
751 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
752 printf("*** required on your system.\n");
753 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
754 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
755 printf("*** before re-running configure\n");
756 }
757 else
758 {
759 if ((gtk_major_version > major) ||
760 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
761 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
762 {
763 return 0;
764 }
765 else
766 {
767 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
768 gtk_major_version, gtk_minor_version, gtk_micro_version);
769 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
770 major, minor, micro);
771 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
772 printf("***\n");
773 printf("*** If you have already installed a sufficiently new version, this error\n");
774 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
775 printf("*** being found. The easiest way to fix this is to remove the old version\n");
776 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
777 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
778 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
779 printf("*** so that the correct libraries are found at run-time))\n");
780 }
781 }
782 return 1;
783}
784],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
785 CFLAGS="$ac_save_CFLAGS"
786 LIBS="$ac_save_LIBS"
787 fi
788 fi
789 if test "x$no_gtk" = x ; then
790 AC_MSG_RESULT(yes)
791 ifelse([$2], , :, [$2])
792 else
793 AC_MSG_RESULT(no)
794 if test "$GTK_CONFIG" = "no" ; then
795 echo "*** The gtk-config script installed by GTK could not be found"
796 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
797 echo "*** your path, or set the GTK_CONFIG environment variable to the"
798 echo "*** full path to gtk-config."
799 else
800 if test -f conf.gtktest ; then
801 :
802 else
803 echo "*** Could not run GTK test program, checking why..."
804 CFLAGS="$CFLAGS $GTK_CFLAGS"
805 LIBS="$LIBS $GTK_LIBS"
806 AC_TRY_LINK([
807#include <gtk/gtk.h>
808#include <stdio.h>
809], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
810 [ echo "*** The test program compiled, but did not run. This usually means"
811 echo "*** that the run-time linker is not finding GTK or finding the wrong"
812 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
813 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
814 echo "*** to the installed location Also, make sure you have run ldconfig if that"
815 echo "*** is required on your system"
816 echo "***"
817 echo "*** If you have an old version installed, it is best to remove it, although"
818 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
819 echo "***"
820 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
821 echo "*** came with the system with the command"
822 echo "***"
823 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
824 [ echo "*** The test program failed to compile or link. See the file config.log for the"
825 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
826 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
827 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
828 CFLAGS="$ac_save_CFLAGS"
829 LIBS="$ac_save_LIBS"
830 fi
831 fi
832 GTK_CFLAGS=""
833 GTK_LIBS=""
834 ifelse([$3], , :, [$3])
835 fi
836 AC_SUBST(GTK_CFLAGS)
837 AC_SUBST(GTK_LIBS)
838 rm -f conf.gtktest
839])
840
841dnl --- *@-AC_TYPE_PTRDIFF_T-@* ---
842dnl
843dnl Author: Ulrich Drepper
844dnl
845dnl Synopsis: AC_TYPE_PTRDIFF_T
846dnl
847dnl Arguments: ---
848dnl
849dnl Use: Sets HAVE_PTRDIFF_T if the type exists.
850
851AC_DEFUN(AM_TYPE_PTRDIFF_T,
852 [AC_CACHE_CHECK([for ptrdiff_t], am_cv_type_ptrdiff_t,
853 [AC_TRY_COMPILE([#include <stddef.h>], [ptrdiff_t p],
854 am_cv_type_ptrdiff_t=yes, am_cv_type_ptrdiff_t=no)])
855 if test $am_cv_type_ptrdiff_t = yes; then
856 AC_DEFINE(HAVE_PTRDIFF_T)
857 fi
858])
859
860dnl --- *@-AM_WITH_REGEX-@* ---
861dnl
862dnl Author: Unknown (possibly Franc,ois Pinard)
863dnl
864dnl Synopsis: AM_WITH_REGEX
865dnl
866dnl Arguments: ---
867dnl
868dnl Use:
869dnl The idea is to distribute rx.[hc] and regex.[hc] together,
870dnl for a while. The WITH_REGEX symbol (which should also be
871dnl documented in acconfig.h) is used to decide which of regex.h
872dnl or rx.h should be included in the application. If
873dnl `./configure --with-regex' is given (the default), the
874dnl package will use gawk's regex. If `./configure
875dnl --without-regex', a check is made to see if rx is already
876dnl installed, as with newer Linux'es. If not found, the package
877dnl will use the rx from the distribution. If found, the package
878dnl will use the system's rx which, on Linux at least, will
879dnl result in a smaller executable file.
880
881AC_DEFUN(AM_WITH_REGEX,
882[AC_MSG_CHECKING(which of GNU rx or gawk's regex is wanted)
883AC_ARG_WITH(regex,
884[ --without-regex use GNU rx in lieu of gawk's regex for matching],
885[test "$withval" = yes && am_with_regex=1],
886[am_with_regex=1])
887if test -n "$am_with_regex"; then
888 AC_MSG_RESULT(regex)
889 AC_DEFINE(WITH_REGEX)
890 AC_CACHE_CHECK([for GNU regex in libc], am_cv_gnu_regex,
891 AC_TRY_LINK([], [extern int re_max_failures; re_max_failures = 1],
892 am_cv_gnu_regex=yes, am_cv_gnu_regex=no))
893 if test $am_cv_gnu_regex = no; then
894 LIBOBJS="$LIBOBJS regex.o"
895 fi
896else
897 AC_MSG_RESULT(rx)
898 AC_CHECK_FUNC(re_rx_search, , [LIBOBJS="$LIBOBJS rx.o"])
899fi
900AC_SUBST(LIBOBJS)dnl
901])
902
903dnl --- *@-AM_SANITY_CHECK-@*
904dnl
905dnl Author: Unknown
906dnl
907dnl Synopsis: AM_SANITY_CHECK
908dnl
909dnl Arguments: ---
910dnl
911dnl Use: Check for build environment sanity.
912
913AC_DEFUN(AM_SANITY_CHECK,
914[AC_MSG_CHECKING([whether build environment is sane])
915# Just in case
916sleep 1
917echo timestamp > conftestfile
918# Do `set' in a subshell so we don't clobber the current shell's
919# arguments. Must try -L first in case configure is actually a
920# symlink; some systems play weird games with the mod time of symlinks
921# (eg FreeBSD returns the mod time of the symlink's containing
922# directory).
923if (
924 set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
925 if test "$@" = "X"; then
926 # -L didn't work.
927 set X `ls -t $srcdir/configure conftestfile`
928 fi
929 test "[$]2" = conftestfile
930 )
931then
932 # Ok.
933 :
934else
935 AC_MSG_ERROR([newly created file is older than distributed files!
936Check your system clock])
937fi
938rm -f conftest*
939AC_MSG_RESULT(yes)])
940
941dnl --- *@-AM_FUNC_STRDOD-@* ---
942dnl
943dnl Author: Jim Meyering
944dnl
945dnl Synopsis: AM_FUNC_STRTOD
946dnl
947dnl Arguments: ---
948dnl
949dnl Use: Checks for a working strtod function.
950
951## Copyright (C) 1996 Free Software Foundation, Inc.
952
953## This program is free software; you can redistribute it and/or modify
954## it under the terms of the GNU General Public License as published by
955## the Free Software Foundation; either version 2, or (at your option)
956## any later version.
957
958## This program is distributed in the hope that it will be useful,
959## but WITHOUT ANY WARRANTY; without even the implied warranty of
960## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
961## GNU General Public License for more details.
962
963## You should have received a copy of the GNU General Public License
964## along with this program; if not, write to the Free Software
965## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
966## 02111-1307, USA.
967
968## From Jim Meyering.
969
970## serial 1
971
972## @defmac AC_FUNC_STRTOD
973## @maindex FUNC_STRTOD
974## @ovindex LIBOBJS
975## If the @code{strtod} function is not available, or does not work
976## correctly (like the one on SunOS 5.4), add @samp{strtod.o} to output
977## variable @code{LIBOBJS}.
978## @end defmac
979
980AC_DEFUN(AM_FUNC_STRTOD,
981[AC_CACHE_CHECK(for working strtod, am_cv_func_strtod,
982[AC_TRY_RUN([
983double strtod ();
984int
985main()
986{
987 {
988 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
989 char *string = " +69";
990 char *term;
991 double value;
992 value = strtod (string, &term);
993 if (value != 69 || term != (string + 4))
994 exit (1);
995 }
996
997 {
998 /* Under Solaris 2.4, strtod returns the wrong value for the
999 terminating character under some conditions. */
1000
1001## @defmac AC_FUNC_STRTOD
1002## @maindex FUNC_STRTOD
1003## @ovindex LIBOBJS
1004## If the @code{strtod} function is not available, or does not work
1005## correctly (like the one on SunOS 5.4), add @samp{strtod.o} to output
1006## variable @code{LIBOBJS}.
1007## @end defmac
1008
1009AC_DEFUN(AM_FUNC_STRTOD,
1010[AC_CACHE_CHECK(for working strtod, am_cv_func_strtod,
1011[AC_TRY_RUN([
1012double strtod ();
1013int
1014main()
1015{
1016 {
1017 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1018 char *string = " +69";
1019 char *term;
1020 double value;
1021 value = strtod (string, &term);
1022 if (value != 69 || term != (string + 4))
1023 exit (1);
1024 }
1025
1026 {
1027 /* Under Solaris 2.4, strtod returns the wrong value for the
1028 terminating character under some conditions. */
1029 char *string = "NaN";
1030 char *term;
1031 strtod (string, &term);
1032 if (term != string && *(term - 1) == 0)
1033 exit (1);
1034 }
1035 exit (0);
1036}
1037], am_cv_func_strtod=yes, am_cv_func_strtod=no, am_cv_func_strtod=no)])
1038test $am_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
1039AC_SUBST(LIBOBJS)dnl
1040am_cv_func_strtod_needs_libm=no
1041if test $am_cv_func_strtod = no; then
1042 AC_CHECK_FUNCS(pow)
1043 if test $ac_cv_func_pow = no; then
1044 AC_CHECK_LIB(m, pow, [am_cv_func_strtod_needs_libm=yes],
1045 [AC_MSG_WARN(can't find library containing definition of pow)])
1046 fi
1047fi
1048])
1049
1050dnl --- *@-AM_SYS_POSIX_TERMIOS-@* ---
1051dnl
1052dnl Author: Jim Meyering
1053dnl
1054dnl Synopsis: AM_SYS_POSIX_TERMIOS
1055dnl
1056dnl Arguments: ---
1057dnl
1058dnl Use: Checks for a POSIX termios.h.
1059
1060AC_DEFUN(AM_SYS_POSIX_TERMIOS,
1061[AC_CACHE_CHECK([POSIX termios], am_cv_sys_posix_termios,
1062 [AC_TRY_LINK([#include <sys/types.h>
1063#include <unistd.h>
1064#include <termios.h>],
1065 [/* SunOS 4.0.3 has termios.h but not the library calls. */
1066 tcgetattr(0, 0);],
1067 am_cv_sys_posix_termios=yes,
1068 am_cv_sys_posix_termios=no)])
1069])
1070
1071dnl----- Macros by Mark Wooding ------------------------------ *@--IGNORE--@*
1072
a80cb8cc 1073dnl --- *@-mdw_REQUIRE-@* ---
aaa99339 1074dnl
1075dnl Author: Mark Wooding
1076dnl
a80cb8cc 1077dnl Synopsis: mdw_REQUIRE(MACRO, ARGS...)
aaa99339 1078dnl
a80cb8cc 1079dnl Arguments: MACRO = name of a macro which should have been called
1080dnl ARGS = arguments to pass
aaa99339 1081dnl
a80cb8cc 1082dnl Use: Like `AC_REQUIRE', only it handles arguments.
aaa99339 1083
a80cb8cc 1084AC_DEFUN(mdw_REQUIRE,
17fc60ae 1085[ifdef([AC_PROVIDE_$1], ,
a80cb8cc 1086[AC_DIVERT_PUSH(builtin(eval, AC_DIVERSION_CURRENT - 1))dnl
1087indir($@)
1088AC_DIVERT_POP()dnl
1089])])
aaa99339 1090
1091dnl --- *@-mdw_CURSES-@* ---
1092dnl
1093dnl Author: Mark Wooding
1094dnl
1095dnl Synopsis: mdw_CURSES
1096dnl
1097dnl Arguments: ---
1098dnl
a80cb8cc 1099dnl Use: Searches for a `curses' library (one of `ncurses' or
1100dnl `curses') using mdw_CHECK_MANYLIBS. If one is found, the
1101dnl preprocessor macro HAVE_CURSES is defined, and a search is
1102dnl made for a `curses' header file (one of <ncurses.h>,
1103dnl <ncurses/ncurses.h> or <curses.h>) using AC_CHECK_HEADERS
1104dnl and the appropriate preprocessor symbol is defined.
1105dnl Finally, a check is made for the function `wresize' using
1106dnl AC_CHECK_FUNCS.
aaa99339 1107
1108AC_DEFUN(mdw_CURSES,
1109[mdw_CHECK_MANYLIBS(newwin, ncurses curses, AC_DEFINE(HAVE_CURSES))
1110if test $mdw_cv_lib_newwin != no; then
1111AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h curses.h], [break])
1112if test "$ac_cv_header_ncurses_h" = "no" &&
1113 test "$ac_cv_header_ncurses_ncurses_h" = "no" &&
1114 test "$ac_cv_header_curses_h" = "no"; then
1115 AC_MSG_WARN([couldn't find a \`curses' header. Assuming \`curses.h'.])
1116 AC_DEFINE(HAVE_CURSES_H)
1117fi
1118AC_CHECK_FUNCS(wresize)
1119fi])
1120
1121dnl --- *@-mdw_TYPE_SSIZE_T-@* ---
1122dnl
1123dnl Author: Mark Wooding
1124dnl
1125dnl Synopsis: mdw_TYPE_SSIZE_T
1126dnl
1127dnl Arguments: ---
1128dnl
a80cb8cc 1129dnl Use: Checks whether the Posix type `ssize_t' is defined. If not,
1130dnl it defaults to `int'.
aaa99339 1131
1132AC_DEFUN(mdw_TYPE_SSIZE_T,
a80cb8cc 1133[AC_REQUIRE([AC_HEADER_STDC])
1134AC_CACHE_CHECK(for ssize_t, mdw_cv_ssize_t,
aaa99339 1135[AC_EGREP_CPP(ssize_t,
1136[#include <sys/types.h>
1137#if HAVE_UNISTD_H
1138#include <unistd.h>
1139#endif
1140#if STDC_HEADERS
1141#include <stdlib.h>
1142#include <stddef.h>
1143#endif],
a80cb8cc 1144[mdw_cv_ssize_t=yes], [mdw_cv_ssize_t=no])])
1145if test $mdw_cv_ssize_t = no; then
aaa99339 1146 AC_DEFINE(ssize_t, int)
1147fi])
1148
6c1c6588 1149dnl --- *@-mdw_DECL_ENVIRON-@* ---
b91e2391 1150dnl
1151dnl Author: Mark Wooding
1152dnl
a80cb8cc 1153dnl Synopsis: mdw_DECL_ENVIRON
b91e2391 1154dnl
a80cb8cc 1155dnl Arguments: ---
b91e2391 1156dnl
a80cb8cc 1157dnl Use: Searches for a declaration of the global `environ' variable.
1158dnl If one is found in one of the `usual' places, DECL_ENVIRON
1159dnl is defined as a preprocessor symbol.
b91e2391 1160
a80cb8cc 1161AC_DEFUN(mdw_DECL_ENVIRON,
1162[AC_CACHE_CHECK([for declaration of \`environ'], mdw_cv_environ,
1163[AC_EGREP_CPP(environ,
1164[#include <sys/types.h>
1165#if HAVE_UNISTD_H
1166#include <unistd.h>
1167#endif
1168#if STDC_HEADERS
1169#include <stdlib.h>
1170#include <stddef.h>
1171#endif], [mdw_cv_environ=yes], [mdw_cv_environ=no])])
1172if test $mdw_cv_environ = yes; then
1173 AC_DEFINE(DECL_ENVIRON)
1174fi])
b91e2391 1175
1176dnl --- *@-mdw_CHECK_MANYLIBS-@* ---
1177dnl
1178dnl Author: Mark Wooding
1179dnl
37dec778 1180dnl Synopsis: mdw_CHECK_MANYLIBS(FUNC, LIBS, [IF-FOUND], [IF-NOT-FOUND],
1181dnl [INCLUDES], [ARGS])
b91e2391 1182dnl
1183dnl Arguments: FUNC = a function to try to find
1184dnl LIBS = a whitespace-separated list of libraries to search
1185dnl IF-FOUND = what to do when the function is found
1186dnl IF-NOT-FOUND = what to do when the function isn't found
37dec778 1187dnl INCLUDES = other include files to add
1188dnl ARGS = arguments to pass the function
b91e2391 1189dnl
1190dnl Use: Searches for a library which defines FUNC. It first tries
1191dnl without any libraries; then it tries each library specified
1192dnl in LIBS in turn. If it finds a match, it adds the
1193dnl appropriate library to `LIBS'.
1194dnl
1195dnl This is particularly handy under DIREIX: if you link with
1196dnl `-lnsl' then you get non-NIS-aware versions of getpwnam and
1197dnl so on, which is clearly a Bad Thing.
1198
1199AC_DEFUN(mdw_CHECK_MANYLIBS,
1200[AC_CACHE_CHECK([for library containing $1], [mdw_cv_lib_$1],
1201[mdw_save_LIBS="$LIBS"
1202mdw_cv_lib_$1="no"
37dec778 1203AC_TRY_LINK([$5], [$1($6)], [mdw_cv_lib_$1="none required"])
b91e2391 1204test "$mdw_cv_lib_$1" = "no" && for i in $2; do
1205LIBS="-l$i $mdw_save_LIBS"
37dec778 1206AC_TRY_LINK([$5], [$1($6)],
b91e2391 1207[mdw_cv_lib_$1="-l$i"
1208break])
1209done
1210LIBS="$mdw_save_LIBS"])
1211if test "$mdw_cv_lib_$1" != "no"; then
1212 test "$mdw_cv_lib_$1" = "none required" || LIBS="$mdw_cv_lib_$1 $LIBS"
1213 $3
1214else :
1215 $4
1216fi])
1217
1218dnl --- *@-mdw__PERL_VERSION-@* ---
1219dnl
1220dnl AC_DEFUN relies on `[', `]' being quotes, so I have to drop down a level.
1221
1222changequote(<<, >>)
1223define(mdw__PERL_VERSION, <<$1 -e 'exit ($] < $2);' >&5 2>&5>>)
1224changequote([, ])
1225
1226dnl --- *@-mdw_PROG_PERL-@* ---
1227dnl
1228dnl Author: Mark Wooding
1229dnl
1230dnl Synopsis: mdw_PROG_PERL(VERSION, [IF-FOUND], [IF-NOT-FOUND])
1231dnl
1232dnl Arguments: VERSION = version number of Perl required
1233dnl IF-FOUND = what to do if it's found
1234dnl IF-NOT-FOUND = what to do if it isn't
1235dnl
1236dnl Use: Attempts to find a working version of Perl with a late
1237dnl enough version number. It supplies an option `--with-perl'
1238dnl to allow the user to provide a Perl interpreter. If one
1239dnl isn't provided explicitly, it searches for `perl' and `perl5'
1240dnl in the current PATH, asking them whether they have a late
1241dnl enough version number. The path of the working Perl is
1242dnl put into the `PERL' environment variable; `AC_SUBST' is used
1243dnl to substitute its value into Perl scripts. If there is no
1244dnl Perl to be found, the value of `PERL' is set to be `none'.
1245
1246AC_DEFUN(mdw_PROG_PERL,
1247[AC_ARG_WITH([perl],
1248[ --with-perl=PERL specify path to Perl version $1 or newer],
1249[PERL="$withval"],
1250if test -z "$PERL"; then
1251[AC_CACHE_CHECK([for Perl version $1 or later], mdw_cv_prog_perl,
1252[mdw_cv_prog_perl="none"
1253for p in `echo "$PATH:/usr/local/bin" | tr ":" " "`; do
1254 case $p in /*) ;; *) p=`pwd`/$p ;; esac
1255 if mdw__PERL_VERSION(["$p/perl"], $1); then
1256 mdw_cv_prog_perl="$p/perl"
1257 break
1258 fi
1259 if mdw__PERL_VERSION(["$p/perl5"], $1); then
1260 mdw_cv_prog_perl="$p/perl5"
1261 break
1262 fi
1263done])
1264PERL="$mdw_cv_prog_perl"])
1265fi
1266
1267AC_SUBST(PERL)dnl
1268if test "$PERL" = "none"; then :
1269 $3
1270else :
1271 $2
1272fi])
1273
1274dnl --- *@-mdw_CHECK_PERL-@* ---
1275dnl
1276dnl Author: Mark Wooding
1277dnl
1278dnl Synopsis: mdw_CHECK_PERL(VERSION)
1279dnl
1280dnl Arguments: VERSION = version number of Perl required
1281dnl
1282dnl Use: Verifies that the Perl interpreter in the `PERL' shell
1283dnl variable actually works and is of the right version. If it's
1284dnl not, an error is raised and configuration is aborted.
1285
1286AC_DEFUN(mdw_CHECK_PERL,
1287[mdw_REQUIRE([mdw_PROG_PERL], [$1])
1288AC_MSG_CHECKING([whether Perl ($PERL) works])
1289if test "$PERL" != "none" && mdw__PERL_VERSION("$PERL", $1); then
1290 AC_MSG_RESULT([yes])
1291else
1292 AC_MSG_RESULT([no])
1293 AC_MSG_ERROR([Perl version $1 or newer not found.
1294If you have a recent enough Perl, and I just failed to find it, try using
1295the --with-perl=PERL option to give me an explicit pathname.])
1296fi])
1297
1298dnl --- *@-mdw_PERLLIB_CHECK-@* ---
1299dnl
1300dnl Author: Mark Wooding
1301dnl
1302dnl Synopsis: mdw_PERLLIB_CHECK(LIBRARY)
1303dnl
1304dnl Arguments: LIBRARY = name of a Perl library to check for
1305dnl
1306dnl Use: Ensures that a Perl script can `use LIBRARY;'. If it can,
1307dnl all's well and good; if it can't, `LIBRARY.pm' is added to
1308dnl the variable `NEEDED_PERLLIBS' and a line which adds
1309dnl `pkgdatadir' to Perl's `@INC' array is placed in the
1310dnl variable `INC_PERLLIBS'; `AC_SUBST' is called for both of
1311dnl these variables. It's expected that `NEEDED_PERLLIBS' will
1312dnl be used in the `Makefile.in' to decide which versions from
1313dnl the distribution need installing.
1314dnl
1315dnl This macro isn't terribly useful in the general case. It
1316dnl Also implicitly assumes that `$PERL' is Perl 5 or later.
1317
1318AC_DEFUN(mdw__PERLLIB_INIT,
1319[AC_SUBST(INC_PERLLIBS)dnl
1320AC_SUBST(NEEDED_PERLLIBS)dnl
1321])
1322
1323AC_DEFUN(mdw_PERLLIB_CHECK,
1324[AC_REQUIRE([mdw__PERLLIB_INIT])
1325mdw_REQUIRE([mdw_CHECK_PERL], 5)
1326AC_CACHE_CHECK([for Perl library $1], mdw_cv_perllib_$1,
1327[if $PERL -e 'use $1;' >&5 2>&5; then
1328 mdw_cv_perllib_$1="yes"
1329else
1330 mdw_cv_perllib_$1="no"
1331fi])
1332
1333if test "$mdw_cv_perllib_$1" = "no"; then
1334 NEEDED_PERLLIBS="$NEEDED_PERLLIBS $1.pm"
1335
1336 # --- Deal with autoconf lossage ---
1337 #
1338 # It doesn't want to define `prefix' until rather later on, so I have
1339 # to bodge it here.
1340
1341 if test -z "$INC_PERLLIBS"; then
1342 mdw_old_prefix="$prefix"
1343 test "$prefix" = "NONE" && prefix="$ac_default_prefix";
1344 INC_PERLLIBS="BEGIN { push @INC, \"`eval echo $datadir/$PACKAGE`\"; }"
1345 prefix="$mdw_old_prefix";
1346 fi
1347fi])
1348
1349dnl --- *@-mdw_GCC_FLAGS-@* ---
1350dnl
1351dnl Author: Mark Wooding
1352dnl
1353dnl Synopsis: mdw_GCC_FLAGS([FLAGS], [CFLAGS], [C++FLAGS])
1354dnl
1355dnl Arguments: FLAGS = GCC compiler flags to add (default is
1356dnl `-pedantic -Wall')
1357dnl CFLAGS = GCC C compiler flags to add (default is empty)
1358dnl C++FLAGS = GCC C++ compiler flags to add (default is
1359dnl `-fhandle-exceptions').
1360dnl
1361dnl Use: If the C compiler is GCC, add the compiler flags.
1362
1363AC_DEFUN(mdw_GCC_FLAGS,
1364[if test "$GCC" = "yes"; then
1365 CFLAGS="$CFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
1366 CFLAGS="$CFLAGS ifelse([$2], [], [], [$2])"
1367fi
1368if test "$GXX" = "yes"; then
1369 CXXFLAGS="$CXXFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
1370 CXXFLAGS="$CXXFLAGS ifelse([$3], [], [-fhandle-exceptions], [$3])"
1371fi])
1372
08f6362d 1373dnl *@-mdw_INIT_LIB-@*
17fc60ae 1374dnl
1375dnl Author: Mark Wooding
1376dnl
08f6362d 1377dnl Synopsis: mdw_INIT_LIB(LIB, NAME, VERSION, [PACKAGE])
17fc60ae 1378dnl
08f6362d 1379dnl Arguments: LIB = the name of the library (and the package)
1380dnl NAME = a presentable version of the library's name
1381dnl VERSION = version of the library
1382dnl PACKAGE = package name to pass on to AM_INIT_AUTOMAKE
1383dnl
1384dnl Use: Sets up various useful variables. This macro calls
1385dnl AM_INIT_AUTOMAKE, which might be considered useful. It also
1386dnl provides variables for the use of `lib-config.in'.
1387
1388AC_DEFUN([mdw_INIT_LIB],
1389[AM_INIT_AUTOMAKE(ifelse([$4], [], [$1], [$4]), [$3])
1390LIBRARY="$1" AC_SUBST(LIBRARY)
1391LIBNAME="$2" AC_SUBST(LIBNAME)])
1392
1393dnl *@-mdw_LIB_CONFIG-@*
1394dnl
1395dnl Author: Mark Wooding
1396dnl
1397dnl Synopsis: mdw_LIB_CONFIG(LIB, NAME, VERSION, IF-FOUND, IF-NOT-FOUND)
1398dnl
1399dnl Arguments: LIB = the name of the library (and its configuration program)
1400dnl NAME = a presentable version of the library's name
1401dnl VERSION = version of library required
17fc60ae 1402dnl IF-FOUND = what to do if found
1403dnl IF-NOT-FOUND = what to do if not found
1404dnl
08f6362d 1405dnl Use: Configures a library client program, using a configuration
1406dnl script provided by the library maintainer.
1407dnl
1408dnl The default version is 1.0.0pre0; the default action is to
1409dnl add everything to the CFLAGS and LIBS variables, and complain
17fc60ae 1410dnl if the library couldn't be found.
1411dnl
08f6362d 1412dnl The variable LIB_VERSION contains the version number of
1413dnl the library; LIB_CFLAGS is the C compiler flags required
1414dnl and LIB_LIBS is the linker flags.
1415
1416AC_DEFUN([mdw_LIB_CONFIG],
1417[pushdef([upname], translit([$1], [a-z], [A-Z]))dnl
1418AC_MSG_CHECKING([for $2 library])
1419if $1-config --check $3 >/dev/null 2>&1; then
1420 upname[]_VERSION=`$1-config --version`
1421 upname[]_CFLAGS=`$1-config --cflags`
1422 upname[]_LIBS=`$1-config --libs`
1423 AC_SUBST(upname[]_VERSION)
1424 AC_SUBST(upname[]_CFLAGS)
1425 AC_SUBST(upname[]_LIBS)
1426 ifelse([$4], [],
1427 [CFLAGS="$CFLAGS $upname[]_CFLAGS"
1428 LIBS="$upname[]_LIBS $LIBS"],
1429 $4)
1430 AC_MSG_RESULT([$upname[]_VERSION])
17fc60ae 1431else
08f6362d 1432 ifelse([$5], [],
1433 AC_MSG_ERROR([$2 library not found or too old.]),
1434 $5)
17fc60ae 1435 AC_MSG_RESULT([not found])
1436fi])
1437
08f6362d 1438dnl *@-mdw_MLIB-@*
5a27eb4e 1439dnl
1440dnl Author: Mark Wooding
1441dnl
08f6362d 1442dnl Synopsis: mdw_MLIB(VERSION, IF-FOUND, IF-NOT-FOUND
5a27eb4e 1443dnl
1444dnl Arguments: VERSION = version of library required
1445dnl IF-FOUND = what to do if found
1446dnl IF-NOT-FOUND = what to do if not found
1447dnl
08f6362d 1448dnl Use: Configures an mLib client program.
5a27eb4e 1449
08f6362d 1450AC_DEFUN([mdw_MLIB], [mdw_LIB_CONFIG(mLib, mLib, $@)])
5a27eb4e 1451
08f6362d 1452dnl *@-mdw_MGLIB-@*
5ba1b8b8 1453dnl
1454dnl Author: Mark Wooding
1455dnl
08f6362d 1456dnl Synopsis: mdw_MGLIB(VERSION, IF-FOUND, IF-NOT-FOUND
5ba1b8b8 1457dnl
1458dnl Arguments: VERSION = version of library required
1459dnl IF-FOUND = what to do if found
1460dnl IF-NOT-FOUND = what to do if not found
1461dnl
08f6362d 1462dnl Use: Configures an mgLib client program.
1463
1464AC_DEFUN([mdw_MGLIB],
1465[mdw_REQUIRE([mdw_MLIB], [1.6.0])
1466mdw_LIB_CONFIG(mgLib, mgLib, $@)])
5ba1b8b8 1467
17fc60ae 1468dnl *@-mdw_CATACOMB-@*
1469dnl
1470dnl Author: Mark Wooding
1471dnl
1472dnl Synopsis: mdw_CATACOMB([VERSION], [IF-FOUND], [IF-NOT-FOUND])
1473dnl
1474dnl Arguments: VERSION = version of Catacomb required
1475dnl IF-FOUND = what to do if found
1476dnl IF-NOT-FOUND = what to do if not found
1477dnl
08f6362d 1478dnl Use: Configures the program as a Catacomb client.
17fc60ae 1479
1480AC_DEFUN([mdw_CATACOMB],
5a27eb4e 1481[mdw_REQUIRE([mdw_MLIB], [1.6.0])
08f6362d 1482mdw_LIB_CONFIG(catacomb, Catacomb, $@)])
1483
1484dnl *@-mdw_PK-@*
1485dnl
1486dnl Author: Mark Wooding
1487dnl
1488dnl Synopsis: mdw_PK([VERSION], [IF-FOUND], [IF-NOT-FOUND])
1489dnl
1490dnl Arguments: VERSION = version of PK required
1491dnl IF-FOUND = what to do if found
1492dnl IF-NOT-FOUND = what to do if not found
1493dnl
1494dnl Use: Configures the program as a PK client.
1495
1496AC_DEFUN([mdw_PK],
1497[mdw_REQUIRE([mdw_MLIB], [1.6.0])
1498mdw_LIB_CONFIG(pk, PK, $@)])
17fc60ae 1499
b91e2391 1500dnl --- *@-mdw_OPT_NDEBUG-@* ---
1501dnl
1502dnl Author: Mark Wooding
1503dnl
1504dnl Synopsis: mdw_OPT_NDEBUG
1505dnl
1506dnl Arguments: ---
1507dnl
1508dnl Use: Turns off the `NDEBUG' flag if the user wants to do
1509dnl debugging.
1510
1511AC_DEFUN(mdw_OPT_NDEBUG,
1512[AC_ARG_ENABLE(debugging,
1513[ --enable-debugging spews vast swathes of useless information],
1514[if test "$enableval" = "no"; then
1515 AC_DEFINE(NDEBUG, 1)
1516fi],
1517[AC_DEFINE(NDEBUG, 1)])])
1518
1519dnl --- *@-mdw_OPT_EFENCE-@* ---
1520dnl
1521dnl Author: Mark Wooding
1522dnl
1523dnl Synopsis: mdw_OPT_EFENCE
1524dnl
1525dnl Arguments: ---
1526dnl
1527dnl Use: Links with the Electric Fence library.
1528
1529AC_DEFUN(mdw_OPT_EFENCE,
1530[AC_ARG_WITH(electric-fence,
1531[ --with-electric-fence link programs with Electric Fence],
1532[if test "$withval" = "yes"; then
1533 AC_CHECK_LIB(efence, malloc)
1534fi])])
1535
1536dnl --- *@-mdw_OPT_mLib_DEBUG-@* ---
1537dnl
1538dnl Author: Mark Wooding
1539dnl
1540dnl Synopsis: mdw_OPT_mLib_DEBUG(PROGRAM)
1541dnl
1542dnl Arguments: ---
1543dnl
1544dnl Use: Provides options for mLib debugging. In particular, the
1545dnl following are defined:
1546dnl
1547dnl --enable-tracing turns off the NTRACE variable
1548dnl --enable-track turns on malloc tracking
1549dnl --enable-blame-PROGRAM tracks malloc contexts in PROGRAM
1550dnl
1551dnl There must be a separate `blame' option, so that the various
1552dnl blame options work properly.
1553
1554AC_DEFUN(mdw_OPT_mLib_DEBUG,
1555[mdw_OPT_NDEBUG
1556mdw_OPT_EFENCE
1557
1558AC_ARG_ENABLE(tracing,
1559[ --enable-tracing enable output of tracing information],
1560[if test "$enableval" = "no"; then
1561 AC_DEFINE(NTRACE, 1)
1562fi],
1563[AC_DEFINE(NTRACE, 1)])
1564
1565AC_ARG_ENABLE(track,
1566[ --enable-track enable tracking of malloc and free],
1567[AC_DEFINE(TRACK_ENABLE, 1)])
1568
1569AC_ARG_ENABLE(blame-$1,
1570[ --enable-blame-$1
1571 track malloc contexts while in $1],
1572[AC_DEFINE(TRACK_BLAME, 1)])])
1573
1574dnl----- That's all, folks --------------------------------- *@--GLOB-END--@*