Whamcloud - gitweb
7d807da5e7e09d2b75a3d84cfefbe5a3a9272032
[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         # -------- 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         #### Rapid Array
535         AC_MSG_CHECKING([if RapidArray kernel headers are present])
536         # placeholder
537         RACPPFLAGS="-I/tmp"
538         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
539         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
540         LUSTRE_MODULE_TRY_COMPILE(
541                 [
542                         #include <linux/types.h>
543                         #include <rapl.h>
544                 ],[
545                         RAP_RETURN          rc;
546                         RAP_PVOID           dev_handle;
547
548                         rc = RapkGetDeviceByIndex(0, NULL, NULL, &dev_handle);
549
550                         return rc == RAP_SUCCESS ? 0 : 1;
551                 ],[
552                         AC_MSG_RESULT([yes])
553                         RANAL="ranal"
554                 ],[
555                         AC_MSG_RESULT([no])
556                         RANAL=""
557                         RACPPFLAGS=""
558                 ])
559         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
560         AC_SUBST(RACPPFLAGS)
561         AC_SUBST(RANAL)
562
563         # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
564         # But other kernels don't
565
566         AC_MSG_CHECKING([if struct kiobuf has a dovary field])
567         LUSTRE_MODULE_TRY_COMPILE(
568                 [
569                         #include <linux/iobuf.h>
570                 ],[
571                         struct kiobuf iobuf;
572                         iobuf.dovary = 1;
573                 ],[
574                         AC_MSG_RESULT([yes])
575                         AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
576                 ],[
577                         AC_MSG_RESULT([no])
578                 ])      
579
580         # ----------- 2.6.4 no longer has page->list ---------------
581         AC_MSG_CHECKING([if struct page has a list field])
582         LUSTRE_MODULE_TRY_COMPILE(
583                 [
584                         #include <linux/mm.h>
585                 ],[
586                         struct page page;
587                         &page.list;
588                 ],[
589                         AC_MSG_RESULT([yes])
590                         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
591                 ],[
592                         AC_MSG_RESULT([no])
593                 ])
594
595         # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
596         # This needs to run after we've defined the KCPPFLAGS
597
598         AC_MSG_CHECKING([if task_struct has a sighand field])
599         LUSTRE_MODULE_TRY_COMPILE(
600                 [
601                         #include <linux/sched.h>
602                 ],[
603                         struct task_struct p;
604                         p.sighand = NULL;
605                 ],[
606                         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
607                         AC_MSG_RESULT([yes])
608                 ],[
609                         AC_MSG_RESULT([no])
610                 ])
611
612         # ---------- 2.4.20 introduced cond_resched --------------
613
614         AC_MSG_CHECKING([if kernel offers cond_resched])
615         LUSTRE_MODULE_TRY_COMPILE(
616                 [
617                         #include <linux/sched.h>
618                 ],[
619                         cond_resched();
620                 ],[
621                         AC_MSG_RESULT([yes])
622                         AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
623                 ],[
624                         AC_MSG_RESULT([no])
625                 ])
626
627         # --------- zap_page_range(vma) --------------------------------
628         AC_MSG_CHECKING([if zap_pag_range with vma parameter])
629         ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
630         if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
631                 AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
632                 AC_MSG_RESULT([yes])
633         else
634                 AC_MSG_RESULT([no])
635         fi
636
637         # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
638
639         AC_MSG_CHECKING([if kernel defines PDE])
640         HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
641         if test "$HAVE_PDE" != 0 ; then
642                 AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
643                 AC_MSG_RESULT([yes])
644         else
645                 AC_MSG_RESULT([no])
646         fi
647
648         AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
649         HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
650         if test "$HAVE_DIO_FILE" != 0 ; then
651                 AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
652                 AC_MSG_RESULT(yes)
653         else
654                 AC_MSG_RESULT(no)
655         fi
656
657         AC_MSG_CHECKING([if kernel defines cpu_online()])
658         LUSTRE_MODULE_TRY_COMPILE(
659                 [
660                         #include <linux/sched.h>
661                 ],[
662                         cpu_online(0);
663                 ],[
664                         AC_MSG_RESULT([yes])
665                         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
666                 ],[
667                         AC_MSG_RESULT([no])
668                 ])
669         AC_MSG_CHECKING([if kernel defines cpumask_t])
670         LUSTRE_MODULE_TRY_COMPILE(
671                 [
672                         #include <linux/sched.h>
673                 ],[
674                         return sizeof (cpumask_t);
675                 ],[
676                         AC_MSG_RESULT([yes])
677                         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
678                 ],[
679                         AC_MSG_RESULT([no])
680                 ])
681
682         # ---------- RHEL kernels define page_count in mm_inline.h
683         AC_MSG_CHECKING([if kernel has mm_inline.h header])
684         LUSTRE_MODULE_TRY_COMPILE(
685                 [
686                         #include <linux/mm_inline.h>
687                 ],[
688                         #ifndef page_count
689                         #error mm_inline.h does not define page_count
690                         #endif
691                 ],[
692                         AC_MSG_RESULT([yes])
693                         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
694                 ],[
695                         AC_MSG_RESULT([no])
696                 ])
697
698         # ---------- inode->i_alloc_sem --------------
699         AC_MSG_CHECKING([if struct inode has i_alloc_sem])
700         LUSTRE_MODULE_TRY_COMPILE(
701                 [
702                         #include <linux/fs.h>
703                         #include <linux/version.h>
704                 ],[
705                         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
706                         #error "down_read_trylock broken before 2.4.24"
707                         #endif
708                         struct inode i;
709                         return (char *)&i.i_alloc_sem - (char *)&i;
710                 ],[
711                         AC_MSG_RESULT([yes])
712                         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
713                 ],[
714                         AC_MSG_RESULT([no])
715                 ])
716
717
718         # ---------- modules? ------------------------
719         AC_MSG_CHECKING([for module support])
720         LUSTRE_MODULE_TRY_COMPILE(
721                 [
722                         #include <linux/config.h>
723                 ],[
724                         #ifndef CONFIG_MODULES
725                         #error CONFIG_MODULES not #defined
726                         #endif
727                 ],[
728                         AC_MSG_RESULT([yes])
729                 ],[
730                         AC_MSG_RESULT([no])
731                         AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
732                 ])
733
734         # ---------- modversions? --------------------
735         AC_MSG_CHECKING([for MODVERSIONS])
736         LUSTRE_MODULE_TRY_COMPILE(
737                 [
738                         #include <linux/config.h>
739                 ],[
740                         #ifndef CONFIG_MODVERSIONS
741                         #error CONFIG_MODVERSIONS not #defined
742                         #endif
743                 ],[
744                         AC_MSG_RESULT([yes])
745                 ],[
746                         AC_MSG_RESULT([no])
747                 ])
748
749         # ------------ preempt -----------------------
750         AC_MSG_CHECKING([if preempt is enabled])
751         LUSTRE_MODULE_TRY_COMPILE(
752                 [
753                         #include <linux/config.h>
754                 ],[
755                         #ifndef CONFIG_PREEMPT
756                         #error CONFIG_PREEMPT is not #defined
757                         #endif
758                 ],[
759                         AC_MSG_RESULT([yes])
760                         AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
761                 ],[
762                         AC_MSG_RESULT([no])
763                 ])
764
765         # ------------ kallsyms (so software watchdogs produce useful stacks)
766         AC_MSG_CHECKING([if kallsyms is enabled])
767         LUSTRE_MODULE_TRY_COMPILE(
768                 [
769                         #include <linux/config.h>
770                 ],[
771                         #ifndef CONFIG_KALLSYMS
772                         #error CONFIG_KALLSYMS is not #defined
773                         #endif
774                 ],[
775                         AC_MSG_RESULT([yes])
776                 ],[
777                         AC_MSG_RESULT([no])
778                         if test "x$ARCH_UM" = "x" ; then
779                                 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
780                         fi
781                 ])
782
783         # ------------ check for our show_task patch
784         AC_MSG_CHECKING([if kernel exports show_task])
785         have_show_task=0
786         for file in ksyms sched ; do
787                 if grep -q "EXPORT_SYMBOL(show_task)" \
788                          "$LINUX/kernel/$file.c" 2>/dev/null ; then
789                         have_show_task=1
790                         break
791                 fi
792         done
793         if test x$have_show_task = x1 ; then
794                 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
795                 AC_MSG_RESULT(yes)
796         else
797                 AC_MSG_RESULT(no)
798         fi
799
800         case $BACKINGFS in
801                 ext3)
802                         # --- Check that ext3 and ext3 xattr are enabled in the kernel
803                         AC_MSG_CHECKING([that ext3 is enabled in the kernel])
804                         LUSTRE_MODULE_TRY_COMPILE(
805                                 [
806                                         #include <linux/config.h>
807                                 ],[
808                                         #ifndef CONFIG_EXT3_FS
809                                         #ifndef CONFIG_EXT3_FS_MODULE
810                                         #error CONFIG_EXT3_FS not #defined
811                                         #endif
812                                         #endif
813                                 ],[
814                                         AC_MSG_RESULT([yes])
815                                 ],[
816                                         AC_MSG_RESULT([no])
817                                         AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
818                                 ])
819         
820                         AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
821                         LUSTRE_MODULE_TRY_COMPILE(
822                                 [
823                                         #include <linux/config.h>
824                                 ],[
825                                         #ifndef CONFIG_EXT3_FS_XATTR
826                                         #error CONFIG_EXT3_FS_XATTR not #defined
827                                         #endif
828                                 ],[
829                                         AC_MSG_RESULT([yes])
830                                 ],[
831                                         AC_MSG_RESULT([no])
832                                         AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
833                                         AC_MSG_WARN([This build may fail.])
834                                 ])
835                         ;;
836                 ldiskfs)
837                         AC_MSG_CHECKING([if fshooks are present])
838                         LUSTRE_MODULE_TRY_COMPILE(
839                                 [
840                                         #include <linux/fshooks.h>
841                                 ],[],[
842                                         AC_MSG_RESULT([yes])
843                                         LDISKFS_SERIES="2.6-suse.series"
844                                 ],[
845                                         AC_MSG_RESULT([no])
846                                         LDISKFS_SERIES="2.6-vanilla.series"
847                                 ])
848                         AC_SUBST(LDISKFS_SERIES)
849                         # --- check which ldiskfs series we should use
850                         ;;
851         esac # $BACKINGFS
852 fi
853
854 AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
855 AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
856 AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
857 AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal")
858 AM_CONDITIONAL(BUILD_RANAL, test x$RANAL = "xranal")
859
860 # portals/utils/portals.c
861 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h])
862 AC_CHECK_FUNCS([gethostbyname socket connect])
863
864 # portals/utils/debug.c
865 AC_CHECK_HEADERS([linux/version.h])
866
867 # include/liblustre.h
868 AC_CHECK_HEADERS([asm/page.h sys/user.h stdint.h])
869
870 # liblustre/llite_lib.h
871 AC_CHECK_HEADERS([xtio.h file.h])
872
873 # liblustre/dir.c
874 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
875
876 # liblustre/lutil.c
877 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
878 AC_CHECK_FUNCS([inet_ntoa])
879
880 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
881 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
882 AC_SUBST(EXTRA_KCFLAGS)
883
884 echo "CPPFLAGS: $CPPFLAGS"
885 echo "LLCPPFLAGS: $LLCPPFLAGS"
886 echo "CFLAGS: $CFLAGS"
887 echo "EXTRA_KCFLAGS: $EXTRA_KCFLAGS"
888 echo "LLCFLAGS: $LLCFLAGS"
889
890 ENABLE_INIT_SCRIPTS=0
891 if test x$enable_utils = xyes ; then
892         AC_MSG_CHECKING([whether to install init scripts])
893         # our scripts only work on red hat systems
894         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
895                 ENABLE_INIT_SCRIPTS=1
896                 AC_MSG_RESULT([yes])
897         else
898                 AC_MSG_RESULT([no])
899         fi
900 fi
901 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
902 AC_SUBST(ENABLE_INIT_SCRIPTS)