Thanks to jean-frederic clere for input on this. Ok, here goes again... ;-)

Attached is a patch that makes the following changes for building jk2 via
configure and make:

1) Introduces a new configure argument called --enable-apr-threads=<val> for
use with --with-apr. This argument allows for threading to be configured for
apr because apr doesn't always guess threading the same way apache is
configured.

2) Changes --with-apr to configure apr while configuring jk2. This allows
for the correct naming of the apr library name instead of hard coding it and
compiler consistency with apache13 (I copied stuff from the webapp connector
for this)

3) Added compiler consistency checks for apache13 and apache2. The same
compiler must be used for jk2 as was used for apache. For apache13 a side
effect is that apr is also configured to use the same compiler (picked up
via the environment).

4) Added checks to force the use of --with-apr for apache13 and disallow use
of --with-apr for apache2.

Please review and consider for committing if there are no issues or
objections.

-Kurt
Index: native2/Makefile.in
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native2/Makefile.in,v
retrieving revision 1.2
diff -u -r1.2 Makefile.in
--- native2/Makefile.in 24 May 2002 07:14:08 -0000      1.2
+++ native2/Makefile.in 3 Nov 2003 19:15:44 -0000
@@ -41,7 +41,7 @@
        done;
 
 apr-build:
-       ( cd @APR_DIR@ && ./configure && make )
+       ( cd @APR_DIR@ && make )
 
 apr-clean:
        ( cd @APR_DIR@ && make clean )
Index: native2/configure.in
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native2/configure.in,v
retrieving revision 1.11
diff -u -r1.11 configure.in
--- native2/configure.in        3 Nov 2003 09:49:58 -0000       1.11
+++ native2/configure.in        3 Nov 2003 19:15:44 -0000
@@ -64,6 +64,7 @@
 dnl sinclude(../support/jk_apache_static.m4)
 sinclude(../support/jk_apxs.m4)
 sinclude(../support/jk_ws.m4)
+sinclude(../support/jk_exec.m4)
 sinclude(../support/jk_apr.m4)
 sinclude(../support/jk_tchome.m4)
 sinclude(../support/jk_java.m4)
@@ -172,6 +173,7 @@
 
 dnl APR settings
 
+JK_APR_THREADS()
 JK_APR([include/apr.h.in])
 JK_APR_INCDIR([apr.h])
 JK_APR_LIBDIR()
@@ -203,16 +205,37 @@
 
 AC_SUBST(WEBSERVERS)
 
-dnl check if apache 1.3 selected with jni support
+dnl apache 1.3 consistancy checks
 if ! ${TEST} -z "$APACHE_HOME" ; then
-dnl check jni wanted
-       if ${TEST} "${use_jni}" = "true"; then 
-               if ! ${TEST} "${use_apr}" = "true"; then
-                       AC_MSG_ERROR(Apache 1.3 need apr to use jni)
-               fi
-       fi
+dnl check if apache 1.3 was selected without apr sources
+        if ${TEST} -z "$APR_BUILD"; then
+                AC_MSG_ERROR([Apache 1.3 requires apr to built from source, use 
--with-apr])
+        fi
+dnl make sure compiler matchs apxs
+        if ${TEST} "$APACHE_CC" != "$CC"; then
+                AC_MSG_RESULT([error])
+                AC_MSG_RESULT([compiler discovered by configure: ${CC}])
+                AC_MSG_RESULT([compiler used by apache: ${APACHE_CC}])
+                AC_MSG_RESULT([delete config.cache and try CC=${APACHE_CC} 
./configure])
+                AC_MSG_ERROR([jk2 and apache compilers must be the same])
+        fi
 fi
 
+dnl apache 2 consistancy checks
+if ! ${TEST} -z "$APACHE2_HOME" ; then
+dnl check if apache 2 was selected with apr sources
+        if ${TEST} -z "$APR_BUILD"; then
+                AC_MSG_ERROR([Use apr that comes with Apache 2, remove --with-apr])
+        fi
+dnl make sure compiler matchs apxs
+        if ${TEST} "$APACHE2_CC" != "$CC"; then
+                AC_MSG_RESULT([error])
+                AC_MSG_RESULT([compiler discovered by configure: ${CC}])
+                AC_MSG_RESULT([compiler used by apache: ${APACHE2_CC}])
+                AC_MSG_RESULT([delete config.cache and try CC=${APACHE2_CC} 
./configure])
+                AC_MSG_ERROR([jk2 and apache compilers must be the same])
+        fi
+fi
 AC_SUBST(APACHE20_OEXT)
 AC_SUBST(LIB_JK_TYPE)
 AC_SUBST(INSTALL_TYPE)
@@ -225,6 +248,7 @@
 AC_SUBST(APR_HOME)
 AC_SUBST(APR_INCDIR)
 AC_SUBST(APR_LIBDIR)
+AC_SUBST(APR_CONFIGURE_ARGS)
 AC_SUBST(APR_LDFLAGS)
 AC_SUBST(COMMON_APR_OBJECTS)
 
Index: support/jk_apr.m4
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/support/jk_apr.m4,v
retrieving revision 1.5
diff -u -r1.5 jk_apr.m4
--- support/jk_apr.m4   3 Nov 2003 09:59:45 -0000       1.5
+++ support/jk_apr.m4   3 Nov 2003 19:15:44 -0000
@@ -64,6 +64,31 @@
 dnl --------------------------------------------------------------------------
 
 dnl --------------------------------------------------------------------------
+dnl JK_APR_THREADS
+dnl   Configure APR threading for use with --with-apr.
+dnl   Result goes into APR_CONFIGURE_ARGS
+dnl --------------------------------------------------------------------------
+AC_DEFUN(
+  [JK_APR_THREADS],
+  [
+    AC_ARG_ENABLE(
+      [apr-threads],
+      [  --enable-apr-threads        Configure APR threading for use with --with-apr 
],
+      [
+        case "${enableval}" in
+          ""|"yes"|"YES"|"true"|"TRUE")
+            APR_CONFIGURE_ARGS="--enable-threads ${APR_CONFIGURE_ARGS}"
+          ;;
+          "no"|"NO"|"false"|"FALSE")
+            APR_CONFIGURE_ARGS="--disable-threads ${APR_CONFIGURE_ARGS}"
+          ;;
+        *)
+          APR_CONFIGURE_ARGS="--enable-threads=${enableval} ${APR_CONFIGURE_ARGS}"
+         esac
+      ])
+  ])
+
+dnl --------------------------------------------------------------------------
 dnl JK_APR
 dnl   Set the APR source dir.
 dnl   $1 => File which should be present
@@ -99,7 +124,21 @@
             APR_CLEAN="apr-clean"
             APR_DIR=${tempval}
             APR_INCDIR="${tempval}/include"
-            APR_LDFLAGS="${tempval}/.libs/libapr-0.a"
+            AC_MSG_RESULT(configuring apr...)
+            APR_CONFIGURE_ARGS="--enable-static --disable-shared 
${APR_CONFIGURE_ARGS}"
+            tempret="0"
+            JK_EXEC(
+              [tempret],
+              [./configure ${APR_CONFIGURE_ARGS}],
+              [apr],
+              [${APR_DIR}])
+            if ${TEST} "${tempret}" = "0"; then
+              AC_MSG_RESULT(apr configure ok)
+            else
+              AC_MSG_ERROR(apr configure failed with ${tempret})
+            fi
+            JK_APR_LIBNAME(APR_LDFLAGS,${APR_DIR})
+            APR_LDFLAGS="${APR_DIR}/.libs/${APR_LDFLAGS}"
             APR_LIBDIR=""
                        use_apr=true
             COMMON_APR_OBJECTS="\${COMMON_APR_OBJECTS}"
@@ -108,6 +147,7 @@
         esac
       ])
 
+      unset tempret
       unset tempval
   ])
 
@@ -199,6 +239,30 @@
       ])
 
       unset tempval
+  ])
+
+
+dnl --------------------------------------------------------------------------
+dnl JK_APR_LIBNAME
+dnl   Retrieve the complete name of the library.
+dnl   $1 => Environment variable name for the returned value
+dnl   $2 => APR sources directory
+dnl --------------------------------------------------------------------------
+AC_DEFUN(
+  [JK_APR_LIBNAME],
+  [
+    AC_MSG_CHECKING([for apr APR_LIBNAME])
+    if test ! -f "$2/apr-config" ; then
+      AC_MSG_ERROR([cannot find apr-config file in $2])
+    fi
+    jk_apr_get_tempval=`$2/apr-config --link-libtool 2> /dev/null`
+    if test -z "${jk_apr_get_tempval}" ; then
+      AC_MSG_ERROR([$2/apr-config --link-libtool failed])
+    fi
+    jk_apr_get_tempval=`basename ${jk_apr_get_tempval} | sed 's/\.la/\.a/g'`
+    $1="${jk_apr_get_tempval}"
+    AC_MSG_RESULT([${jk_apr_get_tempval}])
+    unset jk_apr_get_tempval
   ])
 
 dnl vi:set sts=2 sw=2 autoindent:
Index: support/jk_apxs.m4
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/support/jk_apxs.m4,v
retrieving revision 1.6
diff -u -r1.6 jk_apxs.m4
--- support/jk_apxs.m4  25 Sep 2003 15:23:56 -0000      1.6
+++ support/jk_apxs.m4  3 Nov 2003 19:15:44 -0000
@@ -113,6 +113,7 @@
             APACHE$1_INCL="-I`${APXS$1} -q INCLUDEDIR`"
             APACHE$1_INCDIR="`${APXS$1} -q INCLUDEDIR`"
             APACHE$1_LIBEXEC="`${APXS$1} -q LIBEXECDIR`"
+            APACHE$1_CC="`${APXS$1} -q CC`"
 
             dnl test apache version
             APA=`${GREP} STANDARD20 ${APXS$1}`
@@ -160,6 +161,7 @@
   AC_SUBST(APACHE$1_INCDIR)
   AC_SUBST(APACHE$1_INCL)
   AC_SUBST(APACHE$1_LIBEXEC)
+  AC_SUBST(APACHE$1_CC)
   AC_SUBST(APXS$1_LDFLAGS)
 
 ])
--- /dev/null   Mon Nov  3 14:15:09 2003
+++ support/jk_exec.m4  Fri Oct 31 18:57:26 2003
@@ -0,0 +1,128 @@
+dnl  =========================================================================
+dnl
+dnl                  The Apache Software License,  Version 1.1
+dnl
+dnl           Copyright (c) 1999-2003 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 <http://www.apache.org/>."
+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 <[EMAIL PROTECTED]>.
+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 <http://www.apache.org/>.
+dnl
+dnl  =========================================================================
+
+dnl --------------------------------------------------------------------------
+dnl Author Pier Fumagalli <[EMAIL PROTECTED]>
+dnl Version $Id: wa_exec.m4,v 1.4 2002/05/03 12:13:57 pier Exp $
+dnl --------------------------------------------------------------------------
+
+dnl --------------------------------------------------------------------------
+dnl JK_EXEC
+dnl   Execute a program filtering its output (pretty printing).
+dnl
+dnl   Parameters:
+dnl     $1 => name of the variable containing the return value (error code).
+dnl     $2 => name of the binary/script to invoke
+dnl     $3 => message used for pretty printing output
+dnl     $4 => the directory where the command must be executed
+dnl --------------------------------------------------------------------------
+AC_DEFUN(
+  [JK_EXEC],
+  [
+    jk_exec_curdir="`pwd`"
+    if test -d "$4" ; then
+      cd "$4"
+    else
+      AC_MSG_ERROR([can't switch to directory $4])
+    fi
+
+    echo "  invoking \"$2\""
+    echo "  in directory \"$4\""
+    echo "-1" > retvalue.tmp
+
+    set $2
+    jk_exec_file=[$]1
+    if test ! -x "${jk_exec_file}" ; then
+      cd "${jk_exec_curdir}"
+      AC_MSG_ERROR([cannot find or execute \"${jk_exec_file}\" in \"$4\"])
+      exit 1
+    fi
+    unset jk_exec_file
+
+    {
+      $2
+      echo "jk_exec_retvalue $?"
+    } | {
+      jk_exec_ret=0
+      while true ; do
+        read jk_exec_first jk_exec_line
+        if test ! "$?" -eq "0" ; then
+          break
+        else
+          if test "${jk_exec_first}" = "jk_exec_retvalue" ; then
+            jk_exec_ret="${jk_exec_line}"
+          else
+            if test -n "${jk_exec_line}" ; then
+             echo "    $3: ${jk_exec_first} ${jk_exec_line}"
+            fi
+          fi
+        fi
+      done
+      echo "${jk_exec_ret}" > retvalue.tmp
+      unset jk_exec_first
+      unset jk_exec_line
+      unset jk_exec_ret
+    }
+
+    $1="`cat retvalue.tmp`"
+    rm -f retvalue.tmp
+    echo "  execution of \"$2\""
+    echo "  returned with value \"${$1}\""
+
+    cd "${jk_exec_curdir}"
+    unset jk_exec_curdir
+  ])

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to