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