Fix mdw__PERL_VERSION stuff. Grumble.
[cfd] / aclocal.glob
CommitLineData
b91e2391 1dnl -*-fundamental-*- *@--GLOB-HEADER--@*
2dnl
a1af6b50 3dnl $Id: aclocal.glob,v 1.18 2004/04/08 01:36:24 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
a7855629 28dnl *@--NOTICE--@* Common File Distribution
a1af6b50 29dnl $Id: aclocal.glob,v 1.18 2004/04/08 01:36:24 mdw Exp $
b91e2391 30
a80cb8cc 31dnl --- *@-mdw_REQUIRE-@* ---
aaa99339 32dnl
33dnl Author: Mark Wooding
34dnl
a80cb8cc 35dnl Synopsis: mdw_REQUIRE(MACRO, ARGS...)
aaa99339 36dnl
a80cb8cc 37dnl Arguments: MACRO = name of a macro which should have been called
38dnl ARGS = arguments to pass
aaa99339 39dnl
a80cb8cc 40dnl Use: Like `AC_REQUIRE', only it handles arguments.
aaa99339 41
5656743c 42AC_DEFUN([mdw_REQUIRE],
17fc60ae 43[ifdef([AC_PROVIDE_$1], ,
a80cb8cc 44[AC_DIVERT_PUSH(builtin(eval, AC_DIVERSION_CURRENT - 1))dnl
45indir($@)
46AC_DIVERT_POP()dnl
47])])
aaa99339 48
49dnl --- *@-mdw_CURSES-@* ---
50dnl
51dnl Author: Mark Wooding
52dnl
53dnl Synopsis: mdw_CURSES
54dnl
55dnl Arguments: ---
56dnl
a80cb8cc 57dnl Use: Searches for a `curses' library (one of `ncurses' or
58dnl `curses') using mdw_CHECK_MANYLIBS. If one is found, the
59dnl preprocessor macro HAVE_CURSES is defined, and a search is
60dnl made for a `curses' header file (one of <ncurses.h>,
61dnl <ncurses/ncurses.h> or <curses.h>) using AC_CHECK_HEADERS
62dnl and the appropriate preprocessor symbol is defined.
63dnl Finally, a check is made for the function `wresize' using
64dnl AC_CHECK_FUNCS.
aaa99339 65
5656743c 66AC_DEFUN([mdw_CURSES],
aaa99339 67[mdw_CHECK_MANYLIBS(newwin, ncurses curses, AC_DEFINE(HAVE_CURSES))
68if test $mdw_cv_lib_newwin != no; then
69AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h curses.h], [break])
70if test "$ac_cv_header_ncurses_h" = "no" &&
71 test "$ac_cv_header_ncurses_ncurses_h" = "no" &&
72 test "$ac_cv_header_curses_h" = "no"; then
73 AC_MSG_WARN([couldn't find a \`curses' header. Assuming \`curses.h'.])
74 AC_DEFINE(HAVE_CURSES_H)
75fi
76AC_CHECK_FUNCS(wresize)
77fi])
78
79dnl --- *@-mdw_TYPE_SSIZE_T-@* ---
80dnl
81dnl Author: Mark Wooding
82dnl
83dnl Synopsis: mdw_TYPE_SSIZE_T
84dnl
85dnl Arguments: ---
86dnl
a80cb8cc 87dnl Use: Checks whether the Posix type `ssize_t' is defined. If not,
88dnl it defaults to `int'.
aaa99339 89
5656743c 90AC_DEFUN([mdw_TYPE_SSIZE_T],
a80cb8cc 91[AC_REQUIRE([AC_HEADER_STDC])
92AC_CACHE_CHECK(for ssize_t, mdw_cv_ssize_t,
aaa99339 93[AC_EGREP_CPP(ssize_t,
94[#include <sys/types.h>
95#if HAVE_UNISTD_H
96#include <unistd.h>
97#endif
98#if STDC_HEADERS
99#include <stdlib.h>
100#include <stddef.h>
101#endif],
a80cb8cc 102[mdw_cv_ssize_t=yes], [mdw_cv_ssize_t=no])])
103if test $mdw_cv_ssize_t = no; then
aaa99339 104 AC_DEFINE(ssize_t, int)
105fi])
106
6c1c6588 107dnl --- *@-mdw_DECL_ENVIRON-@* ---
b91e2391 108dnl
109dnl Author: Mark Wooding
110dnl
a80cb8cc 111dnl Synopsis: mdw_DECL_ENVIRON
b91e2391 112dnl
a80cb8cc 113dnl Arguments: ---
b91e2391 114dnl
a80cb8cc 115dnl Use: Searches for a declaration of the global `environ' variable.
116dnl If one is found in one of the `usual' places, DECL_ENVIRON
117dnl is defined as a preprocessor symbol.
b91e2391 118
5656743c 119AC_DEFUN([mdw_DECL_ENVIRON],
a80cb8cc 120[AC_CACHE_CHECK([for declaration of \`environ'], mdw_cv_environ,
121[AC_EGREP_CPP(environ,
122[#include <sys/types.h>
123#if HAVE_UNISTD_H
124#include <unistd.h>
125#endif
126#if STDC_HEADERS
127#include <stdlib.h>
128#include <stddef.h>
129#endif], [mdw_cv_environ=yes], [mdw_cv_environ=no])])
130if test $mdw_cv_environ = yes; then
131 AC_DEFINE(DECL_ENVIRON)
132fi])
b91e2391 133
134dnl --- *@-mdw_CHECK_MANYLIBS-@* ---
135dnl
136dnl Author: Mark Wooding
137dnl
37dec778 138dnl Synopsis: mdw_CHECK_MANYLIBS(FUNC, LIBS, [IF-FOUND], [IF-NOT-FOUND],
139dnl [INCLUDES], [ARGS])
b91e2391 140dnl
141dnl Arguments: FUNC = a function to try to find
142dnl LIBS = a whitespace-separated list of libraries to search
143dnl IF-FOUND = what to do when the function is found
144dnl IF-NOT-FOUND = what to do when the function isn't found
37dec778 145dnl INCLUDES = other include files to add
146dnl ARGS = arguments to pass the function
b91e2391 147dnl
148dnl Use: Searches for a library which defines FUNC. It first tries
149dnl without any libraries; then it tries each library specified
150dnl in LIBS in turn. If it finds a match, it adds the
151dnl appropriate library to `LIBS'.
152dnl
153dnl This is particularly handy under DIREIX: if you link with
154dnl `-lnsl' then you get non-NIS-aware versions of getpwnam and
155dnl so on, which is clearly a Bad Thing.
156
5656743c 157AC_DEFUN([mdw_CHECK_MANYLIBS],
b91e2391 158[AC_CACHE_CHECK([for library containing $1], [mdw_cv_lib_$1],
159[mdw_save_LIBS="$LIBS"
160mdw_cv_lib_$1="no"
37dec778 161AC_TRY_LINK([$5], [$1($6)], [mdw_cv_lib_$1="none required"])
b91e2391 162test "$mdw_cv_lib_$1" = "no" && for i in $2; do
163LIBS="-l$i $mdw_save_LIBS"
37dec778 164AC_TRY_LINK([$5], [$1($6)],
b91e2391 165[mdw_cv_lib_$1="-l$i"
166break])
167done
168LIBS="$mdw_save_LIBS"])
169if test "$mdw_cv_lib_$1" != "no"; then
170 test "$mdw_cv_lib_$1" = "none required" || LIBS="$mdw_cv_lib_$1 $LIBS"
171 $3
172else :
173 $4
174fi])
175
176dnl --- *@-mdw__PERL_VERSION-@* ---
177dnl
178dnl AC_DEFUN relies on `[', `]' being quotes, so I have to drop down a level.
179
180changequote(<<, >>)
5656743c 181define([mdw__PERL_VERSION], <<$1 -e 'exit ($] < $2);' >&5 2>&5>>)
b91e2391 182changequote([, ])
183
184dnl --- *@-mdw_PROG_PERL-@* ---
185dnl
186dnl Author: Mark Wooding
187dnl
188dnl Synopsis: mdw_PROG_PERL(VERSION, [IF-FOUND], [IF-NOT-FOUND])
189dnl
190dnl Arguments: VERSION = version number of Perl required
191dnl IF-FOUND = what to do if it's found
192dnl IF-NOT-FOUND = what to do if it isn't
193dnl
194dnl Use: Attempts to find a working version of Perl with a late
195dnl enough version number. It supplies an option `--with-perl'
196dnl to allow the user to provide a Perl interpreter. If one
197dnl isn't provided explicitly, it searches for `perl' and `perl5'
198dnl in the current PATH, asking them whether they have a late
199dnl enough version number. The path of the working Perl is
200dnl put into the `PERL' environment variable; `AC_SUBST' is used
201dnl to substitute its value into Perl scripts. If there is no
202dnl Perl to be found, the value of `PERL' is set to be `none'.
203
5656743c 204AC_DEFUN([mdw_PROG_PERL],
b91e2391 205[AC_ARG_WITH([perl],
206[ --with-perl=PERL specify path to Perl version $1 or newer],
207[PERL="$withval"],
208if test -z "$PERL"; then
209[AC_CACHE_CHECK([for Perl version $1 or later], mdw_cv_prog_perl,
210[mdw_cv_prog_perl="none"
211for p in `echo "$PATH:/usr/local/bin" | tr ":" " "`; do
212 case $p in /*) ;; *) p=`pwd`/$p ;; esac
213 if mdw__PERL_VERSION(["$p/perl"], $1); then
214 mdw_cv_prog_perl="$p/perl"
215 break
216 fi
217 if mdw__PERL_VERSION(["$p/perl5"], $1); then
218 mdw_cv_prog_perl="$p/perl5"
219 break
220 fi
221done])
222PERL="$mdw_cv_prog_perl"])
223fi
224
225AC_SUBST(PERL)dnl
226if test "$PERL" = "none"; then :
227 $3
228else :
229 $2
230fi])
231
232dnl --- *@-mdw_CHECK_PERL-@* ---
233dnl
234dnl Author: Mark Wooding
235dnl
236dnl Synopsis: mdw_CHECK_PERL(VERSION)
237dnl
238dnl Arguments: VERSION = version number of Perl required
239dnl
240dnl Use: Verifies that the Perl interpreter in the `PERL' shell
241dnl variable actually works and is of the right version. If it's
242dnl not, an error is raised and configuration is aborted.
243
5656743c 244AC_DEFUN([mdw_CHECK_PERL],
b91e2391 245[mdw_REQUIRE([mdw_PROG_PERL], [$1])
246AC_MSG_CHECKING([whether Perl ($PERL) works])
247if test "$PERL" != "none" && mdw__PERL_VERSION("$PERL", $1); then
248 AC_MSG_RESULT([yes])
249else
250 AC_MSG_RESULT([no])
251 AC_MSG_ERROR([Perl version $1 or newer not found.
252If you have a recent enough Perl, and I just failed to find it, try using
253the --with-perl=PERL option to give me an explicit pathname.])
254fi])
255
256dnl --- *@-mdw_PERLLIB_CHECK-@* ---
257dnl
258dnl Author: Mark Wooding
259dnl
260dnl Synopsis: mdw_PERLLIB_CHECK(LIBRARY)
261dnl
262dnl Arguments: LIBRARY = name of a Perl library to check for
263dnl
264dnl Use: Ensures that a Perl script can `use LIBRARY;'. If it can,
265dnl all's well and good; if it can't, `LIBRARY.pm' is added to
266dnl the variable `NEEDED_PERLLIBS' and a line which adds
267dnl `pkgdatadir' to Perl's `@INC' array is placed in the
268dnl variable `INC_PERLLIBS'; `AC_SUBST' is called for both of
269dnl these variables. It's expected that `NEEDED_PERLLIBS' will
270dnl be used in the `Makefile.in' to decide which versions from
271dnl the distribution need installing.
272dnl
273dnl This macro isn't terribly useful in the general case. It
274dnl Also implicitly assumes that `$PERL' is Perl 5 or later.
275
5656743c 276AC_DEFUN([mdw__PERLLIB_INIT],
b91e2391 277[AC_SUBST(INC_PERLLIBS)dnl
278AC_SUBST(NEEDED_PERLLIBS)dnl
279])
280
5656743c 281AC_DEFUN([mdw_PERLLIB_CHECK],
b91e2391 282[AC_REQUIRE([mdw__PERLLIB_INIT])
283mdw_REQUIRE([mdw_CHECK_PERL], 5)
284AC_CACHE_CHECK([for Perl library $1], mdw_cv_perllib_$1,
285[if $PERL -e 'use $1;' >&5 2>&5; then
286 mdw_cv_perllib_$1="yes"
287else
288 mdw_cv_perllib_$1="no"
289fi])
290
291if test "$mdw_cv_perllib_$1" = "no"; then
292 NEEDED_PERLLIBS="$NEEDED_PERLLIBS $1.pm"
293
294 # --- Deal with autoconf lossage ---
295 #
296 # It doesn't want to define `prefix' until rather later on, so I have
297 # to bodge it here.
298
299 if test -z "$INC_PERLLIBS"; then
300 mdw_old_prefix="$prefix"
301 test "$prefix" = "NONE" && prefix="$ac_default_prefix";
302 INC_PERLLIBS="BEGIN { push @INC, \"`eval echo $datadir/$PACKAGE`\"; }"
303 prefix="$mdw_old_prefix";
304 fi
305fi])
306
307dnl --- *@-mdw_GCC_FLAGS-@* ---
308dnl
309dnl Author: Mark Wooding
310dnl
311dnl Synopsis: mdw_GCC_FLAGS([FLAGS], [CFLAGS], [C++FLAGS])
312dnl
313dnl Arguments: FLAGS = GCC compiler flags to add (default is
314dnl `-pedantic -Wall')
315dnl CFLAGS = GCC C compiler flags to add (default is empty)
316dnl C++FLAGS = GCC C++ compiler flags to add (default is
317dnl `-fhandle-exceptions').
318dnl
319dnl Use: If the C compiler is GCC, add the compiler flags.
320
5656743c 321AC_DEFUN([mdw_GCC_FLAGS],
b91e2391 322[if test "$GCC" = "yes"; then
323 CFLAGS="$CFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
324 CFLAGS="$CFLAGS ifelse([$2], [], [], [$2])"
325fi
326if test "$GXX" = "yes"; then
327 CXXFLAGS="$CXXFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
328 CXXFLAGS="$CXXFLAGS ifelse([$3], [], [-fhandle-exceptions], [$3])"
329fi])
330
a7855629 331dnl --- *@-mdw_INIT_LIB-@* ---
17fc60ae 332dnl
333dnl Author: Mark Wooding
334dnl
08f6362d 335dnl Synopsis: mdw_INIT_LIB(LIB, NAME, VERSION, [PACKAGE])
17fc60ae 336dnl
08f6362d 337dnl Arguments: LIB = the name of the library (and the package)
338dnl NAME = a presentable version of the library's name
339dnl VERSION = version of the library
340dnl PACKAGE = package name to pass on to AM_INIT_AUTOMAKE
341dnl
342dnl Use: Sets up various useful variables. This macro calls
343dnl AM_INIT_AUTOMAKE, which might be considered useful. It also
344dnl provides variables for the use of `lib-config.in'.
345
346AC_DEFUN([mdw_INIT_LIB],
347[AM_INIT_AUTOMAKE(ifelse([$4], [], [$1], [$4]), [$3])
348LIBRARY="$1" AC_SUBST(LIBRARY)
349LIBNAME="$2" AC_SUBST(LIBNAME)])
350
a7855629 351dnl --- *@-mdw_LIB_CONFIG-@* ---
08f6362d 352dnl
353dnl Author: Mark Wooding
354dnl
355dnl Synopsis: mdw_LIB_CONFIG(LIB, NAME, VERSION, IF-FOUND, IF-NOT-FOUND)
356dnl
357dnl Arguments: LIB = the name of the library (and its configuration program)
358dnl NAME = a presentable version of the library's name
359dnl VERSION = version of library required
17fc60ae 360dnl IF-FOUND = what to do if found
361dnl IF-NOT-FOUND = what to do if not found
362dnl
08f6362d 363dnl Use: Configures a library client program, using a configuration
364dnl script provided by the library maintainer.
365dnl
366dnl The default version is 1.0.0pre0; the default action is to
367dnl add everything to the CFLAGS and LIBS variables, and complain
17fc60ae 368dnl if the library couldn't be found.
369dnl
08f6362d 370dnl The variable LIB_VERSION contains the version number of
371dnl the library; LIB_CFLAGS is the C compiler flags required
372dnl and LIB_LIBS is the linker flags.
373
374AC_DEFUN([mdw_LIB_CONFIG],
375[pushdef([upname], translit([$1], [a-z], [A-Z]))dnl
376AC_MSG_CHECKING([for $2 library])
377if $1-config --check $3 >/dev/null 2>&1; then
378 upname[]_VERSION=`$1-config --version`
379 upname[]_CFLAGS=`$1-config --cflags`
380 upname[]_LIBS=`$1-config --libs`
381 AC_SUBST(upname[]_VERSION)
382 AC_SUBST(upname[]_CFLAGS)
383 AC_SUBST(upname[]_LIBS)
384 ifelse([$4], [],
385 [CFLAGS="$CFLAGS $upname[]_CFLAGS"
386 LIBS="$upname[]_LIBS $LIBS"],
387 $4)
388 AC_MSG_RESULT([$upname[]_VERSION])
17fc60ae 389else
08f6362d 390 ifelse([$5], [],
391 AC_MSG_ERROR([$2 library not found or too old.]),
392 $5)
17fc60ae 393 AC_MSG_RESULT([not found])
191b8aaf 394fi
395popdef([upname])])
17fc60ae 396
a7855629 397dnl --- *@-mdw_MLIB-@* ---
5a27eb4e 398dnl
399dnl Author: Mark Wooding
400dnl
08f6362d 401dnl Synopsis: mdw_MLIB(VERSION, IF-FOUND, IF-NOT-FOUND
5a27eb4e 402dnl
403dnl Arguments: VERSION = version of library required
404dnl IF-FOUND = what to do if found
405dnl IF-NOT-FOUND = what to do if not found
406dnl
08f6362d 407dnl Use: Configures an mLib client program.
5a27eb4e 408
08f6362d 409AC_DEFUN([mdw_MLIB], [mdw_LIB_CONFIG(mLib, mLib, $@)])
5a27eb4e 410
a7855629 411dnl --- *@-mdw_MGLIB-@* ---
5ba1b8b8 412dnl
413dnl Author: Mark Wooding
414dnl
08f6362d 415dnl Synopsis: mdw_MGLIB(VERSION, IF-FOUND, IF-NOT-FOUND
5ba1b8b8 416dnl
417dnl Arguments: VERSION = version of library required
418dnl IF-FOUND = what to do if found
419dnl IF-NOT-FOUND = what to do if not found
420dnl
08f6362d 421dnl Use: Configures an mgLib client program.
422
423AC_DEFUN([mdw_MGLIB],
424[mdw_REQUIRE([mdw_MLIB], [1.6.0])
425mdw_LIB_CONFIG(mgLib, mgLib, $@)])
5ba1b8b8 426
a7855629 427dnl --- *@-mdw_CATACOMB-@* ---
17fc60ae 428dnl
429dnl Author: Mark Wooding
430dnl
431dnl Synopsis: mdw_CATACOMB([VERSION], [IF-FOUND], [IF-NOT-FOUND])
432dnl
433dnl Arguments: VERSION = version of Catacomb required
434dnl IF-FOUND = what to do if found
435dnl IF-NOT-FOUND = what to do if not found
436dnl
08f6362d 437dnl Use: Configures the program as a Catacomb client.
17fc60ae 438
439AC_DEFUN([mdw_CATACOMB],
5a27eb4e 440[mdw_REQUIRE([mdw_MLIB], [1.6.0])
08f6362d 441mdw_LIB_CONFIG(catacomb, Catacomb, $@)])
442
a7855629 443dnl --- *@-mdw_PK-@* ---
08f6362d 444dnl
445dnl Author: Mark Wooding
446dnl
447dnl Synopsis: mdw_PK([VERSION], [IF-FOUND], [IF-NOT-FOUND])
448dnl
449dnl Arguments: VERSION = version of PK required
450dnl IF-FOUND = what to do if found
451dnl IF-NOT-FOUND = what to do if not found
452dnl
453dnl Use: Configures the program as a PK client.
454
455AC_DEFUN([mdw_PK],
456[mdw_REQUIRE([mdw_MLIB], [1.6.0])
457mdw_LIB_CONFIG(pk, PK, $@)])
17fc60ae 458
b91e2391 459dnl --- *@-mdw_OPT_NDEBUG-@* ---
460dnl
461dnl Author: Mark Wooding
462dnl
463dnl Synopsis: mdw_OPT_NDEBUG
464dnl
465dnl Arguments: ---
466dnl
7a1aef7d 467dnl Use: Turns on the `NDEBUG' flag, to disable useful things like
468dnl assertions.
b91e2391 469
5656743c 470AC_DEFUN([mdw_OPT_NDEBUG],
b91e2391 471[AC_ARG_ENABLE(debugging,
7a1aef7d 472[ --disable-debugging spews vast swathes of useless information],
b91e2391 473[if test "$enableval" = "no"; then
474 AC_DEFINE(NDEBUG, 1)
7a1aef7d 475fi])])
b91e2391 476
477dnl --- *@-mdw_OPT_EFENCE-@* ---
478dnl
479dnl Author: Mark Wooding
480dnl
481dnl Synopsis: mdw_OPT_EFENCE
482dnl
483dnl Arguments: ---
484dnl
485dnl Use: Links with the Electric Fence library.
486
5656743c 487AC_DEFUN([mdw_OPT_EFENCE],
b91e2391 488[AC_ARG_WITH(electric-fence,
489[ --with-electric-fence link programs with Electric Fence],
490[if test "$withval" = "yes"; then
491 AC_CHECK_LIB(efence, malloc)
492fi])])
493
7a1aef7d 494dnl --- *@-mdw_OPT_TRACE-@* ---
b91e2391 495dnl
496dnl Author: Mark Wooding
497dnl
7a1aef7d 498dnl Synopsis: mdw_OPT_TRACE
b91e2391 499dnl
500dnl Arguments: ---
501dnl
7a1aef7d 502dnl Use: Turns on the `NTRACE' flag, to disable useful things like
503dnl trace outputs.
504
5656743c 505AC_DEFUN([mdw_OPT_TRACE],
7a1aef7d 506[AC_ARG_ENABLE(tracing,
507[ --disable-tracing disable output of trace information],
508[if test "$enableval" = "no"; then
509 AC_DEFINE(NTRACE, 1)
510fi])])
511
512dnl --- *@-mdw_OPT_mLib_TRACK-@* ---
513dnl
514dnl Author: Mark Wooding
515dnl
516dnl Synopsis: mdw_OPT_mLib_TRACK(PROGRAM)
517dnl
518dnl Arguments: PROGRAM = name of this program or package.
519dnl
520dnl Use: Controls the unsupported mLib memory tracker. The
b91e2391 521dnl following are defined:
522dnl
b91e2391 523dnl --enable-track turns on malloc tracking
524dnl --enable-blame-PROGRAM tracks malloc contexts in PROGRAM
525dnl
7a1aef7d 526dnl There must be a separate `blame' option for each program,
527dnl so that the various blame options in a hierarchy get
528dnl propagated properly. This is an obsolete feature from the
529dnl days when mLib was provided as a subdirectory of other
530dnl packages.
b91e2391 531
5656743c 532AC_DEFUN([mdw_OPT_mLib_TRACK],
7a1aef7d 533[AC_REQUIRE([mdw_OPT_TRACE])
b91e2391 534AC_ARG_ENABLE(track,
535[ --enable-track enable tracking of malloc and free],
536[AC_DEFINE(TRACK_ENABLE, 1)])
b91e2391 537AC_ARG_ENABLE(blame-$1,
538[ --enable-blame-$1
539 track malloc contexts while in $1],
540[AC_DEFINE(TRACK_BLAME, 1)])])
541
7a1aef7d 542dnl --- *@-mdw_OPT_mLib_DEBUG-@* ---
543dnl
544dnl Author: Mark Wooding
545dnl
546dnl Synopsis: mdw_OPT_mLib_DEBUG(PROGRAM)
547dnl
548dnl Arguments: PROGRAM = name of this program or package.
549dnl
550dnl Use: Provides all of the above debugging options.
551
5656743c 552AC_DEFUN([mdw_OPT_mLib_DEBUG],
7a1aef7d 553[mdw_REQUIRE([mdw_OPT_NDEBUG])
554mdw_REQUIRE([mdw_OPT_mLib_TRACK], [$1])])
555
5656743c 556dnl --- *@-mdw_DEFINE_PATHS-@*
557dnl
558dnl Author: Mark Wooding
559dnl
c601ddb3 560dnl Synopsis: mdw_DEFINE_FILES(CODE)
5656743c 561dnl
562dnl Arguments: CODE = shell script code to execute
563dnl
564dnl Use: Fixes up various variables so that pathname defines can be
565dnl defined. Within CODE, you may use the following macros:
566dnl
567dnl mdw_PROG(NAME) Transformed program name
568dnl
569dnl mdw_PATH(PATH) Expanded path (may contain variables)
570dnl
571dnl mdw_DEFINE_PROG(SYMBOL, PROG)
572dnl Define a symbol as a transformed
573dnl program name.
574dnl
575dnl mdw_DEFINE_PATH(SYMBOL, NAME)
576dnl Define a symbol as an expanded path
577
578AC_DEFUN([mdw_DEFINE_PATHS],
579[mdw_prefix=$prefix mdw_exec_prefix=$exec_prefix
580mdw_transform=`echo "$program_transform_name"|sed 's,\\\\\\\\,\\\\,g; s,\\$\\$,$,g'`
581test "$prefix" = "NONE" && prefix=$ac_default_prefix
582test "$exec_prefix" = "NONE" && exec_prefix=$prefix
583$1
584prefix=$mdw_prefix exec_prefix=$mdw_exec_prefix])
585
586AC_DEFUN([mdw_PROG], [`echo "$1"|sed "$mdw_transform"`])
587AC_DEFUN([mdw_PATH], [dnl
588`t="$1"; dnl
589while :; do dnl
590case "$t" in dnl
591*\\$[]*) t=\`eval echo "$t"\`;; dnl
592*) break;; dnl
593esac; done; dnl
594echo "$t"`])
595AC_DEFUN([mdw_DEFINE_PROG], [AC_DEFINE_UNQUOTED([$1], ["mdw_PROG([$2])"])])
596AC_DEFUN([mdw_DEFINE_PATH], [AC_DEFINE_UNQUOTED([$1], ["mdw_PATH([$2])"])])
597
c601ddb3 598dnl --- *@-mdw_DIR_TEXMF-@* ---
599dnl
600dnl Author: Mark Wooding
601dnl
602dnl Synopsis: mdw_DIR_TEXMF
603dnl
604dnl Arguments: ---
605dnl
606dnl Use: Sets the substitution `texmfdir' as a sensible TeX install
607dnl tree.
608
609AC_DEFUN([mdw_DIR_TEXMF], [
610AC_ARG_WITH([texmfdir],
611[ --with-texmfdir=DIR set the TeX install directory to DIR],
0494ba14 612[texmfdir=$withval],
c601ddb3 613[AC_MSG_CHECKING([where to put installed TeX files])
614mdw_DEFINE_PATHS([
615texmfdir='${datadir}/texmf'
616for d in \
617 '${datadir}/texmf' '${prefix}/lib/texmf' \
618 '${prefix}/texmf' '${libdir}/lib/texmf'; do
619 if test -d "mdw_PATH([$d])"; then
620 texmfdir=$d
621 break
622 fi
623done
624AC_MSG_RESULT([$texmfdir])])])
625AC_SUBST(texmfdir)])
626
0494ba14 627dnl --- *@-mdw_MANEXT-@* ---
628dnl
629dnl Author: Mark Wooding
630dnl
631dnl Synopsis: mdw_MANEXT
632dnl
633dnl Arguments: ---
634dnl
635dnl Use: Sets the substitution `manext' for man page extensions.
636
637AC_DEFUN([mdw_MANEXT], [
638AC_ARG_WITH([man-ext],
639[ --with-man-ext=EXT give manpages the EXT extension (e.g., foo.3EXT)],
640[manext=$withval], [manext=mLib])
641AC_SUBST(manext)])
642
b91e2391 643dnl----- That's all, folks --------------------------------- *@--GLOB-END--@*