/[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.11 - (hide annotations) (download)
Mon Jul 26 16:19:00 2010 UTC (4 years, 1 month ago) by mabi
Branch: MAIN
Changes since 1.10: +2 -2 lines
fpm now is a supported SAPI

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

  ViewVC Help
Powered by ViewVC 1.1.20