File: ac_infiniband.m4

package info (click to toggle)
adios 1.3-11
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 7,376 kB
  • sloc: ansic: 48,186; sh: 9,682; cpp: 2,662; f90: 1,390; makefile: 895; python: 372; xml: 301
file content (132 lines) | stat: -rw-r--r-- 3,971 bytes parent folder | download
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
dnl @synopsis AC_INFINIBAND([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
dnl
dnl This macro tries to find out how to compile programs that
dnl use the Infiniband ibverbs API.
dnl
dnl On success, it defines HAVE_INFINIBAND and sets INFINIBAND_LIBS
dnl to any libraries that are needed for linking
dnl Infiniband (e.g. -libverbs,...).
dnl
dnl If you want to compile everything with Portals, you should set:
dnl
dnl     LIBS="$PTL_LIBS $LIBS"
dnl
dnl ACTION-IF-FOUND is a list of shell commands to run if a Infiniband
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands
dnl to run it if it is not found.  If ACTION-IF-FOUND is not specified,
dnl the default action will define HAVE_INFINIBAND.
dnl
dnl @version $Id: ac_infiniband.m4 676 2006-05-16 20:44:08Z thkorde $
dnl @author Todd H. Kordenbrock <thkorde@sandia.gov>

AC_DEFUN([AC_INFINIBAND], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([ACX_PTHREAD])
AC_LANG_SAVE
AC_LANG_C
ac_infiniband_hdr_ok=no
ac_infiniband_lib_ok=no
ac_with_infiniband=no


INFINIBAND_CFLAGS=""
INFINIBAND_CPPFLAGS=""
INFINIBAND_LDFLAGS=""
INFINIBAND_LIBS=""

AC_ARG_WITH(infiniband,
        [  --with-infiniband=DIR      Location of Infiniband],
        [ ac_with_infiniband=yes;])



if test x"$withval" = xno; then

        ac_with_infiniband=no;

elif test x"$withval" = xyes -o x"$withval" = x; then

        INFINIBAND_CPPFLAGS="";
        INFINIBAND_LDFLAGS="";
        ac_with_infiniband=yes;

else

        INFINIBAND_CPPFLAGS="-I$withval/include";
        INFINIBAND_LDFLAGS="-L$withval/lib64 -L$withval/lib";
        ac_with_infiniband=yes;

fi

AM_CONDITIONAL(HAVE_INFINIBAND,test x$ac_with_infiniband = xyes)


dnl Check for command-line disable
if test x"$ac_with_infiniband" = xyes; then

        dnl Look for Infiniband header files
        save_CPPFLAGS=$CPPFLAGS;
        CPPFLAGS="$CPPFLAGS $INFINIBAND_CPPFLAGS"
        LDFLAGS="$LDFLAGS $INFINIBAND_LDFLAGS"


        if test x"$ac_infiniband_hdr_ok" = xno; then
                AC_CHECK_HEADER(infiniband/verbs.h,
                         [AC_DEFINE(HAVE_IBVERBS_H, 1,
                                [Define to 1 if you have <infiniband/verbs.h>.])
                         ac_infiniband_hdr_ok=yes;
                         INFINIBAND_CFLAGS="$INFINIBAND_CFLAGS $EXTRA_CFLAGS";
                         INFINIBAND_CPPFLAGS="$INFINIBAND_CPPFLAGS $EXTRA_CFLAGS"],
                         [ac_infiniband_hdr_ok=no])
        fi

        if test x"$ac_infiniband_hdr_ok" = xno; then
                CPPFLAGS=$save_CPPFLAGS
        fi

        dnl Look for -libverbs
        if test x"$ac_infiniband_lib_ok" = xno -a x$ac_infiniband_hdr_ok = xyes; then
            save_LIBS=$LIBS;
            LIBS=""
            AC_SEARCH_LIBS(ibv_alloc_pd,[ibverbs],
                    [ac_infiniband_lib_ok=yes],
                    [ac_infiniband_lib_ok=no],
                    [$save_LIBS $PTHREAD_LDFLAGS $PTHREAD_LIBS])
            if test -n $LIBS; then
                INFINIBAND_LIBS="$INFINIBAND_LIBS $LIBS";
            fi
            LIBS=$save_LIBS;
        fi

        if test x"$ac_infiniband_hdr_ok" = xno -o x$ac_infiniband_lib_ok = xno; then
            AM_CONDITIONAL(HAVE_INFINIBAND,false)
            INFINIBAND_CFLAGS=""
            INFINIBAND_CPPFLAGS=""
            INFINIBAND_LDFLAGS=""
            INFINIBAND_LIBS=""
            ac_with_infiniband=no
        else
            AM_CONDITIONAL(HAVE_INFINIBAND,true)
        fi


        AC_SUBST(INFINIBAND_CPPFLAGS)
        AC_SUBST(INFINIBAND_CFLAGS)
        AC_SUBST(INFINIBAND_LDFLAGS)
        AC_SUBST(INFINIBAND_LIBS)
        AC_SUBST(INFINIBAND_HEADER)


        # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
        if test x"$ac_infiniband_lib_ok" = xyes; then
                ifelse([$1],,[AC_DEFINE(HAVE_INFINIBAND,1,[Define if you have the Infiniband.])],[$1])
                :
        else
                $2
                :
        fi

fi

AC_LANG_RESTORE
])dnl AC_INFINIBAND