And support for MXD (not yet released).
[cfd] / aclocal.glob
1 dnl -*-fundamental-*- *@--GLOB-HEADER--@*
2 dnl
3 dnl $Id: aclocal.glob,v 1.8 1999/11/26 01:23:17 mdw Exp $
4 dnl
5 dnl Common library of autoconf macros
6 dnl
7 dnl (c) 1997 Mark Wooding, except for macros and documentation where noted.
8 dnl
9
10 dnl----- Licensing notice ---------------------------------------------------
11 dnl
12 dnl This file is part of the Common Files Distribution (`common')
13 dnl
14 dnl `Common' is free software; you can redistribute it and/or modify
15 dnl it under the terms of the GNU General Public License as published by
16 dnl the Free Software Foundation; either version 2 of the License, or
17 dnl (at your option) any later version.
18 dnl
19 dnl `Common' is distributed in the hope that it will be useful,
20 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
21 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 dnl GNU General Public License for more details.
23 dnl
24 dnl You should have received a copy of the GNU General Public License
25 dnl along with `common'; if not, write to the Free Software Foundation,
26 dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
28 dnl----- Revision history ---------------------------------------------------
29 dnl
30 dnl $Log: aclocal.glob,v $
31 dnl Revision 1.8 1999/11/26 01:23:17 mdw
32 dnl And support for MXD (not yet released).
33 dnl
34 dnl Revision 1.7 1999/11/11 20:03:58 mdw
35 dnl Add support for mgLib too.
36 dnl
37 dnl Revision 1.6 1999/11/11 17:49:33 mdw
38 dnl New macros for configuring clients of mLib and Catacomb.
39 dnl
40 dnl Revision 1.5 1999/07/27 18:27:37 mdw
41 dnl Fix typo in header line for mdw_DECL_ENVIRON.
42 dnl
43 dnl Revision 1.4 1999/07/26 23:44:32 mdw
44 dnl Reorder and tidy documentation.
45 dnl
46 dnl Revision 1.3 1999/07/17 10:27:44 mdw
47 dnl More useful macros added.
48 dnl
49 dnl Revision 1.2 1999/05/13 22:57:23 mdw
50 dnl Change `-ise' to `-ize' throughout.
51 dnl
52 dnl Revision 1.1.1.1 1999/05/05 19:23:47 mdw
53 dnl New import. The old CVS repository was lost in a disk disaster.
54 dnl
55
56 dnl----- Common files distribution --------------------------- *@--NOTICE--@*
57 dnl
58 dnl $Id: aclocal.glob,v 1.8 1999/11/26 01:23:17 mdw Exp $
59
60 dnl --- *@-AC_PROG_CC_STDC-@* ---
61 dnl
62 dnl Author: Franc,ois Pinard
63 dnl
64 dnl Synopsis: AC_PROG_CC_STDC
65 dnl
66 dnl Arguments: ---
67 dnl
68 dnl Use: If the C compiler in not in ANSI C mode by default, try to
69 dnl add an option to output variable `CC' to make it so. This
70 dnl macro tries various options that select ANSI C on some system
71 dnl or another. It considers the compiler to be in ANSI C mode
72 dnl if it defines `__STDC__' to 1 and handles function prototypes
73 dnl correctly.
74 dnl
75 dnl If you use this macro, you should check after calling it
76 dnl whether the C compiler has been set to accept ANSI C; if not,
77 dnl the shell variable `ac_cv_prog_cc_stdc' is set to `no'. If
78 dnl you wrote your source code in ANSI C, you can make an
79 dnl un-ANSIfied copy of it by using the program `ansi2knr', which
80 dnl comes with Ghostscript.
81 dnl
82 dnl (documentation by Franc,ois Pinard)
83
84 AC_DEFUN(AM_PROG_CC_STDC,
85 [AC_REQUIRE([AC_PROG_CC])
86 AC_BEFORE([$0], [AC_C_INLINE])
87 AC_BEFORE([$0], [AC_C_CONST])
88 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
89 AC_CACHE_VAL(am_cv_prog_cc_stdc,
90 [am_cv_prog_cc_stdc=no
91 ac_save_CC="$CC"
92 # Don't try gcc -ansi; that turns off useful extensions and
93 # breaks some systems' header files.
94 # AIX -qlanglvl=ansi
95 # Ultrix and OSF/1 -std1
96 # HP-UX -Aa -D_HPUX_SOURCE
97 # SVR4 -Xc -D__EXTENSIONS__
98 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
99 do
100 CC="$ac_save_CC $ac_arg"
101 AC_TRY_COMPILE(
102 [#if !defined(__STDC__) || __STDC__ != 1
103 choke me
104 #endif
105 /* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
106 #ifdef _SEQUENT_
107 # include <sys/types.h>
108 # include <sys/stat.h>
109 #endif
110 ], [
111 int test (int i, double x);
112 struct s1 {int (*f) (int a);};
113 struct s2 {int (*f) (double a);};],
114 [am_cv_prog_cc_stdc="$ac_arg"; break])
115 done
116 CC="$ac_save_CC"
117 ])
118 if test -z "$am_cv_prog_cc_stdc"; then
119 AC_MSG_RESULT([none needed])
120 else
121 AC_MSG_RESULT($am_cv_prog_cc_stdc)
122 fi
123 case "x$am_cv_prog_cc_stdc" in
124 x|xno) ;;
125 *) CC="$CC $am_cv_prog_cc_stdc" ;;
126 esac
127 ])
128
129 dnl----- AutoMake macros ------------------------------------- *@--IGNORE--@*
130
131 dnl --- *@-AM_CONDITIONAL-@* ---
132 dnl
133 dnl Author: Unknown
134 dnl
135 dnl Synopsis: AM_CONDITIONAL(NAME, TEST)
136 dnl
137 dnl Arguments: NAME = name of the conditional
138 dnl TEST = a shell list to execute
139 dnl
140 dnl Use: Allows conditional sections in Makefiles.
141
142 AC_DEFUN(AM_CONDITIONAL,
143 [AC_SUBST($1_TRUE)
144 AC_SUBST($1_FALSE)
145 if $2; then
146 $1_TRUE=
147 $1_FALSE='#'
148 else
149 $1_TRUE='#'
150 $1_FALSE=
151 fi])
152
153 dnl --- *@-AM_CYGWIN32-@* ---
154 dnl
155 dnl Author: Cygnus (I guess)
156 dnl
157 dnl Synopsis: AM_CYGWIN32
158 dnl
159 dnl Arguments: ---
160 dnl
161 dnl Use: Check to see if we're running under Cygwin32, without using
162 dnl AC_CANONICAL_*. If so, set output variable EXEEXT to
163 dnl ".exe". Otherwise set it to "".
164
165 dnl AM_CYGWIN32()
166 dnl You might think we can do this by checking for a cygwin32-specific
167 dnl cpp define. We can't, because cross-compilers that target
168 dnl cygwin32 don't use the .exe suffix. I don't know why.
169 AC_DEFUN(AM_CYGWIN32,
170 [AC_CACHE_CHECK(for Cygwin32 environment, am_cv_cygwin32,
171 [cat > conftest.$ac_ext << 'EOF'
172 int main () {
173 /* Nothing. */
174 return 0; }
175 EOF
176 if AC_TRY_EVAL(ac_link) && test -s conftest.exe; then
177 am_cv_cygwin32=yes
178 else
179 am_cv_cygwin32=no
180 fi
181 rm -f conftest*])
182 EXEEXT=
183 test "$am_cv_cygwin32" = yes && EXEEXT=.exe
184 AC_SUBST(EXEEXT)])
185
186 dnl --- *@-AM_WITH_DMALLOC-@* ---
187 dnl
188 dnl Author: Franc,ois Pinard
189 dnl
190 dnl Synopsis: AM_WITH_DMALLOC
191 dnl
192 dnl Arguments: ---
193 dnl
194 dnl Use: Links with `-dmalloc' if told to by the user.
195
196 ## ----------------------------------- ##
197 ## Check if --with-dmalloc was given. ##
198 ## From Franc,ois Pinard ##
199 ## ----------------------------------- ##
200
201 # serial 1
202
203 AC_DEFUN(AM_WITH_DMALLOC,
204 [AC_MSG_CHECKING(if malloc debugging is wanted)
205 AC_ARG_WITH(dmalloc,
206 [ --with-dmalloc use dmalloc, as in
207 ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz],
208 [if test "$withval" = yes; then
209 AC_MSG_RESULT(yes)
210 AC_DEFINE(WITH_DMALLOC)
211 LIBS="$LIBS -ldmalloc"
212 LDFLAGS="$LDFLAGS -g"
213 else
214 AC_MSG_RESULT(no)
215 fi], [AC_MSG_RESULT(no)])
216 ])
217
218 dnl --- *@-AM_FUNC_ERROR_AT_LINE-@* ---
219 dnl
220 dnl Author: Jim Meyering
221 dnl
222 dnl Synopsis: AM_FUNC_ERROR_AT_LINE
223 dnl
224 dnl Arguments: ---
225 dnl
226 dnl Use: Use this if you use the GNU error.[ch].
227
228 dnl FIXME: Migrate into libit
229
230 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
231 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
232 [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
233 am_cv_lib_error_at_line=yes,
234 am_cv_lib_error_at_line=no)])
235 if test $am_cv_lib_error_at_line = no; then
236 LIBOBJS="$LIBOBJS error.o"
237 fi
238 AC_SUBST(LIBOBJS)dnl
239 ])
240
241 dnl --- *@-AM_INIT_GUILE_MODULE-@* ---
242 dnl
243 dnl Author: Unknown
244 dnl
245 dnl Synopsis: AM_INIT_GUILE_MODULE(MODNAME)
246 dnl
247 dnl Arguments: MODNAME = value to initialize `module' variable with
248 dnl
249 dnl Use: This macro will automatically get the guile version from the
250 dnl top-level srcdir, and will initialize automake. It also
251 dnl defines the `module' variable.
252
253 AC_DEFUN([AM_INIT_GUILE_MODULE],[
254 . $srcdir/../GUILE-VERSION
255 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
256 AC_CONFIG_AUX_DIR(..)
257 module=[$1]
258 AC_SUBST(module)])
259
260 dnl --- *@-AM_CONFIG_HEADER-@* ---
261 dnl
262 dnl Author: Unknown
263 dnl
264 dnl Synopsis: AM_CONFIG_HEADER(HEADER ...)
265 dnl
266 dnl Arguments: HEADER = a header spec, as for AC_CONFIG_HEADER
267 dnl
268 dnl Use: Like AC_CONFIG_HEADER, but automatically create stamp file.
269
270 AC_DEFUN(AM_CONFIG_HEADER,
271 [AC_PREREQ([2.12])
272 AC_CONFIG_HEADER([$1])
273 dnl When config.status generates a header, we must update the stamp-h file.
274 dnl This file resides in the same directory as the config header
275 dnl that is generated. We must strip everything past the first ":",
276 dnl and everything past the last "/".
277 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
278 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
279 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/
280 \)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
281 <<am_indx=1
282 for am_file in <<$1>>; do
283 case " <<$>>CONFIG_HEADERS " in
284 *" <<$>>am_file "*<<)>>
285 echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
286 ;;
287 esac
288 am_indx=`expr "<<$>>am_indx" + 1`
289 done<<>>dnl>>)
290 changequote([,]))])
291
292 dnl --- *@-AM_INIT_AUTOMAKE-@*
293 dnl
294 dnl Author: Unknown
295 dnl
296 dnl Synopsis: AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
297 dnl
298 dnl Arguments: PACKAGE = package name
299 dnl VERSION = version number
300 dnl NO-DEFINE = if set, don't define package and version number
301 dnl
302 dnl Use: Do all the work for Automake. This macro actually does too
303 dnl much -- some checks are only needed if your package does
304 dnl certain things. But this isn't really a big deal.
305
306 # serial 1
307
308 AC_DEFUN(AM_INIT_AUTOMAKE,
309 [AC_REQUIRE([AM_PROG_INSTALL])
310 PACKAGE=[$1]
311 AC_SUBST(PACKAGE)
312 VERSION=[$2]
313 AC_SUBST(VERSION)
314 dnl test to see if srcdir already configured
315 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
316 AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
317 fi
318 ifelse([$3],,
319 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
320 AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
321 AM_SANITY_CHECK
322 AC_ARG_PROGRAM
323 dnl FIXME This is truly gross.
324 missing_dir=`cd $ac_aux_dir && pwd`
325 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
326 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
327 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
328 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
329 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
330 AC_PROG_MAKE_SET])
331
332 dnl --- *@-AM_PROG_INSTALL-@* ---
333 dnl
334 dnl Author: Franc,ois Pinard
335 dnl
336 dnl Synopsis: AM_PROG_INSTALL
337 dnl
338 dnl Arguments: ---
339 dnl
340 dnl Use: Calls `AC_PROG_INSTALL' to find an installer. Then it sets
341 dnl `INSTALL_SCRIPT' to a suitable value if necessary.
342
343 # serial 1
344
345 AC_DEFUN(AM_PROG_INSTALL,
346 [AC_PROG_INSTALL
347 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL} -m 755'
348 AC_SUBST(INSTALL_SCRIPT)dnl
349 ])
350
351 dnl --- *@-AM_PROG_LEX-@* ---
352 dnl
353 dnl Author: Alexandre Oliva
354 dnl
355 dnl Synopsis: AM_PROG_LEX
356 dnl
357 dnl Arguments: ---
358 dnl
359 dnl Use: Replacement for AC_PROG_LEX and AC_DECL_YYTEXT
360
361 dnl AM_PROG_LEX
362 dnl Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT
363 AC_DEFUN(AM_PROG_LEX,
364 [missing_dir=ifelse([$1],,`cd $ac_aux_dir && pwd`,$1)
365 AC_CHECK_PROGS(LEX, flex lex, "$missing_dir/missing flex")
366 AC_PROG_LEX
367 AC_DECL_YYTEXT])
368
369 dnl --- *@-AM_PROG_LIBTOOL-@* ---
370 dnl
371 dnl Author: Unknown
372 dnl
373 dnl Synopsis: AM_PROG_LIBTOOL
374 dnl
375 dnl Arguments: ---
376 dnl
377 dnl Use: Configures `libtool' for the target architecture.
378
379 ##
380 ## Configure libtool for the target system.
381 ##
382 # serial 1 AM_PROG_LIBTOOL
383 AC_DEFUN(AM_PROG_LIBTOOL,
384 [AC_REQUIRE([AC_CANONICAL_HOST])
385 AC_REQUIRE([AC_PROG_CC])
386 AC_REQUIRE([AC_PROG_RANLIB])
387
388 # Always use our own libtool.
389 LIBTOOL='$(top_builddir)/libtool'
390 AC_SUBST(LIBTOOL)
391
392 dnl Allow the --disable-shared flag to stop us from building shared libs.
393 AC_ARG_ENABLE(shared,
394 [ --enable-shared build shared libraries [default=yes]],
395 test "$enableval" = no && libtool_shared=" --disable-shared",
396 libtool_shared=)
397
398 libtool_flags="$libtool_shared"
399 test "$silent" = yes && libtool_flags="$libtool_flags --silent"
400 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
401
402 # Actually configure libtool. ac_aux_dir is where install-sh is found.
403 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LD="$LD" RANLIB="$RANLIB" \
404 $ac_aux_dir/ltconfig $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
405 || AC_MSG_ERROR([libtool configure failed])
406 ])
407
408 dnl --- *@-AM_PATH_LISPDIR-@* ---
409 dnl
410 dnl Author: Ulrich Drepper
411 dnl
412 dnl Synopsis: AM_PATH_LISPDIR
413 dnl
414 dnl Arguments: ---
415 dnl
416 dnl Use: Sets the variable `lispdir' to point to a place to install
417 dnl Emacs lisp files.
418
419 ## ------------------------
420 ## Emacs LISP file handling
421 ## From Ulrich Drepper
422 ## ------------------------
423
424 # serial 1
425
426 AC_DEFUN(AM_PATH_LISPDIR,
427 [# If set to t, that means we are running in a shell under Emacs.
428 # If you have an Emacs named "t", then use the full path.
429 test "$EMACS" = t && EMACS=
430 AC_PATH_PROG(EMACS, emacs xemacs, no)
431 if test $EMACS != "no"; then
432 AC_MSG_CHECKING([where .elc files should go])
433 dnl Set default value
434 lispdir="\$(datadir)/emacs/site-lisp"
435 if test "x$prefix" = "xNONE"; then
436 if test -d $ac_default_prefix/share/emacs/site-lisp; then
437 lispdir="\$(prefix)/share/emacs/site-lisp"
438 else
439 if test -d $ac_default_prefix/lib/emacs/site-lisp; then
440 lispdir="\$(prefix)/lib/emacs/site-lisp"
441 fi
442 fi
443 else
444 if test -d $prefix/share/emacs/site-lisp; then
445 lispdir="\$(prefix)/share/emacs/site-lisp"
446 else
447 if test -d $prefix/lib/emacs/site-lisp; then
448 lispdir="\$(prefix)/lib/emacs/site-lisp"
449 fi
450 fi
451 fi
452 AC_MSG_RESULT($lispdir)
453 fi
454 AC_SUBST(lispdir)])
455
456 dnl --- *@-AM_MAINTAINTER_MODE-@* ---
457 dnl
458 dnl Author: Jim Meyering
459 dnl
460 dnl Synopsis: jm_MAINTAINER_MODE
461 dnl
462 dnl Arguments: ---
463 dnl
464 dnl Use: Provides an option `--enable-maintainer-mode' which turns
465 dnl on rules which might normally be commented out. The
466 dnl substitution variable `MAINT' is set to be a comment when
467 dnl this option is disabled, which it is by default.
468
469 # serial 1
470
471 AC_DEFUN(AM_MAINTAINER_MODE,
472 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
473 dnl maintainer-mode is disabled by default
474 AC_ARG_ENABLE(maintainer-mode,
475 [ --enable-maintainer-mode enable make rules and dependencies not useful
476 (and sometimes confusing) to the casual installer],
477 USE_MAINTAINER_MODE=$enableval,
478 USE_MAINTAINER_MODE=no)
479 AC_MSG_RESULT($USE_MAINTAINER_MODE)
480 if test $USE_MAINTAINER_MODE = yes; then
481 MAINT=
482 else
483 MAINT='#M#'
484 fi
485 AC_SUBST(MAINT)dnl
486 ]
487 )
488
489 dnl --- *@-AM_MISSING_PROG-@* ---
490 dnl
491 dnl Author: Unknown
492 dnl
493 dnl Synopsis: AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
494 dnl
495 dnl Arguments: NAME = variable to set to the file's location
496 dnl PROGRAM = name of program to find
497 dnl DIRECTORY = directory to look in
498 dnl
499 dnl Use: Fakes existence of a useful GNU maintainer tool.
500
501 AC_DEFUN(AM_MISSING_PROG,
502 [AC_MSG_CHECKING(for working $2)
503 # Run test in a subshell; some versions of sh will print an error if
504 # an executable is not found, even if stderr is redirected.
505 # Redirect stdin to placate older versions of autoconf. Sigh.
506 if ($2 --version) < /dev/null > /dev/null 2>&1; then
507 $1=$2
508 AC_MSG_RESULT(found)
509 else
510 $1="$3/missing $2"
511 AC_MSG_RESULT(missing)
512 fi
513 AC_SUBST($1)])
514
515 dnl --- *@-AM_FUNC_MKTIME-@* ---
516 dnl
517 dnl Author: Jim Meyering
518 dnl
519 dnl Synopsis: AM_FUNC_MKTIME
520 dnl
521 dnl Arguments: ---
522 dnl
523 dnl Use: Checks for a working mktime function.
524
525 AC_DEFUN(AM_FUNC_MKTIME,
526 [AC_REQUIRE([AC_HEADER_TIME])dnl
527 AC_CHECK_HEADERS(sys/time.h)
528 AC_CACHE_CHECK([for working mktime], am_cv_func_working_mktime,
529 [AC_TRY_RUN(
530 changequote(<<, >>)dnl
531 <</* Test program from Paul Eggert (eggert@twinsun.com)
532 and Tony Leneis (tony@plaza.ds.adp.com). */
533 #if TIME_WITH_SYS_TIME
534 # include <sys/time.h>
535 # include <time.h>
536 #else
537 # if HAVE_SYS_TIME_H
538 # include <sys/time.h>
539 # else
540 # include <time.h>
541 # endif
542 #endif
543
544 static time_t time_t_max;
545
546 /* Values we'll use to set the TZ environment variable. */
547 static const char *const tz_strings[] = {
548 NULL, "GMT0", "JST-9", "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
549 };
550 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
551
552 static void
553 mktime_test (now)
554 time_t now;
555 {
556 if (mktime (localtime (&now)) != now)
557 exit (1);
558 now = time_t_max - now;
559 if (mktime (localtime (&now)) != now)
560 exit (1);
561 }
562
563 int
564 main ()
565 {
566 time_t t, delta;
567 int i;
568
569 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
570 continue;
571 time_t_max--;
572 delta = time_t_max / 997; /* a suitable prime number */
573 for (i = 0; i < N_STRINGS; i++)
574 {
575 if (tz_strings[i])
576 putenv (tz_strings[i]);
577
578 for (t = 0; t <= time_t_max - delta; t += delta)
579 mktime_test (t);
580 mktime_test ((time_t) 60 * 60);
581 mktime_test ((time_t) 60 * 60 * 24);
582 }
583 exit (0);
584 }
585 >>,
586 changequote([, ])dnl
587 am_cv_func_working_mktime=yes, am_cv_func_working_mktime=no,
588 dnl When crosscompiling, assume mktime is missing or broken.
589 am_cv_func_working_mktime=no)
590 ])
591 if test $am_cv_func_working_mktime = no; then
592 LIBOBJS="$LIBOBJS mktime.o"
593 fi
594 ])
595
596 dnl --- *@-AM_FUNC_OBSTACK-@* ---
597 dnl
598 dnl Author: Jim Meyering
599 dnl
600 dnl Synopsis: AM_FUNC_OBSTACK
601 dnl
602 dnl Arguments: ---
603 dnl
604 dnl Use: Checks for GNU obstacks.
605
606 AC_DEFUN(AM_FUNC_OBSTACK,
607 [AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
608 [AC_TRY_LINK([#include "obstack.h"],
609 [struct obstack *mem;obstack_free(mem,(char *) 0)],
610 am_cv_func_obstack=yes,
611 am_cv_func_obstack=no)])
612 if test $am_cv_func_obstack = yes; then
613 AC_DEFINE(HAVE_OBSTACK)
614 else
615 LIBOBJS="$LIBOBJS obstack.o"
616 fi
617 ])
618
619 dnl --- *@-AC_C_PROTOTYPES-@* ---
620 dnl
621 dnl Author: Franc,ois Pinard
622 dnl
623 dnl Synopsis: AC_C_PROTOTYPES
624 dnl
625 dnl Arguments: ---
626 dnl
627 dnl Use: If the C compiler understands ANSI C, define `PROTOTYPES',
628 dnl and clear the `U' and `ANSI2KNR' variables. Otherwise,
629 dnl set `U' to be `_' and `ANSI2KNR' to be `./ansi2knr'.
630
631 # serial 1
632
633 AC_DEFUN(fp_C_PROTOTYPES,
634 [AC_REQUIRE([fp_PROG_CC_STDC])
635 AC_MSG_CHECKING([for function prototypes])
636 if test "$ac_cv_prog_cc_stdc" != no; then
637 AC_MSG_RESULT(yes)
638 AC_DEFINE(PROTOTYPES)
639 U= ANSI2KNR=
640 else
641 AC_MSG_RESULT(no)
642 U=_ ANSI2KNR=./ansi2knr
643 fi
644 AC_SUBST(U)dnl
645 AC_SUBST(ANSI2KNR)dnl
646 ])
647
648 dnl --- *@-AM_PATH_GTK-@* ---
649 dnl
650 dnl Author: Owen Taylor
651 dnl
652 dnl Synopsis: AM_PATH_GTK(MIN-VERSION, [ACTION-IF-FOUND], [ACTION-IF-NOT])
653 dnl
654 dnl Arguments: MIN-VERSION = minimum version of GTK required
655 dnl ACTION-IF-FOUND = executed if GTK found OK
656 dnl ACTION-IF-NOT-FOUND = what to do if GTK not available
657 dnl
658 dnl Use: Sets up compilation environment suitably for GTK programming.
659
660 # Configure paths for GTK+
661 # Owen Taylor 97-11-3
662
663 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
664 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
665 dnl
666 AC_DEFUN(AM_PATH_GTK,
667 [dnl
668 dnl Get the cflags and libraries from the gtk-config script
669 dnl
670 AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
671 gtk_config_prefix="$withval", gtk_config_prefix="")
672 AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
673 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
674 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
675 , enable_gtktest=yes)
676
677 if test x$gtk_config_exec_prefix != x ; then
678 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
679 if test x${GTK_CONFIG+set} != xset ; then
680 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
681 fi
682 fi
683 if test x$gtk_config_prefix != x ; then
684 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
685 if test x${GTK_CONFIG+set} != xset ; then
686 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
687 fi
688 fi
689
690 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
691 min_gtk_version=ifelse([$1], ,0.99.7,$1)
692 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
693 no_gtk=""
694 if test "$GTK_CONFIG" = "no" ; then
695 no_gtk=yes
696 else
697 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
698 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
699 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
700 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
701 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
702 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
703 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
704 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
705 if test "x$enable_gtktest" = "xyes" ; then
706 ac_save_CFLAGS="$CFLAGS"
707 ac_save_LIBS="$LIBS"
708 CFLAGS="$CFLAGS $GTK_CFLAGS"
709 LIBS="$LIBS $GTK_LIBS"
710 dnl
711 dnl Now check if the installed GTK is sufficiently new. (Also sanity
712 dnl checks the results of gtk-config to some extent
713 dnl
714 rm -f conf.gtktest
715 AC_TRY_RUN([
716 #include <gtk/gtk.h>
717 #include <stdio.h>
718
719 int
720 main ()
721 {
722 int major, minor, micro;
723 char *tmp_version;
724
725 system ("touch conf.gtktest");
726
727 /* HP/UX 9 (%@#!) writes to sscanf strings */
728 tmp_version = g_strdup("$min_gtk_version");
729 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
730 printf("%s, bad version string\n", "$min_gtk_version");
731 exit(1);
732 }
733
734 if ((gtk_major_version != $gtk_config_major_version) ||
735 (gtk_minor_version != $gtk_config_minor_version) ||
736 (gtk_micro_version != $gtk_config_micro_version))
737 {
738 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
739 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
740 gtk_major_version, gtk_minor_version, gtk_micro_version);
741 printf ("*** was found! If gtk-config was correct, then it is best\n");
742 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
743 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
744 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
745 printf("*** required on your system.\n");
746 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
747 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
748 printf("*** before re-running configure\n");
749 }
750 else
751 {
752 if ((gtk_major_version > major) ||
753 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
754 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
755 {
756 return 0;
757 }
758 else
759 {
760 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
761 gtk_major_version, gtk_minor_version, gtk_micro_version);
762 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
763 major, minor, micro);
764 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
765 printf("***\n");
766 printf("*** If you have already installed a sufficiently new version, this error\n");
767 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
768 printf("*** being found. The easiest way to fix this is to remove the old version\n");
769 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
770 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
771 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
772 printf("*** so that the correct libraries are found at run-time))\n");
773 }
774 }
775 return 1;
776 }
777 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
778 CFLAGS="$ac_save_CFLAGS"
779 LIBS="$ac_save_LIBS"
780 fi
781 fi
782 if test "x$no_gtk" = x ; then
783 AC_MSG_RESULT(yes)
784 ifelse([$2], , :, [$2])
785 else
786 AC_MSG_RESULT(no)
787 if test "$GTK_CONFIG" = "no" ; then
788 echo "*** The gtk-config script installed by GTK could not be found"
789 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
790 echo "*** your path, or set the GTK_CONFIG environment variable to the"
791 echo "*** full path to gtk-config."
792 else
793 if test -f conf.gtktest ; then
794 :
795 else
796 echo "*** Could not run GTK test program, checking why..."
797 CFLAGS="$CFLAGS $GTK_CFLAGS"
798 LIBS="$LIBS $GTK_LIBS"
799 AC_TRY_LINK([
800 #include <gtk/gtk.h>
801 #include <stdio.h>
802 ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
803 [ echo "*** The test program compiled, but did not run. This usually means"
804 echo "*** that the run-time linker is not finding GTK or finding the wrong"
805 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
806 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
807 echo "*** to the installed location Also, make sure you have run ldconfig if that"
808 echo "*** is required on your system"
809 echo "***"
810 echo "*** If you have an old version installed, it is best to remove it, although"
811 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
812 echo "***"
813 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
814 echo "*** came with the system with the command"
815 echo "***"
816 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
817 [ echo "*** The test program failed to compile or link. See the file config.log for the"
818 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
819 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
820 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
821 CFLAGS="$ac_save_CFLAGS"
822 LIBS="$ac_save_LIBS"
823 fi
824 fi
825 GTK_CFLAGS=""
826 GTK_LIBS=""
827 ifelse([$3], , :, [$3])
828 fi
829 AC_SUBST(GTK_CFLAGS)
830 AC_SUBST(GTK_LIBS)
831 rm -f conf.gtktest
832 ])
833
834 dnl --- *@-AC_TYPE_PTRDIFF_T-@* ---
835 dnl
836 dnl Author: Ulrich Drepper
837 dnl
838 dnl Synopsis: AC_TYPE_PTRDIFF_T
839 dnl
840 dnl Arguments: ---
841 dnl
842 dnl Use: Sets HAVE_PTRDIFF_T if the type exists.
843
844 AC_DEFUN(AM_TYPE_PTRDIFF_T,
845 [AC_CACHE_CHECK([for ptrdiff_t], am_cv_type_ptrdiff_t,
846 [AC_TRY_COMPILE([#include <stddef.h>], [ptrdiff_t p],
847 am_cv_type_ptrdiff_t=yes, am_cv_type_ptrdiff_t=no)])
848 if test $am_cv_type_ptrdiff_t = yes; then
849 AC_DEFINE(HAVE_PTRDIFF_T)
850 fi
851 ])
852
853 dnl --- *@-AM_WITH_REGEX-@* ---
854 dnl
855 dnl Author: Unknown (possibly Franc,ois Pinard)
856 dnl
857 dnl Synopsis: AM_WITH_REGEX
858 dnl
859 dnl Arguments: ---
860 dnl
861 dnl Use:
862 dnl The idea is to distribute rx.[hc] and regex.[hc] together,
863 dnl for a while. The WITH_REGEX symbol (which should also be
864 dnl documented in acconfig.h) is used to decide which of regex.h
865 dnl or rx.h should be included in the application. If
866 dnl `./configure --with-regex' is given (the default), the
867 dnl package will use gawk's regex. If `./configure
868 dnl --without-regex', a check is made to see if rx is already
869 dnl installed, as with newer Linux'es. If not found, the package
870 dnl will use the rx from the distribution. If found, the package
871 dnl will use the system's rx which, on Linux at least, will
872 dnl result in a smaller executable file.
873
874 AC_DEFUN(AM_WITH_REGEX,
875 [AC_MSG_CHECKING(which of GNU rx or gawk's regex is wanted)
876 AC_ARG_WITH(regex,
877 [ --without-regex use GNU rx in lieu of gawk's regex for matching],
878 [test "$withval" = yes && am_with_regex=1],
879 [am_with_regex=1])
880 if test -n "$am_with_regex"; then
881 AC_MSG_RESULT(regex)
882 AC_DEFINE(WITH_REGEX)
883 AC_CACHE_CHECK([for GNU regex in libc], am_cv_gnu_regex,
884 AC_TRY_LINK([], [extern int re_max_failures; re_max_failures = 1],
885 am_cv_gnu_regex=yes, am_cv_gnu_regex=no))
886 if test $am_cv_gnu_regex = no; then
887 LIBOBJS="$LIBOBJS regex.o"
888 fi
889 else
890 AC_MSG_RESULT(rx)
891 AC_CHECK_FUNC(re_rx_search, , [LIBOBJS="$LIBOBJS rx.o"])
892 fi
893 AC_SUBST(LIBOBJS)dnl
894 ])
895
896 dnl --- *@-AM_SANITY_CHECK-@*
897 dnl
898 dnl Author: Unknown
899 dnl
900 dnl Synopsis: AM_SANITY_CHECK
901 dnl
902 dnl Arguments: ---
903 dnl
904 dnl Use: Check for build environment sanity.
905
906 AC_DEFUN(AM_SANITY_CHECK,
907 [AC_MSG_CHECKING([whether build environment is sane])
908 # Just in case
909 sleep 1
910 echo timestamp > conftestfile
911 # Do `set' in a subshell so we don't clobber the current shell's
912 # arguments. Must try -L first in case configure is actually a
913 # symlink; some systems play weird games with the mod time of symlinks
914 # (eg FreeBSD returns the mod time of the symlink's containing
915 # directory).
916 if (
917 set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
918 if test "$@" = "X"; then
919 # -L didn't work.
920 set X `ls -t $srcdir/configure conftestfile`
921 fi
922 test "[$]2" = conftestfile
923 )
924 then
925 # Ok.
926 :
927 else
928 AC_MSG_ERROR([newly created file is older than distributed files!
929 Check your system clock])
930 fi
931 rm -f conftest*
932 AC_MSG_RESULT(yes)])
933
934 dnl --- *@-AM_FUNC_STRDOD-@* ---
935 dnl
936 dnl Author: Jim Meyering
937 dnl
938 dnl Synopsis: AM_FUNC_STRTOD
939 dnl
940 dnl Arguments: ---
941 dnl
942 dnl Use: Checks for a working strtod function.
943
944 ## Copyright (C) 1996 Free Software Foundation, Inc.
945
946 ## This program is free software; you can redistribute it and/or modify
947 ## it under the terms of the GNU General Public License as published by
948 ## the Free Software Foundation; either version 2, or (at your option)
949 ## any later version.
950
951 ## This program is distributed in the hope that it will be useful,
952 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
953 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
954 ## GNU General Public License for more details.
955
956 ## You should have received a copy of the GNU General Public License
957 ## along with this program; if not, write to the Free Software
958 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
959 ## 02111-1307, USA.
960
961 ## From Jim Meyering.
962
963 ## serial 1
964
965 ## @defmac AC_FUNC_STRTOD
966 ## @maindex FUNC_STRTOD
967 ## @ovindex LIBOBJS
968 ## If the @code{strtod} function is not available, or does not work
969 ## correctly (like the one on SunOS 5.4), add @samp{strtod.o} to output
970 ## variable @code{LIBOBJS}.
971 ## @end defmac
972
973 AC_DEFUN(AM_FUNC_STRTOD,
974 [AC_CACHE_CHECK(for working strtod, am_cv_func_strtod,
975 [AC_TRY_RUN([
976 double strtod ();
977 int
978 main()
979 {
980 {
981 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
982 char *string = " +69";
983 char *term;
984 double value;
985 value = strtod (string, &term);
986 if (value != 69 || term != (string + 4))
987 exit (1);
988 }
989
990 {
991 /* Under Solaris 2.4, strtod returns the wrong value for the
992 terminating character under some conditions. */
993
994 ## @defmac AC_FUNC_STRTOD
995 ## @maindex FUNC_STRTOD
996 ## @ovindex LIBOBJS
997 ## If the @code{strtod} function is not available, or does not work
998 ## correctly (like the one on SunOS 5.4), add @samp{strtod.o} to output
999 ## variable @code{LIBOBJS}.
1000 ## @end defmac
1001
1002 AC_DEFUN(AM_FUNC_STRTOD,
1003 [AC_CACHE_CHECK(for working strtod, am_cv_func_strtod,
1004 [AC_TRY_RUN([
1005 double strtod ();
1006 int
1007 main()
1008 {
1009 {
1010 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1011 char *string = " +69";
1012 char *term;
1013 double value;
1014 value = strtod (string, &term);
1015 if (value != 69 || term != (string + 4))
1016 exit (1);
1017 }
1018
1019 {
1020 /* Under Solaris 2.4, strtod returns the wrong value for the
1021 terminating character under some conditions. */
1022 char *string = "NaN";
1023 char *term;
1024 strtod (string, &term);
1025 if (term != string && *(term - 1) == 0)
1026 exit (1);
1027 }
1028 exit (0);
1029 }
1030 ], am_cv_func_strtod=yes, am_cv_func_strtod=no, am_cv_func_strtod=no)])
1031 test $am_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
1032 AC_SUBST(LIBOBJS)dnl
1033 am_cv_func_strtod_needs_libm=no
1034 if test $am_cv_func_strtod = no; then
1035 AC_CHECK_FUNCS(pow)
1036 if test $ac_cv_func_pow = no; then
1037 AC_CHECK_LIB(m, pow, [am_cv_func_strtod_needs_libm=yes],
1038 [AC_MSG_WARN(can't find library containing definition of pow)])
1039 fi
1040 fi
1041 ])
1042
1043 dnl --- *@-AM_SYS_POSIX_TERMIOS-@* ---
1044 dnl
1045 dnl Author: Jim Meyering
1046 dnl
1047 dnl Synopsis: AM_SYS_POSIX_TERMIOS
1048 dnl
1049 dnl Arguments: ---
1050 dnl
1051 dnl Use: Checks for a POSIX termios.h.
1052
1053 AC_DEFUN(AM_SYS_POSIX_TERMIOS,
1054 [AC_CACHE_CHECK([POSIX termios], am_cv_sys_posix_termios,
1055 [AC_TRY_LINK([#include <sys/types.h>
1056 #include <unistd.h>
1057 #include <termios.h>],
1058 [/* SunOS 4.0.3 has termios.h but not the library calls. */
1059 tcgetattr(0, 0);],
1060 am_cv_sys_posix_termios=yes,
1061 am_cv_sys_posix_termios=no)])
1062 ])
1063
1064 dnl----- Macros by Mark Wooding ------------------------------ *@--IGNORE--@*
1065
1066 dnl --- *@-mdw_REQUIRE-@* ---
1067 dnl
1068 dnl Author: Mark Wooding
1069 dnl
1070 dnl Synopsis: mdw_REQUIRE(MACRO, ARGS...)
1071 dnl
1072 dnl Arguments: MACRO = name of a macro which should have been called
1073 dnl ARGS = arguments to pass
1074 dnl
1075 dnl Use: Like `AC_REQUIRE', only it handles arguments.
1076
1077 AC_DEFUN(mdw_REQUIRE,
1078 [ifdef([AC_PROVIDE_$1], ,
1079 [AC_DIVERT_PUSH(builtin(eval, AC_DIVERSION_CURRENT - 1))dnl
1080 indir($@)
1081 AC_DIVERT_POP()dnl
1082 ])])
1083
1084 dnl --- *@-mdw_CURSES-@* ---
1085 dnl
1086 dnl Author: Mark Wooding
1087 dnl
1088 dnl Synopsis: mdw_CURSES
1089 dnl
1090 dnl Arguments: ---
1091 dnl
1092 dnl Use: Searches for a `curses' library (one of `ncurses' or
1093 dnl `curses') using mdw_CHECK_MANYLIBS. If one is found, the
1094 dnl preprocessor macro HAVE_CURSES is defined, and a search is
1095 dnl made for a `curses' header file (one of <ncurses.h>,
1096 dnl <ncurses/ncurses.h> or <curses.h>) using AC_CHECK_HEADERS
1097 dnl and the appropriate preprocessor symbol is defined.
1098 dnl Finally, a check is made for the function `wresize' using
1099 dnl AC_CHECK_FUNCS.
1100
1101 AC_DEFUN(mdw_CURSES,
1102 [mdw_CHECK_MANYLIBS(newwin, ncurses curses, AC_DEFINE(HAVE_CURSES))
1103 if test $mdw_cv_lib_newwin != no; then
1104 AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h curses.h], [break])
1105 if test "$ac_cv_header_ncurses_h" = "no" &&
1106 test "$ac_cv_header_ncurses_ncurses_h" = "no" &&
1107 test "$ac_cv_header_curses_h" = "no"; then
1108 AC_MSG_WARN([couldn't find a \`curses' header. Assuming \`curses.h'.])
1109 AC_DEFINE(HAVE_CURSES_H)
1110 fi
1111 AC_CHECK_FUNCS(wresize)
1112 fi])
1113
1114 dnl --- *@-mdw_TYPE_SSIZE_T-@* ---
1115 dnl
1116 dnl Author: Mark Wooding
1117 dnl
1118 dnl Synopsis: mdw_TYPE_SSIZE_T
1119 dnl
1120 dnl Arguments: ---
1121 dnl
1122 dnl Use: Checks whether the Posix type `ssize_t' is defined. If not,
1123 dnl it defaults to `int'.
1124
1125 AC_DEFUN(mdw_TYPE_SSIZE_T,
1126 [AC_REQUIRE([AC_HEADER_STDC])
1127 AC_CACHE_CHECK(for ssize_t, mdw_cv_ssize_t,
1128 [AC_EGREP_CPP(ssize_t,
1129 [#include <sys/types.h>
1130 #if HAVE_UNISTD_H
1131 #include <unistd.h>
1132 #endif
1133 #if STDC_HEADERS
1134 #include <stdlib.h>
1135 #include <stddef.h>
1136 #endif],
1137 [mdw_cv_ssize_t=yes], [mdw_cv_ssize_t=no])])
1138 if test $mdw_cv_ssize_t = no; then
1139 AC_DEFINE(ssize_t, int)
1140 fi])
1141
1142 dnl --- *@-mdw_DECL_ENVIRON-@* ---
1143 dnl
1144 dnl Author: Mark Wooding
1145 dnl
1146 dnl Synopsis: mdw_DECL_ENVIRON
1147 dnl
1148 dnl Arguments: ---
1149 dnl
1150 dnl Use: Searches for a declaration of the global `environ' variable.
1151 dnl If one is found in one of the `usual' places, DECL_ENVIRON
1152 dnl is defined as a preprocessor symbol.
1153
1154 AC_DEFUN(mdw_DECL_ENVIRON,
1155 [AC_CACHE_CHECK([for declaration of \`environ'], mdw_cv_environ,
1156 [AC_EGREP_CPP(environ,
1157 [#include <sys/types.h>
1158 #if HAVE_UNISTD_H
1159 #include <unistd.h>
1160 #endif
1161 #if STDC_HEADERS
1162 #include <stdlib.h>
1163 #include <stddef.h>
1164 #endif], [mdw_cv_environ=yes], [mdw_cv_environ=no])])
1165 if test $mdw_cv_environ = yes; then
1166 AC_DEFINE(DECL_ENVIRON)
1167 fi])
1168
1169 dnl --- *@-mdw_CHECK_MANYLIBS-@* ---
1170 dnl
1171 dnl Author: Mark Wooding
1172 dnl
1173 dnl Synopsis: mdw_CHECK_MANYLIBS(FUNC, LIBS, [IF-FOUND], [IF-NOT-FOUND])
1174 dnl
1175 dnl Arguments: FUNC = a function to try to find
1176 dnl LIBS = a whitespace-separated list of libraries to search
1177 dnl IF-FOUND = what to do when the function is found
1178 dnl IF-NOT-FOUND = what to do when the function isn't found
1179 dnl
1180 dnl Use: Searches for a library which defines FUNC. It first tries
1181 dnl without any libraries; then it tries each library specified
1182 dnl in LIBS in turn. If it finds a match, it adds the
1183 dnl appropriate library to `LIBS'.
1184 dnl
1185 dnl This is particularly handy under DIREIX: if you link with
1186 dnl `-lnsl' then you get non-NIS-aware versions of getpwnam and
1187 dnl so on, which is clearly a Bad Thing.
1188
1189 AC_DEFUN(mdw_CHECK_MANYLIBS,
1190 [AC_CACHE_CHECK([for library containing $1], [mdw_cv_lib_$1],
1191 [mdw_save_LIBS="$LIBS"
1192 mdw_cv_lib_$1="no"
1193 AC_TRY_LINK(,[$1()], [mdw_cv_lib_$1="none required"])
1194 test "$mdw_cv_lib_$1" = "no" && for i in $2; do
1195 LIBS="-l$i $mdw_save_LIBS"
1196 AC_TRY_LINK(,[$1()],
1197 [mdw_cv_lib_$1="-l$i"
1198 break])
1199 done
1200 LIBS="$mdw_save_LIBS"])
1201 if test "$mdw_cv_lib_$1" != "no"; then
1202 test "$mdw_cv_lib_$1" = "none required" || LIBS="$mdw_cv_lib_$1 $LIBS"
1203 $3
1204 else :
1205 $4
1206 fi])
1207
1208 dnl --- *@-mdw__PERL_VERSION-@* ---
1209 dnl
1210 dnl AC_DEFUN relies on `[', `]' being quotes, so I have to drop down a level.
1211
1212 changequote(<<, >>)
1213 define(mdw__PERL_VERSION, <<$1 -e 'exit ($] < $2);' >&5 2>&5>>)
1214 changequote([, ])
1215
1216 dnl --- *@-mdw_PROG_PERL-@* ---
1217 dnl
1218 dnl Author: Mark Wooding
1219 dnl
1220 dnl Synopsis: mdw_PROG_PERL(VERSION, [IF-FOUND], [IF-NOT-FOUND])
1221 dnl
1222 dnl Arguments: VERSION = version number of Perl required
1223 dnl IF-FOUND = what to do if it's found
1224 dnl IF-NOT-FOUND = what to do if it isn't
1225 dnl
1226 dnl Use: Attempts to find a working version of Perl with a late
1227 dnl enough version number. It supplies an option `--with-perl'
1228 dnl to allow the user to provide a Perl interpreter. If one
1229 dnl isn't provided explicitly, it searches for `perl' and `perl5'
1230 dnl in the current PATH, asking them whether they have a late
1231 dnl enough version number. The path of the working Perl is
1232 dnl put into the `PERL' environment variable; `AC_SUBST' is used
1233 dnl to substitute its value into Perl scripts. If there is no
1234 dnl Perl to be found, the value of `PERL' is set to be `none'.
1235
1236 AC_DEFUN(mdw_PROG_PERL,
1237 [AC_ARG_WITH([perl],
1238 [ --with-perl=PERL specify path to Perl version $1 or newer],
1239 [PERL="$withval"],
1240 if test -z "$PERL"; then
1241 [AC_CACHE_CHECK([for Perl version $1 or later], mdw_cv_prog_perl,
1242 [mdw_cv_prog_perl="none"
1243 for p in `echo "$PATH:/usr/local/bin" | tr ":" " "`; do
1244 case $p in /*) ;; *) p=`pwd`/$p ;; esac
1245 if mdw__PERL_VERSION(["$p/perl"], $1); then
1246 mdw_cv_prog_perl="$p/perl"
1247 break
1248 fi
1249 if mdw__PERL_VERSION(["$p/perl5"], $1); then
1250 mdw_cv_prog_perl="$p/perl5"
1251 break
1252 fi
1253 done])
1254 PERL="$mdw_cv_prog_perl"])
1255 fi
1256
1257 AC_SUBST(PERL)dnl
1258 if test "$PERL" = "none"; then :
1259 $3
1260 else :
1261 $2
1262 fi])
1263
1264 dnl --- *@-mdw_CHECK_PERL-@* ---
1265 dnl
1266 dnl Author: Mark Wooding
1267 dnl
1268 dnl Synopsis: mdw_CHECK_PERL(VERSION)
1269 dnl
1270 dnl Arguments: VERSION = version number of Perl required
1271 dnl
1272 dnl Use: Verifies that the Perl interpreter in the `PERL' shell
1273 dnl variable actually works and is of the right version. If it's
1274 dnl not, an error is raised and configuration is aborted.
1275
1276 AC_DEFUN(mdw_CHECK_PERL,
1277 [mdw_REQUIRE([mdw_PROG_PERL], [$1])
1278 AC_MSG_CHECKING([whether Perl ($PERL) works])
1279 if test "$PERL" != "none" && mdw__PERL_VERSION("$PERL", $1); then
1280 AC_MSG_RESULT([yes])
1281 else
1282 AC_MSG_RESULT([no])
1283 AC_MSG_ERROR([Perl version $1 or newer not found.
1284 If you have a recent enough Perl, and I just failed to find it, try using
1285 the --with-perl=PERL option to give me an explicit pathname.])
1286 fi])
1287
1288 dnl --- *@-mdw_PERLLIB_CHECK-@* ---
1289 dnl
1290 dnl Author: Mark Wooding
1291 dnl
1292 dnl Synopsis: mdw_PERLLIB_CHECK(LIBRARY)
1293 dnl
1294 dnl Arguments: LIBRARY = name of a Perl library to check for
1295 dnl
1296 dnl Use: Ensures that a Perl script can `use LIBRARY;'. If it can,
1297 dnl all's well and good; if it can't, `LIBRARY.pm' is added to
1298 dnl the variable `NEEDED_PERLLIBS' and a line which adds
1299 dnl `pkgdatadir' to Perl's `@INC' array is placed in the
1300 dnl variable `INC_PERLLIBS'; `AC_SUBST' is called for both of
1301 dnl these variables. It's expected that `NEEDED_PERLLIBS' will
1302 dnl be used in the `Makefile.in' to decide which versions from
1303 dnl the distribution need installing.
1304 dnl
1305 dnl This macro isn't terribly useful in the general case. It
1306 dnl Also implicitly assumes that `$PERL' is Perl 5 or later.
1307
1308 AC_DEFUN(mdw__PERLLIB_INIT,
1309 [AC_SUBST(INC_PERLLIBS)dnl
1310 AC_SUBST(NEEDED_PERLLIBS)dnl
1311 ])
1312
1313 AC_DEFUN(mdw_PERLLIB_CHECK,
1314 [AC_REQUIRE([mdw__PERLLIB_INIT])
1315 mdw_REQUIRE([mdw_CHECK_PERL], 5)
1316 AC_CACHE_CHECK([for Perl library $1], mdw_cv_perllib_$1,
1317 [if $PERL -e 'use $1;' >&5 2>&5; then
1318 mdw_cv_perllib_$1="yes"
1319 else
1320 mdw_cv_perllib_$1="no"
1321 fi])
1322
1323 if test "$mdw_cv_perllib_$1" = "no"; then
1324 NEEDED_PERLLIBS="$NEEDED_PERLLIBS $1.pm"
1325
1326 # --- Deal with autoconf lossage ---
1327 #
1328 # It doesn't want to define `prefix' until rather later on, so I have
1329 # to bodge it here.
1330
1331 if test -z "$INC_PERLLIBS"; then
1332 mdw_old_prefix="$prefix"
1333 test "$prefix" = "NONE" && prefix="$ac_default_prefix";
1334 INC_PERLLIBS="BEGIN { push @INC, \"`eval echo $datadir/$PACKAGE`\"; }"
1335 prefix="$mdw_old_prefix";
1336 fi
1337 fi])
1338
1339 dnl --- *@-mdw_GCC_FLAGS-@* ---
1340 dnl
1341 dnl Author: Mark Wooding
1342 dnl
1343 dnl Synopsis: mdw_GCC_FLAGS([FLAGS], [CFLAGS], [C++FLAGS])
1344 dnl
1345 dnl Arguments: FLAGS = GCC compiler flags to add (default is
1346 dnl `-pedantic -Wall')
1347 dnl CFLAGS = GCC C compiler flags to add (default is empty)
1348 dnl C++FLAGS = GCC C++ compiler flags to add (default is
1349 dnl `-fhandle-exceptions').
1350 dnl
1351 dnl Use: If the C compiler is GCC, add the compiler flags.
1352
1353 AC_DEFUN(mdw_GCC_FLAGS,
1354 [if test "$GCC" = "yes"; then
1355 CFLAGS="$CFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
1356 CFLAGS="$CFLAGS ifelse([$2], [], [], [$2])"
1357 fi
1358 if test "$GXX" = "yes"; then
1359 CXXFLAGS="$CXXFLAGS ifelse([$1], [], [-pedantic -Wall], [$1])"
1360 CXXFLAGS="$CXXFLAGS ifelse([$3], [], [-fhandle-exceptions], [$3])"
1361 fi])
1362
1363 dnl *@-mdw_MLIB-@*
1364 dnl
1365 dnl Author: Mark Wooding
1366 dnl
1367 dnl Synopsis: mdw_MLIB(VERSION, IF-FOUND, IF-NOT-FOUND
1368 dnl
1369 dnl Arguments: VERSION = version of library required
1370 dnl IF-FOUND = what to do if found
1371 dnl IF-NOT-FOUND = what to do if not found
1372 dnl
1373 dnl Use: Configures an mLib client program. The default
1374 dnl version is 1.0.0pre0; the default action is to add
1375 dnl everything to the CFLAGS and LIBS variables, and complain
1376 dnl if the library couldn't be found.
1377 dnl
1378 dnl The variable MLIB_VERSION contains the version number of
1379 dnl the library; MLIB_CFLAGS is the C compiler flags required
1380 dnl and MLIB_LIBS is the linker flags.
1381
1382 AC_DEFUN([mdw_MLIB],
1383 [AC_MSG_CHECKING([for mLib library])
1384 if mLib-config --check $1 >/dev/null 2>&1; then
1385 MLIB_VERSION=`mLib-config --version`
1386 MLIB_CFLAGS=`mLib-config --cflags`
1387 MLIB_LIBS=`mLib-config --libs`
1388 AC_SUBST(MLIB_VERSION) AC_SUBST(MLIB_CFLAGS) AC_SUBST(MLIB_LIBS)
1389 ifelse([$2], [],
1390 [CFLAGS="$CFLAGS $MLIB_CFLAGS"
1391 LIBS="$MLIB_LIBS $LIBS"],
1392 $2)
1393 AC_MSG_RESULT([$MLIB_VERSION])
1394 else
1395 ifelse([$3], [],
1396 AC_MSG_ERROR([mLib library not found or too old.]),
1397 $3)
1398 AC_MSG_RESULT([not found])
1399 fi])
1400
1401 dnl *@-mdw_MGLIB-@*
1402 dnl
1403 dnl Author: Mark Wooding
1404 dnl
1405 dnl Synopsis: mdw_MGLIB(VERSION, IF-FOUND, IF-NOT-FOUND
1406 dnl
1407 dnl Arguments: VERSION = version of library required
1408 dnl IF-FOUND = what to do if found
1409 dnl IF-NOT-FOUND = what to do if not found
1410 dnl
1411 dnl Use: Configures an mgLib client program. The default
1412 dnl version is 1.0.0pre0; the default action is to add
1413 dnl everything to the CFLAGS and LIBS variables, and complain
1414 dnl if the library couldn't be found.
1415 dnl
1416 dnl The variable MGLIB_VERSION contains the version number of
1417 dnl the library; MGLIB_CFLAGS is the C compiler flags required
1418 dnl and MGLIB_LIBS is the linker flags.
1419
1420 AC_DEFUN([mdw_MGLIB],
1421 [mdw_REQUIRE([mdw_MGLIB], [1.6.0])
1422 AC_MSG_CHECKING([for mgLib library])
1423 if mgLib-config --check $1 >/dev/null 2>&1; then
1424 MGLIB_VERSION=`mgLib-config --version`
1425 MGLIB_CFLAGS=`mgLib-config --cflags`
1426 MGLIB_LIBS=`mgLib-config --libs`
1427 AC_SUBST(MGLIB_VERSION) AC_SUBST(MGLIB_CFLAGS) AC_SUBST(MGLIB_LIBS)
1428 ifelse([$2], [],
1429 [CFLAGS="$CFLAGS $MGLIB_CFLAGS"
1430 LIBS="$MGLIB_LIBS $LIBS"],
1431 $2)
1432 AC_MSG_RESULT([$MGLIB_VERSION])
1433 else
1434 ifelse([$3], [],
1435 AC_MSG_ERROR([mgLib library not found or too old.]),
1436 $3)
1437 AC_MSG_RESULT([not found])
1438 fi])
1439
1440 dnl *@-mdw_MXD-@*
1441 dnl
1442 dnl Author: Mark Wooding
1443 dnl
1444 dnl Synopsis: mdw_MXD(VERSION, IF-FOUND, IF-NOT-FOUND
1445 dnl
1446 dnl Arguments: VERSION = version of library required
1447 dnl IF-FOUND = what to do if found
1448 dnl IF-NOT-FOUND = what to do if not found
1449 dnl
1450 dnl Use: Configures an MXD client program. The default
1451 dnl version is 1.0.0pre0; the default action is to add
1452 dnl everything to the CFLAGS and LIBS variables, and complain
1453 dnl if the library couldn't be found.
1454 dnl
1455 dnl The variable MXD_VERSION contains the version number of
1456 dnl the library; MXD_CFLAGS is the C compiler flags required
1457 dnl and MXD_LIBS is the linker flags.
1458
1459 AC_DEFUN([mdw_MXD],
1460 [AC_MSG_CHECKING([for MXD library])
1461 if mxd-config --check $1 >/dev/null 2>&1; then
1462 MXD_VERSION=`mxd-config --version`
1463 MXD_CFLAGS=`mxd-config --cflags`
1464 MXD_LIBS=`mxd-config --libs`
1465 AC_SUBST(MXD_VERSION) AC_SUBST(MXD_CFLAGS) AC_SUBST(MXD_LIBS)
1466 ifelse([$2], [],
1467 [CFLAGS="$CFLAGS $MXD_CFLAGS"
1468 LIBS="$MXD_LIBS $LIBS"],
1469 $2)
1470 AC_MSG_RESULT([$MXD_VERSION])
1471 else
1472 ifelse([$3], [],
1473 AC_MSG_ERROR([MXD library not found or too old.]),
1474 $3)
1475 AC_MSG_RESULT([not found])
1476 fi])
1477
1478 dnl *@-mdw_CATACOMB-@*
1479 dnl
1480 dnl Author: Mark Wooding
1481 dnl
1482 dnl Synopsis: mdw_CATACOMB([VERSION], [IF-FOUND], [IF-NOT-FOUND])
1483 dnl
1484 dnl Arguments: VERSION = version of Catacomb required
1485 dnl IF-FOUND = what to do if found
1486 dnl IF-NOT-FOUND = what to do if not found
1487 dnl
1488 dnl Use: Configures the program as a Catacomb client. The default
1489 dnl version is 1.0.0pre0; the default action is to add
1490 dnl everything to the CFLAGS and LIBS variables, and complain
1491 dnl if the library couldn't be found.
1492 dnl
1493 dnl The variable CATACOMB_VERSION contains the version number of
1494 dnl the library; CATACOMB_CFLAGS is the C compiler flags required
1495 dnl and CATACOMB_LIBS is the linker flags.
1496
1497 AC_DEFUN([mdw_CATACOMB],
1498 [mdw_REQUIRE([mdw_MLIB], [1.6.0])
1499 AC_MSG_CHECKING([for Catacomb library])
1500 if catacomb-config --check $1 >/dev/null 2>&1; then
1501 CATACOMB_VERSION=`catacomb-config --version`
1502 CATACOMB_CFLAGS=`catacomb-config --cflags`
1503 CATACOMB_LIBS=`catacomb-config --libs`
1504 AC_SUBST(CATACOMB_VERSION)
1505 AC_SUBST(CATACOMB_CFLAGS) AC_SUBST(CATACOMB_LIBS)
1506 ifelse([$2], [],
1507 [CFLAGS="$CFLAGS $CATACOMB_CFLAGS"
1508 LIBS="$CATACOMB_LIBS $LIBS"],
1509 $2)
1510 AC_MSG_RESULT([$CATACOMB_VERSION])
1511 else
1512 ifelse([$3], [],
1513 AC_MSG_ERROR([Catacomb library not found or too old.]),
1514 $3)
1515 AC_MSG_RESULT([not found])
1516 fi])
1517
1518 dnl --- *@-mdw_OPT_NDEBUG-@* ---
1519 dnl
1520 dnl Author: Mark Wooding
1521 dnl
1522 dnl Synopsis: mdw_OPT_NDEBUG
1523 dnl
1524 dnl Arguments: ---
1525 dnl
1526 dnl Use: Turns off the `NDEBUG' flag if the user wants to do
1527 dnl debugging.
1528
1529 AC_DEFUN(mdw_OPT_NDEBUG,
1530 [AC_ARG_ENABLE(debugging,
1531 [ --enable-debugging spews vast swathes of useless information],
1532 [if test "$enableval" = "no"; then
1533 AC_DEFINE(NDEBUG, 1)
1534 fi],
1535 [AC_DEFINE(NDEBUG, 1)])])
1536
1537 dnl --- *@-mdw_OPT_EFENCE-@* ---
1538 dnl
1539 dnl Author: Mark Wooding
1540 dnl
1541 dnl Synopsis: mdw_OPT_EFENCE
1542 dnl
1543 dnl Arguments: ---
1544 dnl
1545 dnl Use: Links with the Electric Fence library.
1546
1547 AC_DEFUN(mdw_OPT_EFENCE,
1548 [AC_ARG_WITH(electric-fence,
1549 [ --with-electric-fence link programs with Electric Fence],
1550 [if test "$withval" = "yes"; then
1551 AC_CHECK_LIB(efence, malloc)
1552 fi])])
1553
1554 dnl --- *@-mdw_OPT_mLib_DEBUG-@* ---
1555 dnl
1556 dnl Author: Mark Wooding
1557 dnl
1558 dnl Synopsis: mdw_OPT_mLib_DEBUG(PROGRAM)
1559 dnl
1560 dnl Arguments: ---
1561 dnl
1562 dnl Use: Provides options for mLib debugging. In particular, the
1563 dnl following are defined:
1564 dnl
1565 dnl --enable-tracing turns off the NTRACE variable
1566 dnl --enable-track turns on malloc tracking
1567 dnl --enable-blame-PROGRAM tracks malloc contexts in PROGRAM
1568 dnl
1569 dnl There must be a separate `blame' option, so that the various
1570 dnl blame options work properly.
1571
1572 AC_DEFUN(mdw_OPT_mLib_DEBUG,
1573 [mdw_OPT_NDEBUG
1574 mdw_OPT_EFENCE
1575
1576 AC_ARG_ENABLE(tracing,
1577 [ --enable-tracing enable output of tracing information],
1578 [if test "$enableval" = "no"; then
1579 AC_DEFINE(NTRACE, 1)
1580 fi],
1581 [AC_DEFINE(NTRACE, 1)])
1582
1583 AC_ARG_ENABLE(track,
1584 [ --enable-track enable tracking of malloc and free],
1585 [AC_DEFINE(TRACK_ENABLE, 1)])
1586
1587 AC_ARG_ENABLE(blame-$1,
1588 [ --enable-blame-$1
1589 track malloc contexts while in $1],
1590 [AC_DEFINE(TRACK_BLAME, 1)])])
1591
1592 dnl----- That's all, folks --------------------------------- *@--GLOB-END--@*