Whamcloud - gitweb
LU-3953 build: configure output improvments
[fs/lustre-release.git] / config / lustre-build-linux.m4
1 #
2 # LB_LINUX_VERSION
3 #
4 # Set things accordingly for a linux kernel
5 #
6 AC_DEFUN([LB_LINUX_VERSION],[
7 KMODEXT=".ko"
8
9 MODULE_TARGET="SUBDIRS"
10 makerule="$PWD/build"
11 AC_MSG_CHECKING([for external module build support])
12 rm -f build/conftest.i
13 LB_LINUX_TRY_MAKE([],[],
14         [$makerule LUSTRE_KERNEL_TEST=conftest.i],
15         [test -s build/conftest.i],
16         [
17                 AC_MSG_RESULT([no])
18         ],[
19                 makerule="_module_$makerule"
20                 MODULE_TARGET="M"
21                 LB_LINUX_TRY_MAKE([],[],
22                         [$makerule LUSTRE_KERNEL_TEST=conftest.i],
23                         [test -s build/conftest.i],
24                         [
25                                 AC_MSG_RESULT([yes])
26                         ],[
27                                 AC_MSG_ERROR([unknown; check config.log for details])
28                         ])
29         ])
30
31 AC_SUBST(MODULE_TARGET)
32 AC_SUBST(KMODEXT)
33 ])
34
35 #
36 # LB_LINUX_UTSRELEASE
37 #
38 # Determine the Linux kernel version string from the utsrelease
39 #
40 AC_DEFUN([LB_LINUX_UTSRELEASE], [
41         AC_MSG_CHECKING([kernel source version])
42
43         utsrelease1=${LINUX_OBJ}/include/generated/utsrelease.h
44         utsrelease2=${LINUX_OBJ}/include/linux/utsrelease.h
45         utsrelease3=${LINUX_OBJ}/include/linux/version.h
46         AS_IF([test -r ${utsrelease1} && fgrep -q UTS_RELEASE ${utsrelease1}], [
47                 utsrelease=${utsrelease1}
48         ], [test -r ${utsrelease2} && fgrep -q UTS_RELEASE ${utsrelease2}], [
49                 utsrelease=${utsrelease2}
50         ], [test -r ${utsrelease3} && fgrep -q UTS_RELEASE ${utsrelease3}], [
51                 utsrelease=${utsrelease3}
52         ])
53
54         AS_IF([test ! -z "${utsrelease}"], [
55                 UTS_RELEASE=$(awk -F \" '/ UTS_RELEASE / { print [$]2 }' \
56                               ${utsrelease})
57                 AS_IF([test -z "$UTS_RELEASE"], [
58                         AC_MSG_RESULT([Not found])
59                         AC_MSG_ERROR([Cannot determine kernel version.])
60                 ])
61         ], [
62                 AC_MSG_RESULT([Not found])
63                 AC_MSG_ERROR([
64
65 Cannot find UTS_RELEASE definition.
66
67 This is often provided by the kernel-devel package.
68 ])
69         ])
70
71         AC_MSG_RESULT([${UTS_RELEASE}])
72
73         LINUX_VERSION=${UTS_RELEASE}
74         AC_SUBST(LINUX_VERSION)
75         LINUXRELEASE=${UTS_RELEASE}
76         AC_SUBST(LINUXRELEASE)
77 ])
78
79
80 #
81 # LB_LINUX_RELEASE
82 #
83 # get the release version of linux
84 #
85 AC_DEFUN([LB_LINUX_RELEASE],
86 [
87 LB_LINUX_UTSRELEASE
88
89 # ------------ RELEASE --------------------------------
90 AC_MSG_CHECKING([for Lustre release])
91 AC_ARG_WITH([release],
92         AC_HELP_STRING([--with-release=string],
93                        [set the release string (default=$kvers_YYYYMMDDhhmm)]),
94         [RELEASE=$withval],[
95         RELEASE=""
96         if test -n "$DOWNSTREAM_RELEASE"; then
97                 RELEASE="${DOWNSTREAM_RELEASE}_"
98         fi
99         RELEASE="$RELEASE`echo ${LINUXRELEASE} | tr '-' '_'`_$BUILDID"])
100 AC_MSG_RESULT($RELEASE)
101 AC_SUBST(RELEASE)
102
103 # check if the kernel is one from RHEL or SUSE
104 AC_MSG_CHECKING([for RedHat kernel version])
105         AS_IF([fgrep -q RHEL_RELEASE ${LINUX_OBJ}/include/$VERSION_HDIR/version.h], [
106                 RHEL_KERNEL="yes"
107                 RHEL_RELEASE=$(expr 0$(awk -F \" '/ RHEL_RELEASE / { print [$]2 }' \
108                                ${LINUX_OBJ}/include/$VERSION_HDIR/version.h) + 1)
109                 KERNEL_VERSION=$(sed -e 's/\(@<:@23@:>@\.@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/' <<< ${LINUXRELEASE})
110                 RHEL_KERNEL_VERSION=${KERNEL_VERSION}-${RHEL_RELEASE}
111                 AC_SUBST(RHEL_KERNEL_VERSION)
112                 AC_MSG_RESULT([${RHEL_KERNEL_VERSION}])
113         ], [
114                 AC_MSG_RESULT([not found])
115                 LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
116         ])
117
118 AC_MSG_CHECKING([for kernel module package directory])
119 AC_ARG_WITH([kmp-moddir],
120         AC_HELP_STRING([--with-kmp-moddir=string],
121                        [set the kmod updates or extra directory]),
122         [KMP_MODDIR=$withval],[
123         AS_IF([test x$RHEL_KERNEL = xyes], [KMP_MODDIR="extra"],
124               [test x$SUSE_KERNEL = xyes], [KMP_MODDIR="updates"])])
125
126 AC_MSG_RESULT($KMP_MODDIR)
127 AC_SUBST(KMP_MODDIR)
128
129 moduledir='$(CROSS_PATH)/lib/modules/$(LINUXRELEASE)/$(KMP_MODDIR)/kernel'
130 AC_SUBST(moduledir)
131
132 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
133 AC_SUBST(modulefsdir)
134
135 modulenetdir='$(moduledir)/net/$(PACKAGE)'
136 AC_SUBST(modulenetdir)
137
138 ])
139
140 # LB_ARG_REPLACE_PATH(PACKAGE, PATH)
141 AC_DEFUN([LB_ARG_REPLACE_PATH],[
142         new_configure_args=
143         eval "set x $ac_configure_args"
144         shift
145         for arg; do
146                 case $arg in
147                         --with-[$1]=*)
148                                 arg=--with-[$1]=[$2]
149                                 ;;
150                         *\'*)
151                                 arg=$(printf %s\n ["$arg"] | \
152                                       sed "s/'/'\\\\\\\\''/g")
153                                 ;;
154                 esac
155                 dnl AS_VAR_APPEND([new_configure_args], [" '$arg'"])
156                 new_configure_args="$new_configure_args \"$arg\""
157         done
158         ac_configure_args=$new_configure_args
159 ])
160
161 # this is the work-horse of the next function
162 AC_DEFUN([__LB_ARG_CANON_PATH], [
163         [$3]=$(readlink -f $with_$2)
164         LB_ARG_REPLACE_PATH([$1], $[$3])
165 ])
166
167 # a front-end for the above function that transforms - and . in the
168 # PACKAGE portion of --with-PACKAGE into _ suitable for variable names
169 AC_DEFUN([LB_ARG_CANON_PATH], [
170         __LB_ARG_CANON_PATH([$1], m4_translit([$1], [-.], [__]), [$2])
171 ])
172
173 #
174 #
175 # LB_LINUX_PATH
176 #
177 # Find paths for linux, handling kernel-source rpms
178 #
179 AC_DEFUN([LB_LINUX_PATH],
180 [# prep some default values
181 for DEFAULT_LINUX in /lib/modules/$(uname -r)/{source,build} /usr/src/linux; do
182         if readlink -q -e $DEFAULT_LINUX; then
183                 break
184         fi
185 done
186 if test "$DEFAULT_LINUX" = "/lib/modules/$(uname -r)/source"; then
187         PATHS="/lib/modules/$(uname -r)/build"
188 fi
189 PATHS+=" $DEFAULT_LINUX"
190 for DEFAULT_LINUX_OBJ in $PATHS; do
191         if readlink -q -e $DEFAULT_LINUX_OBJ; then
192                 break
193         fi
194 done
195 AC_MSG_CHECKING([for Linux sources])
196 AC_ARG_WITH([linux],
197         AC_HELP_STRING([--with-linux=path],
198                        [set path to Linux source (default=/lib/modules/$(uname -r)/{source,build},/usr/src/linux)]),
199         [LB_ARG_CANON_PATH([linux], [LINUX])
200         DEFAULT_LINUX_OBJ=$LINUX],
201         [LINUX=$DEFAULT_LINUX])
202 AC_MSG_RESULT([$LINUX])
203 AC_SUBST(LINUX)
204
205 # -------- check for linux --------
206 LB_CHECK_FILE([$LINUX],[],
207         [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
208
209 # -------- linux objects (for 2.6) --
210 AC_MSG_CHECKING([for Linux objects dir])
211 AC_ARG_WITH([linux-obj],
212         AC_HELP_STRING([--with-linux-obj=path],
213                         [set path to Linux objects dir (default=/lib/modules/$(uname -r)/build,/usr/src/linux)]),
214         [LB_ARG_CANON_PATH([linux-obj], [LINUX_OBJ])],
215         [LINUX_OBJ=$DEFAULT_LINUX_OBJ])
216
217 AC_MSG_RESULT([$LINUX_OBJ])
218 AC_SUBST(LINUX_OBJ)
219
220 # -------- check for .config --------
221 AC_ARG_WITH([linux-config],
222         [AC_HELP_STRING([--with-linux-config=path],
223                         [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
224         [LB_ARG_CANON_PATH([linux-config], [LINUX_CONFIG])],
225         [LINUX_CONFIG=$LINUX_OBJ/.config])
226 AC_SUBST(LINUX_CONFIG)
227
228 LB_CHECK_FILE([/boot/kernel.h],
229         [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
230         [LB_CHECK_FILE([/var/adm/running-kernel.h],
231                 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
232
233 AC_ARG_WITH([kernel-source-header],
234         AC_HELP_STRING([--with-kernel-source-header=path],
235                         [Use a different kernel version header.  Consult build/README.kernel-source for details.]),
236         [LB_ARG_CANON_PATH([kernel-source-header], [KERNEL_SOURCE_HEADER])])
237
238 # ------------ .config exists ----------------
239 LB_CHECK_FILE([$LINUX_CONFIG],[],
240         [AC_MSG_ERROR([
241
242 Kernel config could not be found.
243
244 If you are building from a kernel-source rpm consult build/README.kernel-source
245 ])
246 ])
247
248 # ----------- make dep run? ------------------
249 # at 2.6.19 # $LINUX/include/linux/config.h is removed
250 # and at more old has only one line
251 # include <autoconf.h>
252 LB_CHECK_FILE([$LINUX_OBJ/include/generated/autoconf.h],[AUTOCONF_HDIR=generated],
253         [LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[AUTOCONF_HDIR=linux],
254         [AC_MSG_ERROR([Run make config in $LINUX.])])])
255         AC_SUBST(AUTOCONF_HDIR)
256 LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h], [VERSION_HDIR=linux],
257         [LB_CHECK_FILE([$LINUX_OBJ/include/generated/uapi/linux/version.h],
258                 [VERSION_HDIR=generated/uapi/linux],
259                 [AC_MSG_ERROR([Run make config in $LINUX.])])
260         ])
261         AC_SUBST(VERSION_HDIR)
262
263 # ----------- kconfig.h exists ---------------
264 # kernel 3.1, $LINUX/include/linux/kconfig.h is added
265 # see kernel commit 2a11c8ea20bf850b3a2c60db8c2e7497d28aba99
266 LB_CHECK_FILE([$LINUX_OBJ/include/linux/kconfig.h],
267               [CONFIG_INCLUDE=include/linux/kconfig.h],
268               [CONFIG_INCLUDE=include/$AUTOCONF_HDIR/autoconf.h])
269         AC_SUBST(CONFIG_INCLUDE)
270
271 # ------------ rhconfig.h includes runtime-generated bits --
272 # red hat kernel-source checks
273
274 # we know this exists after the check above.  if the user
275 # tarred up the tree and ran make dep etc. in it, then
276 # version.h gets overwritten with a standard linux one.
277
278 if grep rhconfig $LINUX_OBJ/include/$VERSION_HDIR/version.h >/dev/null ; then
279         # This is a clean kernel-source tree, we need to
280         # enable extensive workarounds to get this to build
281         # modules
282         LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
283                 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
284                         AC_MSG_WARN([
285
286 Using /boot/kernel.h from RUNNING kernel.
287
288 If this is not what you want, use --with-kernel-source-header.
289 Consult build/README.kernel-source for details.
290 ])
291                 fi],
292                 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found.  Consult build/README.kernel-source for details.])])
293         EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
294 fi
295
296 # this is needed before we can build modules
297 LB_LINUX_CROSS
298 LB_LINUX_VERSION
299
300 # --- check that we can build modules at all
301 AC_MSG_CHECKING([that modules can be built at all])
302 LB_LINUX_TRY_COMPILE([],[],[
303         AC_MSG_RESULT([yes])
304 ],[
305         AC_MSG_RESULT([no])
306         AC_MSG_ERROR([
307
308 Kernel modules cannot be built. Consult config.log for details.
309
310 If you are trying to build with a kernel-source rpm,
311 consult build/README.kernel-source
312 ])
313 ])
314
315 LB_LINUX_RELEASE
316 ]) # end of LB_LINUX_PATH
317
318 # LB_LINUX_SYMVERFILE
319 # SLES 9 uses a different name for this file - unsure about vanilla kernels
320 # around this version, but it matters for servers only.
321 AC_DEFUN([LB_LINUX_SYMVERFILE],
322         [AC_MSG_CHECKING([name of module symbol version file])
323         if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost ; then
324                 SYMVERFILE=Modules.symvers
325         else
326                 SYMVERFILE=Module.symvers
327         fi
328         AC_MSG_RESULT($SYMVERFILE)
329         AC_SUBST(SYMVERFILE)
330 ])
331
332 #
333 # LB_LINUX_CROSS
334 #
335 # check for cross compilation
336 #
337 AC_DEFUN([LB_LINUX_CROSS],
338         [AC_MSG_CHECKING([for cross compilation])
339 AS_IF([test "x$cross_compiling" = xno], [AC_MSG_RESULT([no])],
340         [case $host_vendor in
341                 # The K1OM architecture is an extension of the x86 architecture
342                 # and in MPSS 2.1 it's defined in $host_vendor. But in MPSS 3.x
343                 # it's defined in $host_arch. So, try to support both case.
344                 k1om | mpss)
345                         AC_MSG_RESULT([Intel(R) Xeon Phi(TM)])
346                         CC_TARGET_ARCH=`$CC -v 2>&1 | grep Target: | sed -e 's/Target: //'`
347                         AC_SUBST(CC_TARGET_ARCH)
348                         if test \( $CC_TARGET_ARCH != x86_64-k1om-linux \
349                                 -a $CC_TARGET_ARCH != k1om-mpss-linux \)
350                         then
351                                 AC_MSG_ERROR([Cross compiler not found in PATH.])
352                         fi
353                         CROSS_VARS="ARCH=k1om CROSS_COMPILE=${CC_TARGET_ARCH}-"
354                         CROSS_PATH="${CROSS_PATH:=/opt/lustre/${VERSION}/${CC_TARGET_ARCH}}"
355                         CCAS=$CC
356                         # need to produce special section for debuginfo extraction
357                         LDFLAGS="${LDFLAGS} -Wl,--build-id"
358                         EXTRA_KLDFLAGS="${EXTRA_KLDFLAGS} -Wl,--build-id"
359                         if test x$enable_server != xno ; then
360                                 AC_MSG_WARN([Disabling server (not supported for k1om architecture).])
361                                 enable_server='no'
362                         fi
363                         ;;
364                 *)
365                         AC_MSG_RESULT([yes, but no changes])
366                         ;;
367         esac
368         ])
369 AC_SUBST(CROSS_VARS)
370 AC_SUBST(CROSS_PATH)
371 ])
372
373 # these are like AC_TRY_COMPILE, but try to build modules against the
374 # kernel, inside the build directory
375
376 # LB_LANG_PROGRAM(C)([PROLOGUE], [BODY])
377 # --------------------------------------
378 m4_define([LB_LANG_PROGRAM],
379 [
380 #include <linux/kernel.h>
381 $1
382 int
383 main (void)
384 {
385 dnl Do *not* indent the following line: there may be CPP directives.
386 dnl Don't move the `;' right after for the same reason.
387 $2
388   ;
389   return 0;
390 }])
391
392 #
393 # LB_LINUX_COMPILE_IFELSE
394 #
395 # like AC_COMPILE_IFELSE
396 #
397 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
398 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
399 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
400 SUBARCH=$(echo $target_cpu | sed -e 's/powerpc64/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/' -e 's/k1om/x86/')
401 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_OFED_INCLUDE -I$LINUX/arch/$SUBARCH/include -I$LINUX/arch/$SUBARCH/include/generated -Iinclude -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -I$LINUX/include/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi ${SPL_OBJ:+-include $SPL_OBJ/spl_config.h} ${ZFS_OBJ:+-include $ZFS_OBJ/zfs_config.h} ${SPL:+-I$SPL -I$SPL/include } ${ZFS:+-I$ZFS -I$ZFS/include} -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $CROSS_VARS $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
402         [$4],
403         [_AC_MSG_LOG_CONFTEST
404 m4_ifvaln([$5],[$5])dnl])
405 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
406 ])
407
408 #
409 # LB_LINUX_ARCH
410 #
411 # Determine the kernel's idea of the current architecture
412 #
413 AC_DEFUN([LB_LINUX_ARCH],
414          [AC_MSG_CHECKING([Linux kernel architecture])
415           AS_IF([rm -f $PWD/build/arch
416                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
417                      LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $CROSS_VARS  \
418                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
419                 [AC_MSG_RESULT([$LINUX_ARCH])],
420                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
421           rm -f build/arch])
422
423 #
424 # LB_LINUX_TRY_COMPILE
425 #
426 # like AC_TRY_COMPILE
427 #
428 AC_DEFUN([LB_LINUX_TRY_COMPILE],
429 [LB_LINUX_COMPILE_IFELSE(
430         [AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])],
431         [modules],
432         [test -s build/conftest.o],
433         [$3], [$4])])
434
435 #
436 # LB_LINUX_CONFIG
437 #
438 # check if a given config option is defined
439 #
440 AC_DEFUN([LB_LINUX_CONFIG],[
441         AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
442         LB_LINUX_TRY_COMPILE([
443                 #include <$AUTOCONF_HDIR/autoconf.h>
444         ],[
445                 #ifndef CONFIG_$1
446                 #error CONFIG_$1 not #defined
447                 #endif
448         ],[
449                 AC_MSG_RESULT([yes])
450                 $2
451         ],[
452                 AC_MSG_RESULT([no])
453                 $3
454         ])
455 ])
456
457 #
458 # LB_LINUX_CONFIG_IM
459 #
460 # check if a given config option is builtin or as module
461 #
462 AC_DEFUN([LB_LINUX_CONFIG_IM],[
463         AC_MSG_CHECKING([if Linux was built with CONFIG_$1 in or as module])
464         LB_LINUX_TRY_COMPILE([
465                 #include <$AUTOCONF_HDIR/autoconf.h>
466         ],[
467                 #if !(defined(CONFIG_$1) || defined(CONFIG_$1_MODULE))
468                 #error CONFIG_$1 and CONFIG_$1_MODULE not #defined
469                 #endif
470         ],[
471                 AC_MSG_RESULT([yes])
472                 $2
473         ],[
474                 AC_MSG_RESULT([no])
475                 $3
476         ])
477 ])
478
479 #
480 # LB_LINUX_TRY_MAKE
481 #
482 # like LB_LINUX_TRY_COMPILE, but with different arguments
483 #
484 AC_DEFUN([LB_LINUX_TRY_MAKE],
485         [LB_LINUX_COMPILE_IFELSE(
486                 [AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])],
487                 [$3], [$4], [$5], [$6]
488         )]
489 )
490
491 # LC_MODULE_LOADING
492 # after 2.6.28 CONFIG_KMOD is removed, and only CONFIG_MODULES remains
493 # so we test if request_module is implemented or not
494 AC_DEFUN([LC_MODULE_LOADING],
495 [AC_MSG_CHECKING([if kernel module loading is possible])
496 LB_LINUX_TRY_MAKE([
497         #include <linux/kmod.h>
498 ],[
499         int myretval=ENOSYS ;
500         return myretval;
501 ],[
502         $makerule LUSTRE_KERNEL_TEST=conftest.i
503 ],[dnl
504         grep request_module build/conftest.i |dnl
505                 grep -v `grep "int myretval=" build/conftest.i |dnl
506                         cut -d= -f2 | cut -d" "  -f1`dnl
507                 >/dev/null dnl
508 ],[
509         AC_MSG_RESULT(yes)
510         AC_DEFINE(HAVE_MODULE_LOADING_SUPPORT, 1,
511                   [kernel module loading is possible])
512 ],[
513         AC_MSG_RESULT(no)
514         AC_MSG_WARN([
515
516 Kernel module loading support is highly recommended.
517 ])
518 ])
519 ])
520
521 #
522 # LB_PROG_LINUX
523 #
524 # linux tests
525 #
526 AC_DEFUN([LB_PROG_LINUX],
527 [LB_LINUX_PATH
528 LB_LINUX_ARCH
529 LB_LINUX_SYMVERFILE
530
531
532 LB_LINUX_CONFIG([MODULES],[],[
533         AC_MSG_ERROR([
534
535 module support is required to build Lustre kernel modules.
536 ])
537 ])
538
539 LB_LINUX_CONFIG([MODVERSIONS])
540
541 LB_LINUX_CONFIG([KALLSYMS],[],[
542         AC_MSG_ERROR([
543
544 Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.
545 ])
546 ])
547
548 # 2.6.28
549 LC_MODULE_LOADING
550 ])
551
552 #
553 # LB_CHECK_SYMBOL_EXPORT
554 # check symbol exported or not
555 # $1 - symbol
556 # $2 - file(s) for find.
557 # $3 - do 'yes'
558 # $4 - do 'no'
559 #
560 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
561 # or check
562 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
563 [AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
564 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX_OBJ/$SYMVERFILE 2>/dev/null
565 rc=$?
566 if test $rc -ne 0; then
567         export=0
568         for file in $2; do
569                 grep -q -E "EXPORT_SYMBOL.*\($1\)" "$LINUX/$file" 2>/dev/null
570                 rc=$?
571                 if test $rc -eq 0; then
572                         export=1
573                         break;
574                 fi
575         done
576         if test $export -eq 0; then
577                 AC_MSG_RESULT([no])
578                 $4
579         else
580                 AC_MSG_RESULT([yes])
581                 $3
582         fi
583 else
584         AC_MSG_RESULT([yes])
585         $3
586 fi
587 ])
588
589 #
590 # Like AC_CHECK_HEADER but checks for a kernel-space header
591 #
592 m4_define([LB_CHECK_LINUX_HEADER],
593 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
594 AC_CACHE_CHECK([for $1], ac_Header,
595                [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
596                                   [modules],
597                                   [test -s build/conftest.o],
598                                   [AS_VAR_SET(ac_Header, [yes])],
599                                   [AS_VAR_SET(ac_Header, [no])])])
600 AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
601 AS_VAR_POPDEF([ac_Header])dnl
602 ])
603
604 #
605 # LB_USES_DPKG
606 #
607 # Determine if the target is a dpkg system or rpm
608 #
609 AC_DEFUN([LB_USES_DPKG],
610 [
611 AC_MSG_CHECKING([if this distro uses dpkg])
612 case `lsb_release -i -s 2>/dev/null` in
613         Ubuntu | Debian)
614                 AC_MSG_RESULT([yes])
615                 uses_dpkg=yes
616                 ;;
617         *)
618                 AC_MSG_RESULT([no])
619                 uses_dpkg=no
620                 ;;
621 esac
622 ])