e7b309815812523bfb8f39773eeecfdcd91e8533
[mjo-overlay.git] / dev-lang / php / php-5.6.4-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=5
6
7 inherit eutils autotools flag-o-matic versionator depend.apache apache-module db-use libtool systemd
8
9 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
10
11 function php_get_uri ()
12 {
13 case "${1}" in
14 "php-pre")
15 echo "http://downloads.php.net/dsp/${2}"
16 ;;
17 "php")
18 echo "http://www.php.net/distributions/${2}"
19 ;;
20 "olemarkus")
21 echo "http://dev.gentoo.org/~olemarkus/php/${2}"
22 ;;
23 "gentoo")
24 echo "mirror://gentoo/${2}"
25 ;;
26 *)
27 die "unhandled case in php_get_uri"
28 ;;
29 esac
30 }
31
32 PHP_MV="$(get_major_version)"
33 SLOT="$(get_version_component_range 1-2)"
34
35 # alias, so we can handle different types of releases (finals, rcs, alphas,
36 # betas, ...) w/o changing the whole ebuild
37 PHP_PV="${PV/_rc/RC}"
38 PHP_PV="${PHP_PV/_alpha/alpha}"
39 PHP_PV="${PHP_PV/_beta/beta}"
40 PHP_RELEASE="php"
41 [[ ${PV} == ${PV/_alpha/} ]] || PHP_RELEASE="php-pre"
42 [[ ${PV} == ${PV/_beta/} ]] || PHP_RELEASE="php-pre"
43 [[ ${PV} == ${PV/_rc/} ]] || PHP_RELEASE="php-pre"
44 PHP_P="${PN}-${PHP_PV}"
45
46 PHP_SRC_URI="$(php_get_uri "${PHP_RELEASE}" "${PHP_P}.tar.bz2")"
47
48 PHP_FPM_CONF_VER="1"
49
50 SRC_URI="${PHP_SRC_URI}"
51
52 DESCRIPTION="The PHP language runtime engine: CLI, CGI, FPM/FastCGI, Apache2 and embed SAPIs"
53 HOMEPAGE="http://php.net/"
54 LICENSE="PHP-3"
55
56 S="${WORKDIR}/${PHP_P}"
57
58 # We can build the following SAPIs in the given order
59 SAPIS="embed cli cgi fpm apache2"
60
61 # SAPIs and SAPI-specific USE flags (cli SAPI is default on):
62 IUSE="${IUSE}
63 ${SAPIS/cli/+cli}
64 threads"
65
66 IUSE="${IUSE} bcmath berkdb bzip2 calendar cdb cjk
67 crypt +ctype curl debug
68 enchant exif frontbase +fileinfo +filter firebird
69 flatfile ftp gd gdbm gmp +hash +iconv imap inifile
70 intl iodbc ipv6 +json kerberos ldap ldap-sasl libedit mhash
71 mssql mysql libmysqlclient mysqli nls
72 oci8-instant-client odbc +opcache pcntl pdo pdo-dblib pdo-mysql pdo-oci
73 pdo-odbc pdo-pgsql pdo-sqlite +phar +posix postgres qdbm readline recode
74 selinux +session sharedmem +simplexml snmp soap sockets spell sqlite ssl
75 sybase-ct sysvipc systemd tidy +tokenizer truetype unicode vpx wddx
76 +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
77
78 # See REQUIRED_USE for an explanation of why we duplicate dependencies
79 # for USE=pdo-foo.
80 DEPEND="
81 >=app-admin/eselect-php-0.7.1-r3[apache2?,fpm?]
82 >=dev-libs/libpcre-8.32[unicode]
83 apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
84 <www-servers/apache-2.4[threads=] ) )
85 berkdb? ( =sys-libs/db-4* )
86 bzip2? ( app-arch/bzip2 )
87 cdb? ( || ( dev-db/cdb dev-db/tinycdb ) )
88 cjk? ( !gd? (
89 virtual/jpeg:0
90 media-libs/libpng:0=
91 sys-libs/zlib
92 ) )
93 crypt? ( >=dev-libs/libmcrypt-2.4 )
94 curl? ( >=net-misc/curl-7.10.5 )
95 enchant? ( app-text/enchant )
96 exif? ( !gd? (
97 virtual/jpeg:0
98 media-libs/libpng:0=
99 sys-libs/zlib
100 ) )
101 firebird? ( dev-db/firebird )
102 gd? ( virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
103 gdbm? ( >=sys-libs/gdbm-1.8.0 )
104 gmp? ( >=dev-libs/gmp-4.1.2 )
105 iconv? ( virtual/libiconv )
106 imap? ( virtual/imap-c-client[ssl=] )
107 intl? ( dev-libs/icu:= )
108 iodbc? ( dev-db/libiodbc )
109 kerberos? ( virtual/krb5 )
110 ldap? ( >=net-nds/openldap-1.2.11 )
111 ldap-sasl? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 )
112 libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) )
113 mssql? ( dev-db/freetds[mssql] )
114 libmysqlclient? (
115 mysql? ( virtual/mysql )
116 mysqli? ( virtual/mysql )
117 )
118 nls? ( sys-devel/gettext )
119 oci8-instant-client? ( dev-db/oracle-instantclient-basic )
120 odbc? ( >=dev-db/unixODBC-1.8.13 )
121 pdo-dblib? ( dev-db/freetds[mssql] )
122 pdo-oci? ( dev-db/oracle-instantclient-basic )
123 pdo-odbc? ( >=dev-db/unixODBC-1.8.13 )
124 pdo-mysql? ( virtual/mysql )
125 pdo-pgsql? ( dev-db/postgresql )
126 pdo-sqlite? ( >=dev-db/sqlite-3.7.6.3 )
127 postgres? ( dev-db/postgresql )
128 qdbm? ( dev-db/qdbm )
129 readline? ( sys-libs/readline )
130 recode? ( app-text/recode )
131 sharedmem? ( dev-libs/mm )
132 simplexml? ( >=dev-libs/libxml2-2.6.8 )
133 snmp? ( >=net-analyzer/net-snmp-5.2 )
134 soap? ( >=dev-libs/libxml2-2.6.8 )
135 spell? ( >=app-text/aspell-0.50 )
136 sqlite? ( >=dev-db/sqlite-3.7.6.3 )
137 ssl? ( >=dev-libs/openssl-0.9.7 )
138 sybase-ct? ( dev-db/freetds )
139 tidy? ( app-text/htmltidy )
140 truetype? (
141 =media-libs/freetype-2*
142 >=media-libs/t1lib-5.0.0
143 !gd? (
144 virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
145 )
146 unicode? ( dev-libs/oniguruma )
147 vpx? ( media-libs/libvpx )
148 wddx? ( >=dev-libs/libxml2-2.6.8 )
149 xml? ( >=dev-libs/libxml2-2.6.8 )
150 xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv )
151 xmlreader? ( >=dev-libs/libxml2-2.6.8 )
152 xmlwriter? ( >=dev-libs/libxml2-2.6.8 )
153 xpm? (
154 x11-libs/libXpm
155 virtual/jpeg:0
156 media-libs/libpng:0= sys-libs/zlib
157 )
158 xslt? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 )
159 zip? ( sys-libs/zlib )
160 zlib? ( sys-libs/zlib )
161 virtual/mta
162 "
163
164 php="=${CATEGORY}/${PF}"
165
166 # All of the pdo-foo USE flags could require USE=foo, but this has an
167 # unwanted side effect. USE=mysql, for example, also enables the old
168 # deprecated mysql database driver. We would like it to be possible to
169 # install pdo-mysql without the deprecated mysql driver, so we don't
170 # require USE=mysql with USE=pdo-mysql. This means that we have to
171 # reproduce the mysql? (...) dependencies for pdo-mysql in (R)DEPEND
172 # above.
173 REQUIRED_USE="
174 truetype? ( gd )
175 vpx? ( gd )
176 cjk? ( gd )
177 exif? ( gd )
178
179 xpm? ( gd )
180 gd? ( zlib )
181 simplexml? ( xml )
182 soap? ( xml )
183 wddx? ( xml )
184 xmlrpc? ( || ( xml iconv ) )
185 xmlreader? ( xml )
186 xslt? ( xml )
187 ldap-sasl? ( ldap )
188 mhash? ( hash )
189 phar? ( hash )
190 libmysqlclient? ( || (
191 mysql
192 mysqli
193 pdo-mysql
194 ) )
195
196 pdo-dblib? ( pdo )
197 pdo-oci? ( pdo )
198 pdo-odbc? ( pdo )
199 pdo-mysql? ( pdo )
200 pdo-pgsql? ( pdo )
201 pdo-sqlite? ( pdo )
202 qdbm? ( !gdbm )
203 readline? ( !libedit )
204 recode? ( !imap !mysql !mysqli )
205 sharedmem? ( !threads )
206
207 !cli? ( !cgi? ( !fpm? ( !apache2? ( !embed? ( cli ) ) ) ) )"
208
209 RDEPEND="${DEPEND}"
210
211 RDEPEND="${RDEPEND}
212 fpm? (
213 selinux? ( sec-policy/selinux-phpfpm )
214 systemd? ( sys-apps/systemd ) )"
215
216 DEPEND="${DEPEND}
217 sys-devel/flex
218 >=sys-devel/m4-1.4.3
219 >=sys-devel/libtool-1.5.18"
220
221 # Allow users to install production version if they want to
222
223 case "${PHP_INI_VERSION}" in
224 production|development)
225 ;;
226 *)
227 PHP_INI_VERSION="development"
228 ;;
229 esac
230
231 PHP_INI_UPSTREAM="php.ini-${PHP_INI_VERSION}"
232 PHP_INI_FILE="php.ini"
233
234 want_apache
235
236 pkg_setup() {
237 depend.apache_pkg_setup
238 }
239
240 php_install_ini() {
241 local phpsapi="${1}"
242
243 # work out where we are installing the ini file
244 php_set_ini_dir "${phpsapi}"
245
246 local phpinisrc="${PHP_INI_UPSTREAM}-${phpsapi}"
247 cp "${PHP_INI_UPSTREAM}" "${phpinisrc}"
248
249 # default to /tmp for save_path, bug #282768
250 sed -e 's|^;session.save_path .*$|session.save_path = "'"${EPREFIX}"'/tmp"|g' -i "${phpinisrc}"
251
252 # Set the extension dir
253 sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" -i "${phpinisrc}"
254
255 # Set the include path to point to where we want to find PEAR packages
256 sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:'"${EPREFIX}"'/usr/share/php'${PHP_MV}':'"${EPREFIX}"'/usr/share/php"|' -i "${phpinisrc}"
257
258 dodir "${PHP_INI_DIR#${EPREFIX}}"
259 insinto "${PHP_INI_DIR#${EPREFIX}}"
260 newins "${phpinisrc}" "${PHP_INI_FILE}"
261
262 elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR#${EPREFIX}}"
263 elog
264
265 dodir "${PHP_EXT_INI_DIR#${EPREFIX}}"
266 dodir "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}"
267
268 if use_if_iuse opcache; then
269 elog "Adding opcache to $PHP_EXT_INI_DIR"
270 echo "zend_extension=${PHP_DESTDIR}/$(get_libdir)/opcache.so" >> "${D}/${PHP_EXT_INI_DIR}"/opcache.ini
271 dosym "${PHP_EXT_INI_DIR#${EPREFIX}}/opcache.ini" "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}/opcache.ini"
272 fi
273
274 # SAPI-specific handling
275
276 if [[ "${sapi}" == "fpm" ]] ; then
277 [[ -z ${PHP_FPM_CONF_VER} ]] && PHP_FPM_CONF_VER=0
278 einfo "Installing FPM CGI config file php-fpm.conf"
279 insinto "${PHP_INI_DIR#${EPREFIX}}"
280 newins "${FILESDIR}/php-fpm-r${PHP_FPM_CONF_VER}.conf" php-fpm.conf
281
282 # Remove bogus /etc/php-fpm.conf.default (bug 359906)
283 [[ -f "${ED}/etc/php-fpm.conf.default" ]] && rm "${ED}/etc/php-fpm.conf.default"
284 fi
285
286 # Install PHP ini files into /usr/share/php
287
288 dodoc php.ini-development
289 dodoc php.ini-production
290
291 }
292
293 php_set_ini_dir() {
294 PHP_INI_DIR="${EPREFIX}/etc/php/${1}-php${SLOT}"
295 PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
296 PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
297 }
298
299 src_prepare() {
300 # USE=sharedmem (session/mod_mm to be exact) tries to mmap() this path
301 # ([empty session.save_path]/session_mm_[sapi][gid].sem)
302 # there is no easy way to circumvent that, all php calls during
303 # install use -n, so no php.ini file will be used.
304 # As such, this is the easiest way to get around
305 addpredict /session_mm_cli250.sem
306 addpredict /session_mm_cli0.sem
307
308 # Change PHP branding
309 # Get the alpha/beta/rc version
310 sed -re "s|^(PHP_EXTRA_VERSION=\").*(\")|\1-pl${PR/r/}-gentoo\2|g" \
311 -i configure.in || die "Unable to change PHP branding"
312
313 # Patch PHP to show Gentoo as the server platform
314 sed -e 's/PHP_UNAME=`uname -a | xargs`/PHP_UNAME=`uname -s -n -r -v | xargs`/g' \
315 -i configure.in || die "Failed to fix server platform name"
316
317 # Prevent PHP from activating the Apache config,
318 # as we will do that ourselves
319 sed -i \
320 -e "s,-i -a -n php${PHP_MV},-i -n php${PHP_MV},g" \
321 -e "s,-i -A -n php${PHP_MV},-i -n php${PHP_MV},g" \
322 configure sapi/apache2filter/config.m4 sapi/apache2handler/config.m4
323
324 # Patch PHP to support heimdal instead of mit-krb5
325 if has_version "app-crypt/heimdal" ; then
326 sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 \
327 || die "Failed to fix heimdal libname"
328 sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 \
329 || die "Failed to fix heimdal crypt library reference"
330 fi
331
332 #Add user patches #357637
333 epatch_user
334
335 #force rebuilding aclocal.m4
336 rm aclocal.m4
337 eautoreconf
338
339 if [[ ${CHOST} == *-darwin* ]] ; then
340 # http://bugs.php.net/bug.php?id=48795, bug #343481
341 sed -i -e '/BUILD_CGI="\\$(CC)/s/CC/CXX/' configure || die
342 fi
343 }
344
345 src_configure() {
346 addpredict /usr/share/snmp/mibs/.index
347 addpredict /var/lib/net-snmp/mib_indexes
348
349 PHP_DESTDIR="${EPREFIX}/usr/$(get_libdir)/php${SLOT}"
350
351 # This is a global variable and should be in caps. It isn't because the
352 # phpconfutils eclass relies on exactly this name...
353 # for --with-libdir see bug #327025
354 my_conf="
355 --prefix="${PHP_DESTDIR}"
356 --mandir="${PHP_DESTDIR}"/man
357 --infodir="${PHP_DESTDIR}"/info
358 --libdir="${PHP_DESTDIR}"/lib
359 --with-libdir=$(get_libdir)
360 --without-pear
361 $(use_enable threads maintainer-zts)"
362
363 # extension USE flag shared
364 my_conf+="
365 $(use_enable bcmath bcmath )
366 $(use_with bzip2 bz2 "${EPREFIX}"/usr)
367 $(use_enable calendar calendar )
368 $(use_with crypt mcrypt "${EPREFIX}"/usr)
369 $(use_enable ctype ctype )
370 $(use_with curl curl "${EPREFIX}"/usr)
371 $(use_enable debug debug )
372 $(use_with enchant enchant "${EPREFIX}"/usr)
373 $(use_enable exif exif )
374 $(use_enable fileinfo fileinfo )
375 $(use_enable filter filter )
376 $(use_with firebird interbase "${EPREFIX}"/usr)
377 $(use_enable ftp ftp )
378 $(use_with gmp gmp "${EPREFIX}"/usr)
379 $(use_enable hash hash )
380 $(use_with iconv iconv $(use elibc_glibc || echo "${EPREFIX}"/usr))
381 $(use_with imap imap "${EPREFIX}"/usr)
382 $(use_enable intl intl )
383 $(use_with iodbc iodbc "${EPREFIX}"/usr)
384 $(use_enable ipv6 ipv6 )
385 $(use_enable json json )
386 $(use_with kerberos kerberos "${EPREFIX}"/usr)
387 $(use_with ldap ldap "${EPREFIX}"/usr)
388 $(use_with ldap-sasl ldap-sasl "${EPREFIX}"/usr)
389 $(use_with libedit libedit "${EPREFIX}"/usr)
390 $(use_with mhash mhash "${EPREFIX}"/usr)
391 $(use_with mssql mssql "${EPREFIX}"/usr)
392 $(use_with nls gettext "${EPREFIX}"/usr)
393 $(use_with oci8-instant-client oci8)
394 $(use_with odbc unixODBC "${EPREFIX}"/usr)
395 $(use_enable opcache opcache )
396 $(use_enable pcntl pcntl )
397 $(use_enable pdo pdo )
398 $(use_with pdo-dblib pdo-dblib )
399 $(use_with pdo-oci pdo-oci )
400 $(use_with pdo-odbc pdo-odbc unixODBC,"${EPREFIX}"/usr)
401 $(use_with pdo-pgsql pdo-pgsql )
402 $(use_with pdo-sqlite pdo-sqlite "${EPREFIX}"/usr)
403 $(use_enable phar phar )
404 $(use_enable posix posix )
405 $(use_with postgres pgsql "${EPREFIX}"/usr)
406 $(use_with spell pspell "${EPREFIX}"/usr)
407 $(use_with readline readline "${EPREFIX}"/usr)
408 $(use_with recode recode "${EPREFIX}"/usr)
409 $(use_enable sharedmem shmop )
410 $(use_enable simplexml simplexml )
411 $(use_with snmp snmp "${EPREFIX}"/usr)
412 $(use_enable soap soap )
413 $(use_enable sockets sockets )
414 $(use_with sqlite sqlite3 "${EPREFIX}"/usr)
415 $(use_with ssl openssl "${EPREFIX}"/usr)
416 $(use_with ssl openssl-dir "${EPREFIX}"/usr)
417 $(use_with sybase-ct sybase-ct "${EPREFIX}"/usr)
418 $(use_with systemd fpm-systemd)
419 $(use_enable sysvipc sysvmsg )
420 $(use_enable sysvipc sysvsem )
421 $(use_enable sysvipc sysvshm )
422 $(use_with tidy tidy "${EPREFIX}"/usr)
423 $(use_enable tokenizer tokenizer )
424 $(use_enable unicode mbstring )
425 $(use_with unicode onig "${EPREFIX}"/usr)
426 $(use_enable wddx wddx )
427 $(use_enable xml dom )
428 $(use_enable xml libxml )
429 $(use_with xml libxml-dir "${EPREFIX}"/usr)
430 $(use_enable xml xml )
431 $(use_enable xmlreader xmlreader )
432 $(use_with xmlrpc xmlrpc)
433 $(use_enable xmlwriter xmlwriter )
434 $(use_with xslt xsl "${EPREFIX}"/usr)
435 $(use_enable zip zip )
436 $(use_with zlib zlib "${EPREFIX}"/usr)"
437
438 # DBA support
439 if use cdb || use berkdb || use flatfile || use gdbm || use inifile \
440 || use qdbm ; then
441 my_conf="${my_conf} --enable-dba${shared}"
442 fi
443
444 # DBA drivers support
445 my_conf+="
446 $(use_with cdb cdb)
447 $(use_with berkdb db4 ${EPREFIX}/usr)
448 $(use_enable flatfile flatfile )
449 $(use_with gdbm gdbm ${EPREFIX}/usr)
450 $(use_enable inifile inifile )
451 $(use_with qdbm qdbm ${EPREFIX}/usr)"
452
453 # Support for the GD graphics library
454 my_conf+="
455 $(use_with truetype freetype-dir ${EPREFIX}/usr)
456 $(use_with truetype t1lib ${EPREFIX}/usr)
457 $(use_enable cjk gd-jis-conv )
458 $(use_with gd jpeg-dir ${EPREFIX}/usr)
459 $(use_with gd png-dir ${EPREFIX}/usr)
460 $(use_with xpm xpm-dir ${EPREFIX}/usr)
461 $(use_with vpx vpx-dir ${EPREFIX}/usr)"
462 # enable gd last, so configure can pick up the previous settings
463 my_conf+="
464 $(use_with gd gd)"
465
466 # IMAP SSL support
467 if use imap ; then
468 my_conf+=" $(use_with ssl imap-ssl ${EPREFIX}/usr)"
469 fi
470
471 # MySQL support
472 local mysqllib="mysqlnd"
473 local mysqlilib="mysqlnd"
474 use libmysqlclient && mysqllib="${EPREFIX}/usr"
475 use libmysqlclient && mysqlilib="${EPREFIX}/usr/bin/mysql_config"
476
477 my_conf+=" $(use_with mysql mysql $mysqllib)"
478 my_conf+=" $(use_with mysqli mysqli $mysqlilib)"
479
480 # MySQL PDO support
481 my_conf+=" $(use_with pdo-mysql pdo-mysql ${mysqllib})"
482
483 # If MySQL is enabled in any way, pass --with-mysql-sock to ./configure.
484 if use mysql || use mysqli || use pdo-mysql ; then
485 my_conf+=" --with-mysql-sock=${EPREFIX}/var/run/mysqld/mysqld.sock"
486 fi
487
488 # Session support
489 if use session ; then
490 my_conf+="
491 $(use_with sharedmem mm ${EPREFIX}/usr)"
492 else
493 my_conf+="
494 $(use_enable session session )"
495 fi
496
497 # Use pic for shared modules such as apache2's mod_php
498 my_conf="${my_conf} --with-pic"
499
500 # we use the system copy of pcre
501 # --with-pcre-regex affects ext/pcre
502 # --with-pcre-dir affects ext/filter and ext/zip
503 my_conf="${my_conf} --with-pcre-regex=${EPREFIX}/usr --with-pcre-dir=${EPREFIX}/usr"
504
505 # Catch CFLAGS problems
506 # Fixes bug #14067.
507 # Changed order to run it in reverse for bug #32022 and #12021.
508 replace-cpu-flags "k6*" "i586"
509
510 # Support user-passed configuration parameters
511 my_conf="${my_conf} ${EXTRA_ECONF:-}"
512
513 # Support the Apache2 extras, they must be set globally for all
514 # SAPIs to work correctly, especially for external PHP extensions
515
516 mkdir -p "${WORKDIR}/sapis-build"
517 for one_sapi in $SAPIS ; do
518 use "${one_sapi}" || continue
519 php_set_ini_dir "${one_sapi}"
520
521 cp -r "${S}" "${WORKDIR}/sapis-build/${one_sapi}"
522 cd "${WORKDIR}/sapis-build/${one_sapi}"
523
524 sapi_conf="${my_conf} --with-config-file-path=${PHP_INI_DIR}
525 --with-config-file-scan-dir=${PHP_EXT_INI_DIR_ACTIVE}"
526
527 for sapi in $SAPIS ; do
528 case "$sapi" in
529 cli|cgi|embed|fpm)
530 if [[ "${one_sapi}" == "${sapi}" ]] ; then
531 sapi_conf="${sapi_conf} --enable-${sapi}"
532 else
533 sapi_conf="${sapi_conf} --disable-${sapi}"
534 fi
535 ;;
536
537 apache2)
538 if [[ "${one_sapi}" == "${sapi}" ]] ; then
539 sapi_conf="${sapi_conf} --with-apxs2=${EPREFIX}/usr/sbin/apxs"
540 else
541 sapi_conf="${sapi_conf} --without-apxs2"
542 fi
543 ;;
544 esac
545 done
546
547 econf ${sapi_conf}
548 done
549 }
550
551 src_compile() {
552 # snmp seems to run during src_compile, too (bug #324739)
553 addpredict /usr/share/snmp/mibs/.index
554 addpredict /var/lib/net-snmp/mib_indexes
555
556 for sapi in ${SAPIS} ; do
557 if use "${sapi}"; then
558 cd "${WORKDIR}/sapis-build/$sapi" || "Failed to change dir to ${WORKDIR}/sapis-build/$1"
559 emake || die "emake failed"
560 fi
561 done
562 }
563
564 src_install() {
565 # see bug #324739 for what happens when we don't have that
566 addpredict /usr/share/snmp/mibs/.index
567
568 # grab the first SAPI that got built and install common files from there
569 local first_sapi=""
570 for sapi in $SAPIS ; do
571 if use $sapi ; then
572 first_sapi=$sapi
573 break
574 fi
575 done
576
577 # Makefile forgets to create this before trying to write to it...
578 dodir "${PHP_DESTDIR#${EPREFIX}}/bin"
579
580 # Install php environment (without any sapis)
581 cd "${WORKDIR}/sapis-build/$first_sapi"
582 emake INSTALL_ROOT="${D}" \
583 install-build install-headers install-programs \
584 || die "emake install failed"
585
586 local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)"
587
588 # Create the directory where we'll put version-specific php scripts
589 keepdir /usr/share/php${PHP_MV}
590
591 local sapi="", file=""
592 local sapi_list=""
593
594 for sapi in ${SAPIS}; do
595 if use "${sapi}" ; then
596 einfo "Installing SAPI: ${sapi}"
597 cd "${WORKDIR}/sapis-build/${sapi}"
598
599 if [[ "${sapi}" == "apache2" ]] ; then
600 # We're specifically not using emake install-sapi as libtool
601 # may cause unnecessary relink failures (see bug #351266)
602 insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/"
603 newins ".libs/libphp5$(get_libname)" "libphp${PHP_MV}$(get_libname)"
604 keepdir "/usr/$(get_libdir)/apache2/modules"
605 else
606 # needed each time, php_install_ini would reset it
607 local dest="${PHP_DESTDIR#${EPREFIX}}"
608 into "${dest}"
609 case "$sapi" in
610 cli)
611 source="sapi/cli/php"
612 ;;
613 cgi)
614 source="sapi/cgi/php-cgi"
615 ;;
616 fpm)
617 source="sapi/fpm/php-fpm"
618 ;;
619 embed)
620 source="libs/libphp${PHP_MV}$(get_libname)"
621 ;;
622 *)
623 die "unhandled sapi in src_install"
624 ;;
625 esac
626
627 if [[ "${source}" == *"$(get_libname)" ]]; then
628 dolib.so "${source}" || die "Unable to install ${sapi} sapi"
629 else
630 dobin "${source}" || die "Unable to install ${sapi} sapi"
631 local name="$(basename ${source})"
632 dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}"
633 fi
634 fi
635
636 php_install_ini "${sapi}"
637
638 # construct correct SAPI string for php-config
639 # thanks to ferringb for the bash voodoo
640 if [[ "${sapi}" == "apache2" ]]; then
641 sapi_list="${sapi_list:+${sapi_list} }apache2handler"
642 else
643 sapi_list="${sapi_list:+${sapi_list} }${sapi}"
644 fi
645 fi
646 done
647
648 # Installing opcache module
649 if use_if_iuse opcache ; then
650 dolib.so "modules/opcache$(get_libname)" || die "Unable to install opcache module"
651 fi
652
653 # Install env.d files
654 newenvd "${FILESDIR}/20php5-envd" \
655 "20php${SLOT}"
656 sed -e "s|/lib/|/$(get_libdir)/|g" -i \
657 "${ED}/etc/env.d/20php${SLOT}"
658 sed -e "s|php5|php${SLOT}|g" -i \
659 "${ED}/etc/env.d/20php${SLOT}"
660
661 # set php-config variable correctly (bug #278439)
662 sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
663 "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config"
664
665 if use fpm ; then
666 if use systemd; then
667 systemd_newunit "${FILESDIR}/php-fpm_at.service" "php-fpm@${SLOT}.service"
668 else
669 systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" "php-fpm@${SLOT}.service"
670 fi
671 fi
672 }
673
674 src_test() {
675 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
676 PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php"
677 if [[ ! -x "${PHP_BIN}" ]] ; then
678 ewarn "Test phase requires USE=cli, skipping"
679 return
680 else
681 export TEST_PHP_EXECUTABLE="${PHP_BIN}"
682 fi
683
684 if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then
685 export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi"
686 fi
687
688 REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d "session.save_path=${T}" \
689 "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d "session.save_path=${T}"
690
691 for name in ${EXPECTED_TEST_FAILURES}; do
692 mv "${name}.out" "${name}.out.orig" 2>/dev/null
693 done
694
695 local failed="$(find -name '*.out')"
696 if [[ ${failed} != "" ]] ; then
697 ewarn "The following test cases failed unexpectedly:"
698 for name in ${failed}; do
699 ewarn " ${name/.out/}"
700 done
701 else
702 einfo "No unexpected test failures, all fine"
703 fi
704
705 if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then
706 local passed=""
707 for name in ${EXPECTED_TEST_FAILURES}; do
708 [[ -f "${name}.diff" ]] && continue
709 passed="${passed} ${name}"
710 done
711 if [[ ${passed} != "" ]] ; then
712 einfo "The following test cases passed unexpectedly:"
713 for name in ${passed}; do
714 ewarn " ${passed}"
715 done
716 else
717 einfo "None of the known-to-fail tests passed, all fine"
718 fi
719 fi
720 }
721
722 pkg_postinst() {
723 # Output some general info to the user
724 if use apache2 ; then
725 APACHE2_MOD_DEFINE="PHP5"
726 APACHE2_MOD_CONF="70_mod_php5"
727 apache-module_pkg_postinst
728 fi
729
730 # Create the symlinks for php
731 for m in ${SAPIS}; do
732 [[ ${m} == 'embed' ]] && continue;
733 if use $m ; then
734 local ci=$(eselect php show $m)
735 if [[ -z $ci ]]; then
736 eselect php set $m php${SLOT}
737 einfo "Switched ${m} to use php:${SLOT}"
738 einfo
739 elif [[ $ci != "php${SLOT}" ]] ; then
740 elog "To switch $m to use php:${SLOT}, run"
741 elog " eselect php set $m php${SLOT}"
742 elog
743 fi
744 fi
745 done
746
747 elog "Make sure that PHP_TARGETS in ${EPREFIX}/etc/make.conf includes php${SLOT/./-} in order"
748 elog "to compile extensions for the ${SLOT} ABI"
749 elog
750 if ! use readline && use cli ; then
751 ewarn "Note that in order to use php interactivly, you need to enable"
752 ewarn "the readline USE flag or php -a will hang"
753 fi
754 elog
755 elog "This ebuild installed a version of php.ini based on php.ini-${PHP_INI_VERSION} version."
756 elog "You can chose which version of php.ini to install by default by setting PHP_INI_VERSION to either"
757 elog "'production' or 'development' in ${EPREFIX}/etc/make.conf"
758 elog "Both versions of php.ini can be found in ${EPREFIX}/usr/share/doc/${PF}"
759
760 elog
761 elog "For more details on how minor version slotting works (PHP_TARGETS) please read the upgrade guide:"
762 elog "http://www.gentoo.org/proj/en/php/php-upgrading.xml"
763 elog
764 }
765
766 pkg_prerm() {
767 eselect php cleanup
768 }