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="-Werror-implicit-function-declaration $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>],
222 LINUXRELEASE=UTS_RELEASE;],
223 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
224 [test -s kernel-tests/conftest.i],
226 # LINUXRELEASE="UTS_RELEASE"
227 eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
229 AC_MSG_RESULT([unknown])
230 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
232 rm -f kernel-tests/conftest.i
233 if test x$LINUXRELEASE = x ; then
234 AC_MSG_RESULT([unknown])
235 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
237 AC_MSG_RESULT([$LINUXRELEASE])
238 AC_SUBST(LINUXRELEASE)
240 moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
243 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
244 AC_SUBST(modulefsdir)
246 # ------------ RELEASE --------------------------------
247 AC_MSG_CHECKING([for Lustre release])
248 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
249 AC_MSG_RESULT($RELEASE)
253 # ---------- Portals flags --------------------
255 #AC_PREFIX_DEFAULT([])
256 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
259 # usrprefix='${prefix}'
263 AC_MSG_CHECKING([for zero-copy TCP support])
264 AC_ARG_ENABLE([zerocopy],
265 AC_HELP_STRING([--disable-zerocopy],
266 [disable socknal zerocopy]),
267 [],[enable_zerocopy='yes'])
268 if test x$enable_zerocopy = xno ; then
269 AC_MSG_RESULT([no (by request)])
271 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
272 if test "$ZCCD" != 0 ; then
273 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
276 AC_MSG_RESULT([no (no kernel support)])
280 AC_MSG_CHECKING([for CPU affinity support])
281 AC_ARG_ENABLE([affinity],
282 AC_HELP_STRING([--disable-affinity],
283 [disable process/irq affinity]),
284 [],[enable_affinity='yes'])
285 if test x$enable_affinity = xno ; then
286 AC_MSG_RESULT([no (by request)])
288 SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
289 if test "$SET_CPUS_ALLOW" != 0 ; then
290 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
293 AC_MSG_RESULT([no (no kernel support)])
298 #####################################
300 AC_MSG_CHECKING([if quadrics kernel headers are present])
301 if test -d $LINUX/drivers/net/qsnet ; then
304 AC_MSG_CHECKING([for multirail EKC])
305 if test -f $LINUX/include/elan/epcomms.h; then
306 AC_MSG_RESULT([supported])
307 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
309 AC_MSG_RESULT([not supported])
310 if test -d $LINUX/drivers/net/qsnet/include; then
311 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
313 QSWCPPFLAGS="-I$LINUX/include/linux"
321 AC_SUBST(QSWCPPFLAGS)
323 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
325 AC_MSG_CHECKING([if gm support was requested])
327 AC_HELP_STRING([--with-gm=path],
328 [build gmnal against path]),
333 GMCPPFLAGS="-I/usr/local/gm/include"
343 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
354 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
356 #fixme: where are the default IB includes?
357 default_ib_include_dir=/usr/local/ib/include
358 an_ib_include_file=vapi.h
360 AC_MSG_CHECKING([if ib nal support was requested])
362 AC_HELP_STRING([--with-ib=yes/no/path],
363 [Path to IB includes]),
368 IBCPPFLAGS="-I/usr/local/ib/include"
378 IBCPPFLAGS="-I$with_ib"
389 AM_CONDITIONAL(BUILD_IBNAL, test x$IBNAL = "xibnal")
394 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
395 # But other kernels don't
397 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
398 LUSTRE_MODULE_TRY_COMPILE(
400 #include <linux/iobuf.h>
406 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
411 # ----------- 2.6.4 no longer has page->list ---------------
412 AC_MSG_CHECKING([if struct page has a list field])
413 LUSTRE_MODULE_TRY_COMPILE(
415 #include <linux/mm.h>
421 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
426 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
427 # This needs to run after we've defined the KCPPFLAGS
429 AC_MSG_CHECKING([for kernel version])
430 LUSTRE_MODULE_TRY_COMPILE(
432 #include <linux/sched.h>
434 struct task_struct p;
437 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
438 AC_MSG_RESULT([redhat-2.4.20])
440 AC_MSG_RESULT([$LINUXRELEASE])
443 # ---------- 2.4.20 introduced cond_resched --------------
445 AC_MSG_CHECKING([if kernel offers cond_resched])
446 LUSTRE_MODULE_TRY_COMPILE(
448 #include <linux/sched.h>
453 AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
457 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
459 AC_MSG_CHECKING([if kernel defines PDE])
460 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
461 if test "$HAVE_PDE" != 0 ; then
462 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
468 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
469 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
470 if test "$HAVE_DIO_FILE" != 0 ; then
471 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
477 if test x$enable_modules != xno ; then
478 # ---------- modules? ------------------------
479 AC_MSG_CHECKING([for module support])
480 LUSTRE_MODULE_TRY_COMPILE(
482 #include <linux/config.h>
484 #ifndef CONFIG_MODULES
485 #error CONFIG_MODULES not #defined
491 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
494 # ---------- modversions? --------------------
495 AC_MSG_CHECKING([for MODVERSIONS])
496 LUSTRE_MODULE_TRY_COMPILE(
498 #include <linux/config.h>
500 #ifndef CONFIG_MODVERSIONS
501 #error CONFIG_MODVERSIONS not #defined
509 # ------------ preempt -----------------------
510 AC_MSG_CHECKING([if preempt is enabled])
511 LUSTRE_MODULE_TRY_COMPILE(
513 #include <linux/config.h>
515 #ifndef CONFIG_PREEMPT
516 #error CONFIG_PREEMPT is not #defined
520 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
525 if test $BACKINGFS = 'ext3' ; then
526 # --- Check that ext3 and ext3 xattr are enabled in the kernel
527 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
528 LUSTRE_MODULE_TRY_COMPILE(
530 #include <linux/config.h>
532 #ifndef CONFIG_EXT3_FS
533 #ifndef CONFIG_EXT3_FS_MODULE
534 #error CONFIG_EXT3_FS not #defined
541 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
544 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
545 LUSTRE_MODULE_TRY_COMPILE(
547 #include <linux/config.h>
549 #ifndef CONFIG_EXT3_FS_XATTR
550 #error CONFIG_EXT3_FS_XATTR not #defined
556 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
557 AC_MSG_WARN([This build may fail.])
559 fi # BACKINGFS = ext3
562 # ---------- check ->lookup_raw() support --------
564 AC_MSG_CHECKING([if kernel supports ->lookup_raw()])
565 HAVE_LOOKUP_RAW="`grep -c 'lookup_raw.*struct inode' $LINUX/include/linux/fs.h`"
566 if test "$HAVE_LOOKUP_RAW" != 0 ; then
567 AC_DEFINE(HAVE_LOOKUP_RAW, 1, [the kernel supports ->lookup_raw()])
573 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
574 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
575 AC_SUBST(EXTRA_KCFLAGS)
577 #echo "KCPPFLAGS: $KCPPFLAGS"
578 #echo "KCFLAGS: $KCFLAGS"
579 #echo "LLCPPFLAGS: $LLCPPFLAGS"
580 #echo "LLCFLAGS: $LLCFLAGS"
581 #echo "MOD_LINK: $MOD_LINK"
582 #echo "CFLAGS: $CFLAGS"
583 #echo "CPPFLAGS: $CPPFLAGS"