1 dnl -------------------------------------------------------- -*- autoconf -*-
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 jk_common.m4: JK's general-purpose autoconf macros
19 dnl Mostly taken from APR.
23 dnl JK_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])
25 dnl A variant of AC_CHECK_SIZEOF which allows the checking of
26 dnl sizes of non-builtin types
28 AC_DEFUN([JK_CHECK_SIZEOF_EXTENDED],
29 [changequote(<<,>>)dnl
30 dnl The name to #define
31 define(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl
32 dnl The cache variable
33 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$2, [ *],[<p>]))dnl
35 AC_MSG_CHECKING(size of $2)
36 AC_CACHE_VAL(AC_CV_NAME,
37 [AC_TRY_RUN([#include <stdio.h>
41 FILE *f=fopen("conftestval","w");
43 fprintf(f, "%d\n", sizeof($2));
45 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,
47 AC_MSG_RESULT($AC_CV_NAME)
48 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The size of ]$2)
49 undefine([AC_TYPE_NAME])dnl
50 undefine([AC_CV_NAME])dnl
54 dnl JK_PREFIX_IF_MISSING(variable, prefix)
56 dnl Prefix all tokens in a variable with "prefix" unless
57 dnl it is already there.
59 AC_DEFUN([JK_PREFIX_IF_MISSING], [
65 jk_new_val="$jk_new_val $i"
68 jk_new_val="$jk_new_val $2$i"
73 if test $jk_val_changed = "1"; then
74 AC_MSG_NOTICE(tokens in $1 have been prefixed with '[$2]')
79 dnl Iteratively interpolate the contents of the second argument
80 dnl until interpolation offers no new result. Then assign the
81 dnl final result to $1.
88 dnl JK_EXPAND_VAR(fraz, $baz)
89 dnl $fraz is now "1/2/3"
91 AC_DEFUN([JK_EXPAND_VAR], [
94 while test "x${jk_cur}" != "x${jk_last}";
97 jk_cur=`eval "echo ${jk_cur}"`
103 dnl JK_CONFIG_NICE(filename)
105 dnl Saves a snapshot of the configure command-line for later reuse
107 AC_DEFUN([JK_CONFIG_NICE], [
112 # Created by configure
115 if test -n "$CC"; then
116 echo "CC=\"$CC\"; export CC" >> $1
118 if test -n "$CFLAGS"; then
119 echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1
121 if test -n "$CPPFLAGS"; then
122 echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1
124 if test -n "$LDFLAGS"; then
125 echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1
127 if test -n "$LTFLAGS"; then
128 echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> $1
130 if test -n "$LIBS"; then
131 echo "LIBS=\"$LIBS\"; export LIBS" >> $1
133 if test -n "$INCLUDES"; then
134 echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1
136 if test -n "$NOTEST_CFLAGS"; then
137 echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1
139 if test -n "$NOTEST_CPPFLAGS"; then
140 echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1
142 if test -n "$NOTEST_LDFLAGS"; then
143 echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1
145 if test -n "$NOTEST_LIBS"; then
146 echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1
149 # Retrieve command-line arguments.
150 eval "set x $[0] $ac_configure_args"
155 JK_EXPAND_VAR(arg, $arg)
156 echo "\"[$]arg\" \\" >> $1