Whamcloud - gitweb
- landing of b_hd_cleanup_merge to HEAD.
[fs/lustre-release.git] / lustre / portals / archdep.m4
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.])])
5 fi
6
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)
15
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]),
21         [
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])
27                         else
28                                 AC_MSG_ERROR([--with-cray-portals specified badly])
29                         fi
30                 fi
31         ],[with_cray_portals=no])
32 AC_SUBST(CRAY_PORTALS_PATH)
33 AC_MSG_RESULT([$with_cray_portals])
34
35 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
36
37 # -------- enable tests and utils? -------
38 if test x$enable_tests = xno ; then
39         AC_MSG_NOTICE([disabling tests])
40         enable_tests=no
41 fi
42 if test x$enable_utils = xno ; then
43         AC_MSG_NOTICE([disabling utilities])
44         enable_utils=no
45 fi
46
47 if test x$enable_modules != xno ; then
48         # -------- set linuxdir ------------
49         AC_MSG_CHECKING([for Linux sources])
50         AC_ARG_WITH([linux],
51                 AC_HELP_STRING([--with-linux=path],
52                                [set path to Linux source (default=/usr/src/linux)]),
53                 [LINUX=$with_linux],
54                 [LINUX=/usr/src/linux])
55         AC_MSG_RESULT([$LINUX])
56         AC_SUBST(LINUX)
57         if test x$enable_inkernel = xyes ; then
58                 echo ln -s `pwd` $LINUX/fs/lustre
59                 rm $LINUX/fs/lustre
60                 ln -s `pwd` $LINUX/fs/lustre
61         fi
62
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)
70
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']])
75
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])
80
81         #  --------------------
82         ARCH_UM=
83         UML_CFLAGS=
84
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
88                         ARCH_UM='ARCH=um'
89                         # see notes in Rules.in
90                         UML_CFLAGS='-O0'
91                         AC_MSG_RESULT(yes)
92                 else
93                         AC_MSG_RESULT([no (asm doesn't point at asm-um)])
94                 fi
95         else
96                 AC_MSG_RESULT([no (asm-um missing)])
97         fi
98
99         AC_SUBST(ARCH_UM)
100         AC_SUBST(UML_CFLAGS)
101
102         # --------- Linux 25 ------------------
103         AC_CHECK_FILE([$LINUX/include/linux/namei.h],
104                 [
105                         linux25="yes"
106                         KMODEXT=".ko"
107                         enable_ldiskfs="yes"
108                         BACKINGFS="ldiskfs"
109                 ],[
110                         KMODEXT=".o"
111                         linux25="no"
112                 ])
113         AC_MSG_CHECKING([if you are using Linux 2.6])
114         AC_MSG_RESULT([$linux25])
115
116         AC_SUBST(LINUX25)
117         AC_SUBST(KMODEXT)
118
119         AC_PATH_PROG(PATCH, patch, [no])
120         AC_PATH_PROG(QUILT, quilt, [no])
121
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)])
124         fi
125 fi
126 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
127 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
128
129 # -------  Makeflags ------------------
130
131 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
132
133 # liblustre are all the same
134 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
135 AC_SUBST(LLCPPFLAGS)
136
137 LLCFLAGS="-g -Wall -fPIC"
138 AC_SUBST(LLCFLAGS)
139
140 # everyone builds against portals and lustre
141
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])
147 fi
148
149 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I$PWD/portals/include -I$PWD/include"
150
151 # these are like AC_TRY_COMPILE, but try to build modules against the
152 # kernel, inside the kernel-tests directory
153
154 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
155 [cat >conftest.c <<_ACEOF
156 $1
157 _ACEOF
158 ])
159
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])],
164         [$4],
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
168 ])
169
170 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
171 [LUSTRE_MODULE_COMPILE_IFELSE(
172         [AC_LANG_PROGRAM([[$1]], [[$2]])],
173         [modules],
174         [test -s kernel-tests/conftest.o],
175         [$3], [$4])])
176
177 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
178 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
179
180 # ------------ include paths ------------------
181
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])])
186
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.])])
192
193         # ------------ rhconfig.h includes runtime-generated bits --
194         # red hat kernel-source checks
195
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.
199
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
203                 # modules
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.])
209                         fi],
210                         [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found.  Consult README.kernel-source for details.])])
211                 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
212         fi
213
214         # --- check that we can build modules at all
215         AC_MSG_CHECKING([that modules can be built])
216         LUSTRE_MODULE_TRY_COMPILE([],[],
217                 [
218                         AC_MSG_RESULT([yes])
219                 ],[
220                         AC_MSG_RESULT([no])
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.])
224                 ])
225
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],
236                         [
237                                 AC_MSG_RESULT([no])
238                         ],[
239                                 AC_MSG_RESULT([yes])
240                                 makerule="_module_$makerule"
241                                 MODULE_TARGET="M"
242                         ])
243         else
244                 makerule="_dir_$PWD/kernel-tests"
245         fi
246         AC_SUBST(MODULE_TARGET)
247         LINUXRELEASE=
248         rm -f kernel-tests/conftest.i
249         AC_MSG_CHECKING([for Linux release])
250         LUSTRE_MODULE_TRY_MAKE(
251                 [#include <linux/version.h>],
252                 [char *LINUXRELEASE;
253                  LINUXRELEASE=UTS_RELEASE;],
254                 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
255                 [test -s kernel-tests/conftest.i],
256                 [
257                         # LINUXRELEASE="UTS_RELEASE"
258                         eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
259                 ],[
260                         AC_MSG_RESULT([unknown])
261                         AC_MSG_ERROR([Could not preprocess test program.  Consult config.log for details.])
262                 ])
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.])
267         fi
268         AC_MSG_RESULT([$LINUXRELEASE])
269         AC_SUBST(LINUXRELEASE)
270
271         moduledir='/lib/modules/'$LINUXRELEASE/kernel
272         modulefsdir='$(moduledir)/fs/$(PACKAGE)'
273         modulenetdir='$(moduledir)/net/$(PACKAGE)'
274
275         AC_SUBST(moduledir)
276         AC_SUBST(modulefsdir)
277         AC_SUBST(modulenetdir)
278
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)
283         AC_SUBST(RELEASE)
284
285         # ---------- Portals flags --------------------
286
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)])
294         else
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])
298                         AC_MSG_RESULT(yes)
299                 else
300                         AC_MSG_RESULT([no (no kernel support)])
301                 fi
302         fi
303
304         AC_ARG_ENABLE([affinity],
305                 AC_HELP_STRING([--disable-affinity],
306                                [disable process/irq affinity]),
307                 [],[enable_affinity='yes'])
308
309         AC_MSG_CHECKING([for CPU affinity support])
310         if test x$enable_affinity = xno ; then
311                 AC_MSG_RESULT([no (by request)])
312         else
313                 LUSTRE_MODULE_TRY_COMPILE(
314                         [
315                                 #include <linux/sched.h>
316                         ],[
317                                 struct task_struct t;
318                                 #ifdef CPU_ARRAY_SIZE
319                                 cpumask_t m;
320                                 #else
321                                 unsigned long m;
322                                 #endif
323                                 set_cpus_allowed(&t, m);
324                         ],[
325                                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
326                                 AC_MSG_RESULT([yes])
327                         ],[
328                                 AC_MSG_RESULT([no (no kernel support)])
329                         ])
330         fi
331
332         #####################################
333
334         AC_MSG_CHECKING([if quadrics kernel headers are present])
335         if test -d $LINUX/drivers/net/qsnet ; then
336                 AC_MSG_RESULT([yes])
337                 QSWNAL="qswnal"
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"
342                 else
343                         AC_MSG_RESULT([not supported])
344                         if test -d $LINUX/drivers/net/qsnet/include; then
345                                 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
346                         else
347                                 QSWCPPFLAGS="-I$LINUX/include/linux"
348                         fi
349                 fi
350         else
351                 AC_MSG_RESULT([no])
352                 QSWNAL=""
353                 QSWCPPFLAGS=""
354         fi
355         AC_SUBST(QSWCPPFLAGS)
356         AC_SUBST(QSWNAL)
357
358         AC_MSG_CHECKING([if gm support was requested])
359         AC_ARG_WITH([gm],
360                 AC_HELP_STRING([--with-gm=path],
361                                [build gmnal against path]),
362                 [
363                         case $with_gm in 
364                                 yes)
365                                         AC_MSG_RESULT([yes])
366                                         GMCPPFLAGS="-I/usr/local/gm/include"
367                                         GMNAL="gmnal"
368                                         ;;
369                                 no)
370                                         AC_MSG_RESULT([no])
371                                         GMCPPFLAGS=""
372                                         GMNAL=""
373                                         ;;
374                                 *)
375                                         AC_MSG_RESULT([yes])
376                                         GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
377                                         GMNAL="gmnal"
378                                         ;;
379                         esac
380                 ],[
381                         AC_MSG_RESULT([no])
382                         GMCPPFLAGS=""
383                         GMNAL=""
384                 ])
385         AC_SUBST(GMCPPFLAGS)
386         AC_SUBST(GMNAL)
387
388         #### OpenIB 
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(
394                 [
395                         #include <ts_ib_core.h>
396                 ],[
397                         struct ib_device_properties props;
398                         return 0;
399                 ],[
400                         AC_MSG_RESULT([yes])
401                         OPENIBNAL="openibnal"
402                 ],[
403                         AC_MSG_RESULT([no])
404                         OPENIBNAL=""
405                         OPENIBCPPFLAGS=""
406                 ])
407         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
408         AC_SUBST(OPENIBCPPFLAGS)
409         AC_SUBST(OPENIBNAL)
410
411         # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
412         # But other kernels don't
413
414         AC_MSG_CHECKING([if struct kiobuf has a dovary field])
415         LUSTRE_MODULE_TRY_COMPILE(
416                 [
417                         #include <linux/iobuf.h>
418                 ],[
419                         struct kiobuf iobuf;
420                         iobuf.dovary = 1;
421                 ],[
422                         AC_MSG_RESULT([yes])
423                         AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
424                 ],[
425                         AC_MSG_RESULT([no])
426                 ])      
427
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(
431                 [
432                         #include <linux/mm.h>
433                 ],[
434                         struct page page;
435                         &page.list;
436                 ],[
437                         AC_MSG_RESULT([yes])
438                         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
439                 ],[
440                         AC_MSG_RESULT([no])
441                 ])
442
443         # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
444         # This needs to run after we've defined the KCPPFLAGS
445
446         AC_MSG_CHECKING([if task_struct has a sighand field])
447         LUSTRE_MODULE_TRY_COMPILE(
448                 [
449                         #include <linux/sched.h>
450                 ],[
451                         struct task_struct p;
452                         p.sighand = NULL;
453                 ],[
454                         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
455                         AC_MSG_RESULT([yes])
456                 ],[
457                         AC_MSG_RESULT([no])
458                 ])
459
460         # ---------- 2.4.20 introduced cond_resched --------------
461
462         AC_MSG_CHECKING([if kernel offers cond_resched])
463         LUSTRE_MODULE_TRY_COMPILE(
464                 [
465                         #include <linux/sched.h>
466                 ],[
467                         cond_resched();
468                 ],[
469                         AC_MSG_RESULT([yes])
470                         AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
471                 ],[
472                         AC_MSG_RESULT([no])
473                 ])
474
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])
480                 AC_MSG_RESULT([yes])
481         else
482                 AC_MSG_RESULT([no])
483         fi
484
485         # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
486
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])
491                 AC_MSG_RESULT([yes])
492         else
493                 AC_MSG_RESULT([no])
494         fi
495
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])
500                 AC_MSG_RESULT(yes)
501         else
502                 AC_MSG_RESULT(no)
503         fi
504
505         AC_MSG_CHECKING([if kernel defines cpu_online()])
506         LUSTRE_MODULE_TRY_COMPILE(
507                 [
508                         #include <linux/sched.h>
509                 ],[
510                         cpu_online(0);
511                 ],[
512                         AC_MSG_RESULT([yes])
513                         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
514                 ],[
515                         AC_MSG_RESULT([no])
516                 ])
517         AC_MSG_CHECKING([if kernel defines cpumask_t])
518         LUSTRE_MODULE_TRY_COMPILE(
519                 [
520                         #include <linux/sched.h>
521                 ],[
522                         return sizeof (cpumask_t);
523                 ],[
524                         AC_MSG_RESULT([yes])
525                         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
526                 ],[
527                         AC_MSG_RESULT([no])
528                 ])
529
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(
533                 [
534                         #include <linux/mm_inline.h>
535                 ],[
536                         #ifndef page_count
537                         #error mm_inline.h does not define page_count
538                         #endif
539                 ],[
540                         AC_MSG_RESULT([yes])
541                         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
542                 ],[
543                         AC_MSG_RESULT([no])
544                 ])
545
546         # ---------- inode->i_alloc_sem --------------
547         AC_MSG_CHECKING([if struct inode has i_alloc_sem])
548         LUSTRE_MODULE_TRY_COMPILE(
549                 [
550                         #include <linux/fs.h>
551                         #include <linux/version.h>
552                 ],[
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"
555                         #endif
556                         struct inode i;
557                         return (char *)&i.i_alloc_sem - (char *)&i;
558                 ],[
559                         AC_MSG_RESULT([yes])
560                         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
561                 ],[
562                         AC_MSG_RESULT([no])
563                 ])
564
565
566         # ---------- modules? ------------------------
567         AC_MSG_CHECKING([for module support])
568         LUSTRE_MODULE_TRY_COMPILE(
569                 [
570                         #include <linux/config.h>
571                 ],[
572                         #ifndef CONFIG_MODULES
573                         #error CONFIG_MODULES not #defined
574                         #endif
575                 ],[
576                         AC_MSG_RESULT([yes])
577                 ],[
578                         AC_MSG_RESULT([no])
579                         AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
580                 ])
581
582         # ---------- modversions? --------------------
583         AC_MSG_CHECKING([for MODVERSIONS])
584         LUSTRE_MODULE_TRY_COMPILE(
585                 [
586                         #include <linux/config.h>
587                 ],[
588                         #ifndef CONFIG_MODVERSIONS
589                         #error CONFIG_MODVERSIONS not #defined
590                         #endif
591                 ],[
592                         AC_MSG_RESULT([yes])
593                 ],[
594                         AC_MSG_RESULT([no])
595                 ])
596
597         # ------------ preempt -----------------------
598         AC_MSG_CHECKING([if preempt is enabled])
599         LUSTRE_MODULE_TRY_COMPILE(
600                 [
601                         #include <linux/config.h>
602                 ],[
603                         #ifndef CONFIG_PREEMPT
604                         #error CONFIG_PREEMPT is not #defined
605                         #endif
606                 ],[
607                         AC_MSG_RESULT([yes])
608                         AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
609                 ],[
610                         AC_MSG_RESULT([no])
611                 ])
612
613         case $BACKINGFS in
614                 ext3)
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(
618                                 [
619                                         #include <linux/config.h>
620                                 ],[
621                                         #ifndef CONFIG_EXT3_FS
622                                         #ifndef CONFIG_EXT3_FS_MODULE
623                                         #error CONFIG_EXT3_FS not #defined
624                                         #endif
625                                         #endif
626                                 ],[
627                                         AC_MSG_RESULT([yes])
628                                 ],[
629                                         AC_MSG_RESULT([no])
630                                         AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
631                                 ])
632         
633                         AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
634                         LUSTRE_MODULE_TRY_COMPILE(
635                                 [
636                                         #include <linux/config.h>
637                                 ],[
638                                         #ifndef CONFIG_EXT3_FS_XATTR
639                                         #error CONFIG_EXT3_FS_XATTR not #defined
640                                         #endif
641                                 ],[
642                                         AC_MSG_RESULT([yes])
643                                 ],[
644                                         AC_MSG_RESULT([no])
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.])
647                                 ])
648                         ;;
649                 ldiskfs)
650                         AC_MSG_CHECKING([if fshooks are present])
651                         LUSTRE_MODULE_TRY_COMPILE(
652                                 [
653                                         #include <linux/fshooks.h>
654                                 ],[],[
655                                         AC_MSG_RESULT([yes])
656                                         LDISKFS_SERIES="2.6-suse.series"
657                                 ],[
658                                         AC_MSG_RESULT([no])
659                                         LDISKFS_SERIES="2.6-vanilla.series"
660                                 ])
661                         AC_SUBST(LDISKFS_SERIES)
662                         # --- check which ldiskfs series we should use
663                         ;;
664         esac # $BACKINGFS
665 fi
666
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")
670
671 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
672 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
673 AC_SUBST(EXTRA_KCFLAGS)
674
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"