Tweak sysutils/healthd version 0.7.9_2
[dports.git] / Mk / bsd.php.mk
1 #
2 # bsd.php.mk - Support for PHP-based ports.
3 #
4 # Created by: Alex Dupre <ale@FreeBSD.org>
5 #
6 # For FreeBSD committers:
7 # Please send all suggested changes to the maintainer instead of committing
8 # them to SVN yourself.
9 #
10 # $FreeBSD$
11 #
12 # Adding 'USE_PHP=yes' to a port includes this Makefile after bsd.ports.pre.mk.
13 # If the port requires a predefined set of PHP extensions, they can be
14 # listed in this way:
15 #
16 # USE_PHP=      ext1 ext2 ext3
17 #
18 # The port can set these options in its Makefile before bsd.port.pre.mk:
19 #
20 # DEFAULT_PHP_VER=N - Use PHP version N if PHP is not yet installed.
21 # IGNORE_WITH_PHP=N - The port doesn't work with PHP version N.
22 # USE_PHPIZE=yes    - Use to build a PHP extension.
23 # USE_PHPEXT=yes    - Use to build, install and register a PHP extension.
24 # USE_ZENDEXT=yes   - Use to build, install and register a Zend extension.
25 # USE_PHP_BUILD=yes - Set PHP also as a build dependency.
26 # WANT_PHP_CLI=yes  - Want the CLI version of PHP.
27 # WANT_PHP_CGI=yes  - Want the CGI version of PHP.
28 # WANT_PHP_MOD=yes  - Want the Apache Module for PHP.
29 # WANT_PHP_WEB=yes  - Want the Apache Module or the CGI version of PHP.
30 # WANT_PHP_EMB=yes  - Want the embedded library version of PHP.
31 #
32 # You may combine multiple WANT_PHP_* knobs.
33 # Don't specify any WANT_PHP_* knob if your port will work with every PHP SAPI.
34 #
35
36 .if !defined(_PHPMKINCLUDED)
37
38 PHP_Include_MAINTAINER= ale@FreeBSD.org
39
40 _PHPMKINCLUDED= yes
41
42 .include "${PORTSDIR}/Mk/bsd.default-versions.mk"
43
44 .if defined(DEFAULT_PHP_VER)
45 WARNING+=       "DEFAULT_PHP_VER is defined, consider using DEFAULT_VERSIONS=php=${DEFAULT_PHP_VER} instead"
46 .endif
47
48 PHPBASE?=       ${LOCALBASE}
49 .if exists(${PHPBASE}/etc/php.conf)
50 .include "${PHPBASE}/etc/php.conf"
51 PHP_EXT_DIR!=   ${PHPBASE}/bin/php-config --extension-dir | ${SED} -ne 's,^${PHPBASE}/lib/php/\(.*\),\1,p'
52
53 .else
54 DEFAULT_PHP_VER?=       ${PHP_DEFAULT:S/.//}
55
56 PHP_VER?=       ${DEFAULT_PHP_VER}
57 .if ${PHP_VER}  == 53
58 PHP_EXT_DIR=    20090626
59 PHP_EXT_INC=    pcre spl
60 .elif ${PHP_VER}  == 56
61 PHP_EXT_DIR=    20131226
62 PHP_EXT_INC=    pcre spl
63 .elif ${PHP_VER}  == 55
64 PHP_EXT_DIR=    20121212
65 PHP_EXT_INC=    pcre spl
66 .elif ${PHP_VER}  == 54
67 PHP_VER=        5
68 PHP_EXT_DIR=    20100525
69 PHP_EXT_INC=    pcre spl
70 .else
71 PHP_EXT_DIR=    20100525
72 PHP_EXT_INC=    pcre spl
73 .endif
74
75 HTTPD?=         ${LOCALBASE}/sbin/httpd
76 .if exists(${HTTPD})
77 APACHE_THR!=    ${HTTPD} -V | ${GREP} threaded
78 .       if ${APACHE_THR:Myes}
79 PHP_EXT_DIR:=   ${PHP_EXT_DIR}-zts
80 .       endif
81 .elif defined(APACHE_PORT) && (${APACHE_PORT:M*worker*} != "" || ${APACHE_PORT:M*event*} != "")
82 PHP_EXT_DIR:=   ${PHP_EXT_DIR}-zts
83 .elif defined(WITH_MPM) && (${WITH_MPM} == "worker" || ${WITH_MPM} == "event")
84 PHP_EXT_DIR:=   ${PHP_EXT_DIR}-zts
85 .endif
86
87 .if defined(WITH_DEBUG)
88 PHP_EXT_DIR:=   ${PHP_EXT_DIR}-debug
89 .endif
90 PHP_SAPI?=      ""
91 .endif  # .if exists(${PHPBASE}/etc/php.conf)
92 PHP_EXT_INC?=   ""
93
94 PHP5_LAST_VER=  54
95
96 .if defined(IGNORE_WITH_PHP)
97 .       for VER in ${IGNORE_WITH_PHP}
98 .               if ${PHP_VER} == "${VER}"
99 IGNORE=         cannot be installed: doesn't work with lang/php${PHP_VER} port\
100                 (doesn't support PHP ${IGNORE_WITH_PHP:C/^5$/${PHP5_LAST_VER}/:C/^5/5./})
101 .               endif
102 .       endfor
103 .endif
104
105 .if defined(WANT_PHP_WEB)
106 .       if defined(WANT_PHP_CGI) || defined(WANT_PHP_MOD)
107 check-makevars::
108                 @${ECHO_CMD} "If you define WANT_PHP_WEB you cannot set also WANT_PHP_CGI"
109                 @${ECHO_CMD} "or WANT_PHP_MOD. Use only one of them."
110                 @${FALSE}
111 .       elif defined(PHP_VERSION) && ${PHP_VER} == 53 && ${PHP_SAPI:Mcgi} == "" && ${PHP_SAPI:Mfpm} == "" && ${PHP_SAPI:Mmod} == ""
112 check-makevars::
113                 @${ECHO_CMD} "This port requires the Apache Module or the CGI version of PHP, but you have"
114                 @${ECHO_CMD} "already installed a PHP port without them."
115                 @${FALSE}
116 .       endif
117 .endif
118
119 .if defined(WANT_PHP_CGI)
120 .       if defined(PHP_VERSION) && ${PHP_SAPI:Mcgi} == "" && ${PHP_SAPI:Mfpm} == ""
121 check-makevars::
122                 @${ECHO_CMD} "This port requires the CGI version of PHP, but you have already"
123                 @${ECHO_CMD} "installed a PHP port without CGI."
124                 @${FALSE}
125 .       endif
126 .endif
127
128 .if defined(WANT_PHP_CLI)
129 .       if defined(PHP_VERSION) && ${PHP_SAPI:Mcli} == ""
130 check-makevars::
131                 @${ECHO_CMD} "This port requires the CLI version of PHP, but you have already"
132                 @${ECHO_CMD} "installed a PHP port without CLI."
133                 @${FALSE}
134 .       endif
135 .endif
136
137 .if defined(WANT_PHP_MOD)
138 .       if defined(PHP_VERSION) && ${PHP_VER} == 53 && ${PHP_SAPI:Mmod} == ""
139 check-makevars::
140                 @${ECHO_CMD} "This port requires the Apache Module for PHP, but you have already"
141                 @${ECHO_CMD} "installed a PHP port without the Apache Module."
142                 @${FALSE}
143 .       endif
144 .endif
145
146 .if defined(WANT_PHP_EMB)
147 .       if defined(PHP_VERSION) && ${PHP_SAPI:Membed} == ""
148 check-makevars::
149                 @${ECHO_CMD} "This port requires the embedded library version of PHP, but you have already"
150                 @${ECHO_CMD} "installed a PHP port without the embedded library."
151                 @${FALSE}
152 .       endif
153 .endif
154
155 PHP_PORT?=      lang/php${PHP_VER}
156 .if ${PHP_VER} == 53
157 MOD_PHP_PORT?=  ${PHP_PORT}
158 .else
159 MOD_PHP_PORT?=  www/mod_php${PHP_VER}
160 .endif
161
162 .if defined(USE_PHP_BUILD)
163 BUILD_DEPENDS+= ${PHPBASE}/include/php/main/php.h:${PORTSDIR}/${PHP_PORT}
164 .endif
165 RUN_DEPENDS+=   ${PHPBASE}/include/php/main/php.h:${PORTSDIR}/${PHP_PORT}
166 .if defined(WANT_PHP_MOD) || (defined(WANT_PHP_WEB) && defined(PHP_VERSION) && ${PHP_SAPI:Mcgi} == "" && ${PHP_SAPI:Mfpm} == "")
167 USE_APACHE_RUN= 22+
168 .include "${PORTSDIR}/Mk/bsd.apache.mk"
169 RUN_DEPENDS+=   ${PHPBASE}/${APACHEMODDIR}/libphp5.so:${PORTSDIR}/${MOD_PHP_PORT}
170 .endif
171
172 PLIST_SUB+=     PHP_EXT_DIR=${PHP_EXT_DIR}
173 SUB_LIST+=      PHP_EXT_DIR=${PHP_EXT_DIR}
174
175 .if defined(USE_PHPIZE) || defined(USE_PHPEXT) || defined(USE_ZENDEXT)
176 BUILD_DEPENDS+= ${PHPBASE}/bin/phpize:${PORTSDIR}/${PHP_PORT}
177 GNU_CONFIGURE=  yes
178 USE_AUTOTOOLS+= autoconf:env
179 CONFIGURE_ARGS+=--with-php-config=${PHPBASE}/bin/php-config
180
181 configure-message: phpize-message do-phpize
182
183 phpize-message:
184         @${ECHO_MSG} "===>  PHPizing for ${PKGNAME}"
185
186 do-phpize:
187         @(cd ${WRKSRC}; ${SETENV} ${SCRIPTS_ENV} ${PHPBASE}/bin/phpize)
188 .endif
189
190 .endif
191
192 .if defined(_POSTMKINCLUDED) && (defined(USE_PHPEXT) || defined(USE_ZENDEXT))
193 PHP_MODNAME?=   ${PORTNAME}
194 PHP_HEADER_DIRS?=       ""
195
196 do-install:
197         @${MKDIR} ${STAGEDIR}${PREFIX}/lib/php/${PHP_EXT_DIR}
198         @${INSTALL_DATA} ${WRKSRC}/modules/${PHP_MODNAME}.so \
199                 ${STAGEDIR}${PREFIX}/lib/php/${PHP_EXT_DIR}
200 .       for header in . ${PHP_HEADER_DIRS}
201                 @${MKDIR} ${STAGEDIR}${PREFIX}/include/php/ext/${PHP_MODNAME}/${header}
202                 @${INSTALL_DATA} ${WRKSRC}/${header}/*.h \
203                         ${STAGEDIR}${PREFIX}/include/php/ext/${PHP_MODNAME}/${header}
204 .       endfor
205         @${RM} -f ${STAGEDIR}${PREFIX}/include/php/ext/${PHP_MODNAME}/config.h
206         @${GREP} "#define \(COMPILE\|HAVE\|USE\)_" ${WRKSRC}/config.h \
207                 > ${STAGEDIR}${PREFIX}/include/php/ext/${PHP_MODNAME}/config.h
208         @${MKDIR} ${STAGEDIR}${PREFIX}/etc/php
209
210 add-plist-info: add-plist-phpext
211 add-plist-phpext:
212         @${ECHO_CMD} "lib/php/${PHP_EXT_DIR}/${PHP_MODNAME}.so" \
213                 >> ${TMPPLIST}
214         @${FIND} -P ${STAGEDIR}${PREFIX}/include/php/ext/${PHP_MODNAME} ! -type d 2>/dev/null | \
215                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
216         @${ECHO_CMD} "@exec echo \#include \\\"ext/${PHP_MODNAME}/config.h\\\" >> %D/include/php/ext/php_config.h" \
217                 >> ${TMPPLIST}
218         @${ECHO_CMD} "@unexec cp %D/include/php/ext/php_config.h %D/include/php/ext/php_config.h.orig" \
219                 >> ${TMPPLIST}
220         @${ECHO_CMD} "@unexec grep -v ext/${PHP_MODNAME}/config.h %D/include/php/ext/php_config.h.orig > %D/include/php/ext/php_config.h || true" \
221                 >> ${TMPPLIST}
222         @${ECHO_CMD} "@unexec rm %D/include/php/ext/php_config.h.orig" \
223                 >> ${TMPPLIST}
224         @${ECHO_CMD} "@dir etc/php" \
225                 >> ${TMPPLIST}
226 .if defined(USE_ZENDEXT)
227         @${ECHO_CMD} "@exec echo zend_extension=%D/lib/php/${PHP_EXT_DIR}/${PHP_MODNAME}.so >> %D/etc/php/extensions.ini" \
228                 >> ${TMPPLIST}
229 .else
230         @${ECHO_CMD} "@exec echo extension=${PHP_MODNAME}.so >> %D/etc/php/extensions.ini" \
231                 >> ${TMPPLIST}
232 .endif
233         @${ECHO_CMD} "@unexec cp %D/etc/php/extensions.ini %D/etc/php/extensions.ini.orig" \
234                 >> ${TMPPLIST}
235 .if defined(USE_ZENDEXT)
236         @${ECHO_CMD} "@unexec grep -v zend_extension=%D/lib/php/${PHP_EXT_DIR}/${PHP_MODNAME}\\\.so %D/etc/php/extensions.ini.orig > %D/etc/php/extensions.ini || true" \
237                 >> ${TMPPLIST}
238 .else
239         @${ECHO_CMD} "@unexec grep -v extension=${PHP_MODNAME}\\\.so %D/etc/php/extensions.ini.orig > %D/etc/php/extensions.ini || true" \
240                 >> ${TMPPLIST}
241 .endif
242         @${ECHO_CMD} "@unexec rm %D/etc/php/extensions.ini.orig" \
243                 >> ${TMPPLIST}
244         @${ECHO_CMD} "@unexec [ -s %D/etc/php/extensions.ini ] || rm %D/etc/php/extensions.ini" \
245                 >> ${TMPPLIST}
246
247 package-message: php-ini
248
249 php-ini:
250         @${ECHO_CMD} "****************************************************************************"
251         @${ECHO_CMD} ""
252         @${ECHO_CMD} "The following line has been added to your ${PREFIX}/etc/php/extensions.ini"
253         @${ECHO_CMD} "configuration file to automatically load the installed extension:"
254         @${ECHO_CMD} ""
255 .if defined(USE_ZENDEXT)
256         @${ECHO_CMD} "zend_extension=${PREFIX}/lib/php/${PHP_EXT_DIR}/${PHP_MODNAME}.so"
257 .else
258         @${ECHO_CMD} "extension=${PHP_MODNAME}.so"
259 .endif
260         @${ECHO_CMD} ""
261         @${ECHO_CMD} "****************************************************************************"
262 .endif
263
264 # Extensions
265 .if defined(_POSTMKINCLUDED) && ${USE_PHP:tl} != "yes"
266 # non-version specific components
267 _USE_PHP_ALL=   apc bcmath bitset bz2 calendar ctype curl dba dom \
268                 exif fileinfo filter ftp gd gettext gmp \
269                 hash iconv igbinary imap interbase intl json ldap mbstring mcrypt \
270                 memcache mssql mysql mysqli odbc opcache \
271                 openssl pcntl pcre pdf pdo pdo_dblib pdo_firebird pdo_mysql \
272                 pdo_odbc pdo_pgsql pdo_sqlite pgsql posix \
273                 pspell radius readline recode session shmop simplexml snmp soap\
274                 sockets spl sybase_ct sysvmsg sysvsem sysvshm \
275                 tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib
276 # version specific components
277 _USE_PHP_VER5=  ${_USE_PHP_ALL} phar sqlite3
278 _USE_PHP_VER53= ${_USE_PHP_ALL} phar sqlite sqlite3
279 _USE_PHP_VER55= ${_USE_PHP_ALL} phar sqlite3
280 _USE_PHP_VER56= ${_USE_PHP_ALL} phar sqlite3
281
282 apc_DEPENDS=    www/pecl-APC
283 bcmath_DEPENDS= math/php${PHP_VER}-bcmath
284 bitset_DEPENDS= math/pecl-bitset
285 bz2_DEPENDS=    archivers/php${PHP_VER}-bz2
286 calendar_DEPENDS=       misc/php${PHP_VER}-calendar
287 ctype_DEPENDS=  textproc/php${PHP_VER}-ctype
288 curl_DEPENDS=   ftp/php${PHP_VER}-curl
289 dba_DEPENDS=    databases/php${PHP_VER}-dba
290 dbase_DEPENDS=  databases/php${PHP_VER}-dbase
291 dom_DEPENDS=    textproc/php${PHP_VER}-dom
292 exif_DEPENDS=   graphics/php${PHP_VER}-exif
293 fileinfo_DEPENDS=       sysutils/php${PHP_VER}-fileinfo
294 filter_DEPENDS= security/php${PHP_VER}-filter
295 ftp_DEPENDS=    ftp/php${PHP_VER}-ftp
296 gd_DEPENDS=     graphics/php${PHP_VER}-gd
297 gettext_DEPENDS=devel/php${PHP_VER}-gettext
298 gmp_DEPENDS=    math/php${PHP_VER}-gmp
299 hash_DEPENDS=   security/php${PHP_VER}-hash
300 iconv_DEPENDS=  converters/php${PHP_VER}-iconv
301 igbinary_DEPENDS=       converters/pecl-igbinary
302 imap_DEPENDS=   mail/php${PHP_VER}-imap
303 interbase_DEPENDS=      databases/php${PHP_VER}-interbase
304 intl_DEPENDS=   devel/pecl-intl
305 json_DEPENDS=   devel/php${PHP_VER}-json
306 ldap_DEPENDS=   net/php${PHP_VER}-ldap
307 mbstring_DEPENDS=       converters/php${PHP_VER}-mbstring
308 mcrypt_DEPENDS= security/php${PHP_VER}-mcrypt
309 memcache_DEPENDS=       databases/pecl-memcache
310 mhash_DEPENDS=  security/php${PHP_VER}-mhash
311 mssql_DEPENDS=  databases/php${PHP_VER}-mssql
312 mysql_DEPENDS=  databases/php${PHP_VER}-mysql
313 mysqli_DEPENDS= databases/php${PHP_VER}-mysqli
314 ncurses_DEPENDS=devel/php${PHP_VER}-ncurses
315 odbc_DEPENDS=   databases/php${PHP_VER}-odbc
316 oci8_DEPENDS=   databases/php${PHP_VER}-oci8
317 .if ${PHP_VER} == 55 || ${PHP_VER} == 56
318 opcache_DEPENDS=        www/php${PHP_VER}-opcache
319 .else
320 opcache_DEPENDS=        www/pecl-zendopcache
321 .endif  
322 openssl_DEPENDS=security/php${PHP_VER}-openssl
323 pcntl_DEPENDS=  devel/php${PHP_VER}-pcntl
324 pcre_DEPENDS=   devel/php${PHP_VER}-pcre
325 pdf_DEPENDS=    print/pecl-pdflib
326 pdo_DEPENDS=    databases/php${PHP_VER}-pdo
327 pdo_dblib_DEPENDS=      databases/php${PHP_VER}-pdo_dblib
328 pdo_firebird_DEPENDS=   databases/php${PHP_VER}-pdo_firebird
329 pdo_mysql_DEPENDS=      databases/php${PHP_VER}-pdo_mysql
330 pdo_odbc_DEPENDS=       databases/php${PHP_VER}-pdo_odbc
331 pdo_pgsql_DEPENDS=      databases/php${PHP_VER}-pdo_pgsql
332 pdo_sqlite_DEPENDS=     databases/php${PHP_VER}-pdo_sqlite
333 pgsql_DEPENDS=  databases/php${PHP_VER}-pgsql
334 phar_DEPENDS=   archivers/php${PHP_VER}-phar
335 posix_DEPENDS=  sysutils/php${PHP_VER}-posix
336 pspell_DEPENDS= textproc/php${PHP_VER}-pspell
337 radius_DEPENDS= net/pecl-radius
338 readline_DEPENDS=       devel/php${PHP_VER}-readline
339 recode_DEPENDS= converters/php${PHP_VER}-recode
340 session_DEPENDS=www/php${PHP_VER}-session
341 shmop_DEPENDS=  devel/php${PHP_VER}-shmop
342 simplexml_DEPENDS=      textproc/php${PHP_VER}-simplexml
343 snmp_DEPENDS=   net-mgmt/php${PHP_VER}-snmp
344 soap_DEPENDS=   net/php${PHP_VER}-soap
345 sockets_DEPENDS=net/php${PHP_VER}-sockets
346 spl_DEPENDS=    devel/php${PHP_VER}-spl
347 sqlite_DEPENDS= databases/php${PHP_VER}-sqlite
348 sqlite3_DEPENDS=databases/php${PHP_VER}-sqlite3
349 sybase_ct_DEPENDS=      databases/php${PHP_VER}-sybase_ct
350 sysvmsg_DEPENDS=devel/php${PHP_VER}-sysvmsg
351 sysvsem_DEPENDS=devel/php${PHP_VER}-sysvsem
352 sysvshm_DEPENDS=devel/php${PHP_VER}-sysvshm
353 tidy_DEPENDS=   www/php${PHP_VER}-tidy
354 tokenizer_DEPENDS=      devel/php${PHP_VER}-tokenizer
355 wddx_DEPENDS=   textproc/php${PHP_VER}-wddx
356 xml_DEPENDS=    textproc/php${PHP_VER}-xml
357 xmlreader_DEPENDS=      textproc/php${PHP_VER}-xmlreader
358 xmlrpc_DEPENDS= net/php${PHP_VER}-xmlrpc
359 xmlwriter_DEPENDS=      textproc/php${PHP_VER}-xmlwriter
360 xsl_DEPENDS=    textproc/php${PHP_VER}-xsl
361 zip_DEPENDS=    archivers/php${PHP_VER}-zip
362 zlib_DEPENDS=   archivers/php${PHP_VER}-zlib
363
364 .       for extension in ${USE_PHP}
365 .               if ${_USE_PHP_VER${PHP_VER}:M${extension}} != ""
366 .                       if ${PHP_EXT_INC:M${extension}} == ""
367 .                               if defined(USE_PHP_BUILD)
368 BUILD_DEPENDS+= ${PHPBASE}/lib/php/${PHP_EXT_DIR}/${extension}.so:${PORTSDIR}/${${extension}_DEPENDS}
369 .                               endif
370 RUN_DEPENDS+=   ${PHPBASE}/lib/php/${PHP_EXT_DIR}/${extension}.so:${PORTSDIR}/${${extension}_DEPENDS}
371 .                       endif
372 .               else
373 ext=            ${extension}
374 .                       if ${ext} == "mhash"
375 .                               if defined(USE_PHP_BUILD)
376 BUILD_DEPENDS+= ${PHPBASE}/lib/php/${PHP_EXT_DIR}/hash.so:${PORTSDIR}/${hash_DEPENDS}
377 .                               endif
378 RUN_DEPENDS+=   ${PHPBASE}/lib/php/${PHP_EXT_DIR}/hash.so:${PORTSDIR}/${hash_DEPENDS}
379 .                       elif ${ext:tl} != "yes"
380 check-makevars::
381                         @${ECHO_CMD} "Unknown extension ${extension} for PHP ${PHP_VER}."
382                         @${FALSE}
383 .                       endif
384 .               endif
385 .       endfor
386 .endif