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 Author Jon S. Stevens
dnl Version $Id$
dnl --------------------------------------------------------------------------
dnl --------------------------------------------------------------------------
dnl Initialize
dnl New vars: TEST TRUE ECHO GREP CAT SED RM SYSTEM
dnl Upd vars: N/A
dnl --------------------------------------------------------------------------
sinclude(./support/aplocal.m4)
sinclude(./support/apjava.m4)
AC_INIT([Makefile.in])
AC_CONFIG_AUX_DIR([support])
LOCAL_INIT()
AC_CANONICAL_HOST()
SYSTEM="${host_os}-${host_cpu}"
AC_SUBST(SYSTEM)
dnl --------------------------------------------------------------------------
dnl Setup initial variable value
dnl
dnl New vars: MODULE TARGET CFGFILES
dnl APR_CFGFLG APR_SRCDIR APR_LIBDIR APR_INCDIR APR_VARFIL
dnl Upd vars: N/A
dnl --------------------------------------------------------------------------
MODULE=""
TARGET="lib"
CFGFILES="./Makefile ./Makedefs ./lib/Makefile"
APR_CFGFLG=""
APR_SRCDIR=""
APR_LIBDIR=""
APR_INCDIR=""
APR_VARFIL=""
AC_SUBST(MODULE)
AC_SUBST(TARGET)
AC_SUBST(CFGFILES)
AC_SUBST(APR_CFGFLG)
AC_SUBST(APR_SRCDIR)
AC_SUBST(APR_LIBDIR)
AC_SUBST(APR_INCDIR)
AC_SUBST(APR_VARFIL)
dnl --------------------------------------------------------------------------
dnl Check where sources are
dnl
dnl New vars: SRCDIR
dnl Upd vars: N/A
dnl --------------------------------------------------------------------------
LOCAL_RESOLVEDIR(SRCDIR,[${srcdir}],[sources directory])
LOCAL_RESOLVEDIR(TGTDIR,[.],[targets directory])
AC_SUBST(SRCDIR)
dnl -------------------------------------------------------------------------
dnl Check C environment
dnl
dnl We need to check local compilation in case the user got an APR
dnl distribution from a binary tarball (such as in Apache 2.0) and the
dnl compiler is not available.
dnl
dnl New vars: AR RANLIB CC CFLAGS CPP CPPFLAGS
dnl Upd vars: N/A
dnl -------------------------------------------------------------------------
LOCAL_HEADER([C-Language compilation tools])
LOCAL_CHECK_PROG(AR,ar)
AC_CHECK_TOOL(RANLIB, ranlib, true)
AC_SUBST(AR)
AC_SUBST(RANLIB)
AC_PROG_CC()
local_cc="${CC}"
LOCAL_CHECK_PROG(CC,"${local_cc}")
unset local_cc
AC_PROG_CC_C_O()
AC_PROG_CPP()
AC_SUBST(CPPFLAGS)
dnl -------------------------------------------------------------------------
dnl Optional compilation flags
dnl
dnl New vars: DEBUG
dnl Upd vars: CPPFLAGS
dnl -------------------------------------------------------------------------
LOCAL_HELP([External libraries and compilation flags])
AC_MSG_CHECKING([for debug build])
AC_ARG_ENABLE(debug,
[ --enable-debug enable compilation of debug information messages
within C code (this will slow down
execution and create huge log files).],
[
AC_MSG_RESULT([yes])
DEBUG="true"
CPPFLAGS="${CPPFLAGS} -DDEBUG"
],[
AC_MSG_RESULT([no])
DEBUG="false"
]
)
AC_SUBST(DEBUG)
dnl -------------------------------------------------------------------------
dnl Check wether we have to build the C API documentation or not
dnl
dnl New vars: PERL SCANDOC SCANDOCFLAGS
dnl Upd vars: TARGET
dnl -------------------------------------------------------------------------
LOCAL_HEADER([API documentation generation])
AC_MSG_CHECKING([for C API documentation])
AC_ARG_ENABLE(apidocs-c,
[ --enable-apidocs-c[=PERL]
enable generation of C API documentation using
ScanDoc (PERL is the name of the Perl interpreter
used to run ScanDoc. If not specified this is
looked up in your current path).],
[
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for Perl interpreter])
case "${enableval}" in
""|"yes"|"YES"|"true"|"TRUE")
LOCAL_CHECK_PROG(PERL,perl)
;;
*)
PERL="${enableval}"
;;
esac
if ${TEST} ! -x "${PERL}"
then
AC_MSG_RESULT([error])
AC_MSG_ERROR([cannot execute perl \"${PERL}\"])
fi
AC_MSG_RESULT([${PERL}])
AC_MSG_CHECKING([for ScanDoc to use])
SCANDOC="${SRCDIR}/support/scandoc.pl"
if ${TEST} ! -f "${SCANDOC}"
then
AC_MSG_RESULT([error])
AC_MSG_ERROR([cannof find ScanDoc \"${SCANDOC}\"])
fi
AC_MSG_RESULT([${SCANDOC}])
AC_MSG_CHECKING([for ScanDoc template])
if ${TEST} ! -f "${SRCDIR}/support/template.pl"
then
AC_MSG_RESULT([error])
AC_MSG_ERROR([cannof find ScanDoc \"${SRCDIR}/support/template.pl\"])
fi
AC_MSG_RESULT([${SRCDIR}/support/template.pl])
SCANDOCFLAGS="-i ${SRCDIR}/support/template.pl"
TARGET="${TARGET} apidocs-c"
],[
AC_MSG_RESULT([no])
PERL=""
]
)
AC_SUBST(PERL)
AC_SUBST(SCANDOC)
AC_SUBST(SCANDOCFLAGS)
dnl --------------------------------------------------------------------------
dnl Process the --with-apr=... command line argument
dnl
dnl This is always processed, and sets the APR_SRCDIR variable. After this
dnl is executed, for each module the APR_SRCDIR variable should be over
dnl written if the web server already knows the location of APR's include
dnl header and library directories. (As in Apache 2.0)
dnl
dnl New vars: N/A
dnl Upd vars: APR_SRCDIR
dnl --------------------------------------------------------------------------
LOCAL_HEADER([APR location])
AC_MSG_CHECKING([for APR sources])
AC_ARG_WITH(apr,
[ --with-apr[=DIR] path of an APR (Apache Portable Runtime) source
distribution or CVS snapshot. (DIR defaults to
\"./apr\"). Not required and ignored when an
Apache 2.0 apxs is specified (--with-apxs).],
[
case "${withval}" in
""|"yes"|"YES"|"true"|"TRUE")
APR_SRCDIR="${SRCDIR}/apr"
;;
*)
APR_SRCDIR="${withval}"
;;
esac
AC_MSG_RESULT([${APR_SRCDIR}])
],[
APR_SRCDIR="${SRCDIR}/apr"
AC_MSG_RESULT([${APR_SRCDIR}])
]
)
dnl --------------------------------------------------------------------------
dnl Process the --with-apr-lib=... command line argument
dnl FHS System does not have apr library installed local_prefix/lib
dnl but somewhere else.
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for APR libraries])
AC_ARG_WITH(apr-lib,
[ --with-apr-lib=DIR path where the APR libraries are installed.],
[
case "${withval}" in
""|"yes"|"YES"|"true"|"TRUE")
AC_MSG_ERROR([--with-apr-lib need a directory])
;;
*)
APR_LIBDIR="${withval}"
;;
esac
AC_MSG_RESULT([${APR_LIBDIR}])
],
[
AC_MSG_RESULT([no])
]
)
dnl --------------------------------------------------------------------------
dnl Process the --with-apr-include=... command line argument
dnl FHS System does not have apr include installed local_prefix/include
dnl but somewhere else.
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for APR includes])
AC_ARG_WITH(apr-include,
[ --with-apr-include=DIR path where the APR includes are
installed.],
[
case "${withval}" in
""|"yes"|"YES"|"true"|"TRUE")
AC_MSG_ERROR([--with-apr-include need a directory])
;;
*)
APR_INCDIR="${withval}"
;;
esac
AC_MSG_RESULT([${APR_INCDIR}])
],
[
AC_MSG_RESULT([no])
]
)
dnl --------------------------------------------------------------------------
dnl Target module to build
dnl --------------------------------------------------------------------------
LOCAL_HEADER([Target web-server])
LOCAL_HELP([Available Web-Server modules])
dnl --------------------------------------------------------------------------
dnl Process the --with-apxs[=FILE] command line argument
dnl
dnl Use Apache's APXS utility to compile the Apache module (1.3/2.0 is
dnl detected and APR variables are set accordingly).
dnl
dnl New vars: APXS
dnl Upd vars: N/A
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for Apache apxs])
AC_ARG_WITH(apxs,
[ --with-apxs[=FILE] build a shared Apache module. If FILE was not
specified, then APXS will be searched within the
current PATH. The Apache server version (1.3 or 2.0)
will be automatically detected.],
[
AC_MSG_RESULT([yes])
if ${TEST} -n "${MODULE}"
then
AC_MSG_ERROR([target module already defined as ${MODULE}])
fi
case "${withval}" in
""|"yes"|"YES"|"true"|"TRUE")
LOCAL_CHECK_PROG(APXS,apxs)
;;
*)
APXS="${withval}"
;;
esac
if ${TEST} ! -x ${APXS}
then
AC_MSG_ERROR([cannot execute apxs \"${APXS}\"])
fi
dnl ----------------------------------------------------------------------
dnl Detect APXS 1.3/2.0
dnl ----------------------------------------------------------------------
local_apache=`${GREP} STANDARD20 ${APXS}`
if ${TEST} -n "${local_apache}"
then
dnl -----------------------------------------------------
dnl APXS 2.0
dnl Note: APXS for 2.0 is broken, so we need to
dnl "discover" some of the values manually hoping
dnl to get the right layout.
dnl
dnl New vars: N/A
dnl Upd vars: APR_CFGFLG APR_VARFIL APR_LIBDIR APR_INCDIR
dnl -----------------------------------------------------
MODULE="apache-2.0"
local_prefix="`${APXS} -q PREFIX`"
LIBTOOL="$local_prefix/build/libtool"
APR_CFGFLG=""
dnl check APR_LIBDIR
if ${TEST} -z "${APR_LIBDIR}"
then
APR_VARFIL="${local_prefix}/lib/APRVARS"
APR_LIBDIR="${local_prefix}/lib"
else
APR_VARFIL="${APR_LIBDIR}/APRVARS"
fi
dnl check APR_INCDIR
if ${TEST} -z "${APR_INCDIR}"
then
APR_INCDIR="${local_prefix}/include"
fi
if ${TEST} ! -d "${APR_LIBDIR}"
then
AC_MSG_ERROR([\"${APR_LIBDIR}\" not found. Use --with-apr-lib=DIR.])
fi
if ${TEST} ! -d "${APR_INCDIR}"
then
AC_MSG_ERROR([\"${APR_INCDIR}\" not found. Use --with-apr-include=DIR.])
fi
unset local_prefix
else
dnl Upd vars: APR_CFGFLG APR_VARFIL APR_LIBDIR APR_INCDIR
dnl -----------------------------------------------------
dnl APXS 1.3
dnl
dnl New vars: N/A
dnl Upd vars: APR_CFGFLG APR_VARFIL APR_LIBDIR APR_INCDIR
dnl -----------------------------------------------------
MODULE="apache-1.3"
APR_CFGFLG="--enable-static --disable-shared --disable-threads"
APR_VARFIL=""
APR_LIBDIR=""
APR_INCDIR=""
dnl -----------------------------------------------------
dnl check for broken APXS (Apachetoolbox brokes it)
dnl -----------------------------------------------------
local_ldflags_shlib="`${APXS} -q LDFLAGS_SHLIB 2>&1 | grep Error`"
if ${TEST} -n "${local_ldflags_shlib}"
then
AC_MSG_ERROR([${APXS} is broken (LDFLAGS_SHLIB not found)])
fi
local_cflags="`${APXS} -q CFLAGS 2>&1 | grep Error`"
if ${TEST} -n "${local_cflags}"
then
AC_MSG_ERROR([${APXS} is broken (CFLAGS not found)])
fi
fi
unset local_apache
],[
AC_MSG_RESULT([no])
]
)
dnl --------------------------------------------------------------------------
dnl Was a module specified?
dnl
dnl New vars: N/A
dnl Upd vars: CFGFILES
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([target module])
if ${TEST} -z "${MODULE}"
then
AC_MSG_RESULT([error])
AC_MSG_ERROR([No target module specified])
fi
AC_MSG_RESULT([${MODULE}])
CFGFILES="${CFGFILES} ./${MODULE}/Makefile"
dnl --------------------------------------------------------------------------
dnl Configure the APR source distribution
dnl
dnl This step gets executed ONLY if APR_VARFIL's length zero. Basically, if
dnl the module doesn't provide us with a name for the APRVARS file.
dnl
dnl New vars: N/A
dnl Upd vars: APR_VARFIL APR_LIBDIR APR_INCDIR TARGET
dnl --------------------------------------------------------------------------
if ${TEST} -z "${APR_VARFIL}"
then
dnl -----------------------------------------------
dnl Check if we were supplied a valid APR directory
dnl -----------------------------------------------
if ${TEST} ! -d "${APR_SRCDIR}"
then
AC_MSG_ERROR([APR sources not found. Use --with-apr=DIR.])
fi
LOCAL_RESOLVEDIR(APR_SRCDIR,[${APR_SRCDIR}],[full APR directory path])
dnl ----------------------------
dnl Run the APR configure script
dnl ----------------------------
LOCAL_HEADER([Configuring APR])
LOCAL_FILTEREXEC(local_return,
[./configure ${APR_CFGFLG}],
["APR configure"],
[${APR_SRCDIR}])
if ${TEST} "${local_return}" -ne "0"
then
AC_MSG_ERROR([APR configure script terminated with error code ${local_return}])
fi
APR_INCDIR="${APR_SRCDIR}/include"
APR_VARFIL="${APR_SRCDIR}/APRVARS"
APR_LIBDIR="${TGTDIR}/lib"
TARGET="${TARGET} apr"
LIBTOOL="${APR_SRCDIR}/libtool"
eval `${GREP} "^CC=" ${APR_VARFIL} | ${SED} "s/^CC=/APR_CC=/"`
else
APR_CC="${CC}"
fi
dnl --------------------------------------------------------------------------
dnl Parse APRVARS and discover what values we need
dnl
dnl New vars: APR_CFLAGS APR_CPPFLAGS APR_LDFLAGS APR_LIBS APR_INCLUDES
dnl Upd vars: N/A
dnl --------------------------------------------------------------------------
LOCAL_HEADER([Finishing up])
AC_MSG_CHECKING([for APR compilation flags])
if ${TEST} ! -f "${APR_VARFIL}"
then
AC_MSG_RESULT([error])
AC_MSG_ERROR([Cannot find required APRVARS file])
fi
dnl Check that we are not mixing native and gnu compilers
dnl on the platfroms that do not support it.
eval `${GREP} "^NM=" ${LIBTOOL}`
gnu_cc=`${APR_CC} --help | ${GREP} gnu`
if ${TEST} ! -z "${gnu_cc}"
then
APACHE_DIR=`${APXS} -q SBINDIR`
is_apache_gcc="Yes"
case $host in
sparc-sun-solaris2.8)
is_apache_gcc=`${NM} ${APACHE_DIR}/httpd | ${GREP} __lshrdi3`
;;
esac
if ${TEST} -z "${is_apache_gcc}"
then
AC_MSG_ERROR([Cannot mix gcc and native cc])
fi
fi
AC_MSG_RESULT([ok])
eval `${CAT} ${APR_VARFIL} | ${GREP} "EXTRA_" | ${SED} "s/EXTRA_/APR_/g"`
AC_SUBST(APR_CFLAGS)
AC_SUBST(APR_CPPFLAGS)
AC_SUBST(APR_INCLUDES)
AC_SUBST(APR_LDFLAGS)
AC_SUBST(APR_LIBS)
AC_SUBST(LIBTOOL)
dnl --------------------------------------------------------------------------
dnl Set up targets for building and cleaning
dnl
dnl New vars: TARGET_BUILD TARGET_CLEAN TARGET_LBUILD TARGET_LCLEAN
dnl Upd vars: N/A
dnl --------------------------------------------------------------------------
AC_MSG_CHECKING([for Makefile targets])
TARGET_BUILD=""
TARGET_CLEAN=""
for local_target in ${TARGET}
do
TARGET_BUILD="${TARGET_BUILD} ${local_target}-build"
TARGET_CLEAN="${TARGET_CLEAN} ${local_target}-clean"
if ${TEST} ! "${local_target}" = "apr"
then
TARGET_LBUILD="${TARGET_LBUILD} ${local_target}-build"
TARGET_LCLEAN="${TARGET_LCLEAN} ${local_target}-clean"
fi
done
unset local_target
TARGET_BUILD="${TARGET_BUILD} ${MODULE}-build"
TARGET_CLEAN="${TARGET_CLEAN} ${MODULE}-clean"
TARGET_LBUILD="${TARGET_LBUILD} ${MODULE}-build"
TARGET_LCLEAN="${TARGET_LCLEAN} ${MODULE}-clean"
AC_MSG_RESULT([${TARGET} ${MODULE}])
AC_SUBST(TARGET_BUILD)
AC_SUBST(TARGET_CLEAN)
AC_SUBST(TARGET_LBUILD)
AC_SUBST(TARGET_LCLEAN)
dnl --------------------------------------------------------------------------
dnl Finish up
dnl --------------------------------------------------------------------------
AC_OUTPUT(${CFGFILES})
LOCAL_HEADER([All done. Now you can issue \"make\". Good luck.])