]> git.ipfire.org Git - thirdparty/squid.git/blame - acinclude/squid-util.m4
Author: Various Translators
[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],[
36$1_CFLAGS="${CFLAGS}"
37$1_CXXFLAGS="${CXXFLAGS}"
38$1_LDFLAGS="${LDFLAGS}"
39$1_LIBS="${LIBS}"
bee906c3
FC
40$1_CC="${CC}"
41$1_CXX="${CXX}"
fa522425
FC
42$1_squid_saved_vars="$2"
43for squid_util_var_tosave in $2
44do
45 squid_util_var_tosave2="$1_${squid_util_var_tosave}"
46 eval "${squid_util_var_tosave2}=\"${squid_util_var_tosave}\""
47done
48])
49
50dnl commit the state changes: deleting the temporary state defined in SQUID_STATE_SAVE
51dnl with the same prefix. It's not necessary to specify the extra variables passed
52dnl to SQUID_STATE_SAVE again, they will be automatically reclaimed.
53AC_DEFUN([SQUID_STATE_COMMIT],[
54unset $1_CFLAGS
018a3298 55unset $1_CXXFLAGS
fa522425
FC
56unset $1_LDFLAGS
57unset $1_LIBS
50fbcbd6
FC
58unset $1_CC
59unset $1_CXX
fa522425
FC
60for squid_util_var_tosave in $$1_squid_saved_vars
61do
62 unset ${squid_util_var_tosave2}
63done
64])
65
66dnl rollback state to the call of SQUID_STATE_SAVE with the same namespace argument.
67dnl all temporary state will be cleared, including the custom variables specified
68dnl at call time. It's not necessary to explicitly name them, they will be automatically
69dnl cleared.
70AC_DEFUN([SQUID_STATE_ROLLBACK],[
71CFLAGS="${$1_CFLAGS}"
72CXXFLAGS="${$1_CXXFLAGS}"
73LDFLAGS="${$1_LDFLAGS}"
74LIBS="${$1_LIBS}"
50fbcbd6
FC
75CC="${$1_CC}"
76CXX="${$1_CXX}"
fa522425
FC
77for squid_util_var_tosave in $$1_squid_saved_vars
78do
79 squid_util_var_tosave2="$1_${squid_util_var_tosave}"
daed6927 80 eval "${squid_util_var_tosave}=\"${${squid_util_var_tosave2}}\""
fa522425
FC
81done
82SQUID_STATE_COMMIT($1)
83])
84
50fbcbd6
FC
85
86dnl look for modules in the base-directory supplied as argument.
9d6186b1
FC
87dnl fill-in the variable pointed-to by the second argument with the
88dnl space-separated list of modules
50fbcbd6 89AC_DEFUN([SQUID_LOOK_FOR_MODULES],[
26ffc057 90$2=""
50fbcbd6
FC
91for dir in $1/*; do
92 module="`basename $dir`"
93 if test -d "$dir" && test "$module" != CVS; then
94 $2="$$2 $module"
95 fi
96done
97])
d235bc84
FC
98
99dnl remove duplicates out of a list.
100dnl dnl argument is the name of a variable to be checked and cleaned up
101AC_DEFUN([SQUID_CLEANUP_MODULES_LIST],[
102squid_cleanup_tmp_outlist=""
103for squid_cleanup_tmp in $$1
104do
105 squid_cleanup_tmp_dupe=0
106 for squid_cleanup_tmp2 in $squid_cleanup_tmp_outlist
107 do
108 if test "$squid_cleanup_tmp" = "$squid_cleanup_tmp2"; then
109 squid_cleanup_tmp_dupe=1
110 break
111 fi
112 done
113 if test $squid_cleanup_tmp_dupe -eq 0; then
114 squid_cleanup_tmp_outlist="${squid_cleanup_tmp_outlist} $squid_cleanup_tmp"
115 fi
116done
117$1=$squid_cleanup_tmp_outlist
118unset squid_cleanup_tmp_outlist
119unset squid_cleanup_tmp_dupe
120unset squid_cleanup_tmp2
121unset squid_cleanup_tmp
122])
123
124dnl check that all the modules supplied as a whitespace-separated list (second
125dnl argument) exist as members of the basedir passed as first argument
dc299f29
FC
126dnl call AC_MESG_ERROR if any module does not exist. Also sets individual variables
127dnl named $2_modulename to value "yes"
128dnl e.g. SQUID_CHECK_EXISTING_MODULES([$srcdir/src/fs],[foo_module_candidates])
129dnl where $foo_module_candidates is "foo bar gazonk"
130dnl checks whether $srcdir/src/fs/{foo,bar,gazonk} exist and are all dirs
131dnl AND sets $foo_module_candidates_foo, $foo_module_candidates_bar
132dnl and $foo_module_candidates_gazonk to "yes"
d235bc84 133AC_DEFUN([SQUID_CHECK_EXISTING_MODULES],[
dc299f29 134 for squid_module_check_exist_tmp in $$2
d235bc84 135 do
dc299f29 136 if test -d $1/$squid_module_check_exist_tmp
d235bc84 137 then
dc299f29
FC
138 eval "$2_$squid_module_check_exist_tmp='yes'"
139 #echo "defining $2_$squid_module_check_exist_tmp"
140 else
d235bc84
FC
141 AC_MSG_ERROR([$squid_module_check_exist_tmp not found in $1])
142 fi
143 done
144])
6d1c1ab1
FC
145
146dnl lowercases the contents of the variable whose name is passed by argument
40503c27 147AC_DEFUN([SQUID_TOLOWER_VAR_CONTENTS],[
6d1c1ab1
FC
148 $1=`echo $$1|tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
149])
150
151dnl uppercases the contents of the variable whose name is passed by argument
152AC_DEFUN([SQUID_TOUPPER_VAR_CONTENTS],[
153 $1=`echo $$1|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
154])
8075a4da 155
0067eb06 156dnl like AC_DEFINE, but it defines the value to 0 or 1 using well-known textual
8075a4da
FC
157dnl conventions:
158dnl 1: "yes", "true", 1
159dnl 0: "no" , "false", 0, ""
160dnl aborts with an error for unknown values
0067eb06 161AC_DEFUN([SQUID_DEFINE_BOOL],[
8075a4da
FC
162squid_tmp_define=""
163case "$2" in
164 yes|true|1) squid_tmp_define="1" ;;
0067eb06 165 no|false|0|"") squid_tmp_define="0" ;;
45c41a07 166 *) AC_MSG_ERROR([SQUID_DEFINE[]_BOOL: unrecognized value for $1: '$2']) ;;
8075a4da
FC
167esac
168ifelse([$#],3,
169 [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define],[$3])],
170 [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define])]
171)
172unset squid_tmp_define
173])
1d87b6b3
FC
174
175dnl aborts with an error specified as the second argument if the first argument doesn't
176dnl contain either "yes" or "no"
177AC_DEFUN([SQUID_YESNO],[
178if test "$1" != "yes" -a "$1" != "no" ; then
179 AC_MSG_ERROR([$2])
180fi
181])
4fe75473
FC
182
183AC_DEFUN([SQUID_EMBED_BUILD_INFO],[
184 AC_ARG_ENABLE([build-info],
185 AS_HELP_STRING([--enable-build-info="build info string"],
b9c250bf 186 [Add an additional string in the output of "squid -v".
4fe75473
FC
187 Default is not to add anything. If the string is not specified,
188 tries to determine nick and revision number of the current
189 bazaar branch]),[
190 case "$enableval" in
191 no) ${TRUE}
192 ;;
193 yes)
194 if test -d "${srcdir}/.bzr"; then
195 AC_PATH_PROG(BZR,bzr,$FALSE)
196 squid_bzr_branch_nick=`${BZR} nick 2>/dev/null`
197 if test $? -eq 0 -a "x$squid_bzr_branch_nick" != "x"; then
198 squid_bzr_branch_revno=`${BZR} revno 2>/dev/null | sed 's/\"//g'`
199 fi
200 if test $? -eq 0 -a "x$squid_bzr_branch_revno" != "x"; then
201 ${BZR} diff 2>&1 >/dev/null
202 if test $? -eq 1; then
203 squid_bzr_branch_revno="$squid_bzr_branch_revno+changes"
204 fi
205 fi
206 if test "x$squid_bzr_branch_revno" != "x"; then
207 squid_build_info="Built branch: ${squid_bzr_branch_nick}-r${squid_bzr_branch_revno}"
208 fi
209 fi
210 ;;
211 *)
212 squid_build_info=$enableval
213 ;;
214 esac
215 ])
216 if test "x${squid_build_info:=no}" != "xno"; then
217 AC_DEFINE_UNQUOTED([SQUID_BUILD_INFO],["$squid_build_info"],
218 [Squid extended build info field for "squid -v" output])
219 fi
220])