1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2007 Gentoo Foundation |
2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/Attic/php-common-r1.eclass,v 1.6 2006/03/24 23:05:49 chtekk Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/Attic/php-common-r1.eclass,v 1.11 2007/09/01 15:58:17 jokey Exp $ |
4 | |
4 | |
5 | # ######################################################################## |
|
|
6 | # |
|
|
7 | # eclass/php-common-r1.eclass |
|
|
8 | # Contains common functions which are shared between the |
|
|
9 | # PHP4 and PHP5 packages |
|
|
10 | # |
|
|
11 | # USE THIS ECLASS FOR THE "CONSOLIDATED" PACKAGES |
|
|
12 | # |
|
|
13 | # Based on robbat2's work on the php4 sapi eclass |
5 | # Based on robbat2's work on the php4 sapi eclass |
14 | # Based on stuart's work on the php5 sapi eclass |
6 | # Based on stuart's work on the php5 sapi eclass |
15 | # |
|
|
16 | # Maintained by the PHP Herd <php-bugs@gentoo.org> |
|
|
17 | # |
|
|
18 | # ######################################################################## |
|
|
19 | |
7 | |
20 | # ######################################################################## |
8 | # @ECLASS: php-common-r1.eclass |
|
|
9 | # @MAINTAINER: |
|
|
10 | # Gentoo PHP team <php-bugs@gentoo.org> |
|
|
11 | # @BLURB: Common functions which are shared between the PHP4 and PHP5 packages. |
|
|
12 | # @DESCRIPTION: |
|
|
13 | # This eclass provides common functions which are shared between the PHP4 and PHP5 packages. |
|
|
14 | # It is only used by php*-sapi eclasses currently and the functions are not intended |
|
|
15 | # for direct use in ebuilds. |
|
|
16 | |
|
|
17 | |
|
|
18 | # ======================================================================== |
21 | # CFLAG SANITY |
19 | # CFLAG SANITY |
22 | # ######################################################################## |
20 | # ======================================================================== |
23 | |
21 | |
24 | php_check_cflags() { |
22 | php_check_cflags() { |
25 | # Filter the following from C[XX]FLAGS regardless, as apache won't be |
23 | # Filter the following from C[XX]FLAGS regardless, as apache won't be |
26 | # supporting LFS until 2.2 is released and in the tree. Fixes bug #24373. |
24 | # supporting LFS until 2.2 is released and in the tree. Fixes bug #24373. |
27 | filter-flags "-D_FILE_OFFSET_BITS=64" |
25 | filter-flags "-D_FILE_OFFSET_BITS=64" |
… | |
… | |
34 | replace-flags "-march=k6-3" "-march=i586" |
32 | replace-flags "-march=k6-3" "-march=i586" |
35 | replace-flags "-march=k6-2" "-march=i586" |
33 | replace-flags "-march=k6-2" "-march=i586" |
36 | replace-flags "-march=k6" "-march=i586" |
34 | replace-flags "-march=k6" "-march=i586" |
37 | } |
35 | } |
38 | |
36 | |
39 | # ######################################################################## |
37 | # ======================================================================== |
40 | # IMAP SUPPORT |
38 | # IMAP SUPPORT |
41 | # ######################################################################## |
39 | # ======================================================================== |
42 | |
40 | |
43 | php_check_imap() { |
41 | php_check_imap() { |
44 | if ! useq "imap" && ! phpconfutils_usecheck "imap" ; then |
42 | if ! use "imap" && ! phpconfutils_usecheck "imap" ; then |
45 | return |
43 | return |
46 | fi |
44 | fi |
47 | |
45 | |
48 | if useq "ssl" || phpconfutils_usecheck "ssl" ; then |
46 | if use "ssl" || phpconfutils_usecheck "ssl" ; then |
49 | if ! built_with_use virtual/imap-c-client ssl ; then |
47 | if ! built_with_use virtual/imap-c-client ssl ; then |
50 | eerror |
48 | eerror |
51 | eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!" |
49 | eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!" |
52 | eerror |
50 | eerror |
53 | die "Please recompile the IMAP C-Client libraries with SSL support enabled" |
51 | die "Please recompile the IMAP C-Client libraries with SSL support enabled" |
… | |
… | |
60 | die "Please recompile the IMAP C-Client libraries with SSL support disabled" |
58 | die "Please recompile the IMAP C-Client libraries with SSL support disabled" |
61 | fi |
59 | fi |
62 | fi |
60 | fi |
63 | } |
61 | } |
64 | |
62 | |
65 | # ######################################################################## |
63 | # ======================================================================== |
66 | # JAVA EXTENSION SUPPORT |
64 | # JAVA EXTENSION SUPPORT |
67 | # |
65 | # |
68 | # The bundled java extension is unique to PHP4 at the time of writing, but |
66 | # The bundled java extension is unique to PHP4, but there is |
69 | # there is now the PHP-Java-Bridge that works under both PHP4 and PHP5. |
67 | # now the PHP-Java-Bridge that works under both PHP4 and PHP5. |
70 | # ######################################################################## |
68 | # ======================================================================== |
71 | |
69 | |
72 | php_check_java() { |
70 | php_check_java() { |
73 | if ! useq "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
71 | if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
74 | return |
72 | return |
75 | fi |
73 | fi |
76 | |
74 | |
77 | JDKHOME="`java-config --jdk-home`" |
75 | JDKHOME="`java-config --jdk-home`" |
78 | NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!" |
76 | NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!" |
… | |
… | |
106 | *) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;; |
104 | *) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;; |
107 | esac |
105 | esac |
108 | } |
106 | } |
109 | |
107 | |
110 | php_install_java() { |
108 | php_install_java() { |
111 | if ! useq "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
109 | if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
112 | return |
110 | return |
113 | fi |
111 | fi |
114 | |
112 | |
115 | # We put these into /usr/lib so that they cannot conflict with |
113 | # We put these into /usr/lib so that they cannot conflict with |
116 | # other versions of PHP (e.g. PHP 4 & PHP 5) |
114 | # other versions of PHP (e.g. PHP 4 & PHP 5) |
117 | insinto "${PHPEXTDIR}" |
115 | insinto "${PHPEXTDIR}" |
|
|
116 | |
|
|
117 | einfo "Installing PHP java extension" |
|
|
118 | doins "modules/java.so" |
|
|
119 | |
|
|
120 | einfo "Creating PHP java extension symlink" |
|
|
121 | dosym "${PHPEXTDIR}/java.so" "${PHPEXTDIR}/libphp_java.so" |
|
|
122 | |
118 | einfo "Installing JAR for PHP" |
123 | einfo "Installing JAR for PHP" |
119 | doins "ext/java/php_java.jar" |
124 | doins "ext/java/php_java.jar" |
120 | |
125 | |
121 | einfo "Installing Java test page" |
126 | einfo "Installing Java test page" |
122 | newins "ext/java/except.php" "java-test.php" |
127 | newins "ext/java/except.php" "java-test.php" |
123 | |
|
|
124 | einfo "Installing Java extension for PHP" |
|
|
125 | doins "modules/java.so" |
|
|
126 | |
|
|
127 | dosym "${PHPEXTDIR}/java.so" "${PHPEXTDIR}/libphp_java.so" |
|
|
128 | } |
128 | } |
129 | |
129 | |
130 | php_install_java_inifile() { |
130 | php_install_java_inifile() { |
131 | if ! useq "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
131 | if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
132 | return |
132 | return |
133 | fi |
133 | fi |
134 | |
134 | |
135 | JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u`" |
135 | JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u`" |
136 | |
136 | |
… | |
… | |
140 | echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" |
140 | echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" |
141 | |
141 | |
142 | dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini" |
142 | dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini" |
143 | } |
143 | } |
144 | |
144 | |
145 | # ######################################################################## |
145 | # ======================================================================== |
146 | # MTA SUPPORT |
146 | # MTA SUPPORT |
147 | # ######################################################################## |
147 | # ======================================================================== |
148 | |
148 | |
149 | php_check_mta() { |
149 | php_check_mta() { |
150 | if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then |
150 | if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then |
151 | ewarn |
151 | ewarn |
152 | ewarn "You need a virtual/mta that provides a sendmail compatible binary!" |
152 | ewarn "You need a virtual/mta that provides a sendmail compatible binary!" |
… | |
… | |
156 | ewarn "in your php.ini for this to work." |
156 | ewarn "in your php.ini for this to work." |
157 | ewarn |
157 | ewarn |
158 | fi |
158 | fi |
159 | } |
159 | } |
160 | |
160 | |
161 | # ######################################################################## |
161 | # ======================================================================== |
162 | # ORACLE SUPPORT |
162 | # ORACLE SUPPORT |
163 | # ######################################################################## |
163 | # ======================================================================== |
164 | |
164 | |
165 | php_check_oracle_all() { |
165 | php_check_oracle_all() { |
166 | if useq "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then |
166 | if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then |
167 | eerror |
167 | eerror |
168 | eerror "You must have the ORACLE_HOME variable set in your environment to" |
168 | eerror "You must have the ORACLE_HOME variable set in your environment to" |
169 | eerror "compile the Oracle extension." |
169 | eerror "compile the Oracle extension." |
170 | eerror |
170 | eerror |
171 | die "Oracle configuration incorrect; user error" |
171 | die "Oracle configuration incorrect; user error" |
172 | fi |
172 | fi |
173 | |
173 | |
174 | if useq "oci8" || useq "oracle7" ; then |
174 | if use "oci8" || use "oracle7" ; then |
175 | if has_version 'dev-db/oracle-instantclient-basic' ; then |
175 | if has_version 'dev-db/oracle-instantclient-basic' ; then |
176 | ewarn |
176 | ewarn |
177 | ewarn "Please ensure you have a full install of the Oracle client." |
177 | ewarn "Please ensure you have a full install of the Oracle client." |
178 | ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." |
178 | ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." |
179 | ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" |
179 | ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" |
… | |
… | |
182 | fi |
182 | fi |
183 | fi |
183 | fi |
184 | } |
184 | } |
185 | |
185 | |
186 | php_check_oracle_8() { |
186 | php_check_oracle_8() { |
187 | if useq "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then |
187 | if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then |
188 | eerror |
188 | eerror |
189 | eerror "You must have the ORACLE_HOME variable set in your environment to" |
189 | eerror "You must have the ORACLE_HOME variable set in your environment to" |
190 | eerror "compile the Oracle extension." |
190 | eerror "compile the Oracle extension." |
191 | eerror |
191 | eerror |
192 | die "Oracle configuration incorrect; user error" |
192 | die "Oracle configuration incorrect; user error" |
193 | fi |
193 | fi |
194 | |
194 | |
195 | if useq "oci8" ; then |
195 | if use "oci8" ; then |
196 | if has_version 'dev-db/oracle-instantclient-basic' ; then |
196 | if has_version 'dev-db/oracle-instantclient-basic' ; then |
197 | ewarn |
197 | ewarn |
198 | ewarn "Please ensure you have a full install of the Oracle client." |
198 | ewarn "Please ensure you have a full install of the Oracle client." |
199 | ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." |
199 | ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." |
200 | ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" |
200 | ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" |
… | |
… | |
202 | ewarn |
202 | ewarn |
203 | fi |
203 | fi |
204 | fi |
204 | fi |
205 | } |
205 | } |
206 | |
206 | |
207 | # ######################################################################## |
207 | # ======================================================================== |
208 | # END OF ECLASS |
208 | # POSTGRESQL SUPPORT |
209 | # ######################################################################## |
209 | # ======================================================================== |
|
|
210 | |
|
|
211 | php_check_pgsql() { |
|
|
212 | if use "postgres" \ |
|
|
213 | && use "apache2" && use "threads" \ |
|
|
214 | && has_version ">=dev-db/libpq-8.1.3-r1" \ |
|
|
215 | && ! built_with_use ">=dev-db/libpq-8.1.3-r1" "threads" ; then |
|
|
216 | eerror |
|
|
217 | eerror "You must build dev-db/libpq with the 'threads' USE flag" |
|
|
218 | eerror "turned on if you want to build PHP with threads support!" |
|
|
219 | eerror |
|
|
220 | die "Rebuild dev-db/libpq with 'threads' USE flag enabled" |
|
|
221 | fi |
|
|
222 | } |
|
|
223 | |
|
|
224 | # ======================================================================== |
|
|
225 | # MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie |
|
|
226 | # ======================================================================== |
|
|
227 | |
|
|
228 | php_get_mycnf_charset() { |
|
|
229 | # nothing todo if no mysql installed |
|
|
230 | if [[ ! -f "${ROOT}/etc/mysql/my.cnf" ]]; then |
|
|
231 | echo "empty" |
|
|
232 | return |
|
|
233 | fi |
|
|
234 | local sapi="${1}" |
|
|
235 | local section="" |
|
|
236 | local client_charset="" |
|
|
237 | local sapi_charset="" |
|
|
238 | |
|
|
239 | # remove comments and pipe the output to our while loop |
|
|
240 | while read line ; do |
|
|
241 | line=$(echo "${line}" | sed 's:[;#][^\n]*::g') |
|
|
242 | |
|
|
243 | # skip empty lines |
|
|
244 | if [[ "${line}" == "" ]] ; then |
|
|
245 | continue |
|
|
246 | fi |
|
|
247 | |
|
|
248 | # capture sections |
|
|
249 | tmp=$(echo "${line}" | sed 's:\[\([-a-z0-9\_]*\)\]:\1:') |
|
|
250 | if [[ "${line}" != "${tmp}" ]] ; then |
|
|
251 | section=${tmp} |
|
|
252 | else |
|
|
253 | # we don't need to check lines which are not in a section we are interested about |
|
|
254 | if [[ "${section}" != "client" && "${section}" != "php-${sapi}" ]] ; then |
|
|
255 | continue |
|
|
256 | fi |
|
|
257 | |
|
|
258 | # match default-character-set= lines |
|
|
259 | tmp=$(echo "${line}" | sed 's|^[[:space:]\ ]*default-character-set[[:space:]\ ]*=[[:space:]\ ]*\"\?\([a-z0-9\-]*\)\"\?|\1|') |
|
|
260 | if [[ "${line}" == "${tmp}" ]] ; then |
|
|
261 | # nothing changed, irrelevant line |
|
|
262 | continue |
|
|
263 | fi |
|
|
264 | if [[ "${section}" == "client" ]] ; then |
|
|
265 | client_charset="${tmp}" |
|
|
266 | else |
|
|
267 | if [[ "${section}" == "php-${sapi}" ]] ; then |
|
|
268 | sapi_charset="${tmp}" |
|
|
269 | fi |
|
|
270 | fi |
|
|
271 | fi |
|
|
272 | done < "${ROOT}/etc/mysql/my.cnf" |
|
|
273 | # if a sapi-specific section with a default-character-set= value was found we use it, otherwise we use the client charset (which may be empty) |
|
|
274 | if [[ -n "${sapi_charset}" ]] ; then |
|
|
275 | echo "${sapi_charset}" |
|
|
276 | elif [[ -n "${client_charset}" ]] ; then |
|
|
277 | echo "${client_charset}" |
|
|
278 | else |
|
|
279 | echo "empty" |
|
|
280 | fi |
|
|
281 | } |