1dnl Process this file with autoconf to produce a configure script.
2
3AC_PREREQ(2.57)
4AC_INIT(libmthca, 1.0.5, openib-general@openib.org)
5AC_CONFIG_SRCDIR([src/mthca.h])
6AC_CONFIG_AUX_DIR(config)
7AM_CONFIG_HEADER(config.h)
8AM_INIT_AUTOMAKE(libmthca, 1.0.5)
9AM_PROG_LIBTOOL
10
11AC_ARG_WITH([valgrind],
12    AC_HELP_STRING([--with-valgrind],
13        [Enable Valgrind annotations (small runtime overhead, default NO)]))
14if test x$with_valgrind = x || test x$with_valgrind = xno; then
15    want_valgrind=no
16    AC_DEFINE([NVALGRIND], 1, [Define to 1 to disable Valgrind annotations.])
17else
18    want_valgrind=yes
19    if test -d $with_valgrind; then
20        CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
21    fi
22fi
23
24dnl Checks for programs
25AC_PROG_CC
26
27dnl Checks for libraries
28AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
29    AC_MSG_ERROR([ibv_get_device_list() not found.  libmthca requires libibverbs.]))
30
31dnl Checks for header files.
32AC_CHECK_HEADER(infiniband/driver.h, [],
33    AC_MSG_ERROR([<infiniband/driver.h> not found.  libmthca requires libibverbs.]))
34AC_HEADER_STDC
35AC_CHECK_HEADER(valgrind/memcheck.h,
36    [AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
37        [Define to 1 if you have the <valgrind/memcheck.h> header file.])],
38    [if test $want_valgrind = yes; then
39        AC_MSG_ERROR([Valgrind memcheck support requested, but <valgrind/memcheck.h> not found.])
40    fi])
41
42dnl Checks for typedefs, structures, and compiler characteristics.
43AC_C_CONST
44AC_CHECK_SIZEOF(long)
45
46dnl Checks for library functions
47AC_CHECK_FUNCS(ibv_read_sysfs_file ibv_dontfork_range ibv_dofork_range \
48    ibv_register_driver)
49
50dnl Now check if for libibverbs 1.0 vs 1.1
51dummy=if$$
52cat <<IBV_VERSION > $dummy.c
53#include <infiniband/driver.h>
54IBV_DEVICE_LIBRARY_EXTENSION
55IBV_VERSION
56IBV_DEVICE_LIBRARY_EXTENSION=`$CC $CPPFLAGS -E $dummy.c 2> /dev/null | tail -1`
57rm -f $dummy.c
58AM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION,
59    test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION)
60AC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION)
61
62AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
63    [if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
64        ac_cv_version_script=yes
65    else
66        ac_cv_version_script=no
67    fi])
68
69if test $ac_cv_version_script = yes; then
70    MTHCA_VERSION_SCRIPT='-Wl,--version-script=$(srcdir)/src/mthca.map'
71else
72    MTHCA_VERSION_SCRIPT=
73fi
74AC_SUBST(MTHCA_VERSION_SCRIPT)
75
76AC_CONFIG_FILES([Makefile libmthca.spec])
77AC_OUTPUT
78