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)
106 # Find paths for linux, handling kernel-source rpms
108 AC_DEFUN([LB_LINUX_PATH],
109 [AC_MSG_CHECKING([for Linux sources])
111 AC_HELP_STRING([--with-linux=path],
112 [set path to Linux source (default=/usr/src/linux)]),
114 [LINUX=/usr/src/linux])
115 AC_MSG_RESULT([$LINUX])
118 # -------- check for linux --------
119 LB_CHECK_FILE([$LINUX],[],
120 [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
122 # -------- linux objects (for 2.6) --
123 AC_MSG_CHECKING([for Linux objects dir])
124 AC_ARG_WITH([linux-obj],
125 AC_HELP_STRING([--with-linux-obj=path],
126 [set path to Linux objects dir (default=$LINUX)]),
127 [LINUX_OBJ=$with_linux_obj],
129 AC_MSG_RESULT([$LINUX_OBJ])
132 # -------- check for .config --------
133 AC_ARG_WITH([linux-config],
134 [AC_HELP_STRING([--with-linux-config=path],
135 [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
136 [LINUX_CONFIG=$with_linux_config],
137 [LINUX_CONFIG=$LINUX_OBJ/.config])
138 AC_SUBST(LINUX_CONFIG)
140 LB_CHECK_FILE([/boot/kernel.h],
141 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
142 [LB_CHECK_FILE([/var/adm/running-kernel.h],
143 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
145 AC_ARG_WITH([kernel-source-header],
146 AC_HELP_STRING([--with-kernel-source-header=path],
147 [Use a different kernel version header. Consult build/README.kernel-source for details.]),
148 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
150 # ------------ .config exists ----------------
151 LB_CHECK_FILE([$LINUX_CONFIG],[],
152 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult build/README.kernel-source])])
154 # ----------- make dep run? ------------------
155 LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
156 $LINUX_OBJ/include/linux/version.h
157 $LINUX/include/linux/config.h],[],
158 [AC_MSG_ERROR([Run make config in $LINUX.])])
160 # ------------ rhconfig.h includes runtime-generated bits --
161 # red hat kernel-source checks
163 # we know this exists after the check above. if the user
164 # tarred up the tree and ran make dep etc. in it, then
165 # version.h gets overwritten with a standard linux one.
167 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
168 # This is a clean kernel-source tree, we need to
169 # enable extensive workarounds to get this to build
171 LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
172 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
173 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
174 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
175 AC_MSG_WARN([Consult build/README.kernel-source for details.])
177 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult build/README.kernel-source for details.])])
178 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
181 # this is needed before we can build modules
185 # --- check that we can build modules at all
186 AC_MSG_CHECKING([that modules can be built at all])
187 LB_LINUX_TRY_COMPILE([],[],[
191 AC_MSG_WARN([Consult config.log for details.])
192 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
193 AC_MSG_ERROR([Kernel modules cannot be build.])
202 # check for a uml kernel
204 AC_DEFUN([LB_LINUX_UML],
208 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
209 if test -e $LINUX/include/asm-um ; then
210 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
212 # see notes in Rules.in
216 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
219 AC_MSG_RESULT([no (asm-um missing)])
225 # these are like AC_TRY_COMPILE, but try to build modules against the
226 # kernel, inside the build directory
231 # create a conftest.c file
233 AC_DEFUN([LB_LINUX_CONFTEST],
234 [cat >conftest.c <<_ACEOF
240 # LB_LINUX_COMPILE_IFELSE
242 # like AC_COMPILE_IFELSE
244 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
245 [m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl
246 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
247 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])],
249 [_AC_MSG_LOG_CONFTEST
250 m4_ifvaln([$5],[$5])dnl])dnl
251 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
255 # LB_LINUX_TRY_COMPILE
257 # like AC_TRY_COMPILE
259 AC_DEFUN([LB_LINUX_TRY_COMPILE],
260 [LB_LINUX_COMPILE_IFELSE(
261 [AC_LANG_PROGRAM([[$1]], [[$2]])],
263 [test -s build/conftest.o],
269 # check if a given config option is defined
271 AC_DEFUN([LB_LINUX_CONFIG],
272 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
273 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
275 #error CONFIG_$1 not #defined
289 # like LB_LINUX_TRY_COMPILE, but with different arguments
291 AC_DEFUN([LB_LINUX_TRY_MAKE],
292 [LB_LINUX_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
295 # LB_LINUX_CONFIG_BIG_STACK
297 # check for big stack patch
299 AC_DEFUN([LB_LINUX_CONFIG_BIG_STACK],
300 [if test "x$ARCH_UM" = "x" -a "x$linux25" = "xno" ; then
303 LB_LINUX_CONFIG([STACK_SIZE_16KB],[],[
304 LB_LINUX_CONFIG([STACK_SIZE_32KB],[],[
305 LB_LINUX_CONFIG([STACK_SIZE_64KB],[],[
306 AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 16KB stack.])
320 AC_DEFUN([LB_PROG_LINUX],
323 LB_LINUX_CONFIG([MODULES],[],[
324 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
327 LB_LINUX_CONFIG([MODVERSIONS])
329 LB_LINUX_CONFIG([PREEMPT],[
330 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
333 LB_LINUX_CONFIG([KALLSYMS],[],[
334 if test "x$ARCH_UM" = "x" ; then
335 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
339 LB_LINUX_CONFIG([KMOD],[],[
341 AC_MSG_WARN([Kernel module loading support is highly recommended.])
345 LB_LINUX_CONFIG([CRYPTO],[],[
346 AC_MSG_ERROR([Lustre require that CONFIG_CRYPTO is enabled in your kernel.])
349 #LB_LINUX_CONFIG_BIG_STACK
358 if test "$PORTALS" ; then
364 # LB_LINUX_CONDITIONALS
366 # AM_CONDITIONALS for linux
368 AC_DEFUN([LB_LINUX_CONDITIONALS],
369 [AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)