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