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