]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - dev-lang/php/php-5.6.4-r1.ebuild
32fd2bc2dcb9fa80dcc5e26ed1ab0c25af906e76
[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 local mysqlsock=" $(use_with mysql mysql-sock ${EPREFIX}/var/run/mysqld/mysqld.sock)"
481 if use mysql ; then
482 my_conf+="${mysqlsock}"
483 elif use mysqli ; then
484 my_conf+="${mysqlsock}"
485 fi
486
487 # MySQL PDO support
488 my_conf+=" $(use_with pdo-mysql pdo-mysql ${mysqllib})"
489
490 # Session support
491 if use session ; then
492 my_conf+="
493 $(use_with sharedmem mm ${EPREFIX}/usr)"
494 else
495 my_conf+="
496 $(use_enable session session )"
497 fi
498
499 # Use pic for shared modules such as apache2's mod_php
500 my_conf="${my_conf} --with-pic"
501
502 # we use the system copy of pcre
503 # --with-pcre-regex affects ext/pcre
504 # --with-pcre-dir affects ext/filter and ext/zip
505 my_conf="${my_conf} --with-pcre-regex=${EPREFIX}/usr --with-pcre-dir=${EPREFIX}/usr"
506
507 # Catch CFLAGS problems
508 # Fixes bug #14067.
509 # Changed order to run it in reverse for bug #32022 and #12021.
510 replace-cpu-flags "k6*" "i586"
511
512 # Support user-passed configuration parameters
513 my_conf="${my_conf} ${EXTRA_ECONF:-}"
514
515 # Support the Apache2 extras, they must be set globally for all
516 # SAPIs to work correctly, especially for external PHP extensions
517
518 mkdir -p "${WORKDIR}/sapis-build"
519 for one_sapi in $SAPIS ; do
520 use "${one_sapi}" || continue
521 php_set_ini_dir "${one_sapi}"
522
523 cp -r "${S}" "${WORKDIR}/sapis-build/${one_sapi}"
524 cd "${WORKDIR}/sapis-build/${one_sapi}"
525
526 sapi_conf="${my_conf} --with-config-file-path=${PHP_INI_DIR}
527 --with-config-file-scan-dir=${PHP_EXT_INI_DIR_ACTIVE}"
528
529 for sapi in $SAPIS ; do
530 case "$sapi" in
531 cli|cgi|embed|fpm)
532 if [[ "${one_sapi}" == "${sapi}" ]] ; then
533 sapi_conf="${sapi_conf} --enable-${sapi}"
534 else
535 sapi_conf="${sapi_conf} --disable-${sapi}"
536 fi
537 ;;
538
539 apache2)
540 if [[ "${one_sapi}" == "${sapi}" ]] ; then
541 sapi_conf="${sapi_conf} --with-apxs2=${EPREFIX}/usr/sbin/apxs"
542 else
543 sapi_conf="${sapi_conf} --without-apxs2"
544 fi
545 ;;
546 esac
547 done
548
549 econf ${sapi_conf}
550 done
551 }
552
553 src_compile() {
554 # snmp seems to run during src_compile, too (bug #324739)
555 addpredict /usr/share/snmp/mibs/.index
556 addpredict /var/lib/net-snmp/mib_indexes
557
558 for sapi in ${SAPIS} ; do
559 if use "${sapi}"; then
560 cd "${WORKDIR}/sapis-build/$sapi" || "Failed to change dir to ${WORKDIR}/sapis-build/$1"
561 emake || die "emake failed"
562 fi
563 done
564 }
565
566 src_install() {
567 # see bug #324739 for what happens when we don't have that
568 addpredict /usr/share/snmp/mibs/.index
569
570 # grab the first SAPI that got built and install common files from there
571 local first_sapi=""
572 for sapi in $SAPIS ; do
573 if use $sapi ; then
574 first_sapi=$sapi
575 break
576 fi
577 done
578
579 # Makefile forgets to create this before trying to write to it...
580 dodir "${PHP_DESTDIR#${EPREFIX}}/bin"
581
582 # Install php environment (without any sapis)
583 cd "${WORKDIR}/sapis-build/$first_sapi"
584 emake INSTALL_ROOT="${D}" \
585 install-build install-headers install-programs \
586 || die "emake install failed"
587
588 local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)"
589
590 # Create the directory where we'll put version-specific php scripts
591 keepdir /usr/share/php${PHP_MV}
592
593 local sapi="", file=""
594 local sapi_list=""
595
596 for sapi in ${SAPIS}; do
597 if use "${sapi}" ; then
598 einfo "Installing SAPI: ${sapi}"
599 cd "${WORKDIR}/sapis-build/${sapi}"
600
601 if [[ "${sapi}" == "apache2" ]] ; then
602 # We're specifically not using emake install-sapi as libtool
603 # may cause unnecessary relink failures (see bug #351266)
604 insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/"
605 newins ".libs/libphp5$(get_libname)" "libphp${PHP_MV}$(get_libname)"
606 keepdir "/usr/$(get_libdir)/apache2/modules"
607 else
608 # needed each time, php_install_ini would reset it
609 local dest="${PHP_DESTDIR#${EPREFIX}}"
610 into "${dest}"
611 case "$sapi" in
612 cli)
613 source="sapi/cli/php"
614 ;;
615 cgi)
616 source="sapi/cgi/php-cgi"
617 ;;
618 fpm)
619 source="sapi/fpm/php-fpm"
620 ;;
621 embed)
622 source="libs/libphp${PHP_MV}$(get_libname)"
623 ;;
624 *)
625 die "unhandled sapi in src_install"
626 ;;
627 esac
628
629 if [[ "${source}" == *"$(get_libname)" ]]; then
630 dolib.so "${source}" || die "Unable to install ${sapi} sapi"
631 else
632 dobin "${source}" || die "Unable to install ${sapi} sapi"
633 local name="$(basename ${source})"
634 dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}"
635 fi
636 fi
637
638 php_install_ini "${sapi}"
639
640 # construct correct SAPI string for php-config
641 # thanks to ferringb for the bash voodoo
642 if [[ "${sapi}" == "apache2" ]]; then
643 sapi_list="${sapi_list:+${sapi_list} }apache2handler"
644 else
645 sapi_list="${sapi_list:+${sapi_list} }${sapi}"
646 fi
647 fi
648 done
649
650 # Installing opcache module
651 if use_if_iuse opcache ; then
652 dolib.so "modules/opcache$(get_libname)" || die "Unable to install opcache module"
653 fi
654
655 # Install env.d files
656 newenvd "${FILESDIR}/20php5-envd" \
657 "20php${SLOT}"
658 sed -e "s|/lib/|/$(get_libdir)/|g" -i \
659 "${ED}/etc/env.d/20php${SLOT}"
660 sed -e "s|php5|php${SLOT}|g" -i \
661 "${ED}/etc/env.d/20php${SLOT}"
662
663 # set php-config variable correctly (bug #278439)
664 sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
665 "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config"
666
667 if use fpm ; then
668 if use systemd; then
669 systemd_newunit "${FILESDIR}/php-fpm_at.service" "php-fpm@${SLOT}.service"
670 else
671 systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" "php-fpm@${SLOT}.service"
672 fi
673 fi
674 }
675
676 src_test() {
677 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
678 PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php"
679 if [[ ! -x "${PHP_BIN}" ]] ; then
680 ewarn "Test phase requires USE=cli, skipping"
681 return
682 else
683 export TEST_PHP_EXECUTABLE="${PHP_BIN}"
684 fi
685
686 if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then
687 export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi"
688 fi
689
690 REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d "session.save_path=${T}" \
691 "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d "session.save_path=${T}"
692
693 for name in ${EXPECTED_TEST_FAILURES}; do
694 mv "${name}.out" "${name}.out.orig" 2>/dev/null
695 done
696
697 local failed="$(find -name '*.out')"
698 if [[ ${failed} != "" ]] ; then
699 ewarn "The following test cases failed unexpectedly:"
700 for name in ${failed}; do
701 ewarn " ${name/.out/}"
702 done
703 else
704 einfo "No unexpected test failures, all fine"
705 fi
706
707 if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then
708 local passed=""
709 for name in ${EXPECTED_TEST_FAILURES}; do
710 [[ -f "${name}.diff" ]] && continue
711 passed="${passed} ${name}"
712 done
713 if [[ ${passed} != "" ]] ; then
714 einfo "The following test cases passed unexpectedly:"
715 for name in ${passed}; do
716 ewarn " ${passed}"
717 done
718 else
719 einfo "None of the known-to-fail tests passed, all fine"
720 fi
721 fi
722 }
723
724 pkg_postinst() {
725 # Output some general info to the user
726 if use apache2 ; then
727 APACHE2_MOD_DEFINE="PHP5"
728 APACHE2_MOD_CONF="70_mod_php5"
729 apache-module_pkg_postinst
730 fi
731
732 # Create the symlinks for php
733 for m in ${SAPIS}; do
734 [[ ${m} == 'embed' ]] && continue;
735 if use $m ; then
736 local ci=$(eselect php show $m)
737 if [[ -z $ci ]]; then
738 eselect php set $m php${SLOT}
739 einfo "Switched ${m} to use php:${SLOT}"
740 einfo
741 elif [[ $ci != "php${SLOT}" ]] ; then
742 elog "To switch $m to use php:${SLOT}, run"
743 elog " eselect php set $m php${SLOT}"
744 elog
745 fi
746 fi
747 done
748
749 elog "Make sure that PHP_TARGETS in ${EPREFIX}/etc/make.conf includes php${SLOT/./-} in order"
750 elog "to compile extensions for the ${SLOT} ABI"
751 elog
752 if ! use readline && use cli ; then
753 ewarn "Note that in order to use php interactivly, you need to enable"
754 ewarn "the readline USE flag or php -a will hang"
755 fi
756 elog
757 elog "This ebuild installed a version of php.ini based on php.ini-${PHP_INI_VERSION} version."
758 elog "You can chose which version of php.ini to install by default by setting PHP_INI_VERSION to either"
759 elog "'production' or 'development' in ${EPREFIX}/etc/make.conf"
760 elog "Both versions of php.ini can be found in ${EPREFIX}/usr/share/doc/${PF}"
761
762 elog
763 elog "For more details on how minor version slotting works (PHP_TARGETS) please read the upgrade guide:"
764 elog "http://www.gentoo.org/proj/en/php/php-upgrading.xml"
765 elog
766 }
767
768 pkg_prerm() {
769 eselect php cleanup
770 }