2 # bsd.php.mk - Support for PHP-based ports.
4 # Created by: Alex Dupre <ale@FreeBSD.org>
6 # For FreeBSD committers:
7 # Please send all suggested changes to the maintainer instead of committing
8 # them to SVN yourself.
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
16 # USE_PHP= ext1 ext2 ext3
18 # The port can set these options in its Makefile before bsd.port.pre.mk:
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.
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.
36 .if !defined(_PHPMKINCLUDED)
38 PHP_Include_MAINTAINER= ale@FreeBSD.org
42 .include "${PORTSDIR}/Mk/bsd.default-versions.mk"
44 .if defined(DEFAULT_PHP_VER)
45 WARNING+= "DEFAULT_PHP_VER is defined, consider using DEFAULT_VERSIONS=php=${DEFAULT_PHP_VER} instead"
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'
54 DEFAULT_PHP_VER?= ${PHP_DEFAULT:S/.//}
56 PHP_VER?= ${DEFAULT_PHP_VER}
60 .elif ${PHP_VER} == 56
63 .elif ${PHP_VER} == 55
66 .elif ${PHP_VER} == 54
75 HTTPD?= ${LOCALBASE}/sbin/httpd
77 APACHE_THR!= ${HTTPD} -V | ${GREP} threaded
78 . if ${APACHE_THR:Myes}
79 PHP_EXT_DIR:= ${PHP_EXT_DIR}-zts
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
87 .if defined(WITH_DEBUG)
88 PHP_EXT_DIR:= ${PHP_EXT_DIR}-debug
91 .endif # .if exists(${PHPBASE}/etc/php.conf)
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./})
105 .if defined(WANT_PHP_WEB)
106 . if defined(WANT_PHP_CGI) || defined(WANT_PHP_MOD)
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."
111 . elif defined(PHP_VERSION) && ${PHP_VER} == 53 && ${PHP_SAPI:Mcgi} == "" && ${PHP_SAPI:Mfpm} == "" && ${PHP_SAPI:Mmod} == ""
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."
119 .if defined(WANT_PHP_CGI)
120 . if defined(PHP_VERSION) && ${PHP_SAPI:Mcgi} == "" && ${PHP_SAPI:Mfpm} == ""
122 @${ECHO_CMD} "This port requires the CGI version of PHP, but you have already"
123 @${ECHO_CMD} "installed a PHP port without CGI."
128 .if defined(WANT_PHP_CLI)
129 . if defined(PHP_VERSION) && ${PHP_SAPI:Mcli} == ""
131 @${ECHO_CMD} "This port requires the CLI version of PHP, but you have already"
132 @${ECHO_CMD} "installed a PHP port without CLI."
137 .if defined(WANT_PHP_MOD)
138 . if defined(PHP_VERSION) && ${PHP_VER} == 53 && ${PHP_SAPI:Mmod} == ""
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."
146 .if defined(WANT_PHP_EMB)
147 . if defined(PHP_VERSION) && ${PHP_SAPI:Membed} == ""
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."
155 PHP_PORT?= lang/php${PHP_VER}
157 MOD_PHP_PORT?= ${PHP_PORT}
159 MOD_PHP_PORT?= www/mod_php${PHP_VER}
162 .if defined(USE_PHP_BUILD)
163 BUILD_DEPENDS+= ${PHPBASE}/include/php/main/php.h:${PORTSDIR}/${PHP_PORT}
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} == "")
168 .include "${PORTSDIR}/Mk/bsd.apache.mk"
169 RUN_DEPENDS+= ${PHPBASE}/${APACHEMODDIR}/libphp5.so:${PORTSDIR}/${MOD_PHP_PORT}
172 PLIST_SUB+= PHP_EXT_DIR=${PHP_EXT_DIR}
173 SUB_LIST+= PHP_EXT_DIR=${PHP_EXT_DIR}
175 .if defined(USE_PHPIZE) || defined(USE_PHPEXT) || defined(USE_ZENDEXT)
176 BUILD_DEPENDS+= ${PHPBASE}/bin/phpize:${PORTSDIR}/${PHP_PORT}
178 USE_AUTOTOOLS+= autoconf:env
179 CONFIGURE_ARGS+=--with-php-config=${PHPBASE}/bin/php-config
181 configure-message: phpize-message do-phpize
184 @${ECHO_MSG} "===> PHPizing for ${PKGNAME}"
187 @(cd ${WRKSRC}; ${SETENV} ${SCRIPTS_ENV} ${PHPBASE}/bin/phpize)
192 .if defined(_POSTMKINCLUDED) && (defined(USE_PHPEXT) || defined(USE_ZENDEXT))
193 PHP_MODNAME?= ${PORTNAME}
197 @${MKDIR} ${STAGEDIR}${PREFIX}/lib/php/${PHP_EXT_DIR}
198 @${INSTALL_LIB} ${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}
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
210 add-plist-info: add-plist-phpext
212 @${ECHO_CMD} "lib/php/${PHP_EXT_DIR}/${PHP_MODNAME}.so" \
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" \
218 @${ECHO_CMD} "@unexec cp %D/include/php/ext/php_config.h %D/include/php/ext/php_config.h.orig" \
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" \
222 @${ECHO_CMD} "@unexec rm %D/include/php/ext/php_config.h.orig" \
224 @${ECHO_CMD} "@dir etc/php" \
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" \
230 @${ECHO_CMD} "@exec echo extension=${PHP_MODNAME}.so >> %D/etc/php/extensions.ini" \
233 @${ECHO_CMD} "@unexec cp %D/etc/php/extensions.ini %D/etc/php/extensions.ini.orig" \
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" \
239 @${ECHO_CMD} "@unexec grep -v extension=${PHP_MODNAME}\\\.so %D/etc/php/extensions.ini.orig > %D/etc/php/extensions.ini || true" \
242 @${ECHO_CMD} "@unexec rm %D/etc/php/extensions.ini.orig" \
244 @${ECHO_CMD} "@unexec [ -s %D/etc/php/extensions.ini ] || rm %D/etc/php/extensions.ini" \
247 package-message: php-ini
250 @${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:"
255 .if defined(USE_ZENDEXT)
256 @${ECHO_CMD} "zend_extension=${PREFIX}/lib/php/${PHP_EXT_DIR}/${PHP_MODNAME}.so"
258 @${ECHO_CMD} "extension=${PHP_MODNAME}.so"
261 @${ECHO_CMD} "****************************************************************************"
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
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
320 opcache_DEPENDS= www/pecl-zendopcache
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
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}
370 RUN_DEPENDS+= ${PHPBASE}/lib/php/${PHP_EXT_DIR}/${extension}.so:${PORTSDIR}/${${extension}_DEPENDS}
374 . if ${ext} == "mhash"
375 . if defined(USE_PHP_BUILD)
376 BUILD_DEPENDS+= ${PHPBASE}/lib/php/${PHP_EXT_DIR}/hash.so:${PORTSDIR}/${hash_DEPENDS}
378 RUN_DEPENDS+= ${PHPBASE}/lib/php/${PHP_EXT_DIR}/hash.so:${PORTSDIR}/${hash_DEPENDS}
379 . elif ${ext:tl} != "yes"
381 @${ECHO_CMD} "Unknown extension ${extension} for PHP ${PHP_VER}."