| 1 |
# SYNOPSIS |
| 2 |
# |
| 3 |
# AX_CHECK_PAM([action-if-found[, action-if-not-found]]) |
| 4 |
# |
| 5 |
# DESCRIPTION |
| 6 |
# |
| 7 |
# Look for libpam in a number of default locations, or in a provided location |
| 8 |
# (via --with-pam=). Sets |
| 9 |
# PAM_CFLAGS |
| 10 |
# PAM_LDFLAGS |
| 11 |
# PAM_LIBS |
| 12 |
# |
| 13 |
# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately |
| 14 |
# |
| 15 |
# LICENSE |
| 16 |
# |
| 17 |
# Copyright (c) 2021 Eivind Naess <[email protected]> |
| 18 |
# |
| 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 |
| 22 |
# warranty. |
| 23 |
|
| 24 |
#serial 1 |
| 25 |
|
| 26 |
AC_DEFUN([AX_CHECK_PAM], [ |
| 27 |
AC_ARG_WITH([pam], |
| 28 |
[AS_HELP_STRING([--with-pam=yes|no|DIR], |
| 29 |
[With libpam support, see ftp.redhat.com:/pub/pam])]) |
| 30 |
|
| 31 |
AS_CASE(["$with_pam"], |
| 32 |
[ye|y], [with_pam=yes], |
| 33 |
[n], [with_pam=no]) |
| 34 |
|
| 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"]) |
| 40 |
|
| 41 |
AS_IF([test -n "$pamdirs"], [ |
| 42 |
PAM_LIBS="-lpam" |
| 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" |
| 48 |
AC_MSG_RESULT([yes]) |
| 49 |
break |
| 50 |
else |
| 51 |
AC_MSG_RESULT([no]) |
| 52 |
fi |
| 53 |
done |
| 54 |
]) |
| 55 |
|
| 56 |
# try the preprocessor and linker with our new flags, |
| 57 |
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS |
| 58 |
|
| 59 |
AC_MSG_CHECKING([if compiling and linking against libpam works]) |
| 60 |
|
| 61 |
save_LIBS="$LIBS" |
| 62 |
save_LDFLAGS="$LDFLAGS" |
| 63 |
save_CPPFLAGS="$CPPFLAGS" |
| 64 |
LDFLAGS="$LDFLAGS $PAM_LDFLAGS" |
| 65 |
LIBS="$PAM_LIBS $LIBS" |
| 66 |
CPPFLAGS="$PAM_CFLAGS $CPPFLAGS" |
| 67 |
AC_LINK_IFELSE( |
| 68 |
[AC_LANG_PROGRAM( |
| 69 |
[#include <security/pam_appl.h> |
| 70 |
#include <stddef.h>], |
| 71 |
[pam_authenticate(NULL, 0);])], |
| 72 |
[ |
| 73 |
AC_MSG_RESULT([yes]) |
| 74 |
with_pam=yes |
| 75 |
$1 |
| 76 |
], [ |
| 77 |
AC_MSG_RESULT([no]) |
| 78 |
with_pam="no" |
| 79 |
$2 |
| 80 |
]) |
| 81 |
CPPFLAGS="$save_CPPFLAGS" |
| 82 |
LDFLAGS="$save_LDFLAGS" |
| 83 |
LIBS="$save_LIBS" |
| 84 |
|
| 85 |
AC_SUBST([PAM_CFLAGS]) |
| 86 |
AC_SUBST([PAM_LIBS]) |
| 87 |
AC_SUBST([PAM_LDFLAGS]) |
| 88 |
]) |
| 89 |
AM_CONDITIONAL(WITH_LIBPAM, test "x${with_pam}" != "xno") |
| 90 |
]) |
| 91 |
|