/[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.14 - (hide annotations) (download)
Sun Oct 31 12:39:09 2010 UTC (3 years, 8 months ago) by olemarkus
Branch: MAIN
Changes since 1.13: +4 -2 lines
Added more blockers to php-ext-*r1.eclass

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

  ViewVC Help
Powered by ViewVC 1.1.20