Commit 56d50498 56d50498700d28bb7bf3bab5e23973d29669e101 by Sergey Poznyakoff

Define the necessary PATH_ constants.

* paths: New file.
* am/config_paths.m4: New file.
* include/confpaths.h.in: New file.
* Makefile.am (EXTRA_DIST): Add paths.
(DISTCLEANFILES): Add pathdefs.h
* configure.ac: Invoke MU_CONFIG_PATHS
(AC_CONFIG_FILES): Add include/confpaths.h
* include/Makefile.am (EXTRA_DIST): Add confpaths.h.in
* lib/utmp.c, libmu_scm/mu_scm.c,
libproto/mailer/sendmail.c, mail/mail.c: Use PATH_* constants.
* mail/mail.h: Remove definition of _PATH_SENDMAIL.
* .gitignore, include/.gitignore: Update.
1 parent aee26e58
......@@ -4,6 +4,7 @@
*.o
*.so
*~
*.cflow
.bootstrap
.deps
.emacs*
......
......@@ -54,7 +54,9 @@ SUBDIRS = \
movemail\
mimeview
EXTRA_DIST = COPYING.LESSER
EXTRA_DIST = COPYING.LESSER paths
DISTCLEANFILES = pathdefs.h
gen_start_date =
prev_change_log =
......
#serial 1
dnl Copyright (C) 1996, 1997, 1998, 2002, 2004, 2005, 2007,
dnl 2009 Free Software Foundation, Inc.
dnl
dnl Written by Miles Bader <miles@gnu.ai.mit.edu> and
dnl Sergey Poznyakoff <gray@gnu.org>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl
dnl MU_CONFIG_PATHS -- Configure system paths for use by programs
dnl $1 - PATHS -- The file to read containing the paths
dnl $2 - HDRDEFS -- The file to put the generated C defines into
dnl $3 - MAKEDEFS -- [OPTIONAL] The file to put the generated
dnl make `PATHDEF_' vars
dnl
dnl From the paths listed in the file PATHS, generate a C header file
dnl HDRDEFS, containing the necessary #define statements.
dnl
dnl Additionally, if MAKEDEFS is supplied, populate this file with
dnl make variables. A variable for each PATH_FOO will be called
dnl PATHDEF_FOO and will be set to a cpp option to define that path,
dnl unless it is to be defined using a system define.
dnl
dnl Use of MAKEDEFS is recommended if any of the settings from PATHS refer
dnl to environment or make variables.
dnl
AC_DEFUN([MU_CONFIG_PATHS], [
dnl We need to know if we're cross compiling.
AC_REQUIRE([AC_PROG_CC])
AC_CHECK_HEADER(paths.h, AC_DEFINE(HAVE_PATHS_H, 1,
[Define if you have the <paths.h> header file]) mu_paths_h="<paths.h>")
dnl A slightly bogus use of AC_ARG_WITH; we never actually use
dnl $with_PATHVAR, we just want to get this entry put into the help list.
dnl We actually look for `with_' variables corresponding to each path
dnl configured.
AC_ARG_WITH([PATHVAR],
AC_HELP_STRING([--with-PATHVAR=PATH],
[Set the value of PATHVAR to PATH
PATHVAR is the name of a \`PATH_FOO' variable,
downcased, with \`_' changed to \`-']))
# For case-conversion with sed
MU_UCASE=ABCDEFGHIJKLMNOPQRSTUVWXYZ
mu_lcase=abcdefghijklmnopqrstuvwxyz
tmpdir="$TMPDIR"
test x"$tmpdir" = x && tmpdir="/tmp"
mu_cache_file="$tmpdir/,mu-path-cache.$$"
mu_tmp_file="$tmpdir/,mu-tmp.$$"
ac_clean_files="$ac_clean_files $mu_cache_file $mu_tmp_file"
while read mu_path mu_search; do
test "$mu_path" = "#" -o -z "$mu_path" && continue
mu_pathvar="`echo $mu_path | sed y/${MU_UCASE}/${mu_lcase}/`"
AC_MSG_CHECKING(for value of $mu_path)
mu_val='' mu_hdr='' mu_sym=''
mu_cached='' mu_defaulted=''
mu_cross_conflict=''
if test "`eval echo '$'{with_$mu_pathvar+set}`" = set; then
# User-supplied value
eval mu_val=\"'$'with_$mu_pathvar\"
elif test "`eval echo '$'{mailutils_cv_$mu_pathvar+set}`" = set; then
# Cached value
eval mu_val=\"'$'mailutils_cv_$mu_pathvar\"
# invert escaped $(...) notation used in autoconf cache
eval mu_val=\"\`echo \'"$mu_val"\' \| sed \''s/@(/$\(/g'\'\`\"
mu_cached="(cached) "
elif test "`eval echo '$'{mailutils_cv_hdr_$mu_pathvar+set}`" = set; then
# Cached non-value
eval mu_hdr=\"'$'mailutils_cv_hdr_$mu_pathvar\"
eval mu_sym=\"'$'mailutils_cv_hdr_sym_$mu_pathvar\"
mu_cached="(cached) "
else
# search for a reasonable value
mu_test_type=r # `exists'
mu_default='' mu_prev_cross_test=''
for mu_try in $mu_paths_h $mu_search; do
mu_cross_test=''
case "$mu_try" in
"<"*">"*)
# <HEADER.h> and <HEADER.h>:SYMBOL -- look for SYMBOL in <HEADER.h>
# SYMBOL defaults to _$mu_path (e.g., _PATH_FOO)
changequote(,) dnl Avoid problems with [ ] in regexps
eval mu_hdr=\'`echo "$mu_try" |sed 's/:.*$//'`\'
eval mu_sym=\'`echo "$mu_try" |sed -n 's/^<[^>]*>:\(.*\)$/\1/p'`\'
changequote([,])
test "$mu_sym" || mu_sym="_$mu_path"
AC_EGREP_CPP(HAVE_$mu_sym,
[#include ]$mu_hdr[
#ifdef $mu_sym
HAVE_$mu_sym
#endif],
:, mu_hdr='' mu_sym='')
;;
search:*)
# Do a path search. The syntax here is: search:NAME[:PATH]...
# Path searches always generate potential conflicts
test "$cross_compiling" = yes && { mu_cross_conflict=yes; continue; }
changequote(,) dnl Avoid problems with [ ] in regexps
mu_name="`echo $mu_try | sed 's/^search:\([^:]*\).*$/\1/'`"
mu_spath="`echo $mu_try | sed 's/^search:\([^:]*\)//'`"
changequote([,])
test "$mu_spath" || mu_spath="$PATH"
for mu_dir in `echo "$mu_spath" | sed 'y/:/ /'`; do
test -z "$mu_dir" && mu_dir=.
if test -$mu_test_type "$mu_dir/$mu_name"; then
mu_val="$mu_dir/$mu_name"
break
fi
done
;;
no) mu_default=no;;
x|d|f|c|b) mu_test_type=$mu_try;;
*)
# Just try the given name, with make-var substitution. Besides
# yielding a value if found, this also sets the default.
case "$mu_try" in "\""*"\"")
# strip off quotes
mu_try="`echo $mu_try | sed -e 's/^.//' -e 's/.$//'`"
esac
test -z "$mu_default" && mu_default="$mu_try"
test "$cross_compiling" = yes && { mu_cross_test=yes; continue; }
# See if the value begins with a $(FOO)/${FOO} make variable
# corresponding to a shell variable, and if so set try_exp to the
# value thereof. Recurse.
mu_try_exp="$mu_try"
changequote(,)
mu_try_var="`echo "$mu_try_exp" |sed -n 's;^\$[({]\([-_a-zA-Z]*\)[)}].*;\1;p'`"
while eval test \"$mu_try_var\" && eval test '${'$mu_try_var'+set}'; do
# yes, and there's a corresponding shell variable, which substitute
if eval test \"'$'"$mu_try_var"\" = NONE; then
# Not filled in by configure yet
case "$mu_try_var" in
prefix | exec_prefix)
mu_try_exp="$ac_default_prefix`echo "$mu_try_exp" |sed 's;^\$[({][-_a-zA-Z]*[)}];;'`";;
esac
mu_try_var='' # Stop expansion here
else
# Use the actual value of the shell variable
eval mu_try_exp=\"`echo "$mu_try_exp" |sed 's;^\$[({]\([-_a-zA-Z]*\)[)}];\$\1;'`\"
mu_try_var="`echo "$mu_try_exp" |sed -n 's;^\$[({]\([-_a-zA-Z]*\)[)}].*;\1;p'`"
fi
done
changequote([,])
test -$mu_test_type "$mu_try_exp" && mu_val="$mu_try"
;;
esac
test "$mu_val" -o "$mu_hdr" && break
test "$mu_cross_test" -a "$mu_prev_cross_test" && mu_cross_conflict=yes
mu_prev_cross_test=$mu_cross_test
done
if test -z "$mu_val" -a -z "$mu_hdr"; then
if test -z "$mu_default"; then
mu_val=no
else
mu_val="$mu_default"
mu_defaulted="(default) "
fi
fi
fi
if test "$mu_val"; then
AC_MSG_RESULT(${mu_cached}${mu_defaulted}$mu_val)
test "$mu_cross_conflict" -a "$mu_defaulted" \
&& AC_MSG_WARN(may be incorrect because of cross-compilation)
# Put the value in the autoconf cache. We replace $( with @( to avoid
# variable evaluation problems when autoconf reads the cache later.
echo mailutils_cv_$mu_pathvar=\'"`echo "$mu_val" | sed 's/\$(/@(/g'`"\'
elif test "$mu_hdr"; then
AC_MSG_RESULT(${mu_cached}from $mu_sym in $mu_hdr)
echo mailutils_cv_hdr_$mu_pathvar=\'"$mu_hdr"\'
echo mailutils_cv_hdr_sym_$mu_pathvar=\'"$mu_sym"\'
fi
done <[$1] >$mu_cache_file
# Read the cache values constructed by the previous loop,
. $mu_cache_file
# Generate a file of #ifdefs that defaults PATH_FOO macros to _PATH_FOO (or
# some other symbol) (excluding any who's value is set to `no').
while read mu_cache_set; do
mu_sym_var="`echo "$mu_cache_set" | sed 's/=.*$//'`"
eval mu_sym_value=\"'$'"$mu_sym_var"\"
case $mu_sym_var in
mailutils_cv_hdr_sym_*)
mu_path="`echo $mu_sym_var | sed -e 's/^mailutils_cv_hdr_sym_//' -e y/${mu_lcase}/${MU_UCASE}/`"
;;
mailutils_cv_path_*)
mu_path="PATH_`echo $mu_sym_var | sed -e 's/^mailutils_cv_path_//' -e y/${mu_lcase}/${MU_UCASE}/`"
s=`echo "$mu_sym_value" | sed 's/[[^@\$]]//g'`
if test -n "$s"; then
continue
fi
mu_sym_value="\"$mu_sym_value\""
;;
*)
continue;;
esac
cat <<EOF
#ifndef $mu_path
#define $mu_path $mu_sym_value
#endif
EOF
done < $mu_cache_file >$[$2]
AC_SUBST_FILE([$2])
m4_if([$3],[],[],[
# Construct the pathdefs file -- a file of make variable definitions, of
# the form PATHDEF_FOO, that contain cc -D switches to define the cpp macro
# PATH_FOO.
grep -v '^mailutils_cv_hdr_' < $mu_cache_file | \
while read mu_cache_set; do
mu_var="`echo $mu_cache_set | sed 's/=.*$//'`"
eval mu_val=\"'$'"$mu_var"\"
# invert escaped $(...) notation used in autoconf cache
eval mu_val=\"\`echo \'"$mu_val"\' \| sed \''s/@(/$\(/g'\'\`\"
if test "$mu_val" != no; then
mu_path="`echo $mu_var | sed -e 's/^mailutils_cv_//' -e y/${mu_lcase}/${MU_UCASE}/`"
mu_pathdef="`echo $mu_path | sed 's/^PATH_/PATHDEF_/'`"
echo $mu_pathdef = -D$mu_path='\"'"$mu_val"'\"'
fi
done >$[$3]
AC_SUBST_FILE([$3])
]) ])
......@@ -324,17 +324,14 @@ if test "x$MU_CONF_MAILDIR" != x; then
AC_DEFINE_UNQUOTED(MU_CONF_MAILDIR,$MU_CONF_MAILDIR,
[Pathname of the mail spool directory])
fi
AH_BOTTOM([
#ifdef HAVE_PATHS_H
# include <paths.h>
#endif
#ifndef _PATH_MAILDIR
# if (defined(sun) && defined(__svr4__)) || defined(__SVR4)
# define _PATH_MAILDIR "/var/mail"
# else
# define _PATH_MAILDIR "/usr/spool/mail"
# endif
#endif
PATHDEFS_H=pathdefs.h
MU_CONFIG_PATHS($srcdir/paths,PATHDEFS_H)
AH_BOTTOM(
[/* Defaults for PATH_ variables. */
#include <confpaths.h>
#ifdef MU_CONF_MAILDIR
# define MU_PATH_MAILDIR MU_CONF_MAILDIR
#else
......@@ -1291,7 +1288,9 @@ status_sendmail=$mu_cv_enable_sendmail
])
dnl Output Makefiles
AC_CONFIG_FILES([Makefile
AC_CONFIG_FILES([
include/confpaths.h
Makefile
sql/Makefile
comsat/Makefile
config/Makefile
......
Makefile
Makefile.in
confpaths.h
......
......@@ -18,3 +18,4 @@
## 02110-1301 USA
SUBDIRS=mailutils
EXTRA_DIST=confpaths.h.in
\ No newline at end of file
......
/* Define PATH_* macros from paths in $(top_srcdir)/paths. */
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
@PATHDEFS_H@
/* utmp.c -- Replacements for {set,get,end}utmp functions
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -28,7 +28,7 @@ MA 02110-1301 USA. */
#include <string.h>
#include <stdio.h>
static char *utmp_name = _PATH_UTMP;
static char *utmp_name = PATH_UTMP;
static int fd = -1;
static struct utmp ut;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2005, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2005, 2006, 2007,
2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -18,8 +19,8 @@
#include "mu_scm.h"
#ifndef _PATH_SENDMAIL
# define _PATH_SENDMAIL "/usr/lib/sendmail"
#ifndef PATH_SENDMAIL
# define PATH_SENDMAIL "/usr/lib/sendmail"
#endif
void
......@@ -190,7 +191,7 @@ mu_scm_init ()
{
int i;
_mu_scm_mailer = scm_makfrom0str ("sendmail:" _PATH_SENDMAIL);
_mu_scm_mailer = scm_makfrom0str ("sendmail:" PATH_SENDMAIL);
mu_set_variable ("mu-mailer", _mu_scm_mailer);
_mu_scm_debug = mu_scm_makenum(0);
......
......@@ -58,7 +58,7 @@ _url_sendmail_init (mu_url_t url)
return EINVAL;
if (url->path == 0)
if ((url->path = strdup (_PATH_SENDMAIL)) == 0)
if ((url->path = strdup (PATH_SENDMAIL)) == 0)
return ENOMEM;
return 0;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007 Free Software Foundation, Inc.
2005, 2006, 2007, 2009 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -341,8 +341,8 @@ main (int argc, char **argv)
/* Set the default mailer to sendmail. */
{
char *mailer_name = alloca (strlen ("sendmail:")
+ strlen (_PATH_SENDMAIL) + 1);
sprintf (mailer_name, "sendmail:%s", _PATH_SENDMAIL);
+ strlen (PATH_SENDMAIL) + 1);
sprintf (mailer_name, "sendmail:%s", PATH_SENDMAIL);
util_setenv ("sendmail", mailer_name, Mail_env_string, 1);
}
......
......@@ -416,10 +416,6 @@ void compose_destroy (compose_env_t *env);
extern char *readline (char *prompt);
#endif
#ifndef _PATH_SENDMAIL
#define _PATH_SENDMAIL "/usr/lib/sendmail"
#endif
/* Flags for util_get_message */
#define MSG_ALL 0
#define MSG_NODELETED 0x0001
......
# Paths for GNU Mailutils
#
# Copyright (C) 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file describes how to set various paths used by libraries and
# programs in GNU Mailutils.
#
# The rules that determine what a given PATH_FOO define expands to are:
# (1) If the user specifies --with-path-foo, that value is used.
# (2) If _PATH_FOO is defined in <paths.h>, that value is used.
# (3) The lines below are consulted. They are whitespace-separated
# lists of things to try, in order. The various sorts of entries are:
#
# "value" -- If a file VALUE exists, use VALUE; if no default yet, set
# it to VALUE. If VALUE begins with a make-variable of the
# form `$(NAME)' and a corresponding shell-variable $NAME
# exists at configure time, the value of $NAME is substituted
# for the $(NAME) for testing (but not subsitution) purposes.
# test:T -- Use `test -T' to test for file existance
# x -- The same as test:x
# d -- The same as test:d
# c -- The same as test:c
# b -- The same as test:b
# <ach.h>:SYMBOL
# -- If SYMBOL is defined in <ack.h>, use SYM
# <ack.h> -- The same as <ack.h>:_PATH_FOO
# search:NAME:PATH
# -- Search for NAME in the colon-separated path PATH, and use
# the first thing found; if the `:PATH' is omitted, it
# uses the environment variable $PATH
# no -- Set the default to `no' (even if there's already a default).
# FILE -- The same as "FILE" (the quoted syntax only need be used if
# the contents could match one of the special syntaxes)
#
# If cross-compiling then every file-existence test is made to fail
# (regardless of what exists on the compilation system), forcing
# defaults to be used for paths not defined in any header file. A
# warning message is printed by configure in this case, as the user may
# have to define many paths by hand.
#
# If none of the things in the list matches a real file, the default is
# used, or `no' if there is none (this means that no path may ever have
# the value `no', but that's probably not a severe problem).
#
# (4) If the resulting value is the string `no', then PATH_FOO is never
# defined by any method (programs that use it should check that it's
# defined before using it).
#
# Programs wanting to use a particular path PATH_FOO should include the
# file <confpaths.h> (located in include/).
#
PATH_SENDMAIL search:sendmail:/usr/sbin:/usr/lib:/etc /usr/sbin/sendmail
PATH_MAILDIR d /var/mail /var/spool/mail
PATH_DEV d /dev/
# PATH_TTY_PFX is a prefix that's removed to get a tty device's name
PATH_TTY_PFX <paths.h>:_PATH_DEV d /dev/
PATH_DEVNULL c /dev/null
PATH_UTMP <utmp.h> <utmp.h>:UTMP_FILE $(localstatedir)/run/utmp search:utmp:/var/run:/var/adm:/etc
PATH_UTMPX <utmpx.h> <utmpx.h>:UTMPX_FILE $(localstatedir)/run/utmpx search:utmpx:/var/run:/var/adm:/etc
PATH_WTMP <utmp.h> <utmp.h>:WTMP_FILE $(localstatedir)/log/wtmp search:wtmp:/var/log:/var/adm:/etc
PATH_TTY c /dev/tty