/[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 - (hide annotations) (download)
Wed Oct 6 17:37:51 2010 UTC (4 years 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 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.13 # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.12 2010/10/06 08:25: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     !=dev-lang/php-5.2.14-r1"
24 olemarkus 1.12
25 stuart 1.1 inherit depend.php
26    
27     EXPORT_FUNCTIONS src_install
28    
29 jokey 1.8 # @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 chtekk 1.6 [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-base-r1 eclass"
35 stuart 1.1
36 jokey 1.8 # @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 chtekk 1.6 [[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
41 stuart 1.1
42 jokey 1.8 # @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 chtekk 1.6 [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
47 stuart 1.1
48 jokey 1.8
49 stuart 1.1 php-ext-base-r1_buildinilist() {
50 chtekk 1.6 # Work out the list of <ext>.ini files to edit/add to
51     if [[ -z "${PHPSAPILIST}" ]] ; then
52 mabi 1.11 PHPSAPILIST="apache2 cli cgi fpm"
53 stuart 1.1 fi
54    
55 chtekk 1.6 PHPINIFILELIST=""
56 stuart 1.1
57     for x in ${PHPSAPILIST} ; do
58 chtekk 1.6 if [[ -f "/etc/php/${x}-php${PHP_VERSION}/php.ini" ]] ; then
59 stuart 1.1 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php${PHP_VERSION}/ext/${PHP_EXT_NAME}.ini"
60     fi
61     done
62     }
63    
64 jokey 1.8 # @FUNCTION: php-ext-base-r1_src_install
65     # @DESCRIPTION:
66     # Takes care of standard install for PHP extensions (modules).
67 stuart 1.1 php-ext-base-r1_src_install() {
68 chtekk 1.6 # Pull in the PHP settings
69 stuart 1.1 has_php
70     addpredict /usr/share/snmp/mibs/.index
71 chtekk 1.6
72     # Build the list of <ext>.ini files to edit/add to
73 stuart 1.1 php-ext-base-r1_buildinilist
74 chtekk 1.6
75     # Add the needed lines to the <ext>.ini files
76     if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
77 stuart 1.1 php-ext-base-r1_addextension "${PHP_EXT_NAME}.so"
78     fi
79 chtekk 1.6
80     # Symlink the <ext>.ini files from ext/ to ext-active/
81 chtekk 1.3 for inifile in ${PHPINIFILELIST} ; do
82 chtekk 1.6 inidir="${inifile/${PHP_EXT_NAME}.ini/}"
83     inidir="${inidir/ext/ext-active}"
84 chtekk 1.3 dodir "/${inidir}"
85     dosym "/${inifile}" "/${inifile/ext/ext-active}"
86     done
87 chtekk 1.6
88     # Add support for installing PHP files into a version dependant directory
89 stuart 1.1 PHP_EXT_SHARED_DIR="/usr/share/${PHP_SHARED_CAT}/${PHP_EXT_NAME}"
90     }
91    
92     php-ext-base-r1_addextension() {
93 chtekk 1.6 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 kloeri 1.2 if has_zts ; then
97 chtekk 1.6 if has_debug ; then
98     ext_type="zend_extension_debug_ts"
99     else
100     ext_type="zend_extension_ts"
101     fi
102 stuart 1.1 ext_file="${EXT_DIR}/$1"
103     else
104 chtekk 1.6 if has_debug ; then
105     ext_type="zend_extension_debug"
106     else
107     ext_type="zend_extension"
108     fi
109 stuart 1.1 ext_file="${EXT_DIR}/$1"
110     fi
111 hoffie 1.10
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 stuart 1.1 else
120 chtekk 1.6 # We don't need the full path for normal extensions!
121 stuart 1.1 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 chtekk 1.6 # $1 - Setting name
129     # $2 - Setting value
130     # $3 - File to add to
131     # $4 - Sanitized text to output
132 stuart 1.1 php-ext-base-r1_addtoinifile() {
133 jokey 1.9 if [[ ! -d $(dirname $3) ]] ; then
134     mkdir -p $(dirname $3)
135 stuart 1.1 fi
136    
137 chtekk 1.6 # Are we adding the name of a section?
138 stuart 1.1 if [[ ${1:0:1} == "[" ]] ; then
139 chtekk 1.6 echo "$1" >> "$3"
140 stuart 1.1 my_added="$1"
141     else
142 chtekk 1.6 echo "$1=$2" >> "$3"
143 stuart 1.1 my_added="$1=$2"
144     fi
145    
146 chtekk 1.6 if [[ -z "$4" ]] ; then
147 stuart 1.1 einfo "Added '$my_added' to /$3"
148     else
149     einfo "$4 to /$3"
150     fi
151    
152 jokey 1.9 insinto /$(dirname $3)
153 chtekk 1.6 doins "$3"
154 stuart 1.1 }
155    
156 jokey 1.8 # @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 stuart 1.1 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