[PATCH:xbiff] Convert checks for mailbox directory from ifdefs to autoconf tests

Alan Coopersmith alan.coopersmith at oracle.com
Sun Oct 31 13:45:15 PDT 2010


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 MailboxP.h   |   18 +++---------------
 configure.ac |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/MailboxP.h b/MailboxP.h
index 937f895..365c63e 100644
--- a/MailboxP.h
+++ b/MailboxP.h
@@ -33,24 +33,12 @@ from the X Consortium.
 #ifndef _XawMailboxP_h
 #define _XawMailboxP_h
 
+#include "config.h"
 #include "Mailbox.h"
 #include <X11/Xaw/SimpleP.h>
 
-#if defined(SYSV)
-#define MAILBOX_DIRECTORY "/usr/mail"
-#elif defined(SVR4)
-#define MAILBOX_DIRECTORY "/var/mail"
-#elif defined(CSRG_BASED)
-#include <paths.h>
-#ifdef _PATH_MAILDIR
-#define MAILBOX_DIRECTORY _PATH_MAILDIR
-#endif
-#elif defined(__linux__)
-#define MAILBOX_DIRECTORY "/var/spool/mail"
-#endif
-
-#ifndef MAILBOX_DIRECTORY
-#define MAILBOX_DIRECTORY "/usr/spool/mail"
+#ifdef HAVE_PATHS_H
+# include <paths.h>
 #endif
 
 typedef struct {			/* new fields for mailbox widget */
diff --git a/configure.ac b/configure.ac
index 5891c6c..c8338b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,4 +41,40 @@ XORG_DEFAULT_OPTIONS
 # Checks for pkg-config packages
 PKG_CHECK_MODULES(XBIFF, xaw7 xmu xbitmaps xext x11)
 
+# Find mail directory
+# - First see if builder specified it
+AC_ARG_VAR([MAILBOX_DIRECTORY], [Directory containing user mailboxes])
+# - then check for BSD-style <paths.h> with _PATH_MAILDIR
+AC_CHECK_HEADERS([paths.h])
+if test "x$MAILBOX_DIRECTORY" = "x"; then
+   AC_CHECK_DECL([_PATH_MAILDIR], [MAILBOX_DIRECTORY="_PATH_MAILDIR"], [], [
+AC_INCLUDES_DEFAULT
+#if HAVE_PATHS_H
+#include <paths.h>
+#endif
+	])
+fi
+# - if not found there, check common paths
+if test "x$MAILBOX_DIRECTORY" = "x"; then
+    if test "$cross_compiling" = yes ; then
+        AC_MSG_ERROR([cannot check for mailbox directory when cross compiling])
+    fi
+    for d in /var/mail /var/spool/mail /usr/spool/mail /usr/mail  ; do
+        AC_MSG_CHECKING([for $d])
+        if test -d "$d" ; then
+            AC_MSG_RESULT([yes])
+            MAILBOX_DIRECTORY="\"$d\""
+            break
+        else
+            AC_MSG_RESULT([no])
+        fi
+    done
+fi
+AC_MSG_CHECKING([for mailbox directory])
+AC_MSG_RESULT([$MAILBOX_DIRECTORY])
+if test "x$MAILBOX_DIRECTORY" = "x"; then
+   AC_MSG_ERROR([mailbox directory not found, try setting MAILBOX_DIRECTORY])
+fi
+AC_DEFINE_UNQUOTED([MAILBOX_DIRECTORY], [$MAILBOX_DIRECTORY],
+                   [Directory containing user mailboxes])
 AC_OUTPUT([Makefile])
-- 
1.7.3.2



More information about the xorg-devel mailing list