bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / native / scripts / build / jk_common.m4
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
8 dnl
9 dnl     http://www.apache.org/licenses/LICENSE-2.0
10 dnl
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.
16
17 dnl
18 dnl jk_common.m4: JK's general-purpose autoconf macros
19 dnl Mostly taken from APR.
20 dnl
21
22 dnl
23 dnl JK_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])
24 dnl
25 dnl A variant of AC_CHECK_SIZEOF which allows the checking of
26 dnl sizes of non-builtin types
27 dnl
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
34 changequote([, ])dnl
35 AC_MSG_CHECKING(size of $2)
36 AC_CACHE_VAL(AC_CV_NAME,
37 [AC_TRY_RUN([#include <stdio.h>
38 $1
39 main()
40 {
41   FILE *f=fopen("conftestval","w");
42   if (!f) exit(1);
43   fprintf(f, "%d\n", sizeof($2));
44   exit(0);
45 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,
46 AC_CV_NAME=$3))])dnl
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
51 ])
52
53 dnl
54 dnl JK_PREFIX_IF_MISSING(variable, prefix)
55 dnl
56 dnl Prefix all tokens in a variable with "prefix" unless
57 dnl it is already there.
58 dnl
59 AC_DEFUN([JK_PREFIX_IF_MISSING], [
60   jk_new_val=""
61   jk_val_changed=0
62   for i in $$1; do
63     case $i in
64       $2*)
65         jk_new_val="$jk_new_val $i"
66         ;;
67       *)
68         jk_new_val="$jk_new_val $2$i"
69         jk_val_changed=1
70         ;;
71     esac
72   done
73   if test $jk_val_changed = "1"; then
74     AC_MSG_NOTICE(tokens in $1 have been prefixed with '[$2]')
75     $1=$jk_new_val
76   fi
77 ]) dnl
78
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.
82 dnl
83 dnl Example:
84 dnl
85 dnl foo=1
86 dnl bar='${foo}/2'
87 dnl baz='${bar}/3'
88 dnl JK_EXPAND_VAR(fraz, $baz)
89 dnl   $fraz is now "1/2/3"
90 dnl 
91 AC_DEFUN([JK_EXPAND_VAR], [
92 jk_last=
93 jk_cur="$2"
94 while test "x${jk_cur}" != "x${jk_last}";
95 do
96   jk_last="${jk_cur}"
97   jk_cur=`eval "echo ${jk_cur}"`
98 done
99 $1="${jk_cur}"
100 ])
101
102 dnl
103 dnl JK_CONFIG_NICE(filename)
104 dnl
105 dnl Saves a snapshot of the configure command-line for later reuse
106 dnl
107 AC_DEFUN([JK_CONFIG_NICE], [
108   rm -f $1
109   cat >$1<<EOF
110 #! /bin/sh
111 #
112 # Created by configure
113
114 EOF
115   if test -n "$CC"; then
116     echo "CC=\"$CC\"; export CC" >> $1
117   fi
118   if test -n "$CFLAGS"; then
119     echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1
120   fi
121   if test -n "$CPPFLAGS"; then
122     echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1
123   fi
124   if test -n "$LDFLAGS"; then
125     echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1
126   fi
127   if test -n "$LTFLAGS"; then
128     echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> $1
129   fi
130   if test -n "$LIBS"; then
131     echo "LIBS=\"$LIBS\"; export LIBS" >> $1
132   fi
133   if test -n "$INCLUDES"; then
134     echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1
135   fi
136   if test -n "$NOTEST_CFLAGS"; then
137     echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1
138   fi
139   if test -n "$NOTEST_CPPFLAGS"; then
140     echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1
141   fi
142   if test -n "$NOTEST_LDFLAGS"; then
143     echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1
144   fi
145   if test -n "$NOTEST_LIBS"; then
146     echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1
147   fi
148
149   # Retrieve command-line arguments.
150   eval "set x $[0] $ac_configure_args"
151   shift
152
153   for arg
154   do
155     JK_EXPAND_VAR(arg, $arg)
156     echo "\"[$]arg\" \\" >> $1
157   done
158   echo '"[$]@"' >> $1
159   chmod +x $1
160 ])dnl