-dnl ** figure out the alignment restriction of a type
-dnl (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE
-dnl so we can't call REQUIRE)
-
-dnl FPTOOLS_CHECK_ALIGNMENT(TYPE)
-AC_DEFUN(FPTOOLS_CHECK_ALIGNMENT,
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl
-dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl
-dnl The name of the corresponding size.
-define(<<AC_CV_SIZEOF_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
-changequote([, ])dnl
-AC_MSG_CHECKING(alignment of $1)
-AC_CACHE_VAL(AC_CV_NAME,
-[AC_TRY_RUN([
-#include <stdio.h>
-#if HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-#ifndef offsetof
-#define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0))
-#endif
-int
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d", offsetof(struct { char c; $1 ty;},ty));
- exit(0);
-}],
-AC_CV_NAME=`cat conftestval`,
-AC_CV_NAME=$AC_CV_SIZEOF_NAME,
-AC_CV_NAME=$AC_CV_SIZEOF_NAME)])
-AC_MSG_RESULT($AC_CV_NAME)
-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
-AC_PROVIDE($AC_TYPE_NAME)
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-undefine([AC_CV_SIZEOF_NAME])dnl
-])
-
-dnl ** Map an arithmetic C type to a Haskell type.
-dnl Based on autconf's AC_CHECK_SIZEOF.
-
-dnl FPTOOLS_CHECK_HTYPE(TYPE [, DEFAULT_VALUE, [, VALUE-FOR-CROSS-COMPILATION])
-AC_DEFUN(FPTOOLS_CHECK_HTYPE,
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))dnl
-dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))dnl
-changequote([, ])dnl
-AC_MSG_CHECKING(Haskell type for $1)
-AC_CACHE_VAL(AC_CV_NAME,
-[AC_TRY_RUN([#include <stdio.h>
-#include <stddef.h>
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#ifdef HAVE_TIME_H
-# include <time.h>
-#endif
-
-#ifdef HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-
-#ifdef HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#ifdef HAVE_GL_GL_H
-# include <GL/gl.h>
-#endif
-
-#ifdef HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef $1 testing;
-
-main() {
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
- fprintf(f, "%s%d\n",
- ((testing)(-1) < (testing)0) ? "Int" : "Word",
- sizeof(testing)*8);
- } else {
- fprintf(f,"%s\n",
- (sizeof(testing) > sizeof(double)) ? "LDouble" :
- (sizeof(testing) == sizeof(double)) ? "Double" : "Float");
- }
- fclose(f);
- exit(0);
-}], AC_CV_NAME=`cat conftestval`,
-ifelse([$2], , AC_CV_NAME=NotReallyAType, AC_CV_NAME=$2),
-ifelse([$3], , AC_CV_NAME=NotReallyATypeCross, AC_CV_NAME=$3))]) dnl
-AC_MSG_RESULT($AC_CV_NAME)
-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-])
-
-dnl ** figure out whether C compiler supports 'long long's
-dnl (Closely based on Andreas Zeller's macro for testing
-dnl for this under C++)
-dnl
-dnl If the C compiler supports `long long' types,
-dnl define `HAVE_LONG_LONG'.
-dnl
-AC_DEFUN(FPTOOLS_C_LONG_LONG,
-[
-AC_REQUIRE([AC_PROG_CC])
-AC_MSG_CHECKING(whether ${CC} supports long long types)
-AC_CACHE_VAL(fptools_cv_have_long_long,
-[
-AC_LANG_SAVE
-AC_LANG_C
-AC_TRY_COMPILE(,[long long a;],
-fptools_cv_have_long_long=yes,
-fptools_cv_have_long_long=no)
-AC_LANG_RESTORE
-])
-AC_MSG_RESULT($fptools_cv_have_long_long)
-if test "$fptools_cv_have_long_long" = yes; then
-AC_DEFINE(HAVE_LONG_LONG)
+# FP_CHECK_FUNC(FUNCTION, PROLOGUE, BODY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------------
+# A variant of AC_CHECK_FUNCS, limited to a single FUNCTION, but with the
+# additional flexibility of specifying the PROLOGUE and BODY.
+AC_DEFUN([FP_CHECK_FUNC],
+[AS_VAR_PUSHDEF([fp_func], [fp_cv_func_$1])dnl
+AC_CACHE_CHECK([for $1], fp_func,
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], [$3])],
+ [AS_VAR_SET(fp_func, yes)],
+ [AS_VAR_SET(fp_func, no)])])
+AS_IF([test AS_VAR_GET(fp_func) = yes],
+ [AC_DEFINE(AS_TR_CPP(HAVE_$1), [1],
+ [Define to 1 if you have the `]$1[' function.]) $4],
+ [$5])dnl
+AS_VAR_POPDEF([fp_func])dnl
+])# FP_CHECK_FUNC
+
+
+# FP_GEN_DOCBOOK_XML
+# ------------------
+# Generates a DocBook XML V4.2 document in conftest.xml.
+#
+# It took a lot of experimentation to find a document that will cause
+# xsltproc to fail with an error code when the relevant
+# stylesheets/DTDs are not found. I couldn't make xsltproc fail with
+# a single-file document, it seems a multi-file document is needed.
+# -- SDM 2009-06-03
+#
+AC_DEFUN([FP_GEN_DOCBOOK_XML],
+[rm -f conftest.xml conftest-book.xml
+cat > conftest.xml << EOF
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [[
+<!ENTITY conftest-book SYSTEM "conftest-book.xml">
+]]>
+<book id="test">
+&conftest-book;
+</book>
+EOF
+cat >conftest-book.xml << EOF
+<?xml version="1.0" encoding="iso-8859-1"?>
+ <title>A DocBook “Test Document”</title>
+ <chapter id="id-one">
+ <title>A Chapter Title</title>
+ <para>This is a paragraph, referencing <xref linkend="id-two"/>.</para>
+ </chapter>
+ <chapter id="id-two">
+ <title>Another Chapter Title</title>
+ <para>This is another paragraph, referencing <xref linkend="id-one"/>.</para>
+ </chapter>
+EOF
+]) # FP_GEN_DOCBOOK_XML
+
+
+# FP_PROG_DBLATEX
+# ----------------
+# Sets the output variable DblatexCmd to the full path of dblatex,
+# which we use for building PDF and PS docs.
+# DblatexCmd is empty if dblatex could not be found.
+AC_DEFUN([FP_PROG_DBLATEX],
+[AC_PATH_PROG([DblatexCmd], [dblatex])
+if test -z "$DblatexCmd"; then
+ AC_MSG_WARN([cannot find dblatex in your PATH, you will not be able to build the PDF and PS documentation])