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