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