4 # Set things accordingly for a 2.5 kernel
6 AC_DEFUN([LB_LINUX_VERSION],
7 [AC_CHECK_FILE([$LINUX/include/linux/namei.h],
15 AC_MSG_CHECKING([if you are using Linux 2.6])
16 AC_MSG_RESULT([$linux25])
18 MODULE_TARGET="SUBDIRS"
19 if test $linux25 = "yes" ; then
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],
30 makerule="_module_$makerule"
35 makerule="_dir_$PWD/build"
38 AC_SUBST(MODULE_TARGET)
46 # get the release version of linux
48 AC_DEFUN([LB_LINUX_RELEASE],
50 rm -f build/conftest.i
51 AC_MSG_CHECKING([for Linux release])
53 #include <linux/version.h>
56 LINUXRELEASE=UTS_RELEASE;
58 $makerule LUSTRE_KERNEL_TEST=conftest.i
60 test -s build/conftest.i
62 # LINUXRELEASE="UTS_RELEASE"
63 eval $(grep "LINUXRELEASE=" build/conftest.i)
65 AC_MSG_RESULT([unknown])
66 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
68 rm -f build/conftest.i
69 if test x$LINUXRELEASE = x ; then
70 AC_MSG_RESULT([unknown])
71 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
73 AC_MSG_RESULT([$LINUXRELEASE])
74 AC_SUBST(LINUXRELEASE)
76 moduledir='/lib/modules/'$LINUXRELEASE/kernel
79 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
82 modulenetdir='$(moduledir)/net/$(PACKAGE)'
83 AC_SUBST(modulenetdir)
85 # ------------ RELEASE --------------------------------
86 AC_MSG_CHECKING([for Lustre release])
87 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
88 AC_MSG_RESULT($RELEASE)
95 # Find paths for linux, handling kernel-source rpms
97 AC_DEFUN([LB_LINUX_PATH],
98 [AC_MSG_CHECKING([for Linux sources])
100 AC_HELP_STRING([--with-linux=path],
101 [set path to Linux source (default=/usr/src/linux)]),
103 [LINUX=/usr/src/linux])
104 AC_MSG_RESULT([$LINUX])
107 # -------- linux objects (for 2.6) --
108 AC_MSG_CHECKING([for Linux objects dir])
109 AC_ARG_WITH([linux-obj],
110 AC_HELP_STRING([--with-linux-obj=path],
111 [set path to Linux objects dir (default=$LINUX)]),
112 [LINUX_OBJ=$with_linux_obj],
114 AC_MSG_RESULT([$LINUX_OBJ])
117 # -------- check for .confg --------
118 AC_ARG_WITH([linux-config],
119 [AC_HELP_STRING([--with-linux-config=path],
120 [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
121 [LINUX_CONFIG=$with_linux_config],
122 [LINUX_CONFIG=$LINUX_OBJ/.config])
123 AC_SUBST(LINUX_CONFIG)
125 AC_CHECK_FILE([/boot/kernel.h],
126 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
127 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
128 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
130 AC_ARG_WITH([kernel-source-header],
131 AC_HELP_STRING([--with-kernel-source-header=path],
132 [Use a different kernel version header. Consult README.kernel-source for details.]),
133 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
135 # ------------ .config exists ----------------
136 AC_CHECK_FILE([$LINUX_CONFIG],[],
137 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
139 # ----------- make dep run? ------------------
140 AC_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
141 $LINUX_OBJ/include/linux/version.h
142 $LINUX/include/linux/config.h],[],
143 [AC_MSG_ERROR([Run make config in $LINUX.])])
145 # ------------ rhconfig.h includes runtime-generated bits --
146 # red hat kernel-source checks
148 # we know this exists after the check above. if the user
149 # tarred up the tree and ran make dep etc. in it, then
150 # version.h gets overwritten with a standard linux one.
152 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
153 # This is a clean kernel-source tree, we need to
154 # enable extensive workarounds to get this to build
156 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
157 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
158 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
159 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
160 AC_MSG_WARN([Consult README.kernel-source for details.])
162 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
163 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
166 # this is needed before we can build modules
169 # --- check that we can build modules at all
170 AC_MSG_CHECKING([that modules can be built at all])
171 LB_LINUX_TRY_COMPILE([],[],[
175 AC_MSG_WARN([Consult config.log for details.])
176 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
177 AC_MSG_ERROR([Kernel modules could not be built.])
186 # check for a uml kernel
188 AC_DEFUN([LB_LINUX_UML],
192 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
193 if test -e $LINUX/include/asm-um ; then
194 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
196 # see notes in Rules.in
200 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
203 AC_MSG_RESULT([no (asm-um missing)])
209 # these are like AC_TRY_COMPILE, but try to build modules against the
210 # kernel, inside the build directory
215 # create a conftest.c file
217 AC_DEFUN([LB_LINUX_CONFTEST],
218 [cat >conftest.c <<_ACEOF
224 # LB_LINUX_COMPILE_IFELSE
226 # like AC_COMPILE_IFELSE
228 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
229 [m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl
230 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
231 AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -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])],
233 [_AC_MSG_LOG_CONFTEST
234 m4_ifvaln([$5],[$5])dnl])dnl
235 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
239 # LB_LINUX_TRY_COMPILE
241 # like AC_TRY_COMPILE
243 AC_DEFUN([LB_LINUX_TRY_COMPILE],
244 [LB_LINUX_COMPILE_IFELSE(
245 [AC_LANG_PROGRAM([[$1]], [[$2]])],
247 [test -s build/conftest.o],
253 # check if a given config option is defined
255 AC_DEFUN([LB_LINUX_CONFIG],
256 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
257 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
259 #error CONFIG_$1 not #defined
273 # like LB_LINUX_TRY_COMPILE, but with different arguments
275 AC_DEFUN([LB_LINUX_TRY_MAKE],
276 [LB_LINUX_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
283 AC_DEFUN([LB_PROG_LINUX],
287 LB_LINUX_CONFIG([MODULES],[],[
288 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
291 LB_LINUX_CONFIG([MODVERSIONS])
293 LB_LINUX_CONFIG([PREEMPT],[
294 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
297 LB_LINUX_CONFIG([KALLSYMS],[],[
298 if test "x$ARCH_UM" = "x" ; then
299 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
311 # LB_LINUX_CONDITIONALS
313 # AM_CONDITIONALS for linux
315 AC_DEFUN([LB_LINUX_CONDITIONALS],
316 [AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes)
317 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
321 # LB_LINUX_STRUCT_PAGE_LIST
323 # 2.6.4 no longer has page->list
325 AC_DEFUN([LB_LINUX_STRUCT_PAGE_LIST],
326 [AC_MSG_CHECKING([if struct page has a list field])
327 LB_LINUX_TRY_COMPILE([
328 #include <linux/mm.h>
334 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
341 # LB_LINUX_STRUCT_SIGHAND
343 # red hat 2.4 adds sighand to struct task_struct
345 AC_DEFUN([LB_LINUX_STRUCT_SIGHAND],
346 [AC_MSG_CHECKING([if task_struct has a sighand field])
347 LB_LINUX_TRY_COMPILE([
348 #include <linux/sched.h>
350 struct task_struct p;
353 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
361 # LB_LINUX_FUNC_CPU_ONLINE
363 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
365 AC_DEFUN([LB_LINUX_FUNC_CPU_ONLINE],
366 [AC_MSG_CHECKING([if kernel defines cpu_online()])
367 LB_LINUX_TRY_COMPILE([
368 #include <linux/sched.h>
373 AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
380 # LB_LINUX_TYPE_CPUMASK_T
382 # same goes for cpumask_t
384 AC_DEFUN([LB_LINUX_TYPE_CPUMASK_T],
385 [AC_MSG_CHECKING([if kernel defines cpumask_t])
386 LB_LINUX_TRY_COMPILE([
387 #include <linux/sched.h>
389 return sizeof (cpumask_t);
392 AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
399 # LB_LINUX_FUNC_SHOW_TASK
401 # we export show_task(), but not all kernels have it (yet)
403 AC_DEFUN([LB_LINUX_FUNC_SHOW_TASK],
404 [AC_MSG_CHECKING([if kernel exports show_task])
406 for file in ksyms sched ; do
407 if grep -q "EXPORT_SYMBOL(show_task)" \
408 "$LINUX/kernel/$file.c" 2>/dev/null ; then
413 if test x$have_show_task = x1 ; then
414 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
422 # LB_LINUX_CONFIG_EXT3
424 # that ext3 is enabled in the kernel
426 AC_DEFUN([LB_LINUX_CONFIG_EXT3],
427 [LB_LINUX_CONFIG([EXT3_FS],[],[
428 LB_LINUX_CONFIG([EXT3_FS_MODULE],[],[$2])
430 LB_LINUX_CONFIG([EXT3_FS_XATTR],[$1],[$3])
436 # If we have (and can build) fshooks.h
438 AC_DEFUN([LB_LINUX_FSHOOKS],
439 [AC_CHECK_FILE([$LINUX/include/linux/fshooks.h],[
440 AC_MSG_CHECKING([if fshooks.h can be compiled])
441 LB_LINUX_TRY_COMPILE([
442 #include <linux/fshooks.h>
447 AC_MSG_WARN([You might have better luck with gcc 3.3.x.])
448 AC_MSG_WARN([You can set CC=gcc33 before running configure.])
449 AC_MSG_ERROR([Your compiler cannot build fshooks.h.])
458 # LB_LINUX_STRUCT_KIOBUF
460 # rh 2.4.18 has iobuf->dovary, but other kernels do not
462 AC_DEFUN([LB_LINUX_STRUCT_KIOBUF],
463 [AC_MSG_CHECKING([if struct kiobuf has a dovary field])
464 LB_LINUX_TRY_COMPILE([
465 #include <linux/iobuf.h>
471 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
478 # LB_LINUX_FUNC_COND_RESCHED
480 # cond_resched() was introduced in 2.4.20
482 AC_DEFUN([LB_LINUX_FUNC_COND_RESCHED],
483 [AC_MSG_CHECKING([if kernel offers cond_resched])
484 LB_LINUX_TRY_COMPILE([
485 #include <linux/sched.h>
490 AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
497 # LB_LINUX_FUNC_ZAP_PAGE_RANGE
499 # if zap_page_range() takes a vma arg
501 AC_DEFUN([LB_LINUX_FUNC_ZAP_PAGE_RANGE],
502 [AC_MSG_CHECKING([if zap_pag_range with vma parameter])
503 ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
504 if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
505 AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
515 # if proc_fs.h defines PDE()
517 AC_DEFUN([LB_LINUX_FUNC_PDE],
518 [AC_MSG_CHECKING([if kernel defines PDE])
519 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
520 if test "$HAVE_PDE" != 0 ; then
521 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
529 # LB_LINUX_FUNC_DIRECT_IO
531 # if direct_IO takes a struct file argument
533 AC_DEFUN([LB_LINUX_FUNC_DIRECT_IO],
534 [AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
535 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
536 if test "$HAVE_DIO_FILE" != 0 ; then
537 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
545 # LB_LINUX_HEADER_MM_INLINE
547 # RHEL kernels define page_count in mm_inline.h
549 AC_DEFUN([LB_LINUX_HEADER_MM_INLINE],
550 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
551 LB_LINUX_TRY_COMPILE([
552 #include <linux/mm_inline.h>
555 #error mm_inline.h does not define page_count
559 AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
566 # LB_LINUX_STRUCT_INODE
568 # if inode->i_alloc_sem exists
570 AC_DEFUN([LB_LINUX_STRUCT_INODE],
571 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
572 LB_LINUX_TRY_COMPILE([
573 #include <linux/fs.h>
574 #include <linux/version.h>
576 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
577 #error "down_read_trylock broken before 2.4.24"
580 return (char *)&i.i_alloc_sem - (char *)&i;
583 AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])