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