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