2 dnl Licensed to the Apache Software Foundation (ASF) under one or more
3 dnl contributor license agreements. See the NOTICE file distributed with
4 dnl this work for additional information regarding copyright ownership.
5 dnl The ASF licenses this file to You under the Apache License, Version 2.0
6 dnl (the "License"); you may not use this file except in compliance with
7 dnl the License. You may obtain a copy of the License at
9 dnl http://www.apache.org/licenses/LICENSE-2.0
11 dnl Unless required by applicable law or agreed to in writing, software
12 dnl distributed under the License is distributed on an "AS IS" BASIS,
13 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 dnl See the License for the specific language governing permissions and
15 dnl limitations under the License.
18 dnl --------------------------------------------------------------------------
20 dnl Inspired by Pier works on webapp m4 macros :)
22 dnl Version $Id: jk_exec.m4 802231 2009-08-07 21:43:52Z markt $
23 dnl --------------------------------------------------------------------------
25 dnl --------------------------------------------------------------------------
27 dnl Execute a program filtering its output (pretty printing).
30 dnl $1 => name of the variable containing the return value (error code).
31 dnl $2 => name of the binary/script to invoke
32 dnl $3 => message used for pretty printing output
33 dnl $4 => the directory where the command must be executed
34 dnl --------------------------------------------------------------------------
38 jk_exec_curdir="`pwd`"
39 if test -d "$4" ; then
42 AC_MSG_ERROR([can't switch to directory $4])
45 echo " invoking \"$2\""
46 echo " in directory \"$4\""
47 echo "-1" > retvalue.tmp
51 if test ! -x "${jk_exec_file}" ; then
52 cd "${jk_exec_curdir}"
53 AC_MSG_ERROR([cannot find or execute \"${jk_exec_file}\" in \"$4\"])
61 echo "jk_exec_retvalue $?"
65 read jk_exec_first jk_exec_line
66 if test ! "$?" -eq "0" ; then
69 if test "${jk_exec_first}" = "jk_exec_retvalue" ; then
70 jk_exec_ret="${jk_exec_line}"
72 if test -n "${jk_exec_line}" ; then
73 echo " $3: ${jk_exec_first} ${jk_exec_line}"
78 echo "${jk_exec_ret}" > retvalue.tmp
84 $1="`cat retvalue.tmp`"
86 echo " execution of \"$2\""
87 echo " returned with value \"${$1}\""
89 cd "${jk_exec_curdir}"