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