aboutsummaryrefslogtreecommitdiffstats
path: root/www/apache20/Makefile.modules.3rd
blob: 6305ceffd39cdc2896f361f3322b314a23dcb5ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# Makefile.modules.3rd
#
# $FreeBSD$
#
# Author: Clement Laforet <clement@FreeBSD.org>
# If you have questions, please contact me.
#

.ifdef(USE_APACHE)
.error USE_APACHE and Makefile.modules.3rd can't be used together.
.endif

APXS?=      ${LOCALBASE}/sbin/apxs
MODULENAME?=    ${PORTNAME}
SHORTMODNAME?=  ${MODULENAME:S/mod_//}
SRC_FILE?=  ${MODULENAME}.c
OVERRIDABLE_VARS=   SRC_FILE MODULENAME SHORTMODNAME WRKSRC \
            PKGNAMESUFFIX


.if exists(${LOCALBASE}/include/apache2/http_core.h)
WITH_APACHE2=   YES
.   if defined (WANT_APACHE)
.     if ${WANT_APACHE} == 13
IGNORE=     "This module require apache13 and you have apache2 installed"
.     endif
.   endif
.elif exists(${LOCALBASE}/include/apache/http_core.h)
WITH_APACHE13=  YES
.   if defined (WANT_APACHE)
.     if ${WANT_APACHE} == 2
IGNORE=     "This module require apache2 and you have apache13 installed"
.     endif
.   endif
.   ifdef(WITH_APACHE2)
.error You have `WITH_APACHE2' variable defined either in environment or in make(1) argumentsm. but apache13 is installed Please undefine and try again.
.   endif
.endif

.if defined (WANT_APACHE)
.  if ${WANT_APACHE} == 13
WITH_APACHE13=      YES
.  elif ${WANT_APACHE} == 2
WITH_APACHE2=       YES
.elif ${WANT_APACHE:Mcommon*} != ""
PORT_IS_SERVER=     YES
.  else
IGNORE=     "Unknown apache version"
.  endif
.endif

.if !defined(PORT_IS_SERVER)
.if exists(${APXS})
APXS_PREFIX!=   ${APXS} -q prefix 2> /dev/null || echo NULL
.   if ${APXS_PREFIX} == NULL
IGNORE= : Your apache does not support DSO modules
.   endif
.   if defined(AP_GENPLIST) && ${APXS_PREFIX} != ${PREFIX}
IGNORE?=    PREFIX must be egal to APXS_PREFIX.
.   endif
.else
APXS_PREFIX=    ${APXS:S/\/sbin\/apxs//}
.endif

.if defined(WITH_APACHE2)
AP_BUILDEXT=    la
PLIST_SUB+= APACHEMODDIR="libexec/apache2"
APACHE_PORT=    www/apache2
AP_VER=     2
.else
AP_BUILDEXT=    so
PLIST_SUB+= APACHEMODDIR="libexec/apache"
APACHE_PORT?=   www/apache13
AP_VER=     13
.endif

.for VAR in ${OVERRIDABLE_VARS}
.   if defined(AP${AP_VER}_${VAR})
${VAR}= ${AP${AP_VER}_${VAR}}
.   endif
.endfor

BUILD_DEPENDS+= ${APXS}:${PORTSDIR}/${APACHE_PORT}
RUN_DEPENDS+=   ${APXS}:${PORTSDIR}/${APACHE_PORT}
PLIST_SUB+= AP_NAME="${SHORTMODNAME}"
PLIST_SUB+= AP_MODULE="${MODULENAME}.so"
.if defined(AP_GENPLIST)
PLIST?=     ${WRKDIR}/ap-plist
.endif

.if defined(AP_INC)
AP_EXTRAS+= -I ${AP_INC}
.endif
.if defined(AP_LIB)
AP_EXTRAS+= -L ${AP_LIB}
.endif

.if defined(AP_FAST_BUILD)

ap-gen-plist:
.if defined(AP_GENPLIST)
.   if !exists(${PLIST})
    @${ECHO} "===>  Generating apache plist"
    @${ECHO} "@unexec %D/sbin/apxs -e -A -n %%AP_NAME%% %D/%%APACHEMODDIR%%/%%AP_MODULE%%" > ${PLIST}
    @${ECHO} "%%APACHEMODDIR%%/%%AP_MODULE%%" >> ${PLIST}
    @${ECHO} "@exec %D/sbin/apxs -e -A -n %%AP_NAME%% %D/%F" >> ${PLIST}
    @${ECHO} "@unexec echo \"Don't forget to remove all ${MODULENAME}-related directives in your httpd.conf\"">> ${PLIST}
.   endif
.else
    @${DO_NADA}
.endif

do-build: ap-gen-plist
    @cd ${WRKSRC} && ${APXS} -c ${AP_EXTRAS} -o ${MODULENAME}.${AP_BUILDEXT} ${SRC_FILE}

do-install:
    @${APXS} -i -A -n ${SHORTMODNAME} ${WRKSRC}/${MODULENAME}.${AP_BUILDEXT}
.endif

.else # PORT_IS_SERVER

# For slave ports:
.if defined(SLAVE_DESIGNED_FOR) && ${PORTVERSION} != ${SLAVE_DESIGNED_FOR}
IGNORE= "Sorry, ${SLAVENAME} and ${PORTNAME} versions are out of sync"
.endif

.if defined(SLAVE_PORT_MODULES)
DEFAULT_MODULES_CATEGORIES+=    SLAVE_PORT
ALL_MODULES_CATEGORIES+=    SLAVE_PORT
.endif

# Module selection
.for category in ${DEFAULT_MODULES_CATEGORIES}
DEFAULT_MODULES+=   ${${category}_MODULES}
# We select them
WITH_${category}_MODULES= YES
.endfor

.for category in ${ALL_MODULES_CATEGORIES}
AVAILABLE_MODULES+= ${${category}_MODULES}
.endfor

# Setting "@comment " as default.
.for module in ${AVAILABLE_MODULES}
${module}_PLIST_SUB=    "@comment "
.endfor


# Configure
.if ${WANT_APACHE} == common13
# dirty hack to make sure all modules are disabled before we select them
CONFIGURE_ARGS+=    --disable-module="all"
.elif ${WANT_APACHE} == common2
CONFIGURE_ARGS+=    --disable-access --disable-auth \
            --disable-charset-lite --disable-include \
            --disable-log-config --disable-env --disable-setenvif \
            --disable-mime --disable-status --disable-autoindex \
            --disable-asis --disable-cgid --disable-cgi \
            --disable-negotiation --disable-dir --disable-imap \
            --disable-actions --disable-userdir --disable-alias
.endif

.if defined(WITH_MODULES)
_APACHE_MODULES+=   ${WITH_MODULES}
.else
.for category in ${ALL_MODULES_CATEGORIES}
.if defined (WITHOUT_${category}_MODULES) || defined (WITH_CUSTOM_${category})
.        if defined(WITH_${category}_MODULES})
.        undef WITH_${category}_MODULES
.        endif
.    if defined (WITH_CUSTOM_${category})
_APACHE_MODULES+=   ${WITH_CUSTOM_${category}}
.    endif
.elif defined(WITH_${category}_MODULES)
_APACHE_MODULES+=   ${${category}_MODULES}
.endif
.endfor
.    if defined(WITH_EXTRA_MODULES)
_APACHE_MODULES+=   ${WITH_EXTRA_MODULES}
.    endif
.endif


.if !defined(WITH_STATIC_APACHE)
.    if ${WANT_APACHE} == common2
# FYI
#DYNAMIC_MODULES=   so
CONFIGURE_ARGS+=    --enable-so
.    endif
.else
.    if ${WANT_APACHE} == common2
CONFIGURE_ARGS+=    --disable-so
.    endif
WITH_ALL_STATIC_MODULES=    YES
.endif

.if defined(WITH_SUEXEC) || defined(WITH_SUEXEC_MODULES)
.if ${WANT_APACHE} == common13
SUEXEC_CONFARGS=    suexec
CONFIGURE_ARGS+=    --enable-suexec
.elif ${WANT_APACHE} == common2
SUEXEC_CONFARGS=    with-suexec
.else
IGNORE=     Can not determine apache version
.endif

SUEXEC_DOCROOT?=        ${PREFIX}/www/data
SUEXEC_USERDIR?=        public_html
SUEXEC_SAFEPATH?=       ${PREFIX}/bin:${LOCALBASE}/bin:/usr/bin:/bin
SUEXEC_LOGFILE?=        /var/log/httpd-suexec.log
SUEXEC_UIDMIN?=         1000
SUEXEC_GIDMIN?=         1000
SUEXEC_CALLER?=         ${WWWOWN}
_APACHE_MODULES+=       ${SUEXEC_MODULES}
CONFIGURE_ARGS+=        --${SUEXEC_CONFARGS}-caller=${SUEXEC_CALLER} \
                --${SUEXEC_CONFARGS}-uidmin=${SUEXEC_UIDMIN} \
                --${SUEXEC_CONFARGS}-gidmin=${SUEXEC_GIDMIN} \
                --${SUEXEC_CONFARGS}-userdir="${SUEXEC_USERDIR}" \
                --${SUEXEC_CONFARGS}-docroot="${SUEXEC_DOCROOT}" \
                --${SUEXEC_CONFARGS}-safepath="${SUEXEC_SAFEPATH}" \
                --${SUEXEC_CONFARGS}-logfile="${SUEXEC_LOGFILE}" \
                --${SUEXEC_CONFARGS}-bin="${PREFIX}/sbin/suexec"
.   if defined(WITH_SUEXEC_UMASK)
CONFIGURE_ARGS+=        --${SUEXEC_CONFARGS}-umask=${WITH_SUEXEC_UMASK}
.   endif
.endif

.if !defined(WITHOUT_MODULES)
APACHE_MODULES=     ${_APACHE_MODULES}
.else
APACHE_MODULES!=    \
            for module in ${_APACHE_MODULES}; do \
                ${ECHO_CMD} ${WITHOUT_MODULES} | ${GREP} -wq $${module} 2> /dev/null || \
                ${ECHO_CMD} $${module}; \
            done
.endif

.if defined(WITH_STATIC_MODULES)
.   if WANT_APACHE=13
STATIC_MODULE_CONFARG=  --enable-module=$${module}
DSO_MODULE_CONFARG= --enable-module=$${module} --enable-shared=$${module}
.   else
STATIC_MODULE_CONFARG=  --enable-$${module}
DSO_MODULE_CONFARG= --enable-$${module}=shared
.endif
_CONFIGURE_ARGS!=   \
            for module in ${APACHE_MODULES} ; do \
                ${ECHO_CMD} ${WITH_STATIC_MODULES} | \
                    ${GREP} -wq $${module} 2> /dev/null ; \
                if [ "$${?}" = "0" ] ; then \
                        ${ECHO_CMD} "${STATIC_MODULE_CONFARG}"; \
                    else \
                        ${ECHO_CMD} "${DSO_MODULE_CONFARG}"; \
                    fi; done
CONFIGURE_ARGS+=    ${_CONFIGURE_ARGS}
.elif defined(WITH_STATIC_APACHE) || defined(WITH_ALL_STATIC_MODULES)
WITH_STATIC_MODULES=    ${APACHE_MODULES}
.    if ${WANT_APACHE} == common13
.      for module in ${APACHE_MODULES}
CONFIGURE_ARGS+=    --enable-module=${module}
.      endfor
.    else
CONFIGURE_ARGS+=    --enable-modules="${APACHE_MODULES}"
.    endif
.else
.    if ${WANT_APACHE} == common13
.      for module in ${APACHE_MODULES}
CONFIGURE_ARGS+=    --enable-module=${module} --enable-shared=${module}
.      endfor
.    else
CONFIGURE_ARGS+=    --enable-mods-shared="${APACHE_MODULES}"
.    endif
.endif

.if defined(WITH_STATIC_MODULES)
_SHARED_MODULES!=   \
            for module in ${APACHE_MODULES} ; do \
                ${ECHO_CMD} ${WITH_STATIC_MODULES} | ${GREP} -wq $${module} 2> /dev/null || \
                ${ECHO_CMD} $${module}; \
            done
SHARED_MODULES=     ${_SHARED_MODULES}
.elif !defined(WITH_ALL_STATIC_MODULES)
SHARED_MODULES=     ${APACHE_MODULES}
.endif

.  for module in ${SHARED_MODULES}
${module}_PLIST_SUB=    ""
.  endfor

.for module in ${AVAILABLE_MODULES}
PLIST_SUB+= MOD_${module:U}=${${module}_PLIST_SUB}
.endfor

.endif #PORT_IS_SERVER