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