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 if test x$enable_modules != xno ; then
37 # -------- set linuxdir ------------
38 AC_MSG_CHECKING([for Linux sources])
40 AC_HELP_STRING([--with-linux=path],
41 [set path to Linux source (default=/usr/src/linux)]),
43 [LINUX=/usr/src/linux])
44 AC_MSG_RESULT([$LINUX])
46 if test x$enable_inkernel = xyes ; then
47 echo ln -s `pwd` $LINUX/fs/lustre
49 ln -s `pwd` $LINUX/fs/lustre
52 # -------- check for .confg --------
53 AC_ARG_WITH([linux-config],
54 [AC_HELP_STRING([--with-linux-config=path],
55 [set path to Linux .conf (default=\$LINUX/.config)])],
56 [LINUX_CONFIG=$with_linux_config],
57 [LINUX_CONFIG=$LINUX/.config])
58 AC_SUBST(LINUX_CONFIG)
60 AC_CHECK_FILE([/boot/kernel.h],
61 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
62 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
63 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
65 AC_ARG_WITH([kernel-source-header],
66 AC_HELP_STRING([--with-kernel-source-header=path],
67 [Use a different kernel version header. Consult README.kernel-source for details.]),
68 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
70 # --------------------
74 AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
75 if test -e $LINUX/include/asm-um ; then
76 if test X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
78 # see notes in Rules.in
82 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
85 AC_MSG_RESULT([no (asm-um missing)])
91 # --------- Linux 25 ------------------
92 AC_CHECK_FILE([$LINUX/include/linux/namei.h],
102 AC_MSG_CHECKING([if you are using Linux 2.6])
103 AC_MSG_RESULT([$linux25])
108 AC_PATH_PROG(PATCH, patch, [no])
109 AC_PATH_PROG(QUILT, quilt, [no])
111 if test x$enable_ldiskfs$PATCH$QUILT = xyesnono ; then
112 AC_MSG_ERROR([Quilt or patch are needed to build the ldiskfs module (for Linux 2.6)])
115 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
116 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
118 # ------- Makeflags ------------------
120 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
122 # liblustre are all the same
123 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
126 LLCFLAGS="-g -Wall -fPIC"
129 # everyone builds against portals and lustre
131 if test x$enable_ldiskfs = xyes ; then
132 AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
133 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
134 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
135 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
138 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I$PWD/portals/include -I$PWD/include"
140 # these are like AC_TRY_COMPILE, but try to build modules against the
141 # kernel, inside the kernel-tests directory
143 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
144 [cat >conftest.c <<_ACEOF
149 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
150 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
151 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
152 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])],
154 [_AC_MSG_LOG_CONFTEST
155 m4_ifvaln([$5],[$5])dnl])dnl
156 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
159 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
160 [LUSTRE_MODULE_COMPILE_IFELSE(
161 [AC_LANG_PROGRAM([[$1]], [[$2]])],
163 [test -s kernel-tests/conftest.o],
166 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
167 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
169 # ------------ include paths ------------------
171 if test x$enable_modules != xno ; then
172 # ------------ .config exists ----------------
173 AC_CHECK_FILE([$LINUX_CONFIG],[],
174 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
176 # ----------- make dep run? ------------------
177 AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
178 $LINUX/include/linux/version.h
179 $LINUX/include/linux/config.h],[],
180 [AC_MSG_ERROR([Run make config in $LINUX.])])
182 # ------------ rhconfig.h includes runtime-generated bits --
183 # red hat kernel-source checks
185 # we know this exists after the check above. if the user
186 # tarred up the tree and ran make dep etc. in it, then
187 # version.h gets overwritten with a standard linux one.
189 if grep rhconfig $LINUX/include/linux/version.h >/dev/null ; then
190 # This is a clean kernel-source tree, we need to
191 # enable extensive workarounds to get this to build
193 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
194 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
195 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
196 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
197 AC_MSG_WARN([Consult README.kernel-source for details.])
199 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
200 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
203 # --- check that we can build modules at all
204 AC_MSG_CHECKING([that modules can be built])
205 LUSTRE_MODULE_TRY_COMPILE([],[],
210 AC_MSG_WARN([Consult config.log for details.])
211 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
212 AC_MSG_ERROR([Kernel modules could not be built.])
215 # ------------ LINUXRELEASE and moduledir ------------------
216 MODULE_TARGET="SUBDIRS"
217 if test $linux25 = 'yes' ; then
218 # ------------ external module support ---------------------
219 makerule="$PWD/kernel-tests"
220 AC_MSG_CHECKING([for external module build support])
221 rm -f kernel-tests/conftest.i
222 LUSTRE_MODULE_TRY_MAKE([],[],
223 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
224 [test -s kernel-tests/conftest.i],
229 makerule="_module_$makerule"
233 makerule="_dir_$PWD/kernel-tests"
235 AC_SUBST(MODULE_TARGET)
237 rm -f kernel-tests/conftest.i
238 AC_MSG_CHECKING([for Linux release])
239 LUSTRE_MODULE_TRY_MAKE(
240 [#include <linux/version.h>],
242 LINUXRELEASE=UTS_RELEASE;],
243 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
244 [test -s kernel-tests/conftest.i],
246 # LINUXRELEASE="UTS_RELEASE"
247 eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
249 AC_MSG_RESULT([unknown])
250 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
252 rm -f kernel-tests/conftest.i
253 if test x$LINUXRELEASE = x ; then
254 AC_MSG_RESULT([unknown])
255 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
257 AC_MSG_RESULT([$LINUXRELEASE])
258 AC_SUBST(LINUXRELEASE)
260 moduledir='/lib/modules/'$LINUXRELEASE/kernel
261 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
262 modulenetdir='$(moduledir)/net/$(PACKAGE)'
265 AC_SUBST(modulefsdir)
266 AC_SUBST(modulenetdir)
268 # ------------ RELEASE --------------------------------
269 AC_MSG_CHECKING([for Lustre release])
270 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
271 AC_MSG_RESULT($RELEASE)
274 # ---------- Portals flags --------------------
276 AC_MSG_CHECKING([for zero-copy TCP support])
277 AC_ARG_ENABLE([zerocopy],
278 AC_HELP_STRING([--disable-zerocopy],
279 [disable socknal zerocopy]),
280 [],[enable_zerocopy='yes'])
281 if test x$enable_zerocopy = xno ; then
282 AC_MSG_RESULT([no (by request)])
284 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
285 if test "$ZCCD" != 0 ; then
286 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
289 AC_MSG_RESULT([no (no kernel support)])
293 AC_ARG_ENABLE([affinity],
294 AC_HELP_STRING([--disable-affinity],
295 [disable process/irq affinity]),
296 [],[enable_affinity='yes'])
298 AC_MSG_CHECKING([for CPU affinity support])
299 if test x$enable_affinity = xno ; then
300 AC_MSG_RESULT([no (by request)])
302 LUSTRE_MODULE_TRY_COMPILE(
304 #include <linux/sched.h>
306 struct task_struct t;
307 #ifdef CPU_ARRAY_SIZE
312 set_cpus_allowed(&t, m);
314 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
317 AC_MSG_RESULT([no (no kernel support)])
321 #####################################
323 AC_MSG_CHECKING([if quadrics kernel headers are present])
324 if test -d $LINUX/drivers/net/qsnet ; then
327 AC_MSG_CHECKING([for multirail EKC])
328 if test -f $LINUX/include/elan/epcomms.h; then
329 AC_MSG_RESULT([supported])
330 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
332 AC_MSG_RESULT([not supported])
333 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
340 AC_SUBST(QSWCPPFLAGS)
343 AC_MSG_CHECKING([if gm support was requested])
345 AC_HELP_STRING([--with-gm=path],
346 [build gmnal against path]),
351 GMCPPFLAGS="-I/usr/local/gm/include"
361 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
373 #fixme: where are the default IB includes?
374 default_ib_include_dir=/usr/local/ib/include
375 an_ib_include_file=vapi.h
377 AC_MSG_CHECKING([if ib nal support was requested])
379 AC_HELP_STRING([--with-ib=yes/no/path],
380 [Path to IB includes]),
385 IBCPPFLAGS="-I/usr/local/ib/include"
395 IBCPPFLAGS="-I$with_ib"
407 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
408 # But other kernels don't
410 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
411 LUSTRE_MODULE_TRY_COMPILE(
413 #include <linux/iobuf.h>
419 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
424 # ----------- 2.6.4 no longer has page->list ---------------
425 AC_MSG_CHECKING([if struct page has a list field])
426 LUSTRE_MODULE_TRY_COMPILE(
428 #include <linux/mm.h>
434 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
439 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
440 # This needs to run after we've defined the KCPPFLAGS
442 AC_MSG_CHECKING([if task_struct has a sighand field])
443 LUSTRE_MODULE_TRY_COMPILE(
445 #include <linux/sched.h>
447 struct task_struct p;
450 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
456 # ---------- 2.4.20 introduced cond_resched --------------
458 AC_MSG_CHECKING([if kernel offers cond_resched])
459 LUSTRE_MODULE_TRY_COMPILE(
461 #include <linux/sched.h>
466 AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
471 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
473 AC_MSG_CHECKING([if kernel defines PDE])
474 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
475 if test "$HAVE_PDE" != 0 ; then
476 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
482 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
483 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
484 if test "$HAVE_DIO_FILE" != 0 ; then
485 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
491 AC_MSG_CHECKING([if kernel defines cpu_online()])
492 LUSTRE_MODULE_TRY_COMPILE(
494 #include <linux/sched.h>
499 AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
504 AC_MSG_CHECKING([if kernel defines cpumask_t])
505 LUSTRE_MODULE_TRY_COMPILE(
507 #include <linux/sched.h>
509 return sizeof (cpumask_t);
512 AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
517 # ---------- RHEL kernels define page_count in mm_inline.h
518 AC_MSG_CHECKING([if kernel has mm_inline.h header])
519 LUSTRE_MODULE_TRY_COMPILE(
521 #include <linux/mm_inline.h>
524 #error mm_inline.h does not define page_count
528 AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
533 # ---------- inode->i_alloc_sem --------------
534 AC_MSG_CHECKING([if struct inode has i_alloc_sem])
535 LUSTRE_MODULE_TRY_COMPILE(
537 #include <linux/fs.h>
538 #include <linux/version.h>
540 #if defined(CONFIG_X86_64) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
541 #error "x86_64 down_read_trylock broken before 2.4.24"
544 return (char *)&i.i_alloc_sem - (char *)&i;
547 AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
552 # ---------- modules? ------------------------
553 AC_MSG_CHECKING([for module support])
554 LUSTRE_MODULE_TRY_COMPILE(
556 #include <linux/config.h>
558 #ifndef CONFIG_MODULES
559 #error CONFIG_MODULES not #defined
565 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
568 # ---------- modversions? --------------------
569 AC_MSG_CHECKING([for MODVERSIONS])
570 LUSTRE_MODULE_TRY_COMPILE(
572 #include <linux/config.h>
574 #ifndef CONFIG_MODVERSIONS
575 #error CONFIG_MODVERSIONS not #defined
583 # ------------ preempt -----------------------
584 AC_MSG_CHECKING([if preempt is enabled])
585 LUSTRE_MODULE_TRY_COMPILE(
587 #include <linux/config.h>
589 #ifndef CONFIG_PREEMPT
590 #error CONFIG_PREEMPT is not #defined
594 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
601 # --- Check that ext3 and ext3 xattr are enabled in the kernel
602 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
603 LUSTRE_MODULE_TRY_COMPILE(
605 #include <linux/config.h>
607 #ifndef CONFIG_EXT3_FS
608 #ifndef CONFIG_EXT3_FS_MODULE
609 #error CONFIG_EXT3_FS not #defined
616 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
619 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
620 LUSTRE_MODULE_TRY_COMPILE(
622 #include <linux/config.h>
624 #ifndef CONFIG_EXT3_FS_XATTR
625 #error CONFIG_EXT3_FS_XATTR not #defined
631 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
632 AC_MSG_WARN([This build may fail.])
636 AC_MSG_CHECKING([if fshooks are present])
637 LUSTRE_MODULE_TRY_COMPILE(
639 #include <linux/fshooks.h>
642 LDISKFS_SERIES="2.6-suse.series"
645 LDISKFS_SERIES="2.6-vanilla.series"
647 AC_SUBST(LDISKFS_SERIES)
648 # --- check which ldiskfs series we should use
653 AM_CONDITIONAL(BUILD_IBNAL, test x$IBNAL = "xibnal")
654 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
655 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
657 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
658 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
659 AC_SUBST(EXTRA_KCFLAGS)
661 #echo "KCPPFLAGS: $KCPPFLAGS"
662 #echo "KCFLAGS: $KCFLAGS"
663 #echo "LLCPPFLAGS: $LLCPPFLAGS"
664 #echo "LLCFLAGS: $LLCFLAGS"
665 #echo "MOD_LINK: $MOD_LINK"
666 #echo "CFLAGS: $CFLAGS"
667 #echo "CPPFLAGS: $CPPFLAGS"