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