New initialization macro for libraries, and a new base client macro for
[cfd] / aclocal.glob
index cf5334f..311768e 100644 (file)
@@ -1,6 +1,6 @@
 dnl -*-fundamental-*-                                    *@--GLOB-HEADER--@*
 dnl
-dnl $Id: aclocal.glob,v 1.1 1999/05/05 19:23:47 mdw Exp $
+dnl $Id: aclocal.glob,v 1.9 2000/08/15 21:37:49 mdw Exp $
 dnl
 dnl Common library of autoconf macros
 dnl
@@ -28,13 +28,38 @@ dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 dnl----- Revision history ---------------------------------------------------
 dnl
 dnl $Log: aclocal.glob,v $
-dnl Revision 1.1  1999/05/05 19:23:47  mdw
-dnl Initial revision
+dnl Revision 1.9  2000/08/15 21:37:49  mdw
+dnl New initialization macro for libraries, and a new base client macro for
+dnl finding libraries with an appropriate version.
+dnl
+dnl Revision 1.8  1999/11/26 01:23:17  mdw
+dnl And support for MXD (not yet released).
+dnl
+dnl Revision 1.7  1999/11/11 20:03:58  mdw
+dnl Add support for mgLib too.
+dnl
+dnl Revision 1.6  1999/11/11 17:49:33  mdw
+dnl New macros for configuring clients of mLib and Catacomb.
+dnl
+dnl Revision 1.5  1999/07/27 18:27:37  mdw
+dnl Fix typo in header line for mdw_DECL_ENVIRON.
+dnl
+dnl Revision 1.4  1999/07/26 23:44:32  mdw
+dnl Reorder and tidy documentation.
+dnl
+dnl Revision 1.3  1999/07/17 10:27:44  mdw
+dnl More useful macros added.
+dnl
+dnl Revision 1.2  1999/05/13 22:57:23  mdw
+dnl Change `-ise' to `-ize' throughout.
+dnl
+dnl Revision 1.1.1.1  1999/05/05 19:23:47  mdw
+dnl New import.  The old CVS repository was lost in a disk disaster.
 dnl
 
 dnl----- Common files distribution --------------------------- *@--NOTICE--@*
 dnl
-dnl $Id: aclocal.glob,v 1.1 1999/05/05 19:23:47 mdw Exp $
+dnl $Id: aclocal.glob,v 1.9 2000/08/15 21:37:49 mdw Exp $
 
 dnl --- *@-AC_PROG_CC_STDC-@* ---
 dnl
@@ -223,7 +248,7 @@ dnl Author: Unknown
 dnl
 dnl Synopsis:  AM_INIT_GUILE_MODULE(MODNAME)
 dnl
-dnl Arguments: MODNAME = value to initialise `module' variable with
+dnl Arguments: MODNAME = value to initialize `module' variable with
 dnl
 dnl Use:       This macro will automatically get the guile version from the
 dnl            top-level srcdir, and will initialize automake.  It also
@@ -1054,12 +1079,97 @@ dnl
 dnl Use:       Like `AC_REQUIRE', only it handles arguments.
 
 AC_DEFUN(mdw_REQUIRE,
-[ifdef([AC_PROVIDED_$1], ,
+[ifdef([AC_PROVIDE_$1], ,
 [AC_DIVERT_PUSH(builtin(eval, AC_DIVERSION_CURRENT - 1))dnl
 indir($@)
 AC_DIVERT_POP()dnl
 ])])
 
+dnl --- *@-mdw_CURSES-@* ---
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_CURSES
+dnl
+dnl Arguments: ---
+dnl
+dnl Use:       Searches for a `curses' library (one of `ncurses' or
+dnl            `curses') using mdw_CHECK_MANYLIBS.  If one is found, the
+dnl            preprocessor macro HAVE_CURSES is defined, and a search is
+dnl            made for a `curses' header file (one of <ncurses.h>,
+dnl            <ncurses/ncurses.h> or <curses.h>) using AC_CHECK_HEADERS
+dnl            and the appropriate preprocessor symbol is defined.
+dnl            Finally, a check is made for the function `wresize' using
+dnl            AC_CHECK_FUNCS.
+
+AC_DEFUN(mdw_CURSES,
+[mdw_CHECK_MANYLIBS(newwin, ncurses curses, AC_DEFINE(HAVE_CURSES))
+if test $mdw_cv_lib_newwin != no; then
+AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h curses.h], [break])
+if test "$ac_cv_header_ncurses_h" = "no" &&
+   test "$ac_cv_header_ncurses_ncurses_h" = "no" &&
+   test "$ac_cv_header_curses_h" = "no"; then
+     AC_MSG_WARN([couldn't find a \`curses' header.  Assuming \`curses.h'.])
+     AC_DEFINE(HAVE_CURSES_H)
+fi
+AC_CHECK_FUNCS(wresize)
+fi])
+
+dnl --- *@-mdw_TYPE_SSIZE_T-@* ---
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_TYPE_SSIZE_T
+dnl
+dnl Arguments: ---
+dnl
+dnl Use:       Checks whether the Posix type `ssize_t' is defined.  If not,
+dnl            it defaults to `int'.
+
+AC_DEFUN(mdw_TYPE_SSIZE_T,
+[AC_REQUIRE([AC_HEADER_STDC])
+AC_CACHE_CHECK(for ssize_t, mdw_cv_ssize_t,
+[AC_EGREP_CPP(ssize_t,
+[#include <sys/types.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif],
+[mdw_cv_ssize_t=yes], [mdw_cv_ssize_t=no])])
+if test $mdw_cv_ssize_t = no; then
+  AC_DEFINE(ssize_t, int)
+fi])
+
+dnl --- *@-mdw_DECL_ENVIRON-@* ---
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_DECL_ENVIRON
+dnl
+dnl Arguments: ---
+dnl
+dnl Use:       Searches for a declaration of the global `environ' variable.
+dnl            If one is found in one of the `usual' places, DECL_ENVIRON
+dnl            is defined as a preprocessor symbol.
+
+AC_DEFUN(mdw_DECL_ENVIRON,
+[AC_CACHE_CHECK([for declaration of \`environ'], mdw_cv_environ,
+[AC_EGREP_CPP(environ, 
+[#include <sys/types.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], [mdw_cv_environ=yes], [mdw_cv_environ=no])])
+if test $mdw_cv_environ = yes; then
+  AC_DEFINE(DECL_ENVIRON)
+fi])
+
 dnl --- *@-mdw_CHECK_MANYLIBS-@* ---
 dnl
 dnl Author:    Mark Wooding
@@ -1254,6 +1364,133 @@ if test "$GXX" = "yes"; then
   CXXFLAGS="$CXXFLAGS ifelse([$3], [], [-fhandle-exceptions], [$3])"
 fi])
 
+dnl *@-mdw_INIT_LIB-@*
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_INIT_LIB(LIB, NAME, VERSION, [PACKAGE])
+dnl
+dnl Arguments: LIB = the name of the library (and the package)
+dnl            NAME = a presentable version of the library's name
+dnl            VERSION = version of the library
+dnl            PACKAGE = package name to pass on to AM_INIT_AUTOMAKE
+dnl
+dnl Use:       Sets up various useful variables.  This macro calls
+dnl            AM_INIT_AUTOMAKE, which might be considered useful.  It also
+dnl            provides variables for the use of `lib-config.in'.
+
+AC_DEFUN([mdw_INIT_LIB],
+[AM_INIT_AUTOMAKE(ifelse([$4], [], [$1], [$4]), [$3])
+LIBRARY="$1" AC_SUBST(LIBRARY)
+LIBNAME="$2" AC_SUBST(LIBNAME)])
+
+dnl *@-mdw_LIB_CONFIG-@*
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_LIB_CONFIG(LIB, NAME, VERSION, IF-FOUND, IF-NOT-FOUND)
+dnl
+dnl Arguments: LIB = the name of the library (and its configuration program)
+dnl            NAME = a presentable version of the library's name
+dnl            VERSION = version of library required
+dnl            IF-FOUND = what to do if found
+dnl            IF-NOT-FOUND = what to do if not found  
+dnl
+dnl Use:       Configures a library client program, using a configuration
+dnl            script provided by the library maintainer.
+dnl
+dnl            The default version is 1.0.0pre0; the default action is to
+dnl            add everything to the CFLAGS and LIBS variables, and complain
+dnl            if the library couldn't be found.
+dnl
+dnl            The variable LIB_VERSION contains the version number of
+dnl            the library; LIB_CFLAGS is the C compiler flags required
+dnl            and LIB_LIBS is the linker flags.
+
+AC_DEFUN([mdw_LIB_CONFIG],
+[pushdef([upname], translit([$1], [a-z], [A-Z]))dnl
+AC_MSG_CHECKING([for $2 library])
+if $1-config --check $3 >/dev/null 2>&1; then
+  upname[]_VERSION=`$1-config --version`
+  upname[]_CFLAGS=`$1-config --cflags`
+  upname[]_LIBS=`$1-config --libs`
+  AC_SUBST(upname[]_VERSION)
+  AC_SUBST(upname[]_CFLAGS)
+  AC_SUBST(upname[]_LIBS)
+  ifelse([$4], [],
+  [CFLAGS="$CFLAGS $upname[]_CFLAGS"
+  LIBS="$upname[]_LIBS $LIBS"],
+  $4)
+  AC_MSG_RESULT([$upname[]_VERSION])
+else
+  ifelse([$5], [],
+  AC_MSG_ERROR([$2 library not found or too old.]),
+  $5)
+  AC_MSG_RESULT([not found])
+fi])
+
+dnl *@-mdw_MLIB-@*
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_MLIB(VERSION, IF-FOUND, IF-NOT-FOUND
+dnl
+dnl Arguments: VERSION = version of library required
+dnl            IF-FOUND = what to do if found
+dnl            IF-NOT-FOUND = what to do if not found  
+dnl
+dnl Use:       Configures an mLib client program.
+
+AC_DEFUN([mdw_MLIB], [mdw_LIB_CONFIG(mLib, mLib, $@)])
+
+dnl *@-mdw_MGLIB-@*
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_MGLIB(VERSION, IF-FOUND, IF-NOT-FOUND
+dnl
+dnl Arguments: VERSION = version of library required
+dnl            IF-FOUND = what to do if found
+dnl            IF-NOT-FOUND = what to do if not found  
+dnl
+dnl Use:       Configures an mgLib client program.
+
+AC_DEFUN([mdw_MGLIB],
+[mdw_REQUIRE([mdw_MLIB], [1.6.0])
+mdw_LIB_CONFIG(mgLib, mgLib, $@)])
+
+dnl *@-mdw_CATACOMB-@*
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_CATACOMB([VERSION], [IF-FOUND], [IF-NOT-FOUND])
+dnl
+dnl Arguments: VERSION = version of Catacomb required
+dnl            IF-FOUND = what to do if found
+dnl            IF-NOT-FOUND = what to do if not found  
+dnl
+dnl Use:       Configures the program as a Catacomb client.
+
+AC_DEFUN([mdw_CATACOMB],
+[mdw_REQUIRE([mdw_MLIB], [1.6.0])
+mdw_LIB_CONFIG(catacomb, Catacomb, $@)])
+
+dnl *@-mdw_PK-@*
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_PK([VERSION], [IF-FOUND], [IF-NOT-FOUND])
+dnl
+dnl Arguments: VERSION = version of PK required
+dnl            IF-FOUND = what to do if found
+dnl            IF-NOT-FOUND = what to do if not found  
+dnl
+dnl Use:       Configures the program as a PK client.
+
+AC_DEFUN([mdw_PK],
+[mdw_REQUIRE([mdw_MLIB], [1.6.0])
+mdw_LIB_CONFIG(pk, PK, $@)])
+
 dnl --- *@-mdw_OPT_NDEBUG-@* ---
 dnl
 dnl Author:    Mark Wooding