-dnl --- *@-mdw_CHECK_PERL-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_CHECK_PERL(VERSION)
-dnl
-dnl Arguments: VERSION = version number of Perl required
-dnl
-dnl Use: Verifies that the Perl interpreter in the `PERL' shell
-dnl variable actually works and is of the right version. If it's
-dnl not, an error is raised and configuration is aborted.
-
-AC_DEFUN([mdw_CHECK_PERL],
-[mdw_REQUIRE([mdw_PROG_PERL], [$1])
-AC_MSG_CHECKING([whether Perl ($PERL) works])
-if test "$PERL" != "none" && mdw__PERL_VERSION("$PERL", $1); then
- AC_MSG_RESULT([yes])
-else
- AC_MSG_RESULT([no])
- AC_MSG_ERROR([Perl version $1 or newer not found.
-If you have a recent enough Perl, and I just failed to find it, try using
-the --with-perl=PERL option to give me an explicit pathname.])
-fi])
-
-dnl --- *@-mdw_PERLLIB_CHECK-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_PERLLIB_CHECK(LIBRARY)
-dnl
-dnl Arguments: LIBRARY = name of a Perl library to check for
-dnl
-dnl Use: Ensures that a Perl script can `use LIBRARY;'. If it can,
-dnl all's well and good; if it can't, `LIBRARY.pm' is added to
-dnl the variable `NEEDED_PERLLIBS' and a line which adds
-dnl `pkgdatadir' to Perl's `@INC' array is placed in the
-dnl variable `INC_PERLLIBS'; `AC_SUBST' is called for both of
-dnl these variables. It's expected that `NEEDED_PERLLIBS' will
-dnl be used in the `Makefile.in' to decide which versions from
-dnl the distribution need installing.
-dnl
-dnl This macro isn't terribly useful in the general case. It
-dnl Also implicitly assumes that `$PERL' is Perl 5 or later.
-
-AC_DEFUN([mdw__PERLLIB_INIT],
-[AC_SUBST(INC_PERLLIBS)dnl
-AC_SUBST(NEEDED_PERLLIBS)dnl
-])
-
-AC_DEFUN([mdw_PERLLIB_CHECK],
-[AC_REQUIRE([mdw__PERLLIB_INIT])
-mdw_REQUIRE([mdw_CHECK_PERL], 5)
-AC_CACHE_CHECK([for Perl library $1], mdw_cv_perllib_$1,
-[if $PERL -e 'use $1;' >&5 2>&5; then
- mdw_cv_perllib_$1="yes"
-else
- mdw_cv_perllib_$1="no"
-fi])
-
-if test "$mdw_cv_perllib_$1" = "no"; then
- NEEDED_PERLLIBS="$NEEDED_PERLLIBS $1.pm"
-
- # --- Deal with autoconf lossage ---
- #
- # It doesn't want to define `prefix' until rather later on, so I have
- # to bodge it here.
-
- if test -z "$INC_PERLLIBS"; then
- mdw_old_prefix="$prefix"
- test "$prefix" = "NONE" && prefix="$ac_default_prefix";
- INC_PERLLIBS="BEGIN { push @INC, \"`eval echo $datadir/$PACKAGE`\"; }"
- prefix="$mdw_old_prefix";
- fi
-fi])
-
-dnl --- *@-mdw_GCC_FLAGS-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_GCC_FLAGS([FLAGS], [CFLAGS], [C++FLAGS])
-dnl
-dnl Arguments: FLAGS = GCC compiler flags to add (default is
-dnl `-pedantic -Wall')
-dnl CFLAGS = GCC C compiler flags to add (default is empty)
-dnl C++FLAGS = GCC C++ compiler flags to add (default is
-dnl `-fhandle-exceptions').
-dnl
-dnl Use: If the C compiler is GCC, add the compiler flags.
-
-AC_DEFUN([mdw_GCC_FLAGS],
-[if test "$GCC" = "yes"; then
- CFLAGS="$CFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
- CFLAGS="$CFLAGS ifelse([$2], [], [], [$2])"
-fi
-if test "$GXX" = "yes"; then
- CXXFLAGS="$CXXFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
- CXXFLAGS="$CXXFLAGS ifelse([$3], [], [-fhandle-exceptions], [$3])"
-fi])
-
-dnl --- *@-mdw_INIT_LIB-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_INIT_LIB(LIB, NAME, VERSION, [PACKAGE])
-dnl
-dnl Arguments: LIB = the name of the library (and the package)
-dnl NAME = a presentable version of the library's name
-dnl VERSION = version of the library
-dnl PACKAGE = package name to pass on to AM_INIT_AUTOMAKE
-dnl
-dnl Use: Sets up various useful variables. This macro calls
-dnl AM_INIT_AUTOMAKE, which might be considered useful. It also
-dnl provides variables for the use of `lib-config.in'.
-
-AC_DEFUN([mdw_INIT_LIB],
-[AM_INIT_AUTOMAKE(ifelse([$4], [], [$1], [$4]), [$3])
-LIBRARY="$1" AC_SUBST(LIBRARY)
-LIBNAME="$2" AC_SUBST(LIBNAME)])
-
-dnl --- *@-mdw_LIB_CONFIG-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_LIB_CONFIG(LIB, NAME, VERSION, IF-FOUND, IF-NOT-FOUND)
-dnl
-dnl Arguments: LIB = the name of the library (and its configuration program)
-dnl NAME = a presentable version of the library's name
-dnl VERSION = version of library required
-dnl IF-FOUND = what to do if found
-dnl IF-NOT-FOUND = what to do if not found
-dnl
-dnl Use: Configures a library client program, using a configuration
-dnl script provided by the library maintainer.
-dnl
-dnl The default version is 1.0.0pre0; the default action is to
-dnl add everything to the CFLAGS and LIBS variables, and complain
-dnl if the library couldn't be found.
-dnl
-dnl The variable LIB_VERSION contains the version number of
-dnl the library; LIB_CFLAGS is the C compiler flags required
-dnl and LIB_LIBS is the linker flags.
-
-AC_DEFUN([mdw_LIB_CONFIG],
-[pushdef([upname], translit([$1], [a-z], [A-Z]))dnl
-AC_MSG_CHECKING([for $2 library])
-if $1-config --check $3 >/dev/null 2>&1; then
- upname[]_VERSION=`$1-config --version`
- upname[]_CFLAGS=`$1-config --cflags`
- upname[]_LIBS=`$1-config --libs`
- AC_SUBST(upname[]_VERSION)
- AC_SUBST(upname[]_CFLAGS)
- AC_SUBST(upname[]_LIBS)
- ifelse([$4], [],
- [CFLAGS="$CFLAGS $upname[]_CFLAGS"
- LIBS="$upname[]_LIBS $LIBS"],
- $4)
- AC_MSG_RESULT([$upname[]_VERSION])
-else
- ifelse([$5], [],
- AC_MSG_ERROR([$2 library not found or too old.]),
- $5)
- AC_MSG_RESULT([not found])
-fi
-popdef([upname])])
-
-dnl --- *@-mdw_MLIB-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_MLIB(VERSION, IF-FOUND, IF-NOT-FOUND
-dnl
-dnl Arguments: VERSION = version of library required
-dnl IF-FOUND = what to do if found
-dnl IF-NOT-FOUND = what to do if not found
-dnl
-dnl Use: Configures an mLib client program.
-
-AC_DEFUN([mdw_MLIB], [mdw_LIB_CONFIG(mLib, mLib, $@)])
-
-dnl --- *@-mdw_MGLIB-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_MGLIB(VERSION, IF-FOUND, IF-NOT-FOUND
-dnl
-dnl Arguments: VERSION = version of library required
-dnl IF-FOUND = what to do if found
-dnl IF-NOT-FOUND = what to do if not found
-dnl
-dnl Use: Configures an mgLib client program.
-
-AC_DEFUN([mdw_MGLIB],
-[mdw_REQUIRE([mdw_MLIB], [1.6.0])
-mdw_LIB_CONFIG(mgLib, mgLib, $@)])
-
-dnl --- *@-mdw_CATACOMB-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_CATACOMB([VERSION], [IF-FOUND], [IF-NOT-FOUND])
-dnl
-dnl Arguments: VERSION = version of Catacomb required
-dnl IF-FOUND = what to do if found
-dnl IF-NOT-FOUND = what to do if not found
-dnl
-dnl Use: Configures the program as a Catacomb client.
-
-AC_DEFUN([mdw_CATACOMB],
-[mdw_REQUIRE([mdw_MLIB], [1.6.0])
-mdw_LIB_CONFIG(catacomb, Catacomb, $@)])
-
-dnl --- *@-mdw_PK-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_PK([VERSION], [IF-FOUND], [IF-NOT-FOUND])
-dnl
-dnl Arguments: VERSION = version of PK required
-dnl IF-FOUND = what to do if found
-dnl IF-NOT-FOUND = what to do if not found
-dnl
-dnl Use: Configures the program as a PK client.
-
-AC_DEFUN([mdw_PK],
-[mdw_REQUIRE([mdw_MLIB], [1.6.0])
-mdw_LIB_CONFIG(pk, PK, $@)])
-
-dnl --- *@-mdw_OPT_NDEBUG-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_OPT_NDEBUG
-dnl
-dnl Arguments: ---
-dnl
-dnl Use: Turns on the `NDEBUG' flag, to disable useful things like
-dnl assertions.
-
-AC_DEFUN([mdw_OPT_NDEBUG],
-[AC_ARG_ENABLE(debugging,
-[ --disable-debugging spews vast swathes of useless information],
-[if test "$enableval" = "no"; then
- AC_DEFINE(NDEBUG, 1)
-fi])])
-
-dnl --- *@-mdw_OPT_EFENCE-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_OPT_EFENCE
-dnl
-dnl Arguments: ---
-dnl
-dnl Use: Links with the Electric Fence library.
-
-AC_DEFUN([mdw_OPT_EFENCE],
-[AC_ARG_WITH(electric-fence,
-[ --with-electric-fence link programs with Electric Fence],
-[if test "$withval" = "yes"; then
- AC_CHECK_LIB(efence, malloc)
-fi])])
-
-dnl --- *@-mdw_OPT_TRACE-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_OPT_TRACE
-dnl
-dnl Arguments: ---
-dnl
-dnl Use: Turns on the `NTRACE' flag, to disable useful things like
-dnl trace outputs.
-
-AC_DEFUN([mdw_OPT_TRACE],
-[AC_ARG_ENABLE(tracing,
-[ --disable-tracing disable output of trace information],
-[if test "$enableval" = "no"; then
- AC_DEFINE(NTRACE, 1)
-fi])])
-
-dnl --- *@-mdw_OPT_mLib_TRACK-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_OPT_mLib_TRACK(PROGRAM)
-dnl
-dnl Arguments: PROGRAM = name of this program or package.
-dnl
-dnl Use: Controls the unsupported mLib memory tracker. The
-dnl following are defined:
-dnl
-dnl --enable-track turns on malloc tracking
-dnl --enable-blame-PROGRAM tracks malloc contexts in PROGRAM
-dnl
-dnl There must be a separate `blame' option for each program,
-dnl so that the various blame options in a hierarchy get
-dnl propagated properly. This is an obsolete feature from the
-dnl days when mLib was provided as a subdirectory of other
-dnl packages.
-
-AC_DEFUN([mdw_OPT_mLib_TRACK],
-[AC_REQUIRE([mdw_OPT_TRACE])
-AC_ARG_ENABLE(track,
-[ --enable-track enable tracking of malloc and free],
-[AC_DEFINE(TRACK_ENABLE, 1)])
-AC_ARG_ENABLE(blame-$1,
-[ --enable-blame-$1
- track malloc contexts while in $1],
-[AC_DEFINE(TRACK_BLAME, 1)])])
-
-dnl --- *@-mdw_OPT_mLib_DEBUG-@* ---
-dnl
-dnl Author: Mark Wooding
-dnl
-dnl Synopsis: mdw_OPT_mLib_DEBUG(PROGRAM)
-dnl
-dnl Arguments: PROGRAM = name of this program or package.
-dnl
-dnl Use: Provides all of the above debugging options.
-
-AC_DEFUN([mdw_OPT_mLib_DEBUG],
-[mdw_REQUIRE([mdw_OPT_NDEBUG])
-mdw_REQUIRE([mdw_OPT_mLib_TRACK], [$1])])
-