2 dnl Licensed to the Apache Software Foundation (ASF) under one or more
3 dnl contributor license agreements. See the NOTICE file distributed with
4 dnl this work for additional information regarding copyright ownership.
5 dnl The ASF licenses this file to You under the Apache License, Version 2.0
6 dnl (the "License"); you may not use this file except in compliance with
7 dnl the License. You may obtain a copy of the License at
9 dnl http://www.apache.org/licenses/LICENSE-2.0
11 dnl Unless required by applicable law or agreed to in writing, software
12 dnl distributed under the License is distributed on an "AS IS" BASIS,
13 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 dnl See the License for the specific language governing permissions and
15 dnl limitations under the License.
18 dnl --------------------------------------------------------------------------
19 dnl Author Henri Gomez <hgomez@apache.org>
21 dnl Inspired by Pier works on webapp m4 macros :)
23 dnl Version $Id: jk_java.m4 714101 2008-11-14 18:53:19Z rjung $
24 dnl --------------------------------------------------------------------------
26 dnl --------------------------------------------------------------------------
29 dnl Detection of JDK location and Java Platform (1.1, 1.2, 1.3, 1.4)
30 dnl result goes in JAVA_HOME / JAVA_PLATFORM (1 -> 1.1, 2 -> 1.2 and higher)
32 dnl --------------------------------------------------------------------------
37 [ --with-jni Build jni support],
40 y | yes | true) use_jni=true ;;
41 n | no | false) use_jni=false ;;
45 if ${TEST} "${use_jni}" = "true"; then
55 if ${TEST} "${use_jni}" = "true"; then
57 AC_MSG_CHECKING([for JDK location (please wait)])
58 if ${TEST} -n "${JAVA_HOME}" ; then
59 JAVA_HOME_ENV="${JAVA_HOME}"
69 [ --with-java-home=DIR Location of JDK directory.],
72 # This stuff works if the command line parameter --with-java-home was
73 # specified, so it takes priority rightfully.
77 if ${TEST} ! -d "${tempval}" ; then
78 AC_MSG_ERROR(Not a directory: ${tempval})
82 AC_MSG_RESULT(${JAVA_HOME})
85 # This works if the parameter was NOT specified, so it's a good time
86 # to see what the enviroment says.
87 # Since Sun uses JAVA_HOME a lot, we check it first and ignore the
88 # JAVA_HOME, otherwise just use whatever JAVA_HOME was specified.
90 if ${TEST} -n "${JAVA_HOME_ENV}" ; then
91 JAVA_HOME=${JAVA_HOME_ENV}
92 AC_MSG_RESULT(${JAVA_HOME_ENV} from environment)
96 if ${TEST} -z "${JAVA_HOME}" ; then
98 # Oh well, nobody set neither JAVA_HOME nor JAVA_HOME, have to guess
99 # The following code is based on the code submitted by Henner Zeller
100 # for ${srcdir}/src/scripts/package/rpm/ApacheJServ.spec
101 # Two variables will be set as a result:
105 AC_MSG_CHECKING([Try to guess JDK location])
107 for JAVA_PREFIX in /usr/local /usr/local/lib /usr /usr/lib /opt /usr/java ; do
109 for JAVA_PLATFORM in 4 3 2 1 ; do
111 for subversion in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
113 for VARIANT in IBMJava2- java java- jdk jdk-; do
114 GUESS="${JAVA_PREFIX}/${VARIANT}1.${JAVA_PLATFORM}${subversion}"
115 dnl AC_MSG_CHECKING([${GUESS}])
116 if ${TEST} -d "${GUESS}/bin" & ${TEST} -d "${GUESS}/include" ; then
118 AC_MSG_RESULT([${GUESS}])
123 if ${TEST} -n "${JAVA_HOME}" ; then
129 if ${TEST} -n "${JAVA_HOME}" ; then
135 if ${TEST} -n "${JAVA_HOME}" ; then
141 if ${TEST} ! -n "${JAVA_HOME}" ; then
142 AC_MSG_ERROR(can't locate a valid JDK location)
147 if ${TEST} -n "${JAVA_PLATFORM}"; then
148 AC_MSG_RESULT(Java Platform detected - 1.${JAVA_PLATFORM})
150 AC_MSG_CHECKING(Java platform)
153 AC_ARG_WITH(java-platform,
154 [ --with-java-platform[=2] Force the Java platform
155 (value is 1 for 1.1.x or 2 for 1.2.x or greater)],
159 JAVA_PLATFORM=${withval}
162 AC_MSG_ERROR(invalid java platform provided)
167 if ${TEST} -n "${JAVA_PLATFORM}"; then
168 AC_MSG_RESULT(Java Platform detected - 1.${JAVA_PLATFORM})
170 AC_MSG_CHECKING(Java platform)
174 AC_MSG_RESULT(${JAVA_PLATFORM})
178 # no jni, then make sure JAVA_HOME is not picked up from env
188 if ${TEST} "${use_jni}" = "true"; then
192 [ --with-os-type[=SUBDIR] Location of JDK os-type subdirectory.],
196 if ${TEST} ! -d "${JAVA_HOME}/${tempval}" ; then
197 AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${tempval})
203 AC_MSG_CHECKING(os_type directory)
204 if ${TEST} -f ${JAVA_HOME}/include/jni_md.h; then
207 for f in ${JAVA_HOME}/include/*/jni_md.h; do
208 if ${TEST} -f $f; then
214 if ${TEST} -z "${OS}"; then
215 AC_MSG_RESULT(Cannot find jni_md.h in ${JAVA_HOME}/${OS})
216 AC_MSG_ERROR(You should retry --with-os-type=SUBDIR)
223 dnl vi:set sts=2 sw=2 autoindent: