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