Whamcloud - gitweb
* landed unified portals (b_hd_cleanup_merge_singleportals) on HEAD
[fs/lustre-release.git] / lnet / 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([for Cray portals])
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                         CRAY_PORTALS_PATH=$with_cray_portals
24                         CRAY_PORTALS_INCLUDES="$with_cray_portals/include"
25                         CRAY_PORTALS_LIBS="$with_cray_portals"
26                 fi
27         ],[with_cray_portals=no])
28 AC_SUBST(CRAY_PORTALS_PATH)
29 AC_MSG_RESULT([$CRAY_PORTALS_PATH])
30
31 AC_MSG_CHECKING([for Cray portals includes])
32 AC_ARG_WITH([cray-portals-includes],
33         AC_HELP_STRING([--with-cray-portals-includes=path],
34                        [path to cray portals includes]),
35         [
36                 if test "$with_cray_portals_includes" != no; then
37                         CRAY_PORTALS_INCLUDES="$with_cray_portals_includes"
38                 fi
39         ])
40 AC_SUBST(CRAY_PORTALS_INCLUDES)
41 AC_MSG_RESULT([$CRAY_PORTALS_INCLUDES])
42
43 AC_MSG_CHECKING([for Cray portals libs])
44 AC_ARG_WITH([cray-portals-libs],
45         AC_HELP_STRING([--with-cray-portals-libs=path],
46                        [path to cray portals libs]),
47         [
48                 if test "$with_cray_portals_libs" != no; then
49                         CRAY_PORTALS_LIBS="$with_cray_portals_libs"
50                 fi
51         ])
52 AC_SUBST(CRAY_PORTALS_LIBS)
53 AC_MSG_RESULT([$CRAY_PORTALS_LIBS])
54
55 if test x$CRAY_PORTALS_INCLUDES != x ; then
56         if test ! -r $CRAY_PORTALS_INCLUDES/portals/api.h ; then
57                 AC_MSG_ERROR([Cray portals headers were not found in $CRAY_PORTALS_INCLUDES.  Please check the paths passed to --with-cray-portals or --with-cray-portals-includes.])
58         fi
59 fi
60 if test x$CRAY_PORTALS_LIBS != x ; then
61         if test ! -r $CRAY_PORTALS_LIBS/libportals.a ; then
62                 AC_MSG_ERROR([Cray portals libraries were not found in $CRAY_PORTALS_LIBS.  Please check the paths passed to --with-cray-portals or --with-cray-portals-libs.])
63         fi
64 fi
65
66 AC_MSG_CHECKING([whether to use Cray portals])
67 if test x$CRAY_PORTALS_INCLUDES != x -a x$CRAY_PORTALS_LIBS != x ; then
68         with_cray_portals=yes
69         AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
70         CRAY_PORTALS_INCLUDES="-I$CRAY_PORTALS_INCLUDES"
71 else
72         with_cray_portals=no
73 fi
74 AC_MSG_RESULT([$with_cray_portals])
75 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
76
77 # ----------------------------------------
78 # some tests for catamount-like systems
79 # ----------------------------------------
80 AC_ARG_ENABLE([sysio_init],
81         AC_HELP_STRING([--disable-sysio-init],
82                 [call sysio init functions when initializing liblustre]),
83         [],[enable_sysio_init=yes])
84 AC_MSG_CHECKING([whether to initialize libsysio])
85 AC_MSG_RESULT([$enable_sysio_init])
86 if test x$enable_sysio_init != xno ; then
87         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
88 fi
89
90 AC_ARG_ENABLE([urandom],
91         AC_HELP_STRING([--disable-urandom],
92                 [disable use of /dev/urandom for liblustre]),
93         [],[enable_urandom=yes])
94 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
95 AC_MSG_RESULT([$enable_urandom])
96 if test x$enable_urandom != xno ; then
97         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
98 fi
99
100 # -------- check for -lcap and -lpthread ----
101 if test x$enable_liblustre = xyes ; then
102         AC_CHECK_LIB([cap], [cap_get_proc],
103                 [
104                         CAP_LIBS="-lcap"
105                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
106                 ],
107                 [CAP_LIBS=""])
108         AC_SUBST(CAP_LIBS)
109         AC_CHECK_LIB([pthread], [pthread_create],
110                 [
111                         PTHREAD_LIBS="-lpthread"
112                         AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
113                 ],
114                 [PTHREAD_LIBS=""])
115         AC_SUBST(PTHREAD_LIBS)
116 fi
117
118 # -------- enable tests and utils? -------
119 if test x$enable_tests = xno ; then
120         AC_MSG_NOTICE([disabling tests])
121         enable_tests=no
122 fi
123 if test x$enable_utils = xno ; then
124         AC_MSG_NOTICE([disabling utilities])
125         enable_utils=no
126 fi
127
128 if test x$enable_modules != xno ; then
129         # -------- set linuxdir ------------
130         AC_MSG_CHECKING([for Linux sources])
131         AC_ARG_WITH([linux],
132                 AC_HELP_STRING([--with-linux=path],
133                                [set path to Linux source (default=/usr/src/linux)]),
134                 [LINUX=$with_linux],
135                 [LINUX=/usr/src/linux])
136         AC_MSG_RESULT([$LINUX])
137         AC_SUBST(LINUX)
138         if test x$enable_inkernel = xyes ; then
139                 echo ln -s `pwd` $LINUX/fs/lustre
140                 rm $LINUX/fs/lustre
141                 ln -s `pwd` $LINUX/fs/lustre
142         fi
143
144         # -------- check for .confg --------
145         AC_ARG_WITH([linux-config],
146                 [AC_HELP_STRING([--with-linux-config=path],
147                                 [set path to Linux .conf (default=\$LINUX/.config)])],
148                 [LINUX_CONFIG=$with_linux_config],
149                 [LINUX_CONFIG=$LINUX/.config])
150         AC_SUBST(LINUX_CONFIG)
151
152         AC_CHECK_FILE([/boot/kernel.h],
153                 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
154                 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
155                         [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
156
157         AC_ARG_WITH([kernel-source-header],
158                 AC_HELP_STRING([--with-kernel-source-header=path],
159                                 [Use a different kernel version header.  Consult README.kernel-source for details.]),
160                 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
161
162         #  --------------------
163         ARCH_UM=
164         UML_CFLAGS=
165
166         AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
167         if test -e $LINUX/include/asm-um ; then
168                 if test  X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
169                         ARCH_UM='ARCH=um'
170                         # see notes in Rules.in
171                         UML_CFLAGS='-O0'
172                         AC_MSG_RESULT(yes)
173                 else
174                         AC_MSG_RESULT([no (asm doesn't point at asm-um)])
175                 fi
176         else
177                 AC_MSG_RESULT([no (asm-um missing)])
178         fi
179
180         AC_SUBST(ARCH_UM)
181         AC_SUBST(UML_CFLAGS)
182
183         # --------- Linux 25 ------------------
184         AC_CHECK_FILE([$LINUX/include/linux/namei.h],
185                 [
186                         linux25="yes"
187                         KMODEXT=".ko"
188                         enable_ldiskfs="yes"
189                         BACKINGFS="ldiskfs"
190                 ],[
191                         KMODEXT=".o"
192                         linux25="no"
193                 ])
194         AC_MSG_CHECKING([if you are using Linux 2.6])
195         AC_MSG_RESULT([$linux25])
196
197         AC_SUBST(LINUX25)
198         AC_SUBST(KMODEXT)
199
200         AC_PATH_PROG(PATCH, patch, [no])
201         AC_PATH_PROG(QUILT, quilt, [no])
202
203         if test x$enable_ldiskfs$PATCH$QUILT = xyesnono ; then
204                 AC_MSG_ERROR([Quilt or patch are needed to build the ldiskfs module (for Linux 2.6)])
205         fi
206 fi
207 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
208 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
209
210 # -------  Makeflags ------------------
211
212 CPPFLAGS="$CPPFLAGS $CRAY_PORTALS_INCLUDES -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
213
214 # liblustre are all the same
215 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
216 AC_SUBST(LLCPPFLAGS)
217
218 LLCFLAGS="-g -Wall -fPIC"
219 AC_SUBST(LLCFLAGS)
220
221 # everyone builds against portals and lustre
222
223 if test x$enable_ldiskfs = xyes ; then
224         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
225         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
226         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
227         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
228 fi
229
230 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDES -I$PWD/portals/include -I$PWD/include"
231
232 # these are like AC_TRY_COMPILE, but try to build modules against the
233 # kernel, inside the kernel-tests directory
234
235 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
236 [cat >conftest.c <<_ACEOF
237 $1
238 _ACEOF
239 ])
240
241 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
242 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
243 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
244 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])],
245         [$4],
246         [_AC_MSG_LOG_CONFTEST
247 m4_ifvaln([$5],[$5])dnl])dnl
248 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
249 ])
250
251 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
252 [LUSTRE_MODULE_COMPILE_IFELSE(
253         [AC_LANG_PROGRAM([[$1]], [[$2]])],
254         [modules],
255         [test -s kernel-tests/conftest.o],
256         [$3], [$4])])
257
258 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
259 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
260
261 # ------------ include paths ------------------
262
263 if test x$enable_modules != xno ; then
264         # ------------ .config exists ----------------
265         AC_CHECK_FILE([$LINUX_CONFIG],[],
266                 [AC_MSG_ERROR([Kernel config could not be found.  If you are building from a kernel-source rpm consult README.kernel-source])])
267
268         # ----------- make dep run? ------------------
269         AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
270                         $LINUX/include/linux/version.h
271                         $LINUX/include/linux/config.h],[],
272                 [AC_MSG_ERROR([Run make config in $LINUX.])])
273
274         # ------------ rhconfig.h includes runtime-generated bits --
275         # red hat kernel-source checks
276
277         # we know this exists after the check above.  if the user
278         # tarred up the tree and ran make dep etc. in it, then
279         # version.h gets overwritten with a standard linux one.
280
281         if grep rhconfig $LINUX/include/linux/version.h >/dev/null ; then
282                 # This is a clean kernel-source tree, we need to
283                 # enable extensive workarounds to get this to build
284                 # modules
285                 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
286                         [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
287                                 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
288                                 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
289                                 AC_MSG_WARN([Consult README.kernel-source for details.])
290                         fi],
291                         [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found.  Consult README.kernel-source for details.])])
292                 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
293         fi
294
295         # --- check that we can build modules at all
296         AC_MSG_CHECKING([that modules can be built])
297         LUSTRE_MODULE_TRY_COMPILE([],[],
298                 [
299                         AC_MSG_RESULT([yes])
300                 ],[
301                         AC_MSG_RESULT([no])
302                         AC_MSG_WARN([Consult config.log for details.])
303                         AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
304                         AC_MSG_ERROR([Kernel modules could not be built.])
305                 ])
306
307         # ------------ LINUXRELEASE and moduledir ------------------
308         MODULE_TARGET="SUBDIRS"
309         if test $linux25 = 'yes' ; then
310                 # ------------ external module support ---------------------
311                 makerule="$PWD/kernel-tests"
312                 AC_MSG_CHECKING([for external module build support])
313                 rm -f kernel-tests/conftest.i
314                 LUSTRE_MODULE_TRY_MAKE([],[],
315                         [$makerule LUSTRE_KERNEL_TEST=conftest.i],
316                         [test -s kernel-tests/conftest.i],
317                         [
318                                 AC_MSG_RESULT([no])
319                         ],[
320                                 AC_MSG_RESULT([yes])
321                                 makerule="_module_$makerule"
322                                 MODULE_TARGET="M"
323                         ])
324         else
325                 makerule="_dir_$PWD/kernel-tests"
326         fi
327         AC_SUBST(MODULE_TARGET)
328         LINUXRELEASE=
329         rm -f kernel-tests/conftest.i
330         AC_MSG_CHECKING([for Linux release])
331         LUSTRE_MODULE_TRY_MAKE(
332                 [#include <linux/version.h>],
333                 [char *LINUXRELEASE;
334                  LINUXRELEASE=UTS_RELEASE;],
335                 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
336                 [test -s kernel-tests/conftest.i],
337                 [
338                         # LINUXRELEASE="UTS_RELEASE"
339                         eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i)
340                 ],[
341                         AC_MSG_RESULT([unknown])
342                         AC_MSG_ERROR([Could not preprocess test program.  Consult config.log for details.])
343                 ])
344         rm -f kernel-tests/conftest.i
345         if test x$LINUXRELEASE = x ; then
346                 AC_MSG_RESULT([unknown])
347                 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
348         fi
349         AC_MSG_RESULT([$LINUXRELEASE])
350         AC_SUBST(LINUXRELEASE)
351
352         moduledir='/lib/modules/'$LINUXRELEASE/kernel
353         modulefsdir='$(moduledir)/fs/$(PACKAGE)'
354         modulenetdir='$(moduledir)/net/$(PACKAGE)'
355
356         AC_SUBST(moduledir)
357         AC_SUBST(modulefsdir)
358         AC_SUBST(modulenetdir)
359
360         # ------------ RELEASE --------------------------------
361         AC_MSG_CHECKING([for Lustre release])
362         RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
363         AC_MSG_RESULT($RELEASE)
364         AC_SUBST(RELEASE)
365
366         # ---------- Portals flags --------------------
367
368         AC_MSG_CHECKING([for zero-copy TCP support])
369         AC_ARG_ENABLE([zerocopy],
370                 AC_HELP_STRING([--disable-zerocopy],
371                                [disable socknal zerocopy]),
372                 [],[enable_zerocopy='yes'])
373         if test x$enable_zerocopy = xno ; then
374                 AC_MSG_RESULT([no (by request)])
375         else
376                 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
377                 if test "$ZCCD" != 0 ; then
378                         AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
379                         AC_MSG_RESULT(yes)
380                 else
381                         AC_MSG_RESULT([no (no kernel support)])
382                 fi
383         fi
384
385         AC_ARG_ENABLE([affinity],
386                 AC_HELP_STRING([--disable-affinity],
387                                [disable process/irq affinity]),
388                 [],[enable_affinity='yes'])
389
390         AC_MSG_CHECKING([for CPU affinity support])
391         if test x$enable_affinity = xno ; then
392                 AC_MSG_RESULT([no (by request)])
393         else
394                 LUSTRE_MODULE_TRY_COMPILE(
395                         [
396                                 #include <linux/sched.h>
397                         ],[
398                                 struct task_struct t;
399                                 #ifdef CPU_ARRAY_SIZE
400                                 cpumask_t m;
401                                 #else
402                                 unsigned long m;
403                                 #endif
404                                 set_cpus_allowed(&t, m);
405                         ],[
406                                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
407                                 AC_MSG_RESULT([yes])
408                         ],[
409                                 AC_MSG_RESULT([no (no kernel support)])
410                         ])
411         fi
412
413         #####################################
414
415         AC_MSG_CHECKING([if quadrics kernel headers are present])
416         if test -d $LINUX/drivers/net/qsnet ; then
417                 AC_MSG_RESULT([yes])
418                 QSWNAL="qswnal"
419                 AC_MSG_CHECKING([for multirail EKC])
420                 if test -f $LINUX/include/elan/epcomms.h; then
421                         AC_MSG_RESULT([supported])
422                         QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
423                 else
424                         AC_MSG_RESULT([not supported])
425                         if test -d $LINUX/drivers/net/qsnet/include; then
426                                 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
427                         else
428                                 QSWCPPFLAGS="-I$LINUX/include/linux"
429                         fi
430                 fi
431         else
432                 AC_MSG_RESULT([no])
433                 QSWNAL=""
434                 QSWCPPFLAGS=""
435         fi
436         AC_SUBST(QSWCPPFLAGS)
437         AC_SUBST(QSWNAL)
438
439         AC_MSG_CHECKING([if gm support was requested])
440         AC_ARG_WITH([gm],
441                 AC_HELP_STRING([--with-gm=path],
442                                [build gmnal against path]),
443                 [
444                         case $with_gm in 
445                                 yes)
446                                         AC_MSG_RESULT([yes])
447                                         GMCPPFLAGS="-I/usr/local/gm/include"
448                                         GMNAL="gmnal"
449                                         ;;
450                                 no)
451                                         AC_MSG_RESULT([no])
452                                         GMCPPFLAGS=""
453                                         GMNAL=""
454                                         ;;
455                                 *)
456                                         AC_MSG_RESULT([yes])
457                                         GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
458                                         GMNAL="gmnal"
459                                         ;;
460                         esac
461                 ],[
462                         AC_MSG_RESULT([no])
463                         GMCPPFLAGS=""
464                         GMNAL=""
465                 ])
466         AC_SUBST(GMCPPFLAGS)
467         AC_SUBST(GMNAL)
468
469         #### OpenIB 
470         AC_MSG_CHECKING([if OpenIB kernel headers are present])
471         OPENIBCPPFLAGS="-I$LINUX/drivers/infiniband/include -DIN_TREE_BUILD"
472         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
473         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
474         LUSTRE_MODULE_TRY_COMPILE(
475                 [
476                         #include <ts_ib_core.h>
477                 ],[
478                         struct ib_device_properties props;
479                         return 0;
480                 ],[
481                         AC_MSG_RESULT([yes])
482                         OPENIBNAL="openibnal"
483                 ],[
484                         AC_MSG_RESULT([no])
485                         OPENIBNAL=""
486                         OPENIBCPPFLAGS=""
487                 ])
488         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
489         AC_SUBST(OPENIBCPPFLAGS)
490         AC_SUBST(OPENIBNAL)
491
492         #### Infinicon IB
493         AC_MSG_CHECKING([if Infinicon IB kernel headers are present])
494         # for how the only infinicon ib build has headers in /usr/include/iba
495         IIBCPPFLAGS="-I/usr/include -DIN_TREE_BUILD"
496         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
497         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
498         LUSTRE_MODULE_TRY_COMPILE(
499                 [
500                         #include <linux/iba/ibt.h>
501                 ],[
502                         IBT_INTERFACE_UNION interfaces;
503                         FSTATUS             rc;
504
505                         rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
506                                                       &interfaces);
507
508                         return rc == FSUCCESS ? 0 : 1;
509                 ],[
510                         AC_MSG_RESULT([yes])
511                         IIBNAL="iibnal"
512                 ],[
513                         AC_MSG_RESULT([no])
514                         IIBNAL=""
515                         IIBCPPFLAGS=""
516                 ])
517         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
518         AC_SUBST(IIBCPPFLAGS)
519         AC_SUBST(IIBNAL)
520
521         # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
522         # But other kernels don't
523
524         AC_MSG_CHECKING([if struct kiobuf has a dovary field])
525         LUSTRE_MODULE_TRY_COMPILE(
526                 [
527                         #include <linux/iobuf.h>
528                 ],[
529                         struct kiobuf iobuf;
530                         iobuf.dovary = 1;
531                 ],[
532                         AC_MSG_RESULT([yes])
533                         AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
534                 ],[
535                         AC_MSG_RESULT([no])
536                 ])      
537
538         # ----------- 2.6.4 no longer has page->list ---------------
539         AC_MSG_CHECKING([if struct page has a list field])
540         LUSTRE_MODULE_TRY_COMPILE(
541                 [
542                         #include <linux/mm.h>
543                 ],[
544                         struct page page;
545                         &page.list;
546                 ],[
547                         AC_MSG_RESULT([yes])
548                         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
549                 ],[
550                         AC_MSG_RESULT([no])
551                 ])
552
553         # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
554         # This needs to run after we've defined the KCPPFLAGS
555
556         AC_MSG_CHECKING([if task_struct has a sighand field])
557         LUSTRE_MODULE_TRY_COMPILE(
558                 [
559                         #include <linux/sched.h>
560                 ],[
561                         struct task_struct p;
562                         p.sighand = NULL;
563                 ],[
564                         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
565                         AC_MSG_RESULT([yes])
566                 ],[
567                         AC_MSG_RESULT([no])
568                 ])
569
570         # ---------- 2.4.20 introduced cond_resched --------------
571
572         AC_MSG_CHECKING([if kernel offers cond_resched])
573         LUSTRE_MODULE_TRY_COMPILE(
574                 [
575                         #include <linux/sched.h>
576                 ],[
577                         cond_resched();
578                 ],[
579                         AC_MSG_RESULT([yes])
580                         AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
581                 ],[
582                         AC_MSG_RESULT([no])
583                 ])
584
585         # --------- zap_page_range(vma) --------------------------------
586         AC_MSG_CHECKING([if zap_pag_range with vma parameter])
587         ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
588         if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
589                 AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
590                 AC_MSG_RESULT([yes])
591         else
592                 AC_MSG_RESULT([no])
593         fi
594
595         # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
596
597         AC_MSG_CHECKING([if kernel defines PDE])
598         HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
599         if test "$HAVE_PDE" != 0 ; then
600                 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
601                 AC_MSG_RESULT([yes])
602         else
603                 AC_MSG_RESULT([no])
604         fi
605
606         AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
607         HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
608         if test "$HAVE_DIO_FILE" != 0 ; then
609                 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
610                 AC_MSG_RESULT(yes)
611         else
612                 AC_MSG_RESULT(no)
613         fi
614
615         AC_MSG_CHECKING([if kernel defines cpu_online()])
616         LUSTRE_MODULE_TRY_COMPILE(
617                 [
618                         #include <linux/sched.h>
619                 ],[
620                         cpu_online(0);
621                 ],[
622                         AC_MSG_RESULT([yes])
623                         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
624                 ],[
625                         AC_MSG_RESULT([no])
626                 ])
627         AC_MSG_CHECKING([if kernel defines cpumask_t])
628         LUSTRE_MODULE_TRY_COMPILE(
629                 [
630                         #include <linux/sched.h>
631                 ],[
632                         return sizeof (cpumask_t);
633                 ],[
634                         AC_MSG_RESULT([yes])
635                         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
636                 ],[
637                         AC_MSG_RESULT([no])
638                 ])
639
640         # ---------- RHEL kernels define page_count in mm_inline.h
641         AC_MSG_CHECKING([if kernel has mm_inline.h header])
642         LUSTRE_MODULE_TRY_COMPILE(
643                 [
644                         #include <linux/mm_inline.h>
645                 ],[
646                         #ifndef page_count
647                         #error mm_inline.h does not define page_count
648                         #endif
649                 ],[
650                         AC_MSG_RESULT([yes])
651                         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
652                 ],[
653                         AC_MSG_RESULT([no])
654                 ])
655
656         # ---------- inode->i_alloc_sem --------------
657         AC_MSG_CHECKING([if struct inode has i_alloc_sem])
658         LUSTRE_MODULE_TRY_COMPILE(
659                 [
660                         #include <linux/fs.h>
661                         #include <linux/version.h>
662                 ],[
663                         #if defined(CONFIG_X86_64) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
664                         #error "x86_64 down_read_trylock broken before 2.4.24"
665                         #endif
666                         struct inode i;
667                         return (char *)&i.i_alloc_sem - (char *)&i;
668                 ],[
669                         AC_MSG_RESULT([yes])
670                         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
671                 ],[
672                         AC_MSG_RESULT([no])
673                 ])
674
675
676         # ---------- modules? ------------------------
677         AC_MSG_CHECKING([for module support])
678         LUSTRE_MODULE_TRY_COMPILE(
679                 [
680                         #include <linux/config.h>
681                 ],[
682                         #ifndef CONFIG_MODULES
683                         #error CONFIG_MODULES not #defined
684                         #endif
685                 ],[
686                         AC_MSG_RESULT([yes])
687                 ],[
688                         AC_MSG_RESULT([no])
689                         AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
690                 ])
691
692         # ---------- modversions? --------------------
693         AC_MSG_CHECKING([for MODVERSIONS])
694         LUSTRE_MODULE_TRY_COMPILE(
695                 [
696                         #include <linux/config.h>
697                 ],[
698                         #ifndef CONFIG_MODVERSIONS
699                         #error CONFIG_MODVERSIONS not #defined
700                         #endif
701                 ],[
702                         AC_MSG_RESULT([yes])
703                 ],[
704                         AC_MSG_RESULT([no])
705                 ])
706
707         # ------------ preempt -----------------------
708         AC_MSG_CHECKING([if preempt is enabled])
709         LUSTRE_MODULE_TRY_COMPILE(
710                 [
711                         #include <linux/config.h>
712                 ],[
713                         #ifndef CONFIG_PREEMPT
714                         #error CONFIG_PREEMPT is not #defined
715                         #endif
716                 ],[
717                         AC_MSG_RESULT([yes])
718                         AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
719                 ],[
720                         AC_MSG_RESULT([no])
721                 ])
722
723         case $BACKINGFS in
724                 ext3)
725                         # --- Check that ext3 and ext3 xattr are enabled in the kernel
726                         AC_MSG_CHECKING([that ext3 is enabled in the kernel])
727                         LUSTRE_MODULE_TRY_COMPILE(
728                                 [
729                                         #include <linux/config.h>
730                                 ],[
731                                         #ifndef CONFIG_EXT3_FS
732                                         #ifndef CONFIG_EXT3_FS_MODULE
733                                         #error CONFIG_EXT3_FS not #defined
734                                         #endif
735                                         #endif
736                                 ],[
737                                         AC_MSG_RESULT([yes])
738                                 ],[
739                                         AC_MSG_RESULT([no])
740                                         AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
741                                 ])
742         
743                         AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
744                         LUSTRE_MODULE_TRY_COMPILE(
745                                 [
746                                         #include <linux/config.h>
747                                 ],[
748                                         #ifndef CONFIG_EXT3_FS_XATTR
749                                         #error CONFIG_EXT3_FS_XATTR not #defined
750                                         #endif
751                                 ],[
752                                         AC_MSG_RESULT([yes])
753                                 ],[
754                                         AC_MSG_RESULT([no])
755                                         AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
756                                         AC_MSG_WARN([This build may fail.])
757                                 ])
758                         ;;
759                 ldiskfs)
760                         AC_MSG_CHECKING([if fshooks are present])
761                         LUSTRE_MODULE_TRY_COMPILE(
762                                 [
763                                         #include <linux/fshooks.h>
764                                 ],[],[
765                                         AC_MSG_RESULT([yes])
766                                         LDISKFS_SERIES="2.6-suse.series"
767                                 ],[
768                                         AC_MSG_RESULT([no])
769                                         LDISKFS_SERIES="2.6-vanilla.series"
770                                 ])
771                         AC_SUBST(LDISKFS_SERIES)
772                         # --- check which ldiskfs series we should use
773                         ;;
774         esac # $BACKINGFS
775 fi
776
777 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
778 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
779 AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
780 AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal")
781
782 # portals/utils/portals.c
783 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h])
784 AC_CHECK_FUNCS([gethostbyname socket connect])
785
786 # portals/utils/debug.c
787 AC_CHECK_HEADERS([linux/version.h])
788
789 # include/liblustre.h
790 AC_CHECK_HEADERS([asm/page.h sys/user.h stdint.h])
791
792 # liblustre/llite_lib.h
793 AC_CHECK_HEADERS([xtio.h file.h])
794
795 # liblustre/dir.c
796 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
797
798 # liblustre/lutil.c
799 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
800 AC_CHECK_FUNCS([inet_ntoa])
801
802 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
803 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
804 AC_SUBST(EXTRA_KCFLAGS)
805
806 echo "CPPFLAGS: $CPPFLAGS"
807 echo "LLCPPFLAGS: $LLCPPFLAGS"
808 echo "CFLAGS: $CFLAGS"
809 echo "EXTRA_KCFLAGS: $EXTRA_KCFLAGS"
810 echo "LLCFLAGS: $LLCFLAGS"