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

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20