| 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.2 2010/10/06 19:58:45 olemarkus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r2.eclass,v 1.3 2010/11/02 17:09:56 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_configure src_compile src_install |
| 22 | |
22 | |
| 23 | # @ECLASS-VARIABLE: PHP_EXT_NAME |
23 | # @ECLASS-VARIABLE: PHP_EXT_NAME |
| 24 | # @DESCRIPTION: |
24 | # @DESCRIPTION: |
| … | |
… | |
| 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 | |
64 | |
| 65 | #Make sure at least one target is installed. Abuses USE dependencies. |
65 | #Make sure at least one target is installed. Abuses USE dependencies. |
| 66 | for target in $USE_PHP; do |
66 | for target in ${USE_PHP}; do |
| 67 | IUSE="${IUSE} php_targets_$target" |
67 | IUSE="${IUSE} php_targets_${target}" |
| 68 | target=${target/+} |
68 | target=${target/+} |
| 69 | SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]" |
69 | SELFDEPEND="${SELFDEPEND} =${CATEGORY}/${PF}[php_targets_${target}]" |
| 70 | slot=${target/php} |
70 | slot=${target/php} |
| 71 | slot=${slot/-/.} |
71 | slot=${slot/-/.} |
| 72 | PHPDEPEND="$PHPDEPEND |
72 | PHPDEPEND="${PHPDEPEND} |
| 73 | php_targets_$target? ( dev-lang/php:${slot} )" |
73 | php_targets_${target}? ( dev-lang/php:${slot} )" |
| 74 | done |
74 | done |
| 75 | |
75 | |
| 76 | RDEPEND="${RDEPEND} |
76 | RDEPEND="${RDEPEND} |
| 77 | || ( $SELFDEPEND ) |
77 | || ( ${SELFDEPEND} ) |
| 78 | $PHPDEPEND" |
78 | ${PHPDEPEND}" |
| 79 | |
79 | |
| 80 | |
80 | |
| 81 | # @FUNCTION: php-ext-source-r2_src_unpack |
81 | # @FUNCTION: php-ext-source-r2_src_unpack |
| 82 | # @DESCRIPTION: |
82 | # @DESCRIPTION: |
| 83 | # runs standard src_unpack + _phpize |
83 | # runs standard src_unpack + _phpize |
| … | |
… | |
| 89 | # 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. |
| 90 | php-ext-source-r2_src_unpack() { |
90 | php-ext-source-r2_src_unpack() { |
| 91 | unpack ${A} |
91 | unpack ${A} |
| 92 | local slot orig_s="$S" |
92 | local slot orig_s="$S" |
| 93 | for slot in $(php_get_slots); do |
93 | for slot in $(php_get_slots); do |
| 94 | cp -r "$orig_s" "${WORKDIR}/$slot" |
94 | cp -r "${orig_s}" "${WORKDIR}/${slot}" |
| 95 | php_init_slot_env $slot |
95 | php_init_slot_env ${slot} |
| 96 | if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then |
96 | if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then |
| 97 | php-ext-source-r2_phpize |
97 | php-ext-source-r2_phpize |
| 98 | fi |
98 | fi |
| 99 | done |
99 | done |
| 100 | } |
100 | } |
| … | |
… | |
| 121 | # @DESCRIPTION: |
121 | # @DESCRIPTION: |
| 122 | # Set this in the ebuild to pass configure options to econf. |
122 | # Set this in the ebuild to pass configure options to econf. |
| 123 | php-ext-source-r2_src_configure() { |
123 | php-ext-source-r2_src_configure() { |
| 124 | local slot |
124 | local slot |
| 125 | for slot in $(php_get_slots); do |
125 | for slot in $(php_get_slots); do |
| 126 | php_init_slot_env $slot |
126 | php_init_slot_env ${slot} |
| 127 | # Set the correct config options |
127 | # Set the correct config options |
| 128 | # We cannot use econf here, phpize/php-config deals with setting |
128 | # We cannot use econf here, phpize/php-config deals with setting |
| 129 | # --prefix etc to whatever the php slot was configured to use |
129 | # --prefix etc to whatever the php slot was configured to use |
| 130 | ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile" |
130 | ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile" |
| 131 | done |
131 | done |
| … | |
… | |
| 139 | addpredict /usr/share/snmp/mibs/.index |
139 | addpredict /usr/share/snmp/mibs/.index |
| 140 | # shm extension createss a semaphore file #173574 |
140 | # shm extension createss a semaphore file #173574 |
| 141 | addpredict /session_mm_cli0.sem |
141 | addpredict /session_mm_cli0.sem |
| 142 | local slot |
142 | local slot |
| 143 | for slot in $(php_get_slots); do |
143 | for slot in $(php_get_slots); do |
| 144 | php_init_slot_env $slot |
144 | php_init_slot_env ${slot} |
| 145 | emake || die "Unable to make code" |
145 | emake || die "Unable to make code" |
| 146 | |
146 | |
| 147 | done |
147 | done |
| 148 | } |
148 | } |
| 149 | |
149 | |
| … | |
… | |
| 155 | # @DESCRIPTION: |
155 | # @DESCRIPTION: |
| 156 | # Set in ebuild if you wish to install additional, package-specific documentation. |
156 | # Set in ebuild if you wish to install additional, package-specific documentation. |
| 157 | php-ext-source-r2_src_install() { |
157 | php-ext-source-r2_src_install() { |
| 158 | local slot |
158 | local slot |
| 159 | for slot in $(php_get_slots); do |
159 | for slot in $(php_get_slots); do |
| 160 | php_init_slot_env $slot |
160 | php_init_slot_env ${slot} |
| 161 | |
161 | |
| 162 | # Let's put the default module away |
162 | # Let's put the default module away |
| 163 | insinto "${EXT_DIR}" |
163 | insinto "${EXT_DIR}" |
| 164 | newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension" |
164 | newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension" |
| 165 | |
165 | |
|
|
166 | local doc |
| 166 | for doc in ${DOCS} ; do |
167 | for doc in ${DOCS} ; do |
| 167 | [[ -s ${doc} ]] && dodoc ${doc} |
168 | [[ -s ${doc} ]] && dodoc ${doc} |
| 168 | done |
169 | done |
| 169 | |
170 | |
| 170 | done |
171 | done |
| 171 | php-ext-source-r2_createinifiles |
172 | php-ext-source-r2_createinifiles |
| 172 | } |
173 | } |
| 173 | |
174 | |
| 174 | |
175 | |
| 175 | php_get_slots() { |
176 | php_get_slots() { |
| 176 | local s |
|
|
| 177 | local slot |
177 | local s slot |
| 178 | for slot in $USE_PHP; do |
178 | for slot in ${USE_PHP}; do |
| 179 | use php_targets_$slot && s+=" ${slot/-/.}" |
179 | use php_targets_${slot} && s+=" ${slot/-/.}" |
| 180 | done |
180 | done |
| 181 | echo $s |
181 | echo $s |
| 182 | } |
182 | } |
| 183 | |
183 | |
| 184 | php_init_slot_env() { |
184 | php_init_slot_env() { |
| 185 | libdir=$(get_libdir) |
185 | libdir=$(get_libdir) |
| 186 | |
186 | |
| 187 | PHPIZE="/usr/${libdir}/$1/bin/phpize" |
187 | PHPIZE="/usr/${libdir}/${1}/bin/phpize" |
| 188 | PHPCONFIG="/usr/${libdir}/$1/bin/php-config" |
188 | PHPCONFIG="/usr/${libdir}/${1}/bin/php-config" |
| 189 | PHPCLI="/usr/${libdir}/$1/bin/php" |
189 | PHPCLI="/usr/${libdir}/${1}/bin/php" |
| 190 | PHPCGI="/usr/${libdir}/$1/bin/php-cgi" |
190 | PHPCGI="/usr/${libdir}/${1}/bin/php-cgi" |
| 191 | PHP_PKG="$(best_version =dev-lang/php-${1:3}*)" |
191 | PHP_PKG="$(best_version =dev-lang/php-${1:3}*)" |
| 192 | PHPPREFIX="/usr/${libdir}/$slot" |
192 | PHPPREFIX="/usr/${libdir}/${slot}" |
| 193 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
193 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
| 194 | |
194 | |
| 195 | S="${WORKDIR}/$1" |
195 | S="${WORKDIR}/${1}" |
| 196 | cd $S |
196 | cd "${S}" |
| 197 | } |
197 | } |
| 198 | |
198 | |
| 199 | php-ext-source-r2_buildinilist() { |
199 | php-ext-source-r2_buildinilist() { |
| 200 | # Work out the list of <ext>.ini files to edit/add to |
200 | # Work out the list of <ext>.ini files to edit/add to |
| 201 | if [[ -z "${PHPSAPILIST}" ]] ; then |
201 | if [[ -z "${PHPSAPILIST}" ]] ; then |
| 202 | PHPSAPILIST="apache2 cli cgi fpm" |
202 | PHPSAPILIST="apache2 cli cgi fpm" |
| 203 | fi |
203 | fi |
| 204 | |
204 | |
| 205 | PHPINIFILELIST="" |
205 | PHPINIFILELIST="" |
| 206 | |
206 | local x |
| 207 | for x in ${PHPSAPILIST} ; do |
207 | for x in ${PHPSAPILIST} ; do |
| 208 | if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then |
208 | if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then |
| 209 | PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini" |
209 | PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini" |
| 210 | fi |
210 | fi |
| 211 | done |
211 | done |
| … | |
… | |
| 215 | # @DESCRIPTION: |
215 | # @DESCRIPTION: |
| 216 | # Builds ini files for every enabled slot and SAPI |
216 | # Builds ini files for every enabled slot and SAPI |
| 217 | php-ext-source-r2_createinifiles() { |
217 | php-ext-source-r2_createinifiles() { |
| 218 | local slot |
218 | local slot |
| 219 | for slot in $(php_get_slots); do |
219 | for slot in $(php_get_slots); do |
| 220 | php_init_slot_env $slot |
220 | php_init_slot_env ${slot} |
| 221 | # Pull in the PHP settings |
221 | # Pull in the PHP settings |
| 222 | |
222 | |
| 223 | # Build the list of <ext>.ini files to edit/add to |
223 | # Build the list of <ext>.ini files to edit/add to |
| 224 | php-ext-source-r2_buildinilist $slot |
224 | php-ext-source-r2_buildinilist ${slot} |
| 225 | |
225 | |
| 226 | # Add the needed lines to the <ext>.ini files |
226 | # Add the needed lines to the <ext>.ini files |
| 227 | if [[ "${PHP_EXT_INI}" = "yes" ]] ; then |
227 | if [[ "${PHP_EXT_INI}" = "yes" ]] ; then |
| 228 | php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" |
228 | php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" |
| 229 | fi |
229 | fi |
| … | |
… | |
| 249 | if has_debug ; then |
249 | if has_debug ; then |
| 250 | ext_type="zend_extension_debug_ts" |
250 | ext_type="zend_extension_debug_ts" |
| 251 | else |
251 | else |
| 252 | ext_type="zend_extension_ts" |
252 | ext_type="zend_extension_ts" |
| 253 | fi |
253 | fi |
| 254 | ext_file="${EXT_DIR}/$1" |
254 | ext_file="${EXT_DIR}/${1}" |
| 255 | else |
255 | else |
| 256 | if has_debug ; then |
256 | if has_debug ; then |
| 257 | ext_type="zend_extension_debug" |
257 | ext_type="zend_extension_debug" |
| 258 | else |
258 | else |
| 259 | ext_type="zend_extension" |
259 | ext_type="zend_extension" |
| 260 | fi |
260 | fi |
| 261 | ext_file="${EXT_DIR}/$1" |
261 | ext_file="${EXT_DIR}/${1}" |
| 262 | fi |
262 | fi |
| 263 | |
263 | |
| 264 | # php-5.3 unifies zend_extension loading and just requires the |
264 | # php-5.3 unifies zend_extension loading and just requires the |
| 265 | # zend_extension keyword with no suffix |
265 | # zend_extension keyword with no suffix |
| 266 | # TODO: drop previous code and this check once <php-5.3 support is |
266 | # TODO: drop previous code and this check once <php-5.3 support is |
| … | |
… | |
| 269 | ext_type="zend_extension" |
269 | ext_type="zend_extension" |
| 270 | fi |
270 | fi |
| 271 | else |
271 | else |
| 272 | # We don't need the full path for normal extensions! |
272 | # We don't need the full path for normal extensions! |
| 273 | ext_type="extension" |
273 | ext_type="extension" |
| 274 | ext_file="$1" |
274 | ext_file="${1}" |
| 275 | fi |
275 | fi |
| 276 | |
276 | |
| 277 | php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added" |
277 | php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added" |
| 278 | } |
278 | } |
| 279 | |
279 | |
| 280 | # $1 - Setting name |
280 | # $1 - Setting name |
| 281 | # $2 - Setting value |
281 | # $2 - Setting value |
| 282 | # $3 - File to add to |
282 | # $3 - File to add to |
| 283 | # $4 - Sanitized text to output |
283 | # $4 - Sanitized text to output |
| 284 | php-ext-source-r2_addtoinifile() { |
284 | php-ext-source-r2_addtoinifile() { |
| 285 | if [[ ! -d $(dirname $3) ]] ; then |
285 | if [[ ! -d $(dirname ${3}) ]] ; then |
| 286 | mkdir -p $(dirname $3) |
286 | mkdir -p $(dirname ${3}) |
| 287 | fi |
287 | fi |
| 288 | |
288 | |
| 289 | # Are we adding the name of a section? |
289 | # Are we adding the name of a section? |
| 290 | if [[ ${1:0:1} == "[" ]] ; then |
290 | if [[ ${1:0:1} == "[" ]] ; then |
| 291 | echo "$1" >> "$3" |
291 | echo "${1}" >> "${3}" |
| 292 | my_added="$1" |
292 | my_added="${1}" |
| 293 | else |
293 | else |
| 294 | echo "$1=$2" >> "$3" |
294 | echo "${1}=${2}" >> "${3}" |
| 295 | my_added="$1=$2" |
295 | my_added="${1}=${2}" |
| 296 | fi |
296 | fi |
| 297 | |
297 | |
| 298 | if [[ -z "$4" ]] ; then |
298 | if [[ -z "${4}" ]] ; then |
| 299 | einfo "Added '$my_added' to /$3" |
299 | einfo "Added '${my_added}' to /${3}" |
| 300 | else |
300 | else |
| 301 | einfo "$4 to /$3" |
301 | einfo "${4} to /${3}" |
| 302 | fi |
302 | fi |
| 303 | |
303 | |
| 304 | insinto /$(dirname $3) |
304 | insinto /$(dirname ${3}) |
| 305 | doins "$3" |
305 | doins "${3}" |
| 306 | } |
306 | } |
| 307 | |
307 | |
| 308 | # @FUNCTION: php-ext-source-r2_addtoinifiles |
308 | # @FUNCTION: php-ext-source-r2_addtoinifiles |
| 309 | # @USAGE: <setting name> <setting value> [message to output]; or just [section name] |
309 | # @USAGE: <setting name> <setting value> [message to output]; or just [section name] |
| 310 | # @DESCRIPTION: |
310 | # @DESCRIPTION: |
| … | |
… | |
| 323 | # php-ext-source-r2_addtoinifiles "[Debugger]" |
323 | # php-ext-source-r2_addtoinifiles "[Debugger]" |
| 324 | # php-ext-source-r2_addtoinifiles "debugger.enabled" "on" |
324 | # php-ext-source-r2_addtoinifiles "debugger.enabled" "on" |
| 325 | # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on" |
325 | # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on" |
| 326 | # @CODE |
326 | # @CODE |
| 327 | php-ext-source-r2_addtoinifiles() { |
327 | php-ext-source-r2_addtoinifiles() { |
|
|
328 | local x |
| 328 | for x in ${PHPINIFILELIST} ; do |
329 | for x in ${PHPINIFILELIST} ; do |
| 329 | php-ext-source-r2_addtoinifile "$1" "$2" "$x" "$3" |
330 | php-ext-source-r2_addtoinifile "${1}" "${2}" "${x}" "${3}" |
| 330 | done |
331 | done |
| 331 | } |
332 | } |