/[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.12 - (hide annotations) (download)
Wed Oct 6 08:25:51 2010 UTC (4 years, 9 months ago) by olemarkus
Branch: MAIN
Changes since 1.11: +3 -1 lines
Added eclasses required for minor version slotting of PHP
Changed php-ext-base-r1 to require dev-lang/php:5 to prevent mixing of
old-style slotting and new-style

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

  ViewVC Help
Powered by ViewVC 1.1.20