1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
|
#!/usr/bin/env bash
ac_help="--with-pylint[=yes|no|maybe] require and run pylint (maybe)"
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
}
bup_config_cflags=()
bup-add-cflag-if-supported()
{
local opt="$1"
if test -z "$opt"; then
AC_FAIL 'No option to check'
fi
TLOGN "checking for $AC_CC $opt support"
if bup_try_c_code \
"int main(int argc, char**argv) { return 0; }" \
"$opt";
then
bup_config_cflags+="$opt"
TLOG ' (found)'
else
TLOG ' (not found)'
fi
}
TARGET=bup
argv=()
with_pylint=maybe
while test $# -gt 0; do
case "$1" in
--with-pylint=yes) with_pylint=yes; shift;;
--with-pylint=maybe) with_pylint=maybe; shift;;
--with-pylint=no) with_pylint=no; shift;;
*) argv+=("$1"); shift;;
esac
done
# Set $@ to the adjusted args
set - "${argv[@]}"
. ./configure.inc
# FIXME: real tmpdir
rm -rf finished config/bin config.var config.var.tmp config.vars
AC_INIT $TARGET
if ! AC_PROG_CC; then
LOG " You need to have a functional C compiler to build $TARGET"
exit 1
fi
bup-add-cflag-if-supported -Wno-unused-command-line-argument
# Since ./configure changes pwd, fix MAKE if it's relative
case "$MAKE" in
/*) ;;
*/*) MAKE="../../$MAKE";;
esac
for make_candidate in make gmake; do
found_make="$(bup_find_prog "$make_candidate" "$MAKE")"
if test "$found_make" \
&& ("$found_make" --version | grep "GNU Make"); then
MAKE="$found_make"
break;
fi
done
if ! test "$MAKE"; then
AC_FAIL "ERROR: unable to find GNU make as make or gmake"
fi
MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
if [ -z "$MAKE_VERSION" ]; then
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"
# Haven't seen a documented way to determine the python version via
# python-config right now, so we'll defer version checking until
# later.
if test "$BUP_PYTHON_CONFIG"; then
bup_python_config="$(type -p "$BUP_PYTHON_CONFIG")"
if test -z "$bup_python_config"; then
AC_FAIL $(printf "ERROR: BUP_PYTHON_CONFIG value %q appears invalid" \
"$BUP_PYTHON_CONFIG")
fi
else
for py_min_ver in 11 10 9 8 7; do
bup_python_config="$(bup_find_prog "python3.$py_min_ver-config" '')"
test -z "$bup_python_config" || break
done
test -z "$bup_python_config" \
&& bup_python_config="$(bup_find_prog python3-config '')"
if test -z "$bup_python_config"; then
AC_FAIL "ERROR: unable to find a suitable python-config"
fi
fi
bup_python_cflags=$("$bup_python_config" --cflags) || exit $?
bup_python_ldflags=$("$bup_python_config" --ldflags) || exit $?
bup_python_cflags_embed=$("$bup_python_config" --cflags --embed)
if test $? -eq 0; then
bup_python_ldflags_embed=$("$bup_python_config" --ldflags --embed) || exit $?
else # Earlier versions didn't support --embed
bup_python_cflags_embed=$("$bup_python_config" --cflags) || exit $?
bup_python_ldflags_embed=$("$bup_python_config" --ldflags) || exit $?
fi
bup_python_cflags="$bup_python_cflags -fPIC"
case "$OSTYPE" in
darwin*)
# For at least 10.3+ (2003+)
bup_python_ldflags="$bup_python_ldflags -bundle -undefined dynamic_lookup"
;;
*)
bup_python_ldflags="$bup_python_ldflags -shared"
;;
esac
AC_SUB bup_python_config "$bup_python_config"
AC_SUB bup_python_cflags "$bup_python_cflags"
AC_SUB bup_python_ldflags "$bup_python_ldflags"
AC_SUB bup_python_cflags_embed "$bup_python_cflags_embed"
AC_SUB bup_python_ldflags_embed "$bup_python_ldflags_embed"
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
AC_CHECK_FUNCS utimes
AC_CHECK_FUNCS lutimes
AC_CHECK_FUNCS mincore
mincore_incore_code="
#if 0$ac_defined_HAVE_UNISTD_H
#include <unistd.h>
#endif
#if 0$ac_defined_HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
int main(int argc, char **argv)
{
if (MINCORE_INCORE)
return 0;
}
"
mincore_buf_type_code()
{
local vec_type="$1"
echo "
#include <sys/mman.h>
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
# <readline/readline.h>. See what's really going on.
if bup_try_c_code "#include <stdio.h> // required by unpatched readline
#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 <stdio.h> // required by unpatched readline
#include <readline.h>
$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/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> $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_SUB bup_config_cflags "$bup_config_cflags"
AC_OUTPUT config.vars
set -euo pipefail
# FIXME: real tmpdir
mkdir -p config.var.tmp
echo -n "$MAKE" > config.var.tmp/bup-make
echo -n "$bup_python_config" > config.var.tmp/bup-python-config
echo -n "$with_pylint" > config.var.tmp/with-pylint
mv config.var.tmp config.var
if test -e bin; then rm -r bin; fi
mkdir -p bin
(cd bin && ln -s "$MAKE" make)
touch finished
printf "
found: python-config (%q)
found: git (%q, ($("$bup_git" --version))
" \
"$bup_python_config" \
"$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
|