/[gentoo-x86]/eclass/php-ext-base-r1.eclass
Gentoo

Diff of /eclass/php-ext-base-r1.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1.1.1 Revision 1.17
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.1.1.1 2005/11/30 09:59:18 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.17 2011/08/22 04:46:32 vapier Exp $
4# 4
5# @ECLASS: php-ext-base-r1.eclass
6# @MAINTAINER:
7# Gentoo PHP team <php-bugs@gentoo.org>
8# @AUTHOR:
5# Author: Tal Peer <coredumb@gentoo.org> 9# Author: Tal Peer <coredumb@gentoo.org>
6# Author: Stuart Herbert <stuart@gentoo.org> 10# Author: Stuart Herbert <stuart@gentoo.org>
7# Maintained by the PHP Herd <php-bugs@gentoo.org> 11# Author: Luca Longinotti <chtekk@gentoo.org>
8# 12# Author: Jakub Moc <jakub@gentoo.org> (documentation)
13# @BLURB: A unified interface for adding standalone PHP extensions.
14# @DESCRIPTION:
9# The php-ext-base-r1 eclass provides a unified interface for adding standalone 15# This eclass provides a unified interface for adding standalone
10# PHP extensions ('modules') to the php.ini files on your system. 16# PHP extensions (modules) to the php.ini files on your system.
11# 17#
12# Combined with php-ext-source-r1, we have a standardised solution for supporting 18# Combined with php-ext-source-r1, we have a standardised solution for supporting
13# PHP extensions. 19# PHP extensions.
20
21# Block ebuilds with minor version slotting. Quite temporary fix
22DEPEND="!=dev-lang/php-5.3.3-r2
23 !=dev-lang/php-5.2.14-r1
24 !=dev-lang/php-5.3.3-r3
25 !=dev-lang/php-5.3.5
26 !=dev-lang/php-5.3.4-r1
27 !=dev-lang/php-5.3.4
28 !=dev-lang/php-5.2.16
29 !=dev-lang/php-5.2.17
30 !=dev-lang/php-5.2.14-r2"
14 31
15inherit depend.php 32inherit depend.php
16 33
17EXPORT_FUNCTIONS src_install 34EXPORT_FUNCTIONS src_install
18 35
19# ---begin ebuild configurable settings 36# @ECLASS-VARIABLE: PHP_EXT_NAME
37# @DESCRIPTION:
38# The extension name. This must be set, otherwise the eclass dies.
39# Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild
40# inherits that eclass, you must set this manually before inherit.
41[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-base-r1 eclass"
20 42
21# The extension name, this must be set, otherwise we die. 43# @ECLASS-VARIABLE: PHP_EXT_INI
22[ -z "${PHP_EXT_NAME}" ] && die "No module name specified for the php-ext eclass." 44# @DESCRIPTION:
45# Controls whether or not to add a line to php.ini for the extension.
46# Defaults to "yes" and should not be changed in most cases.
47[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
23 48
49# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
50# @DESCRIPTION:
24# Wether the extensions is a Zend Engine extension 51# Controls whether the extension is a ZendEngine extension or not.
25#(defaults to "no" and if you don't know what is it, you don't need it.) 52# Defaults to "no" and if you don't know what is it, you don't need it.
26[ -z "${PHP_EXT_ZENDEXT}" ] && PHP_EXT_ZENDEXT="no" 53[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
27 54
28# Wether or not to add a line in the php.ini for the extension
29# (defaults to "yes" and shouldn't be changed in most cases)
30[ -z "${PHP_EXT_INI}" ] && PHP_EXT_INI="yes"
31
32# find out where to install extensions
33EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`"
34
35# ---end ebuild configurable settings
36
37DEPEND="${DEPEND}
38 >=sys-devel/m4-1.4.3
39 >=sys-devel/libtool-1.5.18
40 >=sys-devel/automake-1.9.6
41 sys-devel/automake-wrapper
42 >=sys-devel/autoconf-2.59
43 sys-devel/autoconf-wrapper"
44 55
45php-ext-base-r1_buildinilist() { 56php-ext-base-r1_buildinilist() {
46 # work out the list of .ini files to edit/add to 57 # Work out the list of <ext>.ini files to edit/add to
47 if [ -z "${PHPSAPILIST}" ]; then 58 if [[ -z "${PHPSAPILIST}" ]] ; then
48 PHPSAPILIST="apache1 apache2 cli cgi" 59 PHPSAPILIST="apache2 cli cgi fpm"
49 fi 60 fi
50 61
51 PHPINIFILELIST= 62 PHPINIFILELIST=""
52 63
53 for x in ${PHPSAPILIST} ; do 64 for x in ${PHPSAPILIST} ; do
54 if [ -f /etc/php/${x}-php${PHP_VERSION}/php.ini ]; then 65 if [[ -f "/etc/php/${x}-php${PHP_VERSION}/php.ini" ]] ; then
55 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php${PHP_VERSION}/ext/${PHP_EXT_NAME}.ini" 66 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php${PHP_VERSION}/ext/${PHP_EXT_NAME}.ini"
56 fi 67 fi
57 done 68 done
58} 69}
59 70
71# @FUNCTION: php-ext-base-r1_src_install
72# @DESCRIPTION:
73# Takes care of standard install for PHP extensions (modules).
60php-ext-base-r1_src_install() { 74php-ext-base-r1_src_install() {
75 # Pull in the PHP settings
61 has_php 76 has_php
62 addpredict /usr/share/snmp/mibs/.index 77 addpredict /usr/share/snmp/mibs/.index
78
79 # Build the list of <ext>.ini files to edit/add to
63 php-ext-base-r1_buildinilist 80 php-ext-base-r1_buildinilist
81
82 # Add the needed lines to the <ext>.ini files
64 if [ "${PHP_EXT_INI}" = "yes" ] ; then 83 if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
65 php-ext-base-r1_addextension "${PHP_EXT_NAME}.so" 84 php-ext-base-r1_addextension "${PHP_EXT_NAME}.so"
66 fi 85 fi
86
87 # Symlink the <ext>.ini files from ext/ to ext-active/
67 for inifile in ${PHPINIFILELIST} ; do 88 for inifile in ${PHPINIFILELIST} ; do
68 inidir=${inifile/${PHP_EXT_NAME}.ini/} 89 inidir="${inifile/${PHP_EXT_NAME}.ini/}"
69 inidir=${inidir/ext/ext-active} 90 inidir="${inidir/ext/ext-active}"
70 dodir "/${inidir}" 91 dodir "/${inidir}"
71 dosym "/${inifile}" "/${inifile/ext/ext-active}" 92 dosym "/${inifile}" "/${inifile/ext/ext-active}"
72 done 93 done
94
73 # add support for installing php files into a version dependant directory 95 # Add support for installing PHP files into a version dependant directory
74 PHP_EXT_SHARED_DIR="/usr/share/${PHP_SHARED_CAT}/${PHP_EXT_NAME}" 96 PHP_EXT_SHARED_DIR="/usr/share/${PHP_SHARED_CAT}/${PHP_EXT_NAME}"
75} 97}
76 98
77php-ext-base-r1_addextension() { 99php-ext-base-r1_addextension() {
78 if [ "${PHP_EXT_ZENDEXT}" = "yes" ] ; then 100 if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
101 # We need the full path for ZendEngine extensions
102 # and we need to check for debugging enabled!
79 if has_zts ; then 103 if has_zts ; then
104 if has_debug ; then
105 ext_type="zend_extension_debug_ts"
106 else
80 ext_type="zend_extension_ts" 107 ext_type="zend_extension_ts"
108 fi
81 ext_file="${EXT_DIR}/$1" 109 ext_file="${EXT_DIR}/$1"
82 else 110 else
111 if has_debug ; then
112 ext_type="zend_extension_debug"
113 else
83 ext_type="zend_extension" 114 ext_type="zend_extension"
115 fi
84 ext_file="${EXT_DIR}/$1" 116 ext_file="${EXT_DIR}/$1"
85 fi 117 fi
118
119 # php-5.3 unifies zend_extension loading and just requires the
120 # zend_extension keyword with no suffix
121 # TODO: drop previous code and this check once <php-5.3 support is
122 # discontinued
123 if has_version '>=dev-lang/php-5.3' ; then
124 ext_type="zend_extension"
125 fi
86 else 126 else
87 # we do *not* add the full path for the extension! 127 # We don't need the full path for normal extensions!
88 ext_type="extension" 128 ext_type="extension"
89 ext_file="$1" 129 ext_file="$1"
90 fi 130 fi
91 131
92 php-ext-base-r1_addtoinifiles "${ext_type}" "${ext_file}" "Extension added" 132 php-ext-base-r1_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
93} 133}
94 134
95# $1 - setting name 135# $1 - Setting name
96# $2 - setting value 136# $2 - Setting value
97# $3 - file to add to 137# $3 - File to add to
98# $4 - sanitised text to output 138# $4 - Sanitized text to output
99
100php-ext-base-r1_addtoinifile() { 139php-ext-base-r1_addtoinifile() {
101 if [[ ! -d `dirname $3` ]]; then 140 if [[ ! -d $(dirname $3) ]] ; then
102 mkdir -p `dirname $3` 141 mkdir -p $(dirname $3)
103 fi 142 fi
104 143
105 # are we adding the name of a section? 144 # Are we adding the name of a section?
106 if [[ ${1:0:1} == "[" ]] ; then 145 if [[ ${1:0:1} == "[" ]] ; then
107 echo "$1" >> $3 146 echo "$1" >> "$3"
108 my_added="$1" 147 my_added="$1"
109 else 148 else
110 echo "$1=$2" >> $3 149 echo "$1=$2" >> "$3"
111 my_added="$1=$2" 150 my_added="$1=$2"
112 fi 151 fi
113 152
114 if [ -z "$4" ]; then 153 if [[ -z "$4" ]] ; then
115 einfo "Added '$my_added' to /$3" 154 einfo "Added '$my_added' to /$3"
116 else 155 else
117 einfo "$4 to /$3" 156 einfo "$4 to /$3"
118 fi 157 fi
119 158
120 # yes, this is inefficient - but it works every time ;-)
121
122 insinto /`dirname $3` 159 insinto /$(dirname $3)
123 doins $3 160 doins "$3"
124} 161}
125 162
163# @FUNCTION: php-ext-base-r1_addtoinifiles
164# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
165# @DESCRIPTION:
166# Add value settings to php.ini file installed by the extension (module).
167# You can also add a [section], see examples below.
168#
169# @CODE
170# Add some settings for the extension:
171#
172# php-ext-base-r1_addtoinifiles "zend_optimizer.optimization_level" "15"
173# php-ext-base-r1_addtoinifiles "zend_optimizer.enable_loader" "0"
174# php-ext-base-r1_addtoinifiles "zend_optimizer.disable_licensing" "0"
175#
176# Adding values to a section in php.ini file installed by the extension:
177#
178# php-ext-base-r1_addtoinifiles "[Debugger]"
179# php-ext-base-r1_addtoinifiles "debugger.enabled" "on"
180# php-ext-base-r1_addtoinifiles "debugger.profiler_enabled" "on"
181# @CODE
126php-ext-base-r1_addtoinifiles() { 182php-ext-base-r1_addtoinifiles() {
127 for x in ${PHPINIFILELIST} ; do 183 for x in ${PHPINIFILELIST} ; do
128 php-ext-base-r1_addtoinifile "$1" "$2" "$x" "$3" 184 php-ext-base-r1_addtoinifile "$1" "$2" "$x" "$3"
129 done 185 done
130} 186}

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20