Blitz logo

Blitz Support :

From: Frank Schimmel (frs_at_[hidden])
Date: 2004-04-16 03:25:54


Hendrik,

I have been using a little custom autoconf function to check for
blitz (attached). You can use that one for a start, but it actually
*requires* blitz: you cannot tell it not to use it. So maybe you'll
have to do some modifications...

To use it include the function directly in `acinclude.m4' or do a
`sinclude(frs_lib_blitz.m4)' instead. It defines the variables
`BLITZ_CXXFLAGS' and `BLITZ_LIBS' to use in your `Makefile.am' (or to
append directly to `CXXFLAGS' in `configure.in'. Oh, and for safety
also do a `m4_pattern_forbid(frs_LIB)' in `acinclude.m4'. This tells
autoconf that everything starting with 'frs_LIB' is an autoconf
function and that it should complain it it cant find the necessary
definitions.

>>>>> Hendrik Belitz writes:

> Hi all,
> I'm using the blitz++ in my project as an optional feature and
> would like to detect the library automatically with an autoconf
> macro. Is there any global function with could be used for
> identification? The usual

> AC_CHECK_LIB( blitz, main, have_blitz=yes, have_blitz=no, -lm )

Well, there is no function main() in libblitz. Actually, I'm not sure
there is any real function in there. That's why I check for `_blitz_id',
which is a C string. (Which once contained the version number but does
not anymore...)

> doesn't work.

Best regards
-Frank Schimmel

dnl -*- Autoconf -*-
dnl frs_LIB_BLITZ - check for blitz++ library
dnl
dnl Sets and substitutes variables BLITZ_CXXFLAGS and BLITZ_LIBS
dnl
dnl lacks real test program...
dnl
dnl
AC_DEFUN(frs_LIB_BLITZ,
[AC_MSG_CHECKING([for blitz++ library])
AC_MSG_RESULT([]) dnl for newline
AC_ARG_WITH(blitz,
  AC_HELP_STRING([--with-blitz-include=DIR],
                 [Specify include search path for blitz++]))
AC_ARG_WITH(blitz,
  AC_HELP_STRING([--with-blitz=DIR],
                 [Specify include and library search path for blitz++]))

if test "$with_blitz" = "no"; then
    AC_MSG_ERROR([
*** This software requires the blitz++ library.
*** It can be obtained freely from the blitz++ web site
*** http://oonumerics.org/blitz/])
fi

if test "${with_blitz+set}" = set; then
    if test -d "${with_blitz}/include"; then
        frs_cv_lib_blitz_cxxflags="-I${with_blitz}/include"
    else
        frs_cv_lib_blitz_cxxflags="-I${with_blitz}"
    fi
        if test "${with_blitz_include+set}" = set; then
            frs_cv_lib_blitz_cxxflags="-I${with_blitz_include}"
        fi
else
    frs_cv_lib_blitz_cxxflags=""
fi

if test "${with_blitz+set}" = set; then
    if test -d "${with_blitz}/lib"; then
        frs_cv_lib_blitz_libs="-L${with_blitz}/lib -lblitz"
    else
        frs_cv_lib_blitz_libs="-L${with_blitz} -lblitz"
    fi
else
    frs_cv_lib_blitz_libs="-lblitz"
fi

BLITZ_CXXFLAGS=$frs_cv_lib_blitz_cxxflags
BLITZ_LIBS=$frs_cv_lib_blitz_libs

# save old language settings
frs_save_CPPFLAGS=$CPPFLAGS
frs_save_CXXFLAGS=$CXXFLAGS
frs_save_LIBS=$LIBS
CPPFLAGS="$CPPFLAGS $BLITZ_CXXFLAGS"
CXXFLAGS="$CXXFLAGS $BLITZ_CXXFLAGS"
LIBS="$LIBS $BLITZ_DLFLAGS"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS

# try to find header <blitz/blitz.h>
AC_CHECK_HEADER(blitz/blitz.h,,
AC_MSG_ERROR([Cannot find <blitz/blitz.h> header file.
    You can use options --with-blitz=DIR or
    --with-blitz-include=DIR to specify its location.

*** This software requires the blitz++ library.
*** It can be obtained freely from the blitz++ web site
*** http://oonumerics.org/blitz/]))

# try linking to libblitz
AC_MSG_CHECKING([linking against libblitz])
AC_TRY_LINK([#include <iostream>
extern "C++" {
  char* _blitz_id;
}], [std::cout << _blitz_id << std::endl;],,
AC_MSG_ERROR([Cannot link against blitz library.
    You can use options --with-blitz=DIR to specify its location.

*** This software requires the blitz++ library.
*** It can be obtained freely from the blitz++ web site
*** http://oonumerics.org/blitz/]))
AC_MSG_RESULT([OK])

dnl This has to be AC_CHECK_HEADER (no `S')!
dnl Otherwise HAVE_BLITZ_TINYVEC_H would be defined, which is ambiguous...
AC_CHECK_HEADER(blitz/TinyVec.h,
  AC_DEFINE(HAVE_BLITZ_CAPITAL_TINYVEC_H, 1,
            [defined if Blitz++ has TinyVec.h]))
AC_CHECK_HEADERS(blitz/tinyvec-et.h)

# restore old language settings
AC_LANG_RESTORE
CPPFLAGS=$frs_save_CPPFLAGS
CXXFLAGS=$frs_save_CXXFLAGS
LIBS=$frs_save_LIBS

AC_MSG_RESULT([... blitz++ library is OK])

AC_SUBST(BLITZ_CXXFLAGS)
AC_SUBST(BLITZ_LIBS)
])
dnl EOF