Fix mdw__PERL_VERSION stuff. Grumble.
[cfd] / aclocal.glob
CommitLineData
b91e2391 1dnl -*-fundamental-*- *@--GLOB-HEADER--@*
2dnl
4cb2b091 3dnl $Id$
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
4cb2b091 29dnl $Id$
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
4cb2b091 180AC_DEFUN([mdw__PERL_VERSION], [mdw__PERL_VERSION_hack([$1], [$2])])
b91e2391 181changequote(<<, >>)
4cb2b091 182define(<<mdw__PERL_VERSION_hack>>, <<$1 -e 'exit ($] < $2);' >&5 2>&5>>)
b91e2391 183changequote([, ])
184
185dnl --- *@-mdw_PROG_PERL-@* ---
186dnl
187dnl Author: Mark Wooding
188dnl
189dnl Synopsis: mdw_PROG_PERL(VERSION, [IF-FOUND], [IF-NOT-FOUND])
190dnl
191dnl Arguments: VERSION = version number of Perl required
192dnl IF-FOUND = what to do if it's found
193dnl IF-NOT-FOUND = what to do if it isn't
194dnl
195dnl Use: Attempts to find a working version of Perl with a late
196dnl enough version number. It supplies an option `--with-perl'
197dnl to allow the user to provide a Perl interpreter. If one
198dnl isn't provided explicitly, it searches for `perl' and `perl5'
199dnl in the current PATH, asking them whether they have a late
200dnl enough version number. The path of the working Perl is
201dnl put into the `PERL' environment variable; `AC_SUBST' is used
202dnl to substitute its value into Perl scripts. If there is no
203dnl Perl to be found, the value of `PERL' is set to be `none'.
204
5656743c 205AC_DEFUN([mdw_PROG_PERL],
b91e2391 206[AC_ARG_WITH([perl],
207[ --with-perl=PERL specify path to Perl version $1 or newer],
208[PERL="$withval"],
209if test -z "$PERL"; then
210[AC_CACHE_CHECK([for Perl version $1 or later], mdw_cv_prog_perl,
211[mdw_cv_prog_perl="none"
212for p in `echo "$PATH:/usr/local/bin" | tr ":" " "`; do
213 case $p in /*) ;; *) p=`pwd`/$p ;; esac
214 if mdw__PERL_VERSION(["$p/perl"], $1); then
215 mdw_cv_prog_perl="$p/perl"
216 break
217 fi
218 if mdw__PERL_VERSION(["$p/perl5"], $1); then
219 mdw_cv_prog_perl="$p/perl5"
220 break
221 fi
222done])
223PERL="$mdw_cv_prog_perl"])
224fi
225
226AC_SUBST(PERL)dnl
227if test "$PERL" = "none"; then :
228 $3
229else :
230 $2
231fi])
232
233dnl --- *@-mdw_CHECK_PERL-@* ---
234dnl
235dnl Author: Mark Wooding
236dnl
237dnl Synopsis: mdw_CHECK_PERL(VERSION)
238dnl
239dnl Arguments: VERSION = version number of Perl required
240dnl
241dnl Use: Verifies that the Perl interpreter in the `PERL' shell
242dnl variable actually works and is of the right version. If it's
243dnl not, an error is raised and configuration is aborted.
244
5656743c 245AC_DEFUN([mdw_CHECK_PERL],
b91e2391 246[mdw_REQUIRE([mdw_PROG_PERL], [$1])
247AC_MSG_CHECKING([whether Perl ($PERL) works])
248if test "$PERL" != "none" && mdw__PERL_VERSION("$PERL", $1); then
249 AC_MSG_RESULT([yes])
250else
251 AC_MSG_RESULT([no])
252 AC_MSG_ERROR([Perl version $1 or newer not found.
253If you have a recent enough Perl, and I just failed to find it, try using
254the --with-perl=PERL option to give me an explicit pathname.])
255fi])
256
257dnl --- *@-mdw_PERLLIB_CHECK-@* ---
258dnl
259dnl Author: Mark Wooding
260dnl
261dnl Synopsis: mdw_PERLLIB_CHECK(LIBRARY)
262dnl
263dnl Arguments: LIBRARY = name of a Perl library to check for
264dnl
265dnl Use: Ensures that a Perl script can `use LIBRARY;'. If it can,
266dnl all's well and good; if it can't, `LIBRARY.pm' is added to
267dnl the variable `NEEDED_PERLLIBS' and a line which adds
268dnl `pkgdatadir' to Perl's `@INC' array is placed in the
269dnl variable `INC_PERLLIBS'; `AC_SUBST' is called for both of
270dnl these variables. It's expected that `NEEDED_PERLLIBS' will
271dnl be used in the `Makefile.in' to decide which versions from
272dnl the distribution need installing.
273dnl
274dnl This macro isn't terribly useful in the general case. It
275dnl Also implicitly assumes that `$PERL' is Perl 5 or later.
276
5656743c 277AC_DEFUN([mdw__PERLLIB_INIT],
b91e2391 278[AC_SUBST(INC_PERLLIBS)dnl
279AC_SUBST(NEEDED_PERLLIBS)dnl
280])
281
5656743c 282AC_DEFUN([mdw_PERLLIB_CHECK],
b91e2391 283[AC_REQUIRE([mdw__PERLLIB_INIT])
284mdw_REQUIRE([mdw_CHECK_PERL], 5)
285AC_CACHE_CHECK([for Perl library $1], mdw_cv_perllib_$1,
286[if $PERL -e 'use $1;' >&5 2>&5; then
287 mdw_cv_perllib_$1="yes"
288else
289 mdw_cv_perllib_$1="no"
290fi])
291
292if test "$mdw_cv_perllib_$1" = "no"; then
293 NEEDED_PERLLIBS="$NEEDED_PERLLIBS $1.pm"
294
295 # --- Deal with autoconf lossage ---
296 #
297 # It doesn't want to define `prefix' until rather later on, so I have
298 # to bodge it here.
299
300 if test -z "$INC_PERLLIBS"; then
301 mdw_old_prefix="$prefix"
302 test "$prefix" = "NONE" && prefix="$ac_default_prefix";
303 INC_PERLLIBS="BEGIN { push @INC, \"`eval echo $datadir/$PACKAGE`\"; }"
304 prefix="$mdw_old_prefix";
305 fi
306fi])
307
308dnl --- *@-mdw_GCC_FLAGS-@* ---
309dnl
310dnl Author: Mark Wooding
311dnl
312dnl Synopsis: mdw_GCC_FLAGS([FLAGS], [CFLAGS], [C++FLAGS])
313dnl
314dnl Arguments: FLAGS = GCC compiler flags to add (default is
315dnl `-pedantic -Wall')
316dnl CFLAGS = GCC C compiler flags to add (default is empty)
317dnl C++FLAGS = GCC C++ compiler flags to add (default is
318dnl `-fhandle-exceptions').
319dnl
320dnl Use: If the C compiler is GCC, add the compiler flags.
321
5656743c 322AC_DEFUN([mdw_GCC_FLAGS],
b91e2391 323[if test "$GCC" = "yes"; then
324 CFLAGS="$CFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
325 CFLAGS="$CFLAGS ifelse([$2], [], [], [$2])"
326fi
327if test "$GXX" = "yes"; then
328 CXXFLAGS="$CXXFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
329 CXXFLAGS="$CXXFLAGS ifelse([$3], [], [-fhandle-exceptions], [$3])"
330fi])
331
a7855629 332dnl --- *@-mdw_INIT_LIB-@* ---
17fc60ae 333dnl
334dnl Author: Mark Wooding
335dnl
08f6362d 336dnl Synopsis: mdw_INIT_LIB(LIB, NAME, VERSION, [PACKAGE])
17fc60ae 337dnl
08f6362d 338dnl Arguments: LIB = the name of the library (and the package)
339dnl NAME = a presentable version of the library's name
340dnl VERSION = version of the library
341dnl PACKAGE = package name to pass on to AM_INIT_AUTOMAKE
342dnl
343dnl Use: Sets up various useful variables. This macro calls
344dnl AM_INIT_AUTOMAKE, which might be considered useful. It also
345dnl provides variables for the use of `lib-config.in'.
346
347AC_DEFUN([mdw_INIT_LIB],
348[AM_INIT_AUTOMAKE(ifelse([$4], [], [$1], [$4]), [$3])
349LIBRARY="$1" AC_SUBST(LIBRARY)
350LIBNAME="$2" AC_SUBST(LIBNAME)])
351
a7855629 352dnl --- *@-mdw_LIB_CONFIG-@* ---
08f6362d 353dnl
354dnl Author: Mark Wooding
355dnl
356dnl Synopsis: mdw_LIB_CONFIG(LIB, NAME, VERSION, IF-FOUND, IF-NOT-FOUND)
357dnl
358dnl Arguments: LIB = the name of the library (and its configuration program)
359dnl NAME = a presentable version of the library's name
360dnl VERSION = version of library required
17fc60ae 361dnl IF-FOUND = what to do if found
362dnl IF-NOT-FOUND = what to do if not found
363dnl
08f6362d 364dnl Use: Configures a library client program, using a configuration
365dnl script provided by the library maintainer.
366dnl
367dnl The default version is 1.0.0pre0; the default action is to
368dnl add everything to the CFLAGS and LIBS variables, and complain
17fc60ae 369dnl if the library couldn't be found.
370dnl
08f6362d 371dnl The variable LIB_VERSION contains the version number of
372dnl the library; LIB_CFLAGS is the C compiler flags required
373dnl and LIB_LIBS is the linker flags.
374
375AC_DEFUN([mdw_LIB_CONFIG],
376[pushdef([upname], translit([$1], [a-z], [A-Z]))dnl
377AC_MSG_CHECKING([for $2 library])
378if $1-config --check $3 >/dev/null 2>&1; then
379 upname[]_VERSION=`$1-config --version`
380 upname[]_CFLAGS=`$1-config --cflags`
381 upname[]_LIBS=`$1-config --libs`
382 AC_SUBST(upname[]_VERSION)
383 AC_SUBST(upname[]_CFLAGS)
384 AC_SUBST(upname[]_LIBS)
385 ifelse([$4], [],
386 [CFLAGS="$CFLAGS $upname[]_CFLAGS"
387 LIBS="$upname[]_LIBS $LIBS"],
388 $4)
389 AC_MSG_RESULT([$upname[]_VERSION])
17fc60ae 390else
08f6362d 391 ifelse([$5], [],
392 AC_MSG_ERROR([$2 library not found or too old.]),
393 $5)
17fc60ae 394 AC_MSG_RESULT([not found])
191b8aaf 395fi
396popdef([upname])])
17fc60ae 397
a7855629 398dnl --- *@-mdw_MLIB-@* ---
5a27eb4e 399dnl
400dnl Author: Mark Wooding
401dnl
08f6362d 402dnl Synopsis: mdw_MLIB(VERSION, IF-FOUND, IF-NOT-FOUND
5a27eb4e 403dnl
404dnl Arguments: VERSION = version of library required
405dnl IF-FOUND = what to do if found
406dnl IF-NOT-FOUND = what to do if not found
407dnl
08f6362d 408dnl Use: Configures an mLib client program.
5a27eb4e 409
08f6362d 410AC_DEFUN([mdw_MLIB], [mdw_LIB_CONFIG(mLib, mLib, $@)])
5a27eb4e 411
a7855629 412dnl --- *@-mdw_MGLIB-@* ---
5ba1b8b8 413dnl
414dnl Author: Mark Wooding
415dnl
08f6362d 416dnl Synopsis: mdw_MGLIB(VERSION, IF-FOUND, IF-NOT-FOUND
5ba1b8b8 417dnl
418dnl Arguments: VERSION = version of library required
419dnl IF-FOUND = what to do if found
420dnl IF-NOT-FOUND = what to do if not found
421dnl
08f6362d 422dnl Use: Configures an mgLib client program.
423
424AC_DEFUN([mdw_MGLIB],
425[mdw_REQUIRE([mdw_MLIB], [1.6.0])
426mdw_LIB_CONFIG(mgLib, mgLib, $@)])
5ba1b8b8 427
a7855629 428dnl --- *@-mdw_CATACOMB-@* ---
17fc60ae 429dnl
430dnl Author: Mark Wooding
431dnl
432dnl Synopsis: mdw_CATACOMB([VERSION], [IF-FOUND], [IF-NOT-FOUND])
433dnl
434dnl Arguments: VERSION = version of Catacomb required
435dnl IF-FOUND = what to do if found
436dnl IF-NOT-FOUND = what to do if not found
437dnl
08f6362d 438dnl Use: Configures the program as a Catacomb client.
17fc60ae 439
440AC_DEFUN([mdw_CATACOMB],
5a27eb4e 441[mdw_REQUIRE([mdw_MLIB], [1.6.0])
08f6362d 442mdw_LIB_CONFIG(catacomb, Catacomb, $@)])
443
a7855629 444dnl --- *@-mdw_PK-@* ---
08f6362d 445dnl
446dnl Author: Mark Wooding
447dnl
448dnl Synopsis: mdw_PK([VERSION], [IF-FOUND], [IF-NOT-FOUND])
449dnl
450dnl Arguments: VERSION = version of PK required
451dnl IF-FOUND = what to do if found
452dnl IF-NOT-FOUND = what to do if not found
453dnl
454dnl Use: Configures the program as a PK client.
455
456AC_DEFUN([mdw_PK],
457[mdw_REQUIRE([mdw_MLIB], [1.6.0])
458mdw_LIB_CONFIG(pk, PK, $@)])
17fc60ae 459
b91e2391 460dnl --- *@-mdw_OPT_NDEBUG-@* ---
461dnl
462dnl Author: Mark Wooding
463dnl
464dnl Synopsis: mdw_OPT_NDEBUG
465dnl
466dnl Arguments: ---
467dnl
7a1aef7d 468dnl Use: Turns on the `NDEBUG' flag, to disable useful things like
469dnl assertions.
b91e2391 470
5656743c 471AC_DEFUN([mdw_OPT_NDEBUG],
b91e2391 472[AC_ARG_ENABLE(debugging,
7a1aef7d 473[ --disable-debugging spews vast swathes of useless information],
b91e2391 474[if test "$enableval" = "no"; then
475 AC_DEFINE(NDEBUG, 1)
7a1aef7d 476fi])])
b91e2391 477
478dnl --- *@-mdw_OPT_EFENCE-@* ---
479dnl
480dnl Author: Mark Wooding
481dnl
482dnl Synopsis: mdw_OPT_EFENCE
483dnl
484dnl Arguments: ---
485dnl
486dnl Use: Links with the Electric Fence library.
487
5656743c 488AC_DEFUN([mdw_OPT_EFENCE],
b91e2391 489[AC_ARG_WITH(electric-fence,
490[ --with-electric-fence link programs with Electric Fence],
491[if test "$withval" = "yes"; then
492 AC_CHECK_LIB(efence, malloc)
493fi])])
494
7a1aef7d 495dnl --- *@-mdw_OPT_TRACE-@* ---
b91e2391 496dnl
497dnl Author: Mark Wooding
498dnl
7a1aef7d 499dnl Synopsis: mdw_OPT_TRACE
b91e2391 500dnl
501dnl Arguments: ---
502dnl
7a1aef7d 503dnl Use: Turns on the `NTRACE' flag, to disable useful things like
504dnl trace outputs.
505
5656743c 506AC_DEFUN([mdw_OPT_TRACE],
7a1aef7d 507[AC_ARG_ENABLE(tracing,
508[ --disable-tracing disable output of trace information],
509[if test "$enableval" = "no"; then
510 AC_DEFINE(NTRACE, 1)
511fi])])
512
513dnl --- *@-mdw_OPT_mLib_TRACK-@* ---
514dnl
515dnl Author: Mark Wooding
516dnl
517dnl Synopsis: mdw_OPT_mLib_TRACK(PROGRAM)
518dnl
519dnl Arguments: PROGRAM = name of this program or package.
520dnl
521dnl Use: Controls the unsupported mLib memory tracker. The
b91e2391 522dnl following are defined:
523dnl
b91e2391 524dnl --enable-track turns on malloc tracking
525dnl --enable-blame-PROGRAM tracks malloc contexts in PROGRAM
526dnl
7a1aef7d 527dnl There must be a separate `blame' option for each program,
528dnl so that the various blame options in a hierarchy get
529dnl propagated properly. This is an obsolete feature from the
530dnl days when mLib was provided as a subdirectory of other
531dnl packages.
b91e2391 532
5656743c 533AC_DEFUN([mdw_OPT_mLib_TRACK],
7a1aef7d 534[AC_REQUIRE([mdw_OPT_TRACE])
b91e2391 535AC_ARG_ENABLE(track,
536[ --enable-track enable tracking of malloc and free],
537[AC_DEFINE(TRACK_ENABLE, 1)])
b91e2391 538AC_ARG_ENABLE(blame-$1,
539[ --enable-blame-$1
540 track malloc contexts while in $1],
541[AC_DEFINE(TRACK_BLAME, 1)])])
542
7a1aef7d 543dnl --- *@-mdw_OPT_mLib_DEBUG-@* ---
544dnl
545dnl Author: Mark Wooding
546dnl
547dnl Synopsis: mdw_OPT_mLib_DEBUG(PROGRAM)
548dnl
549dnl Arguments: PROGRAM = name of this program or package.
550dnl
551dnl Use: Provides all of the above debugging options.
552
5656743c 553AC_DEFUN([mdw_OPT_mLib_DEBUG],
7a1aef7d 554[mdw_REQUIRE([mdw_OPT_NDEBUG])
555mdw_REQUIRE([mdw_OPT_mLib_TRACK], [$1])])
556
5656743c 557dnl --- *@-mdw_DEFINE_PATHS-@*
558dnl
559dnl Author: Mark Wooding
560dnl
c601ddb3 561dnl Synopsis: mdw_DEFINE_FILES(CODE)
5656743c 562dnl
563dnl Arguments: CODE = shell script code to execute
564dnl
565dnl Use: Fixes up various variables so that pathname defines can be
566dnl defined. Within CODE, you may use the following macros:
567dnl
568dnl mdw_PROG(NAME) Transformed program name
569dnl
570dnl mdw_PATH(PATH) Expanded path (may contain variables)
571dnl
572dnl mdw_DEFINE_PROG(SYMBOL, PROG)
573dnl Define a symbol as a transformed
574dnl program name.
575dnl
576dnl mdw_DEFINE_PATH(SYMBOL, NAME)
577dnl Define a symbol as an expanded path
578
579AC_DEFUN([mdw_DEFINE_PATHS],
580[mdw_prefix=$prefix mdw_exec_prefix=$exec_prefix
581mdw_transform=`echo "$program_transform_name"|sed 's,\\\\\\\\,\\\\,g; s,\\$\\$,$,g'`
582test "$prefix" = "NONE" && prefix=$ac_default_prefix
583test "$exec_prefix" = "NONE" && exec_prefix=$prefix
584$1
585prefix=$mdw_prefix exec_prefix=$mdw_exec_prefix])
586
587AC_DEFUN([mdw_PROG], [`echo "$1"|sed "$mdw_transform"`])
588AC_DEFUN([mdw_PATH], [dnl
589`t="$1"; dnl
590while :; do dnl
591case "$t" in dnl
592*\\$[]*) t=\`eval echo "$t"\`;; dnl
593*) break;; dnl
594esac; done; dnl
595echo "$t"`])
596AC_DEFUN([mdw_DEFINE_PROG], [AC_DEFINE_UNQUOTED([$1], ["mdw_PROG([$2])"])])
597AC_DEFUN([mdw_DEFINE_PATH], [AC_DEFINE_UNQUOTED([$1], ["mdw_PATH([$2])"])])
598
c601ddb3 599dnl --- *@-mdw_DIR_TEXMF-@* ---
600dnl
601dnl Author: Mark Wooding
602dnl
603dnl Synopsis: mdw_DIR_TEXMF
604dnl
605dnl Arguments: ---
606dnl
607dnl Use: Sets the substitution `texmfdir' as a sensible TeX install
608dnl tree.
609
610AC_DEFUN([mdw_DIR_TEXMF], [
611AC_ARG_WITH([texmfdir],
612[ --with-texmfdir=DIR set the TeX install directory to DIR],
0494ba14 613[texmfdir=$withval],
c601ddb3 614[AC_MSG_CHECKING([where to put installed TeX files])
615mdw_DEFINE_PATHS([
616texmfdir='${datadir}/texmf'
617for d in \
618 '${datadir}/texmf' '${prefix}/lib/texmf' \
619 '${prefix}/texmf' '${libdir}/lib/texmf'; do
620 if test -d "mdw_PATH([$d])"; then
621 texmfdir=$d
622 break
623 fi
624done
625AC_MSG_RESULT([$texmfdir])])])
626AC_SUBST(texmfdir)])
627
0494ba14 628dnl --- *@-mdw_MANEXT-@* ---
629dnl
630dnl Author: Mark Wooding
631dnl
632dnl Synopsis: mdw_MANEXT
633dnl
634dnl Arguments: ---
635dnl
636dnl Use: Sets the substitution `manext' for man page extensions.
637
638AC_DEFUN([mdw_MANEXT], [
639AC_ARG_WITH([man-ext],
640[ --with-man-ext=EXT give manpages the EXT extension (e.g., foo.3EXT)],
641[manext=$withval], [manext=mLib])
642AC_SUBST(manext)])
643
b91e2391 644dnl----- That's all, folks --------------------------------- *@--GLOB-END--@*