3 ac_help="--with-pylint[=yes|no|maybe] require and run pylint (maybe)"
7 # Prints prog path to stdout or nothing.
8 local name="$1" result="$2"
9 TLOGN "checking for $name"
10 if ! [ "$result" ]; then
11 result=`acLookFor "$name"`
19 local code="$1" tmpdir rc cflags=''
20 if test -z "$code"; then
21 AC_FAIL "No code provided to test compile"
27 AC_FAIL "Invald call to bup_try_c_code" "$@"
30 tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
31 echo "$code" > "$tmpdir/test.c" || exit $?
32 $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
34 rm -r "$tmpdir" || exit $?
42 while test $# -gt 0; do
44 --with-pylint=yes) with_pylint=yes; shift;;
45 --with-pylint=maybe) with_pylint=maybe; shift;;
46 --with-pylint=no) with_pylint=no; shift;;
47 *) argv+=("$1"); shift;;
51 # Set $@ to the adjusted args
57 rm -rf finished config/bin config.var config.var.tmp config.vars
62 LOG " You need to have a functional C compiler to build $TARGET"
66 for make_candidate in make gmake; do
67 found_make="$(bup_find_prog "$make_candidate" "$MAKE")"
68 if test "$found_make" \
69 && ("$found_make" --version | grep "GNU Make"); then
75 if ! test "$MAKE"; then
76 AC_FAIL "ERROR: unable to find GNU make as make or gmake"
79 MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
80 if [ -z "$MAKE_VERSION" ]; then
81 AC_FAIL "ERROR: $MAKE --version does not return sensible output?"
83 expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81"
85 AC_SUB bup_make "$MAKE"
88 # Haven't seen a documented way to determine the python version via
89 # python-config right now, so we'll defer version checking until
92 if test "$BUP_PYTHON_CONFIG"; then
93 bup_python_config="$(type -p "$BUP_PYTHON_CONFIG")"
94 if test -z "$bup_python_config"; then
95 AC_FAIL $(printf "ERROR: BUP_PYTHON_CONFIG value %q appears invalid" \
99 for py_maj_ver in 9 8 7 6; do
100 bup_python_config="$(bup_find_prog "python3.$py_maj_ver-config" '')"
101 test -z "$bup_python_config" || break
103 test -z "$bup_python_config" \
104 && bup_python_config="$(bup_find_prog python3-config '')"
105 test -z "$bup_python_config" \
106 && bup_python_config="$(bup_find_prog python2.7-config '')"
107 if test -z "$bup_python_config"; then
108 AC_FAIL "ERROR: unable to find a suitable python-config"
113 bup_python_cflags=$("$bup_python_config" --cflags) || exit $?
114 bup_python_ldflags=$("$bup_python_config" --ldflags) || exit $?
115 bup_python_cflags_embed=$("$bup_python_config" --cflags --embed)
116 if test $? -eq 0; then
117 bup_python_ldflags_embed=$("$bup_python_config" --ldflags --embed) || exit $?
118 else # Earlier versions didn't support --embed
119 bup_python_cflags_embed=$("$bup_python_config" --cflags) || exit $?
120 bup_python_ldflags_embed=$("$bup_python_config" --ldflags) || exit $?
123 bup_python_cflags="$bup_python_cflags -fPIC"
127 # For at least 10.3+ (2003+)
128 bup_python_ldflags="$bup_python_ldflags -bundle -undefined dynamic_lookup"
131 bup_python_ldflags="$bup_python_ldflags -shared"
135 AC_SUB bup_python_config "$bup_python_config"
136 AC_SUB bup_python_cflags "$bup_python_cflags"
137 AC_SUB bup_python_ldflags "$bup_python_ldflags"
138 AC_SUB bup_python_cflags_embed "$bup_python_cflags_embed"
139 AC_SUB bup_python_ldflags_embed "$bup_python_ldflags_embed"
142 bup_git="$(bup_find_prog git '')"
143 if test -z "$bup_git"; then
144 AC_FAIL "ERROR: unable to find git"
148 AC_CHECK_HEADERS sys/stat.h
149 AC_CHECK_HEADERS sys/types.h
151 # For stat and mincore.
152 AC_CHECK_HEADERS unistd.h
155 AC_CHECK_HEADERS sys/mman.h
157 # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS.
158 AC_CHECK_HEADERS linux/fs.h
159 AC_CHECK_HEADERS sys/ioctl.h
161 # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
162 if [ -z "$OS_GNU_KFREEBSD" ]; then
163 AC_CHECK_FUNCS utimensat
165 AC_CHECK_FUNCS utimes
166 AC_CHECK_FUNCS lutimes
169 AC_CHECK_FUNCS mincore
171 mincore_incore_code="
172 #if 0$ac_defined_HAVE_UNISTD_H
175 #if 0$ac_defined_HAVE_SYS_MMAN_H
176 #include <sys/mman.h>
178 int main(int argc, char **argv)
185 mincore_buf_type_code()
189 #include <sys/mman.h>
190 int main(int argc, char **argv)
194 return mincore(x, 0, buf);
198 if test "$ac_defined_HAVE_MINCORE"; then
199 TLOGN "checking for MINCORE_INCORE"
200 if bup_try_c_code "$mincore_incore_code"; then
201 AC_DEFINE BUP_HAVE_MINCORE_INCORE 1
207 TLOGN "checking mincore buf type"
208 if bup_try_c_code "$(mincore_buf_type_code char)"; then
209 AC_DEFINE BUP_MINCORE_BUF_TYPE 'char'
211 elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then
212 AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char'
213 TLOG ' (unsigned char)'
215 AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com"
220 TLOGN "checking for readline"
222 bup_readline_includes_in_subdir=''
223 bup_readline_via_pkg_config=''
224 # We test this specific thing because it should work everywhere and it was
225 # a particulary problem on macos (we'd get the wrong includes if we just
226 # tested that the includes work).
228 static char *on_completion_entry(const char *text, int state) { return NULL; }
229 void bup_test(void) { rl_completion_entry_function = on_completion_entry; }
231 if pkg-config readline; then
232 bup_readline_cflags="$(pkg-config readline --cflags)" || exit $?
233 bup_readline_ldflags="$(pkg-config readline --libs)" || exit $?
234 # It looks like it's not uncommon for pkg-config to provide a -I
235 # that doesn't support the documentation's specified #include
236 # <readline/readline.h>. See what's really going on.
237 if bup_try_c_code "#include <stdio.h> // required by unpatched readline
238 #include <readline/readline.h>
239 $readline_test_code" \
240 "$bup_readline_cflags"
243 bup_readline_includes_in_subdir=1
244 elif bup_try_c_code "#include <stdio.h> // required by unpatched readline
245 #include <readline.h>
246 $readline_test_code" \
247 "$bup_readline_cflags"
251 if test "$bup_have_readline"; then
252 bup_readline_via_pkg_config=1
254 bup_readline_cflags=''
255 bup_readline_ldflags=''
258 if ! test "$bup_have_readline"; then
259 if bup_try_c_code "#include <readline/readline.h> $readline_test_code"; then
260 bup_readline_ldflags=-lreadline
262 bup_readline_includes_in_subdir=1
263 elif bup_try_c_code "#include <readline.h> $readline_test_code"; then
264 bup_readline_ldflags=-lreadline
268 if test "$bup_have_readline"; then
269 AC_DEFINE BUP_HAVE_READLINE 1
270 if test "$bup_readline_includes_in_subdir"; then
271 AC_DEFINE BUP_READLINE_INCLUDES_IN_SUBDIR 1
273 if test "$bup_readline_via_pkg_config"; then
274 TLOG ' (yes, pkg-config)'
281 AC_SUB bup_readline_cflags "$bup_readline_cflags"
282 AC_SUB bup_readline_ldflags "$bup_readline_ldflags"
283 AC_SUB bup_have_readline "$bup_have_readline"
286 AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h
287 AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h
288 AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h
290 AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h
291 AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h
292 AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h
294 AC_CHECK_FIELD tm tm_gmtoff time.h
299 TLOGN "checking for libacl"
300 if pkg-config libacl; then
301 bup_libacl_cflags="$(pkg-config libacl --cflags)"
302 bup_libacl_ldflags="$(pkg-config libacl --libs)"
303 TLOG ' (yes, pkg-config)'
306 bup_libacl_ldflags='-lacl'
309 AC_CC="$AC_CC${bup_libacl_cflags:+ $bup_libacl_cflags}"
310 LIBS="$bup_libacl_ldflags"
311 AC_CHECK_HEADERS sys/acl.h
312 AC_CHECK_HEADERS acl/libacl.h
313 AC_CHECK_FUNCS acl_get_file
314 AC_CHECK_FUNCS acl_from_text
315 AC_CHECK_FUNCS acl_set_file
316 # Note: These are linux specific, but we need them (for now?)
317 AC_CHECK_FUNCS acl_extended_file
318 AC_CHECK_FUNCS acl_to_any_text
319 TLOGN "checking for complete acl support"
320 if test "$ac_defined_HAVE_ACL_EXTENDED_FILE"; then
322 AC_SUB bup_libacl_cflags "$bup_libacl_cflags"
323 AC_SUB bup_libacl_ldflags "$bup_libacl_ldflags"
327 AC_SUB bup_have_libacl ''
330 AC_SUB bup_have_libacl "$bup_have_libacl"
334 AC_OUTPUT config.vars
339 mkdir -p config.var.tmp
340 echo -n "$MAKE" > config.var.tmp/bup-make
341 echo -n "$bup_python_config" > config.var.tmp/bup-python-config
342 echo -n "$with_pylint" > config.var.tmp/with-pylint
343 mv config.var.tmp config.var
345 if test -e bin; then rm -r bin; fi
347 (cd bin && ln -s "$MAKE" make)
352 found: python-config (%q)
353 found: git (%q, ($("$bup_git" --version))
355 "$bup_python_config" \
363 if test "$found"; then
369 summarize "$bup_have_readline" 'readline support (e.g. bup ftp)'
370 summarize "$bup_have_libacl" 'POSIX ACL support'