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