X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=config%2Fconfigure;h=fbf174fd8c95df5e0c591c917699af805102f445;hb=8c860f3d7fd2d0e028df1c2e252366a4c9f98130;hp=20b1b0101b4f1d2ac1d9b4294ddd08e408815964;hpb=6e74568a91d2d7e7912ba490a02f972dccfc99f3;p=bup.git diff --git a/config/configure b/config/configure index 20b1b01..fbf174f 100755 --- a/config/configure +++ b/config/configure @@ -1,4 +1,30 @@ -#!/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 + if test -z "$code"; then + AC_FAIL "No code provided to test compile" + fi + tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $? + echo "$code" > "$tmpdir/test.c" || exit $? + $AC_CC -Wall -Werror -c -o "$tmpdir/test" "$tmpdir/test.c" + rc=$? + rm -r "$tmpdir" || exit $? + return $rc +} TARGET=bup @@ -11,56 +37,135 @@ 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 "$MAKE must be >= version 3.81" -TLOG " ok" - -TLOGN "checking the python" -PYTHON=`acLookFor python` -if [ -z "$PYTHON" ]; then - AC_FAIL " Cannot find python"; +expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81" + +AC_SUB bup_make "$MAKE" + +bup_python="$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 -TLOG " - you have some python program - ok" -TLOGN "checking the git" -GIT=`acLookFor git` -if [ -z "$GIT" ]; then - AC_FAIL " Cannot find git"; +if test -z "$(bup_find_prog git '')"; then + AC_FAIL "ERROR: unable to find git" 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 # 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 -AC_CHECK_FUNCS utimensat -AC_CHECK_FUNCS utime +# 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 + + +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 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 + + +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 + 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 @@ -70,4 +175,10 @@ 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 + AC_OUTPUT config.vars + +mkdir -p config.var +echo -n "$MAKE" > config.var/bup-make +echo -n "$bup_python" > config.var/bup-python