]> arthur.barton.de Git - bup.git/blobdiff - config/configure
Prefer python 3, and mention intent to drop python 2 support
[bup.git] / config / configure
index 33670dd45ed12584e3612a8eacd0cbe676e194a2..6ef05315feaaa0dc349bbf28a1c34d38736672de 100755 (executable)
@@ -66,6 +66,10 @@ expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.8
 AC_SUB bup_make "$MAKE"
 
 bup_python="$(type -p "$PYTHON")"
+test -z "$bup_python" && bup_python="$(bup_find_prog python3.8 '')"
+test -z "$bup_python" && bup_python="$(bup_find_prog python3.7 '')"
+test -z "$bup_python" && bup_python="$(bup_find_prog python3.6 '')"
+test -z "$bup_python" && bup_python="$(bup_find_prog python3 '')"
 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 '')"
@@ -74,8 +78,16 @@ 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])')"
+    bup_python_majver=$("$bup_python" -c 'import sys; print(sys.version_info[0])')
+    bup_python_minver=$("$bup_python" -c 'import sys; print(sys.version_info[1])')
+    AC_SUB bup_python_majver "$bup_python_majver"
+fi
+
+# May not be correct yet, i.e. actual requirement may be higher.
+if test "$bup_python_majver" -gt 2 -a "$bup_python_minver" -lt 3; then
+    # utime follow_symlinks >= 3.3
+    bup_version_str=$("$bup_python" --version 2>&1)
+    AC_FAIL "ERROR: found $bup_version_str (must be >= 3.3 if >= 3)"
 fi
 
 bup_git="$(bup_find_prog git '')"
@@ -97,13 +109,16 @@ AC_CHECK_HEADERS sys/mman.h
 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
+if test "$bup_python_majver" -gt 2; then
+    AC_DEFINE BUP_USE_PYTHON_UTIME 1
+else # Python 2
+    # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
+    if [ -z "$OS_GNU_KFREEBSD" ]; then
+        AC_CHECK_FUNCS utimensat
+    fi
+    AC_CHECK_FUNCS utimes
+    AC_CHECK_FUNCS lutimes
 fi
-AC_CHECK_FUNCS utimes
-AC_CHECK_FUNCS lutimes
-
 
 builtin_mul_overflow_code="
 #include <stddef.h>
@@ -179,17 +194,26 @@ 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
     # <readline/readline.h>.  See what's really going on.
-    if bup_try_c_code '#include <readline/readline.h>' "$bup_readline_cflags"
+    if bup_try_c_code "#include <readline/readline.h> $readline_test_code" \
+                      "$bup_readline_cflags"
     then
         bup_have_readline=1
         bup_readline_includes_in_subdir=1
-    elif bup_try_c_code '#include <readline.h>' "$bup_readline_cflags"
+    elif bup_try_c_code "#include <readline.h> $readline_test_code" \
+                        "$bup_readline_cflags"
     then
         bup_have_readline=1
     fi
@@ -201,11 +225,11 @@ if pkg-config readline; then
     fi
 fi
 if ! test "$bup_have_readline"; then
-    if bup_try_c_code '#include <readline/readline.h>'; then
+    if bup_try_c_code "#include <readline/readline.h> $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.h>'; then
+    elif bup_try_c_code "#include <readline.h> $readline_test_code"; then
         bup_readline_ldflags=-lreadline
         bup_have_readline=1
     fi
@@ -286,7 +310,7 @@ 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
+(cd bin && ln -s "$bup_python" python)
 
 printf "
 found: python (%q, $("$bup_python" --version 2>&1))