5 # Prints prog path to stdout or nothing.
6 local name="$1" result="$2"
7 TLOGN "checking for $name"
8 if ! [ "$result" ]; then
9 result=`acLookFor "$name"`
17 local code="$1" tmpdir rc cflags=''
18 if test -z "$code"; then
19 AC_FAIL "No code provided to test compile"
25 AC_FAIL "Invald call to bup_try_c_code" "$@"
28 tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
29 echo "$code" > "$tmpdir/test.c" || exit $?
30 $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
32 rm -r "$tmpdir" || exit $?
41 rm -rf config.var config.var.tmp config.vars
46 LOG " You need to have a functional C compiler to build $TARGET"
50 MAKE="$(bup_find_prog make "$MAKE")"
51 if test -z "$MAKE"; then
52 MAKE="$(bup_find_prog gmake "$GMAKE")"
55 if test -z "$MAKE"; then
56 AC_FAIL "ERROR: unable to find make"
59 if ! ($MAKE --version | grep "GNU Make"); then
60 AC_FAIL "ERROR: $MAKE is not GNU Make"
63 MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
64 if [ -z "$MAKE_VERSION" ]; then
65 AC_FAIL "ERROR: $MAKE --version does not return sensible output?"
67 expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81"
69 AC_SUB bup_make "$MAKE"
72 # Haven't seen a documented way to determine the python version via
73 # python-config right now, so we'll defer version checking until
76 if test "$BUP_PYTHON_CONFIG"; then
77 bup_python_config="$(type -p "$BUP_PYTHON_CONFIG")"
78 if test -z "$bup_python_config"; then
79 AC_FAIL $(printf "ERROR: BUP_PYTHON_CONFIG value %q appears invalid" \
83 test -z "$bup_python_config" \
84 && bup_python_config="$(bup_find_prog python3-config '')"
85 test -z "$bup_python_config" \
86 && bup_python_config="$(bup_find_prog python2.7-config '')"
87 if test -z "$bup_python_config"; then
88 AC_FAIL "ERROR: unable to find a suitable python-config"
93 bup_python_cflags=$("$bup_python_config" --cflags) || exit $?
94 bup_python_ldflags=$("$bup_python_config" --ldflags) || exit $?
95 bup_python_cflags_embed=$("$bup_python_config" --cflags --embed)
96 if test $? -eq 0; then
97 bup_python_ldflags_embed=$("$bup_python_config" --ldflags --embed) || exit $?
98 else # Earlier versions didn't support --embed
99 bup_python_cflags_embed=$("$bup_python_config" --cflags) || exit $?
100 bup_python_ldflags_embed=$("$bup_python_config" --ldflags) || exit $?
102 AC_SUB bup_python_config "$bup_python_config"
103 AC_SUB bup_python_cflags "$bup_python_cflags"
104 AC_SUB bup_python_ldflags "$bup_python_ldflags"
105 AC_SUB bup_python_cflags_embed "$bup_python_cflags_embed"
106 AC_SUB bup_python_ldflags_embed "$bup_python_ldflags_embed"
109 bup_git="$(bup_find_prog git '')"
110 if test -z "$bup_git"; then
111 AC_FAIL "ERROR: unable to find git"
115 AC_CHECK_HEADERS sys/stat.h
116 AC_CHECK_HEADERS sys/types.h
118 # For stat and mincore.
119 AC_CHECK_HEADERS unistd.h
122 AC_CHECK_HEADERS sys/mman.h
124 # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS.
125 AC_CHECK_HEADERS linux/fs.h
126 AC_CHECK_HEADERS sys/ioctl.h
128 # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
129 if [ -z "$OS_GNU_KFREEBSD" ]; then
130 AC_CHECK_FUNCS utimensat
132 AC_CHECK_FUNCS utimes
133 AC_CHECK_FUNCS lutimes
135 builtin_mul_overflow_code="
137 int main(int argc, char **argv)
139 size_t n = 0, size = 0, total;
140 __builtin_mul_overflow(n, size, &total);
145 TLOGN "checking for __builtin_mul_overflow"
146 if bup_try_c_code "$builtin_mul_overflow_code"; then
147 AC_DEFINE BUP_HAVE_BUILTIN_MUL_OVERFLOW 1
154 AC_CHECK_FUNCS mincore
156 mincore_incore_code="
157 #if 0$ac_defined_HAVE_UNISTD_H
160 #if 0$ac_defined_HAVE_SYS_MMAN_H
161 #include <sys/mman.h>
163 int main(int argc, char **argv)
170 mincore_buf_type_code()
174 #include <sys/mman.h>
175 int main(int argc, char **argv)
179 return mincore(x, 0, buf);
183 if test "$ac_defined_HAVE_MINCORE"; then
184 TLOGN "checking for MINCORE_INCORE"
185 if bup_try_c_code "$mincore_incore_code"; then
186 AC_DEFINE BUP_HAVE_MINCORE_INCORE 1
192 TLOGN "checking mincore buf type"
193 if bup_try_c_code "$(mincore_buf_type_code char)"; then
194 AC_DEFINE BUP_MINCORE_BUF_TYPE 'char'
196 elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then
197 AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char'
198 TLOG ' (unsigned char)'
200 AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com"
205 TLOGN "checking for readline"
207 bup_readline_includes_in_subdir=''
208 bup_readline_via_pkg_config=''
209 # We test this specific thing because it should work everywhere and it was
210 # a particulary problem on macos (we'd get the wrong includes if we just
211 # tested that the includes work).
213 static char *on_completion_entry(const char *text, int state) { return NULL; }
214 void bup_test(void) { rl_completion_entry_function = on_completion_entry; }
216 if pkg-config readline; then
217 bup_readline_cflags="$(pkg-config readline --cflags)" || exit $?
218 bup_readline_ldflags="$(pkg-config readline --libs)" || exit $?
219 # It looks like it's not uncommon for pkg-config to provide a -I
220 # that doesn't support the documentation's specified #include
221 # <readline/readline.h>. See what's really going on.
222 if bup_try_c_code "#include <readline/readline.h> $readline_test_code" \
223 "$bup_readline_cflags"
226 bup_readline_includes_in_subdir=1
227 elif bup_try_c_code "#include <readline.h> $readline_test_code" \
228 "$bup_readline_cflags"
232 if test "$bup_have_readline"; then
233 bup_readline_via_pkg_config=1
235 bup_readline_cflags=''
236 bup_readline_ldflags=''
239 if ! test "$bup_have_readline"; then
240 if bup_try_c_code "#include <readline/readline.h> $readline_test_code"; then
241 bup_readline_ldflags=-lreadline
243 bup_readline_includes_in_subdir=1
244 elif bup_try_c_code "#include <readline.h> $readline_test_code"; then
245 bup_readline_ldflags=-lreadline
249 if test "$bup_have_readline"; then
250 AC_DEFINE BUP_HAVE_READLINE 1
251 if test "$bup_readline_includes_in_subdir"; then
252 AC_DEFINE BUP_READLINE_INCLUDES_IN_SUBDIR 1
254 if test "$bup_readline_via_pkg_config"; then
255 TLOG ' (yes, pkg-config)'
262 AC_SUB bup_readline_cflags "$bup_readline_cflags"
263 AC_SUB bup_readline_ldflags "$bup_readline_ldflags"
264 AC_SUB bup_have_readline "$bup_have_readline"
267 AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h
268 AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h
269 AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h
271 AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h
272 AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h
273 AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h
275 AC_CHECK_FIELD tm tm_gmtoff time.h
280 TLOGN "checking for libacl"
281 if pkg-config libacl; then
282 bup_libacl_cflags="$(pkg-config libacl --cflags)"
283 bup_libacl_ldflags="$(pkg-config libacl --libs)"
284 TLOG ' (yes, pkg-config)'
287 bup_libacl_ldflags='-lacl'
290 AC_CC="$AC_CC${bup_libacl_cflags:+ $bup_libacl_cflags}"
291 LIBS="$bup_libacl_ldflags"
292 AC_CHECK_HEADERS sys/acl.h
293 AC_CHECK_HEADERS acl/libacl.h
294 AC_CHECK_FUNCS acl_get_file
295 AC_CHECK_FUNCS acl_from_text
296 AC_CHECK_FUNCS acl_set_file
297 # Note: These are linux specific, but we need them (for now?)
298 AC_CHECK_FUNCS acl_extended_file
299 AC_CHECK_FUNCS acl_to_any_text
300 TLOGN "checking for complete acl support"
301 if test "$ac_defined_HAVE_ACL_EXTENDED_FILE"; then
303 AC_SUB bup_libacl_cflags "$bup_libacl_cflags"
304 AC_SUB bup_libacl_ldflags "$bup_libacl_ldflags"
308 AC_SUB bup_have_libacl ''
311 AC_SUB bup_have_libacl "$bup_have_libacl"
316 AC_OUTPUT config.vars
322 mkdir -p config.var.tmp
323 echo -n "$MAKE" > config.var.tmp/bup-make
324 echo -n "$bup_python_config" > config.var.tmp/bup-python-config
325 mv config.var.tmp config.var
328 found: python-config (%q)
329 found: git (%q, ($("$bup_git" --version))
331 "$bup_python_config" \
339 if test "$found"; then
345 summarize "$bup_have_readline" 'readline support (e.g. bup ftp)'
346 summarize "$bup_have_libacl" 'POSIX ACL support'