Whamcloud - gitweb
bec57e5fba0b96156306e516d412373a63308b94
[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_CDEBUG
46 #
47 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
48 #
49 AC_DEFUN([LN_CONFIG_CDEBUG],
50 [
51 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
52 AC_ARG_ENABLE([libcfs_cdebug],
53         AC_HELP_STRING([--disable-libcfs-cdebug],
54                         [disable libcfs CDEBUG, CWARN]),
55         [],[enable_libcfs_cdebug='yes'])
56 AC_MSG_RESULT([$enable_libcfs_cdebug])
57 if test x$enable_libcfs_cdebug = xyes; then
58    AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
59 else
60    AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
61 fi
62
63 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
64 AC_ARG_ENABLE([libcfs_trace],
65         AC_HELP_STRING([--disable-libcfs-trace],
66                         [disable libcfs ENTRY/EXIT]),
67         [],[enable_libcfs_trace='yes'])
68 AC_MSG_RESULT([$enable_libcfs_trace])
69 if test x$enable_libcfs_trace = xyes; then
70    AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
71 else
72    AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
73 fi
74
75 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
76 AC_ARG_ENABLE([libcfs_assert],
77         AC_HELP_STRING([--disable-libcfs-assert],
78                         [disable libcfs LASSERT, LASSERTF]),
79         [],[enable_libcfs_assert='yes'])
80 AC_MSG_RESULT([$enable_libcfs_assert])
81 if test x$enable_libcfs_assert = xyes; then
82    AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
83 fi
84 ])
85  
86 #
87 # LN_CONFIG_AFFINITY
88 #
89 # check if cpu affinity is available/wanted
90 #
91 AC_DEFUN([LN_CONFIG_AFFINITY],
92 [AC_ARG_ENABLE([affinity],
93         AC_HELP_STRING([--disable-affinity],
94                        [disable process/irq affinity]),
95         [],[enable_affinity='yes'])
96
97 AC_MSG_CHECKING([for CPU affinity support])
98 if test x$enable_affinity = xno ; then
99         AC_MSG_RESULT([no (by request)])
100 else
101         LB_LINUX_TRY_COMPILE([
102                 #include <linux/sched.h>
103         ],[
104                 struct task_struct t;
105                 #if HAVE_CPUMASK_T
106                 cpumask_t     m;
107                 #else
108                 unsigned long m;
109                 #endif
110                 set_cpus_allowed(&t, m);
111         ],[
112                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
113                 AC_MSG_RESULT([yes])
114         ],[
115                 AC_MSG_RESULT([no (no kernel support)])
116         ])
117 fi
118 ])
119
120 #
121 # LN_CONFIG_PORTALS
122 #
123 # configure support for Portals
124 #
125 AC_DEFUN([LN_CONFIG_PORTALS],
126 [AC_MSG_CHECKING([for portals])
127 AC_ARG_WITH([portals],
128         AC_HELP_STRING([--with-portals=path],
129                        [set path to portals]),
130         [
131                 case $with_portals in
132                         no)     ENABLEPORTALS=0
133                                 ;;
134                         *)      PORTALS="${with_portals}"
135                                 ENABLEPORTALS=1
136                                 ;;
137                 esac
138                 
139         ], [
140                 ENABLEPORTALS=0
141         ])
142 PTLLNDCPPFLAGS=""
143 if test $ENABLEPORTALS -eq 0; then
144         AC_MSG_RESULT([no])
145 elif test ! \( -f ${PORTALS}/include/portals/p30.h \); then
146         AC_MSG_RESULT([no])
147         AC_MSG_ERROR([bad --with-portals path])
148 else
149         AC_MSG_RESULT([$PORTALS])
150         PTLLNDCPPFLAGS="-I${PORTALS}/include"
151 fi
152 AC_SUBST(PTLLNDCPPFLAGS)
153 ])
154
155 #
156 # LN_CONFIG_BACKOFF
157 #
158 # check if tunable tcp backoff is available/wanted
159 #
160 AC_DEFUN([LN_CONFIG_BACKOFF],
161 [AC_MSG_CHECKING([for tunable backoff TCP support])
162 AC_ARG_ENABLE([backoff],
163        AC_HELP_STRING([--disable-backoff],
164                       [disable socknal tunable backoff]),
165        [],[enable_backoff='yes'])
166 if test x$enable_backoff = xno ; then
167        AC_MSG_RESULT([no (by request)])
168 else
169        BOCD="`grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h`"
170        if test "$BOCD" != 0 ; then
171                AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
172                AC_MSG_RESULT(yes)
173        else
174                AC_MSG_RESULT([no (no kernel support)])
175        fi
176 fi
177 ])
178
179 #
180 # LN_CONFIG_PANIC_DUMPLOG
181 #
182 # check if tunable panic_dumplog is wanted
183 #
184 AC_DEFUN([LN_CONFIG_PANIC_DUMPLOG],
185 [AC_MSG_CHECKING([for tunable panic_dumplog support])
186 AC_ARG_ENABLE([panic_dumplog],
187        AC_HELP_STRING([--enable-panic_dumplog],
188                       [enable panic_dumplog]),
189        [],[enable_panic_dumplog='no'])
190 if test x$enable_panic_dumplog = xyes ; then
191        AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
192        AC_MSG_RESULT([yes (by request)])
193 else
194        AC_MSG_RESULT([no])
195 fi
196 ])
197
198 #
199 # LN_CONFIG_PTLLND
200 #
201 # configure support for Portals LND
202 #
203 AC_DEFUN([LN_CONFIG_PTLLND],
204 [
205 if test -z "$ENABLEPORTALS"; then
206         LN_CONFIG_PORTALS
207 fi
208
209 AC_MSG_CHECKING([whether to build the kernel portals LND])
210
211 PTLLND=""
212 if test $ENABLEPORTALS -ne 0; then
213         AC_MSG_RESULT([yes])
214         PTLLND="ptllnd"
215 else
216         AC_MSG_RESULT([no])
217 fi
218 AC_SUBST(PTLLND)
219 ])
220
221 #
222 # LN_CONFIG_UPTLLND
223 #
224 # configure support for Portals LND
225 #
226 AC_DEFUN([LN_CONFIG_UPTLLND],
227 [
228 if test -z "$ENABLEPORTALS"; then
229         LN_CONFIG_PORTALS
230 fi
231
232 AC_MSG_CHECKING([whether to build the userspace portals LND])
233
234 UPTLLND=""
235 if test $ENABLEPORTALS -ne 0; then
236         AC_MSG_RESULT([yes])
237         UPTLLND="ptllnd"
238 else
239         AC_MSG_RESULT([no])
240 fi
241 AC_SUBST(UPTLLND)
242 ])
243
244 #
245 # LN_CONFIG_USOCKLND
246 #
247 # configure support for userspace TCP/IP LND
248 #
249 AC_DEFUN([LN_CONFIG_USOCKLND],
250 [AC_MSG_CHECKING([whether to build usocklnd])
251 AC_ARG_ENABLE([usocklnd],
252         AC_HELP_STRING([--disable-usocklnd],
253                         [disable usocklnd]),
254         [],[enable_usocklnd='yes'])
255
256 if test x$enable_usocklnd = xyes ; then
257         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
258                 AC_MSG_RESULT([yes])
259                 USOCKLND="usocklnd"
260         else
261                 AC_MSG_RESULT([no (libpthread not present or disabled)])
262                 USOCKLND=""
263         fi
264 else
265         AC_MSG_RESULT([no (disabled explicitly)])
266         USOCKLND=""
267 fi
268 AC_SUBST(USOCKLND)
269 ])
270
271 #
272 # LN_CONFIG_QUADRICS
273 #
274 # check if quadrics support is in this kernel
275 #
276 AC_DEFUN([LN_CONFIG_QUADRICS],
277 [AC_MSG_CHECKING([for QsNet sources])
278 AC_ARG_WITH([qsnet],
279         AC_HELP_STRING([--with-qsnet=path],
280                        [set path to qsnet source (default=$LINUX)]),
281         [QSNET=$with_qsnet],
282         [QSNET=$LINUX])
283 AC_MSG_RESULT([$QSNET])
284
285 AC_MSG_CHECKING([if quadrics kernel headers are present])
286 if test -d $QSNET/drivers/net/qsnet ; then
287         AC_MSG_RESULT([yes])
288         QSWLND="qswlnd"
289         AC_MSG_CHECKING([for multirail EKC])
290         if test -f $QSNET/include/elan/epcomms.h; then
291                 AC_MSG_RESULT([supported])
292                 QSWCPPFLAGS="-I$QSNET/include -DMULTIRAIL_EKC=1"
293         else
294                 AC_MSG_RESULT([not supported])
295                 AC_MSG_ERROR([Need multirail EKC])
296         fi
297
298         if test x$QSNET = x$LINUX ; then
299                 LB_LINUX_CONFIG([QSNET],[],[
300                         LB_LINUX_CONFIG([QSNET_MODULE],[],[
301                                 AC_MSG_WARN([QSNET is not enabled in this kernel; not building qswlnd.])
302                                 QSWLND=""
303                                 QSWCPPFLAGS=""
304                         ])
305                 ])
306         fi
307 else
308         AC_MSG_RESULT([no])
309         QSWLND=""
310         QSWCPPFLAGS=""
311 fi
312 AC_SUBST(QSWCPPFLAGS)
313 AC_SUBST(QSWLND)
314 ])
315
316 #
317 # LN_CONFIG_GM
318 #
319 # check if GM support is available
320 #
321 AC_DEFUN([LN_CONFIG_GM],[
322 AC_MSG_CHECKING([whether to enable GM support])
323 AC_ARG_WITH([gm],
324         AC_HELP_STRING([--with-gm=path-to-gm-source-tree],
325                        [build gmlnd against path]),
326         [
327                 case $with_gm in
328                 no)    ENABLE_GM=0
329                        ;;
330                 *)     ENABLE_GM=1
331                        GM_SRC="$with_gm"
332                        ;;
333                 esac
334         ],[
335                 ENABLE_GM=0
336         ])
337 AC_ARG_WITH([gm-install],
338         AC_HELP_STRING([--with-gm-install=path-to-gm-install-tree],
339                        [say where GM has been installed]),
340         [
341                 GM_INSTALL=$with_gm_install
342         ],[
343                 GM_INSTALL="/opt/gm"
344         ])
345 if test $ENABLE_GM -eq 0; then
346         AC_MSG_RESULT([no])
347 else
348         AC_MSG_RESULT([yes])
349
350         GMLND="gmlnd"
351         GMCPPFLAGS="-I$GM_SRC/include -I$GM_SRC/drivers -I$GM_SRC/drivers/linux/gm"
352
353         if test -f $GM_INSTALL/lib/libgm.a -o \
354                 -f $GM_INSTALL/lib64/libgm.a; then
355                 GMLIBS="-L$GM_INSTALL/lib -L$GM_INSTALL/lib64"
356         else
357                 AC_MSG_ERROR([Cant find GM libraries under $GM_INSTALL])
358         fi
359
360         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
361         EXTRA_KCFLAGS="$GMCPPFLAGS -DGM_KERNEL $EXTRA_KCFLAGS"
362
363         AC_MSG_CHECKING([that code using GM compiles with given path])
364         LB_LINUX_TRY_COMPILE([
365                 #define GM_STRONG_TYPES 1
366                 #ifdef VERSION
367                 #undef VERSION
368                 #endif
369                 #include "gm.h"
370                 #include "gm_internal.h"
371         ],[
372                 struct gm_port *port = NULL;
373                 gm_recv_event_t *rxevent = gm_blocking_receive_no_spin(port);
374                 return 0;
375         ],[
376                 AC_MSG_RESULT([yes])
377         ],[
378                 AC_MSG_RESULT([no])
379                 AC_MSG_ERROR([Bad --with-gm path])
380         ])
381
382         AC_MSG_CHECKING([that GM has gm_register_memory_ex_phys()])
383         LB_LINUX_TRY_COMPILE([
384                 #define GM_STRONG_TYPES 1
385                 #ifdef VERSION
386                 #undef VERSION
387                 #endif
388                 #include "gm.h"
389                 #include "gm_internal.h"
390         ],[
391                 gm_status_t     gmrc;
392                 struct gm_port *port = NULL;
393                 gm_u64_t        phys = 0;
394                 gm_up_t         pvma = 0;
395
396                 gmrc = gm_register_memory_ex_phys(port, phys, 100, pvma);
397                 return 0;
398         ],[
399                 AC_MSG_RESULT([yes])
400         ],[
401                 AC_MSG_RESULT([no.
402 Please patch the GM sources as follows...
403     cd $GM_SRC
404     patch -p0 < $PWD/lnet/klnds/gmlnd/gm-reg-phys.patch
405 ...then rebuild and re-install them])
406                 AC_MSG_ERROR([Can't build GM without gm_register_memory_ex_phys()])
407         ])
408
409         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
410 fi
411 AC_SUBST(GMCPPFLAGS)
412 AC_SUBST(GMLIBS)
413 AC_SUBST(GMLND)
414 ])
415
416
417 #
418 # LN_CONFIG_MX
419 #
420 AC_DEFUN([LN_CONFIG_MX],
421 [AC_MSG_CHECKING([whether to enable Myrinet MX support])
422 # set default
423 MXPATH="/opt/mx"
424 AC_ARG_WITH([mx],
425        AC_HELP_STRING([--with-mx=path],
426                       [build mxlnd against path]),
427        [
428                case $with_mx in
429                yes)    ENABLEMX=2
430                        ;;
431                no)     ENABLEMX=0
432                        ;;
433                *)      MXPATH=$with_mx
434                        ENABLEMX=3
435                        ;;
436                esac
437        ],[
438                ENABLEMX=1
439        ])
440 if test $ENABLEMX -eq 0; then
441        AC_MSG_RESULT([disabled])
442 elif test ! \( -f ${MXPATH}/include/myriexpress.h -a \
443               -f ${MXPATH}/include/mx_kernel_api.h -a \
444               -f ${MXPATH}/include/mx_pin.h \); then
445        AC_MSG_RESULT([no])
446        case $ENABLEMX in
447        1) ;;
448        2) AC_MSG_ERROR([Myrinet MX kernel headers not present]);;
449        3) AC_MSG_ERROR([bad --with-mx path]);;
450        *) AC_MSG_ERROR([internal error]);;
451        esac
452 else
453        MXCPPFLAGS="-I$MXPATH/include"
454        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
455        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $MXCPPFLAGS"
456        MXLIBS="-L$MXPATH/lib"
457        LB_LINUX_TRY_COMPILE([
458                #define MX_KERNEL 1
459                #include <mx_extensions.h>
460                #include <myriexpress.h>
461        ],[
462                mx_endpoint_t   end;
463                mx_status_t     status;
464                mx_request_t    request;
465                int             result;
466
467                mx_init();
468                mx_open_endpoint(MX_ANY_NIC, MX_ANY_ENDPOINT, 0, NULL, 0, &end);
469                mx_register_unexp_handler(end, (mx_unexp_handler_t) NULL, NULL);
470                mx_wait_any(end, MX_INFINITE, 0LL, 0LL, &status, &result);
471                mx_iconnect(end, 0LL, 0, 0, 0, NULL, &request);
472                return 0;
473        ],[
474                AC_MSG_RESULT([yes])
475                MXLND="mxlnd"
476        ],[
477                AC_MSG_RESULT([no])
478                case $ENABLEMX in
479                1) ;;
480                2) AC_MSG_ERROR([can't compile with Myrinet MX kernel headers]);;
481                3) AC_MSG_ERROR([can't compile with Myrinet MX headers under $MXPATH]);;
482                *) AC_MSG_ERROR([internal error]);;
483                esac
484                MXLND=""
485                MXCPPFLAGS=""
486        ])
487        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
488 fi
489 AC_SUBST(MXCPPFLAGS)
490 AC_SUBST(MXLIBS)
491 AC_SUBST(MXLND)
492 ])
493
494
495
496 #
497 # LN_CONFIG_O2IB
498 #
499 AC_DEFUN([LN_CONFIG_O2IB],[
500 AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
501 # set default
502 O2IBPATH="$LINUX/drivers/infiniband"
503 AC_ARG_WITH([o2ib],
504         AC_HELP_STRING([--with-o2ib=path],
505                        [build o2iblnd against path]),
506         [
507                 case $with_o2ib in
508                 yes)    ENABLEO2IB=2
509                         ;;
510                 no)     ENABLEO2IB=0
511                         ;;
512                 *)      O2IBPATH=$with_o2ib
513                         ENABLEO2IB=3
514                         ;;
515                 esac
516         ],[
517                 ENABLEO2IB=1
518         ])
519 if test $ENABLEO2IB -eq 0; then
520         AC_MSG_RESULT([disabled])
521 elif test ! \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
522                -f ${O2IBPATH}/include/rdma/ib_cm.h -a\
523                -f ${O2IBPATH}/include/rdma/ib_verbs.h -a\
524                -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
525         AC_MSG_RESULT([no])
526         case $ENABLEO2IB in
527         1) ;;
528         2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
529         3) AC_MSG_ERROR([bad --with-o2ib path]);;
530         *) AC_MSG_ERROR([internal error]);;
531         esac
532 else
533         O2IBCPPFLAGS="-I$O2IBPATH/include"
534         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
535         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
536         EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
537         LB_LINUX_TRY_COMPILE([
538                 #include <linux/version.h>
539                 #if !HAVE_GFP_T
540                 typedef int gfp_t;
541                 #endif
542                 #include <rdma/rdma_cm.h>
543                 #include <rdma/ib_cm.h>
544                 #include <rdma/ib_verbs.h>
545                 #include <rdma/ib_fmr_pool.h>
546         ],[
547                 struct rdma_cm_id          *cm_id;
548                 struct rdma_conn_param      conn_param;
549                 struct ib_device_attr       device_attr;
550                 struct ib_qp_attr           qp_attr;
551                 struct ib_pool_fmr          pool_fmr;           
552                 enum   ib_cm_rej_reason     rej_reason;
553
554                 cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
555                 return PTR_ERR(cm_id);
556         ],[
557                 AC_MSG_RESULT([yes])
558                 O2IBLND="o2iblnd"
559         ],[
560                 AC_MSG_RESULT([no])
561                 case $ENABLEO2IB in
562                 1) ;;
563                 2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
564                 3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
565                 *) AC_MSG_ERROR([internal error]);;
566                 esac
567                 O2IBLND=""
568                 O2IBCPPFLAGS=""
569         ])
570
571         IB_DMA_MAP="`grep -c ib_dma_map_single ${O2IBPATH}/include/rdma/ib_verbs.h`"
572         if test "$IB_DMA_MAP" != 0 ; then
573                 IBLND_OFED_VERSION="102"
574         else
575                 IBLND_OFED_VERSION="101"
576         fi
577
578         AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
579                            [OFED version])
580
581         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
582 fi
583
584 AC_SUBST(EXTRA_LNET_INCLUDE)
585 AC_SUBST(O2IBCPPFLAGS)
586 AC_SUBST(O2IBLND)
587 ])
588
589 #
590 # LN_CONFIG_OPENIB
591 #
592 # check for OpenIB in the kernel
593 AC_DEFUN([LN_CONFIG_OPENIB],[
594 AC_MSG_CHECKING([whether to enable OpenIB support])
595 # set default
596 OPENIBPATH="$LINUX/drivers/infiniband"
597 AC_ARG_WITH([openib],
598         AC_HELP_STRING([--with-openib=path],
599                        [build openiblnd against path]),
600         [
601                 case $with_openib in
602                 yes)    ENABLEOPENIB=2
603                         ;;
604                 no)     ENABLEOPENIB=0
605                         ;;
606                 *)      OPENIBPATH="$with_openib"
607                         ENABLEOPENIB=3
608                         ;;
609                 esac
610         ],[
611                 ENABLEOPENIB=1
612         ])
613 if test $ENABLEOPENIB -eq 0; then
614         AC_MSG_RESULT([disabled])
615 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
616                -f ${OPENIBPATH}/include/ts_ib_cm.h -a\
617                -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
618         AC_MSG_RESULT([no])
619         case $ENABLEOPENIB in
620         1) ;;
621         2) AC_MSG_ERROR([kernel OpenIB headers not present]);;
622         3) AC_MSG_ERROR([bad --with-openib path]);;
623         *) AC_MSG_ERROR([internal error]);;
624         esac
625 else
626         case $ENABLEOPENIB in
627         1|2) OPENIBCPPFLAGS="-I$OPENIBPATH/include -DIN_TREE_BUILD";;
628         3)   OPENIBCPPFLAGS="-I$OPENIBPATH/include";;
629         *)   AC_MSG_RESULT([no])
630              AC_MSG_ERROR([internal error]);;
631         esac
632         OPENIBCPPFLAGS="$OPENIBCPPFLAGS -DIB_NTXRXPARAMS=4"
633         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
634         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
635         LB_LINUX_TRY_COMPILE([
636                 #include <ts_ib_core.h>
637                 #include <ts_ib_cm.h>
638                 #include <ts_ib_sa_client.h>
639         ],[
640                 struct ib_device_properties dev_props;
641                 struct ib_cm_active_param   cm_active_params;
642                 tTS_IB_CLIENT_QUERY_TID     tid;
643                 int                         enum1 = IB_QP_ATTRIBUTE_STATE;
644                 int                         enum2 = IB_ACCESS_LOCAL_WRITE;
645                 int                         enum3 = IB_CQ_CALLBACK_INTERRUPT;
646                 int                         enum4 = IB_CQ_PROVIDER_REARM;
647                 return 0;
648         ],[
649                 AC_MSG_RESULT([yes])
650                 OPENIBLND="openiblnd"
651         ],[
652                 AC_MSG_RESULT([no])
653                 case $ENABLEOPENIB in
654                 1) ;;
655                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
656                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
657                 *) AC_MSG_ERROR([internal error]);;
658                 esac
659                 OPENIBLND=""
660                 OPENIBCPPFLAGS=""
661         ])
662         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
663 fi
664 AC_SUBST(OPENIBCPPFLAGS)
665 AC_SUBST(OPENIBLND)
666 ])
667
668 #
669 # LN_CONFIG_CIBLND
670 #
671 AC_DEFUN([LN_CONFIG_CIB],[
672 AC_MSG_CHECKING([whether to enable Cisco/TopSpin IB support])
673 # set default
674 CIBPATH=""
675 CIBLND=""
676 AC_ARG_WITH([cib],
677         AC_HELP_STRING([--with-cib=path],
678                        [build ciblnd against path]),
679         [
680                 case $with_cib in
681                 no)     AC_MSG_RESULT([no]);;
682                 *)      CIBPATH="$with_cib"
683                         if test -d "$CIBPATH"; then
684                                 AC_MSG_RESULT([yes])
685                         else
686                                 AC_MSG_RESULT([no])
687                                 AC_MSG_ERROR([No directory $CIBPATH])
688                         fi;;
689                 esac
690         ],[
691                 AC_MSG_RESULT([no])
692         ])
693 if test -n "$CIBPATH"; then
694         CIBCPPFLAGS="-I${CIBPATH}/ib/ts_api_ng/include -I${CIBPATH}/all/kernel_services/include -DUSING_TSAPI"
695         CIBCPPFLAGS="$CIBCPPFLAGS -DIB_NTXRXPARAMS=3"
696         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
697         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $CIBCPPFLAGS"
698         LB_LINUX_TRY_COMPILE([
699                 #include <ts_ib_core.h>
700                 #include <ts_ib_cm.h>
701                 #include <ts_ib_sa_client.h>
702         ],[
703                 struct ib_device_properties dev_props;
704                 struct ib_cm_active_param   cm_active_params;
705                 tTS_IB_CLIENT_QUERY_TID     tid;
706                 int                         enum1 = TS_IB_QP_ATTRIBUTE_STATE;
707                 int                         enum2 = TS_IB_ACCESS_LOCAL_WRITE;
708                 int                         enum3 = TS_IB_CQ_CALLBACK_INTERRUPT;
709                 int                         enum4 = TS_IB_CQ_PROVIDER_REARM;
710                 return 0;
711         ],[
712                 CIBLND="ciblnd"
713         ],[
714                 AC_MSG_ERROR([can't compile ciblnd with given path])
715                 CIBCPPFLAGS=""
716         ])
717         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
718 fi
719 AC_SUBST(CIBCPPFLAGS)
720 AC_SUBST(CIBLND)
721 ])
722
723 #
724 # LN_CONFIG_IIB
725 #
726 # check for infinicon infiniband support
727 #
728 AC_DEFUN([LN_CONFIG_IIB],[
729 AC_MSG_CHECKING([whether to enable Infinicon support])
730 # set default
731 IIBPATH="/usr/include"
732 AC_ARG_WITH([iib],
733         AC_HELP_STRING([--with-iib=path],
734                        [build iiblnd against path]),
735         [
736                 case $with_iib in
737                 yes)    ENABLEIIB=2
738                         ;;
739                 no)     ENABLEIIB=0
740                         ;;
741                 *)      IIBPATH="${with_iib}/include"
742                         ENABLEIIB=3
743                         ;;
744                 esac
745         ],[
746                 ENABLEIIB=1
747         ])
748 if test $ENABLEIIB -eq 0; then
749         AC_MSG_RESULT([disabled])
750 elif test ! \( -f ${IIBPATH}/linux/iba/ibt.h \); then
751         AC_MSG_RESULT([no])
752         case $ENABLEIIB in
753         1) ;;
754         2) AC_MSG_ERROR([default Infinicon headers not present]);;
755         3) AC_MSG_ERROR([bad --with-iib path]);;
756         *) AC_MSG_ERROR([internal error]);;
757         esac
758 else
759         IIBCPPFLAGS="-I$IIBPATH"
760         if test $IIBPATH != "/usr/include"; then
761                 # we need /usr/include come what may
762                 IIBCPPFLAGS="$IIBCPPFLAGS -I/usr/include"
763         fi
764         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
765         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
766         LB_LINUX_TRY_COMPILE([
767                 #include <linux/iba/ibt.h>
768         ],[
769                 IBT_INTERFACE_UNION interfaces;
770                 FSTATUS             rc;
771
772                  rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
773                                                &interfaces);
774
775                 return rc == FSUCCESS ? 0 : 1;
776         ],[
777                 AC_MSG_RESULT([yes])
778                 IIBLND="iiblnd"
779         ],[
780                 AC_MSG_RESULT([no])
781                 case $ENABLEIIB in
782                 1) ;;
783                 2) AC_MSG_ERROR([can't compile with default Infinicon headers]);;
784                 3) AC_MSG_ERROR([can't compile with Infinicon headers under $IIBPATH]);;
785                 *) AC_MSG_ERROR([internal error]);;
786                 esac
787                 IIBLND=""
788                 IIBCPPFLAGS=""
789         ])
790         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
791 fi
792 AC_SUBST(IIBCPPFLAGS)
793 AC_SUBST(IIBLND)
794 ])
795
796 #
797 # LN_CONFIG_VIB
798 #
799 # check for Voltaire infiniband support
800 #
801 AC_DEFUN([LN_CONFIG_VIB],
802 [AC_MSG_CHECKING([whether to enable Voltaire IB support])
803 VIBPATH=""
804 AC_ARG_WITH([vib],
805         AC_HELP_STRING([--with-vib=path],
806                        [build viblnd against path]),
807         [
808                 case $with_vib in
809                 no)     AC_MSG_RESULT([no]);;
810                 *)      VIBPATH="${with_vib}/src/nvigor/ib-code"
811                         if test -d "$with_vib" -a -d "$VIBPATH"; then
812                                 AC_MSG_RESULT([yes])
813                         else
814                                 AC_MSG_RESULT([no])
815                                 AC_MSG_ERROR([No directory $VIBPATH])
816                         fi;;
817                 esac
818         ],[
819                 AC_MSG_RESULT([no])
820         ])
821 if test -z "$VIBPATH"; then
822         VIBLND=""
823 else
824         VIBCPPFLAGS="-I${VIBPATH}/include -I${VIBPATH}/cm"
825         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
826         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
827         LB_LINUX_TRY_COMPILE([
828                 #include <linux/list.h>
829                 #include <asm/byteorder.h>
830                 #ifdef __BIG_ENDIAN
831                 # define CPU_BE 1
832                 # define CPU_LE 0
833                 #endif
834                 #ifdef __LITTLE_ENDIAN
835                 # define CPU_BE 0
836                 # define CPU_LE 1
837                 #endif
838                 #include <vverbs.h>
839                 #include <ib-cm.h>
840                 #include <ibat.h>
841         ],[
842                 vv_hca_h_t       kib_hca;
843                 vv_return_t      vvrc;
844                 cm_cep_handle_t  cep;
845                 ibat_arp_data_t  arp_data;
846                 ibat_stat_t      ibatrc;
847
848                 vvrc = vv_hca_open("ANY_HCA", NULL, &kib_hca);
849                 cep = cm_create_cep(cm_cep_transp_rc);
850                 ibatrc = ibat_get_ib_data((uint32_t)0, (uint32_t)0,
851                                           ibat_paths_primary, &arp_data,
852                                           (ibat_get_ib_data_reply_fn_t)NULL,
853                                           NULL, 0);
854                 return 0;
855         ],[
856                 VIBLND="viblnd"
857         ],[
858                 AC_MSG_ERROR([can't compile viblnd with given path])
859         ])
860         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
861 fi
862 if test -n "$VIBLND"; then
863         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
864         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
865         AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
866         LB_LINUX_TRY_COMPILE([
867                 #include <linux/list.h>
868                 #include <asm/byteorder.h>
869                 #ifdef __BIG_ENDIAN
870                 # define CPU_BE 1
871                 # define CPU_LE 0
872                 #endif
873                 #ifdef __LITTLE_ENDIAN
874                 # define CPU_BE 0
875                 # define CPU_LE 1
876                 #endif
877                 #include <vverbs.h>
878                 #include <ib-cm.h>
879                 #include <ibat.h>
880         ],[
881                 vv_scatgat_t  sg;
882
883                 return &sg.v_address[3] == NULL;
884         ],[
885                 AC_MSG_RESULT([yes])
886                 VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_VOIDSTAR_SGADDR=1"
887         ],[
888                 AC_MSG_RESULT([no])
889         ])
890         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
891 fi
892 AC_SUBST(VIBCPPFLAGS)
893 AC_SUBST(VIBLND)
894 ])
895
896 #
897 # LN_CONFIG_RALND
898 #
899 # check whether to use the RapidArray lnd
900 #
901 AC_DEFUN([LN_CONFIG_RALND],
902 [#### Rapid Array
903 AC_MSG_CHECKING([if RapidArray kernel headers are present])
904 # placeholder
905 RACPPFLAGS="-I${LINUX}/drivers/xd1/include"
906 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
907 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
908 LB_LINUX_TRY_COMPILE([
909         #include <linux/types.h>
910         #include <rapl.h>
911 ],[
912         RAP_RETURN          rc;
913         RAP_PVOID           dev_handle;
914
915         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
916
917         return rc == RAP_SUCCESS ? 0 : 1;
918 ],[
919         AC_MSG_RESULT([yes])
920         RALND="ralnd"
921 ],[
922         AC_MSG_RESULT([no])
923         RALND=""
924         RACPPFLAGS=""
925 ])
926 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
927 AC_SUBST(RACPPFLAGS)
928 AC_SUBST(RALND)
929 ])
930
931 #
932 # LN_STRUCT_PAGE_LIST
933 #
934 # 2.6.4 no longer has page->list
935 #
936 AC_DEFUN([LN_STRUCT_PAGE_LIST],
937 [AC_MSG_CHECKING([if struct page has a list field])
938 LB_LINUX_TRY_COMPILE([
939         #include <linux/mm.h>
940 ],[
941         struct page page;
942         &page.list;
943 ],[
944         AC_MSG_RESULT([yes])
945         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
946 ],[
947         AC_MSG_RESULT([no])
948 ])
949 ])
950
951 #
952 # LN_STRUCT_SIGHAND
953 #
954 # red hat 2.4 adds sighand to struct task_struct
955 #
956 AC_DEFUN([LN_STRUCT_SIGHAND],
957 [AC_MSG_CHECKING([if task_struct has a sighand field])
958 LB_LINUX_TRY_COMPILE([
959         #include <linux/sched.h>
960 ],[
961         struct task_struct p;
962         p.sighand = NULL;
963 ],[
964         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
965         AC_MSG_RESULT([yes])
966 ],[
967         AC_MSG_RESULT([no])
968 ])
969 ])
970
971 #
972 # LN_FUNC_CPU_ONLINE
973 #
974 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
975 #
976 AC_DEFUN([LN_FUNC_CPU_ONLINE],
977 [AC_MSG_CHECKING([if kernel defines cpu_online()])
978 LB_LINUX_TRY_COMPILE([
979         #include <linux/sched.h>
980 ],[
981         cpu_online(0);
982 ],[
983         AC_MSG_RESULT([yes])
984         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
985 ],[
986         AC_MSG_RESULT([no])
987 ])
988 ])
989
990 #
991 # LN_TYPE_GFP_T
992 #
993 # check if gfp_t is typedef-ed
994 #
995 AC_DEFUN([LN_TYPE_GFP_T],
996 [AC_MSG_CHECKING([if kernel defines gfp_t])
997 LB_LINUX_TRY_COMPILE([
998         #include <linux/gfp.h>
999 ],[
1000         return sizeof(gfp_t);
1001 ],[
1002         AC_MSG_RESULT([yes])
1003         AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
1004 ],[
1005         AC_MSG_RESULT([no])
1006 ])
1007 ])
1008
1009 #
1010 # LN_TYPE_CPUMASK_T
1011 #
1012 # same goes for cpumask_t
1013 #
1014 AC_DEFUN([LN_TYPE_CPUMASK_T],
1015 [AC_MSG_CHECKING([if kernel defines cpumask_t])
1016 LB_LINUX_TRY_COMPILE([
1017         #include <linux/sched.h>
1018 ],[
1019         return sizeof (cpumask_t);
1020 ],[
1021         AC_MSG_RESULT([yes])
1022         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
1023 ],[
1024         AC_MSG_RESULT([no])
1025 ])
1026 ])
1027
1028 #
1029 # LN_FUNC_SHOW_TASK
1030 #
1031 # we export show_task(), but not all kernels have it (yet)
1032 #
1033 AC_DEFUN([LN_FUNC_SHOW_TASK],
1034 [AC_MSG_CHECKING([if kernel exports show_task])
1035 have_show_task=0
1036 for file in ksyms sched ; do
1037         if grep -q "EXPORT_SYMBOL(show_task)" \
1038                  "$LINUX/kernel/$file.c" 2>/dev/null ; then
1039                 have_show_task=1
1040                 break
1041         fi
1042 done
1043 if test x$have_show_task = x1 ; then
1044         AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
1045         AC_MSG_RESULT([yes])
1046 else
1047         AC_MSG_RESULT([no])
1048 fi
1049 ])
1050
1051 # LN_TASKLIST_LOCK
1052 # 2.6.18 remove tasklist_lock export
1053 AC_DEFUN([LN_TASKLIST_LOCK],
1054 [AC_MSG_CHECKING([kernel export tasklist_lock])
1055         if grep -q "EXPORT_SYMBOL(tasklist_lock)" \
1056                  "$LINUX/kernel/fork.c" 2>/dev/null ; then
1057                 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
1058                           [tasklist_lock exported])
1059                 AC_MSG_RESULT([yes])
1060         else
1061                 AC_MSG_RESULT([no])
1062         fi
1063 ])
1064
1065 # 2.6.19 API changes
1066 # kmem_cache_destroy(cachep) return void instead of 
1067 # int
1068 AC_DEFUN([LN_KMEM_CACHE_DESTROY_INT],
1069 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
1070 LB_LINUX_TRY_COMPILE([
1071         #include <linux/slab.h>
1072 ],[
1073         int i = kmem_cache_destroy(NULL);
1074 ],[
1075         AC_MSG_RESULT(yes)
1076         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
1077                 [kmem_cache_destroy(cachep) return int])
1078 ],[
1079         AC_MSG_RESULT(NO)
1080 ])
1081 ])
1082
1083 # 2.6.19 API change
1084 #panic_notifier_list use atomic_notifier operations
1085 #
1086 AC_DEFUN([LN_ATOMIC_PANIC_NOTIFIER],
1087 [AC_MSG_CHECKING([panic_notifier_list is atomic])
1088 LB_LINUX_TRY_COMPILE([
1089         #include <linux/notifier.h>
1090         #include <linux/kernel.h>       
1091 ],[
1092         struct atomic_notifier_head panic_notifier_list;
1093 ],[
1094         AC_MSG_RESULT(yes)
1095         AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
1096                 [panic_notifier_list is atomic_notifier_head])
1097 ],[
1098         AC_MSG_RESULT(NO)
1099 ])
1100 ])
1101
1102 # 2.6.20 API change INIT_WORK use 2 args and not 
1103 # store data inside
1104 AC_DEFUN([LN_3ARGS_INIT_WORK],
1105 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
1106 LB_LINUX_TRY_COMPILE([
1107         #include <linux/workqueue.h>
1108 ],[
1109         struct work_struct work;
1110
1111         INIT_WORK(&work, NULL, NULL);
1112 ],[
1113         AC_MSG_RESULT(yes)
1114         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
1115                   [INIT_WORK use 3 args and store data inside])
1116 ],[
1117         AC_MSG_RESULT(NO)
1118 ])
1119 ])
1120
1121 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
1122 # instead of more old which need two.
1123 AC_DEFUN([LL_2ARGS_REGISTER_SYSCTL],
1124 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
1125 LB_LINUX_TRY_COMPILE([
1126         #include <linux/sysctl.h>
1127 ],[
1128         return register_sysctl_table(NULL,0);
1129 ],[
1130         AC_MSG_RESULT(yes)
1131         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
1132                   [register_sysctl_table want 2 args])
1133 ],[
1134         AC_MSG_RESULT(NO)
1135 ])
1136 ])
1137
1138 #
1139 # LN_PROG_LINUX
1140 #
1141 # LNet linux kernel checks
1142 #
1143 AC_DEFUN([LN_PROG_LINUX],
1144 [
1145 LN_FUNC_CPU_ONLINE
1146 LN_TYPE_GFP_T
1147 LN_TYPE_CPUMASK_T
1148 LN_CONFIG_AFFINITY
1149 LN_CONFIG_BACKOFF
1150 LN_CONFIG_PANIC_DUMPLOG
1151 LN_CONFIG_QUADRICS
1152 LN_CONFIG_GM
1153 LN_CONFIG_OPENIB
1154 LN_CONFIG_CIB
1155 LN_CONFIG_VIB
1156 LN_CONFIG_IIB
1157 LN_CONFIG_O2IB
1158 LN_CONFIG_RALND
1159 LN_CONFIG_PTLLND
1160 LN_CONFIG_MX
1161
1162 LN_STRUCT_PAGE_LIST
1163 LN_STRUCT_SIGHAND
1164 LN_FUNC_SHOW_TASK
1165 # 2.6.18
1166 LN_TASKLIST_LOCK
1167 # 2.6.19
1168 LN_KMEM_CACHE_DESTROY_INT
1169 LN_ATOMIC_PANIC_NOTIFIER
1170 # 2.6.20
1171 LN_3ARGS_INIT_WORK
1172 # 2.6.21
1173 LL_2ARGS_REGISTER_SYSCTL
1174 ])
1175
1176 #
1177 # LN_PROG_DARWIN
1178 #
1179 # Darwin checks
1180 #
1181 AC_DEFUN([LN_PROG_DARWIN],
1182 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
1183 ])
1184
1185 #
1186 # LN_PATH_DEFAULTS
1187 #
1188 # default paths for installed files
1189 #
1190 AC_DEFUN([LN_PATH_DEFAULTS],
1191 [
1192 ])
1193
1194 #
1195 # LN_CONFIGURE
1196 #
1197 # other configure checks
1198 #
1199 AC_DEFUN([LN_CONFIGURE],
1200 [# lnet/utils/portals.c
1201 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
1202 AC_CHECK_FUNCS([gethostbyname socket connect])
1203
1204 # lnet/utils/debug.c
1205 AC_CHECK_HEADERS([linux/version.h])
1206
1207 AC_CHECK_TYPE([spinlock_t],
1208         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
1209         [],
1210         [#include <linux/spinlock.h>])
1211
1212 # lnet/utils/wirecheck.c
1213 AC_CHECK_FUNCS([strnlen])
1214
1215 # --------  Check for required packages  --------------
1216
1217 #
1218 # LC_CONFIG_READLINE
1219 #
1220 # Build with readline
1221 #
1222 AC_MSG_CHECKING([whether to enable readline support])
1223 AC_ARG_ENABLE(readline,
1224         AC_HELP_STRING([--disable-readline],
1225                         [disable readline support]),
1226         [],[enable_readline='yes'])
1227 AC_MSG_RESULT([$enable_readline])
1228
1229 # -------- check for readline if enabled ----
1230 if test x$enable_readline = xyes ; then
1231         LIBS_save="$LIBS"
1232         LIBS="-lncurses $LIBS"
1233         AC_CHECK_LIB([readline],[readline],[
1234         LIBREADLINE="-lreadline -lncurses"
1235         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
1236         ],[
1237         LIBREADLINE=""
1238         ])
1239         LIBS="$LIBS_save"
1240 else
1241         LIBREADLINE=""
1242 fi
1243 AC_SUBST(LIBREADLINE)
1244
1245 AC_MSG_CHECKING([if efence debugging support is requested])
1246 AC_ARG_ENABLE(efence,
1247         AC_HELP_STRING([--enable-efence],
1248                         [use efence library]),
1249         [],[enable_efence='no'])
1250 AC_MSG_RESULT([$enable_efence])
1251 if test "$enable_efence" = "yes" ; then
1252         LIBEFENCE="-lefence"
1253         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
1254 else
1255         LIBEFENCE=""
1256 fi
1257 AC_SUBST(LIBEFENCE)
1258
1259 # -------- enable acceptor libwrap (TCP wrappers) support? -------
1260 AC_MSG_CHECKING([if libwrap support is requested])
1261 AC_ARG_ENABLE([libwrap],
1262         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
1263         [case "${enableval}" in
1264                 yes) enable_libwrap=yes ;;
1265                 no) enable_libwrap=no ;;
1266                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
1267         esac],[enable_libwrap=no])
1268 AC_MSG_RESULT([$enable_libwrap])
1269 if test x$enable_libwrap = xyes ; then
1270         LIBWRAP="-lwrap"
1271         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
1272 else
1273         LIBWRAP=""
1274 fi
1275 AC_SUBST(LIBWRAP)
1276
1277 # -------- check for -lpthread support ----
1278 AC_MSG_CHECKING([whether to use libpthread for lnet library])
1279 AC_ARG_ENABLE([libpthread],
1280         AC_HELP_STRING([--disable-libpthread],
1281                 [disable libpthread]),
1282         [],[enable_libpthread=yes])
1283 if test "$enable_libpthread" = "yes" ; then
1284         AC_CHECK_LIB([pthread], [pthread_create],
1285                 [ENABLE_LIBPTHREAD="yes"],
1286                 [ENABLE_LIBPTHREAD="no"])
1287         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
1288                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
1289                 PTHREAD_LIBS="-lpthread"
1290                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
1291         else
1292                 PTHREAD_LIBS=""
1293                 AC_MSG_RESULT([no libpthread is found])
1294         fi
1295         AC_SUBST(PTHREAD_LIBS)
1296 else
1297         AC_MSG_RESULT([no (disabled explicitly)])
1298         ENABLE_LIBPTHREAD="no"
1299 fi
1300 AC_SUBST(ENABLE_LIBPTHREAD)
1301
1302 # ----------------------------------------
1303 # some tests for catamount-like systems
1304 # ----------------------------------------
1305 AC_ARG_ENABLE([sysio_init],
1306         AC_HELP_STRING([--disable-sysio-init],
1307                 [call sysio init functions when initializing liblustre]),
1308         [],[enable_sysio_init=yes])
1309 AC_MSG_CHECKING([whether to initialize libsysio])
1310 AC_MSG_RESULT([$enable_sysio_init])
1311 if test x$enable_sysio_init != xno ; then
1312         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
1313 fi
1314
1315 AC_ARG_ENABLE([urandom],
1316         AC_HELP_STRING([--disable-urandom],
1317                 [disable use of /dev/urandom for liblustre]),
1318         [],[enable_urandom=yes])
1319 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
1320 AC_MSG_RESULT([$enable_urandom])
1321 if test x$enable_urandom != xno ; then
1322         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
1323 fi
1324
1325 # -------- check for -lcap support ----
1326 if test x$enable_liblustre = xyes ; then
1327         AC_CHECK_LIB([cap], [cap_get_proc],
1328                 [
1329                         CAP_LIBS="-lcap"
1330                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
1331                 ],
1332                 [
1333                         CAP_LIBS=""
1334                 ])
1335         AC_SUBST(CAP_LIBS)
1336
1337 fi
1338
1339 LN_CONFIG_MAX_PAYLOAD
1340 LN_CONFIG_UPTLLND
1341 LN_CONFIG_USOCKLND
1342 ])
1343
1344 #
1345 # LN_CONDITIONALS
1346 #
1347 # AM_CONDITOINAL defines for lnet
1348 #
1349 AC_DEFUN([LN_CONDITIONALS],
1350 [AM_CONDITIONAL(BUILD_QSWLND, test x$QSWLND = "xqswlnd")
1351 AM_CONDITIONAL(BUILD_GMLND, test x$GMLND = "xgmlnd")
1352 AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
1353 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
1354 AM_CONDITIONAL(BUILD_OPENIBLND, test x$OPENIBLND = "xopeniblnd")
1355 AM_CONDITIONAL(BUILD_CIBLND, test x$CIBLND = "xciblnd")
1356 AM_CONDITIONAL(BUILD_IIBLND, test x$IIBLND = "xiiblnd")
1357 AM_CONDITIONAL(BUILD_VIBLND, test x$VIBLND = "xviblnd")
1358 AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
1359 AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
1360 AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
1361 AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
1362 ])
1363
1364 #
1365 # LN_CONFIG_FILES
1366 #
1367 # files that should be generated with AC_OUTPUT
1368 #
1369 AC_DEFUN([LN_CONFIG_FILES],
1370 [AC_CONFIG_FILES([
1371 lnet/Kernelenv
1372 lnet/Makefile
1373 lnet/autoMakefile
1374 lnet/autoconf/Makefile
1375 lnet/doc/Makefile
1376 lnet/include/Makefile
1377 lnet/include/libcfs/Makefile
1378 lnet/include/libcfs/linux/Makefile
1379 lnet/include/lnet/Makefile
1380 lnet/include/lnet/linux/Makefile
1381 lnet/klnds/Makefile
1382 lnet/klnds/autoMakefile
1383 lnet/klnds/gmlnd/Makefile
1384 lnet/klnds/mxlnd/autoMakefile
1385 lnet/klnds/mxlnd/Makefile
1386 lnet/klnds/gmlnd/autoMakefile
1387 lnet/klnds/openiblnd/Makefile
1388 lnet/klnds/openiblnd/autoMakefile
1389 lnet/klnds/o2iblnd/Makefile
1390 lnet/klnds/o2iblnd/autoMakefile
1391 lnet/klnds/ciblnd/Makefile
1392 lnet/klnds/ciblnd/autoMakefile
1393 lnet/klnds/iiblnd/Makefile
1394 lnet/klnds/iiblnd/autoMakefile
1395 lnet/klnds/viblnd/Makefile
1396 lnet/klnds/viblnd/autoMakefile
1397 lnet/klnds/qswlnd/Makefile
1398 lnet/klnds/qswlnd/autoMakefile
1399 lnet/klnds/ralnd/Makefile
1400 lnet/klnds/ralnd/autoMakefile
1401 lnet/klnds/socklnd/Makefile
1402 lnet/klnds/socklnd/autoMakefile
1403 lnet/klnds/ptllnd/Makefile
1404 lnet/klnds/ptllnd/autoMakefile
1405 lnet/libcfs/Makefile
1406 lnet/libcfs/autoMakefile
1407 lnet/libcfs/linux/Makefile
1408 lnet/lnet/Makefile
1409 lnet/lnet/autoMakefile
1410 lnet/ulnds/Makefile
1411 lnet/ulnds/autoMakefile
1412 lnet/ulnds/socklnd/Makefile
1413 lnet/ulnds/ptllnd/Makefile
1414 lnet/utils/Makefile
1415 ])
1416 case $lb_target_os in
1417         darwin)
1418                 AC_CONFIG_FILES([
1419 lnet/include/libcfs/darwin/Makefile
1420 lnet/include/lnet/darwin/Makefile
1421 lnet/libcfs/darwin/Makefile
1422 ])
1423                 ;;
1424 esac
1425 ])