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 $?
40 bup-add-cflag-if-supported()
43 if test -z "$opt"; then
44 AC_FAIL 'No option to check'
46 TLOGN "checking for $AC_CC $opt support"
48 "int main(int argc, char**argv) { return 0; }" \
51 bup_config_cflags+="$opt"
63 while test $# -gt 0; do
65 --with-pylint=yes) with_pylint=yes; shift;;
66 --with-pylint=maybe) with_pylint=maybe; shift;;
67 --with-pylint=no) with_pylint=no; shift;;
68 *) argv+=("$1"); shift;;
72 # Set $@ to the adjusted args
78 rm -rf finished config/bin config.var config.var.tmp config.vars
83 LOG " You need to have a functional C compiler to build $TARGET"
87 bup-add-cflag-if-supported -Wno-unused-command-line-argument
89 for make_candidate in make gmake; do
90 found_make="$(bup_find_prog "$make_candidate" "$MAKE")"
91 if test "$found_make" \
92 && ("$found_make" --version | grep "GNU Make"); then
98 if ! test "$MAKE"; then
99 AC_FAIL "ERROR: unable to find GNU make as make or gmake"
102 MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
103 if [ -z "$MAKE_VERSION" ]; then
104 AC_FAIL "ERROR: $MAKE --version does not return sensible output?"
106 expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81"
108 AC_SUB bup_make "$MAKE"
111 # Haven't seen a documented way to determine the python version via
112 # python-config right now, so we'll defer version checking until
115 if test "$BUP_PYTHON_CONFIG"; then
116 bup_python_config="$(type -p "$BUP_PYTHON_CONFIG")"
117 if test -z "$bup_python_config"; then
118 AC_FAIL $(printf "ERROR: BUP_PYTHON_CONFIG value %q appears invalid" \
119 "$BUP_PYTHON_CONFIG")
122 for py_min_ver in 10 9 8 7 6; do
123 bup_python_config="$(bup_find_prog "python3.$py_min_ver-config" '')"
124 test -z "$bup_python_config" || break
126 test -z "$bup_python_config" \
127 && bup_python_config="$(bup_find_prog python3-config '')"
128 if test -z "$bup_python_config"; then
129 AC_FAIL "ERROR: unable to find a suitable python-config"
134 bup_python_cflags=$("$bup_python_config" --cflags) || exit $?
135 bup_python_ldflags=$("$bup_python_config" --ldflags) || exit $?
136 bup_python_cflags_embed=$("$bup_python_config" --cflags --embed)
137 if test $? -eq 0; then
138 bup_python_ldflags_embed=$("$bup_python_config" --ldflags --embed) || exit $?
139 else # Earlier versions didn't support --embed
140 bup_python_cflags_embed=$("$bup_python_config" --cflags) || exit $?
141 bup_python_ldflags_embed=$("$bup_python_config" --ldflags) || exit $?
144 bup_python_cflags="$bup_python_cflags -fPIC"
148 # For at least 10.3+ (2003+)
149 bup_python_ldflags="$bup_python_ldflags -bundle -undefined dynamic_lookup"
152 bup_python_ldflags="$bup_python_ldflags -shared"
156 AC_SUB bup_python_config "$bup_python_config"
157 AC_SUB bup_python_cflags "$bup_python_cflags"
158 AC_SUB bup_python_ldflags "$bup_python_ldflags"
159 AC_SUB bup_python_cflags_embed "$bup_python_cflags_embed"
160 AC_SUB bup_python_ldflags_embed "$bup_python_ldflags_embed"
163 bup_git="$(bup_find_prog git '')"
164 if test -z "$bup_git"; then
165 AC_FAIL "ERROR: unable to find git"
169 AC_CHECK_HEADERS sys/stat.h
170 AC_CHECK_HEADERS sys/types.h
172 # For stat and mincore.
173 AC_CHECK_HEADERS unistd.h
176 AC_CHECK_HEADERS sys/mman.h
178 # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS.
179 AC_CHECK_HEADERS linux/fs.h
180 AC_CHECK_HEADERS sys/ioctl.h
182 # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
183 if [ -z "$OS_GNU_KFREEBSD" ]; then
184 AC_CHECK_FUNCS utimensat
186 AC_CHECK_FUNCS utimes
187 AC_CHECK_FUNCS lutimes
190 AC_CHECK_FUNCS mincore
192 mincore_incore_code="
193 #if 0$ac_defined_HAVE_UNISTD_H
196 #if 0$ac_defined_HAVE_SYS_MMAN_H
197 #include <sys/mman.h>
199 int main(int argc, char **argv)
206 mincore_buf_type_code()
210 #include <sys/mman.h>
211 int main(int argc, char **argv)
215 return mincore(x, 0, buf);
219 if test "$ac_defined_HAVE_MINCORE"; then
220 TLOGN "checking for MINCORE_INCORE"
221 if bup_try_c_code "$mincore_incore_code"; then
222 AC_DEFINE BUP_HAVE_MINCORE_INCORE 1
228 TLOGN "checking mincore buf type"
229 if bup_try_c_code "$(mincore_buf_type_code char)"; then
230 AC_DEFINE BUP_MINCORE_BUF_TYPE 'char'
232 elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then
233 AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char'
234 TLOG ' (unsigned char)'
236 AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com"
241 TLOGN "checking for readline"
243 bup_readline_includes_in_subdir=''
244 bup_readline_via_pkg_config=''
245 # We test this specific thing because it should work everywhere and it was
246 # a particulary problem on macos (we'd get the wrong includes if we just
247 # tested that the includes work).
249 static char *on_completion_entry(const char *text, int state) { return NULL; }
250 void bup_test(void) { rl_completion_entry_function = on_completion_entry; }
252 if pkg-config readline; then
253 bup_readline_cflags="$(pkg-config readline --cflags)" || exit $?
254 bup_readline_ldflags="$(pkg-config readline --libs)" || exit $?
255 # It looks like it's not uncommon for pkg-config to provide a -I
256 # that doesn't support the documentation's specified #include
257 # <readline/readline.h>. See what's really going on.
258 if bup_try_c_code "#include <stdio.h> // required by unpatched readline
259 #include <readline/readline.h>
260 $readline_test_code" \
261 "$bup_readline_cflags"
264 bup_readline_includes_in_subdir=1
265 elif bup_try_c_code "#include <stdio.h> // required by unpatched readline
266 #include <readline.h>
267 $readline_test_code" \
268 "$bup_readline_cflags"
272 if test "$bup_have_readline"; then
273 bup_readline_via_pkg_config=1
275 bup_readline_cflags=''
276 bup_readline_ldflags=''
279 if ! test "$bup_have_readline"; then
280 if bup_try_c_code "#include <readline/readline.h> $readline_test_code"; then
281 bup_readline_ldflags=-lreadline
283 bup_readline_includes_in_subdir=1
284 elif bup_try_c_code "#include <readline.h> $readline_test_code"; then
285 bup_readline_ldflags=-lreadline
289 if test "$bup_have_readline"; then
290 AC_DEFINE BUP_HAVE_READLINE 1
291 if test "$bup_readline_includes_in_subdir"; then
292 AC_DEFINE BUP_READLINE_INCLUDES_IN_SUBDIR 1
294 if test "$bup_readline_via_pkg_config"; then
295 TLOG ' (yes, pkg-config)'
302 AC_SUB bup_readline_cflags "$bup_readline_cflags"
303 AC_SUB bup_readline_ldflags "$bup_readline_ldflags"
304 AC_SUB bup_have_readline "$bup_have_readline"
307 AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h
308 AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h
309 AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h
311 AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h
312 AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h
313 AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h
315 AC_CHECK_FIELD tm tm_gmtoff time.h
320 TLOGN "checking for libacl"
321 if pkg-config libacl; then
322 bup_libacl_cflags="$(pkg-config libacl --cflags)"
323 bup_libacl_ldflags="$(pkg-config libacl --libs)"
324 TLOG ' (yes, pkg-config)'
327 bup_libacl_ldflags='-lacl'
330 AC_CC="$AC_CC${bup_libacl_cflags:+ $bup_libacl_cflags}"
331 LIBS="$bup_libacl_ldflags"
332 AC_CHECK_HEADERS sys/acl.h
333 AC_CHECK_HEADERS acl/libacl.h
334 AC_CHECK_FUNCS acl_get_file
335 AC_CHECK_FUNCS acl_from_text
336 AC_CHECK_FUNCS acl_set_file
337 # Note: These are linux specific, but we need them (for now?)
338 AC_CHECK_FUNCS acl_extended_file
339 AC_CHECK_FUNCS acl_to_any_text
340 TLOGN "checking for complete acl support"
341 if test "$ac_defined_HAVE_ACL_EXTENDED_FILE"; then
343 AC_SUB bup_libacl_cflags "$bup_libacl_cflags"
344 AC_SUB bup_libacl_ldflags "$bup_libacl_ldflags"
348 AC_SUB bup_have_libacl ''
351 AC_SUB bup_have_libacl "$bup_have_libacl"
355 AC_SUB bup_config_cflags "$bup_config_cflags"
357 AC_OUTPUT config.vars
362 mkdir -p config.var.tmp
363 echo -n "$MAKE" > config.var.tmp/bup-make
364 echo -n "$bup_python_config" > config.var.tmp/bup-python-config
365 echo -n "$with_pylint" > config.var.tmp/with-pylint
366 mv config.var.tmp config.var
368 if test -e bin; then rm -r bin; fi
370 (cd bin && ln -s "$MAKE" make)
375 found: python-config (%q)
376 found: git (%q, ($("$bup_git" --version))
378 "$bup_python_config" \
386 if test "$found"; then
392 summarize "$bup_have_readline" 'readline support (e.g. bup ftp)'
393 summarize "$bup_have_libacl" 'POSIX ACL support'