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