php-5.6.30-r2.ebuild 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit autotools flag-o-matic versionator systemd
  5. DESCRIPTION="The PHP language runtime engine"
  6. HOMEPAGE="http://php.net/"
  7. SRC_URI="http://php.net/distributions/${P}.tar.xz"
  8. LICENSE="PHP-3.01
  9. BSD
  10. Zend-2.0
  11. bcmath? ( LGPL-2.1+ )
  12. fpm? ( BSD-2 )
  13. gd? ( gd )
  14. unicode? ( BSD-2 LGPL-2.1 )"
  15. SLOT="$(get_version_component_range 1-2)"
  16. KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
  17. # We can build the following SAPIs in the given order
  18. SAPIS="embed cli cgi fpm apache2"
  19. # SAPIs and SAPI-specific USE flags (cli SAPI is default on):
  20. IUSE="${IUSE}
  21. ${SAPIS/cli/+cli}
  22. threads"
  23. IUSE="${IUSE} acl bcmath berkdb bzip2 calendar cdb cjk
  24. coverage crypt +ctype curl debug
  25. enchant exif +fileinfo +filter firebird
  26. flatfile ftp gd gdbm gmp +hash +iconv imap inifile
  27. intl iodbc ipv6 +json kerberos ldap ldap-sasl libedit libressl
  28. mhash mssql mysql libmysqlclient mysqli nls
  29. oci8-instant-client odbc +opcache pcntl pdo +phar +posix postgres qdbm
  30. readline recode selinux +session sharedmem
  31. +simplexml snmp soap sockets spell sqlite ssl
  32. sybase-ct sysvipc systemd tidy +tokenizer truetype unicode vpx wddx
  33. +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
  34. # The supported (that is, autodetected) versions of BDB are listed in
  35. # the ./configure script. Other versions *work*, but we need to stick to
  36. # the ones that can be detected to avoid a repeat of bug #564824.
  37. COMMON_DEPEND="
  38. >=app-eselect/eselect-php-0.9.1[apache2?,fpm?]
  39. >=dev-libs/libpcre-8.32[unicode]
  40. acl? ( sys-apps/acl )
  41. apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
  42. <www-servers/apache-2.4[threads=] ) )
  43. berkdb? ( || ( sys-libs/db:5.3
  44. sys-libs/db:5.1
  45. sys-libs/db:4.8
  46. sys-libs/db:4.7
  47. sys-libs/db:4.6
  48. sys-libs/db:4.5 ) )
  49. bzip2? ( app-arch/bzip2 )
  50. cdb? ( || ( dev-db/cdb dev-db/tinycdb ) )
  51. cjk? ( !gd? (
  52. virtual/jpeg:0
  53. media-libs/libpng:0=
  54. sys-libs/zlib
  55. ) )
  56. coverage? ( dev-util/lcov )
  57. crypt? ( >=dev-libs/libmcrypt-2.4 )
  58. curl? ( >=net-misc/curl-7.10.5 )
  59. enchant? ( app-text/enchant )
  60. exif? ( !gd? (
  61. virtual/jpeg:0
  62. media-libs/libpng:0=
  63. sys-libs/zlib
  64. ) )
  65. firebird? ( dev-db/firebird )
  66. gd? ( virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
  67. gdbm? ( >=sys-libs/gdbm-1.8.0 )
  68. gmp? ( dev-libs/gmp:0 )
  69. iconv? ( virtual/libiconv )
  70. imap? ( virtual/imap-c-client[kerberos=,ssl=] )
  71. intl? ( dev-libs/icu:= )
  72. iodbc? ( dev-db/libiodbc )
  73. kerberos? ( virtual/krb5 )
  74. ldap? ( >=net-nds/openldap-1.2.11 )
  75. ldap-sasl? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 )
  76. libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) )
  77. mssql? ( dev-db/freetds[mssql] )
  78. libmysqlclient? (
  79. mysql? ( virtual/libmysqlclient:= )
  80. mysqli? ( virtual/libmysqlclient:= )
  81. )
  82. nls? ( sys-devel/gettext )
  83. oci8-instant-client? ( dev-db/oracle-instantclient-basic )
  84. odbc? ( >=dev-db/unixODBC-1.8.13 )
  85. postgres? ( dev-db/postgresql:* )
  86. qdbm? ( dev-db/qdbm )
  87. readline? ( sys-libs/readline:0= )
  88. recode? ( app-text/recode )
  89. sharedmem? ( dev-libs/mm )
  90. simplexml? ( >=dev-libs/libxml2-2.6.8 )
  91. snmp? ( >=net-analyzer/net-snmp-5.2 )
  92. soap? ( >=dev-libs/libxml2-2.6.8 )
  93. spell? ( >=app-text/aspell-0.50 )
  94. sqlite? ( >=dev-db/sqlite-3.7.6.3 )
  95. ssl? (
  96. !libressl? ( dev-libs/openssl:0= )
  97. libressl? ( dev-libs/libressl )
  98. )
  99. sybase-ct? ( dev-db/freetds )
  100. tidy? ( app-text/htmltidy )
  101. truetype? (
  102. =media-libs/freetype-2*
  103. >=media-libs/t1lib-5.0.0
  104. !gd? (
  105. virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
  106. )
  107. unicode? ( dev-libs/oniguruma )
  108. vpx? ( media-libs/libvpx )
  109. wddx? ( >=dev-libs/libxml2-2.6.8 )
  110. xml? ( >=dev-libs/libxml2-2.6.8 )
  111. xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv )
  112. xmlreader? ( >=dev-libs/libxml2-2.6.8 )
  113. xmlwriter? ( >=dev-libs/libxml2-2.6.8 )
  114. xpm? (
  115. x11-libs/libXpm
  116. virtual/jpeg:0
  117. media-libs/libpng:0= sys-libs/zlib
  118. )
  119. xslt? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 )
  120. zip? ( sys-libs/zlib )
  121. zlib? ( sys-libs/zlib )
  122. "
  123. RDEPEND="${COMMON_DEPEND}
  124. virtual/mta
  125. fpm? (
  126. selinux? ( sec-policy/selinux-phpfpm )
  127. systemd? ( sys-apps/systemd ) )"
  128. DEPEND="${COMMON_DEPEND}
  129. app-arch/xz-utils
  130. >=sys-devel/bison-3.0.1
  131. sys-devel/flex
  132. >=sys-devel/m4-1.4.3
  133. >=sys-devel/libtool-1.5.18"
  134. # Without USE=readline or libedit, the interactive "php -a" CLI will hang.
  135. REQUIRED_USE="
  136. cli? ( ^^ ( readline libedit ) )
  137. truetype? ( gd )
  138. vpx? ( gd )
  139. cjk? ( gd )
  140. exif? ( gd )
  141. xpm? ( gd )
  142. gd? ( zlib )
  143. simplexml? ( xml )
  144. soap? ( xml )
  145. wddx? ( xml )
  146. xmlrpc? ( || ( xml iconv ) )
  147. xmlreader? ( xml )
  148. xslt? ( xml )
  149. ldap-sasl? ( ldap )
  150. mhash? ( hash )
  151. phar? ( hash )
  152. libmysqlclient? ( || (
  153. mysql
  154. mysqli
  155. pdo
  156. ) )
  157. qdbm? ( !gdbm )
  158. readline? ( !libedit )
  159. recode? ( !imap !mysql !mysqli )
  160. sharedmem? ( !threads )
  161. !cli? ( !cgi? ( !fpm? ( !apache2? ( !embed? ( cli ) ) ) ) )"
  162. PHP_MV="$(get_major_version)"
  163. php_install_ini() {
  164. local phpsapi="${1}"
  165. # work out where we are installing the ini file
  166. php_set_ini_dir "${phpsapi}"
  167. # Always install the production INI file, bug 611214.
  168. local phpinisrc="php.ini-production-${phpsapi}"
  169. cp php.ini-production "${phpinisrc}" || die
  170. # default to /tmp for save_path, bug #282768
  171. sed -e 's|^;session.save_path .*$|session.save_path = "'"${EPREFIX}"'/tmp"|g' -i "${phpinisrc}" || die
  172. # Set the extension dir
  173. sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" \
  174. -i "${phpinisrc}" || die
  175. # Set the include path to point to where we want to find PEAR packages
  176. sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:'"${EPREFIX}"'/usr/share/php'${PHP_MV}':'"${EPREFIX}"'/usr/share/php"|' -i "${phpinisrc}" || die
  177. dodir "${PHP_INI_DIR#${EPREFIX}}"
  178. insinto "${PHP_INI_DIR#${EPREFIX}}"
  179. newins "${phpinisrc}" php.ini
  180. elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR#${EPREFIX}}"
  181. elog
  182. dodir "${PHP_EXT_INI_DIR#${EPREFIX}}"
  183. dodir "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}"
  184. if use opcache; then
  185. elog "Adding opcache to $PHP_EXT_INI_DIR"
  186. echo "zend_extension=${PHP_DESTDIR}/$(get_libdir)/opcache.so" >> \
  187. "${D}/${PHP_EXT_INI_DIR}"/opcache.ini
  188. dosym "${PHP_EXT_INI_DIR#${EPREFIX}}/opcache.ini" \
  189. "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}/opcache.ini"
  190. fi
  191. # SAPI-specific handling
  192. if [[ "${sapi}" == "fpm" ]] ; then
  193. einfo "Installing FPM config file php-fpm.conf"
  194. insinto "${PHP_INI_DIR#${EPREFIX}}"
  195. doins sapi/fpm/php-fpm.conf
  196. fi
  197. dodoc php.ini-{development,production}
  198. }
  199. php_set_ini_dir() {
  200. PHP_INI_DIR="${EPREFIX}/etc/php/${1}-php${SLOT}"
  201. PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
  202. PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
  203. }
  204. src_prepare() {
  205. eapply "${FILESDIR}/php-${SLOT}-no-bison-warnings.patch"
  206. # Change PHP branding
  207. # Get the alpha/beta/rc version
  208. sed -re "s|^(PHP_EXTRA_VERSION=\").*(\")|\1-pl${PR/r/}-gentoo\2|g" \
  209. -i configure.in || die "Unable to change PHP branding"
  210. # Patch PHP to show Gentoo as the server platform
  211. sed -e 's/PHP_UNAME=`uname -a | xargs`/PHP_UNAME=`uname -s -n -r -v | xargs`/g' \
  212. -i configure.in || die "Failed to fix server platform name"
  213. # Prevent PHP from activating the Apache config,
  214. # as we will do that ourselves
  215. sed -i \
  216. -e "s,-i -a -n php${PHP_MV},-i -n php${PHP_MV},g" \
  217. -e "s,-i -A -n php${PHP_MV},-i -n php${PHP_MV},g" \
  218. configure sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 \
  219. || die
  220. # Patch PHP to support heimdal instead of mit-krb5
  221. if has_version "app-crypt/heimdal" ; then
  222. sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 \
  223. || die "Failed to fix heimdal libname"
  224. sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 \
  225. || die "Failed to fix heimdal crypt library reference"
  226. fi
  227. eapply_user
  228. # Force rebuilding aclocal.m4
  229. rm -f aclocal.m4 || die "failed to remove aclocal.m4 in src_prepare"
  230. eautoreconf
  231. if [[ ${CHOST} == *-darwin* ]] ; then
  232. # http://bugs.php.net/bug.php?id=48795, bug #343481
  233. sed -i -e '/BUILD_CGI="\\$(CC)/s/CC/CXX/' configure || die
  234. fi
  235. }
  236. src_configure() {
  237. addpredict /usr/share/snmp/mibs/.index
  238. addpredict /var/lib/net-snmp/mib_indexes
  239. PHP_DESTDIR="${EPREFIX}/usr/$(get_libdir)/php${SLOT}"
  240. # The php-fpm config file wants localstatedir to be ${EPREFIX}/var
  241. # and not the Gentoo default ${EPREFIX}/var/lib. See bug 572002.
  242. local our_conf=(
  243. --prefix="${PHP_DESTDIR}"
  244. --mandir="${PHP_DESTDIR}/man"
  245. --infodir="${PHP_DESTDIR}/info"
  246. --libdir="${PHP_DESTDIR}/lib"
  247. --with-libdir="$(get_libdir)"
  248. --localstatedir="${EPREFIX}/var"
  249. --without-pear
  250. $(use_enable threads maintainer-zts)
  251. )
  252. our_conf+=(
  253. $(use_with acl fpm-acl)
  254. $(use_enable bcmath bcmath)
  255. $(use_with bzip2 bz2 "${EPREFIX}/usr")
  256. $(use_enable calendar calendar)
  257. $(use_enable coverage gcov)
  258. $(use_enable ctype ctype)
  259. $(use_with curl curl "${EPREFIX}/usr")
  260. $(use_enable xml dom)
  261. $(use_with enchant enchant "${EPREFIX}/usr")
  262. $(use_enable exif exif)
  263. $(use_enable fileinfo fileinfo)
  264. $(use_enable filter filter)
  265. $(use_enable ftp ftp)
  266. $(use_with nls gettext "${EPREFIX}/usr")
  267. $(use_with gmp gmp "${EPREFIX}/usr")
  268. $(use_enable hash hash)
  269. $(use_with mhash mhash "${EPREFIX}/usr")
  270. $(use_with iconv iconv \
  271. $(use elibc_glibc || use elibc_musl || echo "${EPREFIX}/usr"))
  272. $(use_enable intl intl)
  273. $(use_enable ipv6 ipv6)
  274. $(use_enable json json)
  275. $(use_with kerberos kerberos "${EPREFIX}/usr")
  276. $(use_enable xml libxml)
  277. $(use_with xml libxml-dir "${EPREFIX}/usr")
  278. $(use_enable unicode mbstring)
  279. $(use_with crypt mcrypt "${EPREFIX}/usr")
  280. $(use_with mssql mssql "${EPREFIX}/usr")
  281. $(use_with unicode onig "${EPREFIX}/usr")
  282. $(use_with ssl openssl "${EPREFIX}/usr")
  283. $(use_with ssl openssl-dir "${EPREFIX}/usr")
  284. $(use_enable pcntl pcntl)
  285. $(use_enable phar phar)
  286. $(use_enable pdo pdo)
  287. $(use_enable opcache opcache)
  288. $(use_with postgres pgsql "${EPREFIX}/usr")
  289. $(use_enable posix posix)
  290. $(use_with spell pspell "${EPREFIX}/usr")
  291. $(use_with recode recode "${EPREFIX}/usr")
  292. $(use_enable simplexml simplexml)
  293. $(use_enable sharedmem shmop)
  294. $(use_with snmp snmp "${EPREFIX}/usr")
  295. $(use_enable soap soap)
  296. $(use_enable sockets sockets)
  297. $(use_with sqlite sqlite3 "${EPREFIX}/usr")
  298. $(use_with sybase-ct sybase-ct "${EPREFIX}/usr")
  299. $(use_enable sysvipc sysvmsg)
  300. $(use_enable sysvipc sysvsem)
  301. $(use_enable sysvipc sysvshm)
  302. $(use_with systemd fpm-systemd)
  303. $(use_with tidy tidy "${EPREFIX}/usr")
  304. $(use_enable tokenizer tokenizer)
  305. $(use_enable wddx wddx)
  306. $(use_enable xml xml)
  307. $(use_enable xmlreader xmlreader)
  308. $(use_enable xmlwriter xmlwriter)
  309. $(use_with xmlrpc xmlrpc)
  310. $(use_with xslt xsl "${EPREFIX}/usr")
  311. $(use_enable zip zip)
  312. $(use_with zlib zlib "${EPREFIX}/usr")
  313. $(use_enable debug debug)
  314. )
  315. # DBA support
  316. if use cdb || use berkdb || use flatfile || use gdbm || use inifile \
  317. || use qdbm ; then
  318. our_conf+=( "--enable-dba${shared}" )
  319. fi
  320. # DBA drivers support
  321. our_conf+=(
  322. $(use_with cdb cdb)
  323. $(use_with berkdb db4 "${EPREFIX}/usr")
  324. $(use_enable flatfile flatfile)
  325. $(use_with gdbm gdbm "${EPREFIX}/usr")
  326. $(use_enable inifile inifile)
  327. $(use_with qdbm qdbm "${EPREFIX}/usr")
  328. )
  329. # Support for the GD graphics library
  330. our_conf+=(
  331. $(use_with truetype freetype-dir "${EPREFIX}/usr")
  332. $(use_with truetype t1lib "${EPREFIX}/usr")
  333. $(use_enable cjk gd-jis-conv)
  334. $(use_with gd jpeg-dir "${EPREFIX}/usr")
  335. $(use_with gd png-dir "${EPREFIX}/usr")
  336. $(use_with xpm xpm-dir "${EPREFIX}/usr")
  337. $(use_with vpx vpx-dir "${EPREFIX}/usr")
  338. )
  339. # enable gd last, so configure can pick up the previous settings
  340. our_conf+=( $(use_with gd gd) )
  341. # IMAP support
  342. if use imap ; then
  343. our_conf+=(
  344. $(use_with imap imap "${EPREFIX}/usr")
  345. $(use_with ssl imap-ssl "${EPREFIX}/usr")
  346. )
  347. fi
  348. # Interbase/firebird support
  349. our_conf+=( $(use_with firebird interbase "${EPREFIX}/usr") )
  350. # LDAP support
  351. if use ldap ; then
  352. our_conf+=(
  353. $(use_with ldap ldap "${EPREFIX}/usr")
  354. $(use_with ldap-sasl ldap-sasl "${EPREFIX}/usr")
  355. )
  356. fi
  357. # MySQL support
  358. local mysqllib="mysqlnd"
  359. local mysqlilib="mysqlnd"
  360. use libmysqlclient && mysqllib="${EPREFIX}/usr"
  361. use libmysqlclient && mysqlilib="${EPREFIX}/usr/bin/mysql_config"
  362. our_conf+=( $(use_with mysql mysql "${mysqllib}") )
  363. our_conf+=( $(use_with mysqli mysqli "${mysqlilib}") )
  364. local mysqlsock="${EPREFIX}/var/run/mysqld/mysqld.sock"
  365. if use mysql || use mysqli ; then
  366. our_conf+=( $(use_with mysql mysql-sock "${mysqlsock}") )
  367. fi
  368. # ODBC support
  369. our_conf+=(
  370. $(use_with odbc unixODBC "${EPREFIX}/usr")
  371. $(use_with iodbc iodbc "${EPREFIX}/usr")
  372. )
  373. # Oracle support
  374. our_conf+=( $(use_with oci8-instant-client oci8) )
  375. # PDO support
  376. if use pdo ; then
  377. our_conf+=(
  378. $(use_with mssql pdo-dblib)
  379. $(use_with mysql pdo-mysql "${mysqllib}")
  380. $(use_with postgres pdo-pgsql)
  381. $(use_with sqlite pdo-sqlite "${EPREFIX}/usr")
  382. $(use_with firebird pdo-firebird "${EPREFIX}/usr")
  383. $(use_with odbc pdo-odbc "unixODBC,${EPREFIX}/usr")
  384. $(use_with oci8-instant-client pdo-oci)
  385. )
  386. fi
  387. # readline/libedit support
  388. our_conf+=(
  389. $(use_with readline readline "${EPREFIX}/usr")
  390. $(use_with libedit libedit "${EPREFIX}/usr")
  391. )
  392. # Session support
  393. if use session ; then
  394. our_conf+=( $(use_with sharedmem mm "${EPREFIX}/usr") )
  395. else
  396. our_conf+=( $(use_enable session session) )
  397. fi
  398. # Use pic for shared modules such as apache2's mod_php
  399. our_conf+=( --with-pic )
  400. # we use the system copy of pcre
  401. # --with-pcre-regex affects ext/pcre
  402. # --with-pcre-dir affects ext/filter and ext/zip
  403. our_conf+=(
  404. --with-pcre-regex="${EPREFIX}/usr"
  405. --with-pcre-dir="${EPREFIX}/usr"
  406. )
  407. # Catch CFLAGS problems
  408. # Fixes bug #14067.
  409. # Changed order to run it in reverse for bug #32022 and #12021.
  410. replace-cpu-flags "k6*" "i586"
  411. # Cache the ./configure test results between SAPIs.
  412. our_conf+=( --cache-file="${T}/config.cache" )
  413. # Support user-passed configuration parameters
  414. our_conf+=( ${EXTRA_ECONF:-} )
  415. # Support the Apache2 extras, they must be set globally for all
  416. # SAPIs to work correctly, especially for external PHP extensions
  417. mkdir -p "${WORKDIR}/sapis-build" || die
  418. for one_sapi in $SAPIS ; do
  419. use "${one_sapi}" || continue
  420. php_set_ini_dir "${one_sapi}"
  421. # The BUILD_DIR variable is used to determine where to output
  422. # the files that autotools creates. This was all originally
  423. # based on the autotools-utils eclass.
  424. BUILD_DIR="${WORKDIR}/sapis-build/${one_sapi}"
  425. cp -a "${S}" "${BUILD_DIR}" || die
  426. cd "${BUILD_DIR}" || die
  427. local sapi_conf=(
  428. --with-config-file-path="${PHP_INI_DIR}"
  429. --with-config-file-scan-dir="${PHP_EXT_INI_DIR_ACTIVE}"
  430. )
  431. for sapi in $SAPIS ; do
  432. case "$sapi" in
  433. cli|cgi|embed|fpm)
  434. if [[ "${one_sapi}" == "${sapi}" ]] ; then
  435. sapi_conf+=( "--enable-${sapi}" )
  436. else
  437. sapi_conf+=( "--disable-${sapi}" )
  438. fi
  439. ;;
  440. apache2)
  441. if [[ "${one_sapi}" == "${sapi}" ]] ; then
  442. sapi_conf+=( --with-apxs2="${EPREFIX}/usr/bin/apxs" )
  443. else
  444. sapi_conf+=( --without-apxs2 )
  445. fi
  446. ;;
  447. esac
  448. done
  449. # Construct the $myeconfargs array by concatenating $our_conf
  450. # (the common args) and $sapi_conf (the SAPI-specific args).
  451. local myeconfargs=( "${our_conf[@]}" )
  452. myeconfargs+=( "${sapi_conf[@]}" )
  453. pushd "${BUILD_DIR}" > /dev/null || die
  454. econf "${myeconfargs[@]}"
  455. popd > /dev/null || die
  456. done
  457. }
  458. src_compile() {
  459. # snmp seems to run during src_compile, too (bug #324739)
  460. addpredict /usr/share/snmp/mibs/.index
  461. addpredict /var/lib/net-snmp/mib_indexes
  462. for sapi in ${SAPIS} ; do
  463. if use "${sapi}"; then
  464. cd "${WORKDIR}/sapis-build/$sapi" || \
  465. die "Failed to change dir to ${WORKDIR}/sapis-build/$1"
  466. emake
  467. fi
  468. done
  469. }
  470. src_install() {
  471. # see bug #324739 for what happens when we don't have that
  472. addpredict /usr/share/snmp/mibs/.index
  473. # grab the first SAPI that got built and install common files from there
  474. local first_sapi=""
  475. for sapi in $SAPIS ; do
  476. if use $sapi ; then
  477. first_sapi=$sapi
  478. break
  479. fi
  480. done
  481. # Makefile forgets to create this before trying to write to it...
  482. dodir "${PHP_DESTDIR#${EPREFIX}}/bin"
  483. # Install php environment (without any sapis)
  484. cd "${WORKDIR}/sapis-build/$first_sapi" || die
  485. emake INSTALL_ROOT="${D}" \
  486. install-build install-headers install-programs
  487. local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)"
  488. # Create the directory where we'll put version-specific php scripts
  489. keepdir "/usr/share/php${PHP_MV}"
  490. local sapi="", file=""
  491. local sapi_list=""
  492. for sapi in ${SAPIS}; do
  493. if use "${sapi}" ; then
  494. einfo "Installing SAPI: ${sapi}"
  495. cd "${WORKDIR}/sapis-build/${sapi}" || die
  496. if [[ "${sapi}" == "apache2" ]] ; then
  497. # We're specifically not using emake install-sapi as libtool
  498. # may cause unnecessary relink failures (see bug #351266)
  499. insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/"
  500. newins ".libs/libphp5$(get_libname)" \
  501. "libphp${PHP_MV}$(get_libname)"
  502. keepdir "/usr/$(get_libdir)/apache2/modules"
  503. else
  504. # needed each time, php_install_ini would reset it
  505. local dest="${PHP_DESTDIR#${EPREFIX}}"
  506. into "${dest}"
  507. case "$sapi" in
  508. cli)
  509. source="sapi/cli/php"
  510. ;;
  511. cgi)
  512. source="sapi/cgi/php-cgi"
  513. ;;
  514. fpm)
  515. source="sapi/fpm/php-fpm"
  516. ;;
  517. embed)
  518. source="libs/libphp${PHP_MV}$(get_libname)"
  519. ;;
  520. *)
  521. die "unhandled sapi in src_install"
  522. ;;
  523. esac
  524. if [[ "${source}" == *"$(get_libname)" ]]; then
  525. dolib.so "${source}"
  526. else
  527. dobin "${source}"
  528. local name="$(basename ${source})"
  529. dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}"
  530. fi
  531. fi
  532. php_install_ini "${sapi}"
  533. # construct correct SAPI string for php-config
  534. # thanks to ferringb for the bash voodoo
  535. if [[ "${sapi}" == "apache2" ]]; then
  536. sapi_list="${sapi_list:+${sapi_list} }apache2handler"
  537. else
  538. sapi_list="${sapi_list:+${sapi_list} }${sapi}"
  539. fi
  540. fi
  541. done
  542. # Installing opcache module
  543. if use opcache ; then
  544. into "${PHP_DESTDIR#${EPREFIX}}"
  545. dolib.so "modules/opcache$(get_libname)"
  546. fi
  547. # Install env.d files
  548. newenvd "${FILESDIR}/20php5-envd" "20php${SLOT}"
  549. sed -e "s|/lib/|/$(get_libdir)/|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
  550. sed -e "s|php5|php${SLOT}|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
  551. # set php-config variable correctly (bug #278439)
  552. sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
  553. "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config" || die
  554. if use fpm ; then
  555. if use systemd; then
  556. systemd_newunit "${FILESDIR}/php-fpm_at.service" \
  557. "php-fpm@${SLOT}.service"
  558. else
  559. systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" \
  560. "php-fpm@${SLOT}.service"
  561. fi
  562. fi
  563. }
  564. src_test() {
  565. echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
  566. PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php"
  567. if [[ ! -x "${PHP_BIN}" ]] ; then
  568. ewarn "Test phase requires USE=cli, skipping"
  569. return
  570. else
  571. export TEST_PHP_EXECUTABLE="${PHP_BIN}"
  572. fi
  573. if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then
  574. export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi"
  575. fi
  576. REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d \
  577. "session.save_path=${T}" \
  578. "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d \
  579. "session.save_path=${T}"
  580. for name in ${EXPECTED_TEST_FAILURES}; do
  581. mv "${name}.out" "${name}.out.orig" 2>/dev/null || die
  582. done
  583. local failed="$(find -name '*.out')"
  584. if [[ ${failed} != "" ]] ; then
  585. ewarn "The following test cases failed unexpectedly:"
  586. for name in ${failed}; do
  587. ewarn " ${name/.out/}"
  588. done
  589. else
  590. einfo "No unexpected test failures, all fine"
  591. fi
  592. if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then
  593. local passed=""
  594. for name in ${EXPECTED_TEST_FAILURES}; do
  595. [[ -f "${name}.diff" ]] && continue
  596. passed="${passed} ${name}"
  597. done
  598. if [[ ${passed} != "" ]] ; then
  599. einfo "The following test cases passed unexpectedly:"
  600. for name in ${passed}; do
  601. ewarn " ${passed}"
  602. done
  603. else
  604. einfo "None of the known-to-fail tests passed, all fine"
  605. fi
  606. fi
  607. }
  608. pkg_postinst() {
  609. # Output some general info to the user
  610. if use apache2 ; then
  611. elog
  612. elog "To enable PHP in apache, you will need to add \"-D PHP\" to"
  613. elog "your apache2 command. OpenRC users can append that string to"
  614. elog "APACHE2_OPTS in /etc/conf.d/apache2."
  615. elog
  616. elog "The apache module configuration file 70_mod_php.conf is"
  617. elog "provided (and maintained) by eselect-php."
  618. elog
  619. fi
  620. # Create the symlinks for php
  621. for m in ${SAPIS}; do
  622. [[ ${m} == 'embed' ]] && continue;
  623. if use $m ; then
  624. local ci=$(eselect php show $m)
  625. if [[ -z $ci ]]; then
  626. eselect php set $m php${SLOT} || die
  627. einfo "Switched ${m} to use php:${SLOT}"
  628. einfo
  629. elif [[ $ci != "php${SLOT}" ]] ; then
  630. elog "To switch $m to use php:${SLOT}, run"
  631. elog " eselect php set $m php${SLOT}"
  632. elog
  633. fi
  634. fi
  635. done
  636. # Remove dead symlinks for SAPIs that were just disabled. For
  637. # example, if the user has the cgi SAPI enabled, then he has an
  638. # eselect-php symlink for it. If he later reinstalls PHP with
  639. # USE="-cgi", that symlink will break. This call to eselect is
  640. # supposed to remove that dead link per bug 572436.
  641. eselect php cleanup || die
  642. if ! has "php${SLOT/./-}" ${PHP_TARGETS}; then
  643. elog "To build extensions for this version of PHP, you will need to"
  644. elog "add php${SLOT/./-} to your PHP_TARGETS USE_EXPAND variable."
  645. elog
  646. fi
  647. # Warn about the removal of PHP_INI_VERSION if the user has it set.
  648. if [[ -n "${PHP_INI_VERSION}" ]]; then
  649. ewarn 'The PHP_INI_VERSION variable has been phased out. You may'
  650. ewarn 'remove it from your configuration at your convenience. See'
  651. ewarn
  652. ewarn ' https://bugs.gentoo.org/611214'
  653. ewarn
  654. ewarn 'for more information.'
  655. fi
  656. elog "For details on how version slotting works, please see"
  657. elog "the wiki:"
  658. elog
  659. elog " https://wiki.gentoo.org/wiki/PHP"
  660. elog
  661. }
  662. pkg_postrm() {
  663. # This serves two purposes. First, if we have just removed the last
  664. # installed version of PHP, then this will remove any dead symlinks
  665. # belonging to eselect-php. Second, if a user upgrades slots from
  666. # (say) 5.6 to 7.0 and depcleans the old slot, then this will update
  667. # his existing symlinks to point to the new 7.0 installation. The
  668. # latter is bug 432962.
  669. #
  670. # Note: the eselect-php package may not be installed at this point,
  671. # so we can't die() if this command fails.
  672. eselect php cleanup
  673. }