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
18 if test -z "$code"; then
19 AC_FAIL "No code provided to test compile"
21 tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
22 echo "$code" > "$tmpdir/test.c" || exit $?
23 $AC_CC -Wall -Werror -c -o "$tmpdir/test" "$tmpdir/test.c"
25 rm -r "$tmpdir" || exit $?
36 LOG " You need to have a functional C compiler to build $TARGET"
40 MAKE="$(bup_find_prog make "$MAKE")"
41 if test -z "$MAKE"; then
42 MAKE="$(bup_find_prog gmake "$GMAKE")"
45 if test -z "$MAKE"; then
46 AC_FAIL "ERROR: unable to find make"
49 if ! ($MAKE --version | grep "GNU Make"); then
50 AC_FAIL "ERROR: $MAKE is not GNU Make"
53 MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
54 if [ -z "$MAKE_VERSION" ]; then
55 AC_FAIL "ERROR: $MAKE --version does not return sensible output?"
57 expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81"
59 AC_SUB bup_make "$MAKE"
61 bup_python="$(type -p "$PYTHON")"
62 test -z "$bup_python" && bup_python="$(bup_find_prog python2.7 '')"
63 test -z "$bup_python" && bup_python="$(bup_find_prog python2.6 '')"
64 test -z "$bup_python" && bup_python="$(bup_find_prog python2 '')"
65 test -z "$bup_python" && bup_python="$(bup_find_prog python '')"
66 if test -z "$bup_python"; then
67 AC_FAIL "ERROR: unable to find python"
69 AC_SUB bup_python "$bup_python"
70 AC_SUB bup_python_majver \
71 "$("$bup_python" -c 'import sys; print(sys.version_info[0])')"
74 if test -z "$(bup_find_prog git '')"; then
75 AC_FAIL "ERROR: unable to find git"
79 AC_CHECK_HEADERS sys/stat.h
80 AC_CHECK_HEADERS sys/types.h
82 # For stat and mincore.
83 AC_CHECK_HEADERS unistd.h
86 AC_CHECK_HEADERS sys/mman.h
88 # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS.
89 AC_CHECK_HEADERS linux/fs.h
90 AC_CHECK_HEADERS sys/ioctl.h
92 # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
93 if [ -z "$OS_GNU_KFREEBSD" ]; then
94 AC_CHECK_FUNCS utimensat
97 AC_CHECK_FUNCS lutimes
100 builtin_mul_overflow_code="
102 int main(int argc, char **argv)
104 size_t n = 0, size = 0, total;
105 __builtin_mul_overflow(n, size, &total);
110 TLOGN "checking for __builtin_mul_overflow"
111 if bup_try_c_code "$builtin_mul_overflow_code"; then
112 AC_DEFINE BUP_HAVE_BUILTIN_MUL_OVERFLOW 1
119 AC_CHECK_FUNCS mincore
121 mincore_incore_code="
122 #if 0$ac_defined_HAVE_UNISTD_H
125 #if 0$ac_defined_HAVE_SYS_MMAN_H
126 #include <sys/mman.h>
128 int main(int argc, char **argv)
135 mincore_buf_type_code()
139 #include <sys/mman.h>
140 int main(int argc, char **argv)
144 return mincore(x, 0, buf);
148 if test "$ac_defined_HAVE_MINCORE"; then
149 TLOGN "checking for MINCORE_INCORE"
150 if bup_try_c_code "$mincore_incore_code"; then
151 AC_DEFINE BUP_HAVE_MINCORE_INCORE 1
157 TLOGN "checking mincore buf type"
158 if bup_try_c_code "$(mincore_buf_type_code char)"; then
159 AC_DEFINE BUP_MINCORE_BUF_TYPE 'char'
161 elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then
162 AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char'
163 TLOG ' (unsigned char)'
165 AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com"
169 TLOGN "checking for readline"
170 if pkg-config readline; then
171 bup_readline_cflags="$(pkg-config readline --cflags)" || exit $?
172 bup_readline_ldflags="$(pkg-config readline --libs)" || exit $?
174 AC_DEFINE BUP_HAVE_READLINE 1
175 TLOG ' (yes, pkg-config)'
176 elif bup_try_c_code '#include <readline/readline.h>'; then
177 bup_readline_cflags=''
178 bup_readline_ldflags=-lreadline
180 AC_DEFINE BUP_HAVE_READLINE 1
183 bup_readline_cflags=''
184 bup_readline_ldflags=''
188 AC_SUB bup_readline_cflags "$bup_readline_cflags"
189 AC_SUB bup_readline_ldflags "$bup_readline_ldflags"
190 AC_SUB bup_have_readline "$bup_have_readline"
192 AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h
193 AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h
194 AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h
196 AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h
197 AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h
198 AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h
200 AC_CHECK_FIELD tm tm_gmtoff time.h
205 TLOGN "checking for libacl"
206 if pkg-config libacl; then
207 bup_libacl_cflags="$(pkg-config libacl --cflags)"
208 bup_libacl_ldflags="$(pkg-config libacl --libs)"
209 TLOG ' (yes, pkg-config)'
212 bup_libacl_ldflags='-lacl'
215 AC_CC="$AC_CC${bup_libacl_cflags:+ $bup_libacl_cflags}"
216 LIBS="$bup_libacl_ldflags"
217 AC_CHECK_HEADERS sys/acl.h
218 AC_CHECK_HEADERS acl/libacl.h
219 AC_CHECK_FUNCS acl_get_file
220 AC_CHECK_FUNCS acl_from_text
221 AC_CHECK_FUNCS acl_set_file
222 # Note: These are linux specific, but we need them (for now?)
223 AC_CHECK_FUNCS acl_extended_file
224 AC_CHECK_FUNCS acl_to_any_text
225 TLOGN "checking for complete acl support"
226 if test "$ac_defined_HAVE_ACL_EXTENDED_FILE"; then
228 AC_SUB bup_libacl_cflags "$bup_libacl_cflags"
229 AC_SUB bup_libacl_ldflags "$bup_libacl_ldflags"
233 AC_SUB bup_have_libacl ''
236 AC_SUB bup_have_libacl "$bup_have_libacl"
241 AC_OUTPUT config.vars
243 if test -e config.var; then rm -r config.var; fi
245 echo -n "$MAKE" > config.var/bup-make
246 echo -n "$bup_python" > config.var/bup-python
248 if test -e bin; then rm -r bin; fi
250 cd bin && ln -s "$bup_python" python