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