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])
59 #include <linux/version.h>
62 LINUXRELEASE=UTS_RELEASE;
64 $makerule LUSTRE_KERNEL_TEST=conftest.i
66 test -s build/conftest.i
68 # LINUXRELEASE="UTS_RELEASE"
69 eval $(grep "LINUXRELEASE=" build/conftest.i)
71 AC_MSG_RESULT([unknown])
72 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
74 rm -f build/conftest.i
75 if test x$LINUXRELEASE = x ; then
76 AC_MSG_RESULT([unknown])
77 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
79 AC_MSG_RESULT([$LINUXRELEASE])
80 AC_SUBST(LINUXRELEASE)
82 moduledir='/lib/modules/'$LINUXRELEASE/kernel
85 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
88 modulenetdir='$(moduledir)/net/$(PACKAGE)'
89 AC_SUBST(modulenetdir)
91 # ------------ RELEASE --------------------------------
92 AC_MSG_CHECKING([for Lustre release])
93 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
94 AC_MSG_RESULT($RELEASE)
101 # Find paths for linux, handling kernel-source rpms
103 AC_DEFUN([LB_LINUX_PATH],
104 [AC_MSG_CHECKING([for Linux sources])
106 AC_HELP_STRING([--with-linux=path],
107 [set path to Linux source (default=/usr/src/linux)]),
109 [LINUX=/usr/src/linux])
110 AC_MSG_RESULT([$LINUX])
113 # -------- linux objects (for 2.6) --
114 AC_MSG_CHECKING([for Linux objects dir])
115 AC_ARG_WITH([linux-obj],
116 AC_HELP_STRING([--with-linux-obj=path],
117 [set path to Linux objects dir (default=$LINUX)]),
118 [LINUX_OBJ=$with_linux_obj],
120 AC_MSG_RESULT([$LINUX_OBJ])
123 # -------- check for .confg --------
124 AC_ARG_WITH([linux-config],
125 [AC_HELP_STRING([--with-linux-config=path],
126 [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
127 [LINUX_CONFIG=$with_linux_config],
128 [LINUX_CONFIG=$LINUX_OBJ/.config])
129 AC_SUBST(LINUX_CONFIG)
131 LB_CHECK_FILE([/boot/kernel.h],
132 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
133 [LB_CHECK_FILE([/var/adm/running-kernel.h],
134 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
136 AC_ARG_WITH([kernel-source-header],
137 AC_HELP_STRING([--with-kernel-source-header=path],
138 [Use a different kernel version header. Consult build/README.kernel-source for details.]),
139 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
141 # ------------ .config exists ----------------
142 LB_CHECK_FILE([$LINUX_CONFIG],[],
143 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult build/README.kernel-source])])
145 # ----------- make dep run? ------------------
146 LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
147 $LINUX_OBJ/include/linux/version.h
148 $LINUX/include/linux/config.h],[],
149 [AC_MSG_ERROR([Run make config in $LINUX.])])
151 # ------------ rhconfig.h includes runtime-generated bits --
152 # red hat kernel-source checks
154 # we know this exists after the check above. if the user
155 # tarred up the tree and ran make dep etc. in it, then
156 # version.h gets overwritten with a standard linux one.
158 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
159 # This is a clean kernel-source tree, we need to
160 # enable extensive workarounds to get this to build
162 LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
163 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
164 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
165 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
166 AC_MSG_WARN([Consult build/README.kernel-source for details.])
168 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult build/README.kernel-source for details.])])
169 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
172 # this is needed before we can build modules
176 # --- check that we can build modules at all
177 AC_MSG_CHECKING([that modules can be built at all])
178 LB_LINUX_TRY_COMPILE([],[],[
182 AC_MSG_WARN([Consult config.log for details.])
183 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
184 AC_MSG_ERROR([Kernel modules cannot be build.])
193 # check for a uml kernel
195 AC_DEFUN([LB_LINUX_UML],
199 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
200 if test -e $LINUX/include/asm-um ; then
201 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
203 # see notes in Rules.in
207 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
210 AC_MSG_RESULT([no (asm-um missing)])
216 # these are like AC_TRY_COMPILE, but try to build modules against the
217 # kernel, inside the build directory
222 # create a conftest.c file
224 AC_DEFUN([LB_LINUX_CONFTEST],
225 [cat >conftest.c <<_ACEOF
231 # LB_LINUX_COMPILE_IFELSE
233 # like AC_COMPILE_IFELSE
235 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
236 [m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl
237 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
238 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])],
240 [_AC_MSG_LOG_CONFTEST
241 m4_ifvaln([$5],[$5])dnl])dnl
242 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
246 # LB_LINUX_TRY_COMPILE
248 # like AC_TRY_COMPILE
250 AC_DEFUN([LB_LINUX_TRY_COMPILE],
251 [LB_LINUX_COMPILE_IFELSE(
252 [AC_LANG_PROGRAM([[$1]], [[$2]])],
254 [test -s build/conftest.o],
260 # check if a given config option is defined
262 AC_DEFUN([LB_LINUX_CONFIG],
263 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
264 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
266 #error CONFIG_$1 not #defined
280 # like LB_LINUX_TRY_COMPILE, but with different arguments
282 AC_DEFUN([LB_LINUX_TRY_MAKE],
283 [LB_LINUX_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
286 # LB_LINUX_CONFIG_BIG_STACK
288 # check for big stack patch
290 AC_DEFUN([LB_LINUX_CONFIG_BIG_STACK],
291 [if test "x$ARCH_UM" = "x" -a "x$linux25" = "xno" ; then
294 LB_LINUX_CONFIG([STACK_SIZE_16KB],[],[
295 LB_LINUX_CONFIG([STACK_SIZE_32KB],[],[
296 LB_LINUX_CONFIG([STACK_SIZE_64KB],[],[
297 AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 16KB stack.])
311 AC_DEFUN([LB_PROG_LINUX],
314 LB_LINUX_CONFIG([MODULES],[],[
315 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
318 LB_LINUX_CONFIG([MODVERSIONS])
320 LB_LINUX_CONFIG([PREEMPT],[
321 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
324 LB_LINUX_CONFIG([KALLSYMS],[],[
325 if test "x$ARCH_UM" = "x" ; then
326 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
330 #LB_LINUX_CONFIG_BIG_STACK
343 # LB_LINUX_CONDITIONALS
345 # AM_CONDITIONALS for linux
347 AC_DEFUN([LB_LINUX_CONDITIONALS],
348 [AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)