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