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