| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 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 2005/09/04 10:54:53 stuart Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/php-common-r1.eclass,v 1.1.1.1 2005/11/30 09:59:37 chriswhite Exp $ |
| 4 | |
4 | |
| 5 | # ######################################################################## |
5 | # ######################################################################## |
| 6 | # |
6 | # |
| 7 | # eclass/php-common-r1.eclass |
7 | # eclass/php-common-r1.eclass |
| 8 | # Contains common functions which are shared between the |
8 | # Contains common functions which are shared between the |
| … | |
… | |
| 61 | # |
61 | # |
| 62 | # The bundled java extension is unique to PHP4 at the time of writing, but |
62 | # The bundled java extension is unique to PHP4 at the time of writing, but |
| 63 | # there is now the PHP-Java-Bridge that works under both PHP4 and PHP5. |
63 | # there is now the PHP-Java-Bridge that works under both PHP4 and PHP5. |
| 64 | # ######################################################################## |
64 | # ######################################################################## |
| 65 | |
65 | |
| 66 | php_uses_java() { |
66 | php_check_java() { |
| 67 | if ! useq java ; then |
67 | if ! useq java-internal ; then |
| 68 | return 1 |
68 | return 1 |
| 69 | fi |
|
|
| 70 | |
|
|
| 71 | if useq alpha || useq amd64 ; then |
|
|
| 72 | return 1 |
|
|
| 73 | fi |
|
|
| 74 | |
|
|
| 75 | return 0 |
|
|
| 76 | } |
|
|
| 77 | |
|
|
| 78 | php_check_java() { |
|
|
| 79 | if ! php_uses_java ; then |
|
|
| 80 | return |
|
|
| 81 | fi |
69 | fi |
| 82 | |
70 | |
| 83 | JDKHOME="`java-config --jdk-home`" |
71 | JDKHOME="`java-config --jdk-home`" |
| 84 | NOJDKERROR="You need to use java-config to set your JVM to a JDK!" |
72 | NOJDKERROR="You need to use java-config to set your JVM to a JDK!" |
| 85 | if [ -z "${JDKHOME}" ] || [ ! -d "${JDKHOME}" ]; then |
73 | if [ -z "${JDKHOME}" ] || [ ! -d "${JDKHOME}" ]; then |
| … | |
… | |
| 87 | die "${NOJDKERROR}" |
75 | die "${NOJDKERROR}" |
| 88 | fi |
76 | fi |
| 89 | |
77 | |
| 90 | # stuart@gentoo.org - 2003/05/18 |
78 | # stuart@gentoo.org - 2003/05/18 |
| 91 | # Kaffe JVM is not a drop-in replacement for the Sun JDK at this time |
79 | # Kaffe JVM is not a drop-in replacement for the Sun JDK at this time |
| 92 | |
|
|
| 93 | if echo ${JDKHOME} | grep kaffe > /dev/null 2>&1 ; then |
80 | if echo ${JDKHOME} | grep kaffe > /dev/null 2>&1 ; then |
| 94 | eerror |
81 | eerror |
| 95 | eerror "PHP will not build using the Kaffe Java Virtual Machine." |
82 | eerror "PHP will not build using the Kaffe Java Virtual Machine." |
| 96 | eerror "Please change your JVM to either Blackdown or Sun's." |
83 | eerror "Please change your JVM to either Blackdown or Sun's." |
| 97 | eerror |
84 | eerror |
| 98 | eerror "To build PHP without Java support, please re-run this emerge" |
85 | eerror "To build PHP without Java support, please re-run this emerge" |
| 99 | eerror "and place the line:" |
86 | eerror "and place the line:" |
| 100 | eerror " USE='-java'" |
87 | eerror " USE='-java-internal'" |
| 101 | eerror "in front of your emerge command; e.g." |
88 | eerror "in front of your emerge command; e.g." |
| 102 | eerror " USE='-java' emerge mod_php" |
89 | eerror " USE='-java-internal' emerge =dev-lang/php-4*" |
| 103 | eerror |
90 | eerror |
| 104 | eerror "or edit your USE flags in /etc/make.conf" |
91 | eerror "or edit your USE flags in /etc/make.conf" |
| 105 | die "Kaffe JVM not supported" |
92 | die "Kaffe JVM not supported" |
| 106 | fi |
93 | fi |
| 107 | |
94 | |
| 108 | JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 |
95 | JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs ) |
| 109 | }' | xargs ) |
|
|
| 110 | einfo "Active JDK version: ${JDKVER}" |
96 | einfo "Active JDK version: ${JDKVER}" |
| 111 | case ${JDKVER} in |
97 | case "${JDKVER}" in |
| 112 | 1.4.*) ;; |
98 | 1.4.*) ;; |
| 113 | 1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;; |
99 | 1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;; |
| 114 | *) eerror "A Java 1.4 JDK is required for Java support in PHP." ; die ;; |
100 | *) eerror "A Java 1.4 JDK is required for Java support in PHP." ; die ;; |
| 115 | esac |
101 | esac |
| 116 | } |
102 | } |
| 117 | |
103 | |
| 118 | php_install_java() { |
104 | php_install_java() { |
| 119 | if ! php_uses_java ; then |
105 | if ! useq java-internal ; then |
| 120 | return |
106 | return 1 |
| 121 | fi |
107 | fi |
| 122 | |
108 | |
| 123 | # we put these into /usr/lib so that they cannot conflict with |
109 | # we put these into /usr/lib so that they cannot conflict with |
| 124 | # other versions of PHP (e.g. PHP 4 & PHP 5) |
110 | # other versions of PHP (e.g. PHP 4 & PHP 5) |
| 125 | insinto ${PHPEXTDIR} |
111 | insinto ${PHPEXTDIR} |
| … | |
… | |
| 127 | doins ext/java/php_java.jar |
113 | doins ext/java/php_java.jar |
| 128 | |
114 | |
| 129 | einfo "Installing Java test page" |
115 | einfo "Installing Java test page" |
| 130 | newins ext/java/except.php java-test.php |
116 | newins ext/java/except.php java-test.php |
| 131 | |
117 | |
| 132 | JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;'| sort | uniq `" |
|
|
| 133 | sed -e "s|;java.library .*$|java.library = ${JAVA_LIBRARY}|g" -i ${phpinisrc} |
|
|
| 134 | sed -e "s|;java.class.path .*$|java.class.path = ${PHPEXTDIR}/php_java.jar|g" -i ${phpinisrc} |
|
|
| 135 | sed -e "s|;java.library.path .*$|java.library.path = ${PHPEXTDIR}|g" -i ${phpinisrc} |
|
|
| 136 | sed -e "s|;extension=php_java.dll.*$|extension = java.so|g" -i ${phpinisrc} |
|
|
| 137 | |
|
|
| 138 | einfo "Installing Java extension for PHP" |
118 | einfo "Installing Java extension for PHP" |
| 139 | doins modules/java.so |
119 | doins modules/java.so |
| 140 | |
120 | |
| 141 | dosym ${PHPEXTDIR}/java.so ${PHPEXTDIR}/libphp_java.so |
121 | dosym ${PHPEXTDIR}/java.so ${PHPEXTDIR}/libphp_java.so |
|
|
122 | } |
|
|
123 | |
|
|
124 | php_install_java_inifile() { |
|
|
125 | if ! useq java-internal ; then |
|
|
126 | return 1 |
|
|
127 | fi |
|
|
128 | |
|
|
129 | JAVA_LIBRARY="`grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;'| sort | uniq `" |
|
|
130 | |
|
|
131 | echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" |
|
|
132 | 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" |
|
|
134 | echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" |
|
|
135 | |
|
|
136 | dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini" |
| 142 | } |
137 | } |
| 143 | |
138 | |
| 144 | # ######################################################################## |
139 | # ######################################################################## |
| 145 | # MTA SUPPORT |
140 | # MTA SUPPORT |
| 146 | # ######################################################################## |
141 | # ######################################################################## |