Whamcloud - gitweb
c72b2ff20ee7e9368a3ac5071c3860b54e97bb94
[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                 return 0;
181         ],[
182                 AC_MSG_RESULT([yes])
183                 OPENIBNAL="openibnal"
184         ],[
185                 AC_MSG_RESULT([no])
186                 case $ENABLEOPENIB in
187                 1) ;;
188                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
189                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
190                 *) AC_MSG_ERROR([internal error]);;
191                 esac
192                 OPENIBNAL=""
193                 OPENIBCPPFLAGS=""
194         ])
195         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
196 fi
197 AC_SUBST(OPENIBCPPFLAGS)
198 AC_SUBST(OPENIBNAL)
199 ])
200
201 #
202 # LP_CONFIG_IIB
203 #
204 # check for infinicon infiniband support
205 #
206 AC_DEFUN([LP_CONFIG_IIB],
207 [AC_MSG_CHECKING([if Infinicon IB kernel headers are present])
208 # for how the only infinicon ib build has headers in /usr/include/iba
209 IIBCPPFLAGS="-I/usr/include -DIN_TREE_BUILD"
210 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
211 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
212 LB_LINUX_TRY_COMPILE([
213         #include <linux/iba/ibt.h>
214 ],[
215         IBT_INTERFACE_UNION interfaces;
216         FSTATUS             rc;
217
218          rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
219                                        &interfaces);
220
221         return rc == FSUCCESS ? 0 : 1;
222 ],[
223         AC_MSG_RESULT([yes])
224         IIBNAL="iibnal"
225 ],[
226         AC_MSG_RESULT([no])
227         IIBNAL=""
228         IIBCPPFLAGS=""
229 ])
230 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
231 AC_SUBST(IIBCPPFLAGS)
232 AC_SUBST(IIBNAL)
233 ])
234
235 #
236 # LP_CONFIG_VIB
237 #
238 # check for Voltaire infiniband support
239 #
240 AC_DEFUN([LP_CONFIG_VIB],
241 [AC_MSG_CHECKING([if Voltaire IB kernel headers are present])
242 VIBCPPFLAGS="-I/usr/local/include/ibhost-kdevel -DCPU_BE=0 -DCPU_LE=1 -DGSI_PASS_PORT_NUM"
243 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
244 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
245 LB_LINUX_TRY_COMPILE([
246         #include <linux/list.h>
247         #include <vverbs.h>
248 ],[
249         vv_hca_h_t     kib_hca;
250         vv_return_t    retval;
251
252         retval = vv_hca_open("ANY_HCA", NULL, &kib_hca);
253
254         return retval == vv_return_ok ? 0 : 1;
255 ],[
256         AC_MSG_RESULT([yes])
257         VIBNAL="vibnal"
258 ],[
259         AC_MSG_RESULT([no])
260         VIBNAL=""
261         VIBCPPFLAGS=""
262 ])
263 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
264 AC_SUBST(VIBCPPFLAGS)
265 AC_SUBST(VIBNAL)
266 ])
267
268 #
269 # LP_CONFIG_RANAL
270 #
271 # check whether to use the RapidArray nal
272 #
273 AC_DEFUN([LP_CONFIG_RANAL],
274 [#### Rapid Array
275 AC_MSG_CHECKING([if RapidArray kernel headers are present])
276 # placeholder
277 RACPPFLAGS="-I/tmp"
278 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
279 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
280 LB_LINUX_TRY_COMPILE([
281         #include <linux/types.h>
282         #include <rapl.h>
283 ],[
284         RAP_RETURN          rc;
285         RAP_PVOID           dev_handle;
286
287         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
288
289         return rc == RAP_SUCCESS ? 0 : 1;
290 ],[
291         AC_MSG_RESULT([yes])
292         RANAL="ranal"
293 ],[
294         AC_MSG_RESULT([no])
295         RANAL=""
296         RACPPFLAGS=""
297 ])
298 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
299 AC_SUBST(RACPPFLAGS)
300 AC_SUBST(RANAL)
301 ])
302
303 #
304 # LP_STRUCT_PAGE_LIST
305 #
306 # 2.6.4 no longer has page->list
307 #
308 AC_DEFUN([LP_STRUCT_PAGE_LIST],
309 [AC_MSG_CHECKING([if struct page has a list field])
310 LB_LINUX_TRY_COMPILE([
311         #include <linux/mm.h>
312 ],[
313         struct page page;
314         &page.list;
315 ],[
316         AC_MSG_RESULT([yes])
317         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
318 ],[
319         AC_MSG_RESULT([no])
320 ])
321 ])
322
323 #
324 # LP_STRUCT_SIGHAND
325 #
326 # red hat 2.4 adds sighand to struct task_struct
327 #
328 AC_DEFUN([LP_STRUCT_SIGHAND],
329 [AC_MSG_CHECKING([if task_struct has a sighand field])
330 LB_LINUX_TRY_COMPILE([
331         #include <linux/sched.h>
332 ],[
333         struct task_struct p;
334         p.sighand = NULL;
335 ],[
336         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
337         AC_MSG_RESULT([yes])
338 ],[
339         AC_MSG_RESULT([no])
340 ])
341 ])
342
343 #
344 # LP_FUNC_CPU_ONLINE
345 #
346 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
347 #
348 AC_DEFUN([LP_FUNC_CPU_ONLINE],
349 [AC_MSG_CHECKING([if kernel defines cpu_online()])
350 LB_LINUX_TRY_COMPILE([
351         #include <linux/sched.h>
352 ],[
353         cpu_online(0);
354 ],[
355         AC_MSG_RESULT([yes])
356         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
357 ],[
358         AC_MSG_RESULT([no])
359 ])
360 ])
361
362 #
363 # LP_TYPE_CPUMASK_T
364 #
365 # same goes for cpumask_t
366 #
367 AC_DEFUN([LP_TYPE_CPUMASK_T],
368 [AC_MSG_CHECKING([if kernel defines cpumask_t])
369 LB_LINUX_TRY_COMPILE([
370         #include <linux/sched.h>
371 ],[
372         return sizeof (cpumask_t);
373 ],[
374         AC_MSG_RESULT([yes])
375         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
376 ],[
377         AC_MSG_RESULT([no])
378 ])
379 ])
380
381 #
382 # LP_FUNC_SHOW_TASK
383 #
384 # we export show_task(), but not all kernels have it (yet)
385 #
386 AC_DEFUN([LP_FUNC_SHOW_TASK],
387 [AC_MSG_CHECKING([if kernel exports show_task])
388 have_show_task=0
389 for file in ksyms sched ; do
390         if grep -q "EXPORT_SYMBOL(show_task)" \
391                  "$LINUX/kernel/$file.c" 2>/dev/null ; then
392                 have_show_task=1
393                 break
394         fi
395 done
396 if test x$have_show_task = x1 ; then
397         AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
398         AC_MSG_RESULT([yes])
399 else
400         AC_MSG_RESULT([no])
401 fi
402 ])
403
404 #
405 # LP_PROG_LINUX
406 #
407 # Portals linux kernel checks
408 #
409 AC_DEFUN([LP_PROG_LINUX],
410 [LP_CONFIG_ZEROCOPY
411 LP_CONFIG_AFFINITY
412 LP_CONFIG_QUADRICS
413 LP_CONFIG_GM
414 LP_CONFIG_OPENIB
415 LP_CONFIG_IIB
416 LP_CONFIG_VIB
417 LP_CONFIG_RANAL
418
419 LP_STRUCT_PAGE_LIST
420 LP_STRUCT_SIGHAND
421 LP_FUNC_CPU_ONLINE
422 LP_TYPE_CPUMASK_T
423 LP_FUNC_SHOW_TASK
424 ])
425
426 #
427 # LP_PATH_DEFAULTS
428 #
429 # default paths for installed files
430 #
431 AC_DEFUN([LP_PATH_DEFAULTS],
432 [
433 ])
434
435 #
436 # LP_CONFIGURE
437 #
438 # other configure checks
439 #
440 AC_DEFUN([LP_CONFIGURE],
441 [# portals/utils/portals.c
442 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h])
443 AC_CHECK_FUNCS([gethostbyname socket connect])
444
445 # portals/utils/debug.c
446 AC_CHECK_HEADERS([linux/version.h])
447
448 AC_CHECK_TYPE([spinlock_t],
449         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
450         [],
451         [#include <linux/spinlock.h>])
452
453 # --------  Check for required packages  --------------
454
455 # this doesn't seem to work on older autoconf
456 # AC_CHECK_LIB(readline, readline,,)
457 AC_MSG_CHECKING([for readline support])
458 AC_ARG_ENABLE(readline,
459         AC_HELP_STRING([--disable-readline],
460                         [do not use readline library]),
461         [],[enable_readline='yes'])
462 AC_MSG_RESULT([$enable_readline]) 
463 if test x$enable_readline = xyes ; then
464         LIBREADLINE="-lreadline -lncurses"
465         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
466 else 
467         LIBREADLINE=""
468 fi
469 AC_SUBST(LIBREADLINE)
470
471 AC_MSG_CHECKING([if efence debugging support is requested])
472 AC_ARG_ENABLE(efence,
473         AC_HELP_STRING([--enable-efence],
474                         [use efence library]),
475         [],[enable_efence='no'])
476 AC_MSG_RESULT([$enable_efence])
477 if test "$enable_efence" = "yes" ; then
478         LIBEFENCE="-lefence"
479         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
480 else 
481         LIBEFENCE=""
482 fi
483 AC_SUBST(LIBEFENCE)
484
485 # -------- enable acceptor libwrap (TCP wrappers) support? -------
486 AC_MSG_CHECKING([if libwrap support is requested])
487 AC_ARG_ENABLE([libwrap],
488         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
489         [case "${enableval}" in
490                 yes) enable_libwrap=yes ;;
491                 no) enable_libwrap=no ;;
492                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
493         esac],[enable_libwrap=no])
494 AC_MSG_RESULT([$enable_libwrap])
495 if test x$enable_libwrap = xyes ; then
496         LIBWRAP="-lwrap"
497         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
498 else
499         LIBWRAP=""
500 fi
501 AC_SUBST(LIBWRAP)
502
503 # ----------------------------------------
504 # some tests for catamount-like systems
505 # ----------------------------------------
506 AC_ARG_ENABLE([sysio_init],
507         AC_HELP_STRING([--disable-sysio-init],
508                 [call sysio init functions when initializing liblustre]),
509         [],[enable_sysio_init=yes])
510 AC_MSG_CHECKING([whether to initialize libsysio])
511 AC_MSG_RESULT([$enable_sysio_init])
512 if test x$enable_sysio_init != xno ; then
513         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
514 fi
515
516 AC_ARG_ENABLE([urandom],
517         AC_HELP_STRING([--disable-urandom],
518                 [disable use of /dev/urandom for liblustre]),
519         [],[enable_urandom=yes])
520 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
521 AC_MSG_RESULT([$enable_urandom])
522 if test x$enable_urandom != xno ; then
523         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
524 fi
525
526 # -------- check for -lcap and -lpthread ----
527 if test x$enable_liblustre = xyes ; then
528         AC_CHECK_LIB([cap], [cap_get_proc],
529                 [
530                         CAP_LIBS="-lcap"
531                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
532                 ],
533                 [CAP_LIBS=""])
534         AC_SUBST(CAP_LIBS)
535         AC_CHECK_LIB([pthread], [pthread_create],
536                 [
537                         PTHREAD_LIBS="-lpthread"
538                         AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
539                 ],
540                 [PTHREAD_LIBS=""])
541         AC_SUBST(PTHREAD_LIBS)
542 fi
543 ])
544
545 #
546 # LP_CONDITIONALS
547 #
548 # AM_CONDITOINAL defines for portals
549 #
550 AC_DEFUN([LP_CONDITIONALS],
551 [AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
552 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
553 AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
554 AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal")
555 AM_CONDITIONAL(BUILD_VIBNAL, test x$VIBNAL = "xvibnal")
556 AM_CONDITIONAL(BUILD_RANAL, test x$RANAL = "xranal")
557 ])
558
559 #
560 # LP_CONFIG_FILES
561 #
562 # files that should be generated with AC_OUTPUT
563 #
564 AC_DEFUN([LP_CONFIG_FILES],
565 [AC_CONFIG_FILES([
566 portals/Kernelenv
567 portals/Makefile
568 portals/autoMakefile
569 portals/autoconf/Makefile
570 portals/doc/Makefile
571 portals/include/Makefile
572 portals/include/linux/Makefile
573 portals/include/portals/Makefile
574 portals/knals/Makefile
575 portals/knals/autoMakefile
576 portals/knals/gmnal/Makefile
577 portals/knals/gmnal/autoMakefile
578 portals/knals/openibnal/Makefile
579 portals/knals/openibnal/autoMakefile
580 portals/knals/iibnal/Makefile
581 portals/knals/iibnal/autoMakefile
582 portals/knals/vibnal/Makefile
583 portals/knals/vibnal/autoMakefile
584 portals/knals/lonal/Makefile
585 portals/knals/lonal/autoMakefile
586 portals/knals/qswnal/Makefile
587 portals/knals/qswnal/autoMakefile
588 portals/knals/ranal/Makefile
589 portals/knals/ranal/autoMakefile
590 portals/knals/socknal/Makefile
591 portals/knals/socknal/autoMakefile
592 portals/libcfs/Makefile
593 portals/libcfs/autoMakefile
594 portals/portals/Makefile
595 portals/portals/autoMakefile
596 portals/router/Makefile
597 portals/router/autoMakefile
598 portals/tests/Makefile
599 portals/tests/autoMakefile
600 portals/unals/Makefile
601 portals/utils/Makefile
602 ])
603 ])