1219820Sjeffdnl Process this file with autoconf to produce a configure script.
2219820Sjeff
3219820SjeffAC_PREREQ(2.57)
4219820SjeffAC_INIT(libmthca, 1.0.5, openib-general@openib.org)
5219820SjeffAC_CONFIG_SRCDIR([src/mthca.h])
6219820SjeffAC_CONFIG_AUX_DIR(config)
7219820SjeffAM_CONFIG_HEADER(config.h)
8219820SjeffAM_INIT_AUTOMAKE(libmthca, 1.0.5)
9219820SjeffAM_PROG_LIBTOOL
10219820Sjeff
11219820SjeffAC_ARG_WITH([valgrind],
12219820Sjeff    AC_HELP_STRING([--with-valgrind],
13219820Sjeff        [Enable Valgrind annotations (small runtime overhead, default NO)]))
14219820Sjeffif test x$with_valgrind = x || test x$with_valgrind = xno; then
15219820Sjeff    want_valgrind=no
16219820Sjeff    AC_DEFINE([NVALGRIND], 1, [Define to 1 to disable Valgrind annotations.])
17219820Sjeffelse
18219820Sjeff    want_valgrind=yes
19219820Sjeff    if test -d $with_valgrind; then
20219820Sjeff        CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
21219820Sjeff    fi
22219820Sjefffi
23219820Sjeff
24219820Sjeffdnl Checks for programs
25219820SjeffAC_PROG_CC
26219820Sjeff
27219820Sjeffdnl Checks for libraries
28219820SjeffAC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
29219820Sjeff    AC_MSG_ERROR([ibv_get_device_list() not found.  libmthca requires libibverbs.]))
30219820Sjeff
31219820Sjeffdnl Checks for header files.
32219820SjeffAC_CHECK_HEADER(infiniband/driver.h, [],
33219820Sjeff    AC_MSG_ERROR([<infiniband/driver.h> not found.  libmthca requires libibverbs.]))
34219820SjeffAC_HEADER_STDC
35219820SjeffAC_CHECK_HEADER(valgrind/memcheck.h,
36219820Sjeff    [AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
37219820Sjeff        [Define to 1 if you have the <valgrind/memcheck.h> header file.])],
38219820Sjeff    [if test $want_valgrind = yes; then
39219820Sjeff        AC_MSG_ERROR([Valgrind memcheck support requested, but <valgrind/memcheck.h> not found.])
40219820Sjeff    fi])
41219820Sjeff
42219820Sjeffdnl Checks for typedefs, structures, and compiler characteristics.
43219820SjeffAC_C_CONST
44219820SjeffAC_CHECK_SIZEOF(long)
45219820Sjeff
46219820Sjeffdnl Checks for library functions
47219820SjeffAC_CHECK_FUNCS(ibv_read_sysfs_file ibv_dontfork_range ibv_dofork_range \
48219820Sjeff    ibv_register_driver)
49219820Sjeff
50219820Sjeffdnl Now check if for libibverbs 1.0 vs 1.1
51219820Sjeffdummy=if$$
52219820Sjeffcat <<IBV_VERSION > $dummy.c
53219820Sjeff#include <infiniband/driver.h>
54219820SjeffIBV_DEVICE_LIBRARY_EXTENSION
55219820SjeffIBV_VERSION
56219820SjeffIBV_DEVICE_LIBRARY_EXTENSION=`$CC $CPPFLAGS -E $dummy.c 2> /dev/null | tail -1`
57219820Sjeffrm -f $dummy.c
58219820SjeffAM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION,
59219820Sjeff    test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION)
60219820SjeffAC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION)
61219820Sjeff
62219820SjeffAC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
63219820Sjeff    [if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
64219820Sjeff        ac_cv_version_script=yes
65219820Sjeff    else
66219820Sjeff        ac_cv_version_script=no
67219820Sjeff    fi])
68219820Sjeff
69219820Sjeffif test $ac_cv_version_script = yes; then
70219820Sjeff    MTHCA_VERSION_SCRIPT='-Wl,--version-script=$(srcdir)/src/mthca.map'
71219820Sjeffelse
72219820Sjeff    MTHCA_VERSION_SCRIPT=
73219820Sjefffi
74219820SjeffAC_SUBST(MTHCA_VERSION_SCRIPT)
75219820Sjeff
76219820SjeffAC_CONFIG_FILES([Makefile libmthca.spec])
77219820SjeffAC_OUTPUT
78