| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2007 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-source-r2.eclass,v 1.1 2010/10/06 08:25:51 olemarkus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r2.eclass,v 1.4 2010/11/02 21:46:05 olemarkus Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Tal Peer <coredumb@gentoo.org> |
5 | # Author: Tal Peer <coredumb@gentoo.org> |
| 6 | # Author: Stuart Herbert <stuart@gentoo.org> |
6 | # Author: Stuart Herbert <stuart@gentoo.org> |
| 7 | # Author: Luca Longinotti <chtekk@gentoo.org> |
7 | # Author: Luca Longinotti <chtekk@gentoo.org> |
| 8 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
8 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
| … | |
… | |
| 14 | # @BLURB: A unified interface for compiling and installing standalone PHP extensions. |
14 | # @BLURB: A unified interface for compiling and installing standalone PHP extensions. |
| 15 | # @DESCRIPTION: |
15 | # @DESCRIPTION: |
| 16 | # This eclass provides a unified interface for compiling and installing standalone |
16 | # This eclass provides a unified interface for compiling and installing standalone |
| 17 | # PHP extensions (modules). |
17 | # PHP extensions (modules). |
| 18 | |
18 | |
| 19 | inherit flag-o-matic autotools |
19 | inherit flag-o-matic autotools depend.php |
| 20 | |
20 | |
| 21 | EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install |
21 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install |
| 22 | |
22 | |
| 23 | # @ECLASS-VARIABLE: PHP_EXT_NAME |
23 | # @ECLASS-VARIABLE: PHP_EXT_NAME |
| 24 | # @DESCRIPTION: |
24 | # @DESCRIPTION: |
| 25 | # The extension name. This must be set, otherwise the eclass dies. |
25 | # The extension name. This must be set, otherwise the eclass dies. |
| 26 | # Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild |
26 | # Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild |
| … | |
… | |
| 58 | [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no" |
58 | [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no" |
| 59 | |
59 | |
| 60 | # @ECLASS-VARIABLE: USE_PHP |
60 | # @ECLASS-VARIABLE: USE_PHP |
| 61 | # @DESCRIPTION: |
61 | # @DESCRIPTION: |
| 62 | # Lists the PHP slots compatibile the extension is compatibile with |
62 | # Lists the PHP slots compatibile the extension is compatibile with |
| 63 | [[ -z "$USE_PHP" ]] && USE_PHP="php5-2 php5-3" |
63 | [[ -z "${USE_PHP}" ]] && USE_PHP="php5-2 php5-3" |
| 64 | |
|
|
| 65 | for target in $USE_PHP; do |
|
|
| 66 | IUSE="${IUSE} php_targets_$target" |
|
|
| 67 | done |
|
|
| 68 | |
64 | |
| 69 | #Make sure at least one target is installed. Abuses USE dependencies. |
65 | #Make sure at least one target is installed. Abuses USE dependencies. |
| 70 | for target in $USE_PHP; do |
66 | for target in ${USE_PHP}; do |
|
|
67 | IUSE="${IUSE} php_targets_${target}" |
| 71 | target=${target/+} |
68 | target=${target/+} |
| 72 | SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]" |
69 | SELFDEPEND="${SELFDEPEND} =${CATEGORY}/${PF}[php_targets_${target}]" |
| 73 | slot=${target/php} |
70 | slot=${target/php} |
| 74 | slot=${slot/-/.} |
71 | slot=${slot/-/.} |
|
|
72 | PHPDEPEND="${PHPDEPEND} |
| 75 | PHPDEPEND="$PHPDEPEND php_target_$target? ( dev-lang/php:${slot} )" |
73 | php_targets_${target}? ( dev-lang/php:${slot} )" |
| 76 | done |
74 | done |
| 77 | |
75 | |
| 78 | RDEPEND="${RDEPEND} |
76 | RDEPEND="${RDEPEND} |
| 79 | || ( $SELFDEPEND ) |
77 | || ( ${SELFDEPEND} ) |
| 80 | $PHPDEPEND" |
78 | ${PHPDEPEND}" |
| 81 | |
79 | |
| 82 | |
80 | |
| 83 | # @FUNCTION: php-ext-source-r2_src_unpack |
81 | # @FUNCTION: php-ext-source-r2_src_unpack |
| 84 | # @DESCRIPTION: |
82 | # @DESCRIPTION: |
| 85 | # runs standard src_unpack + _phpize |
83 | # runs standard src_unpack + _phpize |
| … | |
… | |
| 91 | # Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize. |
89 | # Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize. |
| 92 | php-ext-source-r2_src_unpack() { |
90 | php-ext-source-r2_src_unpack() { |
| 93 | unpack ${A} |
91 | unpack ${A} |
| 94 | local slot orig_s="$S" |
92 | local slot orig_s="$S" |
| 95 | for slot in $(php_get_slots); do |
93 | for slot in $(php_get_slots); do |
| 96 | cp -r "$orig_s" "${WORKDIR}/$slot" |
94 | cp -r "${orig_s}" "${WORKDIR}/${slot}" |
|
|
95 | done |
|
|
96 | } |
|
|
97 | |
|
|
98 | php-ext-source-r2_src_prepare() { |
|
|
99 | local slot orig_s="$S" |
|
|
100 | for slot in $(php_get_slots); do |
| 97 | php_init_slot_env $slot |
101 | php_init_slot_env ${slot} |
| 98 | if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then |
|
|
| 99 | php-ext-source-r2_phpize |
102 | php-ext-source-r2_phpize |
| 100 | fi |
|
|
| 101 | done |
103 | done |
| 102 | } |
104 | } |
| 103 | |
105 | |
| 104 | # @FUNCTION php-ext-source-r2_phpize |
106 | # @FUNCTION php-ext-source-r2_phpize |
| 105 | # @DESCRIPTION: |
107 | # @DESCRIPTION: |
| 106 | # Runs phpize and autotools in addition to the standard src_unpack |
108 | # Runs phpize and autotools in addition to the standard src_unpack |
| 107 | php-ext-source-r2_phpize() { |
109 | php-ext-source-r2_phpize() { |
|
|
110 | if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then |
| 108 | # Create configure out of config.m4 |
111 | # Create configure out of config.m4 |
| 109 | # I wish I could run this to solve #329071, but I cannot |
112 | # I wish I could run this to solve #329071, but I cannot |
| 110 | #autotools_run_tool ${PHPIZE} |
113 | #autotools_run_tool ${PHPIZE} |
| 111 | ${PHPIZE} |
114 | ${PHPIZE} |
| 112 | # force run of libtoolize and regeneration of related autotools |
115 | # force run of libtoolize and regeneration of related autotools |
| 113 | # files (bug 220519) |
116 | # files (bug 220519) |
| 114 | rm aclocal.m4 |
117 | rm aclocal.m4 |
| 115 | eautoreconf |
118 | eautoreconf |
|
|
119 | fi |
| 116 | } |
120 | } |
| 117 | |
121 | |
| 118 | # @FUNCTION: php-ext-source-r2_src_configure |
122 | # @FUNCTION: php-ext-source-r2_src_configure |
| 119 | # @DESCRIPTION: |
123 | # @DESCRIPTION: |
| 120 | # Takes care of standard configure for PHP extensions (modules). |
124 | # Takes care of standard configure for PHP extensions (modules). |
| … | |
… | |
| 123 | # @DESCRIPTION: |
127 | # @DESCRIPTION: |
| 124 | # Set this in the ebuild to pass configure options to econf. |
128 | # Set this in the ebuild to pass configure options to econf. |
| 125 | php-ext-source-r2_src_configure() { |
129 | php-ext-source-r2_src_configure() { |
| 126 | local slot |
130 | local slot |
| 127 | for slot in $(php_get_slots); do |
131 | for slot in $(php_get_slots); do |
| 128 | php_init_slot_env $slot |
132 | php_init_slot_env ${slot} |
| 129 | # Set the correct config options |
133 | # Set the correct config options |
| 130 | # We cannot use econf here, phpize/php-config deals with setting |
134 | # We cannot use econf here, phpize/php-config deals with setting |
| 131 | # --prefix etc to whatever the php slot was configured to use |
135 | # --prefix etc to whatever the php slot was configured to use |
| 132 | ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile" |
136 | ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile" |
| 133 | done |
137 | done |
| … | |
… | |
| 141 | addpredict /usr/share/snmp/mibs/.index |
145 | addpredict /usr/share/snmp/mibs/.index |
| 142 | # shm extension createss a semaphore file #173574 |
146 | # shm extension createss a semaphore file #173574 |
| 143 | addpredict /session_mm_cli0.sem |
147 | addpredict /session_mm_cli0.sem |
| 144 | local slot |
148 | local slot |
| 145 | for slot in $(php_get_slots); do |
149 | for slot in $(php_get_slots); do |
| 146 | php_init_slot_env $slot |
150 | php_init_slot_env ${slot} |
| 147 | emake || die "Unable to make code" |
151 | emake || die "Unable to make code" |
| 148 | |
152 | |
| 149 | done |
153 | done |
| 150 | } |
154 | } |
| 151 | |
155 | |
| … | |
… | |
| 157 | # @DESCRIPTION: |
161 | # @DESCRIPTION: |
| 158 | # Set in ebuild if you wish to install additional, package-specific documentation. |
162 | # Set in ebuild if you wish to install additional, package-specific documentation. |
| 159 | php-ext-source-r2_src_install() { |
163 | php-ext-source-r2_src_install() { |
| 160 | local slot |
164 | local slot |
| 161 | for slot in $(php_get_slots); do |
165 | for slot in $(php_get_slots); do |
| 162 | php_init_slot_env $slot |
166 | php_init_slot_env ${slot} |
| 163 | |
167 | |
| 164 | # Let's put the default module away |
168 | # Let's put the default module away |
| 165 | insinto "${EXT_DIR}" |
169 | insinto "${EXT_DIR}" |
| 166 | newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension" |
170 | newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension" |
| 167 | |
171 | |
|
|
172 | local doc |
| 168 | for doc in ${DOCS} ; do |
173 | for doc in ${DOCS} ; do |
| 169 | [[ -s ${doc} ]] && dodoc ${doc} |
174 | [[ -s ${doc} ]] && dodoc ${doc} |
| 170 | done |
175 | done |
| 171 | |
176 | |
| 172 | done |
177 | done |
| 173 | php-ext-source-r2_createinifiles |
178 | php-ext-source-r2_createinifiles |
| 174 | } |
179 | } |
| 175 | |
180 | |
| 176 | |
181 | |
| 177 | php_get_slots() { |
182 | php_get_slots() { |
| 178 | local s |
|
|
| 179 | local slot |
183 | local s slot |
| 180 | for slot in $USE_PHP; do |
184 | for slot in ${USE_PHP}; do |
| 181 | use php_targets_$slot && s+=" ${slot/-/.}" |
185 | use php_targets_${slot} && s+=" ${slot/-/.}" |
| 182 | done |
186 | done |
| 183 | echo $s |
187 | echo $s |
| 184 | } |
188 | } |
| 185 | |
189 | |
| 186 | php_init_slot_env() { |
190 | php_init_slot_env() { |
| 187 | libdir=$(get_libdir) |
191 | libdir=$(get_libdir) |
| 188 | |
192 | |
| 189 | PHPIZE="/usr/${libdir}/$1/bin/phpize" |
193 | PHPIZE="/usr/${libdir}/${1}/bin/phpize" |
| 190 | PHPCONFIG="/usr/${libdir}/$1/bin/php-config" |
194 | PHPCONFIG="/usr/${libdir}/${1}/bin/php-config" |
| 191 | PHPCLI="/usr/${libdir}/$1/bin/php" |
195 | PHPCLI="/usr/${libdir}/${1}/bin/php" |
| 192 | PHPCGI="/usr/${libdir}/$1/bin/php-cgi" |
196 | PHPCGI="/usr/${libdir}/${1}/bin/php-cgi" |
| 193 | PHP_PKG="$(best_version =dev-lang/php-${1:3}*)" |
197 | PHP_PKG="$(best_version =dev-lang/php-${1:3}*)" |
| 194 | PHPPREFIX="/usr/${libdir}/$slot" |
198 | PHPPREFIX="/usr/${libdir}/${slot}" |
| 195 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
199 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
| 196 | |
200 | |
| 197 | S="${WORKDIR}/$1" |
201 | S="${WORKDIR}/${1}" |
| 198 | cd $S |
202 | cd "${S}" |
| 199 | } |
203 | } |
| 200 | |
204 | |
| 201 | php-ext-source-r2_buildinilist() { |
205 | php-ext-source-r2_buildinilist() { |
| 202 | # Work out the list of <ext>.ini files to edit/add to |
206 | # Work out the list of <ext>.ini files to edit/add to |
| 203 | if [[ -z "${PHPSAPILIST}" ]] ; then |
207 | if [[ -z "${PHPSAPILIST}" ]] ; then |
| 204 | PHPSAPILIST="apache2 cli cgi fpm" |
208 | PHPSAPILIST="apache2 cli cgi fpm" |
| 205 | fi |
209 | fi |
| 206 | |
210 | |
| 207 | PHPINIFILELIST="" |
211 | PHPINIFILELIST="" |
| 208 | |
212 | local x |
| 209 | for x in ${PHPSAPILIST} ; do |
213 | for x in ${PHPSAPILIST} ; do |
| 210 | if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then |
214 | if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then |
| 211 | PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini" |
215 | PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini" |
| 212 | fi |
216 | fi |
| 213 | done |
217 | done |
| … | |
… | |
| 217 | # @DESCRIPTION: |
221 | # @DESCRIPTION: |
| 218 | # Builds ini files for every enabled slot and SAPI |
222 | # Builds ini files for every enabled slot and SAPI |
| 219 | php-ext-source-r2_createinifiles() { |
223 | php-ext-source-r2_createinifiles() { |
| 220 | local slot |
224 | local slot |
| 221 | for slot in $(php_get_slots); do |
225 | for slot in $(php_get_slots); do |
| 222 | php_init_slot_env $slot |
226 | php_init_slot_env ${slot} |
| 223 | # Pull in the PHP settings |
227 | # Pull in the PHP settings |
| 224 | |
228 | |
| 225 | # Build the list of <ext>.ini files to edit/add to |
229 | # Build the list of <ext>.ini files to edit/add to |
| 226 | php-ext-source-r2_buildinilist $slot |
230 | php-ext-source-r2_buildinilist ${slot} |
| 227 | |
231 | |
| 228 | # Add the needed lines to the <ext>.ini files |
232 | # Add the needed lines to the <ext>.ini files |
| 229 | if [[ "${PHP_EXT_INI}" = "yes" ]] ; then |
233 | if [[ "${PHP_EXT_INI}" = "yes" ]] ; then |
| 230 | php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" |
234 | php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" |
| 231 | fi |
235 | fi |
| … | |
… | |
| 251 | if has_debug ; then |
255 | if has_debug ; then |
| 252 | ext_type="zend_extension_debug_ts" |
256 | ext_type="zend_extension_debug_ts" |
| 253 | else |
257 | else |
| 254 | ext_type="zend_extension_ts" |
258 | ext_type="zend_extension_ts" |
| 255 | fi |
259 | fi |
| 256 | ext_file="${EXT_DIR}/$1" |
260 | ext_file="${EXT_DIR}/${1}" |
| 257 | else |
261 | else |
| 258 | if has_debug ; then |
262 | if has_debug ; then |
| 259 | ext_type="zend_extension_debug" |
263 | ext_type="zend_extension_debug" |
| 260 | else |
264 | else |
| 261 | ext_type="zend_extension" |
265 | ext_type="zend_extension" |
| 262 | fi |
266 | fi |
| 263 | ext_file="${EXT_DIR}/$1" |
267 | ext_file="${EXT_DIR}/${1}" |
| 264 | fi |
268 | fi |
| 265 | |
269 | |
| 266 | # php-5.3 unifies zend_extension loading and just requires the |
270 | # php-5.3 unifies zend_extension loading and just requires the |
| 267 | # zend_extension keyword with no suffix |
271 | # zend_extension keyword with no suffix |
| 268 | # TODO: drop previous code and this check once <php-5.3 support is |
272 | # TODO: drop previous code and this check once <php-5.3 support is |
| … | |
… | |
| 271 | ext_type="zend_extension" |
275 | ext_type="zend_extension" |
| 272 | fi |
276 | fi |
| 273 | else |
277 | else |
| 274 | # We don't need the full path for normal extensions! |
278 | # We don't need the full path for normal extensions! |
| 275 | ext_type="extension" |
279 | ext_type="extension" |
| 276 | ext_file="$1" |
280 | ext_file="${1}" |
| 277 | fi |
281 | fi |
| 278 | |
282 | |
| 279 | php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added" |
283 | php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added" |
| 280 | } |
284 | } |
| 281 | |
285 | |
| 282 | # $1 - Setting name |
286 | # $1 - Setting name |
| 283 | # $2 - Setting value |
287 | # $2 - Setting value |
| 284 | # $3 - File to add to |
288 | # $3 - File to add to |
| 285 | # $4 - Sanitized text to output |
289 | # $4 - Sanitized text to output |
| 286 | php-ext-source-r2_addtoinifile() { |
290 | php-ext-source-r2_addtoinifile() { |
| 287 | if [[ ! -d $(dirname $3) ]] ; then |
291 | if [[ ! -d $(dirname ${3}) ]] ; then |
| 288 | mkdir -p $(dirname $3) |
292 | mkdir -p $(dirname ${3}) |
| 289 | fi |
293 | fi |
| 290 | |
294 | |
| 291 | # Are we adding the name of a section? |
295 | # Are we adding the name of a section? |
| 292 | if [[ ${1:0:1} == "[" ]] ; then |
296 | if [[ ${1:0:1} == "[" ]] ; then |
| 293 | echo "$1" >> "$3" |
297 | echo "${1}" >> "${3}" |
| 294 | my_added="$1" |
298 | my_added="${1}" |
| 295 | else |
299 | else |
| 296 | echo "$1=$2" >> "$3" |
300 | echo "${1}=${2}" >> "${3}" |
| 297 | my_added="$1=$2" |
301 | my_added="${1}=${2}" |
| 298 | fi |
302 | fi |
| 299 | |
303 | |
| 300 | if [[ -z "$4" ]] ; then |
304 | if [[ -z "${4}" ]] ; then |
| 301 | einfo "Added '$my_added' to /$3" |
305 | einfo "Added '${my_added}' to /${3}" |
| 302 | else |
306 | else |
| 303 | einfo "$4 to /$3" |
307 | einfo "${4} to /${3}" |
| 304 | fi |
308 | fi |
| 305 | |
309 | |
| 306 | insinto /$(dirname $3) |
310 | insinto /$(dirname ${3}) |
| 307 | doins "$3" |
311 | doins "${3}" |
| 308 | } |
312 | } |
| 309 | |
313 | |
| 310 | # @FUNCTION: php-ext-source-r2_addtoinifiles |
314 | # @FUNCTION: php-ext-source-r2_addtoinifiles |
| 311 | # @USAGE: <setting name> <setting value> [message to output]; or just [section name] |
315 | # @USAGE: <setting name> <setting value> [message to output]; or just [section name] |
| 312 | # @DESCRIPTION: |
316 | # @DESCRIPTION: |
| … | |
… | |
| 325 | # php-ext-source-r2_addtoinifiles "[Debugger]" |
329 | # php-ext-source-r2_addtoinifiles "[Debugger]" |
| 326 | # php-ext-source-r2_addtoinifiles "debugger.enabled" "on" |
330 | # php-ext-source-r2_addtoinifiles "debugger.enabled" "on" |
| 327 | # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on" |
331 | # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on" |
| 328 | # @CODE |
332 | # @CODE |
| 329 | php-ext-source-r2_addtoinifiles() { |
333 | php-ext-source-r2_addtoinifiles() { |
|
|
334 | local x |
| 330 | for x in ${PHPINIFILELIST} ; do |
335 | for x in ${PHPINIFILELIST} ; do |
| 331 | php-ext-source-r2_addtoinifile "$1" "$2" "$x" "$3" |
336 | php-ext-source-r2_addtoinifile "${1}" "${2}" "${x}" "${3}" |
| 332 | done |
337 | done |
| 333 | } |
338 | } |