Whamcloud - gitweb
originally by phil
[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${LINUX}/drivers/xd1/include"
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_PROG_DARWIN
432 #
433 # Darwin checks
434 #
435 AC_DEFUN([LP_PROG_DARWIN],
436 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
437 ])
438
439 #
440 # LP_PATH_DEFAULTS
441 #
442 # default paths for installed files
443 #
444 AC_DEFUN([LP_PATH_DEFAULTS],
445 [
446 ])
447
448 #
449 # LP_CONFIGURE
450 #
451 # other configure checks
452 #
453 AC_DEFUN([LP_CONFIGURE],
454 [# portals/utils/portals.c
455 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h])
456 AC_CHECK_FUNCS([gethostbyname socket connect])
457
458 # portals/utils/debug.c
459 AC_CHECK_HEADERS([linux/version.h])
460
461 AC_CHECK_TYPE([spinlock_t],
462         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
463         [],
464         [#include <linux/spinlock.h>])
465
466 # portals/utils/wirecheck.c
467 AC_CHECK_FUNCS([strnlen])
468
469 # --------  Check for required packages  --------------
470
471 LIBS_save="$LIBS"
472 LIBS="-lncurses $LIBS"
473 AC_CHECK_LIB([readline],[readline],[
474         LIBREADLINE="-lreadline -lncurses"
475         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
476 ],[
477         LIBREADLINE=""
478 ])
479 LIBS="$LIBS_save"
480 AC_SUBST(LIBREADLINE)
481
482 AC_MSG_CHECKING([if efence debugging support is requested])
483 AC_ARG_ENABLE(efence,
484         AC_HELP_STRING([--enable-efence],
485                         [use efence library]),
486         [],[enable_efence='no'])
487 AC_MSG_RESULT([$enable_efence])
488 if test "$enable_efence" = "yes" ; then
489         LIBEFENCE="-lefence"
490         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
491 else 
492         LIBEFENCE=""
493 fi
494 AC_SUBST(LIBEFENCE)
495
496 # -------- enable acceptor libwrap (TCP wrappers) support? -------
497 AC_MSG_CHECKING([if libwrap support is requested])
498 AC_ARG_ENABLE([libwrap],
499         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
500         [case "${enableval}" in
501                 yes) enable_libwrap=yes ;;
502                 no) enable_libwrap=no ;;
503                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
504         esac],[enable_libwrap=no])
505 AC_MSG_RESULT([$enable_libwrap])
506 if test x$enable_libwrap = xyes ; then
507         LIBWRAP="-lwrap"
508         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
509 else
510         LIBWRAP=""
511 fi
512 AC_SUBST(LIBWRAP)
513
514 # ----------------------------------------
515 # some tests for catamount-like systems
516 # ----------------------------------------
517 AC_ARG_ENABLE([sysio_init],
518         AC_HELP_STRING([--disable-sysio-init],
519                 [call sysio init functions when initializing liblustre]),
520         [],[enable_sysio_init=yes])
521 AC_MSG_CHECKING([whether to initialize libsysio])
522 AC_MSG_RESULT([$enable_sysio_init])
523 if test x$enable_sysio_init != xno ; then
524         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
525 fi
526
527 AC_ARG_ENABLE([urandom],
528         AC_HELP_STRING([--disable-urandom],
529                 [disable use of /dev/urandom for liblustre]),
530         [],[enable_urandom=yes])
531 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
532 AC_MSG_RESULT([$enable_urandom])
533 if test x$enable_urandom != xno ; then
534         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
535 fi
536
537 # -------- check for -lcap and -lpthread ----
538 if test x$enable_liblustre = xyes ; then
539         AC_CHECK_LIB([cap], [cap_get_proc],
540                 [
541                         CAP_LIBS="-lcap"
542                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
543                 ],
544                 [CAP_LIBS=""])
545         AC_SUBST(CAP_LIBS)
546         AC_CHECK_LIB([pthread], [pthread_create],
547                 [
548                         PTHREAD_LIBS="-lpthread"
549                         AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
550                 ],
551                 [PTHREAD_LIBS=""])
552         AC_SUBST(PTHREAD_LIBS)
553 fi
554 ])
555
556 #
557 # LP_CONDITIONALS
558 #
559 # AM_CONDITOINAL defines for portals
560 #
561 AC_DEFUN([LP_CONDITIONALS],
562 [AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
563 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
564 AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
565 AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal")
566 AM_CONDITIONAL(BUILD_VIBNAL, test x$VIBNAL = "xvibnal")
567 AM_CONDITIONAL(BUILD_RANAL, test x$RANAL = "xranal")
568 ])
569
570 #
571 # LP_CONFIG_FILES
572 #
573 # files that should be generated with AC_OUTPUT
574 #
575 AC_DEFUN([LP_CONFIG_FILES],
576 [AC_CONFIG_FILES([
577 portals/Kernelenv
578 portals/Makefile
579 portals/autoMakefile
580 portals/autoconf/Makefile
581 portals/doc/Makefile
582 portals/include/Makefile
583 portals/include/libcfs/Makefile
584 portals/include/libcfs/linux/Makefile
585 portals/include/portals/Makefile
586 portals/include/portals/linux/Makefile
587 portals/knals/Makefile
588 portals/knals/autoMakefile
589 portals/knals/gmnal/Makefile
590 portals/knals/gmnal/autoMakefile
591 portals/knals/openibnal/Makefile
592 portals/knals/openibnal/autoMakefile
593 portals/knals/iibnal/Makefile
594 portals/knals/iibnal/autoMakefile
595 portals/knals/vibnal/Makefile
596 portals/knals/vibnal/autoMakefile
597 portals/knals/lonal/Makefile
598 portals/knals/lonal/autoMakefile
599 portals/knals/qswnal/Makefile
600 portals/knals/qswnal/autoMakefile
601 portals/knals/ranal/Makefile
602 portals/knals/ranal/autoMakefile
603 portals/knals/socknal/Makefile
604 portals/knals/socknal/autoMakefile
605 portals/libcfs/Makefile
606 portals/libcfs/autoMakefile
607 portals/libcfs/linux/Makefile
608 portals/portals/Makefile
609 portals/portals/autoMakefile
610 portals/router/Makefile
611 portals/router/autoMakefile
612 portals/tests/Makefile
613 portals/tests/autoMakefile
614 portals/unals/Makefile
615 portals/utils/Makefile
616 ])
617 case $lb_target_os in
618         darwin)
619                 AC_CONFIG_FILES([
620 portals/include/libcfs/darwin/Makefile
621 portals/include/portals/darwin/Makefile
622 portals/libcfs/darwin/Makefile
623 ])
624                 ;;
625 esac
626 ])