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