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],
100 AC_MSG_CHECKING([if you are using Linux 2.6])
101 AC_MSG_RESULT([$linux25])
102 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
105 AC_PATH_PROG(PATCH, patch, [no])
106 AC_PATH_PROG(QUILT, quilt, [no])
107 AM_CONDITIONAL(USE_QUILT, test x$QUILT = xno)
109 if test x$enable_ldiskfs$enable_modules = xyesyes ; then
110 if test x$PATCH$QUILT = xnono ; then
111 AC_MSG_ERROR([Quilt or patch are needed to build the ldiskfs module (for Linux 2.6)])
115 # ------- Makeflags ------------------
117 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
119 # liblustre are all the same
120 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
123 LLCFLAGS="-g -Wall -fPIC"
126 # everyone builds against portals and lustre
128 if test x$enable_ldiskfs = xyes ; then
129 AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
130 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
131 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
132 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
135 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I$PWD/portals/include -I$PWD/include"
137 # these are like AC_TRY_COMPILE, but try to build modules against the
138 # kernel, inside the kernel-tests directory
140 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
141 [cat >conftest.c <<_ACEOF
146 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
147 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
148 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
149 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])],
151 [_AC_MSG_LOG_CONFTEST
152 m4_ifvaln([$5],[$5])dnl])dnl
153 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
156 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
157 [LUSTRE_MODULE_COMPILE_IFELSE(
158 [AC_LANG_PROGRAM([[$1]], [[$2]])],
160 [test -s kernel-tests/conftest.o],
163 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
164 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
166 # ------------ include paths ------------------
168 if test x$enable_modules != xno ; then
169 # ------------ .config exists ----------------
170 AC_CHECK_FILE([$LINUX_CONFIG],[],
171 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
173 # ----------- make dep run? ------------------
174 AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
175 $LINUX/include/linux/version.h
176 $LINUX/include/linux/config.h],[],
177 [AC_MSG_ERROR([Run make config in $LINUX.])])
179 # ------------ rhconfig.h includes runtime-generated bits --
180 # red hat kernel-source checks
182 # we know this exists after the check above. if the user
183 # tarred up the tree and ran make dep etc. in it, then
184 # version.h gets overwritten with a standard linux one.
186 if grep rhconfig $LINUX/include/linux/version.h >/dev/null ; then
187 # This is a clean kernel-source tree, we need to
188 # enable extensive workarounds to get this to build
190 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
191 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
192 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
193 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
194 AC_MSG_WARN([Consult README.kernel-source for details.])
196 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
197 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
200 # --- check that we can build modules at all
201 AC_MSG_CHECKING([that modules can be built])
202 LUSTRE_MODULE_TRY_COMPILE([],[],
207 AC_MSG_WARN([Consult config.log for details.])
208 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
209 AC_MSG_ERROR([Kernel modules could not be built.])
212 # ------------ LINUXRELEASE and moduledir ------------------
213 AC_MSG_CHECKING([for Linux release])
214 rm -f kernel-tests/conftest.i
216 if test $linux25 = 'yes' ; then
217 makerule="$PWD/kernel-tests"
219 makerule="_dir_$PWD/kernel-tests"
221 LUSTRE_MODULE_TRY_MAKE(
222 [#include <linux/version.h>],
224 LINUXRELEASE=UTS_RELEASE;],
225 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
226 [test -s kernel-tests/conftest.i],
228 # LINUXRELEASE="UTS_RELEASE"
229 eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
231 AC_MSG_RESULT([unknown])
232 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
234 rm -f kernel-tests/conftest.i
235 if test x$LINUXRELEASE = x ; then
236 AC_MSG_RESULT([unknown])
237 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
239 AC_MSG_RESULT([$LINUXRELEASE])
240 AC_SUBST(LINUXRELEASE)
242 moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
245 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
246 AC_SUBST(modulefsdir)
248 # ------------ RELEASE --------------------------------
249 AC_MSG_CHECKING([for Lustre release])
250 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
251 AC_MSG_RESULT($RELEASE)
255 # ---------- Portals flags --------------------
257 #AC_PREFIX_DEFAULT([])
258 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
261 # usrprefix='${prefix}'
265 AC_MSG_CHECKING([for zero-copy TCP support])
266 AC_ARG_ENABLE([zerocopy],
267 AC_HELP_STRING([--disable-zerocopy],
268 [disable socknal zerocopy]),
269 [],[enable_zerocopy='yes'])
270 if test x$enable_zerocopy = xno ; then
271 AC_MSG_RESULT([no (by request)])
273 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
274 if test "$ZCCD" != 0 ; then
275 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
278 AC_MSG_RESULT([no (no kernel support)])
282 AC_MSG_CHECKING([for CPU affinity support])
283 AC_ARG_ENABLE([affinity],
284 AC_HELP_STRING([--disable-affinity],
285 [disable process/irq affinity]),
286 [],[enable_affinity='yes'])
287 if test x$enable_affinity = xno ; then
288 AC_MSG_RESULT([no (by request)])
290 SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
291 if test "$SET_CPUS_ALLOW" != 0 ; then
292 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
295 AC_MSG_RESULT([no (no kernel support)])
300 #####################################
302 AC_MSG_CHECKING([if quadrics kernel headers are present])
303 if test -d $LINUX/drivers/net/qsnet ; then
306 AC_MSG_CHECKING([for multirail EKC])
307 if test -f $LINUX/include/elan/epcomms.h; then
308 AC_MSG_RESULT([supported])
309 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
311 AC_MSG_RESULT([not supported])
312 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
319 AC_SUBST(QSWCPPFLAGS)
321 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
323 AC_MSG_CHECKING([if gm support was requested])
325 AC_HELP_STRING([--with-gm=path],
326 [build gmnal against path]),
331 GMCPPFLAGS="-I/usr/local/gm/include"
341 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
352 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
354 #fixme: where are the default IB includes?
355 default_ib_include_dir=/usr/local/ib/include
356 an_ib_include_file=vapi.h
358 AC_MSG_CHECKING([if ib nal support was requested])
360 AC_HELP_STRING([--with-ib=yes/no/path],
361 [Path to IB includes]),
366 IBCPPFLAGS="-I/usr/local/ib/include"
376 IBCPPFLAGS="-I$with_ib"
387 AM_CONDITIONAL(BUILD_IBNAL, test x$IBNAL = "xibnal")
389 def_scamac=/opt/scali/include
390 AC_MSG_CHECKING([if ScaMAC support was requested])
391 AC_ARG_WITH([scamac],
392 AC_HELP_STRING([--with-scamac=yes/no/path],
393 [Path to ScaMAC includes (default=/opt/scali/include)]),
398 SCIMACCPPFLAGS="-I/opt/scali/include"
399 SCIMACNAL="scimacnal"
408 SCIMACCPPFLAGS="-I$with_scamac -I$with_scamac/icm"
409 SCIMACNAL="scimacnal"
417 AC_SUBST(SCIMACCPPFLAGS)
419 AM_CONDITIONAL(BUILD_SCIMACNAL, test x$SCIMACNAL = "xscimacnal")
420 # if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then
425 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
426 # But other kernels don't
428 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
429 LUSTRE_MODULE_TRY_COMPILE(
431 #include <linux/iobuf.h>
437 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
442 # ----------- 2.6.4 no longer has page->list ---------------
443 AC_MSG_CHECKING([if struct page has a list field])
444 LUSTRE_MODULE_TRY_COMPILE(
446 #include <linux/mm.h>
452 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
457 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
458 # This needs to run after we've defined the KCPPFLAGS
460 AC_MSG_CHECKING([if task_struct has a sighand field])
461 LUSTRE_MODULE_TRY_COMPILE(
463 #include <linux/sched.h>
465 struct task_struct p;
468 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
474 # ---------- 2.4.20 introduced cond_resched --------------
476 AC_MSG_CHECKING([if kernel offers cond_resched])
477 LUSTRE_MODULE_TRY_COMPILE(
479 #include <linux/sched.h>
484 AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
489 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
491 AC_MSG_CHECKING([if kernel defines PDE])
492 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
493 if test "$HAVE_PDE" != 0 ; then
494 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
500 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
501 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
502 if test "$HAVE_DIO_FILE" != 0 ; then
503 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
509 if test x$enable_modules != xno ; then
510 # ---------- modules? ------------------------
511 AC_MSG_CHECKING([for module support])
512 LUSTRE_MODULE_TRY_COMPILE(
514 #include <linux/config.h>
516 #ifndef CONFIG_MODULES
517 #error CONFIG_MODULES not #defined
523 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
526 # ---------- modversions? --------------------
527 AC_MSG_CHECKING([for MODVERSIONS])
528 LUSTRE_MODULE_TRY_COMPILE(
530 #include <linux/config.h>
532 #ifndef CONFIG_MODVERSIONS
533 #error CONFIG_MODVERSIONS not #defined
541 # ------------ preempt -----------------------
542 AC_MSG_CHECKING([if preempt is enabled])
543 LUSTRE_MODULE_TRY_COMPILE(
545 #include <linux/config.h>
547 #ifndef CONFIG_PREEMPT
548 #error CONFIG_PREEMPT is not #defined
552 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
557 if test $BACKINGFS = 'ext3' ; then
558 # --- Check that ext3 and ext3 xattr are enabled in the kernel
559 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
560 LUSTRE_MODULE_TRY_COMPILE(
562 #include <linux/config.h>
564 #ifndef CONFIG_EXT3_FS
565 #ifndef CONFIG_EXT3_FS_MODULE
566 #error CONFIG_EXT3_FS not #defined
573 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
576 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
577 LUSTRE_MODULE_TRY_COMPILE(
579 #include <linux/config.h>
581 #ifndef CONFIG_EXT3_FS_XATTR
582 #error CONFIG_EXT3_FS_XATTR not #defined
588 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
589 AC_MSG_WARN([This build may fail.])
591 fi # BACKINGFS = ext3
594 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
595 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
596 AC_SUBST(EXTRA_KCFLAGS)
598 #echo "KCPPFLAGS: $KCPPFLAGS"
599 #echo "KCFLAGS: $KCFLAGS"
600 #echo "LLCPPFLAGS: $LLCPPFLAGS"
601 #echo "LLCFLAGS: $LLCFLAGS"
602 #echo "MOD_LINK: $MOD_LINK"
603 #echo "CFLAGS: $CFLAGS"
604 #echo "CPPFLAGS: $CPPFLAGS"