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