/[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.1.1.1 Revision 1.18
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2011 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.1.1.1 2005/11/30 09:59:37 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/php-common-r1.eclass,v 1.18 2011/12/27 17:55:12 fauli 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# Maintainer:
17# php-bugs@gentoo.org
18#
19# ########################################################################
20 7
21# ######################################################################## 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# ========================================================================
22# CFLAG SANITY 19# CFLAG SANITY
23# ######################################################################## 20# ========================================================================
24 21
25php_check_cflags() { 22php_check_cflags() {
26 # filter the following from C[XX]FLAGS regardless, as apache won't be
27 # supporting LFS until 2.2 is released and in the tree. Fixes bug #24373.
28 filter-flags "-D_FILE_OFFSET_BITS=64"
29 filter-flags "-D_FILE_OFFSET_BITS=32"
30 filter-flags "-D_LARGEFILE_SOURCE=1"
31 filter-flags "-D_LARGEFILE_SOURCE"
32
33 #fixes bug #14067 23 # Fixes bug #14067.
34 # 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.
35 replace-flags "-march=k6-3" "-march=i586" 25 replace-cpu-flags "k6*" "i586"
36 replace-flags "-march=k6-2" "-march=i586"
37 replace-flags "-march=k6" "-march=i586"
38} 26}
39 27
40# ######################################################################## 28# ========================================================================
41# IMAP SUPPORT 29# IMAP SUPPORT
42# ######################################################################## 30# ========================================================================
43 31
44php_check_imap() { 32php_check_imap() {
45 if ! useq imap ; then 33 if ! use "imap" && ! phpconfutils_usecheck "imap" ; then
46 return 34 return
47 fi 35 fi
48 36
49 if useq ssl ; then 37 if use "ssl" || phpconfutils_usecheck "ssl" ; then
50 if ! built_with_use virtual/imap-c-client ssl ; then 38 if ! built_with_use virtual/imap-c-client ssl ; then
51 eerror 39 eerror
52 eerror "IMAP+SSL requested, but your IMAP libraries are built without SSL!" 40 eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!"
53 eerror 41 eerror
54 die "Please recompile IMAP libraries w/ SSL support enabled" 42 die "Please recompile the IMAP C-Client libraries with SSL support enabled"
55 fi
56 fi 43 fi
57} 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
58 52
59# ######################################################################## 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# ========================================================================
60# JAVA EXTENSION SUPPORT 64# JAVA EXTENSION SUPPORT
61# 65#
62# 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
63# 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.
64# ######################################################################## 68# ========================================================================
65 69
66php_check_java() { 70php_check_java() {
67 if ! useq java-internal ; then 71 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
68 return 1 72 return
69 fi 73 fi
70 74
71 JDKHOME="`java-config --jdk-home`" 75 JDKHOME="$(java-config --jdk-home)"
72 NOJDKERROR="You need to use java-config to set your JVM to a JDK!" 76 NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!"
73 if [ -z "${JDKHOME}" ] || [ ! -d "${JDKHOME}" ]; then 77 if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then
74 eerror "${NOJDKERROR}" 78 eerror "${NOJDKERROR}"
75 die "${NOJDKERROR}" 79 die "${NOJDKERROR}"
76 fi 80 fi
77 81
78 # stuart@gentoo.org - 2003/05/18 82 # stuart@gentoo.org - 2003/05/18
83 eerror "Please change your JVM to either Blackdown or Sun's." 87 eerror "Please change your JVM to either Blackdown or Sun's."
84 eerror 88 eerror
85 eerror "To build PHP without Java support, please re-run this emerge" 89 eerror "To build PHP without Java support, please re-run this emerge"
86 eerror "and place the line:" 90 eerror "and place the line:"
87 eerror " USE='-java-internal'" 91 eerror " USE='-java-internal'"
88 eerror "in front of your emerge command; e.g." 92 eerror "in front of your emerge command, for example:"
89 eerror " USE='-java-internal' emerge =dev-lang/php-4*" 93 eerror " USE='-java-internal' emerge =dev-lang/php-4*"
90 eerror 94 eerror
91 eerror "or edit your USE flags in /etc/make.conf" 95 eerror "or edit your USE flags in /etc/make.conf."
92 die "Kaffe JVM not supported" 96 die "Kaffe JVM not supported"
93 fi 97 fi
94 98
95 JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs ) 99 JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs )
96 einfo "Active JDK version: ${JDKVER}" 100 einfo "Active JDK version: ${JDKVER}"
97 case "${JDKVER}" in 101 case "${JDKVER}" in
98 1.4.*) ;; 102 1.4.*) ;;
99 1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;; 103 1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;;
100 *) eerror "A Java 1.4 JDK is required for Java support in PHP." ; die ;; 104 *) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;;
101 esac 105 esac
102} 106}
103 107
104php_install_java() { 108php_install_java() {
105 if ! useq java-internal ; then 109 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
106 return 1 110 return
107 fi 111 fi
108 112
109 # 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
110 # other versions of PHP (e.g. PHP 4 & PHP 5) 114 # other versions of PHP (e.g. PHP 4 & PHP 5)
111 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
112 einfo "Installing JAR for PHP" 123 einfo "Installing JAR for PHP"
113 doins ext/java/php_java.jar 124 doins "ext/java/php_java.jar"
114 125
115 einfo "Installing Java test page" 126 einfo "Installing Java test page"
116 newins ext/java/except.php java-test.php 127 newins "ext/java/except.php" "java-test.php"
117
118 einfo "Installing Java extension for PHP"
119 doins modules/java.so
120
121 dosym ${PHPEXTDIR}/java.so ${PHPEXTDIR}/libphp_java.so
122} 128}
123 129
124php_install_java_inifile() { 130php_install_java_inifile() {
125 if ! useq java-internal ; then 131 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
126 return 1 132 return
127 fi 133 fi
128 134
129 JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;'| sort | uniq `" 135 JAVA_LIBRARY="$(grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u)"
130 136
131 echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" 137 echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
132 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"
133 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"
134 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"
135 141
136 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"
137} 143}
138 144
139# ######################################################################## 145# ========================================================================
140# MTA SUPPORT 146# MTA SUPPORT
141# ######################################################################## 147# ========================================================================
142 148
143php_check_mta() { 149php_check_mta() {
144 [ -x "${ROOT}/usr/sbin/sendmail" ] || die "You need a virtual/mta that provides /usr/sbin/sendmail!" 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
145} 159}
146 160
147# ######################################################################## 161# ========================================================================
148# ORACLE SUPPORT 162# ORACLE SUPPORT
149# ######################################################################## 163# ========================================================================
150 164
151php_check_oracle() { 165php_check_oracle_all() {
152 if useq oci8 && [ -z "${ORACLE_HOME}" ]; then 166 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
153 eerror 167 eerror
154 eerror "You must have the ORACLE_HOME variable in your environment!" 168 eerror "You must have the ORACLE_HOME variable set in your environment to"
169 eerror "compile the Oracle extension."
155 eerror 170 eerror
156 die "Oracle configuration incorrect; user error" 171 die "Oracle configuration incorrect; user error"
157 fi 172 fi
158 173
159 if useq oci8 || useq oracle7 ; then 174 if use "oci8" || use "oracle7" ; then
160 if has_version 'dev-db/oracle-instantclient-basic' ; then 175 if has_version 'dev-db/oracle-instantclient-basic' ; then
176 ewarn
161 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."
162 ewarn "dev-db/oracle-instantclient* 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"
180 ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client."
181 ewarn
182 fi
183 fi
184}
185
186php_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
211php_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"
163 fi 221 fi
222 else
223 local pgsql_ver=$(eselect postgresql show)
224 if [[ ${pgsql_ver} == "(none)" ]]; then
225 eerror "QA: Please select your PostgreSQL version \"eselect postgresql list\""
226 die "Can't determine PgSQL."
227 fi
228 if ! built_with_use "=dev-db/postgresql-base-${pgsql_ver}*" threads ; then
229 eerror
230 eerror "You must build =dev-db/postgresql-base-${pgsql_ver} with USE=threads"
231 eerror "if you want to build PHP with threads support!"
232 eerror
233 die "Rebuild =dev-db/postgresql-base-${pgsql_ver} with USE=threads"
234 fi
164 fi 235 fi
236 fi
165} 237}
166 238
167# ######################################################################## 239# ========================================================================
168# END OF ECLASS 240# MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie
169# ######################################################################## 241# ========================================================================
242
243php_get_mycnf_charset() {
244 # nothing todo if no mysql installed
245 if [[ ! -f "${ROOT}/etc/mysql/my.cnf" ]]; then
246 echo "empty"
247 return
248 fi
249 local sapi="${1}"
250 local section=""
251 local client_charset=""
252 local sapi_charset=""
253
254 # remove comments and pipe the output to our while loop
255 while read line ; do
256 line=$(echo "${line}" | sed 's:[;#][^\n]*::g')
257
258 # skip empty lines
259 if [[ "${line}" == "" ]] ; then
260 continue
261 fi
262
263 # capture sections
264 tmp=$(echo "${line}" | sed 's:\[\([-a-z0-9\_]*\)\]:\1:')
265 if [[ "${line}" != "${tmp}" ]] ; then
266 section=${tmp}
267 else
268 # we don't need to check lines which are not in a section we are interested about
269 if [[ "${section}" != "client" && "${section}" != "php-${sapi}" ]] ; then
270 continue
271 fi
272
273 # match default-character-set= lines
274 tmp=$(echo "${line}" | sed 's|^[[:space:]\ ]*default-character-set[[:space:]\ ]*=[[:space:]\ ]*\"\?\([a-z0-9\-]*\)\"\?|\1|')
275 if [[ "${line}" == "${tmp}" ]] ; then
276 # nothing changed, irrelevant line
277 continue
278 fi
279 if [[ "${section}" == "client" ]] ; then
280 client_charset="${tmp}"
281 else
282 if [[ "${section}" == "php-${sapi}" ]] ; then
283 sapi_charset="${tmp}"
284 fi
285 fi
286 fi
287 done < "${ROOT}/etc/mysql/my.cnf"
288 # 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)
289 if [[ -n "${sapi_charset}" ]] ; then
290 echo "${sapi_charset}"
291 elif [[ -n "${client_charset}" ]] ; then
292 echo "${client_charset}"
293 else
294 echo "empty"
295 fi
296}

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.20