4 # Set things accordingly for a 2.5 kernel
6 AC_DEFUN([LB_LINUX_VERSION],
7 [LB_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],
29 makerule="_module_$makerule"
31 LB_LINUX_TRY_MAKE([],[],
32 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
33 [test -s build/conftest.i],
37 AC_MSG_ERROR([unknown; check config.log for details])
41 makerule="_dir_$PWD/build"
44 AC_SUBST(MODULE_TARGET)
52 # get the release version of linux
54 AC_DEFUN([LB_LINUX_RELEASE],
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
61 LINUXRELEASEHEADER=version.h
64 #include <linux/$LINUXRELEASEHEADER>
67 LINUXRELEASE=UTS_RELEASE;
69 $makerule LUSTRE_KERNEL_TEST=conftest.i
71 test -s build/conftest.i
73 # LINUXRELEASE="UTS_RELEASE"
74 eval $(grep "LINUXRELEASE=" build/conftest.i)
76 AC_MSG_RESULT([unknown])
77 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
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.])
84 AC_MSG_RESULT([$LINUXRELEASE])
85 AC_SUBST(LINUXRELEASE)
87 moduledir='/lib/modules/'$LINUXRELEASE/kernel
90 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
93 modulenetdir='$(moduledir)/net/$(PACKAGE)'
94 AC_SUBST(modulenetdir)
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)
107 # Find paths for linux, handling kernel-source rpms
109 AC_DEFUN([LB_LINUX_PATH],
110 [AC_MSG_CHECKING([for Linux sources])
112 AC_HELP_STRING([--with-linux=path],
113 [set path to Linux source (default=/usr/src/linux)]),
115 [LINUX=/usr/src/linux])
116 AC_MSG_RESULT([$LINUX])
119 # -------- check for linux --------
120 LB_CHECK_FILE([$LINUX],[],
121 [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
123 # -------- linux objects (for 2.6) --
124 AC_MSG_CHECKING([for Linux objects dir])
125 AC_ARG_WITH([linux-obj],
126 AC_HELP_STRING([--with-linux-obj=path],
127 [set path to Linux objects dir (default=$LINUX)]),
128 [LINUX_OBJ=$with_linux_obj],
130 AC_MSG_RESULT([$LINUX_OBJ])
133 # -------- check for .config --------
134 AC_ARG_WITH([linux-config],
135 [AC_HELP_STRING([--with-linux-config=path],
136 [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
137 [LINUX_CONFIG=$with_linux_config],
138 [LINUX_CONFIG=$LINUX_OBJ/.config])
139 AC_SUBST(LINUX_CONFIG)
141 LB_CHECK_FILE([/boot/kernel.h],
142 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
143 [LB_CHECK_FILE([/var/adm/running-kernel.h],
144 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
146 AC_ARG_WITH([kernel-source-header],
147 AC_HELP_STRING([--with-kernel-source-header=path],
148 [Use a different kernel version header. Consult build/README.kernel-source for details.]),
149 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
151 # ------------ .config exists ----------------
152 LB_CHECK_FILE([$LINUX_CONFIG],[],
153 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult build/README.kernel-source])])
155 # ----------- make dep run? ------------------
156 # at 2.6.19 # $LINUX/include/linux/config.h is removed
157 # and at more old has only one line
158 # include <autoconf.h>
159 LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
160 $LINUX_OBJ/include/linux/version.h
162 [AC_MSG_ERROR([Run make config in $LINUX.])])
164 LB_CHECK_FILE([$LINUX_OBJ/include/linux/config.h],
165 [ AC_DEFINE(HAVE_KERNEL_CONFIG_H, 1,
166 [kernel modules need to include config.h])
170 # ------------ rhconfig.h includes runtime-generated bits --
171 # red hat kernel-source checks
173 # we know this exists after the check above. if the user
174 # tarred up the tree and ran make dep etc. in it, then
175 # version.h gets overwritten with a standard linux one.
177 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
178 # This is a clean kernel-source tree, we need to
179 # enable extensive workarounds to get this to build
181 LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
182 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
183 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
184 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
185 AC_MSG_WARN([Consult build/README.kernel-source for details.])
187 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult build/README.kernel-source for details.])])
188 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
191 # Find the modpost utility
192 AC_CHECK_FILE([$LINUX_OBJ/scripts/mod/modpost],
193 [MODPOST=$LINUX_OBJ/scripts/mod/modpost],
194 [AC_MSG_ERROR([modpost not found.])]
198 # this is needed before we can build modules
202 # --- check that we can build modules at all
203 AC_MSG_CHECKING([that modules can be built at all])
204 LB_LINUX_TRY_COMPILE([],[],[
208 AC_MSG_WARN([Consult config.log for details.])
209 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
210 AC_MSG_ERROR([Kernel modules cannot be built.])
214 ]) # end of LB_LINUX_PATH
219 # check for a uml kernel
221 AC_DEFUN([LB_LINUX_UML],
225 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
226 if test -e $LINUX/include/asm-um ; then
227 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
229 # see notes in Rules.in
233 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
236 AC_MSG_RESULT([no (asm-um missing)])
242 # these are like AC_TRY_COMPILE, but try to build modules against the
243 # kernel, inside the build directory
248 # create a conftest.c file
250 AC_DEFUN([LB_LINUX_CONFTEST],
251 [cat >conftest.c <<_ACEOF
257 # LB_LANG_PROGRAM(C)([PROLOGUE], [BODY])
258 # --------------------------------------
259 m4_define([LB_LANG_PROGRAM],
264 dnl Do *not* indent the following line: there may be CPP directives.
265 dnl Don't move the `;' right after for the same reason.
272 # LB_LINUX_COMPILE_IFELSE
274 # like AC_COMPILE_IFELSE
276 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
277 [m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl
278 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
279 AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -Iinclude -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])],
281 [_AC_MSG_LOG_CONFTEST
282 m4_ifvaln([$5],[$5])dnl])dnl
283 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
287 # LB_LINUX_TRY_COMPILE
289 # like AC_TRY_COMPILE
291 AC_DEFUN([LB_LINUX_TRY_COMPILE],
292 [LB_LINUX_COMPILE_IFELSE(
293 [AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])],
295 [test -s build/conftest.o],
301 # check if a given config option is defined
303 AC_DEFUN([LB_LINUX_CONFIG],
304 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
305 LB_LINUX_TRY_COMPILE([
306 #ifdef HAVE_KERNEL_CONFIG_H
307 #include <linux/config.h>
311 #error CONFIG_$1 not #defined
325 # check if a given config option is builtin or as module
327 AC_DEFUN([LB_LINUX_CONFIG_IM],
328 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1 in or as module])
329 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
330 #if !(defined(CONFIG_$1) || defined(CONFIG_$1_MODULE))
331 #error CONFIG_$1 and CONFIG_$1_MODULE not #defined
345 # like LB_LINUX_TRY_COMPILE, but with different arguments
347 AC_DEFUN([LB_LINUX_TRY_MAKE],
348 [LB_LINUX_COMPILE_IFELSE([AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])], [$3], [$4], [$5], [$6])])
351 # LB_LINUX_CONFIG_BIG_STACK
353 # check for big stack patch
355 AC_DEFUN([LB_LINUX_CONFIG_BIG_STACK],
356 [if test "x$ARCH_UM" = "x" -a "x$linux25" = "xno" ; then
359 LB_LINUX_CONFIG([STACK_SIZE_16KB],[],[
360 LB_LINUX_CONFIG([STACK_SIZE_32KB],[],[
361 LB_LINUX_CONFIG([STACK_SIZE_64KB],[],[
362 AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 16KB stack.])
376 AC_DEFUN([LB_PROG_LINUX],
379 LB_LINUX_CONFIG([MODULES],[],[
380 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
383 LB_LINUX_CONFIG([MODVERSIONS])
385 LB_LINUX_CONFIG([PREEMPT],[
386 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
389 LB_LINUX_CONFIG([KALLSYMS],[],[
390 if test "x$ARCH_UM" = "x" ; then
391 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
395 LB_LINUX_CONFIG([KMOD],[],[
397 AC_MSG_WARN([Kernel module loading support is highly recommended.])
401 #LB_LINUX_CONFIG_BIG_STACK
406 # LB_LINUX_CONDITIONALS
408 # AM_CONDITIONALS for linux
410 AC_DEFUN([LB_LINUX_CONDITIONALS],
411 [AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
416 # LB_CHECK_SYMBOL_EXPORT
417 # check symbol exported or not
419 # $2 - file(s) for find.
423 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
425 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
426 [AC_MSG_CHECKING([if Linux was built with symbol $1 is exported])
427 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null
429 if test $rc -ne 0; then
432 grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
434 if test $rc -eq 0; then
439 if test $export -eq 0; then