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 CRAY_PORTALS_INCLUDE="-I$with_cray_portals"
23 AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
24 ],[with_cray_portals=no])
25 AC_MSG_RESULT([$with_cray_portals])
26 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
27 if test x$enable_tests = xno ; then
28 AC_MSG_NOTICE([disabling tests])
31 if test x$enable_utils = xno ; then
32 AC_MSG_NOTICE([disabling utilities])
36 # -------- set linuxdir ------------
37 AC_MSG_CHECKING([for Linux sources])
39 AC_HELP_STRING([--with-linux=path],
40 [set path to Linux source (default=/usr/src/linux)]),
42 [LINUX=/usr/src/linux])
43 AC_MSG_RESULT([$LINUX])
45 if test x$enable_inkernel = xyes ; then
46 echo ln -s `pwd` $LINUX/fs/lustre
48 ln -s `pwd` $LINUX/fs/lustre
51 # -------- check for .confg --------
52 AC_ARG_WITH([linux-config],
53 [AC_HELP_STRING([--with-linux-config=path],
54 [set path to Linux .conf (default=\$LINUX/.config)])],
55 [LINUX_CONFIG=$with_linux_config],
56 [LINUX_CONFIG=$LINUX/.config])
57 AC_SUBST(LINUX_CONFIG)
59 AC_CHECK_FILE([/boot/kernel.h],
60 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
61 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
62 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
64 AC_ARG_WITH([kernel-source-header],
65 AC_HELP_STRING([--with-kernel-source-header=path],
66 [Use a different kernel version header. Consult README.kernel-source for details.]),
67 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
69 # --------------------
72 if test x$enable_modules != xno ; then
73 AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
74 if test -e $LINUX/include/asm-um ; then
75 if test X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
77 # see notes in Rules.in
81 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
84 AC_MSG_RESULT([no (asm-um missing)])
89 # --------- Linux 25 ------------------
91 AC_CHECK_FILE([$LINUX/include/linux/namei.h],
99 AC_MSG_CHECKING([if you are using Linux 2.6])
100 AC_MSG_RESULT([$linux25])
101 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
104 # ------- Makeflags ------------------
106 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
108 # liblustre are all the same
109 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
112 LLCFLAGS="-g -Wall -fPIC"
115 # everyone builds against portals and lustre
117 if test x$enable_ldiskfs = xyes ; then
118 AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
119 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
120 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
121 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
124 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I$PWD/portals/include -I$PWD/include"
126 # these are like AC_TRY_COMPILE, but try to build modules against the
127 # kernel, inside the kernel-tests directory
129 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
130 [cat >conftest.c <<_ACEOF
135 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
136 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
137 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
138 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])],
140 [_AC_MSG_LOG_CONFTEST
141 m4_ifvaln([$5],[$5])dnl])dnl
142 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
145 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
146 [LUSTRE_MODULE_COMPILE_IFELSE(
147 [AC_LANG_PROGRAM([[$1]], [[$2]])],
149 [test -s kernel-tests/conftest.o],
152 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
153 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
155 # ------------ include paths ------------------
157 if test x$enable_modules != xno ; then
158 # ------------ .config exists ----------------
159 AC_CHECK_FILE([$LINUX_CONFIG],[],
160 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
162 # ----------- make dep run? ------------------
163 AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
164 $LINUX/include/linux/version.h
165 $LINUX/include/linux/config.h],[],
166 [AC_MSG_ERROR([Run make config in $LINUX.])])
168 # ------------ rhconfig.h includes runtime-generated bits --
169 # red hat kernel-source checks
171 # we know this exists after the check above. if the user
172 # tarred up the tree and ran make dep etc. in it, then
173 # version.h gets overwritten with a standard linux one.
175 if grep rhconfig $LINUX/include/linux/version.h >/dev/null ; then
176 # This is a clean kernel-source tree, we need to
177 # enable extensive workarounds to get this to build
179 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
180 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
181 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
182 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
183 AC_MSG_WARN([Consult README.kernel-source for details.])
185 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
186 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
189 # --- check that we can build modules at all
190 AC_MSG_CHECKING([that modules can be built])
191 LUSTRE_MODULE_TRY_COMPILE([],[],
196 AC_MSG_WARN([Consult config.log for details.])
197 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
198 AC_MSG_ERROR([Kernel modules could not be built.])
201 # ------------ LINUXRELEASE and moduledir ------------------
202 AC_MSG_CHECKING([for Linux release])
203 rm -f kernel-tests/conftest.i
205 if test $linux25 = 'yes' ; then
206 makerule="$PWD/kernel-tests"
208 makerule="_dir_$PWD/kernel-tests"
210 LUSTRE_MODULE_TRY_MAKE(
211 [#include <linux/version.h>],
213 LINUXRELEASE=UTS_RELEASE;],
214 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
215 [test -s kernel-tests/conftest.i],
217 # LINUXRELEASE="UTS_RELEASE"
218 eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
220 AC_MSG_RESULT([unknown])
221 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
223 rm -f kernel-tests/conftest.i
224 if test x$LINUXRELEASE = x ; then
225 AC_MSG_RESULT([unknown])
226 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
228 AC_MSG_RESULT([$LINUXRELEASE])
229 AC_SUBST(LINUXRELEASE)
231 moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
234 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
235 AC_SUBST(modulefsdir)
237 # ------------ RELEASE --------------------------------
238 AC_MSG_CHECKING([for Lustre release])
239 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
240 AC_MSG_RESULT($RELEASE)
244 # ---------- Portals flags --------------------
246 #AC_PREFIX_DEFAULT([])
247 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
250 # usrprefix='${prefix}'
254 AC_MSG_CHECKING([for zero-copy TCP support])
255 AC_ARG_ENABLE([zerocopy],
256 AC_HELP_STRING([--disable-zerocopy],
257 [disable socknal zerocopy]),
258 [],[enable_zerocopy='yes'])
259 if test x$enable_zerocopy = xno ; then
260 AC_MSG_RESULT([no (by request)])
262 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
263 if test "$ZCCD" != 0 ; then
264 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
267 AC_MSG_RESULT([no (no kernel support)])
271 AC_MSG_CHECKING([for CPU affinity support])
272 AC_ARG_ENABLE([affinity],
273 AC_HELP_STRING([--disable-affinity],
274 [disable process/irq affinity]),
275 [],[enable_affinity='yes'])
276 if test x$enable_affinity = xno ; then
277 AC_MSG_RESULT([no (by request)])
279 SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
280 if test "$SET_CPUS_ALLOW" != 0 ; then
281 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
284 AC_MSG_RESULT([no (no kernel support)])
289 #####################################
291 AC_MSG_CHECKING([if quadrics kernel headers are present])
292 if test -d $LINUX/drivers/net/qsnet ; then
295 AC_MSG_CHECKING([for multirail EKC])
296 if test -f $LINUX/include/elan/epcomms.h; then
297 AC_MSG_RESULT([supported])
298 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
300 AC_MSG_RESULT([not supported])
301 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
308 AC_SUBST(QSWCPPFLAGS)
310 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
312 AC_MSG_CHECKING([if gm support was requested])
314 AC_HELP_STRING([--with-gm=path],
315 [build gmnal against path]),
320 GMCPPFLAGS="-I/usr/local/gm/include"
330 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
341 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
343 #fixme: where are the default IB includes?
344 default_ib_include_dir=/usr/local/ib/include
345 an_ib_include_file=vapi.h
347 AC_MSG_CHECKING([if ib nal support was requested])
349 AC_HELP_STRING([--with-ib=yes/no/path],
350 [Path to IB includes]),
355 IBCPPFLAGS="-I/usr/local/ib/include"
365 IBCPPFLAGS="-I$with_ib"
376 AM_CONDITIONAL(BUILD_IBNAL, test x$IBNAL = "xibnal")
378 def_scamac=/opt/scali/include
379 AC_MSG_CHECKING([if ScaMAC support was requested])
380 AC_ARG_WITH([scamac],
381 AC_HELP_STRING([--with-scamac=yes/no/path],
382 [Path to ScaMAC includes (default=/opt/scali/include)]),
387 SCIMACCPPFLAGS="-I/opt/scali/include"
388 SCIMACNAL="scimacnal"
397 SCIMACCPPFLAGS="-I$with_scamac -I$with_scamac/icm"
398 SCIMACNAL="scimacnal"
406 AC_SUBST(SCIMACCPPFLAGS)
408 AM_CONDITIONAL(BUILD_SCIMACNAL, test x$SCIMACNAL = "xscimacnal")
409 # if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then
414 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
415 # But other kernels don't
417 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
418 LUSTRE_MODULE_TRY_COMPILE(
420 #include <linux/iobuf.h>
426 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
431 # ----------- 2.6.4 no longer has page->list ---------------
432 AC_MSG_CHECKING([if struct page has a list field])
433 LUSTRE_MODULE_TRY_COMPILE(
435 #include <linux/mm.h>
441 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
446 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
447 # This needs to run after we've defined the KCPPFLAGS
449 AC_MSG_CHECKING([for kernel version])
450 LUSTRE_MODULE_TRY_COMPILE(
452 #include <linux/sched.h>
454 struct task_struct p;
457 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
458 AC_MSG_RESULT([redhat-2.4.20])
460 AC_MSG_RESULT([$LINUXRELEASE])
463 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
465 AC_MSG_CHECKING([if kernel defines PDE])
466 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
467 if test "$HAVE_PDE" != 0 ; then
468 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
474 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
475 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
476 if test "$HAVE_DIO_FILE" != 0 ; then
477 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
483 if test x$enable_modules != xno ; then
484 # ---------- modules? ------------------------
485 AC_MSG_CHECKING([for module support])
486 LUSTRE_MODULE_TRY_COMPILE(
488 #include <linux/config.h>
490 #ifndef CONFIG_MODULES
491 #error CONFIG_MODULES not #defined
497 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
500 # ---------- modversions? --------------------
501 AC_MSG_CHECKING([for MODVERSIONS])
502 LUSTRE_MODULE_TRY_COMPILE(
504 #include <linux/config.h>
506 #ifndef CONFIG_MODVERSIONS
507 #error CONFIG_MODVERSIONS not #defined
515 # ------------ preempt -----------------------
516 AC_MSG_CHECKING([if preempt is enabled])
517 LUSTRE_MODULE_TRY_COMPILE(
519 #include <linux/config.h>
521 #ifndef CONFIG_PREEMPT
522 #error CONFIG_PREEMPT is not #defined
526 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
531 if test $BACKINGFS = 'ext3' ; then
532 # --- Check that ext3 and ext3 xattr are enabled in the kernel
533 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
534 LUSTRE_MODULE_TRY_COMPILE(
536 #include <linux/config.h>
538 #ifndef CONFIG_EXT3_FS
539 #ifndef CONFIG_EXT3_FS_MODULE
540 #error CONFIG_EXT3_FS not #defined
547 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
550 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
551 LUSTRE_MODULE_TRY_COMPILE(
553 #include <linux/config.h>
555 #ifndef CONFIG_EXT3_FS_XATTR
556 #error CONFIG_EXT3_FS_XATTR not #defined
562 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
563 AC_MSG_WARN([This build may fail.])
565 fi # BACKINGFS = ext3
568 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
569 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
570 AC_SUBST(EXTRA_KCFLAGS)
572 #echo "KCPPFLAGS: $KCPPFLAGS"
573 #echo "KCFLAGS: $KCFLAGS"
574 #echo "LLCPPFLAGS: $LLCPPFLAGS"
575 #echo "LLCFLAGS: $LLCFLAGS"
576 #echo "MOD_LINK: $MOD_LINK"
577 #echo "CFLAGS: $CFLAGS"
578 #echo "CPPFLAGS: $CPPFLAGS"