/[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.13 - (show annotations) (download)
Wed Oct 6 17:37:51 2010 UTC (3 years, 10 months ago) by olemarkus
Branch: MAIN
Changes since 1.12: +4 -2 lines
Blocking of minor version slotting of PHP that also works with EAPI0

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

  ViewVC Help
Powered by ViewVC 1.1.20