]> git.ipfire.org Git - thirdparty/squid.git/blame - acinclude/squid-util.m4
Typo in rev.12783 and remove MinGW specific hacks
[thirdparty/squid.git] / acinclude / squid-util.m4
CommitLineData
fa522425
FC
1dnl
2dnl AUTHOR: Francesco Chemolli
3dnl
4dnl SQUID Web Proxy Cache http://www.squid-cache.org/
5dnl ----------------------------------------------------------
6dnl Squid is the result of efforts by numerous individuals from
7dnl the Internet community; see the CONTRIBUTORS file for full
8dnl details. Many organizations have provided support for Squid's
9dnl development; see the SPONSORS file for full details. Squid is
10dnl Copyrighted (C) 2001 by the Regents of the University of
11dnl California; see the COPYRIGHT file for full details. Squid
12dnl incorporates software developed and/or copyrighted by other
13dnl sources; see the CREDITS file for full details.
14dnl
15dnl This program is free software; you can redistribute it and/or modify
16dnl it under the terms of the GNU General Public License as published by
17dnl the Free Software Foundation; either version 2 of the License, or
18dnl (at your option) any later version.
19dnl
20dnl This program is distributed in the hope that it will be useful,
21dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23dnl GNU General Public License for more details.
24dnl
25dnl You should have received a copy of the GNU General Public License
26dnl along with this program; if not, write to the Free Software
27dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28
29dnl save main environment variables to variables to the namespace defined by the
30dnl first argument (prefix)
31dnl e.g. SQUID_SAVEFLAGS([foo]) will save CFLAGS to foo_CFLAGS etc.
32dnl Saved variables are:
33dnl CFLAGS, CXXFLAGS, LDFLAGS, LIBS plus any variables specified as
34dnl second argument
35AC_DEFUN([SQUID_STATE_SAVE],[
820c5a3c 36# save state, key is $1
fa522425
FC
37$1_CFLAGS="${CFLAGS}"
38$1_CXXFLAGS="${CXXFLAGS}"
39$1_LDFLAGS="${LDFLAGS}"
40$1_LIBS="${LIBS}"
bee906c3
FC
41$1_CC="${CC}"
42$1_CXX="${CXX}"
fa522425 43$1_squid_saved_vars="$2"
4f0128b6 44for squid_util_var_tosave in $$1_squid_saved_vars
fa522425
FC
45do
46 squid_util_var_tosave2="$1_${squid_util_var_tosave}"
47 eval "${squid_util_var_tosave2}=\"${squid_util_var_tosave}\""
48done
49])
50
51dnl commit the state changes: deleting the temporary state defined in SQUID_STATE_SAVE
52dnl with the same prefix. It's not necessary to specify the extra variables passed
53dnl to SQUID_STATE_SAVE again, they will be automatically reclaimed.
54AC_DEFUN([SQUID_STATE_COMMIT],[
820c5a3c 55# commit state, key is $1
fa522425 56unset $1_CFLAGS
018a3298 57unset $1_CXXFLAGS
fa522425
FC
58unset $1_LDFLAGS
59unset $1_LIBS
50fbcbd6
FC
60unset $1_CC
61unset $1_CXX
fa522425
FC
62for squid_util_var_tosave in $$1_squid_saved_vars
63do
820c5a3c 64 unset ${squid_util_var_tosave}
fa522425
FC
65done
66])
67
68dnl rollback state to the call of SQUID_STATE_SAVE with the same namespace argument.
69dnl all temporary state will be cleared, including the custom variables specified
70dnl at call time. It's not necessary to explicitly name them, they will be automatically
71dnl cleared.
72AC_DEFUN([SQUID_STATE_ROLLBACK],[
820c5a3c 73# rollback state, key is $1
fa522425
FC
74CFLAGS="${$1_CFLAGS}"
75CXXFLAGS="${$1_CXXFLAGS}"
76LDFLAGS="${$1_LDFLAGS}"
77LIBS="${$1_LIBS}"
50fbcbd6
FC
78CC="${$1_CC}"
79CXX="${$1_CXX}"
fa522425
FC
80for squid_util_var_tosave in $$1_squid_saved_vars
81do
820c5a3c
FC
82 squid_util_var_tosave2="\$$1_${squid_util_var_tosave}"
83 eval "$squid_util_var_tosave=\"${squid_util_var_tosave2}\""
fa522425
FC
84done
85SQUID_STATE_COMMIT($1)
86])
87
50fbcbd6
FC
88
89dnl look for modules in the base-directory supplied as argument.
9d6186b1
FC
90dnl fill-in the variable pointed-to by the second argument with the
91dnl space-separated list of modules
50fbcbd6 92AC_DEFUN([SQUID_LOOK_FOR_MODULES],[
26ffc057 93$2=""
50fbcbd6
FC
94for dir in $1/*; do
95 module="`basename $dir`"
96 if test -d "$dir" && test "$module" != CVS; then
97 $2="$$2 $module"
98 fi
99done
100])
d235bc84
FC
101
102dnl remove duplicates out of a list.
103dnl dnl argument is the name of a variable to be checked and cleaned up
104AC_DEFUN([SQUID_CLEANUP_MODULES_LIST],[
105squid_cleanup_tmp_outlist=""
106for squid_cleanup_tmp in $$1
107do
108 squid_cleanup_tmp_dupe=0
109 for squid_cleanup_tmp2 in $squid_cleanup_tmp_outlist
110 do
111 if test "$squid_cleanup_tmp" = "$squid_cleanup_tmp2"; then
112 squid_cleanup_tmp_dupe=1
113 break
114 fi
115 done
116 if test $squid_cleanup_tmp_dupe -eq 0; then
117 squid_cleanup_tmp_outlist="${squid_cleanup_tmp_outlist} $squid_cleanup_tmp"
118 fi
119done
120$1=$squid_cleanup_tmp_outlist
121unset squid_cleanup_tmp_outlist
122unset squid_cleanup_tmp_dupe
123unset squid_cleanup_tmp2
124unset squid_cleanup_tmp
125])
126
127dnl check that all the modules supplied as a whitespace-separated list (second
128dnl argument) exist as members of the basedir passed as first argument
dc299f29
FC
129dnl call AC_MESG_ERROR if any module does not exist. Also sets individual variables
130dnl named $2_modulename to value "yes"
131dnl e.g. SQUID_CHECK_EXISTING_MODULES([$srcdir/src/fs],[foo_module_candidates])
132dnl where $foo_module_candidates is "foo bar gazonk"
133dnl checks whether $srcdir/src/fs/{foo,bar,gazonk} exist and are all dirs
134dnl AND sets $foo_module_candidates_foo, $foo_module_candidates_bar
135dnl and $foo_module_candidates_gazonk to "yes"
d235bc84 136AC_DEFUN([SQUID_CHECK_EXISTING_MODULES],[
dc299f29 137 for squid_module_check_exist_tmp in $$2
d235bc84 138 do
dc299f29 139 if test -d $1/$squid_module_check_exist_tmp
d235bc84 140 then
dc299f29
FC
141 eval "$2_$squid_module_check_exist_tmp='yes'"
142 #echo "defining $2_$squid_module_check_exist_tmp"
143 else
d235bc84
FC
144 AC_MSG_ERROR([$squid_module_check_exist_tmp not found in $1])
145 fi
146 done
147])
6d1c1ab1
FC
148
149dnl lowercases the contents of the variable whose name is passed by argument
40503c27 150AC_DEFUN([SQUID_TOLOWER_VAR_CONTENTS],[
6d1c1ab1
FC
151 $1=`echo $$1|tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
152])
153
154dnl uppercases the contents of the variable whose name is passed by argument
155AC_DEFUN([SQUID_TOUPPER_VAR_CONTENTS],[
156 $1=`echo $$1|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
157])
8075a4da 158
0067eb06 159dnl like AC_DEFINE, but it defines the value to 0 or 1 using well-known textual
8075a4da
FC
160dnl conventions:
161dnl 1: "yes", "true", 1
162dnl 0: "no" , "false", 0, ""
163dnl aborts with an error for unknown values
0067eb06 164AC_DEFUN([SQUID_DEFINE_BOOL],[
8075a4da
FC
165squid_tmp_define=""
166case "$2" in
167 yes|true|1) squid_tmp_define="1" ;;
0067eb06 168 no|false|0|"") squid_tmp_define="0" ;;
45c41a07 169 *) AC_MSG_ERROR([SQUID_DEFINE[]_BOOL: unrecognized value for $1: '$2']) ;;
8075a4da
FC
170esac
171ifelse([$#],3,
172 [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define],[$3])],
173 [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define])]
174)
175unset squid_tmp_define
176])
1d87b6b3
FC
177
178dnl aborts with an error specified as the second argument if the first argument doesn't
179dnl contain either "yes" or "no"
180AC_DEFUN([SQUID_YESNO],[
181if test "$1" != "yes" -a "$1" != "no" ; then
182 AC_MSG_ERROR([$2])
183fi
184])
4fe75473
FC
185
186AC_DEFUN([SQUID_EMBED_BUILD_INFO],[
187 AC_ARG_ENABLE([build-info],
188 AS_HELP_STRING([--enable-build-info="build info string"],
b9c250bf 189 [Add an additional string in the output of "squid -v".
4fe75473
FC
190 Default is not to add anything. If the string is not specified,
191 tries to determine nick and revision number of the current
192 bazaar branch]),[
193 case "$enableval" in
194 no) ${TRUE}
195 ;;
196 yes)
197 if test -d "${srcdir}/.bzr"; then
198 AC_PATH_PROG(BZR,bzr,$FALSE)
aa73ca74 199 squid_bzr_branch_nick=`cd ${srcdir} && ${BZR} nick 2>/dev/null`
4fe75473 200 if test $? -eq 0 -a "x$squid_bzr_branch_nick" != "x"; then
aa73ca74 201 squid_bzr_branch_revno=`cd ${srcdir} && ${BZR} revno 2>/dev/null | sed 's/\"//g'`
4fe75473
FC
202 fi
203 if test $? -eq 0 -a "x$squid_bzr_branch_revno" != "x"; then
aa73ca74 204 sh -c "cd ${srcdir} && ${BZR} diff 2>&1 >/dev/null"
4fe75473
FC
205 if test $? -eq 1; then
206 squid_bzr_branch_revno="$squid_bzr_branch_revno+changes"
207 fi
208 fi
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}"
211 fi
212 fi
213 ;;
214 *)
215 squid_build_info=$enableval
216 ;;
217 esac
218 ])
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])
222 fi
223])
391f0bac
FC
224
225dnl like AC_SEARCH_LIBS, with an extra argument which is
226dnl a prefix to the test program
227AC_DEFUN([SQUID_SEARCH_LIBS],
228[AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
229AC_CACHE_CHECK([for library containing $1], [ac_Search],
230[ac_func_search_save_LIBS=$LIBS
231AC_LANG_CONFTEST([AC_LANG_PROGRAM([$6], [$1()])])
232for ac_lib in '' $2; do
233 if test -z "$ac_lib"; then
234 ac_res="none required"
235 else
236 ac_res=-l$ac_lib
237 LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
238 fi
239 AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
240 AS_VAR_SET_IF([ac_Search], [break])
241done
242AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])
243rm conftest.$ac_ext
244LIBS=$ac_func_search_save_LIBS])
245ac_res=AS_VAR_GET([ac_Search])
246AS_IF([test "$ac_res" != no],
247 [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
248 $3],
249 [$4])
250AS_VAR_POPDEF([ac_Search])dnl
251])
5a0c5a92
AJ
252
253dnl Check for Cyrus SASL
254AC_DEFUN([SQUID_CHECK_SASL],[
255 squid_sasl_present="auto"
256 AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
257 AC_CHECK_LIB(sasl2,sasl_errstring,[LIBSASL="-lsasl2"],[
258 AC_CHECK_LIB(sasl,sasl_errstring,[LIBSASL="-lsasl"], [
259 squid_sasl_present="no"
260 ])
261 ])
262 case "$squid_host_os" in
263 Darwin)
264 if test "$ac_cv_lib_sasl2_sasl_errstring" = "yes" ; then
265 AC_DEFINE(HAVE_SASL_DARWIN,1,[Define to 1 if Mac Darwin without sasl.h])
266 echo "checking for MAC Darwin without sasl.h ... yes"
267 squid_sasl_present="yes"
268 else
269 echo "checking for MAC Darwin without sasl.h ... no"
270 squid_sasl_present="no"
271 fi
272 ;;
273 esac
274 if test "x$squid_sasl_present" != "yes"; then
275 AC_MSG_WARN(Neither SASL nor SASL2 found)
276 fi
277 AC_SUBST(LIBSASL)
278])