update Sun Sep 13 06:37:00 PDT 2009
[pkgsrc.git] / www / apache22 / Makefile
1 # $NetBSD: Makefile,v 1.50 2009/09/13 13:32:50 tron Exp $
2
3 DISTNAME=       httpd-2.2.13
4 PKGNAME=        ${DISTNAME:S/httpd/apache/}
5 PKGREVISION=    1
6 CATEGORIES=     www
7 MASTER_SITES=   ${MASTER_SITE_APACHE:=httpd/} \
8                 ${MASTER_SITE_APACHE:=httpd/old/}
9 EXTRACT_SUFX=   .tar.bz2
10
11 MAINTAINER=     tron@NetBSD.org
12 HOMEPAGE=       http://httpd.apache.org/
13 COMMENT=        Apache HTTP (Web) server, version 2.2
14 LICENSE=        apache-2.0
15
16 PKG_DESTDIR_SUPPORT=    user-destdir
17
18 CONFLICTS=      apache-{,*ssl}-[0-9]* apache6-[0-9]*
19
20 BUILD_DEFS+=    IPV6_READY
21 BUILD_DEFS+=    VARBASE
22
23 USE_TOOLS+=             pax perl perl:run pkg-config
24 USE_LIBTOOL=            yes
25 GNU_CONFIGURE=          yes
26 CONFIGURE_ARGS+=        --enable-layout=NetBSD
27 CONFIGURE_ARGS+=        --with-port=80
28 CONFIGURE_ARGS+=        --enable-so
29 CONFIGURE_ENV+=         perlbin=${PERL5:Q}
30 CONFIGURE_ENV+=         ac_cv_path_RSYNC=/nonexistent
31 CONFIGURE_ARGS+=       CFLAGS=${APACHE_CUSTOM_CFLAGS:Q}
32
33 BUILD_DEFS+=           APACHE_CUSTOM_CFLAGS
34
35 # Apache Portable Runtime library configure options
36 CONFIGURE_ARGS+=        --with-apr=${BUILDLINK_PREFIX.apr}
37 CONFIGURE_ARGS+=        --with-apr-util=${BUILDLINK_PREFIX.apr-util}
38
39 CHECK_INTERPRETER_SKIP+=        lib/httpd/httpd.exp
40 CHECK_PORTABILITY_SKIP+=        srclib/pcre/* \
41                                 srclib/apr-util/* \
42                                 srclib/apr/*
43
44 # the following must be set before bsd.prefs.mk in order to make += work
45 # in mk.conf; however, it isn't expanded until referenced, so we can
46 # define DFLT_APACHE_MODULES later
47 #
48 APACHE_MODULES?=        ${DFLT_APACHE_MODULES}
49
50 .include "../../mk/bsd.prefs.mk"
51 .include "../../devel/apr/buildlink3.mk"
52 .include "../../devel/apr-util/buildlink3.mk"
53 .include "../../textproc/expat/buildlink3.mk"
54 .include "../../mk/dlopen.buildlink3.mk"
55
56 # Set the "Multi-Processing Model" used by Apache to handle requests.
57 # Valid values are:
58 #       event           multi-threaded based in worker, designed
59 #                       to allow more requests to be served
60 #                       simultaneously by passing off some processing
61 #                       work to supporting threads.
62 #                       BEWARE: does not work with SSL or input filters.
63 #       prefork         non-threaded, pre-forking web server
64 #       worker          hybrid multi-threaded multi-process web server
65 #
66 APACHE_MPM?=            prefork
67 CONFIGURE_ARGS+=        --with-mpm=${APACHE_MPM:Q}
68 BUILD_DEFS+=            APACHE_MPM
69
70 .if !empty(APACHE_MPM:Mevent) || !empty(APACHE_MPM:Mworker)
71 PLIST_SRC+=             ${PKGDIR}/PLIST.worker
72 .endif
73
74 CONFIGURE_ARGS+=        --disable-include
75 CONFIGURE_ARGS+=        --disable-log-config
76 CONFIGURE_ARGS+=        --disable-env
77 CONFIGURE_ARGS+=        --disable-mime
78 CONFIGURE_ARGS+=        --disable-setenvif
79 CONFIGURE_ARGS+=        --disable-status
80 CONFIGURE_ARGS+=        --disable-autoindex
81 CONFIGURE_ARGS+=        --disable-asis
82 CONFIGURE_ARGS+=        --disable-cgi
83 CONFIGURE_ARGS+=        --disable-negotiation
84 CONFIGURE_ARGS+=        --disable-dir
85 CONFIGURE_ARGS+=        --disable-actions
86 CONFIGURE_ARGS+=        --disable-userdir
87 CONFIGURE_ARGS+=        --disable-alias
88
89 DFLT_APACHE_MODULES=    all
90 DFLT_APACHE_MODULES+=   proxy proxy_connect proxy_ftp proxy_http
91 DFLT_APACHE_MODULES+=   ssl deflate access auth authn_alias
92 DFLT_APACHE_MODULES+=   include log_config env mime setenvif
93 DFLT_APACHE_MODULES+=   status autoindex asis cgi negotiation dir imap
94 DFLT_APACHE_MODULES+=   actions userdir alias isapi file_cache
95 DFLT_APACHE_MODULES+=   cache disk_cache mem_cache bucketeer echo
96 DFLT_APACHE_MODULES+=   example case_filter case_filter_in
97 DFLT_APACHE_MODULES+=   charset_lite
98 DFLT_APACHE_MODULES+=   cgid dav_lock proxy_ajp proxy_balancer
99
100 PLIST_SRC+=             ${PKGDIR}/PLIST
101
102 .include "options.mk"
103
104 # LDAP support
105 PLIST_VARS+=            ldap
106 .if !empty(PKG_BUILD_OPTIONS.apr-util:Mldap)
107 DFLT_APACHE_MODULES+=   ldap authnz_ldap
108 .  if !empty(PKG_OPTIONS:Mapache-shared-modules)
109 PLIST.ldap=             yes
110 .  endif
111 .endif
112
113 APACHE_USER?=           www
114 APACHE_GROUP?=          www
115 PKG_GROUPS=             ${APACHE_GROUP}
116 PKG_USERS=              ${APACHE_USER}:${APACHE_GROUP}
117 PKG_GROUPS_VARS+=       APACHE_GROUP
118 PKG_USERS_VARS+=        APACHE_USER
119
120 PKG_SYSCONFVAR=         apache
121 PKG_SYSCONFSUBDIR?=     httpd
122 EGDIR=                  ${PREFIX}/share/examples/httpd
123 SBINDIR=                ${PREFIX}/sbin
124 CONF_FILES+=            ${EGDIR}/httpd.conf ${PKG_SYSCONFDIR}/httpd.conf
125 .for f in autoindex dav default info languages manual mpm \
126           multilang-errordoc ssl userdir vhosts
127 CONF_FILES+=            ${EGDIR}/extra/httpd-${f}.conf \
128                                 ${PKG_SYSCONFDIR}/httpd-${f}.conf
129 .endfor
130 CONF_FILES+=            ${EGDIR}/magic ${PKG_SYSCONFDIR}/magic
131 CONF_FILES+=            ${EGDIR}/mime.types ${PKG_SYSCONFDIR}/mime.types
132 RCD_SCRIPTS=            apache
133
134 REQD_DIRS=              ${PREFIX}/share/httpd
135 REQD_DIRS+=             ${PREFIX}/share/httpd/htdocs
136 OWN_DIRS=               ${VARBASE}/log/httpd
137 OWN_DIRS+=              ${VARBASE}/db/httpd
138 OWN_DIRS_PERMS+=        ${VARBASE}/db/httpd/proxy ${APACHE_USER} ${APACHE_GROUP} 0755
139 FIX_PERMS=              apachectl apxs dbmmanage envvars-std mkcert
140 FIX_MAN_PERMS=          man1/htdbm.1 man1/htpasswd.1 man1/htdigest.1
141 FIX_MAN_PERMS+=         man1/dbmmanage.1 man8/httpd.8 man8/suexec.8
142 FIX_MAN_PERMS+=         man8/rotatelogs.8 man8/logresolve.8 man8/apxs.8
143 FIX_MAN_PERMS+=         man8/apachectl.8 man8/ab.8
144
145 # Fix paths in the apache manpages.
146 SUBST_CLASSES+=         man
147 SUBST_STAGE.man=        post-patch
148 SUBST_FILES.man=        docs/man/*.1 docs/man/*.8
149 SUBST_SED.man=          -e 's,/usr/local/etc/apache,${PKG_SYSCONFDIR},'
150 SUBST_SED.man+=         -e 's,/path/to/apache/etc,${PKG_SYSCONFDIR},'
151 SUBST_SED.man+=         -e 's,/usr/local/apache2,${PREFIX}/share/httpd/htdocs,'
152 SUBST_SED.man+=         -e 's,/usr/web,${PREFIX}/share/httpd/htdocs,'
153
154 SUBST_CLASSES+=         paths
155 SUBST_STAGE.paths=      pre-configure
156 SUBST_FILES.paths=      config.layout Makefile.in support/apxs.in
157 SUBST_SED.paths=        -e "s|@PREFIX@|${PREFIX}|g"
158 SUBST_SED.paths+=       -e "s|@VARBASE@|${VARBASE}|g"
159 SUBST_SED.paths+=       -e "s|@SYSCONFDIR@|${PKG_SYSCONFDIR}|g"
160 SUBST_SED.paths+=       -e "s|@PAX@|${PAX}|g"
161 SUBST_SED.paths+=       -e "s|@LOCALBASE@|${LOCALBASE}|g"
162 SUBST_MESSAGE.paths=    Fixing paths.
163
164 SUBST_CLASSES+=         apr-lt
165 SUBST_STAGE.apr-lt=     post-configure
166 SUBST_FILES.apr-lt=     build/config_vars.mk
167 SUBST_SED.apr-lt=       -e 's|^\(LIBTOOL =\) [^ ]*|\1 $$(SHELL) $$(top_builddir)/build/libtool|g'
168 SUBST_MESSAGE.apr-lt=   Fixing libtool references.
169
170 SUBST_CLASSES+=         confs
171 SUBST_STAGE.confs=      post-configure
172 SUBST_MESSAGE.confs=    Fixing configuration files.
173 SUBST_FILES.confs=      docs/conf/httpd.conf
174 SUBST_FILES.confs+=     docs/conf/extra/httpd-ssl.conf
175 SUBST_SED.confs=        -e "s|${EGDIR}|${PKG_SYSCONFDIR}|g"
176 SUBST_SED.confs+=       -e "s|${PREFIX}/htdocs|${PREFIX}/share/httpd/htdocs|g"
177 SUBST_SED.confs+=       -e "s|${PREFIX}/conf|${PKG_SYSCONFDIR}|g"
178 SUBST_SED.confs+=       -e "s|logs/|${VARBASE}/log/httpd/|g"
179 SUBST_SED.confs+=       -e 's|/var/log/httpd/foo\.log|logs/foo.log/|g'
180 SUBST_SED.confs+=       -e 's|^\(User[   ]\).*|\1${APACHE_USER}|g'
181 SUBST_SED.confs+=       -e 's|^\(Group[  ]\).*|\1${APACHE_GROUP}|g'
182
183 # abs_srcdir in config_vars.mk is used during install so needs to reference
184 # the work dir path, and by other packages such as ap2-fastcgi after install,
185 # so we fix after install to reference the installed path
186 SUBST_CLASSES+=         abs_srcdir
187 SUBST_STAGE.abs_srcdir= post-install
188 SUBST_FILES.abs_srcdir= ${DESTDIR}${PREFIX}/share/httpd/build/config_vars.mk
189 SUBST_SED.abs_srcdir=   -e 's|^\(abs_srcdir =\) .*|\1 ${PREFIX}/share/httpd|'
190 SUBST_MESSAGE.abs_srcdir=       Fixing abs_srcdir
191
192 REPLACE_PERL=           docs/cgi-examples/printenv
193
194 # Add dependencies for the modules that will be built.  For each module
195 # ap_mod listed in ${APACHE_MODULES}, _AP_DEPENDS.ap_mod is a whitespace
196 # separated list of dependencies or buildlink3.mk files needed to build
197 # ap_mod, and _AP_CFG_ARGS.ap_mod is a whitespace separated list of
198 # configure script options for ap_mod.
199 #
200 AP_DEPENDS.ssl= ../../security/openssl/buildlink3.mk
201 AP_DEPENDS.deflate=     ../../devel/zlib/buildlink3.mk
202
203 AP_CFG_ARGS.ssl=        --with-ssl=${BUILDLINK_PREFIX.openssl}
204 AP_CFG_ARGS.deflate=    --with-z=${BUILDLINK_PREFIX.zlib}
205
206 #.if ${APACHE_MODULES} == "all-shared"
207 .if !empty(PKG_OPTIONS:Mapache-shared-modules)
208 .include "${AP_DEPENDS.ssl}"
209 .include "${AP_DEPENDS.deflate}"
210 CONFIGURE_ARGS+=        ${AP_CFG_ARGS.ssl} ${AP_CFG_ARGS.deflate}
211 .else
212 .for ap_mod in ${APACHE_MODULES}
213 .  if defined(AP_DEPENDS.${ap_mod}) && !empty(AP_DEPENDS.${ap_mod})
214 .    for ap_depend in ${AP_DEPENDS.${ap_mod}}
215 .      if exists(${ap_depend})
216 .        include "${ap_depend}"
217 .      else
218 DEPENDS+=               ${ap_depend}
219 .      endif
220 .    endfor
221 .  endif
222 .  if defined(AP_CFG_ARGS.${ap_mod}) && !empty(AP_CFG_ARGS.${ap_mod})
223 CONFIGURE_ARGS+=        ${AP_CFG_ARGS.${ap_mod}}
224 .  endif
225 .endfor
226 .endif
227
228 post-extract:
229         ${TOUCH} ${WRKSRC}/build/libtool
230         ${ECHO} "" >> ${WRKSRC}/docs/conf/extra/httpd-languages.conf.in
231
232 post-build:
233         ${SED} "s#@PKG_SYSCONFDIR@#${PKG_SYSCONFDIR}#g"                 \
234                 < ${FILESDIR}/mkcert.sh > ${WRKDIR}/mkcert
235
236 INSTALL_TARGET=         install-conf install
237 INSTALL_MAKE_FLAGS+=    sysconfdir="${EGDIR}"
238
239 post-install:
240         ${LN} -sf ${LOCALBASE}/libexec/apr/libtool ${DESTDIR}${PREFIX}/share/httpd/build
241         cd ${DESTDIR}${EGDIR} &&                                        \
242         for file in                                                     \
243                 httpd.conf                                              \
244                 extra/httpd-ssl.conf;                                   \
245         do                                                              \
246                 ${AWK} '                                                \
247                         /^Listen[       ]*80/   {                       \
248                                 printf "%s", "Listen 0.0.0.0:80\n";     \
249                                 next;                                   \
250                         }                                               \
251                         /^Listen[       ]*443/  {                       \
252                                 printf "%s", "Listen 0.0.0.0:443\n";    \
253                                 next;                                   \
254                         }                                               \
255                         { print; }                                      \
256                         ' < "$${file}" >> $${file}.new;                 \
257                 ${MV} -f $${file}.new $${file};                         \
258         done
259
260         ${LN} -sf ${SBINDIR}/envvars-std ${DESTDIR}${SBINDIR}/envvars
261
262         ${INSTALL_SCRIPT} ${WRKDIR}/mkcert ${DESTDIR}${PREFIX}/sbin
263
264         for file in ${FIX_PERMS}; do \
265                 ${CHOWN} ${BINOWN}:${BINGRP} ${DESTDIR}${PREFIX}/sbin/$$file && \
266                 ${CHMOD} ${BINMODE} ${DESTDIR}${PREFIX}/sbin/$$file; \
267         done
268
269         ${CHOWN} -R ${BINOWN}:${BINGRP} ${DESTDIR}${PREFIX}/share/httpd
270         ${CHOWN} -R ${BINOWN}:${BINGRP} ${DESTDIR}${PREFIX}/include/httpd
271         ${CHOWN} -R ${BINOWN}:${BINGRP} ${DESTDIR}${PREFIX}/lib/httpd
272         ${CHOWN} ${BINOWN}:${BINGRP} ${DESTDIR}${PREFIX}/libexec/cgi-bin/test-cgi
273         ${CHOWN} ${BINOWN}:${BINGRP} ${DESTDIR}${PREFIX}/libexec/cgi-bin/printenv
274
275         for file in ${FIX_MAN_PERMS}; do \
276                 ${CHOWN} ${MANOWN}:${MANGRP} ${DESTDIR}${PREFIX}/${PKGMANDIR}/$$file; \
277         done
278
279         ${CHMOD} -x ${DESTDIR}${PREFIX}/sbin/envvars-std
280         ${TEST} ! -f ${DESTDIR}${PREFIX}/sbin/suexec || ${CHMOD} -w ${DESTDIR}${PREFIX}/sbin/suexec
281
282 .include "../../mk/bsd.pkg.mk"