Pullup ticket #2800.
[pkgsrc.git] / mk / apache.mk
1 # $NetBSD: apache.mk,v 1.24 2007/10/17 10:43:36 rillig Exp $
2 #
3 # This file is meant to be included by packages that require an apache
4 # web server.
5 #
6 # User-settable variables:
7 #
8 # PKG_APACHE_DEFAULT
9 #       The default apache server to use and install. If there already
10 #       is an apache installed, this will have no effect.
11 #
12 #       Possible values: apache13 apache2 apache22
13 #
14 # Package-settable variables:
15 #
16 # PKG_APACHE_ACCEPTED
17 #       The list of apache packages that can be used as a dependency for
18 #       the package.
19 #
20 #       Possible values: (see PKG_APACHE_DEFAULT)
21 #
22 # USE_APR
23 #       If apache2 is chosen by this file and this variable is set to
24 #       "yes", a full dependency to the Apache Portable Runtime library
25 #       will be added.
26 #
27 # Variables defined by this file:
28 #
29 # PKG_APACHE
30 #       The Apache version that is actually used.
31 #
32 #       Possible values: (see PKG_APACHE_DEFAULT)
33 #
34 # APACHE_PKG_PREFIX
35 #       The package name prefix for apache modules.
36 #
37 #       Possible values: ap13 ap2 ap22
38 #
39
40 .if !defined(APACHE_MK)
41 APACHE_MK=                      # defined
42
43 _VARGROUPS+=            apache
44 _USER_VARS.apache=      PKG_APACHE_DEFAULT
45 _PKG_VARS.apache=       PKG_APACHE_ACCEPTED USE_APR
46 _SYS_VARS.apache=       PKG_APACHE APACHE_PKG_PREFIX
47
48 .include "bsd.fast.prefs.mk"
49
50 PKG_APACHE_DEFAULT?=            apache22
51 BUILD_DEFS+=                    PKG_APACHE_DEFAULT
52 BUILD_DEFS_EFFECTS+=            PKG_APACHE APACHE_PKG_PREFIX
53
54 # Package-settable variables
55 PKG_APACHE_ACCEPTED?=           ${_PKG_APACHES}
56 USE_APR?=                       no
57
58 # The available apache packages:
59 _PKG_APACHES=                   apache13 apache2 apache22
60
61 _APACHE_PKGBASE.apache13=       apache-1*
62 _APACHE_PKG_PREFIX.apache13=    ap13
63 _APACHE_PKGSRCDIR.apache13=     ../../www/apache
64
65 _APACHE_PKGBASE.apache2=        apache-2.0*
66 _APACHE_PKG_PREFIX.apache2=     ap2
67 _APACHE_PKGSRCDIR.apache2=      ../../www/apache2
68
69 _APACHE_PKGBASE.apache22=       apache-2.[23456789]*
70 _APACHE_PKG_PREFIX.apache22=    ap22
71 _APACHE_PKGSRCDIR.apache22=     ../../www/apache22
72
73 #
74 # Sanity checks.
75 #
76
77 .if empty(_PKG_APACHES:M${PKG_APACHE_DEFAULT})
78 PKG_FAIL_REASON+=               "[apache.mk] Invalid apache package \""${PKG_APACHE_DEFAULT:Q}"\" in PKG_APACHE_DEFAULT."
79 PKG_APACHE_DEFAULT=             apache2
80 .endif
81
82 .for _ap_ in ${PKG_APACHE_ACCEPTED}
83 .  if empty(_PKG_APACHES:M${_ap_})
84 PKG_FAIL_REASON+=               "[apache.mk] Invalid apache package \""${_ap_:Q}"\" in PKG_APACHE_ACCEPTED."
85 PKG_APACHE_ACCEPTED=            # none
86 .  endif
87 .endfor
88
89 # Mark the acceptable apaches and check which apache packages are installed.
90 .for _ap_ in ${PKG_APACHE_ACCEPTED}
91 _APACHE_OK.${_ap_}=     yes
92 _APACHE_INSTALLED.${_ap_}!= \
93         if ${PKG_INFO} -qe ${_APACHE_PKGBASE.${_ap_}:Q}; then           \
94                 ${ECHO} yes;                                            \
95         else                                                            \
96                 ${ECHO} no;                                             \
97         fi
98 .endfor
99 .for ap in ${_PKG_APACHES}
100 _APACHE_OK.${ap}?=      no
101 .endfor
102
103 .undef PKG_APACHE
104
105 # Use one of the installed apaches, ...
106 .for _ap_ in ${PKG_APACHE_ACCEPTED}
107 .  if ${_APACHE_INSTALLED.${_ap_}} == "yes"
108 PKG_APACHE?=            ${_ap_}
109 .  endif
110 .endfor
111
112 # ... otherwise, prefer the default one if it's accepted, ...
113 .if ${_APACHE_OK.${PKG_APACHE_DEFAULT}} == "yes"
114 PKG_APACHE?=            ${PKG_APACHE_DEFAULT}
115 .endif
116
117 # ... otherwise, just use the first accepted apache.
118 .for ap in ${PKG_APACHE_ACCEPTED}
119 PKG_APACHE?=            ${ap}
120 .endfor
121
122 .if defined(PKG_APACHE)
123 .  include "${_APACHE_PKGSRCDIR.${PKG_APACHE}}/buildlink3.mk"
124 .else
125 PKG_FAIL_REASON+=       "[apache.mk] No acceptable apache package found."
126 PKG_APACHE=             none
127 .endif
128
129 APACHE_PKG_PREFIX=      ${_APACHE_PKG_PREFIX.${PKG_APACHE}}
130
131 .if (${PKG_APACHE} == "apache2") && !empty(USE_APR:M[yY][eE][sS])
132 .  include "../../devel/apr0/buildlink3.mk"
133 .elif (${PKG_APACHE} == "apache22") && !empty(USE_APR:M[Yy][Ee][Ss])
134 .  include "../../devel/apr/buildlink3.mk"
135 .  include "../../devel/apr-util/buildlink3.mk"
136 .endif
137
138 .endif  # APACHE_MK