Merge from vendor branch TNF:
[pkgsrc.git] / mk / pam.buildlink3.mk
1 # $NetBSD: pam.buildlink3.mk,v 1.4 2005/04/25 14:21:47 tv Exp $
2 #
3 # This Makefile fragment is meant to be included by packages that
4 # require a PAM implementation.  pam.buildlink3.mk will:
5 #
6 #       * set PAMBASE to the base directory of the PAM files;
7 #       * set PAM_TYPE to the PAM implementation used.
8 #
9 # There are two variables that can be used to tweak the selection of
10 # the PAM implementation:
11 #
12 # PAM_DEFAULT is a user-settable variable whose value is the default
13 #       PAM implementation to use.
14 #
15 # PAM_ACCEPTED is a package-settable list of PAM implementations
16 #       that may be used by the package.
17 #
18
19 PAM_BUILDLINK3_MK:=     ${PAM_BUILDLINK3_MK}+
20
21 .include "../../mk/bsd.prefs.mk"
22
23 .if !empty(PAM_BUILDLINK3_MK:M+)
24 #
25 # This is an exhaustive list of all of the PAM implementations
26 # that may be used with PAM.buildlink3.mk, in order of precedence.
27 #
28 # OS conditionals can exclude implementations not available on
29 # some platforms.
30 #
31 .if ${OPSYS} != "Interix"
32 _PAM_PKGS+=     linux-pam
33 .endif
34
35 .if ${OPSYS} != "Interix"
36 _PAM_PKGS+=     openpam
37 .endif
38
39 # builtin only, so no conditional needed
40 _PAM_PKGS+=     solaris-pam
41
42 BUILDLINK_BUILTIN_MK.linux-pam=         ../../security/PAM/builtin.mk
43 BUILDLINK_BUILTIN_MK.openpam=           ../../security/openpam/builtin.mk
44 BUILDLINK_BUILTIN_MK.solaris-pam=       ../../mk/solaris-pam.builtin.mk
45
46 # If we have a particular PAM implementation in the base system, then
47 # default to using that PAM type.  Otherwise, default to "linux-pam".
48 #
49 .  for _pam_ in ${_PAM_PKGS}
50 .    if exists(${BUILDLINK_BUILTIN_MK.${_pam_}})
51 CHECK_BUILTIN.${_pam_}:=        yes
52 .      include "${BUILDLINK_BUILTIN_MK.${_pam_}}"
53 .      if defined(IS_BUILTIN.${_pam_}) && \
54                 !empty(IS_BUILTIN.${_pam_}:M[yY][eE][sS])
55 PAM_DEFAULT?=   ${_pam_}
56 .      endif
57 CHECK_BUILTIN.${_pam_}:=        no
58 .    endif
59 .  endfor
60 PAM_DEFAULT?=   linux-pam
61 PAM_ACCEPTED?=  ${_PAM_PKGS}
62
63 _PAM_DEFAULT=   ${PAM_DEFAULT}
64 _PAM_ACCEPTED=  ${PAM_ACCEPTED}
65
66 _PAM_TYPE?=     ${_PAM_DEFAULT}
67
68 .  if !empty(_PAM_ACCEPTED:M${_PAM_TYPE})
69 PAM_TYPE=       ${_PAM_TYPE}
70 .  else
71 PAM_TYPE=       none
72 .  endif
73 PAMBASE=        ${BUILDLINK_PREFIX.${PAM_TYPE}}
74
75 BUILD_DEFS+=    PAM_TYPE
76 BUILD_DEFS+=    PAMBASE
77 .endif  # PAM_BUILDLINK3_MK
78
79 .if ${PAM_TYPE} == "none"
80 PKG_FAIL_REASON=        \
81         "${_PAM_TYPE} is not an acceptable PAM type for ${PKGNAME}."
82 .elif ${PAM_TYPE} == "linux-pam"
83 .  include "../../security/PAM/buildlink3.mk"
84 .elif ${PAM_TYPE} == "openpam"
85 .  include "../../security/openpam/buildlink3.mk"
86 .elif ${PAM_TYPE} == "solaris-pam"
87 BUILDLINK_PACKAGES:=    ${BUILDLINK_PACKAGES:Nsolaris-pam}
88 BUILDLINK_PACKAGES+=    solaris-pam
89 .endif