/[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.9 - (show annotations) (download)
Thu Nov 29 23:12:13 2007 UTC (6 years, 4 months ago) by jokey
Branch: MAIN
Changes since 1.8: +4 -4 lines
more backticks fixes

1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.8 2007/09/01 15:58:17 jokey Exp $
4 #
5 # Author: Tal Peer <coredumb@gentoo.org>
6 # Author: Stuart Herbert <stuart@gentoo.org>
7 # Author: Luca Longinotti <chtekk@gentoo.org>
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 #
18 # Combined with php-ext-source-r1, we have a standardised solution for supporting
19 # PHP extensions.
20
21 inherit depend.php
22
23 EXPORT_FUNCTIONS src_install
24
25 # @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 [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-base-r1 eclass"
31
32 # @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 [[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
37
38 # @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 [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
43
44
45 php-ext-base-r1_buildinilist() {
46 # Work out the list of <ext>.ini files to edit/add to
47 if [[ -z "${PHPSAPILIST}" ]] ; then
48 PHPSAPILIST="apache2 cli cgi"
49 fi
50
51 PHPINIFILELIST=""
52
53 for x in ${PHPSAPILIST} ; do
54 if [[ -f "/etc/php/${x}-php${PHP_VERSION}/php.ini" ]] ; then
55 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php${PHP_VERSION}/ext/${PHP_EXT_NAME}.ini"
56 fi
57 done
58 }
59
60 # @FUNCTION: php-ext-base-r1_src_install
61 # @DESCRIPTION:
62 # Takes care of standard install for PHP extensions (modules).
63 php-ext-base-r1_src_install() {
64 # Pull in the PHP settings
65 has_php
66 addpredict /usr/share/snmp/mibs/.index
67
68 # Build the list of <ext>.ini files to edit/add to
69 php-ext-base-r1_buildinilist
70
71 # Add the needed lines to the <ext>.ini files
72 if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
73 php-ext-base-r1_addextension "${PHP_EXT_NAME}.so"
74 fi
75
76 # Symlink the <ext>.ini files from ext/ to ext-active/
77 for inifile in ${PHPINIFILELIST} ; do
78 inidir="${inifile/${PHP_EXT_NAME}.ini/}"
79 inidir="${inidir/ext/ext-active}"
80 dodir "/${inidir}"
81 dosym "/${inifile}" "/${inifile/ext/ext-active}"
82 done
83
84 # Add support for installing PHP files into a version dependant directory
85 PHP_EXT_SHARED_DIR="/usr/share/${PHP_SHARED_CAT}/${PHP_EXT_NAME}"
86 }
87
88 php-ext-base-r1_addextension() {
89 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 if has_zts ; then
93 if has_debug ; then
94 ext_type="zend_extension_debug_ts"
95 else
96 ext_type="zend_extension_ts"
97 fi
98 ext_file="${EXT_DIR}/$1"
99 else
100 if has_debug ; then
101 ext_type="zend_extension_debug"
102 else
103 ext_type="zend_extension"
104 fi
105 ext_file="${EXT_DIR}/$1"
106 fi
107 else
108 # We don't need the full path for normal extensions!
109 ext_type="extension"
110 ext_file="$1"
111 fi
112
113 php-ext-base-r1_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
114 }
115
116 # $1 - Setting name
117 # $2 - Setting value
118 # $3 - File to add to
119 # $4 - Sanitized text to output
120 php-ext-base-r1_addtoinifile() {
121 if [[ ! -d $(dirname $3) ]] ; then
122 mkdir -p $(dirname $3)
123 fi
124
125 # Are we adding the name of a section?
126 if [[ ${1:0:1} == "[" ]] ; then
127 echo "$1" >> "$3"
128 my_added="$1"
129 else
130 echo "$1=$2" >> "$3"
131 my_added="$1=$2"
132 fi
133
134 if [[ -z "$4" ]] ; then
135 einfo "Added '$my_added' to /$3"
136 else
137 einfo "$4 to /$3"
138 fi
139
140 insinto /$(dirname $3)
141 doins "$3"
142 }
143
144 # @FUNCTION: php-ext-base-r1_addtoinifiles
145 # @USAGE: <setting name> <setting value> [message to output]; or just [section name]
146 # @DESCRIPTION:
147 # Add value settings to php.ini file installed by the extension (module).
148 # You can also add a [section], see examples below.
149 #
150 # @CODE
151 # Add some settings for the extension:
152 #
153 # php-ext-base-r1_addtoinifiles "zend_optimizer.optimization_level" "15"
154 # php-ext-base-r1_addtoinifiles "zend_optimizer.enable_loader" "0"
155 # php-ext-base-r1_addtoinifiles "zend_optimizer.disable_licensing" "0"
156 #
157 # Adding values to a section in php.ini file installed by the extension:
158 #
159 # php-ext-base-r1_addtoinifiles "[Debugger]"
160 # php-ext-base-r1_addtoinifiles "debugger.enabled" "on"
161 # php-ext-base-r1_addtoinifiles "debugger.profiler_enabled" "on"
162 # @CODE
163 php-ext-base-r1_addtoinifiles() {
164 for x in ${PHPINIFILELIST} ; do
165 php-ext-base-r1_addtoinifile "$1" "$2" "$x" "$3"
166 done
167 }

  ViewVC Help
Powered by ViewVC 1.1.20