X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=config%2Fconfigure;h=916bec371ea8864f563e5b422aa6962ef374cbfc;hb=8f1a5aace7788ee23fb67530252ba434f35e7c51;hp=19cac075026fd544d72ed0202d2471feb6bb35cc;hpb=bf6e0c48f278f3ea9917a7704ef5770a84cdb1b7;p=bup.git diff --git a/config/configure b/config/configure index 19cac07..916bec3 100755 --- a/config/configure +++ b/config/configure @@ -1,4 +1,37 @@ -#!/bin/sh +#!/usr/bin/env bash + +bup_find_prog() +{ + # Prints prog path to stdout or nothing. + local name="$1" result="$2" + TLOGN "checking for $name" + if ! [ "$result" ]; then + result=`acLookFor "$name"` + fi + TLOG " ($result)" + echo "$result" +} + +bup_try_c_code() +{ + local code="$1" tmpdir rc cflags='' + if test -z "$code"; then + AC_FAIL "No code provided to test compile" + fi + case "$#" in + 1) ;; + 2) cflags="$2" ;; + *) + AC_FAIL "Invald call to bup_try_c_code" "$@" + ;; + esac + tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $? + echo "$code" > "$tmpdir/test.c" || exit $? + $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c" + rc=$? + rm -r "$tmpdir" || exit $? + return $rc +} TARGET=bup @@ -11,47 +44,277 @@ if ! AC_PROG_CC; then exit 1 fi -TLOGN "checking the GNU make" -MAKE=`acLookFor make` -if [ -z "$MAKE" ]; then - AC_FAIL " Cannot find make"; +MAKE="$(bup_find_prog make "$MAKE")" +if test -z "$MAKE"; then + MAKE="$(bup_find_prog gmake "$GMAKE")" fi -MAKE_GNU=`$MAKE --version | grep "GNU Make"` -if [ -z "$MAKE_GNU" ]; then - AC_FAIL " $MAKE is not GNU Make" +if test -z "$MAKE"; then + AC_FAIL "ERROR: unable to find make" +fi + +if ! ($MAKE --version | grep "GNU Make"); then + AC_FAIL "ERROR: $MAKE is not GNU Make" fi MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'` if [ -z "$MAKE_VERSION" ]; then - AC_FAIL " $MAKE --version does not return sensible output?" + AC_FAIL "ERROR: $MAKE --version does not return sensible output?" +fi +expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81" + +AC_SUB bup_make "$MAKE" + +bup_python="$(type -p "$PYTHON")" +test -z "$bup_python" && bup_python="$(bup_find_prog python2.7 '')" +test -z "$bup_python" && bup_python="$(bup_find_prog python2.6 '')" +test -z "$bup_python" && bup_python="$(bup_find_prog python2 '')" +test -z "$bup_python" && bup_python="$(bup_find_prog python '')" +if test -z "$bup_python"; then + AC_FAIL "ERROR: unable to find python" +else + AC_SUB bup_python "$bup_python" + AC_SUB bup_python_majver \ + "$("$bup_python" -c 'import sys; print(sys.version_info[0])')" fi -expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "$MAKE must be >= version 3.81" -TLOG " ok" -TLOGN "checking the python" -PYTHON=`acLookFor python` -if [ -z "$PYTHON" ]; then - AC_FAIL " Cannot find python"; +bup_git="$(bup_find_prog git '')" +if test -z "$bup_git"; then + AC_FAIL "ERROR: unable to find git" +fi + +# For stat. +AC_CHECK_HEADERS sys/stat.h +AC_CHECK_HEADERS sys/types.h + +# For stat and mincore. +AC_CHECK_HEADERS unistd.h + +# For mincore. +AC_CHECK_HEADERS sys/mman.h + +# For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS. +AC_CHECK_HEADERS linux/fs.h +AC_CHECK_HEADERS sys/ioctl.h + +# On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work. +if [ -z "$OS_GNU_KFREEBSD" ]; then + AC_CHECK_FUNCS utimensat fi -TLOG " - you have some python program - ok" +AC_CHECK_FUNCS utimes +AC_CHECK_FUNCS lutimes + + +builtin_mul_overflow_code=" +#include +int main(int argc, char **argv) +{ + size_t n = 0, size = 0, total; + __builtin_mul_overflow(n, size, &total); + return 0; +} +" -TLOGN "checking the git" -GIT=`acLookFor git` -if [ -z "$GIT" ]; then - AC_FAIL " Cannot find git"; +TLOGN "checking for __builtin_mul_overflow" +if bup_try_c_code "$builtin_mul_overflow_code"; then + AC_DEFINE BUP_HAVE_BUILTIN_MUL_OVERFLOW 1 + TLOG ' (found)' +else + TLOG ' (not found)' fi -TLOG " - you have some git program - ok" -# assuming the above checks pass, get the path of everything -MF_PATH_INCLUDE GMAKE make gmake -MF_PATH_INCLUDE GIT git -MF_PATH_INCLUDE TAR tar gtar -MF_PATH_INCLUDE PYTHON python +AC_CHECK_FUNCS mincore + +mincore_incore_code=" +#if 0$ac_defined_HAVE_UNISTD_H +#include +#endif +#if 0$ac_defined_HAVE_SYS_MMAN_H +#include +#endif +int main(int argc, char **argv) +{ + if (MINCORE_INCORE) + return 0; +} +" + +mincore_buf_type_code() +{ + local vec_type="$1" + echo " +#include +int main(int argc, char **argv) +{ + void *x = 0; + $vec_type *buf = 0; + return mincore(x, 0, buf); +}" || exit $? +} + +if test "$ac_defined_HAVE_MINCORE"; then + TLOGN "checking for MINCORE_INCORE" + if bup_try_c_code "$mincore_incore_code"; then + AC_DEFINE BUP_HAVE_MINCORE_INCORE 1 + TLOG ' (found)' + else + TLOG ' (not found)' + fi + + TLOGN "checking mincore buf type" + if bup_try_c_code "$(mincore_buf_type_code char)"; then + AC_DEFINE BUP_MINCORE_BUF_TYPE 'char' + TLOG ' (char)' + elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then + AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char' + TLOG ' (unsigned char)' + else + AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com" + fi +fi + + +TLOGN "checking for readline" +bup_have_readline='' +bup_readline_includes_in_subdir='' +bup_readline_via_pkg_config='' +# We test this specific thing because it should work everywhere and it was +# a particulary problem on macos (we'd get the wrong includes if we just +# tested that the includes work). +readline_test_code=' + static char *on_completion_entry(const char *text, int state) { return NULL; } + void bup_test(void) { rl_completion_entry_function = on_completion_entry; } +' +if pkg-config readline; then + bup_readline_cflags="$(pkg-config readline --cflags)" || exit $? + bup_readline_ldflags="$(pkg-config readline --libs)" || exit $? + # It looks like it's not uncommon for pkg-config to provide a -I + # that doesn't support the documentation's specified #include + # . See what's really going on. + if bup_try_c_code "#include $readline_test_code" \ + "$bup_readline_cflags" + then + bup_have_readline=1 + bup_readline_includes_in_subdir=1 + elif bup_try_c_code "#include $readline_test_code" \ + "$bup_readline_cflags" + then + bup_have_readline=1 + fi + if test "$bup_have_readline"; then + bup_readline_via_pkg_config=1 + else + bup_readline_cflags='' + bup_readline_ldflags='' + fi +fi +if ! test "$bup_have_readline"; then + if bup_try_c_code "#include $readline_test_code"; then + bup_readline_ldflags=-lreadline + bup_have_readline=1 + bup_readline_includes_in_subdir=1 + elif bup_try_c_code "#include $readline_test_code"; then + bup_readline_ldflags=-lreadline + bup_have_readline=1 + fi +fi +if test "$bup_have_readline"; then + AC_DEFINE BUP_HAVE_READLINE 1 + if test "$bup_readline_includes_in_subdir"; then + AC_DEFINE BUP_READLINE_INCLUDES_IN_SUBDIR 1 + fi + if test "$bup_readline_via_pkg_config"; then + TLOG ' (yes, pkg-config)' + else + TLOG ' (yes)' + fi +fi + + +AC_SUB bup_readline_cflags "$bup_readline_cflags" +AC_SUB bup_readline_ldflags "$bup_readline_ldflags" +AC_SUB bup_have_readline "$bup_have_readline" + + +AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h +AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h +AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h + +AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h +AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h +AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h + +AC_CHECK_FIELD tm tm_gmtoff time.h + + +orig_ac_cc="$AC_CC" +orig_libs="$LIBS" +TLOGN "checking for libacl" +if pkg-config libacl; then + bup_libacl_cflags="$(pkg-config libacl --cflags)" + bup_libacl_ldflags="$(pkg-config libacl --libs)" + TLOG ' (yes, pkg-config)' +else + bup_libacl_cflags= + bup_libacl_ldflags='-lacl' + TLOG ' (yes)' +fi +AC_CC="$AC_CC${bup_libacl_cflags:+ $bup_libacl_cflags}" +LIBS="$bup_libacl_ldflags" +AC_CHECK_HEADERS sys/acl.h +AC_CHECK_HEADERS acl/libacl.h +AC_CHECK_FUNCS acl_get_file +AC_CHECK_FUNCS acl_from_text +AC_CHECK_FUNCS acl_set_file +# Note: These are linux specific, but we need them (for now?) +AC_CHECK_FUNCS acl_extended_file +AC_CHECK_FUNCS acl_to_any_text +TLOGN "checking for complete acl support" +if test "$ac_defined_HAVE_ACL_EXTENDED_FILE"; then + bup_have_libacl=1 + AC_SUB bup_libacl_cflags "$bup_libacl_cflags" + AC_SUB bup_libacl_ldflags "$bup_libacl_ldflags" + TLOG ' (yes)' +else + bup_have_libacl= + AC_SUB bup_have_libacl '' + TLOG ' (no)' +fi +AC_SUB bup_have_libacl "$bup_have_libacl" +AC_CC="$orig_ac_cc" +LIBS="$orig_libs" -AC_CHECK_HEADERS sys/stat.h -AC_CHECK_FUNCS utimensat -AC_CHECK_FUNCS utime AC_OUTPUT config.vars + +if test -e config.var; then rm -r config.var; fi +mkdir -p config.var +echo -n "$MAKE" > config.var/bup-make +echo -n "$bup_python" > config.var/bup-python + +if test -e bin; then rm -r bin; fi +mkdir -p bin +cd bin && ln -s "$bup_python" python + +printf " +found: python (%q, $("$bup_python" --version 2>&1)) +found: git (%q, ($("$bup_git" --version)) +" \ + "$bup_python" \ + "$bup_git" \ + 1>&5 + +summarize() +{ + local found="$1" + shift + if test "$found"; then + TLOG found: "$@" + else + TLOG not found: "$@" + fi +} +summarize "$bup_have_readline" 'readline support (e.g. bup ftp)' +summarize "$bup_have_libacl" 'POSIX ACL support' +TLOG