1 # -------- we can't build modules unless srcdir = builddir
2 if test x$enable_modules != xno ; then
3 AC_CHECK_FILE([autoMakefile.am],[],
4 [AC_MSG_ERROR([At this time, Lustre does not support building kernel modules with srcdir != buildir.])])
7 # -------- in kernel compilation? (2.5 only) -------------
8 AC_MSG_CHECKING([if inkernel build support is requested])
9 AC_ARG_ENABLE([inkernel],
10 AC_HELP_STRING([--enable-inkernel],
11 [set up 2.5 kernel makefiles]),
12 [],[enable_inkernel=no])
13 AC_MSG_RESULT([$enable_inkernel])
14 AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes)
16 # -------- are we building against an external portals? -------
17 AC_MSG_CHECKING([if Cray portals should be used])
18 AC_ARG_WITH([cray-portals],
19 AC_HELP_STRING([--with-cray-portals=path],
20 [path to cray portals]),
22 if test "$with_cray_portals" != no; then
23 if test -r $with_cray_portals/include/portals/api.h ; then
24 CRAY_PORTALS_INCLUDE="-I$with_cray_portals/include"
25 AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
27 AC_MSG_ERROR([--with-cray-portals specified badly])
30 ],[with_cray_portals=no])
31 AC_MSG_RESULT([$with_cray_portals])
33 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
35 # -------- enable tests and utils? -------
36 if test x$enable_tests = xno ; then
37 AC_MSG_NOTICE([disabling tests])
40 if test x$enable_utils = xno ; then
41 AC_MSG_NOTICE([disabling utilities])
45 # -------- set linuxdir ------------
46 AC_MSG_CHECKING([for Linux sources])
48 AC_HELP_STRING([--with-linux=path],
49 [set path to Linux source (default=/usr/src/linux)]),
51 [LINUX=/usr/src/linux])
52 AC_MSG_RESULT([$LINUX])
54 if test x$enable_inkernel = xyes ; then
55 echo ln -s `pwd` $LINUX/fs/lustre
57 ln -s `pwd` $LINUX/fs/lustre
60 # -------- check for .confg --------
61 AC_ARG_WITH([linux-config],
62 [AC_HELP_STRING([--with-linux-config=path],
63 [set path to Linux .conf (default=\$LINUX/.config)])],
64 [LINUX_CONFIG=$with_linux_config],
65 [LINUX_CONFIG=$LINUX/.config])
66 AC_SUBST(LINUX_CONFIG)
68 AC_CHECK_FILE([/boot/kernel.h],
69 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
70 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
71 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
73 AC_ARG_WITH([kernel-source-header],
74 AC_HELP_STRING([--with-kernel-source-header=path],
75 [Use a different kernel version header. Consult README.kernel-source for details.]),
76 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
78 # --------------------
81 if test x$enable_modules != xno ; then
82 AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
83 if test -e $LINUX/include/asm-um ; then
84 if test X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
86 # see notes in Rules.in
90 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
93 AC_MSG_RESULT([no (asm-um missing)])
98 # --------- Linux 25 ------------------
100 AC_CHECK_FILE([$LINUX/include/linux/namei.h],
108 AC_MSG_CHECKING([if you are using Linux 2.6])
109 AC_MSG_RESULT([$linux25])
110 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
113 # ------- Makeflags ------------------
115 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
117 # liblustre are all the same
118 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
121 LLCFLAGS="-g -Wall -fPIC"
124 # everyone builds against portals and lustre
126 if test x$enable_ldiskfs = xyes ; then
127 AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
128 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
129 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
130 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
133 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I$PWD/portals/include -I$PWD/include"
135 # these are like AC_TRY_COMPILE, but try to build modules against the
136 # kernel, inside the kernel-tests directory
138 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
139 [cat >conftest.c <<_ACEOF
144 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
145 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
146 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
147 AS_IF([AC_TRY_COMMAND(cp conftest.c kernel-tests && make [$2] -f $PWD/kernel-tests/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX EXTRA_CFLAGS="$EXTRA_KCFLAGS" $ARCH_UM SUBDIRS=$PWD/kernel-tests) >/dev/null && AC_TRY_COMMAND([$3])],
149 [_AC_MSG_LOG_CONFTEST
150 m4_ifvaln([$5],[$5])dnl])dnl
151 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.mod.o kernel-tests/conftest.ko m4_ifval([$1], [kernel-tests/conftest.c conftest.c])[]dnl
154 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
155 [LUSTRE_MODULE_COMPILE_IFELSE(
156 [AC_LANG_PROGRAM([[$1]], [[$2]])],
158 [test -s kernel-tests/conftest.o],
161 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
162 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
164 # ------------ include paths ------------------
166 if test x$enable_modules != xno ; then
167 # ------------ .config exists ----------------
168 AC_CHECK_FILE([$LINUX_CONFIG],[],
169 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
171 # ----------- make dep run? ------------------
172 AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
173 $LINUX/include/linux/version.h
174 $LINUX/include/linux/config.h],[],
175 [AC_MSG_ERROR([Run make config in $LINUX.])])
177 # ------------ rhconfig.h includes runtime-generated bits --
178 # red hat kernel-source checks
180 # we know this exists after the check above. if the user
181 # tarred up the tree and ran make dep etc. in it, then
182 # version.h gets overwritten with a standard linux one.
184 if grep rhconfig $LINUX/include/linux/version.h >/dev/null ; then
185 # This is a clean kernel-source tree, we need to
186 # enable extensive workarounds to get this to build
188 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
189 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
190 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
191 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
192 AC_MSG_WARN([Consult README.kernel-source for details.])
194 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
195 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
198 # --- check that we can build modules at all
199 AC_MSG_CHECKING([that modules can be built])
200 LUSTRE_MODULE_TRY_COMPILE([],[],
205 AC_MSG_WARN([Consult config.log for details.])
206 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
207 AC_MSG_ERROR([Kernel modules could not be built.])
210 # ------------ LINUXRELEASE and moduledir ------------------
211 AC_MSG_CHECKING([for Linux release])
212 rm -f kernel-tests/conftest.i
214 if test $linux25 = 'yes' ; then
215 makerule="$PWD/kernel-tests"
217 makerule="_dir_$PWD/kernel-tests"
219 LUSTRE_MODULE_TRY_MAKE(
220 [#include <linux/version.h>],
221 [LINUXRELEASE=UTS_RELEASE],
222 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
223 [test -s kernel-tests/conftest.i],
225 # LINUXRELEASE="UTS_RELEASE"
226 eval $(grep LINUXRELEASE kernel-tests/conftest.i)
228 AC_MSG_RESULT([unknown])
229 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
231 rm -f kernel-tests/conftest.i
232 if test x$LINUXRELEASE = x ; then
233 AC_MSG_RESULT([unknown])
234 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
236 AC_MSG_RESULT([$LINUXRELEASE])
237 AC_SUBST(LINUXRELEASE)
239 moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
242 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
243 AC_SUBST(modulefsdir)
245 # ------------ RELEASE --------------------------------
246 AC_MSG_CHECKING([for Lustre release])
247 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
248 AC_MSG_RESULT($RELEASE)
252 # ---------- Portals flags --------------------
254 #AC_PREFIX_DEFAULT([])
255 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
258 # usrprefix='${prefix}'
262 AC_MSG_CHECKING([for zero-copy TCP support])
263 AC_ARG_ENABLE([zerocopy],
264 AC_HELP_STRING([--disable-zerocopy],
265 [disable socknal zerocopy]),
266 [],[enable_zerocopy='yes'])
267 if test x$enable_zerocopy = xno ; then
268 AC_MSG_RESULT([no (by request)])
270 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
271 if test "$ZCCD" != 0 ; then
272 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
275 AC_MSG_RESULT([no (no kernel support)])
279 AC_MSG_CHECKING([for CPU affinity support])
280 AC_ARG_ENABLE([affinity],
281 AC_HELP_STRING([--disable-affinity],
282 [disable process/irq affinity]),
283 [],[enable_affinity='yes'])
284 if test x$enable_affinity = xno ; then
285 AC_MSG_RESULT([no (by request)])
287 SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
288 if test "$SET_CPUS_ALLOW" != 0 ; then
289 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
292 AC_MSG_RESULT([no (no kernel support)])
297 #####################################
299 AC_MSG_CHECKING([if quadrics kernel headers are present])
300 if test -d $LINUX/drivers/net/qsnet ; then
303 AC_MSG_CHECKING([for multirail EKC])
304 if test -f $LINUX/include/elan/epcomms.h; then
305 AC_MSG_RESULT([supported])
306 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
308 AC_MSG_RESULT([not supported])
309 if test -d $LINUX/drivers/net/qsnet/include; then
310 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
312 QSWCPPFLAGS="-I$LINUX/include/linux"
320 AC_SUBST(QSWCPPFLAGS)
322 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
324 AC_MSG_CHECKING([if gm support was requested])
326 AC_HELP_STRING([--with-gm=path],
327 [build gmnal against path]),
332 GMCPPFLAGS="-I/usr/local/gm/include"
342 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
353 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
355 #fixme: where are the default IB includes?
356 default_ib_include_dir=/usr/local/ib/include
357 an_ib_include_file=vapi.h
359 AC_MSG_CHECKING([if ib nal support was requested])
361 AC_HELP_STRING([--with-ib=yes/no/path],
362 [Path to IB includes]),
367 IBCPPFLAGS="-I/usr/local/ib/include"
377 IBCPPFLAGS="-I$with_ib"
388 AM_CONDITIONAL(BUILD_IBNAL, test x$IBNAL = "xibnal")
393 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
394 # But other kernels don't
396 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
397 LUSTRE_MODULE_TRY_COMPILE(
399 #include <linux/iobuf.h>
405 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
410 # ----------- 2.6.4 no longer has page->list ---------------
411 AC_MSG_CHECKING([if struct page has a list field])
412 LUSTRE_MODULE_TRY_COMPILE(
414 #include <linux/mm.h>
420 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
425 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
426 # This needs to run after we've defined the KCPPFLAGS
428 AC_MSG_CHECKING([for kernel version])
429 LUSTRE_MODULE_TRY_COMPILE(
431 #include <linux/sched.h>
433 struct task_struct p;
436 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
437 AC_MSG_RESULT([redhat-2.4.20])
439 AC_MSG_RESULT([$LINUXRELEASE])
442 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
444 AC_MSG_CHECKING([if kernel defines PDE])
445 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
446 if test "$HAVE_PDE" != 0 ; then
447 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
453 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
454 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
455 if test "$HAVE_DIO_FILE" != 0 ; then
456 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
462 if test x$enable_modules != xno ; then
463 # ---------- modules? ------------------------
464 AC_MSG_CHECKING([for module support])
465 LUSTRE_MODULE_TRY_COMPILE(
467 #include <linux/config.h>
469 #ifndef CONFIG_MODULES
470 #error CONFIG_MODULES not #defined
476 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
479 # ---------- modversions? --------------------
480 AC_MSG_CHECKING([for MODVERSIONS])
481 LUSTRE_MODULE_TRY_COMPILE(
483 #include <linux/config.h>
485 #ifndef CONFIG_MODVERSIONS
486 #error CONFIG_MODVERSIONS not #defined
494 # ------------ preempt -----------------------
495 AC_MSG_CHECKING([if preempt is enabled])
496 LUSTRE_MODULE_TRY_COMPILE(
498 #include <linux/config.h>
500 #ifndef CONFIG_PREEMPT
501 #error CONFIG_PREEMPT is not #defined
505 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
510 if test $BACKINGFS = 'ext3' ; then
511 # --- Check that ext3 and ext3 xattr are enabled in the kernel
512 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
513 LUSTRE_MODULE_TRY_COMPILE(
515 #include <linux/config.h>
517 #ifndef CONFIG_EXT3_FS
518 #ifndef CONFIG_EXT3_FS_MODULE
519 #error CONFIG_EXT3_FS not #defined
526 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
529 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
530 LUSTRE_MODULE_TRY_COMPILE(
532 #include <linux/config.h>
534 #ifndef CONFIG_EXT3_FS_XATTR
535 #error CONFIG_EXT3_FS_XATTR not #defined
541 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
542 AC_MSG_WARN([This build may fail.])
544 fi # BACKINGFS = ext3
547 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
548 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
549 AC_SUBST(EXTRA_KCFLAGS)
551 #echo "KCPPFLAGS: $KCPPFLAGS"
552 #echo "KCFLAGS: $KCFLAGS"
553 #echo "LLCPPFLAGS: $LLCPPFLAGS"
554 #echo "LLCFLAGS: $LLCFLAGS"
555 #echo "MOD_LINK: $MOD_LINK"
556 #echo "CFLAGS: $CFLAGS"
557 #echo "CPPFLAGS: $CPPFLAGS"