bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / native / configure.in
1 dnl  Licensed to the Apache Software Foundation (ASF) under one or more
2 dnl  contributor license agreements.  See the NOTICE file distributed with
3 dnl  this work for additional information regarding copyright ownership.
4 dnl  The ASF licenses this file to You under the Apache License, Version 2.0
5 dnl  (the "License"); you may not use this file except in compliance with
6 dnl  the License.  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
16 dnl
17 dnl Process this file with autoconf to produce a configure script
18 dnl
19 AC_REVISION($Id: configure.in 1054607 2011-01-03 13:13:49Z rjung $)dnl
20
21 AC_PREREQ(2.13)
22 AC_INIT(common/jk_worker.h)
23 AC_CONFIG_HEADER(common/config.h)
24 AC_CONFIG_AUX_DIR(scripts/build/unix)
25 AC_CANONICAL_SYSTEM
26
27 dnl package and version. (synchronization with common/jk_version.h ?)
28 PACKAGE=mod_jk
29 VERSION=1.2.32
30
31 AM_INIT_AUTOMAKE(${PACKAGE}, ${VERSION})
32
33 dnl
34 dnl Include our own M4 macros
35 dnl
36 sinclude(scripts/build/jk_common.m4)
37
38 dnl Generate ./config.nice for reproducing runs of configure
39 dnl
40 JK_CONFIG_NICE(config.nice)
41
42 AC_PATH_PROG(TEST,test,$PATH)dnl
43 AC_SUBST(TEST)
44
45 AC_PATH_PROG(RM,rm,$PATH)dnl
46 AC_SUBST(RM)
47
48 AC_PATH_PROG(GREP,grep,$PATH)dnl
49 AC_SUBST(GREP)
50
51 AC_PATH_PROG(ECHO,echo,echo,$PATH)dnl
52 AC_SUBST(ECHO)
53
54 AC_PATH_PROG(SED,sed,$PATH)dnl
55 AC_SUBST(SED)
56
57 AC_PATH_PROG(CP,cp,$PATH)dnl
58 AC_SUBST(CP)
59
60 AC_PATH_PROG(MKDIR,mkdir,$PATH)dnl
61 AC_SUBST(MKDIR)
62
63 dnl Mark that we have generated config.h
64 CFLAGS="${CFLAGS} -DHAVE_CONFIG_H"
65 AC_SUBST(CFLAGS)
66
67 APACHE_CONFIG_VARS=`pwd`/scripts/build/config_vars.mk
68 WEBSERVER=""
69 apache_dir=""
70 apache_include=""
71 APXS="apxs"
72 AC_ARG_WITH(apxs,
73 [[  --with-apxs[=FILE]      Build shared Apache module.
74                           FILE is the optional pathname to the apxs tool;
75                           defaults to finding apxs in your PATH.]],
76 [
77     case "${withval}" in
78         y | yes | true) find_apxs=true ;;
79         n | no | false) find_apxs= ;;
80         *) find_apxs=${withval} ;;
81     esac
82
83     if ${TEST} ${find_apxs} ; then
84         AC_MSG_RESULT([need to check for Perl first, apxs depends on it...])
85         AC_PATH_PROG(PERL,perl,$PATH)dnl
86
87         if ${TEST} ${find_apxs} = true ; then
88             AC_PATH_PROG(APXS,apxs,$PATH)dnl
89         else
90             APXS=${find_apxs}
91         fi
92
93         if ${TEST} -n "${APXS}" ; then
94             dnl Seems that we have it, but have to check if it is OK first
95             if ${TEST} ! -x "${APXS}" ; then
96                 AC_MSG_ERROR(Invalid location for apxs: '${APXS}')
97             fi
98
99             ${APXS} -q PREFIX >/dev/null 2>/dev/null || apxs_support=false
100
101             if ${TEST} "${apxs_support}" = "false" ; then
102                 AC_MSG_RESULT(could not find ${APXS})
103                 AC_MSG_ERROR(You must specify a valid --with-apxs path)
104             fi
105
106             dnl apache_dir and apache_include are also needed.
107             apache_dir=`$APXS -q PREFIX`
108             apache_include="-I`$APXS -q INCLUDEDIR`"
109
110             dnl test apache version
111             APA=`${GREP} STANDARD20 ${APXS}`
112             if ${TEST} -z "$APA" ; then
113                 WEBSERVER="apache-1.3"
114                 APXSCC="`$APXS -q CC`"
115                 APXSCFLAGS="`$APXS -q CFLAGS` -DJK_PREFORK"
116                 APXSCPPFLAGS=""
117                 APXSLDFLAGS="`$APXS -q LDFLAGS_SHLIB`"
118             else
119                 WEBSERVER="apache-2.0"
120                 APRINCLUDEDIR=""
121                 INCTEMP="`$APXS -q APR_INCLUDEDIR` `$APXS -q APU_INCLUDEDIR`"
122                 for INC in ${INCTEMP}; do
123                     APRINCLUDEDIR="${APRINCLUDEDIR} -I${INC}"
124                 done
125                 AC_MSG_RESULT([APRINCLUDEDIR is $APRINCLUDEDIR])
126                 APXSCC="`$APXS -q CC`"
127                 APXSCFLAGS="`${APXS} -q CFLAGS` `${APXS} -q EXTRA_CFLAGS` -DHAVE_APR ${APRINCLUDEDIR}"
128                 APXSCPPFLAGS="`${APXS} -q EXTRA_CPPFLAGS`"
129                 APXSLDFLAGS="`$APXS -q LDFLAGS`"
130                 APACHE_CONFIG_VARS="`${APXS} -q exp_installbuilddir`/config_vars.mk"
131                 LIBTOOL=`$APXS -q LIBTOOL`
132             fi
133             AC_MSG_RESULT([building connector for \"$WEBSERVER\"])
134             if ${TEST} -z "${CC}" ; then
135                 CC="${APXSCC}"
136             else
137                 if ${TEST} "${CC}" != "$APXSCC" ; then
138                     WARN_CC=1
139                 fi
140             fi
141
142             AC_SUBST(APXS)
143         fi
144     fi
145 ],
146 [
147     AC_MSG_RESULT(no apxs given)
148 ])
149
150 AC_SUBST(APACHE_CONFIG_VARS)
151
152 AC_PROG_CC
153 AC_PROG_LD
154
155 SAVE_LIBTOOL="$LIBTOOL"
156
157 dnl Not sure what it does, but the libtool manual seems to require this
158 dnl It should use the native platform dlopen ( if available )
159 AC_LIBTOOL_DLOPEN
160
161 dnl AM_PROG_LIBTOOL often causes problems.
162 dnl I have solved them once using aclocal --acdir=/usr/local/share/aclocal/
163 AM_PROG_LIBTOOL
164
165 if ${TEST} -n "${SAVE_LIBTOOL}" ; then
166     LIBTOOL="$SAVE_LIBTOOL"
167 fi
168 AC_MSG_RESULT([LIBTOOL="$LIBTOOL"])
169
170 AC_SUBST(LIBTOOL)
171
172 dnl ----------------------------- Checks for standard typedefs
173
174 dnl Checks for integer size
175 AC_CHECK_SIZEOF(char, 1)
176 AC_CHECK_SIZEOF(int, 4)
177 AC_CHECK_SIZEOF(long, 4)
178 AC_CHECK_SIZEOF(short, 2)
179 AC_CHECK_SIZEOF(long double, 12)
180 AC_CHECK_SIZEOF(long long, 8)
181 AC_CHECK_SIZEOF(longlong, 8)
182
183 # Now we need to find what jk_uint32_t (sizeof == 4) will be.
184 # The first match is our preference.
185 if test "$ac_cv_sizeof_int" = "4"; then
186     int32_t_fmt='#define JK_INT32_T_FMT "d"'
187     uint32_t_fmt='#define JK_UINT32_T_FMT "u"'
188     uint32_t_hex_fmt='#define JK_UINT32_T_HEX_FMT "x"'
189     int32_value="int"
190 elif test "$ac_cv_sizeof_long" = "4"; then
191     int32_t_fmt='#define JK_INT32_T_FMT "ld"'
192     uint32_t_fmt='#define JK_UINT32_T_FMT "lu"'
193     uint32_t_hex_fmt='#define JK_UINT32_T_HEX_FMT "lx"'
194     int32_value="long"
195 else
196     int32_t_fmt='#error could not detect a 32-bit integer type'
197     uint32_t_fmt='#error could not detect a 32-bit integer type'
198     uint32_t_hex_fmt='#error could not detect a 32-bit integer type'
199     AC_ERROR([could not detect a 32-bit integer type])
200 fi
201
202 # Now we need to find what jk_uint64_t (sizeof == 8) will be.
203 # The first match is our preference.
204 if test "$ac_cv_sizeof_int" = "8"; then
205     int64_t_fmt='#define JK_INT64_T_FMT "d"'
206     uint64_t_fmt='#define JK_UINT64_T_FMT "u"'
207     uint64_t_hex_fmt='#define JK_UINT64_T_HEX_FMT "x"'
208     int64_value="int"
209 elif test "$ac_cv_sizeof_long" = "8"; then
210     int64_t_fmt='#define JK_INT64_T_FMT "ld"'
211     uint64_t_fmt='#define JK_UINT64_T_FMT "lu"'
212     uint64_t_hex_fmt='#define JK_UINT64_T_HEX_FMT "lx"'
213     int64_value="long"
214 elif test "$ac_cv_sizeof_long_long" = "8"; then
215     # Linux, Solaris, FreeBSD all support ll with printf.
216     # BSD 4.4 originated 'q'.  Solaris is more popular and
217     # doesn't support 'q'.  Solaris wins.  Exceptions can
218     # go to the OS-dependent section.
219     int64_t_fmt='#define JK_INT64_T_FMT "lld"'
220     uint64_t_fmt='#define JK_UINT64_T_FMT "llu"'
221     uint64_t_hex_fmt='#define JK_UINT64_T_HEX_FMT "llx"'
222     int64_value="long long"
223 elif test "$ac_cv_sizeof_long_double" = "8"; then
224     int64_t_fmt='#define JK_INT64_T_FMT "Ld"'
225     uint64_t_fmt='#define JK_UINT64_T_FMT "Lu"'
226     uint64_t_hex_fmt='#define JK_UINT64_T_HEX_FMT "Lx"'
227     int64_value="long double"
228 elif test "$ac_cv_sizeof_longlong" = "8"; then
229     int64_t_fmt='#define JK_INT64_T_FMT "qd"'
230     uint64_t_fmt='#define JK_UINT64_T_FMT "qu"'
231     uint64_t_hex_fmt='#define JK_UINT64_T_HEX_FMT "qx"'
232     int64_value="__int64"
233 else
234     int64_t_fmt='#error could not detect a 64-bit integer type'
235     uint64_t_fmt='#error could not detect a 64-bit integer type'
236     uint64_t_hex_fmt='#error could not detect a 64-bit integer type'
237     AC_ERROR([could not detect a 64-bit integer type])
238 fi
239
240 JK_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], pid_t, 8)
241
242 if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_short"; then
243     pid_t_fmt='#define JK_PID_T_FMT "hd"'
244 elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_int"; then
245     pid_t_fmt='#define JK_PID_T_FMT "d"'
246 elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then
247     pid_t_fmt='#define JK_PID_T_FMT "ld"'
248 elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long_long"; then
249     pid_t_fmt='#define JK_PID_T_FMT JK_INT64_T_FMT'
250 else
251     pid_t_fmt='#error Can not determine the proper size for pid_t'
252 fi
253
254 JK_CHECK_SIZEOF_EXTENDED([#include <pthread.h>], pthread_t, 8)
255
256 if test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_short"; then
257     pthread_t_fmt='#define JK_PTHREAD_T_FMT "hu"'
258     pthread_t_value="short"
259 elif test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_int"; then
260     pthread_t_fmt='#define JK_PTHREAD_T_FMT "u"'
261     pthread_t_value="int"
262 elif test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_long"; then
263     pthread_t_fmt='#define JK_PTHREAD_T_FMT "lu"'
264     pthread_t_value="long"
265 elif test "$ac_cv_sizeof_pthread_t" = "$ac_cv_sizeof_long_long"; then
266     pthread_t_fmt='#define JK_PTHREAD_T_FMT "llu"'
267     pthread_t_value="long long"
268 else
269     pthread_t_fmt='#error Can not determine the proper size for pthread_t'
270 fi
271
272 # Basically, we have tried to figure out the correct format strings
273 # for pid_t which varies between platforms, but we don't always get
274 # it right.  If you find that we don't get it right for your platform,
275 # you can override our decision below.
276 case $host in
277    *-solaris*)
278        if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then
279            pid_t_fmt='#define JK_PID_T_FMT "ld"'
280        fi
281        ;;
282 esac
283
284 AC_SUBST(int32_value)
285 AC_SUBST(int32_t_fmt)
286 AC_SUBST(uint32_t_fmt)
287 AC_SUBST(uint32_t_hex_fmt)
288 AC_SUBST(int64_value)
289 AC_SUBST(int64_t_fmt)
290 AC_SUBST(uint64_t_fmt)
291 AC_SUBST(uint64_t_hex_fmt)
292 AC_SUBST(pid_t_fmt)
293 AC_SUBST(pthread_t_fmt)
294 AC_SUBST(pthread_t_value)
295
296 dnl check for snprintf and vsnprintf.
297 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF,1,[Have snprintf()]))
298 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF,1,[Have vsnprintf()]))
299 dnl check for flock function.
300 AC_CHECK_FUNC(flock, AC_DEFINE(HAVE_FLOCK,1,[Have flock()]))
301
302 dnl check for -lsocket library
303 AC_CHECK_LIB(socket, setsockopt, [LIBS="$LIBS -lsocket"])
304
305 dnl check for filio.h used on Solaris to define FIONREAD ioctl.
306 AC_CHECK_HEADERS(sys/filio.h)
307
308 AC_DEFUN([JK_CHECK_SETSOCKOPT], [
309 AC_MSG_CHECKING(whether to use $1 with setsockopt())
310 AC_TRY_RUN([
311 #include <sys/types.h>
312 #include <sys/socket.h>
313 #include <sys/time.h>
314
315 int main(void)
316 {
317     int s;
318     struct timeval tv;
319     tv.tv_sec  = 3;
320     tv.tv_usec = 0;
321
322 #ifndef $1
323     exit(3);
324 #else
325     if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
326         exit(2);
327
328     /* fails on Solaris 2.6,8,9,10 and some Linuxes because
329        SO_RCVTIMEO|SO_SNDTIMEO are defined but not implemented */
330     if (setsockopt(s, SOL_SOCKET, $1, (const void *)&tv, sizeof(tv)) == -1)
331         exit(1);
332
333     exit(0);
334 #endif
335 }
336 ]
337 , [ AC_MSG_RESULT([yes]) AC_DEFINE(USE_$1, 1, [Define to use $1 with setsockopt()]) ]
338 , [ AC_MSG_RESULT([no]) ]
339 )
340 ])dnl
341
342 dnl check for SO_RCVTIMEO and SO_SNDTIMEO
343 JK_CHECK_SETSOCKOPT(SO_RCVTIMEO)
344 JK_CHECK_SETSOCKOPT(SO_SNDTIMEO)
345
346 AC_DEFUN([JK_CHECK_SOCKOPT], [
347 AC_MSG_CHECKING(whether to use $1 with socket())
348 AC_TRY_RUN([
349 #include <sys/types.h>
350 #include <sys/socket.h>
351 #include <sys/time.h>
352
353 int main(void)
354 {
355     int s;
356
357 #ifndef $1
358     exit(3);
359 #else
360     if ((s = socket(AF_INET, SOCK_STREAM | $1, 0)) == -1)
361         exit(2);
362
363     exit(0);
364 #endif
365 }
366 ]
367 , [ AC_MSG_RESULT([yes]) AC_DEFINE(USE_$1, 1, [Define to use $1 with socket()]) ]
368 , [ AC_MSG_RESULT([no]) ]
369 )
370 ])dnl
371
372 dnl check for SOCK_CLOEXEC
373 JK_CHECK_SOCKOPT(SOCK_CLOEXEC)
374
375 dnl check for poll.h header
376 AC_CHECK_HEADERS(poll.h)
377 dnl check for poll function
378 AC_CHECK_FUNC(poll, AC_DEFINE(HAVE_POLL,1,[Have poll()]))
379
380 dnl Apache-2.0 needs the os subdirectory to include os.h
381 dnl this include is copy from os/config.m4
382 sinclude(../support/os_apache.m4)
383
384 dnl it is copied from the configure of JServ ;=)
385 dnl and adapted.
386
387 apache_dir_is_src="false"
388 AC_ARG_WITH(apache,
389 [AS_HELP_STRING([--with-apache=DIR],
390 [Build static Apache module. DIR is the pathname
391 to the Apache source directory.])],
392 [
393     if ${TEST} ! -z "$WEBSERVER" ; then
394         AC_MSG_ERROR([Sorry cannot use --with-apxs=${APXS} and --with-apache=${withval} together, please choose one of both])
395     fi
396
397     AC_MSG_CHECKING([for Apache source directory (assume static build)])
398
399     if ${TEST} -n "${withval}" && ${TEST} -d "${withval}" ; then
400         if ${TEST} -d "${withval}/src" ; then
401            # handle the case where people use relative paths to
402            # the apache source directory by pre-pending the current
403            # build directory to the path. there are probably
404            # errors with this if configure is run while in a
405            # different directory than what you are in at the time
406            if ${TEST} -n "`${ECHO} ${withval}|${GREP} \"^\.\.\"`" ; then
407                withval=`pwd`/${withval}
408            fi
409
410            apache_dir=${withval}
411            apache_dir_is_src="true"
412            AC_MSG_RESULT(${apache_dir})
413
414            AC_MSG_CHECKING(for Apache include directory)
415
416            if ${TEST} -d "${withval}/src/include" ; then
417                # read osdir from the existing apache.
418                osdir=`${GREP} '^OSDIR=' ${withval}/src/Makefile.config | ${SED} -e 's:^OSDIR=.*/os:os:'`
419                if ${TEST} -z "${osdir}" ; then
420                    osdir=os/unix
421                fi
422                apache_include="-I${withval}/src/include \
423                    -I${withval}/src/${osdir}"
424                WEBSERVER="apache-1.3"
425                LIB_JK_TYPE=mod_jk.a
426                CFLAGS="${CFLAGS} -DJK_PREFORK"
427                AC_MSG_RESULT([${apache_include}, version 1.3])
428            else
429                AC_MSG_ERROR([Sorry Apache 1.2.x is no longer supported.])
430            fi
431         else
432            if ${TEST} -d "${withval}/include" ; then
433               # osdir for Apache20.
434               WEBSERVER="apache-2.0"
435               apache_dir=${withval}
436               apache_dir_is_src="true"
437               LIB_JK_TYPE=lib_jk.la
438               apache_include="-I${withval}/include -I${withval}/srclib/apr/include -I${withval}/os/${OS_APACHE_DIR} -I${withval}/srclib/apr-util/include"
439               AC_MSG_RESULT(${apache_dir})
440            fi
441         fi
442     fi
443
444     dnl Make sure we have a result.
445     if ${TEST} -z "$WEBSERVER" ; then
446         AC_MSG_ERROR([Directory $apache_dir is not a valid Apache source distribution])
447     fi
448
449 # VT: Now, which one I'm supposed to use? Let's figure it out later
450
451     configure_apache=true
452     configure_src=true
453
454     AC_MSG_RESULT([building connector for \"$WEBSERVER\"])
455 ],
456 [
457     AC_MSG_RESULT(no apache given)
458 ])
459
460 AC_SUBST(apache_include)
461 APACHE_DIR=${apache_dir}
462 AC_SUBST(APACHE_DIR)
463
464 AC_ARG_ENABLE(netscape,
465 [AS_HELP_STRING([--enable-netscape=DIR],[Build Netscape/iPlanet/SunONE nsapi redirector plugin])],
466 [
467     if ${TEST} ! -z "$WEBSERVER" ; then
468         AC_MSG_ERROR([Sorry cannot use --with-apxs=${APXS} or --with-apache=${withval} with --with-netscape, please choose one or the other.])
469     fi
470
471     WEBSERVER="netscape"
472
473     AC_MSG_RESULT([building connector for \"$WEBSERVER\"])
474 ],
475 [
476     AC_MSG_RESULT(no netscape given)
477 ])
478
479 dnl Check for enable-jni
480 JK_JNI_WORKER=""
481 AC_ARG_ENABLE(jni,
482 [AS_HELP_STRING([--enable-jni],[DEPRECATED: Build jni_connect.so and enable jni_worker])],
483 [
484     AC_MSG_RESULT(jni enable (need JDK))
485     CFLAGS="${CFLAGS} -DHAVE_JNI"
486     JK_JNI_WORKER="\${JK}jk_jni_worker\${OEXT}"
487     WARN_JNI=1
488 ])dnl
489 AC_SUBST(JK_JNI_WORKER)
490
491 dnl CFLAGS for EAPI mod_ssl (Apache 1.3)
492 dnl it also allows the CFLAGS environment variable.
493 CFLAGS="${CFLAGS}"
494 AC_ARG_ENABLE(EAPI,
495 [AS_HELP_STRING([--enable-EAPI],[Enable EAPI support (mod_ssl, Apache 1.3)])],
496 [
497 case "${enableval}" in
498     y | Y | YES | yes | TRUE | true )
499         CFLAGS="${CFLAGS} -DEAPI"
500         AC_MSG_RESULT([...Enabling EAPI Support...])
501         ;;
502 esac
503 ])
504 AC_SUBST(CFLAGS)
505
506 dnl CFLAGS for maintainer mode
507 dnl it also allows the CFLAGS environment variable.
508 CFLAGS="${CFLAGS}"
509 AC_ARG_ENABLE(maintainer-mode,
510 [AS_HELP_STRING([--enable-maintainer-mode],[Turn on debugging and compile time warnings])],
511 [
512 case "${enableval}" in
513     y | Y | YES | yes | TRUE | true )
514         CFLAGS="${CFLAGS} -DDEBUG -Wall"
515         AC_MSG_RESULT([...Enabling Maintainer mode...])
516         ;;
517 esac
518 ])
519 AC_SUBST(CFLAGS)
520
521 dnl CFLAGS for prefork mode
522 dnl it also allows the CFLAGS environment variable.
523 CFLAGS="${CFLAGS}"
524 AC_ARG_ENABLE(prefork,
525 [AS_HELP_STRING([--enable-prefork],[Turn on prefork web server mode (single-threaded)])],
526 [
527 case "${enableval}" in
528     y | Y | YES | yes | TRUE | true )
529         CFLAGS="${CFLAGS} -DJK_PREFORK"
530         AC_MSG_RESULT([...Enabling Prefork mode...])
531         ;;
532 esac
533 ])
534 AC_SUBST(CFLAGS)
535
536 dnl CFLAGS for stripping TRACE logs
537 dnl it also allows the CFLAGS environment variable.
538 CFLAGS="${CFLAGS}"
539 AC_ARG_ENABLE(trace,
540 [AS_HELP_STRING([--disable-trace],[Exclude trace log code from compilation])],
541 [
542 case "${enableval}" in
543     no )
544         CFLAGS="${CFLAGS} -DJK_PRODUCTION"
545         AC_MSG_RESULT([...Exclude trace log code...])
546         ;;
547 esac
548 ])
549 AC_SUBST(CFLAGS)
550
551 dnl CFLAGS for building against recent httpd but without
552 dnl using httpd API functions, which didn't exist in the first
553 dnl production releases. This ensures, that the resulting
554 dnl module binary is compatible with older httpd releases.
555 dnl Until now only relevant for httpd 2.2.x with x >= 4.
556 CFLAGS="${CFLAGS}"
557 AC_ARG_ENABLE(api-compatibility,
558 [AS_HELP_STRING([--enable-api-compatibility],
559 [Only use httpd API functions available in all production releases.
560 This improves binary compatibility of module builds with httpd releases
561 older than the release against we build (only between minor versions).])],
562 [
563 case "${enableval}" in
564     y | Y | YES | yes | TRUE | true )
565         CFLAGS="${CFLAGS} -DAPI_COMPATIBILITY"
566         AC_MSG_RESULT([...Only using compatible httpd API...])
567         ;;
568 esac
569 ])
570 AC_SUBST(CFLAGS)
571
572 dnl CFLAGS for shared memory lock mode
573 dnl it also allows the CFLAGS environment variable.
574 CFLAGS="${CFLAGS}"
575 AC_ARG_ENABLE(flock,
576 [AS_HELP_STRING([--enable-flock],[Turn on flock for shared locking if present])],
577 [
578 case "${enableval}" in
579     y | Y | YES | yes | TRUE | true )
580         CFLAGS="${CFLAGS} -DJK_USE_FLOCK"
581         AC_MSG_RESULT([...Enabling flock() shared memory locking...])
582         ;;
583 esac
584 ])
585 AC_SUBST(CFLAGS)
586
587 dnl the APXSCFLAGS is given by apxs to the C compiler
588 if ${TEST} -n "${CFLAGS}" ; then
589     APXSCFLAGS="${APXSCFLAGS} ${CFLAGS}"
590 fi
591 AC_SUBST(APXSCFLAGS)
592 AC_SUBST(APXSCPPFLAGS)
593
594 dnl the APXSLDFLAGS is given to the linker (for APRVARS).
595 if ${TEST} -n "${LDFLAGS}" ; then
596     APXSLDFLAGS="${APXSLDFLAGS} ${LDFLAGS}"
597 fi
598
599 dnl Prefix all LDFLAGS with "-Wl,",
600 dnl because we pass them to libtool
601 JK_PREFIX_IF_MISSING(APXSLDFLAGS, [-Wl,])
602
603 AC_SUBST(APXSLDFLAGS)
604
605 if ${TEST} -n "${JK_JNI_WORKER}" ; then
606
607 WEBSERVER="jni ${WEBSERVER}"
608
609 dnl Find the JDK
610 dnl Results go in JAVA_HOME
611 dnl Also sets JAVA_PLATFORM to 1 for 1.1 and to 2 for 1.2
612
613 AC_MSG_CHECKING([for JDK location (please wait)])
614
615 dnl The order is: --with-java-home first, environment second, guessed value third.
616
617 dnl This is a safe default. Could screw up on the security features, but
618 dnl oh well, this is what --with-java2 is for.
619
620 if ${TEST} -n "${JAVA_HOME}" ; then
621     JAVA_HOME_ENV="${JAVA_HOME}"
622 else
623     JAVA_HOME_ENV=""
624 fi
625 JAVA_HOME=""
626 JAVA_PLATFORM="1"
627
628 AC_ARG_WITH(java-home,
629 [AS_HELP_STRING([--with-java-home=DIR],[DEPRECATED: Where is your JDK root directory])],
630 [
631
632     # This stuff works if the command line parameter --with-java-home was
633     # specified, so it takes priority rightfully.
634
635     JAVA_HOME=${withval}
636
637     if ${TEST} ! -d "${JAVA_HOME}" ; then
638         AC_MSG_ERROR(Not a directory: ${JAVA_HOME})
639     fi
640
641     AC_MSG_RESULT(${JAVA_HOME})
642
643 ],
644 [
645     # This works if the parameter was NOT specified, so it's a good time
646     # to see what the enviroment says.
647
648     # Since Sun uses JAVA_HOME a lot, we check it first and ignore the
649     # JAVA_HOME, otherwise just use whatever JAVA_HOME was specified.
650
651     if ${TEST} -n "${JAVA_HOME_ENV}" ; then
652
653         JAVA_HOME=${JAVA_HOME_ENV}
654         AC_MSG_RESULT(${JAVA_HOME_ENV} from environment)
655     fi
656 ])
657
658 if ${TEST} -z "${JAVA_HOME}" ; then
659
660     # Oh well, nobody set neither JAVA_HOME nor JAVA_HOME, have to guess
661
662     # The following code is based on the code submitted by Henner Zeller
663     # for ${srcdir}/src/scripts/package/rpm/ApacheJServ.spec
664
665     # Two variables will be set as a result:
666     #
667     # JAVA_HOME
668     # JAVA_PLATFORM
669     AC_MSG_CHECKING([Try to guess JDK location])
670
671
672     for JAVA_PREFIX in \
673         /usr/local \
674         /usr/local/lib \
675         /usr \
676         /usr/lib \
677         /opt  \
678         /
679     do
680         for JAVA_PLATFORM in 3 2 1 ;
681         do
682
683             for subversion in .9 .8 .7 .6 .5 .4 .3 .2 .1 "" ;
684             do
685                 for VARIANT in IBMJava2- java java- jdk jdk-;
686                 do
687                     GUESS="${JAVA_PREFIX}/${VARIANT}1.${JAVA_PLATFORM}${subversion}"
688 dnl                    AC_MSG_CHECKING([${GUESS}])
689                     if ${TEST} -d "${GUESS}/bin" \
690                     && ${TEST} -d "${GUESS}/include" ; then
691
692                         JAVA_HOME="${GUESS}"
693                         AC_MSG_RESULT([${GUESS}])
694                         break
695                     fi
696
697                 done
698
699                 if ${TEST} -n "${JAVA_HOME}" ; then
700                     break;
701                 fi
702
703             done
704
705             if ${TEST} -n "${JAVA_HOME}" ; then
706                 break;
707             fi
708
709         done
710
711         if ${TEST} -n "${JAVA_HOME}" ; then
712             break;
713         fi
714
715     done
716
717     if ${TEST} -n "${JAVA_HOME}" ; then
718
719         dnl Just to have the messages looking uniformly
720
721         AC_MSG_CHECKING(Java platform)
722         AC_MSG_RESULT([guess ${JAVA_PLATFORM}])
723     fi
724
725
726 else
727
728     AC_MSG_CHECKING(Java platform)
729
730     AC_ARG_WITH(java-platform,
731     [AS_HELP_STRING([--with-java-platform=VAL],
732     [DEPRECATED: Force the Java platform
733      (value is 1 for 1.1.x or 2 for 1.2.x or greater)])],
734     [
735         dnl This requires a bit of tweaking to be handled properly, but
736         dnl the default is good enough
737
738         JAVA_PLATFORM="2"
739     ])
740
741     AC_MSG_RESULT(forced Java ${JAVA_PLATFORM})
742
743 fi
744 dnl end of JServ ;=)
745
746 dnl test if --enable-jni give but not valid JAVA_HOME
747 if ${TEST} -z "${JAVA_HOME}" ; then
748     AC_MSG_ERROR([JDK home not found, please specify one with --with-java-home option (run ./configure --help for more options)])
749 fi
750
751 dnl guess OS = OS_TYPE for jni_md.h
752 OS=""
753 AC_ARG_WITH(os-type,
754 [AS_HELP_STRING([--with-os-type=SUBDIR],[DEPRECATED: Where is your JDK os-type subdirectory])],
755 [
756     OS=${withval}
757
758     if ${TEST} ! -d "${JAVA_HOME}/${OS}" ; then
759         AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${OS})
760     fi
761 ],
762 [
763     AC_MSG_CHECKING(os_type directory)
764     if ${TEST} -f ${JAVA_HOME}/include/jni_md.h; then
765         OS=""
766     else
767         for f in ${JAVA_HOME}/include/*/jni_md.h; do
768             if ${TEST} -f $f; then
769                 OS=`dirname ${f}`
770                 OS=`basename ${OS}`
771                 echo " ${OS}"
772             fi
773         done
774         if ${TEST} -z "${OS}"; then
775             AC_MSG_RESULT(Cannot find jni_md.h in ${JAVA_HOME}/${OS})
776             AC_MSG_ERROR(You should retry --with-os-type=SUBDIR)
777         fi
778     fi
779 ])
780 fi
781 AC_SUBST(JAVA_HOME)
782 AC_SUBST(OS)
783
784
785 dnl Check that  a WEBSERVER has been given
786 if ${TEST} -z "$WEBSERVER" ; then
787     AC_MSG_ERROR(Cannot find the WebServer)
788 fi
789
790 dnl Add common to subdir list
791 WEBSERVER="common ${WEBSERVER}"
792
793 AC_SUBST(WEBSERVER)
794
795 AM_CONDITIONAL(MAKE_DYNAMIC_APACHE, ${TEST} "${apache_dir_is_src}" = "false")
796
797 if ${TEST} "${apache_dir_is_src}" = "false" ; then
798     dnl normal apxs handling
799     APACHE20_OEXT=.c
800     LIB_JK_TYPE=mod_jk.so
801     INSTALL_TYPE=install_dynamic
802 else
803     dnl install static library in apache sources.
804     APACHE20_OEXT=.lo
805     INSTALL_TYPE=install_static
806 fi
807 AC_SUBST(APACHE20_OEXT)
808 AC_SUBST(LIB_JK_TYPE)
809 AC_SUBST(INSTALL_TYPE)
810
811 dnl automake needs the path it does not work with $WEBSERVER
812 dnl that why useless Makefiles are build.
813 AC_OUTPUT([
814     Makefile
815     apache-1.3/Makefile
816     apache-1.3/Makefile.apxs
817     apache-2.0/Makefile
818     apache-2.0/Makefile.apxs
819     common/Makefile
820     common/list.mk
821     common/jk_types.h
822     jni/Makefile
823 ])
824
825 if ${TEST} -n "${WARN_JNI}" ; then
826     AC_MSG_WARN([===========================================])
827     AC_MSG_WARN([You have used one of the following options:])
828     AC_MSG_WARN([    --enable-jni])
829     AC_MSG_WARN([    --with-java-home])
830     AC_MSG_WARN([    --with-java-platform])
831     AC_MSG_WARN([    --with-os-type])
832     AC_MSG_WARN([These options are only necessary if])
833     AC_MSG_WARN([you want to use a worker of type jni.])
834     AC_MSG_WARN([These workers have been deprecated.])
835     AC_MSG_WARN([They do not work and will be removed from])
836     AC_MSG_WARN([a future release])
837     AC_MSG_WARN([===========================================])
838 fi
839
840 if ${TEST} -n "${WARN_CC}" ; then
841     AC_MSG_WARN([===========================================])
842     AC_MSG_WARN([Using CC from environment:])
843     AC_MSG_WARN([    CC="$CC"])
844     AC_MSG_WARN([instead of CC from apxs:])
845     AC_MSG_WARN([    CC="$APXSCC"])
846     AC_MSG_WARN([If "make" throws an error of the form])
847     AC_MSG_WARN([    "libtool: compile: unable to infer tagged configuration"])
848     AC_MSG_WARN([    "libtool: compile: specify a tag with `--tag'"])
849     AC_MSG_WARN([try running configure without setting CC,])
850     AC_MSG_WARN([or at least CC should start with "$APXSCC"])
851     AC_MSG_WARN([===========================================])
852 fi