2 dnl AUTHOR: Francesco Chemolli
4 dnl SQUID Web Proxy Cache http://www.squid-cache.org/
5 dnl ----------------------------------------------------------
6 dnl Squid is the result of efforts by numerous individuals from
7 dnl the Internet community; see the CONTRIBUTORS file for full
8 dnl details. Many organizations have provided support for Squid's
9 dnl development; see the SPONSORS file for full details. Squid is
10 dnl Copyrighted (C) 2001 by the Regents of the University of
11 dnl California; see the COPYRIGHT file for full details. Squid
12 dnl incorporates software developed and/or copyrighted by other
13 dnl sources; see the CREDITS file for full details.
15 dnl This program is free software; you can redistribute it and/or modify
16 dnl it under the terms of the GNU General Public License as published by
17 dnl the Free Software Foundation; either version 2 of the License, or
18 dnl (at your option) any later version.
20 dnl This program is distributed in the hope that it will be useful,
21 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 dnl GNU General Public License for more details.
25 dnl You should have received a copy of the GNU General Public License
26 dnl along with this program; if not, write to the Free Software
27 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
29 dnl save main environment variables to variables to the namespace defined by the
30 dnl first argument (prefix)
31 dnl e.g. SQUID_SAVEFLAGS([foo]) will save CFLAGS to foo_CFLAGS etc.
32 dnl Saved variables are:
33 dnl CFLAGS, CXXFLAGS, LDFLAGS, LIBS plus any variables specified as
35 AC_DEFUN([SQUID_STATE_SAVE],[
36 # save state, key is $1
38 $1_CXXFLAGS="${CXXFLAGS}"
39 $1_LDFLAGS="${LDFLAGS}"
43 $1_squid_saved_vars="$2"
44 for squid_util_var_tosave in $$1_squid_saved_vars
46 squid_util_var_tosave2="$1_${squid_util_var_tosave}"
47 eval "${squid_util_var_tosave2}=\"${squid_util_var_tosave}\""
51 dnl commit the state changes: deleting the temporary state defined in SQUID_STATE_SAVE
52 dnl with the same prefix. It's not necessary to specify the extra variables passed
53 dnl to SQUID_STATE_SAVE again, they will be automatically reclaimed.
54 AC_DEFUN([SQUID_STATE_COMMIT],[
55 # commit state, key is $1
62 for squid_util_var_tosave in $$1_squid_saved_vars
64 unset ${squid_util_var_tosave}
68 dnl rollback state to the call of SQUID_STATE_SAVE with the same namespace argument.
69 dnl all temporary state will be cleared, including the custom variables specified
70 dnl at call time. It's not necessary to explicitly name them, they will be automatically
72 AC_DEFUN([SQUID_STATE_ROLLBACK],[
73 # rollback state, key is $1
75 CXXFLAGS="${$1_CXXFLAGS}"
76 LDFLAGS="${$1_LDFLAGS}"
80 for squid_util_var_tosave in $$1_squid_saved_vars
82 squid_util_var_tosave2="\$$1_${squid_util_var_tosave}"
83 eval "$squid_util_var_tosave=\"${squid_util_var_tosave2}\""
85 SQUID_STATE_COMMIT($1)
89 dnl look for modules in the base-directory supplied as argument.
90 dnl fill-in the variable pointed-to by the second argument with the
91 dnl space-separated list of modules
92 AC_DEFUN([SQUID_LOOK_FOR_MODULES],[
95 module="`basename $dir`"
96 if test -d "$dir" && test "$module" != CVS; then
102 dnl remove duplicates out of a list.
103 dnl dnl argument is the name of a variable to be checked and cleaned up
104 AC_DEFUN([SQUID_CLEANUP_MODULES_LIST],[
105 squid_cleanup_tmp_outlist=""
106 for squid_cleanup_tmp in $$1
108 squid_cleanup_tmp_dupe=0
109 for squid_cleanup_tmp2 in $squid_cleanup_tmp_outlist
111 if test "$squid_cleanup_tmp" = "$squid_cleanup_tmp2"; then
112 squid_cleanup_tmp_dupe=1
116 if test $squid_cleanup_tmp_dupe -eq 0; then
117 squid_cleanup_tmp_outlist="${squid_cleanup_tmp_outlist} $squid_cleanup_tmp"
120 $1=$squid_cleanup_tmp_outlist
121 unset squid_cleanup_tmp_outlist
122 unset squid_cleanup_tmp_dupe
123 unset squid_cleanup_tmp2
124 unset squid_cleanup_tmp
127 dnl check that all the modules supplied as a whitespace-separated list (second
128 dnl argument) exist as members of the basedir passed as first argument
129 dnl call AC_MESG_ERROR if any module does not exist. Also sets individual variables
130 dnl named $2_modulename to value "yes"
131 dnl e.g. SQUID_CHECK_EXISTING_MODULES([$srcdir/src/fs],[foo_module_candidates])
132 dnl where $foo_module_candidates is "foo bar gazonk"
133 dnl checks whether $srcdir/src/fs/{foo,bar,gazonk} exist and are all dirs
134 dnl AND sets $foo_module_candidates_foo, $foo_module_candidates_bar
135 dnl and $foo_module_candidates_gazonk to "yes"
136 AC_DEFUN([SQUID_CHECK_EXISTING_MODULES],[
137 for squid_module_check_exist_tmp in $$2
139 if test -d $1/$squid_module_check_exist_tmp
141 eval "$2_$squid_module_check_exist_tmp='yes'"
142 #echo "defining $2_$squid_module_check_exist_tmp"
144 AC_MSG_ERROR([$squid_module_check_exist_tmp not found in $1])
149 dnl lowercases the contents of the variable whose name is passed by argument
150 AC_DEFUN([SQUID_TOLOWER_VAR_CONTENTS],[
151 $1=`echo $$1|tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
154 dnl uppercases the contents of the variable whose name is passed by argument
155 AC_DEFUN([SQUID_TOUPPER_VAR_CONTENTS],[
156 $1=`echo $$1|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
159 dnl like AC_DEFINE, but it defines the value to 0 or 1 using well-known textual
161 dnl 1: "yes", "true", 1
162 dnl 0: "no" , "false", 0, ""
163 dnl aborts with an error for unknown values
164 AC_DEFUN([SQUID_DEFINE_BOOL],[
167 yes|true|1) squid_tmp_define="1" ;;
168 no|false|0|"") squid_tmp_define="0" ;;
169 *) AC_MSG_ERROR([SQUID_DEFINE[]_BOOL: unrecognized value for $1: '$2']) ;;
172 [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define],[$3])],
173 [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define])]
175 unset squid_tmp_define
178 dnl aborts with an error specified as the second argument if the first argument doesn't
179 dnl contain either "yes" or "no"
180 AC_DEFUN([SQUID_YESNO],[
181 if test "$1" != "yes" -a "$1" != "no" ; then
186 AC_DEFUN([SQUID_EMBED_BUILD_INFO],[
187 AC_ARG_ENABLE([build-info],
188 AS_HELP_STRING([--enable-build-info="build info string"],
189 [Add an additional string in the output of "squid -v".
190 Default is not to add anything. If the string is not specified,
191 tries to determine nick and revision number of the current
197 if test -d "${srcdir}/.bzr"; then
198 AC_PATH_PROG(BZR,bzr,$FALSE)
199 squid_bzr_branch_nick=`${BZR} nick 2>/dev/null`
200 if test $? -eq 0 -a "x$squid_bzr_branch_nick" != "x"; then
201 squid_bzr_branch_revno=`${BZR} revno 2>/dev/null | sed 's/\"//g'`
203 if test $? -eq 0 -a "x$squid_bzr_branch_revno" != "x"; then
204 ${BZR} diff 2>&1 >/dev/null
205 if test $? -eq 1; then
206 squid_bzr_branch_revno="$squid_bzr_branch_revno+changes"
209 if test "x$squid_bzr_branch_revno" != "x"; then
210 squid_build_info="Built branch: ${squid_bzr_branch_nick}-r${squid_bzr_branch_revno}"
215 squid_build_info=$enableval
219 if test "x${squid_build_info:=no}" != "xno"; then
220 AC_DEFINE_UNQUOTED([SQUID_BUILD_INFO],["$squid_build_info"],
221 [Squid extended build info field for "squid -v" output])
225 dnl like AC_SEARCH_LIBS, with an extra argument which is
226 dnl a prefix to the test program
227 AC_DEFUN([SQUID_SEARCH_LIBS],
228 [AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
229 AC_CACHE_CHECK([for library containing $1], [ac_Search],
230 [ac_func_search_save_LIBS=$LIBS
231 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$6], [$1()])])
232 for ac_lib in '' $2; do
233 if test -z "$ac_lib"; then
234 ac_res="none required"
237 LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
239 AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
240 AS_VAR_SET_IF([ac_Search], [break])
242 AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])
244 LIBS=$ac_func_search_save_LIBS])
245 ac_res=AS_VAR_GET([ac_Search])
246 AS_IF([test "$ac_res" != no],
247 [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
250 AS_VAR_POPDEF([ac_Search])dnl