~ubuntu-branches/ubuntu/oneiric/libapache-mod-jk/oneiric

« back to all changes in this revision

Viewing changes to support/jk_java.m4

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2006-08-05 16:30:53 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060805163053-myf66gm6j1a21ps6
Tags: 1:1.2.18-1ubuntu1
Merge from Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl
 
2
dnl Copyright 1999-2004 The Apache Software Foundation
 
3
dnl
 
4
dnl Licensed under the Apache License, Version 2.0 (the "License");
 
5
dnl you may not use this file except in compliance with the License.
 
6
dnl You may obtain a copy of the License at
 
7
dnl
 
8
dnl     http://www.apache.org/licenses/LICENSE-2.0
 
9
dnl
 
10
dnl Unless required by applicable law or agreed to in writing, software
 
11
dnl distributed under the License is distributed on an "AS IS" BASIS,
 
12
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
dnl See the License for the specific language governing permissions and
 
14
dnl limitations under the License.
 
15
dnl
 
16
 
 
17
dnl --------------------------------------------------------------------------
 
18
dnl Author Henri Gomez <hgomez@apache.org>
 
19
dnl
 
20
dnl Inspired by Pier works on webapp m4 macros :)
 
21
dnl 
 
22
dnl Version $Id: jk_java.m4 299440 2004-05-28 00:04:43Z yoavs $
 
23
dnl --------------------------------------------------------------------------
 
24
 
 
25
dnl --------------------------------------------------------------------------
 
26
dnl JK_JDK
 
27
dnl
 
28
dnl Detection of JDK location and Java Platform (1.1, 1.2, 1.3, 1.4)
 
29
dnl result goes in JAVA_HOME / JAVA_PLATFORM (1 -> 1.1, 2 -> 1.2 and higher)
 
30
dnl 
 
31
dnl --------------------------------------------------------------------------
 
32
AC_DEFUN(
 
33
  [JK_JNI],
 
34
  [
 
35
    AC_ARG_WITH(jni,
 
36
      [  --with-jni               Build jni support],
 
37
      [
 
38
                case "${withval}" in
 
39
                  y | yes | true) use_jni=true ;;
 
40
                  n | no | false) use_jni=false ;;
 
41
            *) use_jni=true ;;
 
42
              esac
 
43
 
 
44
                if ${TEST} "${use_jni}" = "true"; then
 
45
                  HAVE_JNI="-DHAVE_JNI"
 
46
                  JNI_BUILD="jni-build"
 
47
                fi
 
48
      ])
 
49
  ])
 
50
 
 
51
AC_DEFUN(
 
52
  [JK_JDK],
 
53
  [
 
54
    if ${TEST} "${use_jni}" = "true"; then
 
55
      tempval=""
 
56
      AC_MSG_CHECKING([for JDK location (please wait)])
 
57
      if ${TEST} -n "${JAVA_HOME}" ; then
 
58
        JAVA_HOME_ENV="${JAVA_HOME}"
 
59
      else
 
60
        JAVA_HOME_ENV=""
 
61
      fi
 
62
 
 
63
      JAVA_HOME=""
 
64
      JAVA_PLATFORM=""
 
65
 
 
66
      AC_ARG_WITH(
 
67
        [java-home],
 
68
        [  --with-java-home=DIR     Location of JDK directory.],
 
69
        [
 
70
 
 
71
        # This stuff works if the command line parameter --with-java-home was
 
72
        # specified, so it takes priority rightfully.
 
73
  
 
74
        tempval=${withval}
 
75
 
 
76
        if ${TEST} ! -d "${tempval}" ; then
 
77
            AC_MSG_ERROR(Not a directory: ${tempval})
 
78
        fi
 
79
  
 
80
        JAVA_HOME=${tempval}
 
81
        AC_MSG_RESULT(${JAVA_HOME})
 
82
      ],
 
83
      [
 
84
        # This works if the parameter was NOT specified, so it's a good time
 
85
        # to see what the enviroment says.
 
86
        # Since Sun uses JAVA_HOME a lot, we check it first and ignore the
 
87
        # JAVA_HOME, otherwise just use whatever JAVA_HOME was specified.
 
88
 
 
89
        if ${TEST} -n "${JAVA_HOME_ENV}" ; then
 
90
          JAVA_HOME=${JAVA_HOME_ENV}
 
91
          AC_MSG_RESULT(${JAVA_HOME_ENV} from environment)
 
92
        fi
 
93
      ])
 
94
 
 
95
      if ${TEST} -z "${JAVA_HOME}" ; then
 
96
 
 
97
        # Oh well, nobody set neither JAVA_HOME nor JAVA_HOME, have to guess
 
98
        # The following code is based on the code submitted by Henner Zeller
 
99
        # for ${srcdir}/src/scripts/package/rpm/ApacheJServ.spec
 
100
        # Two variables will be set as a result:
 
101
        #
 
102
        # JAVA_HOME
 
103
        # JAVA_PLATFORM
 
104
        AC_MSG_CHECKING([Try to guess JDK location])
 
105
 
 
106
        for JAVA_PREFIX in /usr/local /usr/local/lib /usr /usr/lib /opt /usr/java ; do
 
107
 
 
108
          for JAVA_PLATFORM in 4 3 2 1 ; do
 
109
 
 
110
            for subversion in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ; do
 
111
 
 
112
              for VARIANT in IBMJava2- java java- jdk jdk-; do
 
113
                GUESS="${JAVA_PREFIX}/${VARIANT}1.${JAVA_PLATFORM}${subversion}"
 
114
dnl             AC_MSG_CHECKING([${GUESS}])
 
115
                if ${TEST} -d "${GUESS}/bin" & ${TEST} -d "${GUESS}/include" ; then
 
116
                  JAVA_HOME="${GUESS}"
 
117
                  AC_MSG_RESULT([${GUESS}])
 
118
                  break
 
119
                fi
 
120
              done
 
121
 
 
122
              if ${TEST} -n "${JAVA_HOME}" ; then
 
123
                break;
 
124
              fi
 
125
 
 
126
            done
 
127
 
 
128
            if ${TEST} -n "${JAVA_HOME}" ; then
 
129
              break;
 
130
            fi
 
131
 
 
132
          done
 
133
 
 
134
          if ${TEST} -n "${JAVA_HOME}" ; then
 
135
            break;
 
136
          fi
 
137
 
 
138
        done
 
139
 
 
140
        if ${TEST} ! -n "${JAVA_HOME}" ; then
 
141
          AC_MSG_ERROR(can't locate a valid JDK location)
 
142
        fi
 
143
 
 
144
      fi
 
145
 
 
146
      if ${TEST} -n "${JAVA_PLATFORM}"; then
 
147
        AC_MSG_RESULT(Java Platform detected - 1.${JAVA_PLATFORM})
 
148
      else
 
149
        AC_MSG_CHECKING(Java platform)
 
150
      fi
 
151
 
 
152
      AC_ARG_WITH(java-platform,
 
153
       [  --with-java-platform[=2] Force the Java platorm
 
154
                                   (value is 1 for 1.1.x or 2 for 1.2.x or greater)],
 
155
       [
 
156
          case "${withval}" in
 
157
            "1"|"2")
 
158
              JAVA_PLATFORM=${withval}
 
159
              ;;
 
160
            *)
 
161
              AC_MSG_ERROR(invalid java platform provided)
 
162
              ;;
 
163
          esac
 
164
       ],
 
165
       [
 
166
          if ${TEST} -n "${JAVA_PLATFORM}"; then
 
167
            AC_MSG_RESULT(Java Platform detected - 1.${JAVA_PLATFORM})
 
168
          else
 
169
            AC_MSG_CHECKING(Java platform)
 
170
          fi
 
171
       ])
 
172
 
 
173
       AC_MSG_RESULT(${JAVA_PLATFORM})
 
174
 
 
175
      unset tempval
 
176
    else
 
177
      # no jni, then make sure JAVA_HOME is not picked up from env
 
178
      JAVA_HOME=""
 
179
      JAVA_PLATFORM=""
 
180
    fi
 
181
  ])
 
182
 
 
183
 
 
184
AC_DEFUN(
 
185
  [JK_JDK_OS],
 
186
  [
 
187
    if ${TEST} "${use_jni}" = "true"; then
 
188
      tempval=""
 
189
      OS=""
 
190
      AC_ARG_WITH(os-type,
 
191
        [  --with-os-type[=SUBDIR]  Location of JDK os-type subdirectory.],
 
192
        [
 
193
          tempval=${withval}
 
194
 
 
195
          if ${TEST} ! -d "${JAVA_HOME}/${tempval}" ; then
 
196
            AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${tempval})
 
197
          fi
 
198
 
 
199
          OS = ${tempval}
 
200
        ],
 
201
        [   
 
202
          AC_MSG_CHECKING(os_type directory)
 
203
          if ${TEST} -f ${JAVA_HOME}/include/jni_md.h; then
 
204
            OS=""
 
205
          else
 
206
            for f in ${JAVA_HOME}/include/*/jni_md.h; do
 
207
              if ${TEST} -f $f; then
 
208
                OS=`dirname ${f}`
 
209
                OS=`basename ${OS}`
 
210
                echo " ${OS}"
 
211
              fi
 
212
            done
 
213
            if ${TEST} -z "${OS}"; then
 
214
              AC_MSG_RESULT(Cannot find jni_md.h in ${JAVA_HOME}/${OS})
 
215
              AC_MSG_ERROR(You should retry --with-os-type=SUBDIR)
 
216
            fi
 
217
          fi
 
218
        ])
 
219
    fi
 
220
  ])
 
221
 
 
222
dnl vi:set sts=2 sw=2 autoindent:
 
223