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