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_PATH=$with_cray_portals
25 CRAY_PORTALS_INCLUDE="-I$with_cray_portals/include"
26 AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
28 AC_MSG_ERROR([--with-cray-portals specified badly])
31 ],[with_cray_portals=no])
32 AC_SUBST(CRAY_PORTALS_PATH)
33 AC_MSG_RESULT([$with_cray_portals])
35 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
37 # -------- enable tests and utils? -------
38 if test x$enable_tests = xno ; then
39 AC_MSG_NOTICE([disabling tests])
42 if test x$enable_utils = xno ; then
43 AC_MSG_NOTICE([disabling utilities])
47 if test x$enable_modules != xno ; then
48 # -------- set linuxdir ------------
49 AC_MSG_CHECKING([for Linux sources])
51 AC_HELP_STRING([--with-linux=path],
52 [set path to Linux source (default=/usr/src/linux)]),
54 [LINUX=/usr/src/linux])
55 AC_MSG_RESULT([$LINUX])
57 if test x$enable_inkernel = xyes ; then
58 echo ln -s `pwd` $LINUX/fs/lustre
60 ln -s `pwd` $LINUX/fs/lustre
63 # -------- check for .confg --------
64 AC_ARG_WITH([linux-config],
65 [AC_HELP_STRING([--with-linux-config=path],
66 [set path to Linux .conf (default=\$LINUX/.config)])],
67 [LINUX_CONFIG=$with_linux_config],
68 [LINUX_CONFIG=$LINUX/.config])
69 AC_SUBST(LINUX_CONFIG)
71 AC_CHECK_FILE([/boot/kernel.h],
72 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
73 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
74 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
76 AC_ARG_WITH([kernel-source-header],
77 AC_HELP_STRING([--with-kernel-source-header=path],
78 [Use a different kernel version header. Consult README.kernel-source for details.]),
79 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
81 # --------------------
85 AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
86 if test -e $LINUX/include/asm-um ; then
87 if test X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
89 # see notes in Rules.in
93 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
96 AC_MSG_RESULT([no (asm-um missing)])
102 # --------- Linux 25 ------------------
103 AC_CHECK_FILE([$LINUX/include/linux/namei.h],
113 AC_MSG_CHECKING([if you are using Linux 2.6])
114 AC_MSG_RESULT([$linux25])
119 AC_PATH_PROG(PATCH, patch, [no])
120 AC_PATH_PROG(QUILT, quilt, [no])
122 if test x$enable_ldiskfs$PATCH$QUILT = xyesnono ; then
123 AC_MSG_ERROR([Quilt or patch are needed to build the ldiskfs module (for Linux 2.6)])
126 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
127 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
129 # ------- Makeflags ------------------
131 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
133 # liblustre are all the same
134 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
137 LLCFLAGS="-g -Wall -fPIC"
140 # everyone builds against portals and lustre
142 if test x$enable_ldiskfs = xyes ; then
143 AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
144 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
145 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
146 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
149 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I$PWD/portals/include -I$PWD/include"
151 # these are like AC_TRY_COMPILE, but try to build modules against the
152 # kernel, inside the kernel-tests directory
154 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
155 [cat >conftest.c <<_ACEOF
160 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
161 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
162 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
163 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])],
165 [_AC_MSG_LOG_CONFTEST
166 m4_ifvaln([$5],[$5])dnl])dnl
167 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
170 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
171 [LUSTRE_MODULE_COMPILE_IFELSE(
172 [AC_LANG_PROGRAM([[$1]], [[$2]])],
174 [test -s kernel-tests/conftest.o],
177 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
178 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
180 # ------------ include paths ------------------
182 if test x$enable_modules != xno ; then
183 # ------------ .config exists ----------------
184 AC_CHECK_FILE([$LINUX_CONFIG],[],
185 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
187 # ----------- make dep run? ------------------
188 AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
189 $LINUX/include/linux/version.h
190 $LINUX/include/linux/config.h],[],
191 [AC_MSG_ERROR([Run make config in $LINUX.])])
193 # ------------ rhconfig.h includes runtime-generated bits --
194 # red hat kernel-source checks
196 # we know this exists after the check above. if the user
197 # tarred up the tree and ran make dep etc. in it, then
198 # version.h gets overwritten with a standard linux one.
200 if grep rhconfig $LINUX/include/linux/version.h >/dev/null ; then
201 # This is a clean kernel-source tree, we need to
202 # enable extensive workarounds to get this to build
204 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
205 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
206 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
207 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
208 AC_MSG_WARN([Consult README.kernel-source for details.])
210 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
211 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
214 # --- check that we can build modules at all
215 AC_MSG_CHECKING([that modules can be built])
216 LUSTRE_MODULE_TRY_COMPILE([],[],
221 AC_MSG_WARN([Consult config.log for details.])
222 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
223 AC_MSG_ERROR([Kernel modules could not be built.])
226 # ------------ LINUXRELEASE and moduledir ------------------
227 MODULE_TARGET="SUBDIRS"
228 if test $linux25 = 'yes' ; then
229 # ------------ external module support ---------------------
230 makerule="$PWD/kernel-tests"
231 AC_MSG_CHECKING([for external module build support])
232 rm -f kernel-tests/conftest.i
233 LUSTRE_MODULE_TRY_MAKE([],[],
234 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
235 [test -s kernel-tests/conftest.i],
240 makerule="_module_$makerule"
244 makerule="_dir_$PWD/kernel-tests"
246 AC_SUBST(MODULE_TARGET)
248 rm -f kernel-tests/conftest.i
249 AC_MSG_CHECKING([for Linux release])
250 LUSTRE_MODULE_TRY_MAKE(
251 [#include <linux/version.h>],
253 LINUXRELEASE=UTS_RELEASE;],
254 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
255 [test -s kernel-tests/conftest.i],
257 # LINUXRELEASE="UTS_RELEASE"
258 eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
260 AC_MSG_RESULT([unknown])
261 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
263 rm -f kernel-tests/conftest.i
264 if test x$LINUXRELEASE = x ; then
265 AC_MSG_RESULT([unknown])
266 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
268 AC_MSG_RESULT([$LINUXRELEASE])
269 AC_SUBST(LINUXRELEASE)
271 moduledir='/lib/modules/'$LINUXRELEASE/kernel
272 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
273 modulenetdir='$(moduledir)/net/$(PACKAGE)'
276 AC_SUBST(modulefsdir)
277 AC_SUBST(modulenetdir)
279 # ------------ RELEASE --------------------------------
280 AC_MSG_CHECKING([for Lustre release])
281 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
282 AC_MSG_RESULT($RELEASE)
285 # ---------- Portals flags --------------------
287 AC_MSG_CHECKING([for zero-copy TCP support])
288 AC_ARG_ENABLE([zerocopy],
289 AC_HELP_STRING([--disable-zerocopy],
290 [disable socknal zerocopy]),
291 [],[enable_zerocopy='yes'])
292 if test x$enable_zerocopy = xno ; then
293 AC_MSG_RESULT([no (by request)])
295 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
296 if test "$ZCCD" != 0 ; then
297 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
300 AC_MSG_RESULT([no (no kernel support)])
304 AC_ARG_ENABLE([affinity],
305 AC_HELP_STRING([--disable-affinity],
306 [disable process/irq affinity]),
307 [],[enable_affinity='yes'])
309 AC_MSG_CHECKING([for CPU affinity support])
310 if test x$enable_affinity = xno ; then
311 AC_MSG_RESULT([no (by request)])
313 LUSTRE_MODULE_TRY_COMPILE(
315 #include <linux/sched.h>
317 struct task_struct t;
318 #ifdef CPU_ARRAY_SIZE
323 set_cpus_allowed(&t, m);
325 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
328 AC_MSG_RESULT([no (no kernel support)])
332 #####################################
334 AC_MSG_CHECKING([if quadrics kernel headers are present])
335 if test -d $LINUX/drivers/net/qsnet ; then
338 AC_MSG_CHECKING([for multirail EKC])
339 if test -f $LINUX/include/elan/epcomms.h; then
340 AC_MSG_RESULT([supported])
341 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
343 AC_MSG_RESULT([not supported])
344 if test -d $LINUX/drivers/net/qsnet/include; then
345 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
347 QSWCPPFLAGS="-I$LINUX/include/linux"
355 AC_SUBST(QSWCPPFLAGS)
358 AC_MSG_CHECKING([if gm support was requested])
360 AC_HELP_STRING([--with-gm=path],
361 [build gmnal against path]),
366 GMCPPFLAGS="-I/usr/local/gm/include"
376 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
389 AC_MSG_CHECKING([if OpenIB kernel headers are present])
390 OPENIBCPPFLAGS="-I$LINUX/drivers/infiniband/include -DIN_TREE_BUILD"
391 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
392 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
393 LUSTRE_MODULE_TRY_COMPILE(
395 #include <ts_ib_core.h>
397 struct ib_device_properties props;
401 OPENIBNAL="openibnal"
407 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
408 AC_SUBST(OPENIBCPPFLAGS)
411 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
412 # But other kernels don't
414 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
415 LUSTRE_MODULE_TRY_COMPILE(
417 #include <linux/iobuf.h>
423 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
428 # ----------- 2.6.4 no longer has page->list ---------------
429 AC_MSG_CHECKING([if struct page has a list field])
430 LUSTRE_MODULE_TRY_COMPILE(
432 #include <linux/mm.h>
438 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
443 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
444 # This needs to run after we've defined the KCPPFLAGS
446 AC_MSG_CHECKING([if task_struct has a sighand field])
447 LUSTRE_MODULE_TRY_COMPILE(
449 #include <linux/sched.h>
451 struct task_struct p;
454 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
460 # ---------- 2.4.20 introduced cond_resched --------------
462 AC_MSG_CHECKING([if kernel offers cond_resched])
463 LUSTRE_MODULE_TRY_COMPILE(
465 #include <linux/sched.h>
470 AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
475 # --------- zap_page_range(vma) --------------------------------
476 AC_MSG_CHECKING([if zap_pag_range with vma parameter])
477 ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
478 if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
479 AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
485 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
487 AC_MSG_CHECKING([if kernel defines PDE])
488 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
489 if test "$HAVE_PDE" != 0 ; then
490 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
496 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
497 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
498 if test "$HAVE_DIO_FILE" != 0 ; then
499 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
505 AC_MSG_CHECKING([if kernel defines cpu_online()])
506 LUSTRE_MODULE_TRY_COMPILE(
508 #include <linux/sched.h>
513 AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
517 AC_MSG_CHECKING([if kernel defines cpumask_t])
518 LUSTRE_MODULE_TRY_COMPILE(
520 #include <linux/sched.h>
522 return sizeof (cpumask_t);
525 AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
530 # ---------- RHEL kernels define page_count in mm_inline.h
531 AC_MSG_CHECKING([if kernel has mm_inline.h header])
532 LUSTRE_MODULE_TRY_COMPILE(
534 #include <linux/mm_inline.h>
537 #error mm_inline.h does not define page_count
541 AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
546 # ---------- inode->i_alloc_sem --------------
547 AC_MSG_CHECKING([if struct inode has i_alloc_sem])
548 LUSTRE_MODULE_TRY_COMPILE(
550 #include <linux/fs.h>
551 #include <linux/version.h>
553 #if defined(CONFIG_X86_64) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
554 #error "x86_64 down_read_trylock broken before 2.4.24"
557 return (char *)&i.i_alloc_sem - (char *)&i;
560 AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
566 # ---------- modules? ------------------------
567 AC_MSG_CHECKING([for module support])
568 LUSTRE_MODULE_TRY_COMPILE(
570 #include <linux/config.h>
572 #ifndef CONFIG_MODULES
573 #error CONFIG_MODULES not #defined
579 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
582 # ---------- modversions? --------------------
583 AC_MSG_CHECKING([for MODVERSIONS])
584 LUSTRE_MODULE_TRY_COMPILE(
586 #include <linux/config.h>
588 #ifndef CONFIG_MODVERSIONS
589 #error CONFIG_MODVERSIONS not #defined
597 # ------------ preempt -----------------------
598 AC_MSG_CHECKING([if preempt is enabled])
599 LUSTRE_MODULE_TRY_COMPILE(
601 #include <linux/config.h>
603 #ifndef CONFIG_PREEMPT
604 #error CONFIG_PREEMPT is not #defined
608 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
615 # --- Check that ext3 and ext3 xattr are enabled in the kernel
616 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
617 LUSTRE_MODULE_TRY_COMPILE(
619 #include <linux/config.h>
621 #ifndef CONFIG_EXT3_FS
622 #ifndef CONFIG_EXT3_FS_MODULE
623 #error CONFIG_EXT3_FS not #defined
630 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
633 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
634 LUSTRE_MODULE_TRY_COMPILE(
636 #include <linux/config.h>
638 #ifndef CONFIG_EXT3_FS_XATTR
639 #error CONFIG_EXT3_FS_XATTR not #defined
645 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
646 AC_MSG_WARN([This build may fail.])
650 AC_MSG_CHECKING([if fshooks are present])
651 LUSTRE_MODULE_TRY_COMPILE(
653 #include <linux/fshooks.h>
656 LDISKFS_SERIES="2.6-suse.series"
659 LDISKFS_SERIES="2.6-vanilla.series"
661 AC_SUBST(LDISKFS_SERIES)
662 # --- check which ldiskfs series we should use
667 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
668 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
669 AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
671 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
672 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
673 AC_SUBST(EXTRA_KCFLAGS)
675 #echo "KCPPFLAGS: $KCPPFLAGS"
676 #echo "KCFLAGS: $KCFLAGS"
677 #echo "LLCPPFLAGS: $LLCPPFLAGS"
678 #echo "LLCFLAGS: $LLCFLAGS"
679 #echo "MOD_LINK: $MOD_LINK"
680 #echo "CFLAGS: $CFLAGS"
681 #echo "CPPFLAGS: $CPPFLAGS"