/[gentoo-x86]/eclass/php-ext-source-r2.eclass
Gentoo

Contents of /eclass/php-ext-source-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.36 - (hide annotations) (download)
Mon May 4 20:02:26 2015 UTC (16 months, 3 weeks ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.35: +6 -4 lines
Fix documentation of 3 variables in php-ext-source-r2 eclass

1 grknight 1.34 # Copyright 1999-2015 Gentoo Foundation
2 olemarkus 1.1 # Distributed under the terms of the GNU General Public License v2
3 grknight 1.36 # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r2.eclass,v 1.35 2015/05/04 18:59:30 grknight Exp $
4 vapier 1.15
5     # @ECLASS: php-ext-source-r2.eclass
6     # @MAINTAINER:
7     # Gentoo PHP team <php-bugs@gentoo.org>
8     # @AUTHOR:
9 olemarkus 1.1 # Author: Tal Peer <coredumb@gentoo.org>
10     # Author: Stuart Herbert <stuart@gentoo.org>
11     # Author: Luca Longinotti <chtekk@gentoo.org>
12     # Author: Jakub Moc <jakub@gentoo.org> (documentation)
13     # Author: Ole Markus With <olemarkus@gentoo.org>
14     # @BLURB: A unified interface for compiling and installing standalone PHP extensions.
15     # @DESCRIPTION:
16     # This eclass provides a unified interface for compiling and installing standalone
17     # PHP extensions (modules).
18    
19 grknight 1.34 inherit flag-o-matic autotools multilib eutils
20 olemarkus 1.1
21 olemarkus 1.4 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
22 olemarkus 1.1
23     DEPEND=">=sys-devel/m4-1.4.3
24     >=sys-devel/libtool-1.5.18"
25     RDEPEND=""
26    
27     # Because of USE deps, we require at least EAPI 2
28     case ${EAPI} in
29 olemarkus 1.32 4|5) ;;
30 olemarkus 1.1 *)
31     die "php-ext-source-r2 is not compatible with EAPI=${EAPI}"
32     esac
33    
34     # @ECLASS-VARIABLE: PHP_EXT_NAME
35 grknight 1.35 # @REQUIRED
36 olemarkus 1.1 # @DESCRIPTION:
37     # The extension name. This must be set, otherwise the eclass dies.
38     # Only automagically set by php-ext-pecl-r2.eclass, so unless your ebuild
39     # inherits that eclass, you must set this manually before inherit.
40     [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
41    
42     # @ECLASS-VARIABLE: PHP_EXT_INI
43     # @DESCRIPTION:
44     # Controls whether or not to add a line to php.ini for the extension.
45     # Defaults to "yes" and should not be changed in most cases.
46     [[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
47    
48     # @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
49     # @DESCRIPTION:
50     # Controls whether the extension is a ZendEngine extension or not.
51     # Defaults to "no" and if you don't know what is it, you don't need it.
52     [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
53    
54     # @ECLASS-VARIABLE: USE_PHP
55 grknight 1.35 # @REQUIRED
56 olemarkus 1.1 # @DESCRIPTION:
57     # Lists the PHP slots compatibile the extension is compatibile with
58 grknight 1.35 # Example:
59     # @CODE
60     # USE_PHP="php5-5 php5-6"
61     # @CODE
62     [[ -z "${USE_PHP}" ]] && die "USE_PHP is not set for the php-ext-source-r2 eclass"
63 olemarkus 1.1
64 robbat2 1.7 # @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
65     # @DESCRIPTION:
66     # If set, this is the USE flag that the PHP dependencies are behind
67     # Most commonly set as PHP_EXT_OPTIONAL_USE=php to get the dependencies behind
68     # USE=php.
69    
70 olemarkus 1.8 # @ECLASS-VARIABLE: PHP_EXT_S
71     # @DESCRIPTION:
72     # The relative location of the temporary build directory for the PHP extension within
73     # the source package. This is useful for packages that bundle the PHP extension.
74     # Defaults to ${S}
75     [[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
76    
77 olemarkus 1.32 #Make sure at least one target is installed.
78 robbat2 1.33 REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
79 olemarkus 1.3 for target in ${USE_PHP}; do
80     IUSE="${IUSE} php_targets_${target}"
81 olemarkus 1.1 target=${target/+}
82 olemarkus 1.32 REQUIRED_USE+="php_targets_${target} "
83 olemarkus 1.1 slot=${target/php}
84     slot=${slot/-/.}
85 darkside 1.6 PHPDEPEND="${PHPDEPEND}
86 olemarkus 1.3 php_targets_${target}? ( dev-lang/php:${slot} )"
87 olemarkus 1.1 done
88 robbat2 1.33 REQUIRED_USE+=") ${PHP_EXT_OPTIONAL_USE:+ )}"
89 darkside 1.6
90     RDEPEND="${RDEPEND}
91 robbat2 1.7 ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
92     ${PHPDEPEND}
93     ${PHP_EXT_OPTIONAL_USE:+ )}"
94 olemarkus 1.1
95 mabi 1.22 DEPEND="${DEPEND}
96     ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
97     ${PHPDEPEND}
98     ${PHP_EXT_OPTIONAL_USE:+ )}
99     "
100 olemarkus 1.1
101     # @FUNCTION: php-ext-source-r2_src_unpack
102     # @DESCRIPTION:
103     # runs standard src_unpack + _phpize
104 vapier 1.15
105 grknight 1.36 # @ECLASS-VARIABLE: PHP_EXT_SKIP_PHPIZE
106 olemarkus 1.1 # @DESCRIPTION:
107     # phpize will be run by default for all ebuilds that use
108 darkside 1.6 # php-ext-source-r2_src_unpack
109 olemarkus 1.1 # Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
110 grknight 1.36
111 olemarkus 1.1 php-ext-source-r2_src_unpack() {
112     unpack ${A}
113 olemarkus 1.8 local slot orig_s="${PHP_EXT_S}"
114 olemarkus 1.1 for slot in $(php_get_slots); do
115 olemarkus 1.25 cp -r "${orig_s}" "${WORKDIR}/${slot}" || die "Failed to copy source ${orig_s} to PHP target directory"
116 olemarkus 1.4 done
117     }
118    
119     php-ext-source-r2_src_prepare() {
120 olemarkus 1.8 local slot orig_s="${PHP_EXT_S}"
121 olemarkus 1.4 for slot in $(php_get_slots); do
122 olemarkus 1.3 php_init_slot_env ${slot}
123 olemarkus 1.4 php-ext-source-r2_phpize
124 olemarkus 1.1 done
125     }
126    
127 vapier 1.15 # @FUNCTION: php-ext-source-r2_phpize
128 olemarkus 1.1 # @DESCRIPTION:
129     # Runs phpize and autotools in addition to the standard src_unpack
130     php-ext-source-r2_phpize() {
131 olemarkus 1.4 if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
132     # Create configure out of config.m4
133     # I wish I could run this to solve #329071, but I cannot
134 vapier 1.16 #autotools_run_tool ${PHPIZE}
135 olemarkus 1.4 ${PHPIZE}
136     # force run of libtoolize and regeneration of related autotools
137     # files (bug 220519)
138     rm aclocal.m4
139     eautoreconf
140 darkside 1.6 fi
141 olemarkus 1.1 }
142    
143     # @FUNCTION: php-ext-source-r2_src_configure
144     # @DESCRIPTION:
145     # Takes care of standard configure for PHP extensions (modules).
146 vapier 1.15
147 grknight 1.36 # @ECLASS-VARIABLE: my_conf
148 olemarkus 1.1 # @DESCRIPTION:
149     # Set this in the ebuild to pass configure options to econf.
150 grknight 1.36
151 olemarkus 1.1 php-ext-source-r2_src_configure() {
152 mabi 1.24 # net-snmp creates this file #385403
153     addpredict /usr/share/snmp/mibs/.index
154 olemarkus 1.29 addpredict /var/lib/net-snmp/mib_indexes
155 mabi 1.24
156 olemarkus 1.1 local slot
157     for slot in $(php_get_slots); do
158 olemarkus 1.3 php_init_slot_env ${slot}
159 olemarkus 1.1 # Set the correct config options
160 olemarkus 1.14 econf --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
161 olemarkus 1.1 done
162     }
163    
164     # @FUNCTION: php-ext-source-r2_src_compile
165     # @DESCRIPTION:
166     # Takes care of standard compile for PHP extensions (modules).
167     php-ext-source-r2_src_compile() {
168     # net-snmp creates this file #324739
169     addpredict /usr/share/snmp/mibs/.index
170 olemarkus 1.29 addpredict /var/lib/net-snmp/mib_indexes
171    
172 olemarkus 1.1 # shm extension createss a semaphore file #173574
173     addpredict /session_mm_cli0.sem
174 darkside 1.6 local slot
175 olemarkus 1.1 for slot in $(php_get_slots); do
176 olemarkus 1.3 php_init_slot_env ${slot}
177 olemarkus 1.1 emake || die "Unable to make code"
178    
179     done
180     }
181    
182 olemarkus 1.28 # @FUNCTION: php-ext-source-r2_src_install
183 olemarkus 1.1 # @DESCRIPTION:
184     # Takes care of standard install for PHP extensions (modules).
185    
186 grknight 1.36 # @ECLASS-VARIABLE: DOCS
187 olemarkus 1.1 # @DESCRIPTION:
188     # Set in ebuild if you wish to install additional, package-specific documentation.
189     php-ext-source-r2_src_install() {
190     local slot
191     for slot in $(php_get_slots); do
192 olemarkus 1.3 php_init_slot_env ${slot}
193 olemarkus 1.1
194     # Let's put the default module away
195     insinto "${EXT_DIR}"
196     newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"
197    
198 olemarkus 1.3 local doc
199 olemarkus 1.1 for doc in ${DOCS} ; do
200     [[ -s ${doc} ]] && dodoc ${doc}
201     done
202    
203 olemarkus 1.14 INSTALL_ROOT="${D}" emake install-headers
204 olemarkus 1.1 done
205     php-ext-source-r2_createinifiles
206     }
207    
208    
209     php_get_slots() {
210 olemarkus 1.3 local s slot
211     for slot in ${USE_PHP}; do
212     use php_targets_${slot} && s+=" ${slot/-/.}"
213 olemarkus 1.1 done
214     echo $s
215     }
216    
217     php_init_slot_env() {
218     libdir=$(get_libdir)
219    
220 olemarkus 1.3 PHPIZE="/usr/${libdir}/${1}/bin/phpize"
221     PHPCONFIG="/usr/${libdir}/${1}/bin/php-config"
222     PHPCLI="/usr/${libdir}/${1}/bin/php"
223     PHPCGI="/usr/${libdir}/${1}/bin/php-cgi"
224 olemarkus 1.1 PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
225 olemarkus 1.3 PHPPREFIX="/usr/${libdir}/${slot}"
226 olemarkus 1.1 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
227 olemarkus 1.5 PHP_CURRENTSLOT=${1:3}
228 olemarkus 1.1
229 olemarkus 1.8 PHP_EXT_S="${WORKDIR}/${1}"
230     cd "${PHP_EXT_S}"
231 olemarkus 1.1 }
232    
233     php-ext-source-r2_buildinilist() {
234     # Work out the list of <ext>.ini files to edit/add to
235     if [[ -z "${PHPSAPILIST}" ]] ; then
236 olemarkus 1.27 PHPSAPILIST="apache2 cli cgi fpm embed"
237 olemarkus 1.1 fi
238    
239 olemarkus 1.12 PHPINIFILELIST=""
240 olemarkus 1.3 local x
241 olemarkus 1.1 for x in ${PHPSAPILIST} ; do
242     if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
243     PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
244     fi
245     done
246 olemarkus 1.12 PHPFULLINIFILELIST="${PHPFULLINIFILELIST} ${PHPINIFILELIST}"
247 olemarkus 1.1 }
248    
249     # @FUNCTION: php-ext-source-r2_createinifiles
250     # @DESCRIPTION:
251     # Builds ini files for every enabled slot and SAPI
252     php-ext-source-r2_createinifiles() {
253     local slot
254 darkside 1.6 for slot in $(php_get_slots); do
255 olemarkus 1.3 php_init_slot_env ${slot}
256 olemarkus 1.1 # Pull in the PHP settings
257    
258     # Build the list of <ext>.ini files to edit/add to
259 olemarkus 1.3 php-ext-source-r2_buildinilist ${slot}
260 olemarkus 1.1
261 olemarkus 1.13
262 olemarkus 1.1 # Add the needed lines to the <ext>.ini files
263 olemarkus 1.13 local file
264 olemarkus 1.1 if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
265 vapier 1.16 for file in ${PHPINIFILELIST}; do
266 olemarkus 1.13 php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" "${file}"
267     done
268 olemarkus 1.1 fi
269    
270     # Symlink the <ext>.ini files from ext/ to ext-active/
271 olemarkus 1.13 local inifile
272 olemarkus 1.1 for inifile in ${PHPINIFILELIST} ; do
273 olemarkus 1.12 if [[ -n "${PHP_EXT_INIFILE}" ]]; then
274 olemarkus 1.31 cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${inifile}"
275 olemarkus 1.12 einfo "Added content of ${FILESDIR}/${PHP_EXT_INIFILE} to ${inifile}"
276     fi
277 olemarkus 1.1 inidir="${inifile/${PHP_EXT_NAME}.ini/}"
278     inidir="${inidir/ext/ext-active}"
279     dodir "/${inidir}"
280     dosym "/${inifile}" "/${inifile/ext/ext-active}"
281     done
282    
283     # Add support for installing PHP files into a version dependant directory
284     PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
285     done
286     }
287    
288     php-ext-source-r2_addextension() {
289     if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
290     # We need the full path for ZendEngine extensions
291     # and we need to check for debugging enabled!
292 olemarkus 1.5 if has_version "dev-lang/php:${PHP_CURRENTSLOT}[threads]" ; then
293     if has_version "dev-lang/php:${PHP_CURRENTSLOT}[debug]" ; then
294 olemarkus 1.1 ext_type="zend_extension_debug_ts"
295     else
296     ext_type="zend_extension_ts"
297     fi
298 olemarkus 1.3 ext_file="${EXT_DIR}/${1}"
299 olemarkus 1.1 else
300 olemarkus 1.5 if has_version "dev-lang/php:${PHP_CURRENTSLOT}[debug]"; then
301 olemarkus 1.1 ext_type="zend_extension_debug"
302     else
303     ext_type="zend_extension"
304     fi
305 olemarkus 1.3 ext_file="${EXT_DIR}/${1}"
306 olemarkus 1.1 fi
307    
308     # php-5.3 unifies zend_extension loading and just requires the
309     # zend_extension keyword with no suffix
310     # TODO: drop previous code and this check once <php-5.3 support is
311     # discontinued
312     if has_version '>=dev-lang/php-5.3' ; then
313     ext_type="zend_extension"
314     fi
315     else
316     # We don't need the full path for normal extensions!
317     ext_type="extension"
318 olemarkus 1.3 ext_file="${1}"
319 olemarkus 1.1 fi
320    
321 olemarkus 1.13 php-ext-source-r2_addtoinifile "${ext_type}" "${ext_file}" "${2}" "Extension added"
322 olemarkus 1.1 }
323    
324     # $1 - Setting name
325     # $2 - Setting value
326     # $3 - File to add to
327     # $4 - Sanitized text to output
328     php-ext-source-r2_addtoinifile() {
329 olemarkus 1.13 local inifile="${WORKDIR}/${3}"
330     if [[ ! -d $(dirname ${inifile}) ]] ; then
331     mkdir -p $(dirname ${inifile})
332 olemarkus 1.1 fi
333    
334     # Are we adding the name of a section?
335     if [[ ${1:0:1} == "[" ]] ; then
336 olemarkus 1.13 echo "${1}" >> "${inifile}"
337 olemarkus 1.3 my_added="${1}"
338 olemarkus 1.1 else
339 olemarkus 1.13 echo "${1}=${2}" >> "${inifile}"
340 olemarkus 1.3 my_added="${1}=${2}"
341 olemarkus 1.1 fi
342    
343 olemarkus 1.3 if [[ -z "${4}" ]] ; then
344     einfo "Added '${my_added}' to /${3}"
345 olemarkus 1.1 else
346 olemarkus 1.3 einfo "${4} to /${3}"
347 olemarkus 1.1 fi
348    
349 olemarkus 1.3 insinto /$(dirname ${3})
350 olemarkus 1.13 doins "${inifile}"
351 olemarkus 1.1 }
352    
353     # @FUNCTION: php-ext-source-r2_addtoinifiles
354     # @USAGE: <setting name> <setting value> [message to output]; or just [section name]
355     # @DESCRIPTION:
356     # Add value settings to php.ini file installed by the extension (module).
357     # You can also add a [section], see examples below.
358     #
359     # @CODE
360     # Add some settings for the extension:
361     #
362     # php-ext-source-r2_addtoinifiles "zend_optimizer.optimization_level" "15"
363     # php-ext-source-r2_addtoinifiles "zend_optimizer.enable_loader" "0"
364     # php-ext-source-r2_addtoinifiles "zend_optimizer.disable_licensing" "0"
365     #
366     # Adding values to a section in php.ini file installed by the extension:
367     #
368     # php-ext-source-r2_addtoinifiles "[Debugger]"
369     # php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
370     # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
371     # @CODE
372     php-ext-source-r2_addtoinifiles() {
373 olemarkus 1.3 local x
374 olemarkus 1.12 for x in ${PHPFULLINIFILELIST} ; do
375 olemarkus 1.3 php-ext-source-r2_addtoinifile "${1}" "${2}" "${x}" "${3}"
376 olemarkus 1.1 done
377     }

  ViewVC Help
Powered by ViewVC 1.1.20