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