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