Add files from parent branch HEAD:
[pkgsrc.git] / www / apache2 / Makefile
1 # $NetBSD: Makefile,v 1.126 2008/08/09 20:33:37 kefren Exp $
2
3 .include "Makefile.common"
4
5 PKGNAME=        apache-${APACHE_VERSION}
6 PKGREVISION=    4
7 CATEGORIES=     www
8
9 HOMEPAGE=       http://httpd.apache.org/
10 COMMENT=        Apache HTTP (Web) server, version 2
11
12 CONFLICTS=      apache-*ssl-[0-9]* apache6-[0-9]*
13
14 BUILD_DEFS+=    IPV6_READY
15 BUILD_DEFS+=    VARBASE
16
17 USE_TOOLS+=             pax perl perl:run pkg-config
18 USE_LIBTOOL=            yes
19 GNU_CONFIGURE=          yes
20 CONFIGURE_ARGS+=        --enable-layout=NetBSD
21 CONFIGURE_ARGS+=        --with-port=80
22 CONFIGURE_ARGS+=        --enable-so
23 CONFIGURE_ENV+=         perlbin=${PERL5:Q}
24
25 # Apache Portable Runtime library configure options
26 CONFIGURE_ARGS+=        --with-apr=${BUILDLINK_PREFIX.apr}
27 CONFIGURE_ARGS+=        --with-apr-util=${BUILDLINK_PREFIX.apr}
28
29 .include "../../devel/apr0/buildlink3.mk"
30 BUILDLINK_API_DEPENDS.apr+=     apr>=0.9.12.2.0.58
31
32 # the following must be set before bsd.prefs.mk in order to make += work
33 # in mk.conf; however, it isn't expanded until referenced, so we can
34 # define DFLT_APACHE_MODULES later
35 #
36 APACHE_MODULES?=        ${DFLT_APACHE_MODULES}
37
38 .include "../../mk/bsd.prefs.mk"
39 .include "../../textproc/expat/buildlink3.mk"
40 .include "../../mk/dlopen.buildlink3.mk"
41
42 # Set the "Multi-Processing Model" used by Apache to handle requests.
43 # Valid values are:
44 #       prefork         non-threaded, pre-forking web server
45 #       worker          hybrid multi-threaded multi-process web server
46 #
47 APACHE_MPM?=            prefork
48 CONFIGURE_ARGS+=        --with-mpm=${APACHE_MPM:Q}
49 BUILD_DEFS+=            APACHE_MPM
50 PLIST_VARS+=            mpm-prefork mpm-worker
51 PLIST.${APACHE_MPM}=    yes
52
53 CONFIGURE_ARGS+=        --disable-access
54 CONFIGURE_ARGS+=        --disable-auth
55 CONFIGURE_ARGS+=        --disable-include
56 CONFIGURE_ARGS+=        --disable-log-config
57 CONFIGURE_ARGS+=        --disable-env
58 CONFIGURE_ARGS+=        --disable-mime
59 CONFIGURE_ARGS+=        --disable-setenvif
60 CONFIGURE_ARGS+=        --disable-status
61 CONFIGURE_ARGS+=        --disable-autoindex
62 CONFIGURE_ARGS+=        --disable-asis
63 CONFIGURE_ARGS+=        --disable-cgi
64 CONFIGURE_ARGS+=        --disable-negotiation
65 CONFIGURE_ARGS+=        --disable-dir
66 CONFIGURE_ARGS+=        --disable-imap
67 CONFIGURE_ARGS+=        --disable-actions
68 CONFIGURE_ARGS+=        --disable-userdir
69 CONFIGURE_ARGS+=        --disable-alias
70
71 DFLT_APACHE_MODULES=    all
72 DFLT_APACHE_MODULES+=   proxy proxy_connect proxy_ftp proxy_http
73 DFLT_APACHE_MODULES+=   ssl deflate
74 DFLT_APACHE_MODULES+=   access auth include log_config env mime setenvif
75 DFLT_APACHE_MODULES+=   status autoindex asis cgi negotiation dir imap
76 DFLT_APACHE_MODULES+=   actions userdir alias
77
78 # LDAP support
79 .if !empty(PKG_BUILD_OPTIONS.apr:Mldap)
80 DFLT_APACHE_MODULES+=   ldap auth_ldap
81 .endif
82
83 # APACHE_MODULES are the modules that are linked statically into the
84 # apache httpd executable.
85 #
86 CONFIGURE_ARGS+=        --enable-modules=${APACHE_MODULES:Q}
87 BUILD_DEFS+=            APACHE_MODULES
88
89 APACHE_USER?=           www
90 APACHE_GROUP?=          www
91 PKG_GROUPS=             ${APACHE_GROUP}
92 PKG_USERS=              ${APACHE_USER}:${APACHE_GROUP}
93 PKG_GROUPS_VARS+=       APACHE_GROUP
94 PKG_USERS_VARS+=        APACHE_USER
95
96 PKG_SYSCONFVAR=         apache
97 PKG_SYSCONFSUBDIR?=     httpd
98 EGDIR=                  ${PREFIX}/share/examples/httpd
99 SBINDIR=                ${PREFIX}/sbin
100 CONF_FILES=             ${EGDIR}/httpd-std.conf ${PKG_SYSCONFDIR}/httpd.conf
101 CONF_FILES+=            ${EGDIR}/ssl-std.conf ${PKG_SYSCONFDIR}/ssl.conf
102 CONF_FILES+=            ${SBINDIR}/envvars-std ${SBINDIR}/envvars
103 CONF_FILES+=            ${EGDIR}/magic ${PKG_SYSCONFDIR}/magic
104 CONF_FILES+=            ${EGDIR}/mime.types ${PKG_SYSCONFDIR}/mime.types
105 RCD_SCRIPTS=            apache
106
107 REQD_DIRS=              ${PREFIX}/share/httpd
108 REQD_DIRS+=             ${PREFIX}/share/httpd/htdocs
109 OWN_DIRS=       ${VARBASE}/log/httpd
110 OWN_DIRS+=              ${VARBASE}/db/httpd
111 OWN_DIRS_PERMS+=        ${VARBASE}/db/httpd/proxy ${APACHE_USER} ${APACHE_GROUP} 0755
112 FIX_PERMS=              apachectl apxs dbmmanage envvars-std mkcert
113 FIX_MAN_PERMS=          man1/htdbm.1 man1/htpasswd.1 man1/htdigest.1
114 FIX_MAN_PERMS+=         man1/dbmmanage.1 man8/httpd.8 man8/suexec.8
115 FIX_MAN_PERMS+=         man8/rotatelogs.8 man8/logresolve.8 man8/apxs.8
116 FIX_MAN_PERMS+=         man8/apachectl.8 man8/ab.8
117
118 # Fix paths in the apache manpages.
119 SUBST_CLASSES+=         man
120 SUBST_STAGE.man=        post-patch
121 SUBST_FILES.man=        docs/man/*.1 docs/man/*.8
122 SUBST_SED.man=          -e 's,/usr/local/etc/apache,${PKG_SYSCONFDIR},'
123 SUBST_SED.man+=         -e 's,/path/to/apache/etc,${PKG_SYSCONFDIR},'
124 SUBST_SED.man+=         -e 's,/usr/local/apache2,${PREFIX}/share/httpd/htdocs,'
125 SUBST_SED.man+=         -e 's,/usr/web,${PREFIX}/share/httpd/htdocs,'
126
127 SUBST_CLASSES+=         paths
128 SUBST_STAGE.paths=      pre-configure
129 SUBST_FILES.paths=      config.layout
130 SUBST_SED.paths=        -e "s|@PREFIX@|${PREFIX}|g"
131 SUBST_SED.paths+=       -e "s|@VARBASE@|${VARBASE}|g"
132 SUBST_SED.paths+=       -e "s|@SYSCONFDIR@|${PKG_SYSCONFDIR}|g"
133 SUBST_MESSAGE.paths=    Fixing paths.
134
135 SUBST_CLASSES+=         apr-lt
136 SUBST_STAGE.apr-lt=     post-configure
137 SUBST_FILES.apr-lt=     build/config_vars.mk
138 SUBST_SED.apr-lt=       -e 's|^\(LIBTOOL =\) [^ ]*|\1 $$(SHELL) $$(top_builddir)/build/libtool|g'
139 SUBST_MESSAGE.apr-lt=   Fixing libtool references.
140
141 SUBST_CLASSES+=         confs
142 SUBST_STAGE.confs=      post-configure
143 SUBST_MESSAGE.confs=    Fixing configuration files.
144 SUBST_FILES.confs=      docs/conf/highperformance-std.conf
145 SUBST_FILES.confs+=     docs/conf/httpd-std.conf
146 SUBST_FILES.confs+=     docs/conf/ssl-std.conf
147 SUBST_SED.confs=        -e "s|${EGDIR}|${PKG_SYSCONFDIR}|g"
148 SUBST_SED.confs+=       -e "s|${PREFIX}/htdocs|${PREFIX}/share/httpd/htdocs|g"
149 SUBST_SED.confs+=       -e "s|${PREFIX}/conf|${PKG_SYSCONFDIR}|g"
150 SUBST_SED.confs+=       -e "s|logs/|${VARBASE}/log/httpd/|g"
151 SUBST_SED.confs+=       -e 's|/var/log/httpd/foo\.log|logs/foo.log/|g'
152 SUBST_SED.confs+=       -e 's|^\(User[   ]\).*|\1${APACHE_USER}|g'
153 SUBST_SED.confs+=       -e 's|^\(Group[  ]\).*|\1${APACHE_GROUP}|g'
154
155 # abs_srcdir in config_vars.mk is used during install so needs to reference
156 # the work dir path, and by other packages such as ap2-fastcgi after install,
157 # so we fix after install to reference the installed path
158 SUBST_CLASSES+=         abs_srcdir
159 SUBST_STAGE.abs_srcdir= post-install
160 SUBST_FILES.abs_srcdir= ${PREFIX}/share/httpd/build/config_vars.mk
161 SUBST_SED.abs_srcdir=   -e 's|^\(abs_srcdir =\) .*|\1 ${PREFIX}/share/httpd|'
162 SUBST_MESSAGE.abs_srcdir=       Fixing abs_srcdir
163
164 REPLACE_PERL=           docs/cgi-examples/printenv
165
166 .include "options.mk"
167
168 # Add dependencies for the modules that will be built.  For each module
169 # ap_mod listed in ${APACHE_MODULES}, _AP_DEPENDS.ap_mod is a whitespace
170 # separated list of dependencies or buildlink3.mk files needed to build
171 # ap_mod, and _AP_CFG_ARGS.ap_mod is a whitespace separated list of
172 # configure script options for ap_mod.
173 #
174 AP_DEPENDS.ssl= ../../security/openssl/buildlink3.mk
175 AP_DEPENDS.deflate=     ../../devel/zlib/buildlink3.mk
176
177 AP_CFG_ARGS.ssl=        --with-ssl=${BUILDLINK_PREFIX.openssl}
178 AP_CFG_ARGS.deflate=    --with-z=${BUILDLINK_PREFIX.zlib}
179
180 .for ap_mod in ${APACHE_MODULES}
181 .  if defined(AP_DEPENDS.${ap_mod}) && !empty(AP_DEPENDS.${ap_mod})
182 .    for ap_depend in ${AP_DEPENDS.${ap_mod}}
183 .      if exists(${ap_depend})
184 .        include "${ap_depend}"
185 .      else
186 DEPENDS+=               ${ap_depend}
187 .      endif
188 .    endfor
189 .  endif
190 .  if defined(AP_CFG_ARGS.${ap_mod}) && !empty(AP_CFG_ARGS.${ap_mod})
191 CONFIGURE_ARGS+=        ${AP_CFG_ARGS.${ap_mod}}
192 .  endif
193 .endfor
194
195 post-extract:
196         ${TOUCH} ${WRKSRC}/build/libtool
197
198 post-build:
199         ${SED} "s#@PKG_SYSCONFDIR@#${PKG_SYSCONFDIR}#g"                 \
200                 < ${FILESDIR}/mkcert.sh > ${WRKDIR}/mkcert
201
202 pre-install:
203         cd ${WRKSRC} && ${SETENV} ${MAKE_ENV}                           \
204                 ${MAKE_PROGRAM} install-conf sysconfdir="${EGDIR}"
205
206 post-install:
207         ${LN} -sf ${LOCALBASE}/libexec/apr/libtool ${PREFIX}/share/httpd/build
208         cd ${EGDIR} &&                                                  \
209         for file in                                                     \
210                 highperformance-std.conf                                \
211                 httpd-std.conf                                          \
212                 ssl-std.conf;                                           \
213         do                                                              \
214                 ${AWK} '                                                \
215                         /^Listen[       ]*80/   {                       \
216                                 printf "%s", "Listen 0.0.0.0:80\n";     \
217                                 next;                                   \
218                         }                                               \
219                         /^Listen[       ]*443/  {                       \
220                                 printf "%s", "Listen 0.0.0.0:443\n";    \
221                                 next;                                   \
222                         }                                               \
223                         { print; }                                      \
224                         ' < "$${file}" >> $${file}.new;                 \
225                 ${MV} -f $${file}.new $${file};                         \
226         done
227
228         ${INSTALL_DATA_DIR} ${PREFIX}/share/httpd/manual
229         cd ${WRKSRC}/docs/manual && pax -rw . ${PREFIX}/share/httpd/manual
230
231         ${INSTALL_SCRIPT} ${WRKDIR}/mkcert ${PREFIX}/sbin
232
233         for file in ${FIX_PERMS}; do \
234                 ${CHOWN} ${BINOWN}:${BINGRP} ${PREFIX}/sbin/$$file && \
235                 ${CHMOD} ${BINMODE} ${PREFIX}/sbin/$$file; \
236         done
237
238         ${CHOWN} -R ${BINOWN}:${BINGRP} ${PREFIX}/share/httpd
239         ${CHOWN} -R ${BINOWN}:${BINGRP} ${PREFIX}/include/httpd
240         ${CHOWN} -R ${BINOWN}:${BINGRP} ${PREFIX}/lib/httpd
241         ${CHOWN} ${BINOWN}:${BINGRP} ${PREFIX}/libexec/cgi-bin/test-cgi
242         ${CHOWN} ${BINOWN}:${BINGRP} ${PREFIX}/libexec/cgi-bin/printenv
243
244         for file in ${FIX_MAN_PERMS}; do \
245                 ${CHOWN} ${MANOWN}:${MANGRP} ${PREFIX}/${PKGMANDIR}/$$file; \
246         done
247
248         ${INSTALL_SCRIPT} ${WRKSRC}/build/mkdir.sh ${PREFIX}/share/httpd/build
249
250 .include "../../mk/bsd.pkg.mk"