[PATCH:xbiff] Convert checks for mailbox directory from ifdefs to autoconf tests
Mark Kettenis
mark.kettenis at xs4all.nl
Mon Nov 1 02:28:53 PDT 2010
> From: Alan Coopersmith <alan.coopersmith at oracle.com>
> Date: Sun, 31 Oct 2010 13:45:15 -0700
I'm not quite sure this is a good idea. The outcome of the autoconf
checks you're introducing depends on particularities of the build
system. I have seen setups where sysadmins have created /var/mail by
hand where the system default was /var/spool/mail. An xbiff binary
compiled on such a system would not work on an unmodified system.
Not sure this really matters. Most modern systems provide a BSD-style
<paths.h> and on Solaris /var/mail seems to be the preferred mail
directory and that's the one you check first.
The check defenitely won't work for cross-compilation though.
> 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
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list