3 # AX_CHECK_PAM([action-if-found[, action-if-not-found]])
7 # Look for libpam in a number of default locations, or in a provided location
8 # (via --with-pam=). Sets
13 # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
17 # Copyright (c) 2021 Eivind Naess <eivnaes@yahoo.com>
19 # Copying and distribution of this file, with or without modification, are
20 # permitted in any medium without royalty provided the copyright notice
21 # and this notice are preserved. This file is offered as-is, without any
26 AC_DEFUN([AX_CHECK_PAM], [
28 [AS_HELP_STRING([--with-pam=yes|no|DIR],
29 [With libpam support, see ftp.redhat.com:/pub/pam])])
31 AS_CASE(["$with_pam"],
32 [ye|y], [with_pam=yes],
35 AS_IF([test "x$with_pam" != "xno"], [
36 AS_CASE(["$with_pam"],
37 [""|yes], [PKG_CHECK_MODULES([PAM], [pam], [pamdirs=],
38 [pamdirs="/usr/local /usr/lib /usr"])],
39 [pamdirs="$with_pam"])
41 AS_IF([test -n "$pamdirs"], [
43 for pamdir in $pamdirs; do
44 AC_MSG_CHECKING([for pam_appl.h in $pamdir])
45 if test -f "$pamdir/include/security/pam_appl.h"; then
46 PAM_CFLAGS="-I$pamdir/include"
47 PAM_LDFLAGS="-L$pamdir/lib"
56 # try the preprocessor and linker with our new flags,
57 # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
59 AC_MSG_CHECKING([if compiling and linking against libpam works])
62 save_LDFLAGS="$LDFLAGS"
63 save_CPPFLAGS="$CPPFLAGS"
64 LDFLAGS="$LDFLAGS $PAM_LDFLAGS"
65 LIBS="$PAM_LIBS $LIBS"
66 CPPFLAGS="$PAM_CFLAGS $CPPFLAGS"
69 [#include <security/pam_appl.h>
71 [pam_authenticate(NULL, 0);])],
81 CPPFLAGS="$save_CPPFLAGS"
82 LDFLAGS="$save_LDFLAGS"
85 AC_SUBST([PAM_CFLAGS])
87 AC_SUBST([PAM_LDFLAGS])
89 AM_CONDITIONAL(WITH_LIBPAM, test "x${with_pam}" != "xno")