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 $?
43 LOG " You need to have a functional C compiler to build $TARGET"
47 MAKE="$(bup_find_prog make "$MAKE")"
48 if test -z "$MAKE"; then
49 MAKE="$(bup_find_prog gmake "$GMAKE")"
52 if test -z "$MAKE"; then
53 AC_FAIL "ERROR: unable to find make"
56 if ! ($MAKE --version | grep "GNU Make"); then
57 AC_FAIL "ERROR: $MAKE is not GNU Make"
60 MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
61 if [ -z "$MAKE_VERSION" ]; then
62 AC_FAIL "ERROR: $MAKE --version does not return sensible output?"
64 expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81"
66 AC_SUB bup_make "$MAKE"
68 bup_python="$(type -p "$PYTHON")"
69 test -z "$bup_python" && bup_python="$(bup_find_prog python2.7 '')"
70 test -z "$bup_python" && bup_python="$(bup_find_prog python2.6 '')"
71 test -z "$bup_python" && bup_python="$(bup_find_prog python2 '')"
72 test -z "$bup_python" && bup_python="$(bup_find_prog python '')"
73 if test -z "$bup_python"; then
74 AC_FAIL "ERROR: unable to find python"
76 AC_SUB bup_python "$bup_python"
77 AC_SUB bup_python_majver \
78 "$("$bup_python" -c 'import sys; print(sys.version_info[0])')"
81 bup_git="$(bup_find_prog git '')"
82 if test -z "$bup_git"; then
83 AC_FAIL "ERROR: unable to find git"
87 AC_CHECK_HEADERS sys/stat.h
88 AC_CHECK_HEADERS sys/types.h
90 # For stat and mincore.
91 AC_CHECK_HEADERS unistd.h
94 AC_CHECK_HEADERS sys/mman.h
96 # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS.
97 AC_CHECK_HEADERS linux/fs.h
98 AC_CHECK_HEADERS sys/ioctl.h
100 # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
101 if [ -z "$OS_GNU_KFREEBSD" ]; then
102 AC_CHECK_FUNCS utimensat
104 AC_CHECK_FUNCS utimes
105 AC_CHECK_FUNCS lutimes
108 builtin_mul_overflow_code="
110 int main(int argc, char **argv)
112 size_t n = 0, size = 0, total;
113 __builtin_mul_overflow(n, size, &total);
118 TLOGN "checking for __builtin_mul_overflow"
119 if bup_try_c_code "$builtin_mul_overflow_code"; then
120 AC_DEFINE BUP_HAVE_BUILTIN_MUL_OVERFLOW 1
127 AC_CHECK_FUNCS mincore
129 mincore_incore_code="
130 #if 0$ac_defined_HAVE_UNISTD_H
133 #if 0$ac_defined_HAVE_SYS_MMAN_H
134 #include <sys/mman.h>
136 int main(int argc, char **argv)
143 mincore_buf_type_code()
147 #include <sys/mman.h>
148 int main(int argc, char **argv)
152 return mincore(x, 0, buf);
156 if test "$ac_defined_HAVE_MINCORE"; then
157 TLOGN "checking for MINCORE_INCORE"
158 if bup_try_c_code "$mincore_incore_code"; then
159 AC_DEFINE BUP_HAVE_MINCORE_INCORE 1
165 TLOGN "checking mincore buf type"
166 if bup_try_c_code "$(mincore_buf_type_code char)"; then
167 AC_DEFINE BUP_MINCORE_BUF_TYPE 'char'
169 elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then
170 AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char'
171 TLOG ' (unsigned char)'
173 AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com"
178 TLOGN "checking for readline"
180 bup_readline_includes_in_subdir=''
181 bup_readline_via_pkg_config=''
182 # We test this specific thing because it should work everywhere and it was
183 # a particulary problem on macos (we'd get the wrong includes if we just
184 # tested that the includes work).
186 static char *on_completion_entry(const char *text, int state) { return NULL; }
187 void bup_test(void) { rl_completion_entry_function = on_completion_entry; }
189 if pkg-config readline; then
190 bup_readline_cflags="$(pkg-config readline --cflags)" || exit $?
191 bup_readline_ldflags="$(pkg-config readline --libs)" || exit $?
192 # It looks like it's not uncommon for pkg-config to provide a -I
193 # that doesn't support the documentation's specified #include
194 # <readline/readline.h>. See what's really going on.
195 if bup_try_c_code "#include <readline/readline.h> $readline_test_code" \
196 "$bup_readline_cflags"
199 bup_readline_includes_in_subdir=1
200 elif bup_try_c_code "#include <readline.h> $readline_test_code" \
201 "$bup_readline_cflags"
205 if test "$bup_have_readline"; then
206 bup_readline_via_pkg_config=1
208 bup_readline_cflags=''
209 bup_readline_ldflags=''
212 if ! test "$bup_have_readline"; then
213 if bup_try_c_code "#include <readline/readline.h> $readline_test_code"; then
214 bup_readline_ldflags=-lreadline
216 bup_readline_includes_in_subdir=1
217 elif bup_try_c_code "#include <readline.h> $readline_test_code"; then
218 bup_readline_ldflags=-lreadline
222 if test "$bup_have_readline"; then
223 AC_DEFINE BUP_HAVE_READLINE 1
224 if test "$bup_readline_includes_in_subdir"; then
225 AC_DEFINE BUP_READLINE_INCLUDES_IN_SUBDIR 1
227 if test "$bup_readline_via_pkg_config"; then
228 TLOG ' (yes, pkg-config)'
235 AC_SUB bup_readline_cflags "$bup_readline_cflags"
236 AC_SUB bup_readline_ldflags "$bup_readline_ldflags"
237 AC_SUB bup_have_readline "$bup_have_readline"
240 AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h
241 AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h
242 AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h
244 AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h
245 AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h
246 AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h
248 AC_CHECK_FIELD tm tm_gmtoff time.h
253 TLOGN "checking for libacl"
254 if pkg-config libacl; then
255 bup_libacl_cflags="$(pkg-config libacl --cflags)"
256 bup_libacl_ldflags="$(pkg-config libacl --libs)"
257 TLOG ' (yes, pkg-config)'
260 bup_libacl_ldflags='-lacl'
263 AC_CC="$AC_CC${bup_libacl_cflags:+ $bup_libacl_cflags}"
264 LIBS="$bup_libacl_ldflags"
265 AC_CHECK_HEADERS sys/acl.h
266 AC_CHECK_HEADERS acl/libacl.h
267 AC_CHECK_FUNCS acl_get_file
268 AC_CHECK_FUNCS acl_from_text
269 AC_CHECK_FUNCS acl_set_file
270 # Note: These are linux specific, but we need them (for now?)
271 AC_CHECK_FUNCS acl_extended_file
272 AC_CHECK_FUNCS acl_to_any_text
273 TLOGN "checking for complete acl support"
274 if test "$ac_defined_HAVE_ACL_EXTENDED_FILE"; then
276 AC_SUB bup_libacl_cflags "$bup_libacl_cflags"
277 AC_SUB bup_libacl_ldflags "$bup_libacl_ldflags"
281 AC_SUB bup_have_libacl ''
284 AC_SUB bup_have_libacl "$bup_have_libacl"
289 AC_OUTPUT config.vars
291 if test -e config.var; then rm -r config.var; fi
293 echo -n "$MAKE" > config.var/bup-make
294 echo -n "$bup_python" > config.var/bup-python
296 if test -e bin; then rm -r bin; fi
298 (cd bin && ln -s "$bup_python" python)
301 found: python (%q, $("$bup_python" --version 2>&1))
302 found: git (%q, ($("$bup_git" --version))
312 if test "$found"; then
318 summarize "$bup_have_readline" 'readline support (e.g. bup ftp)'
319 summarize "$bup_have_libacl" 'POSIX ACL support'