Attached is a patch to jk2 for the remaining changes that are needed for
using HEAD with apache13. In addition to this patch I needed to delete
common/jk_channel_socket.c and common/jk_pool.c from my tree (perhaps these
should be moved to the attic).

This patch does the following things:

1) adds --with-apr-util to jk_apr.m4 and configure.in and will be a required
configure argument for apache13.

2) fixes some small problems in jk_apr.m4 and jk_exec.m4.

3) removes the remaining  ifdefs HAS_APR from server/apache13/mod_jk2.c
and -DHAS_APR from jk_apr.m4 (I couldn't find any remaining code that needs
it now).

4) reverts server/apache13/Makefile.in to create mod_jk.so without creating
mod_jk.la (this may of interest to jean-frederic clere). I wasn't able to
figure out how to get apr-0 and apr-util-0 statically linked in to mod_jk.so
the way it was changed. To be honest libtool is not my strong point, help
with this would be appreciated. I also removed -lcrypt too.

I think that covers it. Please review and comment.

-Kurt
Index: native2/Makefile.in
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native2/Makefile.in,v
retrieving revision 1.3
diff -u -r1.3 Makefile.in
--- native2/Makefile.in 4 Nov 2003 12:48:05 -0000       1.3
+++ native2/Makefile.in 7 Nov 2003 23:50:15 -0000
@@ -41,10 +41,10 @@
        done;
 
 apr-build:
-       ( cd @APR_DIR@ && make )
+       ( cd @APR_DIR@ && make && cd @APR_UTIL_DIR@ && make )
 
 apr-clean:
-       ( cd @APR_DIR@ && make clean )
+       ( cd @APR_DIR@ && make clean && cd @APR_UTIL_DIR@ && make clean )
 
 apidocs: common/*.h
        mkdir -p ./docs/api
Index: native2/configure.in
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native2/configure.in,v
retrieving revision 1.13
diff -u -r1.13 configure.in
--- native2/configure.in        5 Nov 2003 09:15:19 -0000       1.13
+++ native2/configure.in        7 Nov 2003 23:50:15 -0000
@@ -175,15 +175,10 @@
 
 JK_APR_THREADS()
 JK_APR([include/apr.h.in])
+JK_APR_UTIL([include/apu.h.in])
 JK_APR_INCDIR([apr.h])
 JK_APR_LIBDIR()
 
-dnl Set these to empty until we know what to do with them
-
-AC_SUBST(APR_UTIL_INCL)
-AC_SUBST(APR_UTIL_LIB)
-
-
 dnl Java settings
 
 JK_JNI()
@@ -205,11 +200,16 @@
 
 AC_SUBST(WEBSERVERS)
 
+dnl if --with-apr is specified, --with-apr-util must be too
+if ${TEST} ! -z "$APR_BUILD" -a -z "$APR_UTIL_DIR"; then
+  AC_MSG_ERROR([--with-apr and --with-apr-util must be used together])
+fi
+
 dnl apache 1.3 consistancy checks
 if ! ${TEST} -z "$APACHE_HOME" ; then
 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])
+                AC_MSG_ERROR([Apache 1.3 requires apr to built from source, use 
--with-apr and --with-apr-util])
         fi
 dnl make sure compiler matchs apxs
         if ${TEST} "$APACHE_CC" != "$CC"; then
@@ -222,9 +222,9 @@
 fi
 
 dnl apache 2 consistancy checks
-if ! ${TEST} -z "$APACHE2_HOME" ; then
+if ${TEST} ! -z "$APACHE2_HOME" ; then
 dnl check if apache 2 was selected with apr sources
-        if ${TEST} -z "$APR_BUILD"; then
+        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
@@ -245,9 +245,12 @@
 AC_SUBST(APR_CFLAGS)
 AC_SUBST(APR_CLEAN)
 AC_SUBST(APR_DIR)
+AC_SUBST(APR_UTIL_DIR)
 AC_SUBST(APR_HOME)
 AC_SUBST(APR_INCDIR)
+AC_SUBST(APR_UTIL_INCDIR)
 AC_SUBST(APR_LIBDIR)
+AC_SUBST(APR_UTIL_LIBDIR)
 AC_SUBST(APR_CONFIGURE_ARGS)
 AC_SUBST(APR_LDFLAGS)
 AC_SUBST(COMMON_APR_OBJECTS)
Index: native2/server/apache13/Makefile.in
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-connectors/jk/native2/server/apache13/Makefile.in,v
retrieving revision 1.7
diff -u -r1.7 Makefile.in
--- native2/server/apache13/Makefile.in 28 Nov 2002 15:54:51 -0000      1.7
+++ native2/server/apache13/Makefile.in 7 Nov 2003 23:50:15 -0000
@@ -23,7 +23,7 @@
           ${APACHE_INCL}
 
 JK_CFLAGS=-DCHUNK_SIZE=4096 -DUSE_APACHE_MD5 @APR_CFLAGS@ -DHAVE_MMAP ${JAVA_INCL}
-JK_LDFLAGS=-L${APACHE_HOME}/lib -lcrypt @APR_LDFLAGS@ ${JAVA_LIB}
+JK_LDFLAGS=-L${APACHE_HOME}/lib ${JAVA_LIB}
 
 ###### Based on rules.mk ##########################################
 ALL_CFLAGS   = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
@@ -36,7 +36,7 @@
 COMPILE      = $(CC)  $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
 
 SH_COMPILE = $(LIBTOOL) --mode=compile $(COMPILE) $(JK_CFLAGS)
-MOD_LINK = $(LIBTOOL) --mode=link $(CC) -avoid-version -module -rpath 
$(APACHE_LIBEXEC) $(LT_LDFLAGS) $(ALL_LDFLAGS) $(JK_LDFLAGS)
+MOD_LINK = $(LIBTOOL) --mode=link $(CC) -avoid-version -module -shared -rpath 
$(APACHE_LIBEXEC) $(LT_LDFLAGS) $(ALL_LDFLAGS) $(JK_LDFLAGS)
 MOD_INSTALL = $(LIBTOOL) --mode=install $(CP)
 
 #############################################################################
@@ -76,10 +76,7 @@
 
 all: prepare ${BUILD_DIR}/mod_jk2.so 
 
-${BUILD_DIR}/mod_jk2.so: ${BUILD_DIR}/mod_jk2.la
-       $(MOD_INSTALL) cp $^ `pwd`/${BUILD_DIR}
-
-${BUILD_DIR}/mod_jk2.la: ${COMMON_LO_FILES} ${A_LO_FILES}
+${BUILD_DIR}/mod_jk2.so: ${COMMON_LO_FILES} ${A_LO_FILES}
        ${MOD_LINK} -o $@ $^ @APR_LDFLAGS@
 
 ${COMMON_C_FILES} ${A_C_FILES}: ${H_FILES}
Index: native2/server/apache13/mod_jk2.c
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c,v
retrieving revision 1.28
diff -u -r1.28 mod_jk2.c
--- native2/server/apache13/mod_jk2.c   25 Sep 2003 15:23:23 -0000      1.28
+++ native2/server/apache13/mod_jk2.c   7 Nov 2003 23:50:16 -0000
@@ -299,9 +299,7 @@
 
 
 
-#ifdef HAS_APR
 apr_pool_t *jk_globalPool;
-#endif
 
 /* Create the initial set of objects. You need to cut&paste this and
    adapt to your server.
@@ -312,17 +310,10 @@
     jk_pool_t *globalPool;
     jk_bean_t *jkb;
 
-#ifdef HAS_APR
     apr_initialize();
     apr_pool_create( &jk_globalPool, NULL );
 
     jk2_pool_apr_create( NULL, &globalPool, NULL, jk_globalPool );
-#else
-    /** First create a pool. We use the default ( jk ) pool impl,
-     *  other choices are apr or native.
-     */
-    jk2_pool_create( NULL, &globalPool, NULL, 2048 );
-#endif
     
     /** Create the global environment. This will register the default
         factories, to be overriten later.
Index: support/jk_apr.m4
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/support/jk_apr.m4,v
retrieving revision 1.7
diff -u -r1.7 jk_apr.m4
--- support/jk_apr.m4   5 Nov 2003 09:14:28 -0000       1.7
+++ support/jk_apr.m4   7 Nov 2003 23:50:20 -0000
@@ -103,6 +103,7 @@
       [
         case "${withval}" in
           ""|"yes"|"YES"|"true"|"TRUE")
+            AC_MSG_ERROR(valid apr source dir location required)
           ;;
           "no"|"NO"|"false"|"FALSE")
             AC_MSG_ERROR(valid apr source dir location required)
@@ -120,16 +121,15 @@
 
           if ${TEST} ! -z "$tempval" ; then
             APR_BUILD="apr-build"
-            APR_CFLAGS="-I ${tempval}/include -DHAS_APR"
+            APR_CFLAGS="-I ${tempval}/include"
             APR_CLEAN="apr-clean"
             APR_DIR=${tempval}
             APR_INCDIR="${tempval}/include"
             AC_MSG_RESULT(configuring apr...)
-            APR_CONFIGURE_ARGS="--enable-static --disable-shared 
${APR_CONFIGURE_ARGS}"
             tempret="0"
             JK_EXEC(
               [tempret],
-              [./configure ${APR_CONFIGURE_ARGS}],
+              [./configure --enable-static --disable-shared ${APR_CONFIGURE_ARGS}],
               [apr],
               [${APR_DIR}])
             if ${TEST} "${tempret}" = "0"; then
@@ -137,8 +137,8 @@
             else
               AC_MSG_ERROR(apr configure failed with ${tempret})
             fi
-            JK_APR_LIBNAME(APR_LDFLAGS,${APR_DIR})
-            APR_LDFLAGS="${APR_DIR}/.libs/${APR_LDFLAGS}"
+            JK_APR_LIBNAME(apr_libname,${APR_DIR})
+            APR_LDFLAGS="${APR_DIR}/.libs/${apr_libname}"
             APR_LIBDIR=""
                        use_apr=true
             COMMON_APR_OBJECTS="\${COMMON_APR_OBJECTS}"
@@ -149,6 +149,73 @@
 
       unset tempret
       unset tempval
+      unset apr_libname
+  ])
+
+dnl --------------------------------------------------------------------------
+dnl JK_APR_UTIL
+dnl   Set the APR-UTIL source dir.
+dnl   $1 => File which should be present
+dnl --------------------------------------------------------------------------
+AC_DEFUN(
+  [JK_APR_UTIL],
+  [
+    tempval=""
+    AC_ARG_WITH(
+      [apr-util],
+      [  --with-apr-util=DIR      Location of APR-UTIL source dir ],
+      [
+        case "${withval}" in
+          ""|"yes"|"YES"|"true"|"TRUE")
+            AC_MSG_ERROR(valid apr-util source dir location required)
+          ;;
+          "no"|"NO"|"false"|"FALSE")
+            AC_MSG_ERROR(valid apr-util source dir location required)
+          ;;
+        *)
+          tempval="${withval}"
+
+          if ${TEST} ! -d ${tempval} ; then
+            AC_MSG_ERROR(Not a directory: ${tempval})
+          fi
+
+          if ${TEST} ! -f ${tempval}/$1; then
+            AC_MSG_ERROR(can't locate ${tempval}/$1)
+          fi
+
+          if ${TEST} -z "${APR_BUILD}"; then
+            AC_MSG_ERROR([--with-apr and --with-apr-util must be used together])
+          fi
+
+          if ${TEST} ! -z "$tempval" ; then
+            APR_UTIL_DIR=${tempval}
+            APR_CFLAGS="${APR_CFLAGS} -I ${APR_UTIL_DIR}/include"
+            APR_UTIL_INCDIR="${APR_UTIL_DIR}/include"
+            AC_MSG_RESULT(configuring apr-util...)
+            tempret="0"
+            JK_EXEC(
+              [tempret],
+              [./configure --with-apr=${APR_DIR}],
+              [apr-util],
+              [${APR_UTIL_DIR}])
+            if ${TEST} "${tempret}" = "0"; then
+              AC_MSG_RESULT(apr-util configure ok)
+            else
+              AC_MSG_ERROR(apr-util configure failed with ${tempret})
+            fi
+            JK_APR_UTIL_LIBNAME(apr_util_libname,${APR_UTIL_DIR})
+            APR_LDFLAGS="${APR_LDFLAGS} ${APR_UTIL_DIR}/.libs/${apr_util_libname}"
+            APR_UTIL_LIBDIR=""
+                       use_apr=true
+            COMMON_APR_OBJECTS="\${COMMON_APR_OBJECTS}"
+          fi
+          ;;
+        esac
+      ])
+
+      unset tempret
+      unset tempval
+      unset apr_util_libname
   ])
 
 
@@ -183,7 +250,7 @@
 
           if ${TEST} ! -z "$tempval" ; then
             APR_BUILD=""
-            APR_CFLAGS="-I${tempval} -DHAS_APR"
+            APR_CFLAGS="-I${tempval}"
             APR_CLEAN=""
             APR_DIR=""
             APR_INCDIR=${tempval}
@@ -252,17 +319,41 @@
   [JK_APR_LIBNAME],
   [
     AC_MSG_CHECKING([for apr APR_LIBNAME])
-    if test ! -f "$2/apr-config" ; then
+    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
+    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 --------------------------------------------------------------------------
+dnl JK_APR_UTIL_LIBNAME
+dnl   Retrieve the complete name of the library.
+dnl   $1 => Environment variable name for the returned value
+dnl   $2 => APR_UTIL sources directory
+dnl --------------------------------------------------------------------------
+AC_DEFUN(
+  [JK_APR_UTIL_LIBNAME],
+  [
+    AC_MSG_CHECKING([for apr-util APR_UTIL_LIBNAME])
+    if ${TEST} ! -f "$2/apu-config" ; then
+      AC_MSG_ERROR([cannot find apu-config file in $2])
+    fi
+    jk_apu_get_tempval=`$2/apu-config --link-libtool 2> /dev/null`
+    if ${TEST} -z "${jk_apu_get_tempval}" ; then
+      AC_MSG_ERROR([$2/apu-config --link-libtool failed])
+    fi
+    jk_apu_get_tempval=`basename ${jk_apu_get_tempval} | sed 's/\.la/\.a/g'`
+    $1="${jk_apu_get_tempval}"
+    AC_MSG_RESULT([${jk_apu_get_tempval}])
+    unset jk_apu_get_tempval
   ])
 
 dnl vi:set sts=2 sw=2 autoindent:
Index: support/jk_exec.m4
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/support/jk_exec.m4,v
retrieving revision 1.1
diff -u -r1.1 jk_exec.m4
--- support/jk_exec.m4  5 Nov 2003 09:14:28 -0000       1.1
+++ support/jk_exec.m4  7 Nov 2003 23:50:20 -0000
@@ -1,130 +1,130 @@
-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

-dnl Inspired by Pier works on webapp m4 macros :)

-dnl

-dnl Version $Id$

-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

-  ])

+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
+dnl Inspired by Pier works on webapp m4 macros :)
+dnl
+dnl Version $Id:$
+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 "\njk_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