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