#
# OVERVIEW
#
-# Set up file locking support. Four types of locking are available:
-# USE_POSIX_FCNTL - use fcntl(). The full job.
-# USE_FLOCK - use flock(). Does just as well.
-# USE_LOCKF - use lockf(). Only handles advisory, exclusive,
+# Set up file locking support. Four locking mechanisms are available:
+# POSIX_FCNTL - use fcntl(). The full job.
+# FLOCK - use flock(). Does just as well.
+# LOCKF - use lockf(). Only handles advisory, exclusive,
# blocking file locks as used by Amanda.
-# USE_LNLOCK - Home brew exclusive, blocking file lock.
-# <none> - No locking available. User beware!
-# One of given symbols are defined if the method is discovered to
-# be available; the methods are searched in the above order.
+# LNLOCK - Home brew exclusive, blocking file lock.
+#
+# For the chosen method, WANT_AMFLOCK_mech is defined and set up as an
+# AM_CONDITIONAL. Also, LOCKING, which contains the mechanism, is substituted.
#
AC_DEFUN([AMANDA_SETUP_FILE_LOCKING],
[
# Note: these all use AC_TRY_LINK to make sure that we can compile
# and link each variant. They do not try to test the variants --
# that is left to runtime.
- WORKING_FILE_LOCK="no"
+ LOCKING="no"
# check POSIX locking
AC_CACHE_CHECK(
if test "x$amanda_cv_posix_filelocking" = xyes; then
AC_DEFINE(WANT_AMFLOCK_POSIX,1,[Define to use POSIX (fcntl()) for file locking])
WANT_AMFLOCK_POSIX="yes"
- WORKING_FILE_LOCK="yes"
+ LOCKING="POSIX_FCNTL"
fi
AM_CONDITIONAL(WANT_AMFLOCK_POSIX, test x"$WANT_AMFLOCK_POSIX" = x"yes")
if test "x$amanda_cv_flock_filelocking" = xyes; then
AC_DEFINE(WANT_AMFLOCK_FLOCK,1,[Define to use flock(2) for file locking])
WANT_AMFLOCK_FLOCK="yes"
- WORKING_FILE_LOCK="yes"
+ LOCKING="FLOCK"
fi
AM_CONDITIONAL(WANT_AMFLOCK_FLOCK, test x"$WANT_AMFLOCK_FLOCK" = x"yes")
if test "x$amanda_cv_lockf_filelocking" = xyes; then
AC_DEFINE(WANT_AMFLOCK_LOCKF,1,[Define to use lockf(3) for file locking.])
WANT_AMFLOCK_LOCKF="yes"
- WORKING_FILE_LOCK="yes"
+ LOCKING="LOCKF"
fi
AM_CONDITIONAL(WANT_AMFLOCK_LOCKF, test x"$WANT_AMFLOCK_LOCKF" = x"yes")
if test "x$amanda_cv_lnlock_filelocking" = xyes; then
AC_DEFINE(WANT_AMFLOCK_LNLOCK,1,[Define to use link(2) to emulate file locking.])
WANT_AMFLOCK_LNLOCK="yes"
- WORKING_FILE_LOCK="yes"
+ LOCKING="LNLOCK"
fi
AM_CONDITIONAL(WANT_AMFLOCK_LNLOCK, test x"$WANT_AMFLOCK_LNLOCK" = x"yes")
- if test x"$WORKING_FILE_LOCK" = "no"; then
+ if test x"$LOCKING" = "no"; then
# this shouldn't happen, and is *bad* if it does
AC_MSG_ERROR([*** No working file locking capability found!])
fi
+
+ AC_SUBST(LOCKING)
])