]> arthur.barton.de Git - bup.git/blob - config/configure
config/configure: find bash via env (as we should)
[bup.git] / config / configure
1 #!/usr/bin/env bash
2
3 bup_find_prog()
4 {
5     # Prints prog path to stdout or nothing.
6     local name="$1" result="$2"
7     TLOGN "checking for $name"
8     if ! [ "$result" ]; then
9         result=`acLookFor "$name"`
10     fi
11     TLOG " ($result)"
12     echo "$result"
13 }
14
15 bup_try_c_code()
16 {
17     local code="$1" tmpdir rc
18     if test -z "$code"; then
19         AC_FAIL "No code provided to test compile"
20     fi
21     tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
22     echo "$code" > "$tmpdir/test.c" || exit $?
23     $AC_CC -Wall -Werror -c -o "$tmpdir/test" "$tmpdir/test.c"
24     rc=$?
25     rm -r "$tmpdir" || exit $?
26     return $rc
27 }
28
29 TARGET=bup
30
31 . ./configure.inc
32
33 AC_INIT $TARGET
34
35 if ! AC_PROG_CC; then
36     LOG " You need to have a functional C compiler to build $TARGET"
37     exit 1
38 fi
39
40 MAKE="$(bup_find_prog make $MAKE)"
41 if test -z "$MAKE"; then
42     MAKE="$(bup_find_prog gmake "$GMAKE")"
43 fi
44
45 if test -z "$MAKE"; then
46     AC_FAIL "ERROR: unable to find make"
47 fi
48
49 if ! ($MAKE --version | grep "GNU Make"); then
50     AC_FAIL "ERROR: $MAKE is not GNU Make"
51 fi
52
53 MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
54 if [ -z "$MAKE_VERSION" ]; then
55     AC_FAIL "ERROR: $MAKE --version does not return sensible output?"
56 fi
57 expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "ERROR: $MAKE must be >= version 3.81"
58
59 if test -z "$(bup_find_prog python '')"; then
60     AC_FAIL "ERROR: unable to find python"
61 fi
62
63 if test -z "$(bup_find_prog git '')"; then
64     AC_FAIL "ERROR: unable to find git"
65 fi
66
67 # For stat.
68 AC_CHECK_HEADERS sys/stat.h
69 AC_CHECK_HEADERS sys/types.h
70
71 # For stat and mincore.
72 AC_CHECK_HEADERS unistd.h
73
74 # For mincore.
75 AC_CHECK_HEADERS sys/mman.h
76
77 # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS.
78 AC_CHECK_HEADERS linux/fs.h
79 AC_CHECK_HEADERS sys/ioctl.h
80
81 # On GNU/kFreeBSD utimensat is defined in GNU libc, but won't work.
82 if [ -z "$OS_GNU_KFREEBSD" ]; then
83     AC_CHECK_FUNCS utimensat
84 fi
85 AC_CHECK_FUNCS utimes
86 AC_CHECK_FUNCS lutimes
87
88
89 AC_CHECK_FUNCS mincore
90
91 mincore_incore_code="
92 #if 0$ac_defined_HAVE_UNISTD_H
93 #include <unistd.h>
94 #endif
95 #if 0$ac_defined_HAVE_SYS_MMAN_H
96 #include <sys/mman.h>
97 #endif
98 int main(int argc, char **argv)
99 {
100     if (MINCORE_INCORE)
101       return 0;
102 }
103 "
104
105 mincore_buf_type_code()
106 {
107     local vec_type="$1"
108     echo "
109 #include <sys/mman.h>
110 int main(int argc, char **argv)
111 {
112     void *x = 0;
113     $vec_type *buf = 0;
114     return mincore(x, 0, buf);
115 }" || exit $?
116 }
117
118 if test "$ac_defined_HAVE_MINCORE"; then
119     TLOGN "checking for MINCORE_INCORE"
120     if bup_try_c_code "$mincore_incore_code"; then
121         AC_DEFINE BUP_HAVE_MINCORE_INCORE 1
122         TLOG ' (found)'
123     else
124         TLOG ' (not found)'
125     fi
126
127     TLOGN "checking mincore buf type"
128     if bup_try_c_code "$(mincore_buf_type_code char)"; then
129         AC_DEFINE BUP_MINCORE_BUF_TYPE 'char'
130         TLOG ' (char)'
131     elif bup_try_c_code "$(mincore_buf_type_code 'unsigned char')"; then
132         AC_DEFINE BUP_MINCORE_BUF_TYPE 'unsigned char'
133         TLOG ' (unsigned char)'
134     else
135         AC_FAIL "ERROR: unexpected mincore definition; please notify bup-list@googlegroups.com"
136     fi
137 fi
138
139
140 AC_CHECK_FIELD stat st_atim sys/types.h sys/stat.h unistd.h
141 AC_CHECK_FIELD stat st_mtim sys/types.h sys/stat.h unistd.h
142 AC_CHECK_FIELD stat st_ctim sys/types.h sys/stat.h unistd.h
143
144 AC_CHECK_FIELD stat st_atimensec sys/types.h sys/stat.h unistd.h
145 AC_CHECK_FIELD stat st_mtimensec sys/types.h sys/stat.h unistd.h
146 AC_CHECK_FIELD stat st_ctimensec sys/types.h sys/stat.h unistd.h
147
148 AC_CHECK_FIELD tm tm_gmtoff time.h
149
150 AC_OUTPUT config.vars