dnl Copyright (C) 2004-2006 EDF dnl dnl This file is part of the FVM software package. For license dnl information, see the LICENSE file in the top level directory of the dnl FVM source distribution. # FVM_AC_TEST_BFT #---------------- # Check for BFT version AC_DEFUN([FVM_AC_TEST_BFT], [ AC_ARG_WITH(bft-prefix, [ --with-bft-prefix=DIR BFT installed under DIR] ) if test "x$with_bft_prefix" != "x" ; then BFT_CPPFLAGS="-I$with_bft_prefix/include" BFT_LDFLAGS="-L$with_bft_prefix/lib" bft_config="$with_bft_prefix/bin/bft-config" else BFT_CPPFLAGS="" BFT_LDFLAGS="" bft_config="bft-config" fi BFT_LIBS="-lbft" type "$bft_config" > /dev/null 2>&1 if test "$?" = "0" ; then BFT_CPPFLAGS="$BFT_CPPFLAGS `$bft_config --cppflags-user`" BFT_LDFLAGS="$BFT_LDFLAGS `$bft_config --ldflags-user`" BFT_LIBS="$BFT_LIBS `$bft_config --libs`" fi bft_version_min=$1 bft_version_max=$2 if test "x$bft_version_min" != "x" ; then if test "x$bft_version_max" != "x" ; then AC_MSG_CHECKING([for bft version >= $1 and <= $2]) else AC_MSG_CHECKING([for bft version >= $1]) fi else bft_version_min="0.0.0" fi [ cat > conftest.c < #include #include static void _extract_version(char *s, int v[3]) { int level, i, j, l; for (l = 0 ; s[l] != '\0'; l++); i = 0; for (level = 0 ; level < 3 ; level++) { for (j = i ; s[j] != '.' && j = l) v[level] = 0; else v[level] = atoi(s + i); i = j+1; } } int main(int argc, char **argv) { int level, v_min[3], v_max[3], v_bft[3]; char *s_min, *s_max; if (argc < 2) { printf("usage : %s min_version_string [max_version_string]\n", argv[0]); return 1; } v_bft[0] = BFT_MAJOR_VERSION; v_bft[1] = BFT_MINOR_VERSION; v_bft[2] = BFT_RELEASE_VERSION; s_min = argv[1]; _extract_version(s_min, v_min); for (level = 0 ; level < 3 ; level++) if (v_min[level] > v_bft[level]) return 1; if (argc == 3) { s_max = argv[2]; _extract_version(s_max, v_max); for (level = 0 ; level < 3 ; level++) if (v_max[level] < v_bft[level]) return 1; } return 0; } EOF ] CPPFLAGS="${CPPFLAGS} $BFT_CPPFLAGS" LDFLAGS="${LDFLAGS} $BFT_LDFLAGS" LIBS="${LIBS} $BFT_LIBS" echo "$CC $CPPFLAGS $CFLAGS $LDFLAGS $LIBS -o conftest conftest.c" 1>&5 2>&1 $CC $CPPFLAGS $CFLAGS $LDFLAGS $LIBS -o conftest conftest.c 1>&5 2>&1 ./conftest $bft_version_min $bft_version_max if test -s conftest && (./conftest $bft_version_min $bft_version_max; exit) 2>/dev/null then AC_MSG_RESULT([compatible bft version found]) else if test "x$bft_version_max" != "x" ; then AC_MSG_FAILURE([bft version >= $1 and <= $2 not found]) else AC_MSG_FAILURE([bft version >= $1 not found]) fi fi /bin/rm -f conftest*])dnl unset bft_version_min unset bft_version_max unset bft_config ])dnl