/[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.1 - (hide annotations) (download)
Wed Oct 6 08:25:51 2010 UTC (4 years, 2 months ago) by olemarkus
Branch: MAIN
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 olemarkus 1.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-source-r1.eclass,v 1.19 2008/05/09 13:02:04 hoffie 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     # Author: Ole Markus With <olemarkus@gentoo.org>
10    
11     # @ECLASS: php-ext-source-r2.eclass
12     # @MAINTAINER:
13     # Gentoo PHP team <php-bugs@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     inherit flag-o-matic autotools
20    
21     EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install
22    
23     # @ECLASS-VARIABLE: PHP_EXT_NAME
24     # @DESCRIPTION:
25     # The extension name. This must be set, otherwise the eclass dies.
26     # Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild
27     # inherits that eclass, you must set this manually before inherit.
28     [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
29    
30     DEPEND=">=sys-devel/m4-1.4.3
31     >=sys-devel/libtool-1.5.18"
32     RDEPEND=""
33    
34     # Because of USE deps, we require at least EAPI 2
35     case ${EAPI} in
36     2|3) ;;
37     *)
38     die "php-ext-source-r2 is not compatible with EAPI=${EAPI}"
39     esac
40    
41     # @ECLASS-VARIABLE: PHP_EXT_NAME
42     # @DESCRIPTION:
43     # The extension name. This must be set, otherwise the eclass dies.
44     # Only automagically set by php-ext-pecl-r2.eclass, so unless your ebuild
45     # inherits that eclass, you must set this manually before inherit.
46     [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
47    
48     # @ECLASS-VARIABLE: PHP_EXT_INI
49     # @DESCRIPTION:
50     # Controls whether or not to add a line to php.ini for the extension.
51     # Defaults to "yes" and should not be changed in most cases.
52     [[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
53    
54     # @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
55     # @DESCRIPTION:
56     # Controls whether the extension is a ZendEngine extension or not.
57     # Defaults to "no" and if you don't know what is it, you don't need it.
58     [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
59    
60     # @ECLASS-VARIABLE: USE_PHP
61     # @DESCRIPTION:
62     # Lists the PHP slots compatibile the extension is compatibile with
63     [[ -z "$USE_PHP" ]] && USE_PHP="php5-2 php5-3"
64    
65     for target in $USE_PHP; do
66     IUSE="${IUSE} php_targets_$target"
67     done
68    
69     #Make sure at least one target is installed. Abuses USE dependencies.
70     for target in $USE_PHP; do
71     target=${target/+}
72     SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]"
73     slot=${target/php}
74     slot=${slot/-/.}
75     PHPDEPEND="$PHPDEPEND php_target_$target? ( dev-lang/php:${slot} )"
76     done
77    
78     RDEPEND="${RDEPEND}
79     || ( $SELFDEPEND )
80     $PHPDEPEND"
81    
82    
83     # @FUNCTION: php-ext-source-r2_src_unpack
84     # @DESCRIPTION:
85     # runs standard src_unpack + _phpize
86     #
87     # @VARIABLE: PHP_EXT_SKIP_PHPIZE
88     # @DESCRIPTION:
89     # phpize will be run by default for all ebuilds that use
90     # php-ext-source-r1_src_unpack
91     # Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
92     php-ext-source-r2_src_unpack() {
93     unpack ${A}
94     local slot orig_s="$S"
95     for slot in $(php_get_slots); do
96     cp -r "$orig_s" "${WORKDIR}/$slot"
97     php_init_slot_env $slot
98     if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
99     php-ext-source-r2_phpize
100     fi
101     done
102     }
103    
104     # @FUNCTION php-ext-source-r2_phpize
105     # @DESCRIPTION:
106     # Runs phpize and autotools in addition to the standard src_unpack
107     php-ext-source-r2_phpize() {
108     # Create configure out of config.m4
109     # I wish I could run this to solve #329071, but I cannot
110     #autotools_run_tool ${PHPIZE}
111     ${PHPIZE}
112     # force run of libtoolize and regeneration of related autotools
113     # files (bug 220519)
114     rm aclocal.m4
115     eautoreconf
116     }
117    
118     # @FUNCTION: php-ext-source-r2_src_configure
119     # @DESCRIPTION:
120     # Takes care of standard configure for PHP extensions (modules).
121     #
122     # @VARIABLE: my_conf
123     # @DESCRIPTION:
124     # Set this in the ebuild to pass configure options to econf.
125     php-ext-source-r2_src_configure() {
126     local slot
127     for slot in $(php_get_slots); do
128     php_init_slot_env $slot
129     # Set the correct config options
130     # We cannot use econf here, phpize/php-config deals with setting
131     # --prefix etc to whatever the php slot was configured to use
132     ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
133     done
134     }
135    
136     # @FUNCTION: php-ext-source-r2_src_compile
137     # @DESCRIPTION:
138     # Takes care of standard compile for PHP extensions (modules).
139     php-ext-source-r2_src_compile() {
140     # net-snmp creates this file #324739
141     addpredict /usr/share/snmp/mibs/.index
142     # shm extension createss a semaphore file #173574
143     addpredict /session_mm_cli0.sem
144     local slot
145     for slot in $(php_get_slots); do
146     php_init_slot_env $slot
147     emake || die "Unable to make code"
148    
149     done
150     }
151    
152     # @FUNCTION: php-ext-source-r1_src_install
153     # @DESCRIPTION:
154     # Takes care of standard install for PHP extensions (modules).
155    
156     # @VARIABLE: DOCS
157     # @DESCRIPTION:
158     # Set in ebuild if you wish to install additional, package-specific documentation.
159     php-ext-source-r2_src_install() {
160     local slot
161     for slot in $(php_get_slots); do
162     php_init_slot_env $slot
163    
164     # Let's put the default module away
165     insinto "${EXT_DIR}"
166     newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"
167    
168     for doc in ${DOCS} ; do
169     [[ -s ${doc} ]] && dodoc ${doc}
170     done
171    
172     done
173     php-ext-source-r2_createinifiles
174     }
175    
176    
177     php_get_slots() {
178     local s
179     local slot
180     for slot in $USE_PHP; do
181     use php_targets_$slot && s+=" ${slot/-/.}"
182     done
183     echo $s
184     }
185    
186     php_init_slot_env() {
187     libdir=$(get_libdir)
188    
189     PHPIZE="/usr/${libdir}/$1/bin/phpize"
190     PHPCONFIG="/usr/${libdir}/$1/bin/php-config"
191     PHPCLI="/usr/${libdir}/$1/bin/php"
192     PHPCGI="/usr/${libdir}/$1/bin/php-cgi"
193     PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
194     PHPPREFIX="/usr/${libdir}/$slot"
195     EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
196    
197     S="${WORKDIR}/$1"
198     cd $S
199     }
200    
201     php-ext-source-r2_buildinilist() {
202     # Work out the list of <ext>.ini files to edit/add to
203     if [[ -z "${PHPSAPILIST}" ]] ; then
204     PHPSAPILIST="apache2 cli cgi fpm"
205     fi
206    
207     PHPINIFILELIST=""
208    
209     for x in ${PHPSAPILIST} ; do
210     if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
211     PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
212     fi
213     done
214     }
215    
216     # @FUNCTION: php-ext-source-r2_createinifiles
217     # @DESCRIPTION:
218     # Builds ini files for every enabled slot and SAPI
219     php-ext-source-r2_createinifiles() {
220     local slot
221     for slot in $(php_get_slots); do
222     php_init_slot_env $slot
223     # Pull in the PHP settings
224    
225     # Build the list of <ext>.ini files to edit/add to
226     php-ext-source-r2_buildinilist $slot
227    
228     # Add the needed lines to the <ext>.ini files
229     if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
230     php-ext-source-r2_addextension "${PHP_EXT_NAME}.so"
231     fi
232    
233     # Symlink the <ext>.ini files from ext/ to ext-active/
234     for inifile in ${PHPINIFILELIST} ; do
235     inidir="${inifile/${PHP_EXT_NAME}.ini/}"
236     inidir="${inidir/ext/ext-active}"
237     dodir "/${inidir}"
238     dosym "/${inifile}" "/${inifile/ext/ext-active}"
239     done
240    
241     # Add support for installing PHP files into a version dependant directory
242     PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
243     done
244     }
245    
246     php-ext-source-r2_addextension() {
247     if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
248     # We need the full path for ZendEngine extensions
249     # and we need to check for debugging enabled!
250     if has_zts ; then
251     if has_debug ; then
252     ext_type="zend_extension_debug_ts"
253     else
254     ext_type="zend_extension_ts"
255     fi
256     ext_file="${EXT_DIR}/$1"
257     else
258     if has_debug ; then
259     ext_type="zend_extension_debug"
260     else
261     ext_type="zend_extension"
262     fi
263     ext_file="${EXT_DIR}/$1"
264     fi
265    
266     # php-5.3 unifies zend_extension loading and just requires the
267     # zend_extension keyword with no suffix
268     # TODO: drop previous code and this check once <php-5.3 support is
269     # discontinued
270     if has_version '>=dev-lang/php-5.3' ; then
271     ext_type="zend_extension"
272     fi
273     else
274     # We don't need the full path for normal extensions!
275     ext_type="extension"
276     ext_file="$1"
277     fi
278    
279     php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
280     }
281    
282     # $1 - Setting name
283     # $2 - Setting value
284     # $3 - File to add to
285     # $4 - Sanitized text to output
286     php-ext-source-r2_addtoinifile() {
287     if [[ ! -d $(dirname $3) ]] ; then
288     mkdir -p $(dirname $3)
289     fi
290    
291     # Are we adding the name of a section?
292     if [[ ${1:0:1} == "[" ]] ; then
293     echo "$1" >> "$3"
294     my_added="$1"
295     else
296     echo "$1=$2" >> "$3"
297     my_added="$1=$2"
298     fi
299    
300     if [[ -z "$4" ]] ; then
301     einfo "Added '$my_added' to /$3"
302     else
303     einfo "$4 to /$3"
304     fi
305    
306     insinto /$(dirname $3)
307     doins "$3"
308     }
309    
310     # @FUNCTION: php-ext-source-r2_addtoinifiles
311     # @USAGE: <setting name> <setting value> [message to output]; or just [section name]
312     # @DESCRIPTION:
313     # Add value settings to php.ini file installed by the extension (module).
314     # You can also add a [section], see examples below.
315     #
316     # @CODE
317     # Add some settings for the extension:
318     #
319     # php-ext-source-r2_addtoinifiles "zend_optimizer.optimization_level" "15"
320     # php-ext-source-r2_addtoinifiles "zend_optimizer.enable_loader" "0"
321     # php-ext-source-r2_addtoinifiles "zend_optimizer.disable_licensing" "0"
322     #
323     # Adding values to a section in php.ini file installed by the extension:
324     #
325     # php-ext-source-r2_addtoinifiles "[Debugger]"
326     # php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
327     # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
328     # @CODE
329     php-ext-source-r2_addtoinifiles() {
330     for x in ${PHPINIFILELIST} ; do
331     php-ext-source-r2_addtoinifile "$1" "$2" "$x" "$3"
332     done
333     }

  ViewVC Help
Powered by ViewVC 1.1.20