]> diplodocus.org Git - nmh/blob - m4/locking.m4
getpass.c: Move interface to own file.
[nmh] / m4 / locking.m4
1 dnl Our functions to check the locking functions available and select a
2 dnl default locking function for the spool file
3 dnl
4 dnl Since we're assuming POSIX as a minimum, we always assume we have fcntl
5 dnl locking available.
6 dnl
7
8 AC_DEFUN([NMH_LOCKING],
9 [AC_CHECK_FUNCS([flock lockf])
10 AS_CASE(["$host_os"],
11 [aix*|cygwin*|linux*],
12 [default_locktype="fcntl"],
13 [freebsd*|*netbsd*|openbsd*|darwin*], [default_locktype="flock"],
14 [default_locktype="dot"])
15
16 AC_MSG_CHECKING([default locking method for the mail spool])
17
18 AC_ARG_WITH([locking],
19 AS_HELP_STRING([--with-locking=@<:@dot|fcntl|flock|lockf@:>@],
20 [The default locking method for the mail spool file]), ,
21 [with_locking="$default_locktype"])
22
23 AS_CASE([$with_locking],
24 [fcntl|dot], ,
25 [flock],
26 [AS_IF([test x"$ac_cv_func_flock" != x"yes"],
27 [AC_MSG_ERROR([flock locks not supported on this system])])],
28 [lockf],
29 [AS_IF([test x"$ac_cv_func_lockf" != x"yes"],
30 [AC_MSG_ERROR([lockf locks not supported on this system])])],
31 [no],
32 [AC_MSG_ERROR([--without-locking not supported])],
33 [AC_MSG_ERROR([Unknown locking type $with_locking])])
34
35 AC_DEFINE_UNQUOTED([DEFAULT_LOCKING], ["$with_locking"],
36 [The default lock type for the mail spool file])
37 AC_SUBST([default_locking], [$with_locking])
38
39 AC_MSG_RESULT([$with_locking])
40
41 supported_locks="fcntl dot"
42 AS_IF([test x"$ac_cv_func_flock" = x"yes"],
43 [supported_locks="$supported_locks flock"])
44 AS_IF([test x"$ac_cv_func_lockf" = x"yes"],
45 [supported_locks="$supported_locks lockf"])
46 AC_SUBST([supported_locks])
47
48 dnl Should we use a locking directory?
49 AC_ARG_ENABLE([lockdir],
50 [AS_HELP_STRING([--enable-lockdir=dir], [Store dot-lock files in "dir"])], [
51 AS_IF([test "x$enableval" = xyes],[
52 AC_MSG_ERROR([--enable-lockdir requires an argument])])
53 AC_DEFINE_UNQUOTED([LOCKDIR], ["$enableval"],
54 [Directory to store dot-locking lock files])
55 ])])