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