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 # -------- check for linux --------
114 LB_CHECK_FILE([$LINUX],[],
115 [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
117 # -------- linux objects (for 2.6) --
118 AC_MSG_CHECKING([for Linux objects dir])
119 AC_ARG_WITH([linux-obj],
120 AC_HELP_STRING([--with-linux-obj=path],
121 [set path to Linux objects dir (default=$LINUX)]),
122 [LINUX_OBJ=$with_linux_obj],
124 AC_MSG_RESULT([$LINUX_OBJ])
127 # -------- check for .config --------
128 AC_ARG_WITH([linux-config],
129 [AC_HELP_STRING([--with-linux-config=path],
130 [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
131 [LINUX_CONFIG=$with_linux_config],
132 [LINUX_CONFIG=$LINUX_OBJ/.config])
133 AC_SUBST(LINUX_CONFIG)
135 LB_CHECK_FILE([/boot/kernel.h],
136 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
137 [LB_CHECK_FILE([/var/adm/running-kernel.h],
138 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
140 AC_ARG_WITH([kernel-source-header],
141 AC_HELP_STRING([--with-kernel-source-header=path],
142 [Use a different kernel version header. Consult build/README.kernel-source for details.]),
143 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
145 # ------------ .config exists ----------------
146 LB_CHECK_FILE([$LINUX_CONFIG],[],
147 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult build/README.kernel-source])])
149 # ----------- make dep run? ------------------
150 LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
151 $LINUX_OBJ/include/linux/version.h
152 $LINUX/include/linux/config.h],[],
153 [AC_MSG_ERROR([Run make config in $LINUX.])])
155 # ------------ rhconfig.h includes runtime-generated bits --
156 # red hat kernel-source checks
158 # we know this exists after the check above. if the user
159 # tarred up the tree and ran make dep etc. in it, then
160 # version.h gets overwritten with a standard linux one.
162 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
163 # This is a clean kernel-source tree, we need to
164 # enable extensive workarounds to get this to build
166 LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
167 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
168 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
169 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
170 AC_MSG_WARN([Consult build/README.kernel-source for details.])
172 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult build/README.kernel-source for details.])])
173 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
176 # this is needed before we can build modules
180 # --- check that we can build modules at all
181 AC_MSG_CHECKING([that modules can be built at all])
182 LB_LINUX_TRY_COMPILE([],[],[
186 AC_MSG_WARN([Consult config.log for details.])
187 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
188 AC_MSG_ERROR([Kernel modules cannot be build.])
197 # check for a uml kernel
199 AC_DEFUN([LB_LINUX_UML],
203 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
204 if test -e $LINUX/include/asm-um ; then
205 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
207 # see notes in Rules.in
211 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
214 AC_MSG_RESULT([no (asm-um missing)])
220 # these are like AC_TRY_COMPILE, but try to build modules against the
221 # kernel, inside the build directory
226 # create a conftest.c file
228 AC_DEFUN([LB_LINUX_CONFTEST],
229 [cat >conftest.c <<_ACEOF
235 # LB_LINUX_COMPILE_IFELSE
237 # like AC_COMPILE_IFELSE
239 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
240 [m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl
241 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
242 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])],
244 [_AC_MSG_LOG_CONFTEST
245 m4_ifvaln([$5],[$5])dnl])dnl
246 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
250 # LB_LINUX_TRY_COMPILE
252 # like AC_TRY_COMPILE
254 AC_DEFUN([LB_LINUX_TRY_COMPILE],
255 [LB_LINUX_COMPILE_IFELSE(
256 [AC_LANG_PROGRAM([[$1]], [[$2]])],
258 [test -s build/conftest.o],
264 # check if a given config option is defined
266 AC_DEFUN([LB_LINUX_CONFIG],
267 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
268 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
270 #error CONFIG_$1 not #defined
284 # like LB_LINUX_TRY_COMPILE, but with different arguments
286 AC_DEFUN([LB_LINUX_TRY_MAKE],
287 [LB_LINUX_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
290 # LB_LINUX_CONFIG_BIG_STACK
292 # check for big stack patch
294 AC_DEFUN([LB_LINUX_CONFIG_BIG_STACK],
295 [if test "x$ARCH_UM" = "x" -a "x$linux25" = "xno" ; then
298 LB_LINUX_CONFIG([STACK_SIZE_16KB],[],[
299 LB_LINUX_CONFIG([STACK_SIZE_32KB],[],[
300 LB_LINUX_CONFIG([STACK_SIZE_64KB],[],[
301 AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 16KB stack.])
315 AC_DEFUN([LB_PROG_LINUX],
318 LB_LINUX_CONFIG([MODULES],[],[
319 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
322 LB_LINUX_CONFIG([MODVERSIONS])
324 LB_LINUX_CONFIG([PREEMPT],[
325 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
328 LB_LINUX_CONFIG([KALLSYMS],[],[
329 if test "x$ARCH_UM" = "x" ; then
330 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
334 LB_LINUX_CONFIG([KMOD],[],[
336 AC_MSG_WARN([Kernel module loading support is highly recommended.])
340 #LB_LINUX_CONFIG_BIG_STACK
349 if test "$PORTALS" ; then
355 # LB_LINUX_CONDITIONALS
357 # AM_CONDITIONALS for linux
359 AC_DEFUN([LB_LINUX_CONDITIONALS],
360 [AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)