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