/[gentoo-alt]/trunk/prefix/eclass/php-ext-base.eclass
Gentoo

Contents of /trunk/prefix/eclass/php-ext-base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 3436 byte(s)
Initial eclass import from gentoo-x86
1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base.eclass,v 1.19 2005/07/11 15:08:06 swegener Exp $
4 #
5 # Author: Tal Peer <coredumb@gentoo.org>
6 # Author: Stuart Herbert <stuart@gentoo.org>
7 #
8 # The php-ext-base eclass provides a unified interface for adding standalone
9 # PHP extensions ('modules') to the php.ini files on your system.
10 #
11 # Combined with php-ext-source, we have a standardised solution for supporting
12 # PHP extensions
13
14
15 EXPORT_FUNCTIONS src_install
16
17 # ---begin ebuild configurable settings
18
19 # The extension name, this must be set, otherwise we die.
20 [ -z "$PHP_EXT_NAME" ] && die "No module name specified for the php-ext eclass."
21
22 # Wether the extensions is a Zend Engine extension
23 #(defaults to "no" and if you don't know what is it, you don't need it.)
24 [ -z "$PHP_EXT_ZENDEXT" ] && PHP_EXT_ZENDEXT="no"
25
26 # Wether or not to add a line in the php.ini for the extension
27 # (defaults to "yes" and shouldn't be changed in most cases)
28 [ -z "$PHP_EXT_INI" ] && PHP_EXT_INI="yes"
29
30 # find out where to install extensions
31 EXT_DIR="`php-config --extension-dir 2>/dev/null`"
32
33 # ---end ebuild configurable settings
34
35 DEPEND="${DEPEND}
36 dev-php/php
37 >=sys-devel/m4-1.4
38 >=sys-devel/libtool-1.4.3"
39
40 RDEPEND="${RDEPEND}
41 virtual/php"
42
43 php-ext-base_buildinilist () {
44 # work out the list of .ini files to edit/add to
45
46 if [ -z "${PHPSAPILIST}" ]; then
47 PHPSAPILIST="apache1 apache2 cli cgi"
48 fi
49
50 PHPINIFILELIST=
51
52 for x in ${PHPSAPILIST} ; do
53 if [ -f /etc/php/${x}-php4/php.ini ]; then
54 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php4/php.ini"
55 fi
56
57 if [ -f /etc/php/${x}-php5/php.ini ]; then
58 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php5/php.ini"
59 fi
60 done
61
62 if [ "${PHPINIFILELIST}+" = "+" ] ; then
63 # backwards support for the old location
64
65 if [ -f /etc/php4/php.ini ] ; then
66 PHPINIFILELIST="etc/php4/php.ini"
67 else
68 msg="No PHP ini files found for this extension"
69 eerror ${msg}
70 die ${msg}
71 fi
72 fi
73
74 # einfo "php.ini files found in $PHPINIFILELIST"
75 }
76
77 php-ext-base_src_install() {
78 addpredict /usr/share/snmp/mibs/.index
79 php-ext-base_buildinilist
80 if [ "$PHP_EXT_INI" = "yes" ] ; then
81 php-ext-base_addextension "${PHP_EXT_NAME}.so"
82 fi
83 }
84
85 php-ext-base_addextension () {
86 if [ "${PHP_EXT_ZENDEXT}" = "yes" ]; then
87 ext_type="zend_extension"
88 ext_file="${EXT_DIR}/$1"
89 else
90 # we do *not* add the full path for the extension!
91 ext_type="extension"
92 ext_file="$1"
93 fi
94
95 php-ext-base_addtoinifiles "$ext_type" "$ext_file" "Extension added"
96 }
97
98 php-ext-base_setting_is_present () {
99 grep "^$1=$2" /$3 > /dev/null 2>&1
100 }
101
102 php-ext-base_inifileinimage () {
103 if [ ! -f $1 ]; then
104 mkdir -p `dirname $1`
105 cp /$1 $1
106 fi
107 }
108
109 # $1 - setting name
110 # $2 - setting value
111 # $3 - file to add to
112 # $4 - sanitised text to output
113
114 php-ext-base_addtoinifile () {
115 if [ "$1" != "extension" ] && [ "$1" != "zend_extension" ]; then
116 php-ext-base_setting_is_present $1 "" $3 && return
117 else
118 php-ext-base_setting_is_present "$1" "$2" "$3" && return
119 fi
120
121 php-ext-base_inifileinimage $3
122
123 echo "$1=$2" >> $3
124
125 if [ -z "$4" ]; then
126 einfo "Added '$1=$2' to /$3"
127 else
128 einfo "$4 to /$3"
129 fi
130
131 # yes, this is inefficient - but it works every time ;-)
132
133 insinto /`dirname $3`
134 doins $3
135 }
136
137 php-ext-base_addtoinifiles () {
138 for x in ${PHPINIFILELIST} ; do
139 php-ext-base_addtoinifile $1 $2 $x "$3"
140 done
141 }

  ViewVC Help
Powered by ViewVC 1.1.20