/[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.17 - (hide annotations) (download)
Mon Aug 22 04:46:32 2011 UTC (3 years ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.16: +7 -7 lines
fix random bugs in eclass documentation, and convert to new @AUTHOR tag

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

  ViewVC Help
Powered by ViewVC 1.1.20