summaryrefslogtreecommitdiff
blob: b7557b130dbf0ec088ec6da92aaad51b602ad300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/php-common-r1.eclass,v 1.4 2005/11/01 10:04:13 chtekk Exp $

# ########################################################################
#
# eclass/php-common-r1.eclass
#				Contains common functions which are shared between the
#				PHP4 and PHP5 packages
#
#				USE THIS ECLASS FOR THE "CONSOLIDATED" PACKAGES
#
#				Based on robbat2's work on the php4 sapi eclass
#				Based on stuart's work on the php5 sapi eclass
#
# Maintainer:
#				php-bugs@gentoo.org
#
# ########################################################################

# ########################################################################
# CFLAG SANITY
# ########################################################################

php_check_cflags() {
	# filter the following from C[XX]FLAGS regardless, as apache won't be
	# supporting LFS until 2.2 is released and in the tree.  Fixes bug #24373.
	filter-flags "-D_FILE_OFFSET_BITS=64"
	filter-flags "-D_FILE_OFFSET_BITS=32"
	filter-flags "-D_LARGEFILE_SOURCE=1"
	filter-flags "-D_LARGEFILE_SOURCE"

	#fixes bug #14067
	# changed order to run it in reverse for bug #32022 and #12021
	replace-flags "-march=k6-3" "-march=i586"
	replace-flags "-march=k6-2" "-march=i586"
	replace-flags "-march=k6" "-march=i586"
}

# ########################################################################
# IMAP SUPPORT
# ########################################################################

php_check_imap() {
	if ! useq imap ; then
		return
	fi

	if useq ssl ; then
		if ! built_with_use virtual/imap-c-client ssl ; then
			eerror
			eerror "IMAP+SSL requested, but your IMAP libraries are built without SSL!"
			eerror
			die "Please recompile IMAP libraries w/ SSL support enabled"
		fi
	fi
}

# ########################################################################
# JAVA EXTENSION SUPPORT
#
# The bundled java extension is unique to PHP4 at the time of writing, but
# there is now the PHP-Java-Bridge that works under both PHP4 and PHP5.
# ########################################################################

php_check_java() {
	if ! useq java-internal ; then
		return 1
	fi

	JDKHOME="`java-config --jdk-home`"
	NOJDKERROR="You need to use java-config to set your JVM to a JDK!"
	if [ -z "${JDKHOME}" ] || [ ! -d "${JDKHOME}" ]; then
		eerror "${NOJDKERROR}"
		die "${NOJDKERROR}"
	fi

	# stuart@gentoo.org - 2003/05/18
	# Kaffe JVM is not a drop-in replacement for the Sun JDK at this time
	if echo ${JDKHOME} | grep kaffe > /dev/null 2>&1 ; then
		eerror
		eerror "PHP will not build using the Kaffe Java Virtual Machine."
		eerror "Please change your JVM to either Blackdown or Sun's."
		eerror
		eerror "To build PHP without Java support, please re-run this emerge"
		eerror "and place the line:"
		eerror "  USE='-java-internal'"
		eerror "in front of your emerge command; e.g."
		eerror "  USE='-java-internal' emerge =dev-lang/php-4*"
		eerror
		eerror "or edit your USE flags in /etc/make.conf"
		die "Kaffe JVM not supported"
	fi

	JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs )
	einfo "Active JDK version: ${JDKVER}"
	case "${JDKVER}" in
		1.4.*) ;;
		1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;;
		*) eerror "A Java 1.4 JDK is required for Java support in PHP." ; die ;;
	esac
}

php_install_java() {
	if ! useq java-internal ; then
		return 1
	fi

	# we put these into /usr/lib so that they cannot conflict with
	# other versions of PHP (e.g. PHP 4 & PHP 5)
	insinto ${PHPEXTDIR}
	einfo "Installing JAR for PHP"
	doins ext/java/php_java.jar

	einfo "Installing Java test page"
	newins ext/java/except.php java-test.php

	einfo "Installing Java extension for PHP"
	doins modules/java.so

	dosym ${PHPEXTDIR}/java.so ${PHPEXTDIR}/libphp_java.so
}

php_install_java_inifile() {
	if ! useq java-internal ; then
		return 1
	fi

	JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;'| sort | uniq `"

	echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
	echo "java.library = ${JAVA_LIBRARY}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
	echo "java.class.path = ${PHPEXTDIR}/php_java.jar" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"
	echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini"

	dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini"
}

# ########################################################################
# MTA SUPPORT
# ########################################################################

php_check_mta() {
	[ -x "${ROOT}/usr/sbin/sendmail" ] || die "You need a virtual/mta that provides /usr/sbin/sendmail!"
}

# ########################################################################
# ORACLE SUPPORT
# ########################################################################

php_check_oracle() {
	if useq oci8 && [ -z "${ORACLE_HOME}" ]; then
		eerror
		eerror "You must have the ORACLE_HOME variable in your environment!"
		eerror
		die "Oracle configuration incorrect; user error"
	fi

	if useq oci8 || useq oracle7 ; then
		if has_version 'dev-db/oracle-instantclient-basic' ; then
			ewarn "Please ensure you have a full install of the Oracle client."
			ewarn "dev-db/oracle-instantclient* is NOT sufficient."
		fi
	fi
}

# ########################################################################
# END OF ECLASS
# ########################################################################