]>
Commit | Line | Data |
---|---|---|
77b1029d | 1 | ## Copyright (C) 1996-2020 The Squid Software Foundation and contributors |
5d2e6f19 AJ |
2 | ## |
3 | ## Squid software is distributed under GPLv2+ license and includes | |
4 | ## contributions from numerous individuals and organizations. | |
5 | ## Please see the COPYING and CONTRIBUTORS files for details. | |
6 | ## | |
fa522425 FC |
7 | |
8 | dnl save main environment variables to variables to the namespace defined by the | |
9 | dnl first argument (prefix) | |
10 | dnl e.g. SQUID_SAVEFLAGS([foo]) will save CFLAGS to foo_CFLAGS etc. | |
11 | dnl Saved variables are: | |
12 | dnl CFLAGS, CXXFLAGS, LDFLAGS, LIBS plus any variables specified as | |
13 | dnl second argument | |
14 | AC_DEFUN([SQUID_STATE_SAVE],[ | |
820c5a3c | 15 | # save state, key is $1 |
fa522425 FC |
16 | $1_CFLAGS="${CFLAGS}" |
17 | $1_CXXFLAGS="${CXXFLAGS}" | |
18 | $1_LDFLAGS="${LDFLAGS}" | |
19 | $1_LIBS="${LIBS}" | |
bee906c3 FC |
20 | $1_CC="${CC}" |
21 | $1_CXX="${CXX}" | |
7c760558 | 22 | $1_CPPFLAGS="${CPPFLAGS}" |
fa522425 | 23 | $1_squid_saved_vars="$2" |
4f0128b6 | 24 | for squid_util_var_tosave in $$1_squid_saved_vars |
fa522425 FC |
25 | do |
26 | squid_util_var_tosave2="$1_${squid_util_var_tosave}" | |
27 | eval "${squid_util_var_tosave2}=\"${squid_util_var_tosave}\"" | |
28 | done | |
29 | ]) | |
30 | ||
31 | dnl commit the state changes: deleting the temporary state defined in SQUID_STATE_SAVE | |
32 | dnl with the same prefix. It's not necessary to specify the extra variables passed | |
33 | dnl to SQUID_STATE_SAVE again, they will be automatically reclaimed. | |
34 | AC_DEFUN([SQUID_STATE_COMMIT],[ | |
820c5a3c | 35 | # commit state, key is $1 |
fa522425 | 36 | unset $1_CFLAGS |
018a3298 | 37 | unset $1_CXXFLAGS |
fa522425 FC |
38 | unset $1_LDFLAGS |
39 | unset $1_LIBS | |
50fbcbd6 FC |
40 | unset $1_CC |
41 | unset $1_CXX | |
7c760558 | 42 | unset $1_CPPFLAGS |
fa522425 FC |
43 | for squid_util_var_tosave in $$1_squid_saved_vars |
44 | do | |
820c5a3c | 45 | unset ${squid_util_var_tosave} |
fa522425 FC |
46 | done |
47 | ]) | |
48 | ||
49 | dnl rollback state to the call of SQUID_STATE_SAVE with the same namespace argument. | |
50 | dnl all temporary state will be cleared, including the custom variables specified | |
51 | dnl at call time. It's not necessary to explicitly name them, they will be automatically | |
52 | dnl cleared. | |
53 | AC_DEFUN([SQUID_STATE_ROLLBACK],[ | |
820c5a3c | 54 | # rollback state, key is $1 |
fa522425 FC |
55 | CFLAGS="${$1_CFLAGS}" |
56 | CXXFLAGS="${$1_CXXFLAGS}" | |
57 | LDFLAGS="${$1_LDFLAGS}" | |
58 | LIBS="${$1_LIBS}" | |
50fbcbd6 FC |
59 | CC="${$1_CC}" |
60 | CXX="${$1_CXX}" | |
7c760558 | 61 | CPPFLAGS="${$1_CPPFLAGS}" |
fa522425 FC |
62 | for squid_util_var_tosave in $$1_squid_saved_vars |
63 | do | |
820c5a3c FC |
64 | squid_util_var_tosave2="\$$1_${squid_util_var_tosave}" |
65 | eval "$squid_util_var_tosave=\"${squid_util_var_tosave2}\"" | |
fa522425 FC |
66 | done |
67 | SQUID_STATE_COMMIT($1) | |
68 | ]) | |
69 | ||
50fbcbd6 FC |
70 | |
71 | dnl look for modules in the base-directory supplied as argument. | |
9d6186b1 FC |
72 | dnl fill-in the variable pointed-to by the second argument with the |
73 | dnl space-separated list of modules | |
50fbcbd6 | 74 | AC_DEFUN([SQUID_LOOK_FOR_MODULES],[ |
26ffc057 | 75 | $2="" |
50fbcbd6 FC |
76 | for dir in $1/*; do |
77 | module="`basename $dir`" | |
78 | if test -d "$dir" && test "$module" != CVS; then | |
79 | $2="$$2 $module" | |
80 | fi | |
81 | done | |
82 | ]) | |
d235bc84 FC |
83 | |
84 | dnl remove duplicates out of a list. | |
61beade2 | 85 | dnl argument is the name of a variable to be checked and cleaned up |
d235bc84 FC |
86 | AC_DEFUN([SQUID_CLEANUP_MODULES_LIST],[ |
87 | squid_cleanup_tmp_outlist="" | |
88 | for squid_cleanup_tmp in $$1 | |
89 | do | |
90 | squid_cleanup_tmp_dupe=0 | |
91 | for squid_cleanup_tmp2 in $squid_cleanup_tmp_outlist | |
92 | do | |
93 | if test "$squid_cleanup_tmp" = "$squid_cleanup_tmp2"; then | |
94 | squid_cleanup_tmp_dupe=1 | |
95 | break | |
96 | fi | |
97 | done | |
98 | if test $squid_cleanup_tmp_dupe -eq 0; then | |
99 | squid_cleanup_tmp_outlist="${squid_cleanup_tmp_outlist} $squid_cleanup_tmp" | |
100 | fi | |
101 | done | |
102 | $1=$squid_cleanup_tmp_outlist | |
103 | unset squid_cleanup_tmp_outlist | |
104 | unset squid_cleanup_tmp_dupe | |
105 | unset squid_cleanup_tmp2 | |
106 | unset squid_cleanup_tmp | |
107 | ]) | |
108 | ||
109 | dnl check that all the modules supplied as a whitespace-separated list (second | |
110 | dnl argument) exist as members of the basedir passed as first argument | |
dc299f29 FC |
111 | dnl call AC_MESG_ERROR if any module does not exist. Also sets individual variables |
112 | dnl named $2_modulename to value "yes" | |
113 | dnl e.g. SQUID_CHECK_EXISTING_MODULES([$srcdir/src/fs],[foo_module_candidates]) | |
114 | dnl where $foo_module_candidates is "foo bar gazonk" | |
115 | dnl checks whether $srcdir/src/fs/{foo,bar,gazonk} exist and are all dirs | |
116 | dnl AND sets $foo_module_candidates_foo, $foo_module_candidates_bar | |
117 | dnl and $foo_module_candidates_gazonk to "yes" | |
d235bc84 | 118 | AC_DEFUN([SQUID_CHECK_EXISTING_MODULES],[ |
dc299f29 | 119 | for squid_module_check_exist_tmp in $$2 |
d235bc84 | 120 | do |
dc299f29 | 121 | if test -d $1/$squid_module_check_exist_tmp |
d235bc84 | 122 | then |
dc299f29 FC |
123 | eval "$2_$squid_module_check_exist_tmp='yes'" |
124 | #echo "defining $2_$squid_module_check_exist_tmp" | |
125 | else | |
d235bc84 FC |
126 | AC_MSG_ERROR([$squid_module_check_exist_tmp not found in $1]) |
127 | fi | |
128 | done | |
129 | ]) | |
6d1c1ab1 FC |
130 | |
131 | dnl lowercases the contents of the variable whose name is passed by argument | |
40503c27 | 132 | AC_DEFUN([SQUID_TOLOWER_VAR_CONTENTS],[ |
6d1c1ab1 FC |
133 | $1=`echo $$1|tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` |
134 | ]) | |
135 | ||
136 | dnl uppercases the contents of the variable whose name is passed by argument | |
137 | AC_DEFUN([SQUID_TOUPPER_VAR_CONTENTS],[ | |
138 | $1=`echo $$1|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` | |
139 | ]) | |
8075a4da | 140 | |
0067eb06 | 141 | dnl like AC_DEFINE, but it defines the value to 0 or 1 using well-known textual |
8075a4da FC |
142 | dnl conventions: |
143 | dnl 1: "yes", "true", 1 | |
144 | dnl 0: "no" , "false", 0, "" | |
145 | dnl aborts with an error for unknown values | |
0067eb06 | 146 | AC_DEFUN([SQUID_DEFINE_BOOL],[ |
8075a4da FC |
147 | squid_tmp_define="" |
148 | case "$2" in | |
149 | yes|true|1) squid_tmp_define="1" ;; | |
0067eb06 | 150 | no|false|0|"") squid_tmp_define="0" ;; |
45c41a07 | 151 | *) AC_MSG_ERROR([SQUID_DEFINE[]_BOOL: unrecognized value for $1: '$2']) ;; |
8075a4da FC |
152 | esac |
153 | ifelse([$#],3, | |
154 | [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define],[$3])], | |
155 | [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define])] | |
156 | ) | |
157 | unset squid_tmp_define | |
158 | ]) | |
1d87b6b3 FC |
159 | |
160 | dnl aborts with an error specified as the second argument if the first argument doesn't | |
161 | dnl contain either "yes" or "no" | |
162 | AC_DEFUN([SQUID_YESNO],[ | |
163 | if test "$1" != "yes" -a "$1" != "no" ; then | |
164 | AC_MSG_ERROR([$2]) | |
165 | fi | |
166 | ]) | |
4fe75473 FC |
167 | |
168 | AC_DEFUN([SQUID_EMBED_BUILD_INFO],[ | |
169 | AC_ARG_ENABLE([build-info], | |
170 | AS_HELP_STRING([--enable-build-info="build info string"], | |
b9c250bf | 171 | [Add an additional string in the output of "squid -v". |
4fe75473 FC |
172 | Default is not to add anything. If the string is not specified, |
173 | tries to determine nick and revision number of the current | |
174 | bazaar branch]),[ | |
175 | case "$enableval" in | |
176 | no) ${TRUE} | |
177 | ;; | |
178 | yes) | |
179 | if test -d "${srcdir}/.bzr"; then | |
180 | AC_PATH_PROG(BZR,bzr,$FALSE) | |
aa73ca74 | 181 | squid_bzr_branch_nick=`cd ${srcdir} && ${BZR} nick 2>/dev/null` |
4fe75473 | 182 | if test $? -eq 0 -a "x$squid_bzr_branch_nick" != "x"; then |
aa73ca74 | 183 | squid_bzr_branch_revno=`cd ${srcdir} && ${BZR} revno 2>/dev/null | sed 's/\"//g'` |
4fe75473 FC |
184 | fi |
185 | if test $? -eq 0 -a "x$squid_bzr_branch_revno" != "x"; then | |
aa73ca74 | 186 | sh -c "cd ${srcdir} && ${BZR} diff 2>&1 >/dev/null" |
4fe75473 FC |
187 | if test $? -eq 1; then |
188 | squid_bzr_branch_revno="$squid_bzr_branch_revno+changes" | |
189 | fi | |
190 | fi | |
191 | if test "x$squid_bzr_branch_revno" != "x"; then | |
192 | squid_build_info="Built branch: ${squid_bzr_branch_nick}-r${squid_bzr_branch_revno}" | |
193 | fi | |
194 | fi | |
195 | ;; | |
196 | *) | |
197 | squid_build_info=$enableval | |
198 | ;; | |
199 | esac | |
200 | ]) | |
90cf433e FC |
201 | AC_DEFINE_UNQUOTED([SQUID_BUILD_INFO],["$squid_build_info"], |
202 | [Squid extended build info field for "squid -v" output]) | |
4fe75473 | 203 | ]) |
391f0bac FC |
204 | |
205 | dnl like AC_SEARCH_LIBS, with an extra argument which is | |
206 | dnl a prefix to the test program | |
207 | AC_DEFUN([SQUID_SEARCH_LIBS], | |
208 | [AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl | |
209 | AC_CACHE_CHECK([for library containing $1], [ac_Search], | |
210 | [ac_func_search_save_LIBS=$LIBS | |
211 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([$6], [$1()])]) | |
212 | for ac_lib in '' $2; do | |
213 | if test -z "$ac_lib"; then | |
214 | ac_res="none required" | |
215 | else | |
216 | ac_res=-l$ac_lib | |
217 | LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS" | |
218 | fi | |
219 | AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])]) | |
220 | AS_VAR_SET_IF([ac_Search], [break]) | |
221 | done | |
222 | AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])]) | |
223 | rm conftest.$ac_ext | |
224 | LIBS=$ac_func_search_save_LIBS]) | |
225 | ac_res=AS_VAR_GET([ac_Search]) | |
226 | AS_IF([test "$ac_res" != no], | |
227 | [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" | |
228 | $3], | |
229 | [$4]) | |
230 | AS_VAR_POPDEF([ac_Search])dnl | |
231 | ]) | |
5a0c5a92 AJ |
232 | |
233 | dnl Check for Cyrus SASL | |
234 | AC_DEFUN([SQUID_CHECK_SASL],[ | |
586fa897 | 235 | squid_cv_check_sasl="auto" |
deca8463 | 236 | AC_CHECK_HEADERS([sasl/sasl.h sasl.h]) |
5a0c5a92 AJ |
237 | AC_CHECK_LIB(sasl2,sasl_errstring,[LIBSASL="-lsasl2"],[ |
238 | AC_CHECK_LIB(sasl,sasl_errstring,[LIBSASL="-lsasl"], [ | |
586fa897 | 239 | squid_cv_check_sasl="no" |
5a0c5a92 AJ |
240 | ]) |
241 | ]) | |
242 | case "$squid_host_os" in | |
243 | Darwin) | |
244 | if test "$ac_cv_lib_sasl2_sasl_errstring" = "yes" ; then | |
245 | AC_DEFINE(HAVE_SASL_DARWIN,1,[Define to 1 if Mac Darwin without sasl.h]) | |
246 | echo "checking for MAC Darwin without sasl.h ... yes" | |
586fa897 | 247 | squid_cv_check_sasl="yes" |
5a0c5a92 AJ |
248 | else |
249 | echo "checking for MAC Darwin without sasl.h ... no" | |
586fa897 | 250 | squid_cv_check_sasl="no" |
5a0c5a92 AJ |
251 | fi |
252 | ;; | |
253 | esac | |
586fa897 | 254 | if test "x$squid_cv_check_sasl" = "xno"; then |
deca8463 | 255 | AC_MSG_WARN([Neither SASL nor SASL2 found]) |
586fa897 AJ |
256 | else |
257 | squid_cv_check_sasl="yes" | |
5a0c5a92 AJ |
258 | fi |
259 | AC_SUBST(LIBSASL) | |
260 | ]) |