Whamcloud - gitweb
check both names for symver file.
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
1 #
2 # LN_CONFIG_MAX_PAYLOAD
3 #
4 # configure maximum payload
5 #
6 AC_DEFUN([LN_CONFIG_MAX_PAYLOAD],
7 [AC_MSG_CHECKING([for non-default maximum LNET payload])
8 AC_ARG_WITH([max-payload-mb],
9         AC_HELP_STRING([--with-max-payload-mb=MBytes],
10                        [set maximum lnet payload in MBytes]),
11         [
12                 AC_MSG_RESULT([$with_max_payload_mb])
13                 LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
14                 LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"
15         ], [
16                 AC_MSG_RESULT([no])
17                 LNET_MAX_PAYLOAD="LNET_MTU"
18         ])
19         AC_DEFINE_UNQUOTED(LNET_MAX_PAYLOAD, $LNET_MAX_PAYLOAD,
20                            [Max LNET payload])
21 ])
22
23 #
24 # LN_CHECK_GCC_VERSION
25 #
26 # Check compiler version
27 #
28 AC_DEFUN([LN_CHECK_GCC_VERSION],
29 [AC_MSG_CHECKING([compiler version])
30 PTL_CC_VERSION=`$CC --version | awk '/^gcc/{print $ 3}'`
31 PTL_MIN_CC_VERSION="3.2.2"
32 v2n() {
33         awk -F. '{printf "%d\n", (($ 1)*100+($ 2))*100+($ 3)}'
34 }
35 if test -z "$PTL_CC_VERSION" -o \
36         `echo $PTL_CC_VERSION | v2n` -ge `echo $PTL_MIN_CC_VERSION | v2n`; then
37         AC_MSG_RESULT([ok])
38 else
39         AC_MSG_RESULT([Buggy compiler found])
40         AC_MSG_ERROR([Need gcc version >= $PTL_MIN_CC_VERSION])
41 fi
42 ])
43
44 #
45 # LN_CONFIG_AFFINITY
46 #
47 # check if cpu affinity is available/wanted
48 #
49 AC_DEFUN([LN_CONFIG_AFFINITY],
50 [AC_ARG_ENABLE([affinity],
51         AC_HELP_STRING([--disable-affinity],
52                        [disable process/irq affinity]),
53         [],[enable_affinity='yes'])
54
55 AC_MSG_CHECKING([for CPU affinity support])
56 if test x$enable_affinity = xno ; then
57         AC_MSG_RESULT([no (by request)])
58 else
59         LB_LINUX_TRY_COMPILE([
60                 #include <linux/sched.h>
61         ],[
62                 struct task_struct t;
63                 #if HAVE_CPUMASK_T
64                 cpumask_t     m;
65                 #else
66                 unsigned long m;
67                 #endif
68                 set_cpus_allowed(&t, m);
69         ],[
70                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
71                 AC_MSG_RESULT([yes])
72         ],[
73                 AC_MSG_RESULT([no (no kernel support)])
74         ])
75 fi
76 ])
77
78 #
79 # LN_CONFIG_PORTALS
80 #
81 # configure support for Portals
82 #
83 AC_DEFUN([LN_CONFIG_PORTALS],
84 [AC_MSG_CHECKING([for portals])
85 AC_ARG_WITH([portals],
86         AC_HELP_STRING([--with-portals=path],
87                        [set path to portals]),
88         [
89                 case $with_portals in
90                         no)     ENABLEPORTALS=0
91                                 ;;
92                         *)      PORTALS="${with_portals}"
93                                 ENABLEPORTALS=1
94                                 ;;
95                 esac
96         ], [
97                 ENABLEPORTALS=0
98         ])
99 PTLLNDCPPFLAGS=""
100 if test $ENABLEPORTALS -eq 0; then
101         AC_MSG_RESULT([no])
102 elif test ! \( -f ${PORTALS}/include/portals/p30.h \); then
103         AC_MSG_RESULT([no])
104         AC_MSG_ERROR([bad --with-portals path])
105 else
106         AC_MSG_RESULT([$PORTALS])
107         PTLLNDCPPFLAGS="-I${PORTALS}/include"
108 fi
109 AC_SUBST(PTLLNDCPPFLAGS)
110 ])
111
112 #
113 # LN_CONFIG_BACKOFF
114 #
115 # check if tunable tcp backoff is available/wanted
116 #
117 AC_DEFUN([LN_CONFIG_BACKOFF],
118 [AC_MSG_CHECKING([for tunable backoff TCP support])
119 AC_ARG_ENABLE([backoff],
120        AC_HELP_STRING([--disable-backoff],
121                       [disable socknal tunable backoff]),
122        [],[enable_backoff='yes'])
123 if test x$enable_backoff = xno ; then
124        AC_MSG_RESULT([no (by request)])
125 else
126        BOCD="`grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h`"
127        if test "$BOCD" != 0 ; then
128                AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
129                AC_MSG_RESULT(yes)
130        else
131                AC_MSG_RESULT([no (no kernel support)])
132        fi
133 fi
134 ])
135
136
137 #
138 # LN_CONFIG_PTLLND
139 #
140 # configure support for Portals LND
141 #
142 AC_DEFUN([LN_CONFIG_PTLLND],
143 [
144 if test -z "$ENABLEPORTALS"; then
145         LN_CONFIG_PORTALS
146 fi
147
148 AC_MSG_CHECKING([whether to build the kernel portals LND])
149
150 PTLLND=""
151 if test $ENABLEPORTALS -ne 0; then
152         AC_MSG_RESULT([yes])
153         PTLLND="ptllnd"
154 else
155         AC_MSG_RESULT([no])
156 fi
157 AC_SUBST(PTLLND)
158 ])
159
160 #
161 # LN_CONFIG_UPTLLND
162 #
163 # configure support for Portals LND
164 #
165 AC_DEFUN([LN_CONFIG_UPTLLND],
166 [
167 if test -z "$ENABLEPORTALS"; then
168         LN_CONFIG_PORTALS
169 fi
170
171 AC_MSG_CHECKING([whether to build the userspace portals LND])
172
173 UPTLLND=""
174 if test $ENABLEPORTALS -ne 0; then
175         AC_MSG_RESULT([yes])
176         UPTLLND="ptllnd"
177 else
178         AC_MSG_RESULT([no])
179 fi
180 AC_SUBST(UPTLLND)
181 ])
182
183 #
184 # LN_CONFIG_USOCKLND
185 #
186 # configure support for userspace TCP/IP LND
187 #
188 AC_DEFUN([LN_CONFIG_USOCKLND],
189 [AC_MSG_CHECKING([whether to build usocklnd])
190 AC_ARG_ENABLE([usocklnd],
191         AC_HELP_STRING([--disable-usocklnd],
192                         [disable usocklnd]),
193         [],[enable_usocklnd='yes'])
194
195 if test x$enable_usocklnd = xyes ; then
196         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
197                 AC_MSG_RESULT([yes])
198                 USOCKLND="usocklnd"
199         else
200                 AC_MSG_RESULT([no (libpthread not present or disabled)])
201                 USOCKLND=""
202         fi
203 else
204         AC_MSG_RESULT([no (disabled explicitly)])
205         USOCKLND=""
206 fi
207 AC_SUBST(USOCKLND)
208 ])
209
210 #
211 # LN_CONFIG_QUADRICS
212 #
213 # check if quadrics support is in this kernel
214 #
215 AC_DEFUN([LN_CONFIG_QUADRICS],
216 [AC_MSG_CHECKING([for QsNet sources])
217 AC_ARG_WITH([qsnet],
218         AC_HELP_STRING([--with-qsnet=path],
219                        [set path to qsnet source (default=$LINUX)]),
220         [QSNET=$with_qsnet],
221         [QSNET=$LINUX])
222 AC_MSG_RESULT([$QSNET])
223
224 AC_MSG_CHECKING([if quadrics kernel headers are present])
225 if test -d $QSNET/drivers/net/qsnet ; then
226         AC_MSG_RESULT([yes])
227         QSWLND="qswlnd"
228         AC_MSG_CHECKING([for multirail EKC])
229         if test -f $QSNET/include/elan/epcomms.h; then
230                 AC_MSG_RESULT([supported])
231                 QSWCPPFLAGS="-I$QSNET/include -DMULTIRAIL_EKC=1"
232         else
233                 AC_MSG_RESULT([not supported])
234                 AC_MSG_ERROR([Need multirail EKC])
235         fi
236
237         if test x$QSNET = x$LINUX ; then
238                 LB_LINUX_CONFIG([QSNET],[],[
239                         LB_LINUX_CONFIG([QSNET_MODULE],[],[
240                                 AC_MSG_WARN([QSNET is not enabled in this kernel; not building qswlnd.])
241                                 QSWLND=""
242                                 QSWCPPFLAGS=""
243                         ])
244                 ])
245         fi
246 else
247         AC_MSG_RESULT([no])
248         QSWLND=""
249         QSWCPPFLAGS=""
250 fi
251 AC_SUBST(QSWCPPFLAGS)
252 AC_SUBST(QSWLND)
253 ])
254
255 #
256 # LN_CONFIG_GM
257 #
258 # check if GM support is available
259 #
260 AC_DEFUN([LN_CONFIG_GM],[
261 AC_MSG_CHECKING([whether to enable GM support])
262 AC_ARG_WITH([gm],
263         AC_HELP_STRING([--with-gm=path-to-gm-source-tree],
264                        [build gmlnd against path]),
265         [
266                 case $with_gm in
267                 no)    ENABLE_GM=0
268                        ;;
269                 *)     ENABLE_GM=1
270                        GM_SRC="$with_gm"
271                        ;;
272                 esac
273         ],[
274                 ENABLE_GM=0
275         ])
276 AC_ARG_WITH([gm-install],
277         AC_HELP_STRING([--with-gm-install=path-to-gm-install-tree],
278                        [say where GM has been installed]),
279         [
280                 GM_INSTALL=$with_gm_install
281         ],[
282                 GM_INSTALL="/opt/gm"
283         ])
284 if test $ENABLE_GM -eq 0; then
285         AC_MSG_RESULT([no])
286 else
287         AC_MSG_RESULT([yes])
288
289         GMLND="gmlnd"
290         GMCPPFLAGS="-I$GM_SRC/include -I$GM_SRC/drivers -I$GM_SRC/drivers/linux/gm"
291
292         if test -f $GM_INSTALL/lib/libgm.a -o \
293                 -f $GM_INSTALL/lib64/libgm.a; then
294                 GMLIBS="-L$GM_INSTALL/lib -L$GM_INSTALL/lib64"
295         else
296                 AC_MSG_ERROR([Cant find GM libraries under $GM_INSTALL])
297         fi
298
299         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
300         EXTRA_KCFLAGS="$GMCPPFLAGS -DGM_KERNEL $EXTRA_KCFLAGS"
301
302         AC_MSG_CHECKING([that code using GM compiles with given path])
303         LB_LINUX_TRY_COMPILE([
304                 #define GM_STRONG_TYPES 1
305                 #ifdef VERSION
306                 #undef VERSION
307                 #endif
308                 #include "gm.h"
309                 #include "gm_internal.h"
310         ],[
311                 struct gm_port *port = NULL;
312                 gm_recv_event_t *rxevent = gm_blocking_receive_no_spin(port);
313                 return 0;
314         ],[
315                 AC_MSG_RESULT([yes])
316         ],[
317                 AC_MSG_RESULT([no])
318                 AC_MSG_ERROR([Bad --with-gm path])
319         ])
320
321         AC_MSG_CHECKING([that GM has gm_register_memory_ex_phys()])
322         LB_LINUX_TRY_COMPILE([
323                 #define GM_STRONG_TYPES 1
324                 #ifdef VERSION
325                 #undef VERSION
326                 #endif
327                 #include "gm.h"
328                 #include "gm_internal.h"
329         ],[
330                 gm_status_t     gmrc;
331                 struct gm_port *port = NULL;
332                 gm_u64_t        phys = 0;
333                 gm_up_t         pvma = 0;
334
335                 gmrc = gm_register_memory_ex_phys(port, phys, 100, pvma);
336                 return 0;
337         ],[
338                 AC_MSG_RESULT([yes])
339         ],[
340                 AC_MSG_RESULT([no.
341 Please patch the GM sources as follows...
342     cd $GM_SRC
343     patch -p0 < $PWD/lnet/klnds/gmlnd/gm-reg-phys.patch
344 ...then rebuild and re-install them])
345                 AC_MSG_ERROR([Can't build GM without gm_register_memory_ex_phys()])
346         ])
347
348         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
349 fi
350 AC_SUBST(GMCPPFLAGS)
351 AC_SUBST(GMLIBS)
352 AC_SUBST(GMLND)
353 ])
354
355
356 #
357 # LN_CONFIG_MX
358 #
359 AC_DEFUN([LN_CONFIG_MX],
360 [AC_MSG_CHECKING([whether to enable Myrinet MX support])
361 # set default
362 MXPATH="/opt/mx"
363 AC_ARG_WITH([mx],
364        AC_HELP_STRING([--with-mx=path],
365                       [build mxlnd against path]),
366        [
367                case $with_mx in
368                yes)    ENABLEMX=2
369                        ;;
370                no)     ENABLEMX=0
371                        ;;
372                *)      MXPATH=$with_mx
373                        ENABLEMX=3
374                        ;;
375                esac
376        ],[
377                ENABLEMX=1
378        ])
379 if test $ENABLEMX -eq 0; then
380        AC_MSG_RESULT([disabled])
381 elif test ! \( -f ${MXPATH}/include/myriexpress.h -a \
382               -f ${MXPATH}/include/mx_kernel_api.h -a \
383               -f ${MXPATH}/include/mx_pin.h \); then
384        AC_MSG_RESULT([no])
385        case $ENABLEMX in
386        1) ;;
387        2) AC_MSG_ERROR([Myrinet MX kernel headers not present]);;
388        3) AC_MSG_ERROR([bad --with-mx path]);;
389        *) AC_MSG_ERROR([internal error]);;
390        esac
391 else
392        MXCPPFLAGS="-I$MXPATH/include"
393        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
394        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $MXCPPFLAGS"
395        MXLIBS="-L$MXPATH/lib"
396        LB_LINUX_TRY_COMPILE([
397                #define MX_KERNEL 1
398                #include <mx_extensions.h>
399                #include <myriexpress.h>
400        ],[
401                mx_endpoint_t   end;
402                mx_status_t     status;
403                mx_request_t    request;
404                int             result;
405
406                mx_init();
407                mx_open_endpoint(MX_ANY_NIC, MX_ANY_ENDPOINT, 0, NULL, 0, &end);
408                mx_register_unexp_handler(end, (mx_unexp_handler_t) NULL, NULL);
409                mx_wait_any(end, MX_INFINITE, 0LL, 0LL, &status, &result);
410                mx_iconnect(end, 0LL, 0, 0, 0, NULL, &request);
411                return 0;
412        ],[
413                AC_MSG_RESULT([yes])
414                MXLND="mxlnd"
415        ],[
416                AC_MSG_RESULT([no])
417                case $ENABLEMX in
418                1) ;;
419                2) AC_MSG_ERROR([can't compile with Myrinet MX kernel headers]);;
420                3) AC_MSG_ERROR([can't compile with Myrinet MX headers under $MXPATH]);;
421                *) AC_MSG_ERROR([internal error]);;
422                esac
423                MXLND=""
424                MXCPPFLAGS=""
425        ])
426        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
427 fi
428 AC_SUBST(MXCPPFLAGS)
429 AC_SUBST(MXLIBS)
430 AC_SUBST(MXLND)
431 ])
432
433
434
435 #
436 # LN_CONFIG_O2IB
437 #
438 AC_DEFUN([LN_CONFIG_O2IB],[
439 AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
440 # set default
441 AC_ARG_WITH([o2ib],
442         AC_HELP_STRING([--with-o2ib=path],
443                        [build o2iblnd against path]),
444         [
445                 case $with_o2ib in
446                 yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
447                         ENABLEO2IB=2
448                         ;;
449                 no)     ENABLEO2IB=0
450                         ;;
451                 *)      O2IBPATHS=$with_o2ib
452                         ENABLEO2IB=3
453                         ;;
454                 esac
455         ],[
456                 O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
457                 ENABLEO2IB=1
458         ])
459 if test $ENABLEO2IB -eq 0; then
460         AC_MSG_RESULT([disabled])
461 else
462         o2ib_found=false
463         for O2IBPATH in $O2IBPATHS; do
464                 if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
465                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
466                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
467                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
468                         o2ib_found=true
469                         break
470                 fi
471         done
472         if ! $o2ib_found; then
473                 AC_MSG_RESULT([no])
474                 case $ENABLEO2IB in
475                         1) ;;
476                         2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
477                         3) AC_MSG_ERROR([bad --with-o2ib path]);;
478                         *) AC_MSG_ERROR([internal error]);;
479                 esac
480         else
481                 O2IBCPPFLAGS="-I$O2IBPATH/include"
482                 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
483                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
484                 EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
485                 LB_LINUX_TRY_COMPILE([
486                         #include <linux/version.h>
487                         #include <linux/pci.h>
488                         #if !HAVE_GFP_T
489                         typedef int gfp_t;
490                         #endif
491                         #include <rdma/rdma_cm.h>
492                         #include <rdma/ib_cm.h>
493                         #include <rdma/ib_verbs.h>
494                         #include <rdma/ib_fmr_pool.h>
495                 ],[
496                         struct rdma_cm_id          *cm_id;
497                         struct rdma_conn_param      conn_param;
498                         struct ib_device_attr       device_attr;
499                         struct ib_qp_attr           qp_attr;
500                         struct ib_pool_fmr          pool_fmr;
501                         enum   ib_cm_rej_reason     rej_reason;
502
503                         cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
504                         return PTR_ERR(cm_id);
505                 ],[
506                         AC_MSG_RESULT([yes])
507                         O2IBLND="o2iblnd"
508                 ],[
509                         AC_MSG_RESULT([no])
510                         case $ENABLEO2IB in
511                         1) ;;
512                         2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
513                         3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
514                         *) AC_MSG_ERROR([internal error]);;
515                         esac
516                         O2IBLND=""
517                         O2IBCPPFLAGS=""
518                 ])
519                 # we know at this point that the found OFED source is good
520                 O2IB_SYMVER=""
521                 if test $ENABLEO2IB -eq 3 ; then
522                         # OFED default rpm not handle sles10 Modules.symvers name
523                         for name in Module.symvers Modules.symvers; do
524                                 if test -f $O2IBPATH/$name; then
525                                         O2IB_SYMVER=$name;
526                                         break;
527                                 fi
528                         done
529                         if test -n $O2IB_SYMVER ; then
530                                 AC_MSG_NOTICE([adding $O2IBPATH/$O2IB_SYMVER to $PWD/$SYMVERFILE])
531                                 # strip out the existing symbols versions first
532                                 egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
533                                 cat $PWD/$SYMVERFILE.old $O2IBPATH/$O2IB_SYMVER > $PWD/$SYMVERFILE
534                         else
535                                 AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
536                         fi
537                 fi
538
539                 # version checking is a hack and isn't reliable,
540                 # we need verify it with each new ofed release
541
542                 if grep -q ib_dma_map_single \
543                         ${O2IBPATH}/include/rdma/ib_verbs.h; then
544                         if grep -q comp_vector \
545                                 ${O2IBPATH}/include/rdma/ib_verbs.h; then
546                                 IBLND_OFED_VERSION="1025"
547                         else
548                                 IBLND_OFED_VERSION="1020"
549                         fi
550                 else
551                         IBLND_OFED_VERSION="1010"
552                 fi
553
554                 AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
555                                    [OFED version])
556
557                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
558         fi
559 fi
560
561 AC_SUBST(EXTRA_LNET_INCLUDE)
562 AC_SUBST(O2IBCPPFLAGS)
563 AC_SUBST(O2IBLND)
564 ])
565
566 #
567 # LN_CONFIG_OPENIB
568 #
569 # check for OpenIB in the kernel
570 AC_DEFUN([LN_CONFIG_OPENIB],[
571 AC_MSG_CHECKING([whether to enable OpenIB support])
572 # set default
573 OPENIBPATH="$LINUX/drivers/infiniband"
574 AC_ARG_WITH([openib],
575         AC_HELP_STRING([--with-openib=path],
576                        [build openiblnd against path]),
577         [
578                 case $with_openib in
579                 yes)    ENABLEOPENIB=2
580                         ;;
581                 no)     ENABLEOPENIB=0
582                         ;;
583                 *)      OPENIBPATH="$with_openib"
584                         ENABLEOPENIB=3
585                         ;;
586                 esac
587         ],[
588                 ENABLEOPENIB=1
589         ])
590 if test $ENABLEOPENIB -eq 0; then
591         AC_MSG_RESULT([disabled])
592 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
593                -f ${OPENIBPATH}/include/ts_ib_cm.h -a \
594                -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
595         AC_MSG_RESULT([no])
596         case $ENABLEOPENIB in
597         1) ;;
598         2) AC_MSG_ERROR([kernel OpenIB headers not present]);;
599         3) AC_MSG_ERROR([bad --with-openib path]);;
600         *) AC_MSG_ERROR([internal error]);;
601         esac
602 else
603         case $ENABLEOPENIB in
604         1|2) OPENIBCPPFLAGS="-I$OPENIBPATH/include -DIN_TREE_BUILD";;
605         3)   OPENIBCPPFLAGS="-I$OPENIBPATH/include";;
606         *)   AC_MSG_RESULT([no])
607              AC_MSG_ERROR([internal error]);;
608         esac
609         OPENIBCPPFLAGS="$OPENIBCPPFLAGS -DIB_NTXRXPARAMS=4"
610         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
611         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
612         LB_LINUX_TRY_COMPILE([
613                 #include <ts_ib_core.h>
614                 #include <ts_ib_cm.h>
615                 #include <ts_ib_sa_client.h>
616         ],[
617                 struct ib_device_properties dev_props;
618                 struct ib_cm_active_param   cm_active_params;
619                 tTS_IB_CLIENT_QUERY_TID     tid;
620                 int                         enum1 = IB_QP_ATTRIBUTE_STATE;
621                 int                         enum2 = IB_ACCESS_LOCAL_WRITE;
622                 int                         enum3 = IB_CQ_CALLBACK_INTERRUPT;
623                 int                         enum4 = IB_CQ_PROVIDER_REARM;
624                 return 0;
625         ],[
626                 AC_MSG_RESULT([yes])
627                 OPENIBLND="openiblnd"
628         ],[
629                 AC_MSG_RESULT([no])
630                 case $ENABLEOPENIB in
631                 1) ;;
632                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
633                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
634                 *) AC_MSG_ERROR([internal error]);;
635                 esac
636                 OPENIBLND=""
637                 OPENIBCPPFLAGS=""
638         ])
639         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
640 fi
641 AC_SUBST(OPENIBCPPFLAGS)
642 AC_SUBST(OPENIBLND)
643 ])
644
645 #
646 # LN_CONFIG_CIBLND
647 #
648 AC_DEFUN([LN_CONFIG_CIB],[
649 AC_MSG_CHECKING([whether to enable Cisco/TopSpin IB support])
650 # set default
651 CIBPATH=""
652 CIBLND=""
653 AC_ARG_WITH([cib],
654         AC_HELP_STRING([--with-cib=path],
655                        [build ciblnd against path]),
656         [
657                 case $with_cib in
658                 no)     AC_MSG_RESULT([no]);;
659                 *)      CIBPATH="$with_cib"
660                         if test -d "$CIBPATH"; then
661                                 AC_MSG_RESULT([yes])
662                         else
663                                 AC_MSG_RESULT([no])
664                                 AC_MSG_ERROR([No directory $CIBPATH])
665                         fi;;
666                 esac
667         ],[
668                 AC_MSG_RESULT([no])
669         ])
670 if test -n "$CIBPATH"; then
671         CIBCPPFLAGS="-I${CIBPATH}/ib/ts_api_ng/include -I${CIBPATH}/all/kernel_services/include -DUSING_TSAPI"
672         CIBCPPFLAGS="$CIBCPPFLAGS -DIB_NTXRXPARAMS=3"
673         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
674         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $CIBCPPFLAGS"
675         LB_LINUX_TRY_COMPILE([
676                 #include <ts_ib_core.h>
677                 #include <ts_ib_cm.h>
678                 #include <ts_ib_sa_client.h>
679         ],[
680                 struct ib_device_properties dev_props;
681                 struct ib_cm_active_param   cm_active_params;
682                 tTS_IB_CLIENT_QUERY_TID     tid;
683                 int                         enum1 = TS_IB_QP_ATTRIBUTE_STATE;
684                 int                         enum2 = TS_IB_ACCESS_LOCAL_WRITE;
685                 int                         enum3 = TS_IB_CQ_CALLBACK_INTERRUPT;
686                 int                         enum4 = TS_IB_CQ_PROVIDER_REARM;
687                 return 0;
688         ],[
689                 CIBLND="ciblnd"
690         ],[
691                 AC_MSG_ERROR([can't compile ciblnd with given path])
692                 CIBCPPFLAGS=""
693         ])
694         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
695 fi
696 AC_SUBST(CIBCPPFLAGS)
697 AC_SUBST(CIBLND)
698 ])
699
700 #
701 # LN_CONFIG_IIB
702 #
703 # check for infinicon infiniband support
704 #
705 AC_DEFUN([LN_CONFIG_IIB],[
706 AC_MSG_CHECKING([whether to enable Infinicon support])
707 # set default
708 IIBPATH="/usr/include"
709 AC_ARG_WITH([iib],
710         AC_HELP_STRING([--with-iib=path],
711                        [build iiblnd against path]),
712         [
713                 case $with_iib in
714                 yes)    ENABLEIIB=2
715                         ;;
716                 no)     ENABLEIIB=0
717                         ;;
718                 *)      IIBPATH="${with_iib}/include"
719                         ENABLEIIB=3
720                         ;;
721                 esac
722         ],[
723                 ENABLEIIB=1
724         ])
725 if test $ENABLEIIB -eq 0; then
726         AC_MSG_RESULT([disabled])
727 elif test ! \( -f ${IIBPATH}/linux/iba/ibt.h \); then
728         AC_MSG_RESULT([no])
729         case $ENABLEIIB in
730         1) ;;
731         2) AC_MSG_ERROR([default Infinicon headers not present]);;
732         3) AC_MSG_ERROR([bad --with-iib path]);;
733         *) AC_MSG_ERROR([internal error]);;
734         esac
735 else
736         IIBCPPFLAGS="-I$IIBPATH"
737         if test $IIBPATH != "/usr/include"; then
738                 # we need /usr/include come what may
739                 IIBCPPFLAGS="$IIBCPPFLAGS -I/usr/include"
740         fi
741         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
742         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
743         LB_LINUX_TRY_COMPILE([
744                 #include <linux/iba/ibt.h>
745         ],[
746                 IBT_INTERFACE_UNION interfaces;
747                 FSTATUS             rc;
748
749                  rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
750                                                &interfaces);
751
752                 return rc == FSUCCESS ? 0 : 1;
753         ],[
754                 AC_MSG_RESULT([yes])
755                 IIBLND="iiblnd"
756         ],[
757                 AC_MSG_RESULT([no])
758                 case $ENABLEIIB in
759                 1) ;;
760                 2) AC_MSG_ERROR([can't compile with default Infinicon headers]);;
761                 3) AC_MSG_ERROR([can't compile with Infinicon headers under $IIBPATH]);;
762                 *) AC_MSG_ERROR([internal error]);;
763                 esac
764                 IIBLND=""
765                 IIBCPPFLAGS=""
766         ])
767         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
768 fi
769 AC_SUBST(IIBCPPFLAGS)
770 AC_SUBST(IIBLND)
771 ])
772
773 #
774 # LN_CONFIG_VIB
775 #
776 # check for Voltaire infiniband support
777 #
778 AC_DEFUN([LN_CONFIG_VIB],
779 [AC_MSG_CHECKING([whether to enable Voltaire IB support])
780 VIBPATH=""
781 AC_ARG_WITH([vib],
782         AC_HELP_STRING([--with-vib=path],
783                        [build viblnd against path]),
784         [
785                 case $with_vib in
786                 no)     AC_MSG_RESULT([no]);;
787                 *)      VIBPATH="${with_vib}/src/nvigor/ib-code"
788                         if test -d "$with_vib" -a -d "$VIBPATH"; then
789                                 AC_MSG_RESULT([yes])
790                         else
791                                 AC_MSG_RESULT([no])
792                                 AC_MSG_ERROR([No directory $VIBPATH])
793                         fi;;
794                 esac
795         ],[
796                 AC_MSG_RESULT([no])
797         ])
798 if test -z "$VIBPATH"; then
799         VIBLND=""
800 else
801         VIBCPPFLAGS="-I${VIBPATH}/include -I${VIBPATH}/cm"
802         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
803         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
804         LB_LINUX_TRY_COMPILE([
805                 #include <linux/list.h>
806                 #include <asm/byteorder.h>
807                 #ifdef __BIG_ENDIAN
808                 # define CPU_BE 1
809                 # define CPU_LE 0
810                 #endif
811                 #ifdef __LITTLE_ENDIAN
812                 # define CPU_BE 0
813                 # define CPU_LE 1
814                 #endif
815                 #include <vverbs.h>
816                 #include <ib-cm.h>
817                 #include <ibat.h>
818         ],[
819                 vv_hca_h_t       kib_hca;
820                 vv_return_t      vvrc;
821                 cm_cep_handle_t  cep;
822                 ibat_arp_data_t  arp_data;
823                 ibat_stat_t      ibatrc;
824
825                 vvrc = vv_hca_open("ANY_HCA", NULL, &kib_hca);
826                 cep = cm_create_cep(cm_cep_transp_rc);
827                 ibatrc = ibat_get_ib_data((uint32_t)0, (uint32_t)0,
828                                           ibat_paths_primary, &arp_data,
829                                           (ibat_get_ib_data_reply_fn_t)NULL,
830                                           NULL, 0);
831                 return 0;
832         ],[
833                 VIBLND="viblnd"
834         ],[
835                 AC_MSG_ERROR([can't compile viblnd with given path])
836         ])
837         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
838 fi
839 if test -n "$VIBLND"; then
840         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
841         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
842         AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
843         LB_LINUX_TRY_COMPILE([
844                 #include <linux/list.h>
845                 #include <asm/byteorder.h>
846                 #ifdef __BIG_ENDIAN
847                 # define CPU_BE 1
848                 # define CPU_LE 0
849                 #endif
850                 #ifdef __LITTLE_ENDIAN
851                 # define CPU_BE 0
852                 # define CPU_LE 1
853                 #endif
854                 #include <vverbs.h>
855                 #include <ib-cm.h>
856                 #include <ibat.h>
857         ],[
858                 vv_scatgat_t  sg;
859
860                 return &sg.v_address[3] == NULL;
861         ],[
862                 AC_MSG_RESULT([yes])
863                 VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_VOIDSTAR_SGADDR=1"
864         ],[
865                 AC_MSG_RESULT([no])
866         ])
867         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
868 fi
869 AC_SUBST(VIBCPPFLAGS)
870 AC_SUBST(VIBLND)
871 ])
872
873 #
874 # LN_CONFIG_RALND
875 #
876 # check whether to use the RapidArray lnd
877 #
878 AC_DEFUN([LN_CONFIG_RALND],
879 [#### Rapid Array
880 AC_MSG_CHECKING([if RapidArray kernel headers are present])
881 # placeholder
882 RACPPFLAGS="-I${LINUX}/drivers/xd1/include"
883 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
884 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
885 LB_LINUX_TRY_COMPILE([
886         #include <linux/types.h>
887         #include <rapl.h>
888 ],[
889         RAP_RETURN          rc;
890         RAP_PVOID           dev_handle;
891
892         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
893
894         return rc == RAP_SUCCESS ? 0 : 1;
895 ],[
896         AC_MSG_RESULT([yes])
897         RALND="ralnd"
898 ],[
899         AC_MSG_RESULT([no])
900         RALND=""
901         RACPPFLAGS=""
902 ])
903 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
904 AC_SUBST(RACPPFLAGS)
905 AC_SUBST(RALND)
906 ])
907
908
909
910 #
911 # LN_PROG_LINUX
912 #
913 # LNet linux kernel checks
914 #
915 AC_DEFUN([LN_PROG_LINUX],
916 [
917 LN_CONFIG_AFFINITY
918 LN_CONFIG_BACKOFF
919 LN_CONFIG_QUADRICS
920 LN_CONFIG_GM
921 LN_CONFIG_OPENIB
922 LN_CONFIG_CIB
923 LN_CONFIG_VIB
924 LN_CONFIG_IIB
925 LN_CONFIG_O2IB
926 LN_CONFIG_RALND
927 LN_CONFIG_PTLLND
928 LN_CONFIG_MX
929 ])
930
931 #
932 # LN_PROG_DARWIN
933 #
934 # Darwin checks
935 #
936 AC_DEFUN([LN_PROG_DARWIN],
937 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
938 ])
939
940 #
941 # LN_PATH_DEFAULTS
942 #
943 # default paths for installed files
944 #
945 AC_DEFUN([LN_PATH_DEFAULTS],
946 [
947 ])
948
949 #
950 # LN_CONFIGURE
951 #
952 # other configure checks
953 #
954 AC_DEFUN([LN_CONFIGURE],
955 [# lnet/utils/portals.c
956 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
957 AC_CHECK_FUNCS([gethostbyname socket connect])
958
959 # lnet/utils/debug.c
960 AC_CHECK_HEADERS([linux/version.h])
961
962 AC_CHECK_TYPE([spinlock_t],
963         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
964         [],
965         [#include <linux/spinlock.h>])
966
967 # lnet/utils/wirecheck.c
968 AC_CHECK_FUNCS([strnlen])
969
970 # --------  Check for required packages  --------------
971
972 #
973 # LC_CONFIG_READLINE
974 #
975 # Build with readline
976 #
977 AC_MSG_CHECKING([whether to enable readline support])
978 AC_ARG_ENABLE(readline,
979         AC_HELP_STRING([--disable-readline],
980                         [disable readline support]),
981         [],[enable_readline='yes'])
982 AC_MSG_RESULT([$enable_readline])
983
984 # -------- check for readline if enabled ----
985 if test x$enable_readline = xyes ; then
986         LIBS_save="$LIBS"
987         LIBS="-lncurses $LIBS"
988         AC_CHECK_LIB([readline],[readline],[
989         LIBREADLINE="-lreadline -lncurses"
990         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
991         ],[
992         LIBREADLINE=""
993         ])
994         LIBS="$LIBS_save"
995 else
996         LIBREADLINE=""
997 fi
998 AC_SUBST(LIBREADLINE)
999
1000 # -------- enable acceptor libwrap (TCP wrappers) support? -------
1001 AC_MSG_CHECKING([if libwrap support is requested])
1002 AC_ARG_ENABLE([libwrap],
1003         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
1004         [case "${enableval}" in
1005                 yes) enable_libwrap=yes ;;
1006                 no) enable_libwrap=no ;;
1007                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
1008         esac],[enable_libwrap=no])
1009 AC_MSG_RESULT([$enable_libwrap])
1010 if test x$enable_libwrap = xyes ; then
1011         LIBWRAP="-lwrap"
1012         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
1013 else
1014         LIBWRAP=""
1015 fi
1016 AC_SUBST(LIBWRAP)
1017
1018 # ----------------------------------------
1019 # some tests for catamount-like systems
1020 # ----------------------------------------
1021 AC_ARG_ENABLE([sysio_init],
1022         AC_HELP_STRING([--disable-sysio-init],
1023                 [call sysio init functions when initializing liblustre]),
1024         [],[enable_sysio_init=yes])
1025 AC_MSG_CHECKING([whether to initialize libsysio])
1026 AC_MSG_RESULT([$enable_sysio_init])
1027 if test x$enable_sysio_init != xno ; then
1028         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
1029 fi
1030
1031 AC_ARG_ENABLE([urandom],
1032         AC_HELP_STRING([--disable-urandom],
1033                 [disable use of /dev/urandom for liblustre]),
1034         [],[enable_urandom=yes])
1035 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
1036 AC_MSG_RESULT([$enable_urandom])
1037 if test x$enable_urandom != xno ; then
1038         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
1039 fi
1040
1041 # -------- check for -lcap support ----
1042 if test x$enable_liblustre = xyes ; then
1043         AC_CHECK_LIB([cap], [cap_get_proc],
1044                 [
1045                         CAP_LIBS="-lcap"
1046                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
1047                 ],
1048                 [
1049                         CAP_LIBS=""
1050                 ])
1051         AC_SUBST(CAP_LIBS)
1052
1053 fi
1054
1055 LN_CONFIG_MAX_PAYLOAD
1056 LN_CONFIG_UPTLLND
1057 LN_CONFIG_USOCKLND
1058 ])
1059
1060 #
1061 # LN_CONDITIONALS
1062 #
1063 # AM_CONDITOINAL defines for lnet
1064 #
1065 AC_DEFUN([LN_CONDITIONALS],
1066 [AM_CONDITIONAL(BUILD_QSWLND, test x$QSWLND = "xqswlnd")
1067 AM_CONDITIONAL(BUILD_GMLND, test x$GMLND = "xgmlnd")
1068 AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
1069 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
1070 AM_CONDITIONAL(BUILD_OPENIBLND, test x$OPENIBLND = "xopeniblnd")
1071 AM_CONDITIONAL(BUILD_CIBLND, test x$CIBLND = "xciblnd")
1072 AM_CONDITIONAL(BUILD_IIBLND, test x$IIBLND = "xiiblnd")
1073 AM_CONDITIONAL(BUILD_VIBLND, test x$VIBLND = "xviblnd")
1074 AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
1075 AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
1076 AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
1077 AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
1078 ])
1079
1080 #
1081 # LN_CONFIG_FILES
1082 #
1083 # files that should be generated with AC_OUTPUT
1084 #
1085 AC_DEFUN([LN_CONFIG_FILES],
1086 [AC_CONFIG_FILES([
1087 lnet/Kernelenv
1088 lnet/Makefile
1089 lnet/autoMakefile
1090 lnet/autoconf/Makefile
1091 lnet/doc/Makefile
1092 lnet/include/Makefile
1093 lnet/include/lnet/Makefile
1094 lnet/include/lnet/linux/Makefile
1095 lnet/klnds/Makefile
1096 lnet/klnds/autoMakefile
1097 lnet/klnds/gmlnd/Makefile
1098 lnet/klnds/mxlnd/autoMakefile
1099 lnet/klnds/mxlnd/Makefile
1100 lnet/klnds/gmlnd/autoMakefile
1101 lnet/klnds/openiblnd/Makefile
1102 lnet/klnds/openiblnd/autoMakefile
1103 lnet/klnds/o2iblnd/Makefile
1104 lnet/klnds/o2iblnd/autoMakefile
1105 lnet/klnds/ciblnd/Makefile
1106 lnet/klnds/ciblnd/autoMakefile
1107 lnet/klnds/iiblnd/Makefile
1108 lnet/klnds/iiblnd/autoMakefile
1109 lnet/klnds/viblnd/Makefile
1110 lnet/klnds/viblnd/autoMakefile
1111 lnet/klnds/qswlnd/Makefile
1112 lnet/klnds/qswlnd/autoMakefile
1113 lnet/klnds/ralnd/Makefile
1114 lnet/klnds/ralnd/autoMakefile
1115 lnet/klnds/socklnd/Makefile
1116 lnet/klnds/socklnd/autoMakefile
1117 lnet/klnds/ptllnd/Makefile
1118 lnet/klnds/ptllnd/autoMakefile
1119 lnet/lnet/Makefile
1120 lnet/lnet/autoMakefile
1121 lnet/selftest/Makefile
1122 lnet/selftest/autoMakefile
1123 lnet/ulnds/Makefile
1124 lnet/ulnds/autoMakefile
1125 lnet/ulnds/socklnd/Makefile
1126 lnet/ulnds/ptllnd/Makefile
1127 lnet/utils/Makefile
1128 ])
1129 case $lb_target_os in
1130         darwin)
1131                 AC_CONFIG_FILES([
1132 lnet/include/lnet/darwin/Makefile
1133 ])
1134                 ;;
1135 esac
1136 ])