| 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 |
chtekk |
1.8 |
# $Header: $ |
| 4 |
stuart |
1.1 |
|
| 5 |
chtekk |
1.9 |
# ======================================================================== |
| 6 |
stuart |
1.1 |
# |
| 7 |
chtekk |
1.9 |
# php-common-r1.eclass |
| 8 |
|
|
# Contains common functions which are shared between the |
| 9 |
|
|
# PHP4 and PHP5 packages |
| 10 |
stuart |
1.1 |
# |
| 11 |
chtekk |
1.9 |
# USE THIS ECLASS FOR THE "CONSOLIDATED" PACKAGES |
| 12 |
stuart |
1.1 |
# |
| 13 |
chtekk |
1.9 |
# Based on robbat2's work on the php4 sapi eclass |
| 14 |
|
|
# Based on stuart's work on the php5 sapi eclass |
| 15 |
stuart |
1.1 |
# |
| 16 |
chtekk |
1.9 |
# Maintained by the PHP Team <php-bugs@gentoo.org> |
| 17 |
stuart |
1.1 |
# |
| 18 |
chtekk |
1.9 |
# ======================================================================== |
| 19 |
stuart |
1.1 |
|
| 20 |
chtekk |
1.9 |
# ======================================================================== |
| 21 |
stuart |
1.1 |
# CFLAG SANITY |
| 22 |
chtekk |
1.9 |
# ======================================================================== |
| 23 |
stuart |
1.1 |
|
| 24 |
|
|
php_check_cflags() { |
| 25 |
chtekk |
1.6 |
# 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 |
stuart |
1.1 |
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 |
chtekk |
1.6 |
# Fixes bug #14067. |
| 33 |
|
|
# Changed order to run it in reverse for bug #32022 and #12021. |
| 34 |
stuart |
1.1 |
replace-flags "-march=k6-3" "-march=i586" |
| 35 |
|
|
replace-flags "-march=k6-2" "-march=i586" |
| 36 |
|
|
replace-flags "-march=k6" "-march=i586" |
| 37 |
|
|
} |
| 38 |
|
|
|
| 39 |
chtekk |
1.9 |
# ======================================================================== |
| 40 |
stuart |
1.1 |
# IMAP SUPPORT |
| 41 |
chtekk |
1.9 |
# ======================================================================== |
| 42 |
stuart |
1.1 |
|
| 43 |
|
|
php_check_imap() { |
| 44 |
chtekk |
1.9 |
if ! use "imap" && ! phpconfutils_usecheck "imap" ; then |
| 45 |
stuart |
1.1 |
return |
| 46 |
|
|
fi |
| 47 |
|
|
|
| 48 |
chtekk |
1.9 |
if use "ssl" || phpconfutils_usecheck "ssl" ; then |
| 49 |
stuart |
1.1 |
if ! built_with_use virtual/imap-c-client ssl ; then |
| 50 |
|
|
eerror |
| 51 |
chtekk |
1.6 |
eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!" |
| 52 |
stuart |
1.1 |
eerror |
| 53 |
chtekk |
1.6 |
die "Please recompile the IMAP C-Client libraries with SSL support enabled" |
| 54 |
|
|
fi |
| 55 |
|
|
else |
| 56 |
|
|
if built_with_use virtual/imap-c-client ssl ; then |
| 57 |
|
|
eerror |
| 58 |
|
|
eerror "IMAP without SSL requested, but your IMAP C-Client libraries are built with SSL!" |
| 59 |
|
|
eerror |
| 60 |
|
|
die "Please recompile the IMAP C-Client libraries with SSL support disabled" |
| 61 |
stuart |
1.1 |
fi |
| 62 |
|
|
fi |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
chtekk |
1.9 |
# ======================================================================== |
| 66 |
stuart |
1.1 |
# JAVA EXTENSION SUPPORT |
| 67 |
|
|
# |
| 68 |
chtekk |
1.9 |
# The bundled java extension is unique to PHP4, but there is |
| 69 |
|
|
# now the PHP-Java-Bridge that works under both PHP4 and PHP5. |
| 70 |
|
|
# ======================================================================== |
| 71 |
stuart |
1.1 |
|
| 72 |
hollow |
1.2 |
php_check_java() { |
| 73 |
chtekk |
1.9 |
if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
| 74 |
chtekk |
1.6 |
return |
| 75 |
stuart |
1.1 |
fi |
| 76 |
|
|
|
| 77 |
|
|
JDKHOME="`java-config --jdk-home`" |
| 78 |
chtekk |
1.6 |
NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!" |
| 79 |
|
|
if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then |
| 80 |
stuart |
1.1 |
eerror "${NOJDKERROR}" |
| 81 |
|
|
die "${NOJDKERROR}" |
| 82 |
|
|
fi |
| 83 |
|
|
|
| 84 |
|
|
# stuart@gentoo.org - 2003/05/18 |
| 85 |
|
|
# Kaffe JVM is not a drop-in replacement for the Sun JDK at this time |
| 86 |
|
|
if echo ${JDKHOME} | grep kaffe > /dev/null 2>&1 ; then |
| 87 |
|
|
eerror |
| 88 |
|
|
eerror "PHP will not build using the Kaffe Java Virtual Machine." |
| 89 |
|
|
eerror "Please change your JVM to either Blackdown or Sun's." |
| 90 |
|
|
eerror |
| 91 |
|
|
eerror "To build PHP without Java support, please re-run this emerge" |
| 92 |
|
|
eerror "and place the line:" |
| 93 |
hollow |
1.2 |
eerror " USE='-java-internal'" |
| 94 |
chtekk |
1.6 |
eerror "in front of your emerge command, for example:" |
| 95 |
hollow |
1.2 |
eerror " USE='-java-internal' emerge =dev-lang/php-4*" |
| 96 |
stuart |
1.1 |
eerror |
| 97 |
chtekk |
1.6 |
eerror "or edit your USE flags in /etc/make.conf." |
| 98 |
stuart |
1.1 |
die "Kaffe JVM not supported" |
| 99 |
|
|
fi |
| 100 |
|
|
|
| 101 |
hollow |
1.2 |
JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs ) |
| 102 |
stuart |
1.1 |
einfo "Active JDK version: ${JDKVER}" |
| 103 |
chtekk |
1.3 |
case "${JDKVER}" in |
| 104 |
stuart |
1.1 |
1.4.*) ;; |
| 105 |
|
|
1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;; |
| 106 |
chtekk |
1.6 |
*) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;; |
| 107 |
stuart |
1.1 |
esac |
| 108 |
|
|
} |
| 109 |
|
|
|
| 110 |
|
|
php_install_java() { |
| 111 |
chtekk |
1.9 |
if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
| 112 |
chtekk |
1.6 |
return |
| 113 |
stuart |
1.1 |
fi |
| 114 |
|
|
|
| 115 |
chtekk |
1.6 |
# We put these into /usr/lib so that they cannot conflict with |
| 116 |
stuart |
1.1 |
# other versions of PHP (e.g. PHP 4 & PHP 5) |
| 117 |
chtekk |
1.6 |
insinto "${PHPEXTDIR}" |
| 118 |
chtekk |
1.8 |
|
| 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 |
|
|
|
| 125 |
stuart |
1.1 |
einfo "Installing JAR for PHP" |
| 126 |
chtekk |
1.6 |
doins "ext/java/php_java.jar" |
| 127 |
stuart |
1.1 |
|
| 128 |
|
|
einfo "Installing Java test page" |
| 129 |
chtekk |
1.6 |
newins "ext/java/except.php" "java-test.php" |
| 130 |
stuart |
1.1 |
} |
| 131 |
|
|
|
| 132 |
chtekk |
1.3 |
php_install_java_inifile() { |
| 133 |
chtekk |
1.9 |
if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then |
| 134 |
chtekk |
1.6 |
return |
| 135 |
chtekk |
1.4 |
fi |
| 136 |
|
|
|
| 137 |
chtekk |
1.6 |
JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u`" |
| 138 |
chtekk |
1.3 |
|
| 139 |
|
|
echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" |
| 140 |
|
|
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" |
| 142 |
|
|
echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" |
| 143 |
|
|
|
| 144 |
|
|
dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini" |
| 145 |
|
|
} |
| 146 |
|
|
|
| 147 |
chtekk |
1.9 |
# ======================================================================== |
| 148 |
stuart |
1.1 |
# MTA SUPPORT |
| 149 |
chtekk |
1.9 |
# ======================================================================== |
| 150 |
stuart |
1.1 |
|
| 151 |
|
|
php_check_mta() { |
| 152 |
chtekk |
1.6 |
if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then |
| 153 |
|
|
ewarn |
| 154 |
|
|
ewarn "You need a virtual/mta that provides a sendmail compatible binary!" |
| 155 |
|
|
ewarn "All major MTAs provide this, and it's usually some symlink created" |
| 156 |
|
|
ewarn "as '${ROOT}/usr/sbin/sendmail*'. You should also be able to use other" |
| 157 |
|
|
ewarn "MTAs directly, but you'll have to edit the sendmail_path directive" |
| 158 |
|
|
ewarn "in your php.ini for this to work." |
| 159 |
|
|
ewarn |
| 160 |
|
|
fi |
| 161 |
stuart |
1.1 |
} |
| 162 |
|
|
|
| 163 |
chtekk |
1.9 |
# ======================================================================== |
| 164 |
stuart |
1.1 |
# ORACLE SUPPORT |
| 165 |
chtekk |
1.9 |
# ======================================================================== |
| 166 |
stuart |
1.1 |
|
| 167 |
chtekk |
1.5 |
php_check_oracle_all() { |
| 168 |
chtekk |
1.9 |
if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then |
| 169 |
stuart |
1.1 |
eerror |
| 170 |
chtekk |
1.6 |
eerror "You must have the ORACLE_HOME variable set in your environment to" |
| 171 |
|
|
eerror "compile the Oracle extension." |
| 172 |
stuart |
1.1 |
eerror |
| 173 |
|
|
die "Oracle configuration incorrect; user error" |
| 174 |
|
|
fi |
| 175 |
|
|
|
| 176 |
chtekk |
1.9 |
if use "oci8" || use "oracle7" ; then |
| 177 |
stuart |
1.1 |
if has_version 'dev-db/oracle-instantclient-basic' ; then |
| 178 |
chtekk |
1.6 |
ewarn |
| 179 |
stuart |
1.1 |
ewarn "Please ensure you have a full install of the Oracle client." |
| 180 |
chtekk |
1.6 |
ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." |
| 181 |
|
|
ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" |
| 182 |
|
|
ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client." |
| 183 |
|
|
ewarn |
| 184 |
stuart |
1.1 |
fi |
| 185 |
|
|
fi |
| 186 |
|
|
} |
| 187 |
|
|
|
| 188 |
chtekk |
1.5 |
php_check_oracle_8() { |
| 189 |
chtekk |
1.9 |
if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then |
| 190 |
chtekk |
1.5 |
eerror |
| 191 |
chtekk |
1.6 |
eerror "You must have the ORACLE_HOME variable set in your environment to" |
| 192 |
|
|
eerror "compile the Oracle extension." |
| 193 |
chtekk |
1.5 |
eerror |
| 194 |
|
|
die "Oracle configuration incorrect; user error" |
| 195 |
|
|
fi |
| 196 |
|
|
|
| 197 |
chtekk |
1.9 |
if use "oci8" ; then |
| 198 |
chtekk |
1.5 |
if has_version 'dev-db/oracle-instantclient-basic' ; then |
| 199 |
chtekk |
1.6 |
ewarn |
| 200 |
chtekk |
1.5 |
ewarn "Please ensure you have a full install of the Oracle client." |
| 201 |
chtekk |
1.6 |
ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." |
| 202 |
|
|
ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" |
| 203 |
|
|
ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client." |
| 204 |
|
|
ewarn |
| 205 |
chtekk |
1.5 |
fi |
| 206 |
|
|
fi |
| 207 |
|
|
} |
| 208 |
|
|
|
| 209 |
chtekk |
1.9 |
# ======================================================================== |
| 210 |
chtekk |
1.7 |
# POSTGRESQL SUPPORT |
| 211 |
chtekk |
1.9 |
# ======================================================================== |
| 212 |
chtekk |
1.7 |
|
| 213 |
|
|
php_check_pgsql() { |
| 214 |
chtekk |
1.9 |
if use "postgres" \ |
| 215 |
|
|
&& use "apache2" && use "threads" \ |
| 216 |
chtekk |
1.7 |
&& 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 |
chtekk |
1.9 |
# ======================================================================== |
| 227 |
|
|
# MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie |
| 228 |
|
|
# ======================================================================== |
| 229 |
|
|
|
| 230 |
|
|
php_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 |
|
|
} |