Bug #21128. Reviewed by John Darrington.
[pspp-builds.git] / acinclude.m4
index e15ab76742376dd3ef36acd6373b0c4067c3de63..61290a1802158861f1fbb736838f2c20a6e4690d 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -40,8 +40,28 @@ AC_DEFUN([PSPP_LIBPLOT],
   AC_ARG_WITH(libplot, [  --without-libplot         don't compile in support of charts (using libplot)])
 
   if test x"$with_libplot" != x"no" ; then 
-    AC_CHECK_LIB(plot, pl_newpl_r,,
-                [PSPP_REQUIRED_PREREQ([libplot (or use --without-libplot)])])
+    # Check whether we can link against libplot without any extra libraries.
+    AC_CHECK_LIB(plot, pl_newpl_r, [LIBPLOT_LIBS="-lplot"])
+
+    # Check whether we can link against libplot if we also link X.
+    if test x"$LIBPLOT_LIBS" = x""; then
+      AC_PATH_XTRA
+      extra_libs="-lXaw -lXmu -lXt $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS -lm"
+      AC_CHECK_LIB(plot, pl_newpl_r,
+                  [LIBPLOT_LIBS="-lplot $extra_libs"
+                    LDFLAGS="$LDFLAGS $X_LIBS"],,
+                  [$extra_libs])
+    fi
+
+    # Still can't link?
+    if test x"$LIBPLOT_LIBS" = x""; then
+      PSPP_REQUIRED_PREREQ([libplot (or use --without-libplot)])
+    fi
+
+    # Set up to make everything work.
+    LIBS="$LIBPLOT_LIBS $LIBS"
+    AC_DEFINE(HAVE_LIBPLOT, 1,
+              [Define to 1 if you have the `libplot' library (-lplot).])
   fi
 ])
 
@@ -63,10 +83,10 @@ AC_DEFUN([PSPP_OFF_T],
   `--disable-largefile' or `CFLAGS=-ansi'.])])
 ])
 
-dnl Check whether a warning flag is accepted.
+dnl Check whether a C compiler option is accepted.
 dnl If so, add it to CFLAGS.
-dnl Example: PSPP_ENABLE_WARNING(-Wdeclaration-after-statement)
-AC_DEFUN([PSPP_ENABLE_WARNING],
+dnl Example: PSPP_ENABLE_OPTION(-Wdeclaration-after-statement)
+AC_DEFUN([PSPP_ENABLE_OPTION],
 [
   m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
   AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name], 
@@ -185,4 +205,21 @@ t}
 fi
 AC_SUBST(EXEEXT_FOR_BUILD)])
 
-dnl aclocal.m4 ends here
+dnl Check for LC_PAPER, _NL_PAPER_WIDTH, _NL_PAPER_HEIGHT.
+AC_DEFUN([PSPP_LC_PAPER],
+[AC_CACHE_CHECK(for LC_PAPER, pspp_cv_lc_paper, [
+    pspp_cv_lc_paper=no
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [#include <locale.h>
+#include <langinfo.h>
+],
+        [(void) LC_PAPER; (void) _NL_PAPER_WIDTH; (void) _NL_PAPER_HEIGHT])],
+      [pspp_cv_lc_paper=yes])
+  ])
+  if test "$pspp_cv_lc_paper" = yes; then
+    AC_DEFINE(HAVE_LC_PAPER, 1, [Define if you have LC_PAPER.])
+  fi
+])
+
+dnl acinclude.m4 ends here