/[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.12 - (show annotations) (download)
Wed Oct 6 08:25:51 2010 UTC (3 years, 9 months ago) by olemarkus
Branch: MAIN
Changes since 1.11: +3 -1 lines
Added eclasses required for minor version slotting of PHP
Changed php-ext-base-r1 to require dev-lang/php:5 to prevent mixing of
old-style slotting and new-style

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

  ViewVC Help
Powered by ViewVC 1.1.20