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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Wed Dec 30 01:05:42 2009 UTC (4 years, 7 months ago) by hoffie
Branch: MAIN
Changes since 1.9: +9 -1 lines
php-5.3 compatibility (5.3 supports zend_extension= in php.ini's only, without any suffix)

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

  ViewVC Help
Powered by ViewVC 1.1.20