Whamcloud - gitweb
7023714c0be7a155c56c8db24222ae0e725601d8
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
1 #
2 # LP_CONFIG_ZEROCOPY
3 #
4 # check if zerocopy is available/wanted
5 #
6 AC_DEFUN([LP_CONFIG_ZEROCOPY],
7 [AC_MSG_CHECKING([for zero-copy TCP support])
8 AC_ARG_ENABLE([zerocopy],
9         AC_HELP_STRING([--disable-zerocopy],
10                        [disable socknal zerocopy]),
11         [],[enable_zerocopy='yes'])
12 if test x$enable_zerocopy = xno ; then
13         AC_MSG_RESULT([no (by request)])
14 else
15         ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
16         if test "$ZCCD" != 0 ; then
17                 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
18                 AC_MSG_RESULT(yes)
19         else
20                 AC_MSG_RESULT([no (no kernel support)])
21         fi
22 fi
23 ])
24
25 #
26 # LP_CONFIG_AFFINITY
27 #
28 # check if cpu affinity is available/wanted
29 #
30 AC_DEFUN([LP_CONFIG_AFFINITY],
31 [AC_ARG_ENABLE([affinity],
32         AC_HELP_STRING([--disable-affinity],
33                        [disable process/irq affinity]),
34         [],[enable_affinity='yes'])
35
36 AC_MSG_CHECKING([for CPU affinity support])
37 if test x$enable_affinity = xno ; then
38         AC_MSG_RESULT([no (by request)])
39 else
40         LB_LINUX_TRY_COMPILE([
41                 #include <linux/sched.h>
42         ],[
43                 struct task_struct t;
44                 #ifdef CPU_ARRAY_SIZE
45                 cpumask_t m;
46                 #else
47                 unsigned long m;
48                 #endif
49                 set_cpus_allowed(&t, m);
50         ],[
51                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
52                 AC_MSG_RESULT([yes])
53         ],[
54                 AC_MSG_RESULT([no (no kernel support)])
55         ])
56 fi
57 ])
58
59 #
60 # LP_CONFIG_QUADRICS
61 #
62 # check if quadrics support is in this kernel
63 #
64 AC_DEFUN([LP_CONFIG_QUADRICS],
65 [AC_MSG_CHECKING([if quadrics kernel headers are present])
66 if test -d $LINUX/drivers/net/qsnet ; then
67         AC_MSG_RESULT([yes])
68         QSWNAL="qswnal"
69         AC_MSG_CHECKING([for multirail EKC])
70         if test -f $LINUX/include/elan/epcomms.h; then
71                 AC_MSG_RESULT([supported])
72                 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
73         else
74                 AC_MSG_RESULT([not supported])
75                 if test -d $LINUX/drivers/net/qsnet/include; then
76                         QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
77                 else
78                         QSWCPPFLAGS="-I$LINUX/include/linux"
79                 fi
80         fi
81 else
82         AC_MSG_RESULT([no])
83         QSWNAL=""
84         QSWCPPFLAGS=""
85 fi
86 AC_SUBST(QSWCPPFLAGS)
87 AC_SUBST(QSWNAL)
88 ])
89
90 #
91 # LP_CONFIG_GM
92 #
93 # check if GM support is available
94 #
95 AC_DEFUN([LP_CONFIG_GM],
96 [AC_MSG_CHECKING([if gm support was requested])
97 AC_ARG_WITH([gm],
98         AC_HELP_STRING([--with-gm=path],
99                        [build gmnal against path]),
100         [
101                 case $with_gm in 
102                         yes)
103                                 AC_MSG_RESULT([yes])
104                                 GMCPPFLAGS="-I/usr/local/gm/include"
105                                 GMNAL="gmnal"
106                                 ;;
107                         no)
108                                 AC_MSG_RESULT([no])
109                                 GMCPPFLAGS=""
110                                 GMNAL=""
111                                 ;;
112                         *)
113                                 AC_MSG_RESULT([yes])
114                                 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
115                                 GMNAL="gmnal"
116                                 ;;
117                 esac
118         ],[
119                 AC_MSG_RESULT([no])
120                 GMCPPFLAGS=""
121                 GMNAL=""
122         ])
123 AC_SUBST(GMCPPFLAGS)
124 AC_SUBST(GMNAL)
125 ])
126
127 #
128 # LP_CONFIG_OPENIB
129 #
130 # check for OpenIB in the kernel
131 AC_DEFUN([LP_CONFIG_OPENIB],[
132 AC_MSG_CHECKING([whether to enable OpenIB support])
133 # set default
134 OPENIBPATH="$LINUX/drivers/infiniband"
135 AC_ARG_WITH([openib],
136         AC_HELP_STRING([--with-openib=path],
137                        [build openibnal against path]),
138         [
139                 case $with_openib in
140                 yes)    ENABLEOPENIB=2
141                         ;;
142                 no)     ENABLEOPENIB=0
143                         ;;
144                 *)      OPENIBPATH="$with_openib"
145                         ENABLEOPENIB=3
146                         ;;
147                 esac
148         ],[
149                 ENABLEOPENIB=1
150         ])
151 if test $ENABLEOPENIB -eq 0; then
152         AC_MSG_RESULT([disabled])
153 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
154                -f ${OPENIBPATH}/include/ts_ib_cm.h -a\
155                -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
156         AC_MSG_RESULT([no])
157         case $ENABLEOPENIB in
158         1) ;;
159         2) AC_MSG_ERROR([kernel OpenIB headers not present]);;
160         3) AC_MSG_ERROR([bad --with-openib path]);;
161         *) AC_MSG_ERROR([internal error]);;
162         esac
163 else
164         case $ENABLEOPENIB in
165         1|2) OPENIBCPPFLAGS="-I$OPENIBPATH/include -DIN_TREE_BUILD";;
166         3)   OPENIBCPPFLAGS="-I$OPENIBPATH/include";;
167         *)   AC_MSG_RESULT([no])
168              AC_MSG_ERROR([internal error]);;
169         esac
170         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
171         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
172         LB_LINUX_TRY_COMPILE([
173                 #include <ts_ib_core.h>
174                 #include <ts_ib_cm.h>
175                 #include <ts_ib_sa_client.h>
176         ],[
177                 struct ib_device_properties dev_props;
178                 struct ib_cm_active_param   cm_active_params;
179                 tTS_IB_CLIENT_QUERY_TID     tid;
180                 int                         enum1 = IB_QP_ATTRIBUTE_STATE;
181                 int                         enum2 = IB_ACCESS_LOCAL_WRITE;
182                 int                         enum3 = IB_CQ_CALLBACK_INTERRUPT;
183                 int                         enum4 = IB_CQ_PROVIDER_REARM;
184                 return 0;
185         ],[
186                 AC_MSG_RESULT([yes])
187                 OPENIBNAL="openibnal"
188         ],[
189                 AC_MSG_RESULT([no])
190                 case $ENABLEOPENIB in
191                 1) ;;
192                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
193                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
194                 *) AC_MSG_ERROR([internal error]);;
195                 esac
196                 OPENIBNAL=""
197                 OPENIBCPPFLAGS=""
198         ])
199         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
200 fi
201 AC_SUBST(OPENIBCPPFLAGS)
202 AC_SUBST(OPENIBNAL)
203 ])
204
205 #
206 # LP_CONFIG_IIB
207 #
208 # check for infinicon infiniband support
209 #
210 AC_DEFUN([LP_CONFIG_IIB],
211 [AC_MSG_CHECKING([if Infinicon IB kernel headers are present])
212 # for how the only infinicon ib build has headers in /usr/include/iba
213 IIBCPPFLAGS="-I/usr/include -DIN_TREE_BUILD"
214 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
215 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
216 LB_LINUX_TRY_COMPILE([
217         #include <linux/iba/ibt.h>
218 ],[
219         IBT_INTERFACE_UNION interfaces;
220         FSTATUS             rc;
221
222          rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
223                                        &interfaces);
224
225         return rc == FSUCCESS ? 0 : 1;
226 ],[
227         AC_MSG_RESULT([yes])
228         IIBNAL="iibnal"
229 ],[
230         AC_MSG_RESULT([no])
231         IIBNAL=""
232         IIBCPPFLAGS=""
233 ])
234 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
235 AC_SUBST(IIBCPPFLAGS)
236 AC_SUBST(IIBNAL)
237 ])
238
239 #
240 # LP_CONFIG_VIB
241 #
242 # check for Voltaire infiniband support
243 #
244 AC_DEFUN([LP_CONFIG_VIB],
245 [AC_MSG_CHECKING([if Voltaire IB kernel headers are present])
246 VIBCPPFLAGS="-I/usr/local/include/ibhost-kdevel -DCPU_BE=0 -DCPU_LE=1 -DGSI_PASS_PORT_NUM"
247 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
248 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
249 LB_LINUX_TRY_COMPILE([
250         #include <linux/list.h>
251         #include <vverbs.h>
252 ],[
253         vv_hca_h_t     kib_hca;
254         vv_return_t    retval;
255
256         retval = vv_hca_open("ANY_HCA", NULL, &kib_hca);
257
258         return retval == vv_return_ok ? 0 : 1;
259 ],[
260         AC_MSG_RESULT([yes])
261         VIBNAL="vibnal"
262 ],[
263         AC_MSG_RESULT([no])
264         VIBNAL=""
265         VIBCPPFLAGS=""
266 ])
267 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
268 AC_SUBST(VIBCPPFLAGS)
269 AC_SUBST(VIBNAL)
270 ])
271
272 #
273 # LP_CONFIG_RANAL
274 #
275 # check whether to use the RapidArray nal
276 #
277 AC_DEFUN([LP_CONFIG_RANAL],
278 [#### Rapid Array
279 AC_MSG_CHECKING([if RapidArray kernel headers are present])
280 # placeholder
281 RACPPFLAGS="-I/tmp"
282 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
283 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
284 LB_LINUX_TRY_COMPILE([
285         #include <linux/types.h>
286         #include <rapl.h>
287 ],[
288         RAP_RETURN          rc;
289         RAP_PVOID           dev_handle;
290
291         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
292
293         return rc == RAP_SUCCESS ? 0 : 1;
294 ],[
295         AC_MSG_RESULT([yes])
296         RANAL="ranal"
297 ],[
298         AC_MSG_RESULT([no])
299         RANAL=""
300         RACPPFLAGS=""
301 ])
302 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
303 AC_SUBST(RACPPFLAGS)
304 AC_SUBST(RANAL)
305 ])
306
307 #
308 # LP_STRUCT_PAGE_LIST
309 #
310 # 2.6.4 no longer has page->list
311 #
312 AC_DEFUN([LP_STRUCT_PAGE_LIST],
313 [AC_MSG_CHECKING([if struct page has a list field])
314 LB_LINUX_TRY_COMPILE([
315         #include <linux/mm.h>
316 ],[
317         struct page page;
318         &page.list;
319 ],[
320         AC_MSG_RESULT([yes])
321         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
322 ],[
323         AC_MSG_RESULT([no])
324 ])
325 ])
326
327 #
328 # LP_STRUCT_SIGHAND
329 #
330 # red hat 2.4 adds sighand to struct task_struct
331 #
332 AC_DEFUN([LP_STRUCT_SIGHAND],
333 [AC_MSG_CHECKING([if task_struct has a sighand field])
334 LB_LINUX_TRY_COMPILE([
335         #include <linux/sched.h>
336 ],[
337         struct task_struct p;
338         p.sighand = NULL;
339 ],[
340         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
341         AC_MSG_RESULT([yes])
342 ],[
343         AC_MSG_RESULT([no])
344 ])
345 ])
346
347 #
348 # LP_FUNC_CPU_ONLINE
349 #
350 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
351 #
352 AC_DEFUN([LP_FUNC_CPU_ONLINE],
353 [AC_MSG_CHECKING([if kernel defines cpu_online()])
354 LB_LINUX_TRY_COMPILE([
355         #include <linux/sched.h>
356 ],[
357         cpu_online(0);
358 ],[
359         AC_MSG_RESULT([yes])
360         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
361 ],[
362         AC_MSG_RESULT([no])
363 ])
364 ])
365
366 #
367 # LP_TYPE_CPUMASK_T
368 #
369 # same goes for cpumask_t
370 #
371 AC_DEFUN([LP_TYPE_CPUMASK_T],
372 [AC_MSG_CHECKING([if kernel defines cpumask_t])
373 LB_LINUX_TRY_COMPILE([
374         #include <linux/sched.h>
375 ],[
376         return sizeof (cpumask_t);
377 ],[
378         AC_MSG_RESULT([yes])
379         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
380 ],[
381         AC_MSG_RESULT([no])
382 ])
383 ])
384
385 #
386 # LP_FUNC_SHOW_TASK
387 #
388 # we export show_task(), but not all kernels have it (yet)
389 #
390 AC_DEFUN([LP_FUNC_SHOW_TASK],
391 [AC_MSG_CHECKING([if kernel exports show_task])
392 have_show_task=0
393 for file in ksyms sched ; do
394         if grep -q "EXPORT_SYMBOL(show_task)" \
395                  "$LINUX/kernel/$file.c" 2>/dev/null ; then
396                 have_show_task=1
397                 break
398         fi
399 done
400 if test x$have_show_task = x1 ; then
401         AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
402         AC_MSG_RESULT([yes])
403 else
404         AC_MSG_RESULT([no])
405 fi
406 ])
407
408 #
409 # LP_PROG_LINUX
410 #
411 # Portals linux kernel checks
412 #
413 AC_DEFUN([LP_PROG_LINUX],
414 [LP_CONFIG_ZEROCOPY
415 LP_CONFIG_AFFINITY
416 LP_CONFIG_QUADRICS
417 LP_CONFIG_GM
418 LP_CONFIG_OPENIB
419 LP_CONFIG_IIB
420 LP_CONFIG_VIB
421 LP_CONFIG_RANAL
422
423 LP_STRUCT_PAGE_LIST
424 LP_STRUCT_SIGHAND
425 LP_FUNC_CPU_ONLINE
426 LP_TYPE_CPUMASK_T
427 LP_FUNC_SHOW_TASK
428 ])
429
430 #
431 # LP_PATH_DEFAULTS
432 #
433 # default paths for installed files
434 #
435 AC_DEFUN([LP_PATH_DEFAULTS],
436 [
437 ])
438
439 #
440 # LP_CONFIGURE
441 #
442 # other configure checks
443 #
444 AC_DEFUN([LP_CONFIGURE],
445 [# portals/utils/portals.c
446 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h])
447 AC_CHECK_FUNCS([gethostbyname socket connect])
448
449 # portals/utils/debug.c
450 AC_CHECK_HEADERS([linux/version.h])
451
452 AC_CHECK_TYPE([spinlock_t],
453         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
454         [],
455         [#include <linux/spinlock.h>])
456
457 # --------  Check for required packages  --------------
458
459 # this doesn't seem to work on older autoconf
460 # AC_CHECK_LIB(readline, readline,,)
461 AC_MSG_CHECKING([for readline support])
462 AC_ARG_ENABLE(readline,
463         AC_HELP_STRING([--disable-readline],
464                         [do not use readline library]),
465         [],[enable_readline='yes'])
466 AC_MSG_RESULT([$enable_readline]) 
467 if test x$enable_readline = xyes ; then
468         LIBREADLINE="-lreadline -lncurses"
469         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
470 else 
471         LIBREADLINE=""
472 fi
473 AC_SUBST(LIBREADLINE)
474
475 AC_MSG_CHECKING([if efence debugging support is requested])
476 AC_ARG_ENABLE(efence,
477         AC_HELP_STRING([--enable-efence],
478                         [use efence library]),
479         [],[enable_efence='no'])
480 AC_MSG_RESULT([$enable_efence])
481 if test "$enable_efence" = "yes" ; then
482         LIBEFENCE="-lefence"
483         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
484 else 
485         LIBEFENCE=""
486 fi
487 AC_SUBST(LIBEFENCE)
488
489 # -------- enable acceptor libwrap (TCP wrappers) support? -------
490 AC_MSG_CHECKING([if libwrap support is requested])
491 AC_ARG_ENABLE([libwrap],
492         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
493         [case "${enableval}" in
494                 yes) enable_libwrap=yes ;;
495                 no) enable_libwrap=no ;;
496                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
497         esac],[enable_libwrap=no])
498 AC_MSG_RESULT([$enable_libwrap])
499 if test x$enable_libwrap = xyes ; then
500         LIBWRAP="-lwrap"
501         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
502 else
503         LIBWRAP=""
504 fi
505 AC_SUBST(LIBWRAP)
506
507 # ----------------------------------------
508 # some tests for catamount-like systems
509 # ----------------------------------------
510 AC_ARG_ENABLE([sysio_init],
511         AC_HELP_STRING([--disable-sysio-init],
512                 [call sysio init functions when initializing liblustre]),
513         [],[enable_sysio_init=yes])
514 AC_MSG_CHECKING([whether to initialize libsysio])
515 AC_MSG_RESULT([$enable_sysio_init])
516 if test x$enable_sysio_init != xno ; then
517         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
518 fi
519
520 AC_ARG_ENABLE([urandom],
521         AC_HELP_STRING([--disable-urandom],
522                 [disable use of /dev/urandom for liblustre]),
523         [],[enable_urandom=yes])
524 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
525 AC_MSG_RESULT([$enable_urandom])
526 if test x$enable_urandom != xno ; then
527         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
528 fi
529
530 # -------- check for -lcap and -lpthread ----
531 if test x$enable_liblustre = xyes ; then
532         AC_CHECK_LIB([cap], [cap_get_proc],
533                 [
534                         CAP_LIBS="-lcap"
535                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
536                 ],
537                 [CAP_LIBS=""])
538         AC_SUBST(CAP_LIBS)
539         AC_CHECK_LIB([pthread], [pthread_create],
540                 [
541                         PTHREAD_LIBS="-lpthread"
542                         AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
543                 ],
544                 [PTHREAD_LIBS=""])
545         AC_SUBST(PTHREAD_LIBS)
546 fi
547 ])
548
549 #
550 # LP_CONDITIONALS
551 #
552 # AM_CONDITOINAL defines for portals
553 #
554 AC_DEFUN([LP_CONDITIONALS],
555 [AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
556 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
557 AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
558 AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal")
559 AM_CONDITIONAL(BUILD_VIBNAL, test x$VIBNAL = "xvibnal")
560 AM_CONDITIONAL(BUILD_RANAL, test x$RANAL = "xranal")
561 ])
562
563 #
564 # LP_CONFIG_FILES
565 #
566 # files that should be generated with AC_OUTPUT
567 #
568 AC_DEFUN([LP_CONFIG_FILES],
569 [AC_CONFIG_FILES([
570 portals/Kernelenv
571 portals/Makefile
572 portals/autoMakefile
573 portals/autoconf/Makefile
574 portals/doc/Makefile
575 portals/include/Makefile
576 portals/include/linux/Makefile
577 portals/include/portals/Makefile
578 portals/knals/Makefile
579 portals/knals/autoMakefile
580 portals/knals/gmnal/Makefile
581 portals/knals/gmnal/autoMakefile
582 portals/knals/openibnal/Makefile
583 portals/knals/openibnal/autoMakefile
584 portals/knals/iibnal/Makefile
585 portals/knals/iibnal/autoMakefile
586 portals/knals/vibnal/Makefile
587 portals/knals/vibnal/autoMakefile
588 portals/knals/lonal/Makefile
589 portals/knals/lonal/autoMakefile
590 portals/knals/qswnal/Makefile
591 portals/knals/qswnal/autoMakefile
592 portals/knals/ranal/Makefile
593 portals/knals/ranal/autoMakefile
594 portals/knals/socknal/Makefile
595 portals/knals/socknal/autoMakefile
596 portals/libcfs/Makefile
597 portals/libcfs/autoMakefile
598 portals/portals/Makefile
599 portals/portals/autoMakefile
600 portals/router/Makefile
601 portals/router/autoMakefile
602 portals/tests/Makefile
603 portals/tests/autoMakefile
604 portals/unals/Makefile
605 portals/utils/Makefile
606 ])
607 ])