bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / support / jk_java.m4
1 dnl
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
8 dnl
9 dnl     http://www.apache.org/licenses/LICENSE-2.0
10 dnl
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.
16 dnl
17
18 dnl --------------------------------------------------------------------------
19 dnl Author Henri Gomez <hgomez@apache.org>
20 dnl
21 dnl Inspired by Pier works on webapp m4 macros :)
22 dnl 
23 dnl Version $Id: jk_java.m4 714101 2008-11-14 18:53:19Z rjung $
24 dnl --------------------------------------------------------------------------
25
26 dnl --------------------------------------------------------------------------
27 dnl JK_JDK
28 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)
31 dnl 
32 dnl --------------------------------------------------------------------------
33 AC_DEFUN(
34   [JK_JNI],
35   [
36     AC_ARG_WITH(jni,
37       [  --with-jni               Build jni support],
38       [
39                 case "${withval}" in
40                   y | yes | true) use_jni=true ;;
41                   n | no | false) use_jni=false ;;
42             *) use_jni=true ;;
43               esac
44
45                 if ${TEST} "${use_jni}" = "true"; then
46                   HAVE_JNI="-DHAVE_JNI"
47                   JNI_BUILD="jni-build"
48                 fi
49       ])
50   ])
51
52 AC_DEFUN(
53   [JK_JDK],
54   [
55     if ${TEST} "${use_jni}" = "true"; then
56       tempval=""
57       AC_MSG_CHECKING([for JDK location (please wait)])
58       if ${TEST} -n "${JAVA_HOME}" ; then
59         JAVA_HOME_ENV="${JAVA_HOME}"
60       else
61         JAVA_HOME_ENV=""
62       fi
63
64       JAVA_HOME=""
65       JAVA_PLATFORM=""
66
67       AC_ARG_WITH(
68         [java-home],
69         [  --with-java-home=DIR     Location of JDK directory.],
70         [
71
72         # This stuff works if the command line parameter --with-java-home was
73         # specified, so it takes priority rightfully.
74   
75         tempval=${withval}
76
77         if ${TEST} ! -d "${tempval}" ; then
78             AC_MSG_ERROR(Not a directory: ${tempval})
79         fi
80   
81         JAVA_HOME=${tempval}
82         AC_MSG_RESULT(${JAVA_HOME})
83       ],
84       [
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.
89
90         if ${TEST} -n "${JAVA_HOME_ENV}" ; then
91           JAVA_HOME=${JAVA_HOME_ENV}
92           AC_MSG_RESULT(${JAVA_HOME_ENV} from environment)
93         fi
94       ])
95
96       if ${TEST} -z "${JAVA_HOME}" ; then
97
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:
102         #
103         # JAVA_HOME
104         # JAVA_PLATFORM
105         AC_MSG_CHECKING([Try to guess JDK location])
106
107         for JAVA_PREFIX in /usr/local /usr/local/lib /usr /usr/lib /opt /usr/java ; do
108
109           for JAVA_PLATFORM in 4 3 2 1 ; do
110
111             for subversion in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
112
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
117                   JAVA_HOME="${GUESS}"
118                   AC_MSG_RESULT([${GUESS}])
119                   break
120                 fi
121               done
122
123               if ${TEST} -n "${JAVA_HOME}" ; then
124                 break;
125               fi
126
127             done
128
129             if ${TEST} -n "${JAVA_HOME}" ; then
130               break;
131             fi
132
133           done
134
135           if ${TEST} -n "${JAVA_HOME}" ; then
136             break;
137           fi
138
139         done
140
141         if ${TEST} ! -n "${JAVA_HOME}" ; then
142           AC_MSG_ERROR(can't locate a valid JDK location)
143         fi
144
145       fi
146
147       if ${TEST} -n "${JAVA_PLATFORM}"; then
148         AC_MSG_RESULT(Java Platform detected - 1.${JAVA_PLATFORM})
149       else
150         AC_MSG_CHECKING(Java platform)
151       fi
152
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)],
156        [
157           case "${withval}" in
158             "1"|"2")
159               JAVA_PLATFORM=${withval}
160               ;;
161             *)
162               AC_MSG_ERROR(invalid java platform provided)
163               ;;
164           esac
165        ],
166        [
167           if ${TEST} -n "${JAVA_PLATFORM}"; then
168             AC_MSG_RESULT(Java Platform detected - 1.${JAVA_PLATFORM})
169           else
170             AC_MSG_CHECKING(Java platform)
171           fi
172        ])
173
174        AC_MSG_RESULT(${JAVA_PLATFORM})
175
176       unset tempval
177     else
178       # no jni, then make sure JAVA_HOME is not picked up from env
179       JAVA_HOME=""
180       JAVA_PLATFORM=""
181     fi
182   ])
183
184
185 AC_DEFUN(
186   [JK_JDK_OS],
187   [
188     if ${TEST} "${use_jni}" = "true"; then
189       tempval=""
190       OS=""
191       AC_ARG_WITH(os-type,
192         [  --with-os-type[=SUBDIR]  Location of JDK os-type subdirectory.],
193         [
194           tempval=${withval}
195
196           if ${TEST} ! -d "${JAVA_HOME}/${tempval}" ; then
197             AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${tempval})
198           fi
199
200           OS = ${tempval}
201         ],
202         [   
203           AC_MSG_CHECKING(os_type directory)
204           if ${TEST} -f ${JAVA_HOME}/include/jni_md.h; then
205             OS=""
206           else
207             for f in ${JAVA_HOME}/include/*/jni_md.h; do
208               if ${TEST} -f $f; then
209                 OS=`dirname ${f}`
210                 OS=`basename ${OS}`
211                 echo " ${OS}"
212               fi
213             done
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)
217             fi
218           fi
219         ])
220     fi
221   ])
222
223 dnl vi:set sts=2 sw=2 autoindent:
224