Whamcloud - gitweb
b=20744 use Novell supplied ofed-devel
[fs/lustre-release.git] / build / autoconf / lustre-build-linux.m4
1 #
2 # LB_LINUX_VERSION
3 #
4 # Set things accordingly for a 2.5 kernel
5 #
6 AC_DEFUN([LB_LINUX_VERSION],
7 [LB_CHECK_FILE([$LINUX/include/linux/namei.h],
8         [
9                 linux25="yes"
10                 KMODEXT=".ko"
11         ],[
12                 KMODEXT=".o"
13                 linux25="no"
14         ])
15 AC_MSG_CHECKING([if you are using Linux 2.6])
16 AC_MSG_RESULT([$linux25])
17
18 MODULE_TARGET="SUBDIRS"
19 if test $linux25 = "yes" ; then
20         makerule="$PWD/build"
21         AC_MSG_CHECKING([for external module build support])
22         rm -f build/conftest.i
23         LB_LINUX_TRY_MAKE([],[],
24                 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
25                 [test -s build/conftest.i],
26                 [
27                         AC_MSG_RESULT([no])
28                 ],[
29                         makerule="_module_$makerule"
30                         MODULE_TARGET="M"
31                         LB_LINUX_TRY_MAKE([],[],
32                                 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
33                                 [test -s build/conftest.i],
34                                 [
35                                         AC_MSG_RESULT([yes])
36                                 ],[
37                                         AC_MSG_ERROR([unknown; check config.log for details])
38                                 ])
39                 ])
40 else
41         makerule="_dir_$PWD/build"
42 fi
43
44 AC_SUBST(MODULE_TARGET)
45 AC_SUBST(linux25)
46 AC_SUBST(KMODEXT)
47 ])
48
49 #
50 # LB_LINUX_RELEASE
51 #
52 # get the release version of linux
53 #
54 AC_DEFUN([LB_LINUX_RELEASE],
55 [LINUXRELEASE=
56 rm -f build/conftest.i
57 AC_MSG_CHECKING([for Linux release])
58 if test -s $LINUX_OBJ/include/linux/utsrelease.h ; then
59         LINUXRELEASEHEADER=utsrelease.h
60 else
61         LINUXRELEASEHEADER=version.h
62 fi
63 LB_LINUX_TRY_MAKE([
64         #include <linux/$LINUXRELEASEHEADER>
65 ],[
66         char *LINUXRELEASE;
67         LINUXRELEASE=UTS_RELEASE;
68 ],[
69         $makerule LUSTRE_KERNEL_TEST=conftest.i
70 ],[
71         test -s build/conftest.i
72 ],[
73         # LINUXRELEASE="UTS_RELEASE"
74         eval $(grep "LINUXRELEASE=" build/conftest.i)
75 ],[
76         AC_MSG_RESULT([unknown])
77         AC_MSG_ERROR([Could not preprocess test program.  Consult config.log for details.])
78 ])
79 rm -f build/conftest.i
80 if test x$LINUXRELEASE = x ; then
81         AC_MSG_RESULT([unknown])
82         AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
83 fi
84 AC_MSG_RESULT([$LINUXRELEASE])
85 AC_SUBST(LINUXRELEASE)
86
87 moduledir='/lib/modules/'$LINUXRELEASE/updates/kernel
88 AC_SUBST(moduledir)
89
90 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
91 AC_SUBST(modulefsdir)
92
93 modulenetdir='$(moduledir)/net/$(PACKAGE)'
94 AC_SUBST(modulenetdir)
95
96 # ------------ RELEASE --------------------------------
97 AC_MSG_CHECKING([for Lustre release])
98 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
99 AC_MSG_RESULT($RELEASE)
100 AC_SUBST(RELEASE)
101
102 # check is redhat/suse kernels
103 AC_MSG_CHECKING([that RedHat kernel])
104 LB_LINUX_TRY_COMPILE([
105                 #include <linux/version.h>
106         ],[
107                 #ifndef RHEL_RELEASE_CODE
108                 #error "not redhat kernel"
109                 #endif
110         ],[
111                 RHEL_KENEL="yes"
112                 RHEL_KERNEL="yes"
113                 AC_MSG_RESULT([yes])
114         ],[
115                 AC_MSG_RESULT([no])
116 ])
117
118 LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
119
120 ])
121
122 # LB_ARG_REPLACE_PATH(PACKAGE, PATH)
123 AC_DEFUN([LB_ARG_REPLACE_PATH],[
124         new_configure_args=
125         eval "set x $ac_configure_args"
126         shift
127         for arg; do
128                 case $arg in
129                         --with-[$1]=*)
130                                 arg=--with-[$1]=[$2]
131                                 ;;
132                         *\'*)
133                                 arg=$(printf %s\n ["$arg"] | \
134                                       sed "s/'/'\\\\\\\\''/g")
135                                 ;;
136                 esac
137                 dnl AS_VAR_APPEND([new_configure_args], [" '$arg'"])
138                 new_configure_args="$new_configure_args \"$arg\""
139         done
140         ac_configure_args=$new_configure_args
141 ])
142
143 # this is the work-horse of the next function
144 AC_DEFUN([__LB_ARG_CANON_PATH], [
145         [$3]=$(readlink -f $with_$2)
146         LB_ARG_REPLACE_PATH([$1], $[$3])
147 ])
148
149 # a front-end for the above function that transforms - and . in the
150 # PACKAGE portion of --with-PACKAGE into _ suitable for variable names
151 AC_DEFUN([LB_ARG_CANON_PATH], [
152         __LB_ARG_CANON_PATH([$1], m4_translit([$1], [-.], [__]), [$2])
153 ])
154
155 #
156 #
157 # LB_LINUX_PATH
158 #
159 # Find paths for linux, handling kernel-source rpms
160 #
161 AC_DEFUN([LB_LINUX_PATH],
162 [AC_MSG_CHECKING([for Linux sources])
163 AC_ARG_WITH([linux],
164         AC_HELP_STRING([--with-linux=path],
165                        [set path to Linux source (default=/usr/src/linux)]),
166         [LB_ARG_CANON_PATH([linux], [LINUX])],
167         [LINUX=/usr/src/linux])
168 AC_MSG_RESULT([$LINUX])
169 AC_SUBST(LINUX)
170
171 # -------- check for linux --------
172 LB_CHECK_FILE([$LINUX],[],
173         [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
174
175 # -------- linux objects (for 2.6) --
176 AC_MSG_CHECKING([for Linux objects dir])
177 AC_ARG_WITH([linux-obj],
178         AC_HELP_STRING([--with-linux-obj=path],
179                         [set path to Linux objects dir (default=$LINUX)]),
180         [LB_ARG_CANON_PATH([linux-obj], [LINUX_OBJ])],
181         [LINUX_OBJ=$LINUX])
182 AC_MSG_RESULT([$LINUX_OBJ])
183 AC_SUBST(LINUX_OBJ)
184
185 # -------- check for .config --------
186 AC_ARG_WITH([linux-config],
187         [AC_HELP_STRING([--with-linux-config=path],
188                         [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
189         [LB_ARG_CANON_PATH([linux-config], [LINUX_CONFIG])],
190         [LINUX_CONFIG=$LINUX_OBJ/.config])
191 AC_SUBST(LINUX_CONFIG)
192
193 LB_CHECK_FILE([/boot/kernel.h],
194         [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
195         [LB_CHECK_FILE([/var/adm/running-kernel.h],
196                 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
197
198 AC_ARG_WITH([kernel-source-header],
199         AC_HELP_STRING([--with-kernel-source-header=path],
200                         [Use a different kernel version header.  Consult build/README.kernel-source for details.]),
201         [LB_ARG_CANON_PATH([kernel-source-header], [KERNEL_SOURCE_HEADER])])
202
203 # ------------ .config exists ----------------
204 LB_CHECK_FILE([$LINUX_CONFIG],[],
205         [AC_MSG_ERROR([Kernel config could not be found.  If you are building from a kernel-source rpm consult build/README.kernel-source])])
206
207 # ----------- make dep run? ------------------
208 # at 2.6.19 # $LINUX/include/linux/config.h is removed
209 # and at more old has only one line
210 # include <autoconf.h>
211 LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[],
212         [AC_MSG_ERROR([Run make config in $LINUX.])])
213 LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
214         [AC_MSG_ERROR([Run make config in $LINUX.])])
215
216 # ------------ rhconfig.h includes runtime-generated bits --
217 # red hat kernel-source checks
218
219 # we know this exists after the check above.  if the user
220 # tarred up the tree and ran make dep etc. in it, then
221 # version.h gets overwritten with a standard linux one.
222
223 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
224         # This is a clean kernel-source tree, we need to
225         # enable extensive workarounds to get this to build
226         # modules
227         LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
228                 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
229                         AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
230                         AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
231                         AC_MSG_WARN([Consult build/README.kernel-source for details.])
232                 fi],
233                 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found.  Consult build/README.kernel-source for details.])])
234         EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
235 fi
236
237 # this is needed before we can build modules
238 LB_LINUX_UML
239 LB_LINUX_VERSION
240
241 # --- check that we can build modules at all
242 AC_MSG_CHECKING([that modules can be built at all])
243 LB_LINUX_TRY_COMPILE([],[],[
244         AC_MSG_RESULT([yes])
245 ],[
246         AC_MSG_RESULT([no])
247         AC_MSG_WARN([Consult config.log for details.])
248         AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
249         AC_MSG_ERROR([Kernel modules cannot be built.])
250 ])
251
252 LB_LINUX_RELEASE
253 ]) # end of LB_LINUX_PATH
254
255 # LB_LINUX_SYMVERFILE
256 # SLES 9 uses a different name for this file - unsure about vanilla kernels
257 # around this version, but it matters for servers only.
258 AC_DEFUN([LB_LINUX_SYMVERFILE],
259         [AC_MSG_CHECKING([name of module symbol version file])
260         if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost ; then
261                 SYMVERFILE=Modules.symvers
262         else
263                 SYMVERFILE=Module.symvers
264         fi
265         AC_MSG_RESULT($SYMVERFILE)
266         AC_SUBST(SYMVERFILE)
267 ])
268
269 #
270 #
271 # LB_LINUX_MODPOST
272 #
273 # Find modpost and check it
274 #
275 AC_DEFUN([LB_LINUX_MODPOST],
276 [
277 # Find the modpost utility
278 LB_CHECK_FILE([$LINUX_OBJ/scripts/mod/modpost],
279         [MODPOST=$LINUX_OBJ/scripts/mod/modpost],
280         [LB_CHECK_FILE([$LINUX_OBJ/scripts/modpost],
281                 [MODPOST=$LINUX_OBJ/scripts/modpost],
282                 AC_MSG_ERROR([modpost not found.])
283         )]
284 )
285 AC_SUBST(MODPOST)
286
287 # Ensure it can run
288 AC_MSG_CHECKING([if modpost can be run])
289 if $MODPOST ; then
290         AC_MSG_RESULT([yes])
291 else
292         AC_MSG_ERROR([modpost can not be run.])
293 fi
294
295 # Check if modpost supports (and therefore requires) -m
296 AC_MSG_CHECKING([if modpost supports -m])
297 if $MODPOST -m 2>/dev/null ; then
298         AC_MSG_RESULT([yes])
299         MODPOST_ARGS=-m
300 else
301         AC_MSG_RESULT([no])
302         MODPOST_ARGS=""
303 fi
304 AC_SUBST(MODPOST_ARGS)
305 ])
306
307 #
308 # LB_LINUX_UML
309 #
310 # check for a uml kernel
311 #
312 AC_DEFUN([LB_LINUX_UML],
313 [ARCH_UM=
314 UML_CFLAGS=
315
316 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
317 if test -e $LINUX/include/asm-um ; then
318         if test  X`ls -id $LINUX/include/asm/ 2>/dev/null | awk '{print [$]1}'` = X`ls -id $LINUX/include/asm-um 2>/dev/null | awk '{print [$]1}'` ; then
319                 ARCH_UM='ARCH=um'
320                 # see notes in Rules.in
321                 UML_CFLAGS='-O0'
322                 AC_MSG_RESULT(yes)
323         else
324                 AC_MSG_RESULT([no])
325         fi
326 else
327         AC_MSG_RESULT([no (asm-um missing)])
328 fi
329 AC_SUBST(ARCH_UM)
330 AC_SUBST(UML_CFLAGS)
331 ])
332
333 # these are like AC_TRY_COMPILE, but try to build modules against the
334 # kernel, inside the build directory
335
336 # LB_LANG_PROGRAM(C)([PROLOGUE], [BODY])
337 # --------------------------------------
338 m4_define([LB_LANG_PROGRAM],
339 [$1
340 int
341 main (void)
342 {
343 dnl Do *not* indent the following line: there may be CPP directives.
344 dnl Don't move the `;' right after for the same reason.
345 $2
346   ;
347   return 0;
348 }])
349
350 #
351 # LB_LINUX_COMPILE_IFELSE
352 #
353 # like AC_COMPILE_IFELSE
354 #
355 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
356 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
357 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
358 AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/arch/`uname -m|sed -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
359         [$4],
360         [_AC_MSG_LOG_CONFTEST
361 m4_ifvaln([$5],[$5])dnl])
362 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl
363 ])
364
365 #
366 # LB_LINUX_ARCH
367 #
368 # Determine the kernel's idea of the current architecture
369 #
370 AC_DEFUN([LB_LINUX_ARCH],
371          [AC_MSG_CHECKING([Linux kernel architecture])
372           AS_IF([rm -f $PWD/build/arch
373                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
374                      LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
375                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
376                 [AC_MSG_RESULT([$LINUX_ARCH])],
377                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
378           rm -f build/arch])
379
380 #
381 # LB_LINUX_TRY_COMPILE
382 #
383 # like AC_TRY_COMPILE
384 #
385 AC_DEFUN([LB_LINUX_TRY_COMPILE],
386 [LB_LINUX_COMPILE_IFELSE(
387         [AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])],
388         [modules],
389         [test -s build/conftest.o],
390         [$3], [$4])])
391
392 #
393 # LB_LINUX_CONFIG
394 #
395 # check if a given config option is defined
396 #
397 AC_DEFUN([LB_LINUX_CONFIG],
398 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
399 LB_LINUX_TRY_COMPILE([
400 #include <linux/autoconf.h>
401 ],[
402 #ifndef CONFIG_$1
403 #error CONFIG_$1 not #defined
404 #endif
405 ],[
406 AC_MSG_RESULT([yes])
407 $2
408 ],[
409 AC_MSG_RESULT([no])
410 $3
411 ])
412 ])
413
414 #
415 # LB_LINUX_CONFIG_IM
416 #
417 # check if a given config option is builtin or as module
418 #
419 AC_DEFUN([LB_LINUX_CONFIG_IM],
420 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1 in or as module])
421 LB_LINUX_TRY_COMPILE([
422 #include <linux/autoconf.h>
423 ],[
424 #if !(defined(CONFIG_$1) || defined(CONFIG_$1_MODULE))
425 #error CONFIG_$1 and CONFIG_$1_MODULE not #defined
426 #endif
427 ],[
428 AC_MSG_RESULT([yes])
429 $2
430 ],[
431 AC_MSG_RESULT([no])
432 $3
433 ])
434 ])
435
436 #
437 # LB_LINUX_TRY_MAKE
438 #
439 # like LB_LINUX_TRY_COMPILE, but with different arguments
440 #
441 AC_DEFUN([LB_LINUX_TRY_MAKE],
442 [LB_LINUX_COMPILE_IFELSE([AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])], [$3], [$4], [$5], [$6])])
443
444 #
445 # LB_LINUX_CONFIG_BIG_STACK
446 #
447 # check for big stack patch
448 #
449 AC_DEFUN([LB_LINUX_CONFIG_BIG_STACK],
450 [if test "x$ARCH_UM" = "x" -a "x$linux25" = "xno" ; then
451         case $target_cpu in
452                 i?86 | x86_64)
453                         LB_LINUX_CONFIG([STACK_SIZE_16KB],[],[
454                                 LB_LINUX_CONFIG([STACK_SIZE_32KB],[],[
455                                         LB_LINUX_CONFIG([STACK_SIZE_64KB],[],[
456                                                 AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 16KB stack.])
457                                         ])
458                                 ])
459                         ])
460                         ;;
461         esac
462 fi
463 ])
464
465 #
466 # LB_CONFIG_OFED_BACKPORTS
467 #
468 # include any OFED backport headers in all compile commands
469 # NOTE: this does only include the backport paths, not the OFED headers
470 #       adding the OFED headers is done in the lnet portion
471 AC_DEFUN([LB_CONFIG_OFED_BACKPORTS],
472 [AC_MSG_CHECKING([whether to use any OFED backport headers])
473 # set default
474 AC_ARG_WITH([o2ib],
475         AC_HELP_STRING([--with-o2ib=path],
476                        [build o2iblnd against path]),
477         [
478                 case $with_o2ib in
479                 yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
480                         ENABLEO2IB=2
481                         ;;
482                 no)     ENABLEO2IB=0
483                         ;;
484                 *)      O2IBPATHS=$with_o2ib
485                         ENABLEO2IB=3
486                         ;;
487                 esac
488         ],[
489                 O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
490                 ENABLEO2IB=1
491         ])
492 if test $ENABLEO2IB -eq 0; then
493         AC_MSG_RESULT([no])
494 else
495         o2ib_found=false
496         for O2IBPATH in $O2IBPATHS; do
497                 if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
498                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
499                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
500                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
501                         o2ib_found=true
502                         break
503                 fi
504         done
505         if ! $o2ib_found; then
506                 AC_MSG_RESULT([no])
507                 case $ENABLEO2IB in
508                         1) ;;
509                         2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
510                         3) AC_MSG_ERROR([bad --with-o2ib path]);;
511                         *) AC_MSG_ERROR([internal error]);;
512                 esac
513         else
514                 if test -f $O2IBPATH/config.mk; then
515                         . $O2IBPATH/config.mk
516                 elif test -f $O2IBPATH/ofed_patch.mk; then
517                         . $O2IBPATH/ofed_patch.mk
518                 fi
519                 if test -n "$BACKPORT_INCLUDES"; then
520                         OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
521                         EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
522                         AC_MSG_RESULT([yes])
523                 else
524                         AC_MSG_RESULT([no])
525                 fi
526         fi
527 fi
528 ])
529
530 # LC_MODULE_LOADING
531 # after 2.6.28 CONFIG_KMOD is removed, and only CONFIG_MODULES remains
532 # so we test if request_module is implemented or not
533 AC_DEFUN([LC_MODULE_LOADING],
534 [AC_MSG_CHECKING([if kernel module loading is possible])
535 LB_LINUX_TRY_MAKE([
536         #include <linux/kmod.h>
537 ],[
538         int myretval=ENOSYS ;
539         return myretval;
540 ],[
541         $makerule LUSTRE_KERNEL_TEST=conftest.i
542 ],[
543         grep request_module build/conftest.i | grep -v `grep "int myretval=" build/conftest.i | cut -d= -f2 | cut -d" "  -f1` >/dev/null
544 ],[
545         AC_MSG_RESULT(yes)
546         AC_DEFINE(HAVE_MODULE_LOADING_SUPPORT, 1,
547                 [kernel module loading is possible])
548 ],[
549         AC_MSG_RESULT(no)
550         AC_MSG_WARN([])
551         AC_MSG_WARN([Kernel module loading support is highly recommended.])
552         AC_MSG_WARN([])
553 ])
554 ])
555
556 # LC_MODULE_LOADING
557 # after 2.6.28 CONFIG_KMOD is removed, and only CONFIG_MODULES remains
558 # so we test if request_module is implemented or not
559 AC_DEFUN([LC_MODULE_LOADING],
560 [AC_MSG_CHECKING([if kernel module loading is possible])
561 LB_LINUX_TRY_MAKE([
562         #include <linux/kmod.h>
563 ],[
564         int myretval=ENOSYS ;
565         return myretval;
566 ],[
567         $makerule LUSTRE_KERNEL_TEST=conftest.i
568 ],[
569         grep request_module build/conftest.i | grep -v `grep "int myretval=" build/conftest.i | cut -d= -f2 | cut -d" "  -f1` >/dev/null
570 ],[
571         AC_MSG_RESULT(yes)
572         AC_DEFINE(HAVE_MODULE_LOADING_SUPPORT, 1,
573                 [kernel module loading is possible])
574 ],[
575         AC_MSG_RESULT(no)
576         AC_MSG_WARN([])
577         AC_MSG_WARN([Kernel module loading support is highly recommended.])
578         AC_MSG_WARN([])
579 ])
580 ])
581
582 #
583 # LB_PROG_LINUX
584 #
585 # linux tests
586 #
587 AC_DEFUN([LB_PROG_LINUX],
588 [LB_LINUX_PATH
589 LB_LINUX_ARCH
590 LB_LINUX_SYMVERFILE
591
592
593 LB_LINUX_CONFIG([MODULES],[],[
594         AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
595 ])
596
597 LB_LINUX_CONFIG([MODVERSIONS])
598
599 LB_LINUX_CONFIG([KALLSYMS],[],[
600 if test "x$ARCH_UM" = "x" ; then
601         AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
602 fi
603 ])
604
605 # 2.6.28
606 LC_MODULE_LOADING
607
608 #LB_LINUX_CONFIG_BIG_STACK
609
610 # it's ugly to be doing anything with OFED outside of the lnet module, but
611 # this has to be done here so that the backports path is set before all of
612 # the LN_PROG_LINUX checks are done
613 LB_CONFIG_OFED_BACKPORTS
614 ])
615
616 #
617 # LB_LINUX_CONDITIONALS
618 #
619 # AM_CONDITIONALS for linux
620 #
621 AC_DEFUN([LB_LINUX_CONDITIONALS],
622 [AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
623 ])
624
625
626 #
627 # LB_CHECK_SYMBOL_EXPORT
628 # check symbol exported or not
629 # $1 - symbol
630 # $2 - file(s) for find.
631 # $3 - do 'yes'
632 # $4 - do 'no'
633 #
634 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
635 # or check
636 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
637 [AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
638 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/$SYMVERFILE 2>/dev/null
639 rc=$?
640 if test $rc -ne 0; then
641     export=0
642     for file in $2; do
643         grep -q -E "EXPORT_SYMBOL.*\($1\)" "$LINUX/$file" 2>/dev/null
644         rc=$?
645         if test $rc -eq 0; then
646                 export=1
647                 break;
648         fi
649     done
650     if test $export -eq 0; then
651         AC_MSG_RESULT([no])
652         $4
653     else
654         AC_MSG_RESULT([yes])
655         $3
656     fi
657 else
658     AC_MSG_RESULT([yes])
659     $3
660 fi
661 ])
662
663 #
664 # Like AC_CHECK_HEADER but checks for a kernel-space header
665 #
666 m4_define([LB_CHECK_LINUX_HEADER],
667 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
668 AC_CACHE_CHECK([for $1], ac_Header,
669                [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
670                                   [modules],
671                                   [test -s build/conftest.o],
672                                   [AS_VAR_SET(ac_Header, [yes])],
673                                   [AS_VAR_SET(ac_Header, [no])])])
674 AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
675 AS_VAR_POPDEF([ac_Header])dnl
676 ])