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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.8 Revision 1.15
1# Copyright 1999-2006 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/php-common-r1.eclass,v 1.8 2006/07/14 16:02:36 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/php-common-r1.eclass,v 1.15 2008/05/27 10:14:34 hoffie 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
24php_check_cflags() { 22php_check_cflags() {
25 # 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.
27 filter-flags "-D_FILE_OFFSET_BITS=64"
28 filter-flags "-D_FILE_OFFSET_BITS=32"
29 filter-flags "-D_LARGEFILE_SOURCE=1"
30 filter-flags "-D_LARGEFILE_SOURCE"
31
32 # Fixes bug #14067. 23 # Fixes bug #14067.
33 # Changed order to run it in reverse for bug #32022 and #12021. 24 # Changed order to run it in reverse for bug #32022 and #12021.
34 replace-flags "-march=k6-3" "-march=i586" 25 replace-cpu-flags "k6*" "i586"
35 replace-flags "-march=k6-2" "-march=i586"
36 replace-flags "-march=k6" "-march=i586"
37} 26}
38 27
39# ######################################################################## 28# ========================================================================
40# IMAP SUPPORT 29# IMAP SUPPORT
41# ######################################################################## 30# ========================================================================
42 31
43php_check_imap() { 32php_check_imap() {
44 if ! useq "imap" && ! phpconfutils_usecheck "imap" ; then 33 if ! use "imap" && ! phpconfutils_usecheck "imap" ; then
45 return 34 return
46 fi 35 fi
47 36
48 if useq "ssl" || phpconfutils_usecheck "ssl" ; then 37 if use "ssl" || phpconfutils_usecheck "ssl" ; then
49 if ! built_with_use virtual/imap-c-client ssl ; then 38 if ! built_with_use virtual/imap-c-client ssl ; then
50 eerror 39 eerror
51 eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!" 40 eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!"
52 eerror 41 eerror
53 die "Please recompile the IMAP C-Client libraries with SSL support enabled" 42 die "Please recompile the IMAP C-Client libraries with SSL support enabled"
58 eerror "IMAP without SSL requested, but your IMAP C-Client libraries are built with SSL!" 47 eerror "IMAP without SSL requested, but your IMAP C-Client libraries are built with SSL!"
59 eerror 48 eerror
60 die "Please recompile the IMAP C-Client libraries with SSL support disabled" 49 die "Please recompile the IMAP C-Client libraries with SSL support disabled"
61 fi 50 fi
62 fi 51 fi
63}
64 52
65# ######################################################################## 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# ========================================================================
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
72php_check_java() { 70php_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!"
79 if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then 77 if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then
80 eerror "${NOJDKERROR}" 78 eerror "${NOJDKERROR}"
81 die "${NOJDKERROR}" 79 die "${NOJDKERROR}"
82 fi 80 fi
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
110php_install_java() { 108php_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)
128 einfo "Installing Java test page" 126 einfo "Installing Java test page"
129 newins "ext/java/except.php" "java-test.php" 127 newins "ext/java/except.php" "java-test.php"
130} 128}
131 129
132php_install_java_inifile() { 130php_install_java_inifile() {
133 if ! useq "java-internal" && ! phpconfutils_usecheck "java-internal" ; then 131 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
134 return 132 return
135 fi 133 fi
136 134
137 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)"
138 136
139 echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" 137 echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
140 echo "java.library = ${JAVA_LIBRARY}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" 138 echo "java.library = ${JAVA_LIBRARY}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
141 echo "java.class.path = ${PHPEXTDIR}/php_java.jar" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" 139 echo "java.class.path = ${PHPEXTDIR}/php_java.jar" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
142 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"
143 141
144 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"
145} 143}
146 144
147# ######################################################################## 145# ========================================================================
148# MTA SUPPORT 146# MTA SUPPORT
149# ######################################################################## 147# ========================================================================
150 148
151php_check_mta() { 149php_check_mta() {
152 if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then 150 if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then
153 ewarn 151 ewarn
154 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!"
158 ewarn "in your php.ini for this to work." 156 ewarn "in your php.ini for this to work."
159 ewarn 157 ewarn
160 fi 158 fi
161} 159}
162 160
163# ######################################################################## 161# ========================================================================
164# ORACLE SUPPORT 162# ORACLE SUPPORT
165# ######################################################################## 163# ========================================================================
166 164
167php_check_oracle_all() { 165php_check_oracle_all() {
168 if useq "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then 166 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
169 eerror 167 eerror
170 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"
171 eerror "compile the Oracle extension." 169 eerror "compile the Oracle extension."
172 eerror 170 eerror
173 die "Oracle configuration incorrect; user error" 171 die "Oracle configuration incorrect; user error"
174 fi 172 fi
175 173
176 if useq "oci8" || useq "oracle7" ; then 174 if use "oci8" || use "oracle7" ; then
177 if has_version 'dev-db/oracle-instantclient-basic' ; then 175 if has_version 'dev-db/oracle-instantclient-basic' ; then
178 ewarn 176 ewarn
179 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."
180 ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." 178 ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient."
181 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"
184 fi 182 fi
185 fi 183 fi
186} 184}
187 185
188php_check_oracle_8() { 186php_check_oracle_8() {
189 if useq "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then 187 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
190 eerror 188 eerror
191 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"
192 eerror "compile the Oracle extension." 190 eerror "compile the Oracle extension."
193 eerror 191 eerror
194 die "Oracle configuration incorrect; user error" 192 die "Oracle configuration incorrect; user error"
195 fi 193 fi
196 194
197 if useq "oci8" ; then 195 if use "oci8" ; then
198 if has_version 'dev-db/oracle-instantclient-basic' ; then 196 if has_version 'dev-db/oracle-instantclient-basic' ; then
199 ewarn 197 ewarn
200 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."
201 ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." 199 ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient."
202 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"
204 ewarn 202 ewarn
205 fi 203 fi
206 fi 204 fi
207} 205}
208 206
209# ######################################################################## 207# ========================================================================
210# POSTGRESQL SUPPORT 208# POSTGRESQL SUPPORT
211# ######################################################################## 209# ========================================================================
212 210
213php_check_pgsql() { 211php_check_pgsql() {
214 if useq "postgres" \ 212 if use "postgres" && use "apache2" && use "threads" ; then
215 && useq "apache2" && useq "threads" \
216 && has_version ">=dev-db/libpq-8.1.3-r1" \ 213 if has_version ">=dev-db/libpq-8.1.3-r1" ; then
217 && ! built_with_use ">=dev-db/libpq-8.1.3-r1" "threads" ; then 214 if ! built_with_use ">=dev-db/libpq-8.1.3-r1" "threads" ; then
218 eerror 215 eerror
219 eerror "You must build dev-db/libpq with the 'threads' USE flag" 216 eerror "You must build dev-db/libpq with USE=threads"
220 eerror "turned on if you want to build PHP with threads support!" 217 eerror "if you want to build PHP with threads support!"
221 eerror 218 eerror
222 die "Rebuild dev-db/libpq with 'threads' USE flag enabled" 219 die "Rebuild dev-db/libpq with USE=threads"
220 fi
221 else
222 local pgsql_ver=$(eselect postgresql show)
223 if ! built_with_use "=dev-db/postgresql-base-${pgsql_ver}*" threads ; then
224 eerror
225 eerror "You must build =dev-db/postgresql-base-${pgsql_ver} with USE=threads"
226 eerror "if you want to build PHP with threads support!"
227 eerror
228 die "Rebuild =dev-db/postgresql-base-${pgsql_ver} with USE=threads"
229 fi
223 fi 230 fi
231 fi
224} 232}
225 233
226# ######################################################################## 234# ========================================================================
227# END OF ECLASS 235# MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie
228# ######################################################################## 236# ========================================================================
237
238php_get_mycnf_charset() {
239 # nothing todo if no mysql installed
240 if [[ ! -f "${ROOT}/etc/mysql/my.cnf" ]]; then
241 echo "empty"
242 return
243 fi
244 local sapi="${1}"
245 local section=""
246 local client_charset=""
247 local sapi_charset=""
248
249 # remove comments and pipe the output to our while loop
250 while read line ; do
251 line=$(echo "${line}" | sed 's:[;#][^\n]*::g')
252
253 # skip empty lines
254 if [[ "${line}" == "" ]] ; then
255 continue
256 fi
257
258 # capture sections
259 tmp=$(echo "${line}" | sed 's:\[\([-a-z0-9\_]*\)\]:\1:')
260 if [[ "${line}" != "${tmp}" ]] ; then
261 section=${tmp}
262 else
263 # we don't need to check lines which are not in a section we are interested about
264 if [[ "${section}" != "client" && "${section}" != "php-${sapi}" ]] ; then
265 continue
266 fi
267
268 # match default-character-set= lines
269 tmp=$(echo "${line}" | sed 's|^[[:space:]\ ]*default-character-set[[:space:]\ ]*=[[:space:]\ ]*\"\?\([a-z0-9\-]*\)\"\?|\1|')
270 if [[ "${line}" == "${tmp}" ]] ; then
271 # nothing changed, irrelevant line
272 continue
273 fi
274 if [[ "${section}" == "client" ]] ; then
275 client_charset="${tmp}"
276 else
277 if [[ "${section}" == "php-${sapi}" ]] ; then
278 sapi_charset="${tmp}"
279 fi
280 fi
281 fi
282 done < "${ROOT}/etc/mysql/my.cnf"
283 # 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)
284 if [[ -n "${sapi_charset}" ]] ; then
285 echo "${sapi_charset}"
286 elif [[ -n "${client_charset}" ]] ; then
287 echo "${client_charset}"
288 else
289 echo "empty"
290 fi
291}

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20