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