1#
2# Licensed to the Apache Software Foundation (ASF) under one or more
3# contributor license agreements.  See the NOTICE file distributed with
4# this work for additional information regarding copyright ownership.
5# The ASF licenses this file to You under the Apache License, Version 2.0
6# (the "License"); you may not use this file except in compliance with
7# the License.  You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18dnl
19dnl Process this file with autoconf to produce a configure script
20dnl
21
22AC_PREREQ(2.50)
23AC_INIT(configure.in)
24
25AC_CONFIG_AUX_DIR(build)
26
27sinclude(build/apr_common.m4)
28sinclude(build/tcnative.m4)
29sinclude(build/find_apr.m4)
30
31dnl Generate ./config.nice for reproducing runs of configure
32dnl
33APR_CONFIG_NICE(config.nice)
34
35dnl # Some initial steps for configuration.  We setup the default directory
36dnl # and which files are to be configured.
37
38dnl Absolute source/build directory
39abs_srcdir=`(cd $srcdir && pwd)`
40abs_builddir=`pwd`
41
42if test "$abs_builddir" != "$abs_srcdir"; then
43  USE_VPATH=1
44  TCN_CONFIG_LOCATION=build
45else
46  TCN_CONFIG_LOCATION=source
47fi
48
49AC_SUBST(TCN_CONFIG_LOCATION)
50AC_CANONICAL_SYSTEM
51AC_PROG_INSTALL
52
53dnl
54dnl compute the top directory of the build
55dnl note: this is needed for LIBTOOL and exporting the bundled Expat
56dnl
57top_builddir="$abs_builddir"
58AC_SUBST(top_builddir)
59AC_SUBST(abs_srcdir)
60AC_SUBST(abs_builddir)
61
62dnl Initialize mkdir -p functionality.
63APR_MKDIR_P_CHECK($abs_srcdir/build/mkdir.sh)
64
65dnl get our version information
66get_version="$abs_srcdir/build/get-version.sh"
67version_hdr="$abs_srcdir/include/tcn_version.h"
68TCNATIVE_MAJOR_VERSION="`$get_version major $version_hdr TCN`"
69TCNATIVE_DOTTED_VERSION="`$get_version all $version_hdr TCN`"
70TCNATIVE_LIBTOOL_VERSION="`$get_version libtool $version_hdr TCN`"
71
72AC_SUBST(TCNATIVE_DOTTED_VERSION)
73AC_SUBST(TCNATIVE_MAJOR_VERSION)
74AC_SUBST(TCNATIVE_LIBTOOL_VERSION)
75
76echo "Tomcat Native Version: ${TCNATIVE_DOTTED_VERSION}"
77
78dnl Enable the layout handling code, then reparse the prefix-style
79dnl arguments due to autoconf being a PITA.
80APR_ENABLE_LAYOUT(tcnative)
81APR_PARSE_ARGUMENTS
82
83dnl
84dnl set up the compilation flags and stuff
85dnl
86
87TCNATIVE_INCLUDES=""
88TCNATIVE_PRIV_INCLUDES="-I$srcdir/include"
89
90dnl
91dnl Find the APR includes directory and (possibly) the source (base) dir.
92dnl
93TCN_FIND_APR
94
95dnl
96dnl even though we use apr_rules.mk for building apr-util, we need
97dnl to grab CC and CPP ahead of time so that apr-util config tests
98dnl use the same compiler as APR; we need the same compiler options
99dnl and feature test macros as well
100dnl
101APR_SETIFNULL(CC, `$apr_config --cc`)
102APR_SETIFNULL(CPP, `$apr_config --cpp`)
103
104AC_PROG_INSTALL
105
106dnl
107dnl  Find the JVM related information
108dnl
109NEED_JNI_MD=yes
110TCN_FIND_JAVA
111
112dnl MAC OS X does not used include but Headers
113if test -d ${JAVA_HOME}/Headers; then
114  JAVA_INC=Headers
115else
116  JAVA_INC=include
117fi
118APR_ADDTO(TCNATIVE_PRIV_INCLUDES,[-I$JAVA_HOME/$JAVA_INC])
119
120dnl sableVM does not have/need $JAVA_OS/jni_md.h
121if test "$NEED_JNI_MD" = "yes"; then
122  TCN_FIND_JDK_OS
123  if test -z "${JAVA_OS}"; then
124    AC_MSG_RESULT([jni_md.h found in $JAVA_HOME/$JAVA_INC])
125  else
126    APR_ADDTO(TCNATIVE_PRIV_INCLUDES,[-I$JAVA_HOME/$JAVA_INC/$JAVA_OS])
127  fi
128fi
129
130AC_SUBST(JAVA_HOME)
131AC_SUBST(JAVA_PLATFORM)
132AC_SUBST(JAVA_OS)
133
134
135dnl
136dnl Detect openssl toolkit installation
137dnl
138
139use_openssl=true;
140
141AC_ARG_ENABLE(openssl,
142[AS_HELP_STRING([--disable-openssl],[avoid using OpenSSL toolkit])],
143[
144  case "${enableval}" in
145    no )
146       use_openssl=false;
147       AC_MSG_RESULT([Disabling SSL support...])
148       ;;
149  esac
150])
151
152AC_ARG_ENABLE(insecure-export-ciphers,
153[AS_HELP_STRING([--enable-insecure-export-ciphers],[allow including insecure export and null ciphers in the cipher string (default is disabled=not allowed)])],
154[
155  case "${enableval}" in
156    yes )
157       APR_ADDTO(CFLAGS, [-DHAVE_EXPORT_CIPHERS])
158       AC_MSG_WARN([Enabling insecure export and null cipher support])
159       ;;
160  esac
161])
162
163if $use_openssl ; then
164  TCN_CHECK_SSL_TOOLKIT
165fi
166
167so_ext=$APR_SO_EXT
168lib_target=$APR_LIB_TARGET
169AC_SUBST(so_ext)
170AC_SUBST(lib_target)
171
172TCNATIVE_LIBNAME="tcnative${libsuffix}"
173AC_SUBST(TCNATIVE_LIBNAME)
174
175EXTRA_OS_LINK=""
176host_alias=`uname -s`
177case "$host_alias" in
178    dnl ### BeOS requires that ALL symbols resolve at LINK time!
179    dnl ###
180    dnl ### So, if we're building on BeOS then we need to add in the
181    dnl ### apr and expat libraries to the build or it'll die a truly horrible
182    dnl ### death. We now use the apr-config tool to determine the correct
183    dnl ### library to link against :)
184*AIX*|*Darwin*|*BeOS*)
185    dnl need such stuff as -liconv to be specified when building libaprutil.la
186    EXTRA_OS_LINK='$(TCNATIVE_LDFLAGS) $(TCNATIVE_LIBS)'
187    ;;
188*)
189    ;;
190esac
191
192AC_SUBST(EXTRA_OS_LINK)
193
194dnl CFLAGS for maintainer mode
195dnl it also allows the CFLAGS environment variable.
196CFLAGS="${CFLAGS}"
197AC_ARG_ENABLE(maintainer-mode,
198[AS_HELP_STRING([--enable-maintainer-mode],[Turn on debugging and compile time warnings])],
199[
200  case "${enableval}" in
201    yes )
202       if test "$GCC" = "yes"; then
203         CFLAGS="${CFLAGS} -DDEBUG -Wall"
204       else
205         CFLAGS="${CFLAGS} -DDEBUG"
206       fi
207       AC_MSG_RESULT([...Enabling Maintainer mode...])
208       ;;
209  esac
210])
211
212dnl
213dnl Prep all the flags and stuff for compilation and export to other builds
214dnl
215APR_ADDTO(TCNATIVE_LIBS, [$LIBS])
216APR_ADDTO(TCNATIVE_LIBS, [$APR_LIBTOOL_LIBS])
217APR_ADDTO(TCNATIVE_LDFLAGS, [$LDFLAGS])
218
219# Link libkstat for Solaris
220case $host in
221    *-solaris2*)
222        APR_ADDTO(TCNATIVE_LIBS, -lkstat)
223        ;;
224    *linux*)
225        APR_ADDTO(CFLAGS, -DTCNATIVE_LINUX)
226        ;;
227    *)
228        ;;
229esac
230
231TCN_FIND_APR_FEATURE([apr_pollset_wakeup],[POLLSET_WAKEUP])
232
233AC_SUBST(TCNATIVE_EXPORT_LIBS)
234AC_SUBST(TCNATIVE_PRIV_INCLUDES)
235AC_SUBST(TCNATIVE_INCLUDES)
236AC_SUBST(TCNATIVE_LDFLAGS)
237AC_SUBST(TCNATIVE_LIBS)
238AC_SUBST(CFLAGS)
239AC_SUBST(CPPFLAGS)
240
241dnl copy apr's rules.mk into our build directory.
242if test ! -d ./build; then
243   $mkdir_p build
244fi
245cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk
246
247
248dnl
249dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
250dnl
251case "$host_alias" in
252*bsdi* | BSD/OS)
253    # Check whether they've installed GNU make
254    if make --version > /dev/null 2>&1; then
255        INCLUDE_RULES="include $abs_builddir/build/rules.mk"
256        INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
257    else
258        INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\""
259        INCLUDE_OUTPUTS=".include \"$abs_srcdir/build-outputs.mk\""
260    fi
261    ;;
262*)
263    INCLUDE_RULES="include $abs_builddir/build/rules.mk"
264    INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
265    ;;
266esac
267
268AC_SUBST(INCLUDE_RULES)
269AC_SUBST(INCLUDE_OUTPUTS)
270
271if test -d $srcdir/test; then
272    test_Makefile="test/Makefile"
273fi
274
275dnl
276dnl everything is done.
277MAKEFILES="Makefile"
278AC_OUTPUT([
279    $MAKEFILES
280	],[
281TCNATIVE_MAJOR_VERSION=$TCNATIVE_MAJOR_VERSION
282])
283