dnl =========================================================================
dnl
dnl The Apache Software License, Version 1.1
dnl
dnl Copyright (c) 1999-2001 The Apache Software Foundation.
dnl All rights reserved.
dnl
dnl =========================================================================
dnl
dnl Redistribution and use in source and binary forms, with or without modi-
dnl fication, are permitted provided that the following conditions are met:
dnl
dnl 1. Redistributions of source code must retain the above copyright notice
dnl notice, this list of conditions and the following disclaimer.
dnl
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl 3. The end-user documentation included with the redistribution, if any,
dnl must include the following acknowlegement:
dnl
dnl "This product includes software developed by the Apache Software
dnl Foundation ."
dnl
dnl Alternately, this acknowlegement may appear in the software itself, if
dnl and wherever such third-party acknowlegements normally appear.
dnl
dnl 4. The names "The Jakarta Project", "Apache WebApp Module", and "Apache
dnl Software Foundation" must not be used to endorse or promote products
dnl derived from this software without prior written permission. For
dnl written permission, please contact .
dnl
dnl 5. Products derived from this software may not be called "Apache" nor may
dnl "Apache" appear in their names without prior written permission of the
dnl Apache Software Foundation.
dnl
dnl THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES
dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
dnl AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
dnl THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY
dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
dnl STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
dnl ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dnl POSSIBILITY OF SUCH DAMAGE.
dnl
dnl =========================================================================
dnl
dnl This software consists of voluntary contributions made by many indivi-
dnl duals on behalf of the Apache Software Foundation. For more information
dnl on the Apache Software Foundation, please see .
dnl
dnl =========================================================================
dnl --------------------------------------------------------------------------
dnl Author Pier Fumagalli
dnl Version $Id$
dnl
dnl NOTE: close all functions with ]) on the same line otherwise M4 will spit
dnl out the last argument of the function with an extra newline.
dnl --------------------------------------------------------------------------
sinclude(./support/wa_util.m4)
sinclude(./support/wa_exec.m4)
sinclude(./support/wa_version.m4)
sinclude(./support/wa_apr.m4)
sinclude(./support/wa_apxs.m4)
sinclude(./support/wa_ant.m4)
sinclude(./support/wa_perl.m4)
dnl --------------------------------------------------------------------------
dnl Initialize GNU Autoconf (note, this requires autoconf vers. >= 2.52)
dnl --------------------------------------------------------------------------
AC_INIT([WebApp Module],[""],[http://nagoya.apache.org/bugzilla])
AC_CONFIG_SRCDIR([configure.in])
AC_CONFIG_AUX_DIR([support])
dnl --------------------------------------------------------------------------
dnl Get rid of all that "--prefix" ... "--xxxdir" in the help message
dnl --------------------------------------------------------------------------
WA_HEADER([Configuring AC_PACKAGE_STRING])
WA_HELP()
dnl --------------------------------------------------------------------------
dnl What are we compiling for
dnl --------------------------------------------------------------------------
AC_CANONICAL_HOST()
dnl --------------------------------------------------------------------------
dnl Directories locations are defined here
dnl --------------------------------------------------------------------------
WA_VARIABLE([APR_DIR])
WA_VARIABLE([APR_LIB])
WA_VARIABLE([APR_LIBNAME])
WA_VARIABLE([SRC_DIR])
WA_VARIABLE([TGT_DIR])
WA_VARIABLE([TC4_DIR])
WA_PATH_DIR([SRC_DIR],[${srcdir}],[sources])
WA_PATH_DIR([TGT_DIR],[.],[build])
dnl --------------------------------------------------------------------------
dnl Define the variables we need in Makedefs.in
dnl --------------------------------------------------------------------------
WA_VARIABLE([CC])
WA_VARIABLE([CPP])
WA_VARIABLE([SHELL])
WA_VARIABLE([LIBTOOL])
WA_VARIABLE([APXS])
WA_VARIABLE([ANT])
WA_VARIABLE([PERL])
WA_VARIABLE([CPPFLAGS])
WA_VARIABLE([CFLAGS])
WA_VARIABLE([LDFLAGS])
WA_VARIABLE([INCLUDES])
INCLUDES="-I. -I${SRC_DIR}/include"
WA_VARIABLE([EXTRA_CFLAGS])
WA_VARIABLE([EXTRA_CPPFLAGS])
WA_VARIABLE([EXTRA_LDFLAGS])
WA_VARIABLE([EXTRA_INCLUDES])
WA_VARIABLE([EXTRA_BUILD])
WA_VARIABLE([EXTRA_CLEAN])
WA_VARIABLE([MODULE])
WA_VARIABLE([APACHE_VERSION])
WA_VARIABLE([WEBAPP_VERSION])
WA_VARIABLE([HOST])
WA_VARIABLE([DATE])
HOST="${host}"
DATE="`date`"
WA_VARIABLE([ANT_TARGETS])
dnl --------------------------------------------------------------------------
dnl Figure out if we have APXS, where it's located, and what version it is
dnl --------------------------------------------------------------------------
WA_HEADER([Checking Apache APXS])
WA_APXS([APXS])
WA_APXS_CHECK([APXS_VERSION],[${APXS}])
dnl --------------------------------------------------------------------------
dnl Decide based on what version of APXS we found
dnl --------------------------------------------------------------------------
if test "${APXS_VERSION}" = "1.3" ; then
dnl ----------------------------------------------------------------------
dnl APXS version 1.3, meaning Apache 1.3. We _require_ APR sources
dnl ----------------------------------------------------------------------
WA_HEADER([Apache 1.3 module compilation (APR checks)])
dnl ----------------------------------------------------------------------
dnl Check where the APR sources are and issue "configure"
dnl ----------------------------------------------------------------------
WA_APR([APR_DIR])
tempret="0"
tempval="--enable-static --disable-shared --disable-threads"
tempval="${tempval} --libdir=${TGT_DIR}/objects"
WA_EXEC(
[tempret],
[./configure ${tempval}],
[apr],
[${APR_DIR}])
AC_MSG_CHECKING([for proper command execution])
if test "${tempret}" = "0" ; then
AC_MSG_RESULT([ok (${tempret})])
else
WA_ERROR([command returned with ${tempret}])
fi
unset tempret
unset tempval
dnl ----------------------------------------------------------------------
dnl Retrieve APR variables
dnl ----------------------------------------------------------------------
WA_APR_GET([CC],[${APR_DIR}],[CC])
WA_APR_GET([CPP],[${APR_DIR}],[CPP])
WA_APR_GET([SHELL],[${APR_DIR}],[SHELL])
WA_APR_GET([CFLAGS],[${APR_DIR}],[CFLAGS])
WA_APR_GET([CPPFLAGS],[${APR_DIR}],[CPPFLAGS])
WA_APR_GET([LDFLAGS],[${APR_DIR}],[LDFLAGS])
WA_APR_GET([LDFLAGS],[${APR_DIR}],[LIBS])
WA_APR_GET([CPPFLAGS],[${APR_DIR}],[EXTRA_INCLUDES])
WA_APR_LIB([APR_LIB],[${APR_DIR}])
WA_APR_LIBNAME([APR_LIBNAME],[${APR_DIR}])
AC_MSG_CHECKING([for apr headers])
WA_APPEND([INCLUDES],[-I${APR_DIR}/include])
AC_MSG_RESULT([-I${APR_DIR}/include])
AC_MSG_CHECKING([for apr libtool])
LIBTOOL="${SHELL} ${APR_DIR}/libtool --silent"
AC_MSG_RESULT([${LIBTOOL}])
dnl ----------------------------------------------------------------------
dnl Done with APR, let's see what APXS says
dnl ----------------------------------------------------------------------
WA_HEADER([Apache 1.3 module compilation (APXS checks)])
dnl ----------------------------------------------------------------------
dnl Do a check on the C compiler to see if apxs reports the same one
dnl ----------------------------------------------------------------------
WA_APXS_GET([tempval],[${APXS}],[CC])
AC_MSG_CHECKING([for compiler coherency])
if test "${tempval}" != "${CC}" ; then
AC_MSG_RESULT([error])
AC_MSG_RESULT([compiler discovered by apr: ${CC}])
AC_MSG_RESULT([compiler used by apache apxs: ${tempval}])
AC_MSG_ERROR([the apache apxs and apr compilers must be the same])
exit 1
fi
AC_MSG_RESULT([ok (${CC})])
unset tempval
dnl ----------------------------------------------------------------------
dnl Apache 1.3 configuration complete
dnl ----------------------------------------------------------------------
MODULE="apache-1.3"
WA_APPEND([EXTRA_BUILD],[apr-build])
WA_APPEND([EXTRA_CLEAN],[apr-clean])
WA_APXS_GET([tempval],[${APXS}],[INCLUDEDIR])
WA_PATH_DIR([tempdir],[${tempval}],[apache 1.3 headers])
WA_APPEND([INCLUDES],[-I${tempdir}])
unset tempval
unset tempdir
WA_APXS_GET([EXTRA_CFLAGS],[${APXS}],[CFLAGS])
WA_APXS_GET([EXTRA_CFLAGS],[${APXS}],[CFLAGS_SHLIB])
WA_APXS_GET([EXTRA_LDFLAGS],[${APXS}],[LIBS_SHLIB])
WA_APXS_GET([EXTRA_LDFLAGS],[${APXS}],[LDFLAGS_SHLIB])
else
dnl ----------------------------------------------------------------------
dnl APXS version 2.0, meaning Apache 2.0. We use APR from there
dnl ----------------------------------------------------------------------
WA_HEADER([Apache 2.0 module])
WA_APXS_GET([CC],[${APXS}],[CC])
WA_APXS_GET([CPP],[${APXS}],[CPP])
WA_APXS_GET([SHELL],[${APXS}],[SHELL])
WA_APXS_GET([LIBTOOL],[${APXS}],[LIBTOOL])
WA_APXS_GET([CPPFLAGS],[${APXS}],[CPPFLAGS])
WA_APXS_GET([CPPFLAGS],[${APXS}],[NOTEST_CPPFLAGS])
WA_APXS_GET([CPPFLAGS],[${APXS}],[EXTRA_CPPFLAGS])
WA_APXS_GET([LDFLAGS],[${APXS}],[LDFLAGS])
WA_APXS_GET([LDFLAGS],[${APXS}],[NOTEST_LDFLAGS])
WA_APXS_GET([LDFLAGS],[${APXS}],[EXTRA_LDFLAGS])
WA_APXS_GET([CFLAGS],[${APXS}],[CFLAGS])
WA_APXS_GET([CFLAGS],[${APXS}],[NOTEST_CFLAGS])
WA_APXS_GET([CFLAGS],[${APXS}],[EXTRA_CFLAGS])
WA_APXS_GET([tempval],[${APXS}],[INCLUDEDIR])
WA_PATH_DIR([tempdir],[${tempval}],[apache 2.0 headers])
WA_APPEND([INCLUDES],[-I${tempdir}])
unset tempval
unset tempdir
MODULE="apache-2.0"
fi
dnl --------------------------------------------------------------------------
dnl Retrieve Apache and WebApp version
dnl --------------------------------------------------------------------------
WA_HEADER([Checking component versions])
WA_APXS_SERVER([APACHE_VERSION],[${APXS}])
WA_VERSION([WEBAPP_VERSION],[${CC}])
dnl --------------------------------------------------------------------------
dnl Detect another couple of binaries we _might_ require for compilation
dnl --------------------------------------------------------------------------
WA_HEADER([Checking optional binaries])
WA_PERL([PERL])
WA_ANT([ANT])
dnl --------------------------------------------------------------------------
dnl Optional targets
dnl --------------------------------------------------------------------------
WA_HEADER([Optional targets])
dnl --------------------------------------------------------------------------
dnl Do we want to build also tomcat-webapp.jar or not?
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for java compilation])
AC_ARG_ENABLE(
[java],
[ --enable-java[[=tc4dir]] compile java code (tc4dir must be specifed)],
[
case "${enableval}" in
""|"yes"|"YES"|"true"|"TRUE")
WA_ERROR([path of Tomcat 4.0 binary distribution unspecified])
;;
"no"|"NO"|"false"|"FALSE")
AC_MSG_RESULT([no])
;;
*)
dnl --------------------------------------------------------------
dnl We were given something as a parameter, we need to make sure
dnl that what we were given is the path to the Tomcat 4.0 distrib.
dnl --------------------------------------------------------------
if test -z "${ANT}" ; then
WA_ERROR([java compilation desired but ANT not found])
fi
AC_MSG_RESULT([yes])
WA_PATH_DIR([TC4_DIR],[${enableval}],[tomcat 4.0 distribution])
AC_MSG_CHECKING([for proper tomcat layout])
if test ! -f "${TC4_DIR}/server/lib/catalina.jar" ; then
WA_ERROR([cannot find "${TC4_DIR}/server/lib/catalina.jar"])
fi
if test ! -f "${TC4_DIR}/common/lib/servlet.jar" ; then
WA_ERROR([cannot find "${TC4_DIR}/common/lib/servlet.jar"])
fi
dnl --------------------------------------------------------------
dnl We found what we were looking for, make sure ANT gets called
dnl with the "compile" target
dnl --------------------------------------------------------------
WA_APPEND([ANT_TARGETS],[compile])
WA_APPEND([EXTRA_BUILD],[ant-build])
WA_APPEND([EXTRA_CLEAN],[ant-clean])
AC_MSG_RESULT([ok])
;;
esac
],[
AC_MSG_RESULT([no])
])
dnl --------------------------------------------------------------------------
dnl Do we want to build also the documentation from XML?
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for documentation generation])
AC_ARG_ENABLE(
[docs],
[ --enable-docs generate documentation (requires ANT)],
[
case "${enableval}" in
""|"yes"|"YES"|"true"|"TRUE")
if test -z "${ANT}" ; then
WA_ERROR([docs generation desired but ANT not found])
fi
AC_MSG_RESULT([yes])
dnl --------------------------------------------------------------
dnl We were specifically requested to compile docs, and we found
dnl ANT, we need to call it with the "docs" target
dnl --------------------------------------------------------------
WA_APPEND([ANT_TARGETS],[docs])
WA_APPEND([EXTRA_BUILD],[ant-build])
WA_APPEND([EXTRA_CLEAN],[ant-clean])
;;
"no"|"NO"|"false"|"FALSE")
AC_MSG_RESULT([no])
;;
*)
WA_ERROR([invalid parameter --enable-docs="${enableval}"])
;;
esac
],[
dnl ------------------------------------------------------------------
dnl We are going to call ANT only if we found it, but making sure
dnl that we specify the "docs" target
dnl ------------------------------------------------------------------
if test -z "${ANT}" ; then
AC_MSG_RESULT([no (ant required)])
else
AC_MSG_RESULT([yes (ant detected)])
WA_APPEND([ANT_TARGETS],[docs])
WA_APPEND([EXTRA_BUILD],[ant-build])
WA_APPEND([EXTRA_CLEAN],[ant-clean])
fi
])
dnl --------------------------------------------------------------------------
dnl Do we want to build also the Java API documentation?
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for Java API docs generation])
AC_ARG_ENABLE(
[apidoc-java],
[ --enable-apidoc-java generate Java API docs (requires ANT)],
[
case "${enableval}" in
""|"yes"|"YES"|"true"|"TRUE")
if test -z "${ANT}" ; then
WA_ERROR([docs generation desired but ANT not found])
fi
AC_MSG_RESULT([yes])
dnl --------------------------------------------------------------
dnl We were specifically requested to create javadocs, and we
dnl found ANT, we need to call it with the "javadoc" target
dnl --------------------------------------------------------------
WA_APPEND([ANT_TARGETS],[javadoc])
WA_APPEND([EXTRA_BUILD],[ant-build])
WA_APPEND([EXTRA_CLEAN],[ant-clean])
;;
"no"|"NO"|"false"|"FALSE")
AC_MSG_RESULT([no])
;;
*)
WA_ERROR([invalid parameter --enable-apidoc-java="${enableval}"])
;;
esac
],[
dnl ------------------------------------------------------------------
dnl We are going to call ANT only if we found it, but making sure
dnl that we specify the "javadoc" target
dnl ------------------------------------------------------------------
if test -z "${ANT}" ; then
AC_MSG_RESULT([no (ant required)])
else
AC_MSG_RESULT([yes (ant detected)])
WA_APPEND([ANT_TARGETS],[javadoc])
WA_APPEND([EXTRA_BUILD],[ant-build])
WA_APPEND([EXTRA_CLEAN],[ant-clean])
fi
])
dnl --------------------------------------------------------------------------
dnl Do we want to build also the C API documentation?
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for C API docs generation])
AC_ARG_ENABLE(
[apidoc-c],
[ --enable-apidoc-c generate C API docs (requires PERL)],
[
case "${enableval}" in
""|"yes"|"YES"|"true"|"TRUE")
if test -z "${PERL}" ; then
WA_ERROR([docs generation desired but PERL not found])
fi
AC_MSG_RESULT([yes])
dnl --------------------------------------------------------------
dnl We were specifically requested to create c api docs, and we
dnl found PERL, we need to define a couple of new targets
dnl --------------------------------------------------------------
WA_APPEND([EXTRA_BUILD],[capi-build])
WA_APPEND([EXTRA_CLEAN],[capi-clean])
;;
"no"|"NO"|"false"|"FALSE")
AC_MSG_RESULT([no])
;;
*)
WA_ERROR([invalid parameter --enable-apidoc-c="${enableval}"])
;;
esac
],[
dnl ------------------------------------------------------------------
dnl We are going to call the C Api generation/cleanup targets only if
dnl we found PERL
dnl ------------------------------------------------------------------
if test -z "${PERL}" ; then
AC_MSG_RESULT([no (perl required)])
else
AC_MSG_RESULT([yes (perl detected)])
WA_APPEND([EXTRA_BUILD],[capi-build])
WA_APPEND([EXTRA_CLEAN],[capi-clean])
fi
])
dnl --------------------------------------------------------------------------
dnl All done
dnl --------------------------------------------------------------------------
WA_HEADER([All done])
AC_OUTPUT(
[
Makedefs
Makefile
lib/Makefile
${MODULE}/Makefile
build.properties
])