/[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.12 - (hide annotations) (download)
Thu Nov 29 23:11:04 2007 UTC (6 years, 11 months ago) by jokey
Branch: MAIN
Changes since 1.11: +3 -3 lines
Don't use backticks

1 chtekk 1.9 # Copyright 1999-2007 Gentoo Foundation
2 stuart 1.1 # Distributed under the terms of the GNU General Public License v2
3 jokey 1.12 # $Header: /var/cvsroot/gentoo-x86/eclass/php-common-r1.eclass,v 1.11 2007/09/01 15:58:17 jokey Exp $
4 jokey 1.11
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 stuart 1.1
17    
18 chtekk 1.9 # ========================================================================
19 stuart 1.1 # CFLAG SANITY
20 chtekk 1.9 # ========================================================================
21 stuart 1.1
22     php_check_cflags() {
23 chtekk 1.6 # Filter the following from C[XX]FLAGS regardless, as apache won't be
24     # supporting LFS until 2.2 is released and in the tree. Fixes bug #24373.
25 stuart 1.1 filter-flags "-D_FILE_OFFSET_BITS=64"
26     filter-flags "-D_FILE_OFFSET_BITS=32"
27     filter-flags "-D_LARGEFILE_SOURCE=1"
28     filter-flags "-D_LARGEFILE_SOURCE"
29    
30 chtekk 1.6 # Fixes bug #14067.
31     # Changed order to run it in reverse for bug #32022 and #12021.
32 stuart 1.1 replace-flags "-march=k6-3" "-march=i586"
33     replace-flags "-march=k6-2" "-march=i586"
34     replace-flags "-march=k6" "-march=i586"
35     }
36    
37 chtekk 1.9 # ========================================================================
38 stuart 1.1 # IMAP SUPPORT
39 chtekk 1.9 # ========================================================================
40 stuart 1.1
41     php_check_imap() {
42 chtekk 1.9 if ! use "imap" && ! phpconfutils_usecheck "imap" ; then
43 stuart 1.1 return
44     fi
45    
46 chtekk 1.9 if use "ssl" || phpconfutils_usecheck "ssl" ; then
47 stuart 1.1 if ! built_with_use virtual/imap-c-client ssl ; then
48     eerror
49 chtekk 1.6 eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!"
50 stuart 1.1 eerror
51 chtekk 1.6 die "Please recompile the IMAP C-Client libraries with SSL support enabled"
52     fi
53     else
54     if built_with_use virtual/imap-c-client ssl ; then
55     eerror
56     eerror "IMAP without SSL requested, but your IMAP C-Client libraries are built with SSL!"
57     eerror
58     die "Please recompile the IMAP C-Client libraries with SSL support disabled"
59 stuart 1.1 fi
60     fi
61     }
62    
63 chtekk 1.9 # ========================================================================
64 stuart 1.1 # JAVA EXTENSION SUPPORT
65     #
66 chtekk 1.9 # 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 stuart 1.1
70 hollow 1.2 php_check_java() {
71 chtekk 1.9 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
72 chtekk 1.6 return
73 stuart 1.1 fi
74    
75 jokey 1.12 JDKHOME="$(java-config --jdk-home)"
76 chtekk 1.6 NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!"
77     if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then
78 stuart 1.1 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 hollow 1.2 eerror " USE='-java-internal'"
92 chtekk 1.6 eerror "in front of your emerge command, for example:"
93 hollow 1.2 eerror " USE='-java-internal' emerge =dev-lang/php-4*"
94 stuart 1.1 eerror
95 chtekk 1.6 eerror "or edit your USE flags in /etc/make.conf."
96 stuart 1.1 die "Kaffe JVM not supported"
97     fi
98    
99 hollow 1.2 JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs )
100 stuart 1.1 einfo "Active JDK version: ${JDKVER}"
101 chtekk 1.3 case "${JDKVER}" in
102 stuart 1.1 1.4.*) ;;
103     1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;;
104 chtekk 1.6 *) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;;
105 stuart 1.1 esac
106     }
107    
108     php_install_java() {
109 chtekk 1.9 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
110 chtekk 1.6 return
111 stuart 1.1 fi
112    
113 chtekk 1.6 # We put these into /usr/lib so that they cannot conflict with
114 stuart 1.1 # other versions of PHP (e.g. PHP 4 & PHP 5)
115 chtekk 1.6 insinto "${PHPEXTDIR}"
116 chtekk 1.8
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 stuart 1.1 einfo "Installing JAR for PHP"
124 chtekk 1.6 doins "ext/java/php_java.jar"
125 stuart 1.1
126     einfo "Installing Java test page"
127 chtekk 1.6 newins "ext/java/except.php" "java-test.php"
128 stuart 1.1 }
129    
130 chtekk 1.3 php_install_java_inifile() {
131 chtekk 1.9 if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then
132 chtekk 1.6 return
133 chtekk 1.4 fi
134    
135 jokey 1.12 JAVA_LIBRARY="$(grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u)"
136 chtekk 1.3
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 chtekk 1.9 # ========================================================================
146 stuart 1.1 # MTA SUPPORT
147 chtekk 1.9 # ========================================================================
148 stuart 1.1
149     php_check_mta() {
150 chtekk 1.6 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 stuart 1.1 }
160    
161 chtekk 1.9 # ========================================================================
162 stuart 1.1 # ORACLE SUPPORT
163 chtekk 1.9 # ========================================================================
164 stuart 1.1
165 chtekk 1.5 php_check_oracle_all() {
166 chtekk 1.9 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
167 stuart 1.1 eerror
168 chtekk 1.6 eerror "You must have the ORACLE_HOME variable set in your environment to"
169     eerror "compile the Oracle extension."
170 stuart 1.1 eerror
171     die "Oracle configuration incorrect; user error"
172     fi
173    
174 chtekk 1.9 if use "oci8" || use "oracle7" ; then
175 stuart 1.1 if has_version 'dev-db/oracle-instantclient-basic' ; then
176 chtekk 1.6 ewarn
177 stuart 1.1 ewarn "Please ensure you have a full install of the Oracle client."
178 chtekk 1.6 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 stuart 1.1 fi
183     fi
184     }
185    
186 chtekk 1.5 php_check_oracle_8() {
187 chtekk 1.9 if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then
188 chtekk 1.5 eerror
189 chtekk 1.6 eerror "You must have the ORACLE_HOME variable set in your environment to"
190     eerror "compile the Oracle extension."
191 chtekk 1.5 eerror
192     die "Oracle configuration incorrect; user error"
193     fi
194    
195 chtekk 1.9 if use "oci8" ; then
196 chtekk 1.5 if has_version 'dev-db/oracle-instantclient-basic' ; then
197 chtekk 1.6 ewarn
198 chtekk 1.5 ewarn "Please ensure you have a full install of the Oracle client."
199 chtekk 1.6 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 chtekk 1.5 fi
204     fi
205     }
206    
207 chtekk 1.9 # ========================================================================
208 chtekk 1.7 # POSTGRESQL SUPPORT
209 chtekk 1.9 # ========================================================================
210 chtekk 1.7
211     php_check_pgsql() {
212 chtekk 1.9 if use "postgres" \
213     && use "apache2" && use "threads" \
214 chtekk 1.7 && 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 chtekk 1.9 # ========================================================================
225     # MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie
226     # ========================================================================
227    
228     php_get_mycnf_charset() {
229 jokey 1.10 # nothing todo if no mysql installed
230     if [[ ! -f "${ROOT}/etc/mysql/my.cnf" ]]; then
231     echo "empty"
232     return
233     fi
234 chtekk 1.9 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     }

  ViewVC Help
Powered by ViewVC 1.1.20