/[gentoo-x86]/eclass/php-common-r1.eclass
Gentoo

Contents of /eclass/php-common-r1.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show annotations) (download)
Thu May 29 14:45:38 2008 UTC (5 years, 10 months ago) by hoffie
Branch: MAIN
Changes since 1.15: +4 -3 lines
hopefully last shot at fixing php-common-r1.eclass for postgresql usage, thanks to zlin and dev-zero (again ;)), bug 223797, bug 222933

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-common-r1.eclass,v 1.15 2008/05/27 10:14:34 hoffie Exp $
4
5 # Based on robbat2's work on the php4 sapi eclass
6 # Based on stuart's work on the php5 sapi eclass
7
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 # ========================================================================
19 # CFLAG SANITY
20 # ========================================================================
21
22 php_check_cflags() {
23 # Fixes bug #14067.
24 # Changed order to run it in reverse for bug #32022 and #12021.
25 replace-cpu-flags "k6*" "i586"
26 }
27
28 # ========================================================================
29 # IMAP SUPPORT
30 # ========================================================================
31
32 php_check_imap() {
33 if ! use "imap" && ! phpconfutils_usecheck "imap" ; then
34 return
35 fi
36
37 if use "ssl" || phpconfutils_usecheck "ssl" ; then
38 if ! built_with_use virtual/imap-c-client ssl ; then
39 eerror
40 eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!"
41 eerror
42 die "Please recompile the IMAP C-Client libraries with SSL support enabled"
43 fi
44 else
45 if built_with_use virtual/imap-c-client ssl ; then
46 eerror
47 eerror "IMAP without SSL requested, but your IMAP C-Client libraries are built with SSL!"
48 eerror
49 die "Please recompile the IMAP C-Client libraries with SSL support disabled"
50 fi
51 fi
52
53 if use "kolab" || phpconfutils_usecheck "kolab" ; then
54 if ! built_with_use net-libs/c-client kolab ; then
55 eerror
56 eerror "IMAP with annotations support requested, but net-libs/c-client is built without it!"
57 eerror
58 die "Please recompile net-libs/c-client with USE=kolab."
59 fi
60 fi
61 }
62
63 # ========================================================================
64 # JAVA EXTENSION SUPPORT
65 #
66 # The bundled java extension is unique to PHP4, but there is
67 # now the PHP-Java-Bridge that works under both PHP4 and PHP5.
68 # ========================================================================
69
70 php_check_java() {
71 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
72 return
73 fi
74
75 JDKHOME="$(java-config --jdk-home)"
76 NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!"
77 if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then
78 eerror "${NOJDKERROR}"
79 die "${NOJDKERROR}"
80 fi
81
82 # stuart@gentoo.org - 2003/05/18
83 # Kaffe JVM is not a drop-in replacement for the Sun JDK at this time
84 if echo ${JDKHOME} | grep kaffe > /dev/null 2>&1 ; then
85 eerror
86 eerror "PHP will not build using the Kaffe Java Virtual Machine."
87 eerror "Please change your JVM to either Blackdown or Sun's."
88 eerror
89 eerror "To build PHP without Java support, please re-run this emerge"
90 eerror "and place the line:"
91 eerror " USE='-java-internal'"
92 eerror "in front of your emerge command, for example:"
93 eerror " USE='-java-internal' emerge =dev-lang/php-4*"
94 eerror
95 eerror "or edit your USE flags in /etc/make.conf."
96 die "Kaffe JVM not supported"
97 fi
98
99 JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs )
100 einfo "Active JDK version: ${JDKVER}"
101 case "${JDKVER}" in
102 1.4.*) ;;
103 1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;;
104 *) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;;
105 esac
106 }
107
108 php_install_java() {
109 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
110 return
111 fi
112
113 # We put these into /usr/lib so that they cannot conflict with
114 # other versions of PHP (e.g. PHP 4 & PHP 5)
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
123 einfo "Installing JAR for PHP"
124 doins "ext/java/php_java.jar"
125
126 einfo "Installing Java test page"
127 newins "ext/java/except.php" "java-test.php"
128 }
129
130 php_install_java_inifile() {
131 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
132 return
133 fi
134
135 JAVA_LIBRARY="$(grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u)"
136
137 echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
138 echo "java.library = ${JAVA_LIBRARY}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
139 echo "java.class.path = ${PHPEXTDIR}/php_java.jar" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
140 echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
141
142 dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini"
143 }
144
145 # ========================================================================
146 # MTA SUPPORT
147 # ========================================================================
148
149 php_check_mta() {
150 if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then
151 ewarn
152 ewarn "You need a virtual/mta that provides a sendmail compatible binary!"
153 ewarn "All major MTAs provide this, and it's usually some symlink created"
154 ewarn "as '${ROOT}/usr/sbin/sendmail*'. You should also be able to use other"
155 ewarn "MTAs directly, but you'll have to edit the sendmail_path directive"
156 ewarn "in your php.ini for this to work."
157 ewarn
158 fi
159 }
160
161 # ========================================================================
162 # ORACLE SUPPORT
163 # ========================================================================
164
165 php_check_oracle_all() {
166 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
167 eerror
168 eerror "You must have the ORACLE_HOME variable set in your environment to"
169 eerror "compile the Oracle extension."
170 eerror
171 die "Oracle configuration incorrect; user error"
172 fi
173
174 if use "oci8" || use "oracle7" ; then
175 if has_version 'dev-db/oracle-instantclient-basic' ; then
176 ewarn
177 ewarn "Please ensure you have a full install of the Oracle client."
178 ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient."
179 ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you"
180 ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client."
181 ewarn
182 fi
183 fi
184 }
185
186 php_check_oracle_8() {
187 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
188 eerror
189 eerror "You must have the ORACLE_HOME variable set in your environment to"
190 eerror "compile the Oracle extension."
191 eerror
192 die "Oracle configuration incorrect; user error"
193 fi
194
195 if use "oci8" ; then
196 if has_version 'dev-db/oracle-instantclient-basic' ; then
197 ewarn
198 ewarn "Please ensure you have a full install of the Oracle client."
199 ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient."
200 ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you"
201 ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client."
202 ewarn
203 fi
204 fi
205 }
206
207 # ========================================================================
208 # POSTGRESQL SUPPORT
209 # ========================================================================
210
211 php_check_pgsql() {
212 if use "postgres" && use "apache2" && use "threads" ; then
213 if has_version dev-db/libpq ; then
214 if has_version ">=dev-db/libpq-8" && \
215 ! built_with_use ">=dev-db/libpq-8" "threads" ; then
216 eerror
217 eerror "You must build dev-db/libpq with USE=threads"
218 eerror "if you want to build PHP with threads support!"
219 eerror
220 die "Rebuild dev-db/libpq with USE=threads"
221 fi
222 else
223 local pgsql_ver=$(eselect postgresql show)
224 if ! built_with_use "=dev-db/postgresql-base-${pgsql_ver}*" threads ; then
225 eerror
226 eerror "You must build =dev-db/postgresql-base-${pgsql_ver} with USE=threads"
227 eerror "if you want to build PHP with threads support!"
228 eerror
229 die "Rebuild =dev-db/postgresql-base-${pgsql_ver} with USE=threads"
230 fi
231 fi
232 fi
233 }
234
235 # ========================================================================
236 # MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie
237 # ========================================================================
238
239 php_get_mycnf_charset() {
240 # nothing todo if no mysql installed
241 if [[ ! -f "${ROOT}/etc/mysql/my.cnf" ]]; then
242 echo "empty"
243 return
244 fi
245 local sapi="${1}"
246 local section=""
247 local client_charset=""
248 local sapi_charset=""
249
250 # remove comments and pipe the output to our while loop
251 while read line ; do
252 line=$(echo "${line}" | sed 's:[;#][^\n]*::g')
253
254 # skip empty lines
255 if [[ "${line}" == "" ]] ; then
256 continue
257 fi
258
259 # capture sections
260 tmp=$(echo "${line}" | sed 's:\[\([-a-z0-9\_]*\)\]:\1:')
261 if [[ "${line}" != "${tmp}" ]] ; then
262 section=${tmp}
263 else
264 # we don't need to check lines which are not in a section we are interested about
265 if [[ "${section}" != "client" && "${section}" != "php-${sapi}" ]] ; then
266 continue
267 fi
268
269 # match default-character-set= lines
270 tmp=$(echo "${line}" | sed 's|^[[:space:]\ ]*default-character-set[[:space:]\ ]*=[[:space:]\ ]*\"\?\([a-z0-9\-]*\)\"\?|\1|')
271 if [[ "${line}" == "${tmp}" ]] ; then
272 # nothing changed, irrelevant line
273 continue
274 fi
275 if [[ "${section}" == "client" ]] ; then
276 client_charset="${tmp}"
277 else
278 if [[ "${section}" == "php-${sapi}" ]] ; then
279 sapi_charset="${tmp}"
280 fi
281 fi
282 fi
283 done < "${ROOT}/etc/mysql/my.cnf"
284 # 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)
285 if [[ -n "${sapi_charset}" ]] ; then
286 echo "${sapi_charset}"
287 elif [[ -n "${client_charset}" ]] ; then
288 echo "${client_charset}"
289 else
290 echo "empty"
291 fi
292 }

  ViewVC Help
Powered by ViewVC 1.1.20