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