Whamcloud - gitweb
land b_smallfix 20040407_1414:
[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([Makefile.am],[],
4         [AC_ERROR([At this time, Lustre does not support building kernel modules with srcdir != buildir.])])
5 fi
6
7 # -------- in kernel compilation? (2.5 only) -------------
8 AC_MSG_CHECKING([if inkernel build support is requested])
9 AC_ARG_ENABLE([inkernel],
10         AC_HELP_STRING([--enable-inkernel],
11                        [set up 2.5 kernel makefiles]),
12         [],[enable_inkernel=no])
13 AC_MSG_RESULT([$enable_inkernel])
14 AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes)
15
16 # -------- are we building against an external portals? -------
17 AC_MSG_CHECKING([if Cray portals should be used])
18 AC_ARG_WITH([cray-portals],
19         AC_HELP_STRING([--with-cray-portals=path],
20                        [path to cray portals]),
21         [
22                 CRAY_PORTALS_INCLUDE="-I$with_cray_portals"
23                 AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
24         ],[with_cray_portals=no])
25 AC_MSG_RESULT([$with_cray_portals])
26 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
27 if test x$enable_tests = xno ; then
28         AC_MSG_NOTICE([disabling tests])
29         enable_tests=no
30 fi
31 if test x$enable_utils = xno ; then
32         AC_MSG_NOTICE([disabling utilities])
33         enable_utils=no
34 fi
35
36 # -------- set linuxdir ------------
37 AC_MSG_CHECKING([for Linux sources])
38 AC_ARG_WITH([linux],
39         AC_HELP_STRING([--with-linux=path],
40                        [set path to Linux source (default=/usr/src/linux)]),
41         [LINUX=$with_linux],
42         [LINUX=/usr/src/linux])
43 AC_MSG_RESULT([$LINUX])
44 AC_SUBST(LINUX)
45 if test x$enable_inkernel = xyes ; then
46         echo ln -s `pwd` $LINUX/fs/lustre
47         rm $LINUX/fs/lustre
48         ln -s `pwd` $LINUX/fs/lustre
49 fi
50
51 #  --------------------
52 ARCH_UM=
53 UML_CFLAGS=
54 if test x$enable_modules != xno ; then
55         AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
56         if test -e $LINUX/include/asm-um ; then
57                 if test  X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
58                         ARCH_UM='ARCH=um'
59                         # see notes in Rules.in
60                         UML_CFLAGS='-O0'
61                         AC_MSG_RESULT(yes)
62                 else
63                         AC_MSG_RESULT([no (asm doesn't point at asm-um)])
64                 fi
65         else 
66                 AC_MSG_RESULT([no (asm-um missing)])
67         fi
68 fi
69 AC_SUBST(ARCH_UM)
70 AC_SUBST(UML_CFLAGS)
71 # --------- Linux 25 ------------------
72
73 AC_MSG_CHECKING([if you are running linux 2.5])
74 if test -e $LINUX/include/linux/namei.h ; then
75         linux25="yes"
76         KMODEXT=".ko"
77 else
78         KMODEXT=".o"
79         linux25="no"
80 fi
81 AC_MSG_RESULT([$linux25])
82 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
83 AC_SUBST(KMODEXT)
84
85 # -------  Makeflags ------------------
86
87 CPPFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include"
88
89 # liblustre are all the same
90 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
91 AC_SUBST(LLCPPFLAGS)
92
93 LLCFLAGS="-g -Wall -fPIC"
94 AC_SUBST(LLCFLAGS)
95
96 # everyone builds against portals and lustre
97
98 if test x$enable_ldiskfs = xyes ; then
99         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
100         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
101         AC_DEFINE(CONFIG_LDISKFS_POSIX_ACL, 1, [enable posix acls])
102         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
103 fi
104
105 EXTRA_KCFLAGS="-g -I$PWD/portals/include -I$PWD/include $CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE"
106
107 # ----------- make dep run? ------------------
108
109 if test x$enable_modules != xno ; then
110         AC_MSG_CHECKING([if make dep has been run in kernel source (host $host_cpu)])
111         if test -f $LINUX/include/linux/config.h ; then
112                 AC_MSG_RESULT([yes])
113         else
114                 AC_MSG_RESULT([no])
115                 AC_MSG_ERROR([** cannot find $LINUX/include/linux/config.h. Run make dep in $LINUX.])
116         fi
117 fi
118
119 # ------------ include paths ------------------
120
121 if test x$enable_modules != xno ; then
122         # ------------ autoconf.h ------------------
123         AC_MSG_CHECKING([if autoconf.h is in kernel source])
124         if test -f $LINUX/include/linux/autoconf.h ; then
125                 AC_MSG_RESULT(yes)
126         else
127                 AC_MSG_RESULT(no)
128                 AC_MSG_ERROR([** cannot find $LINUX/include/linux/autoconf.h. Run make config in $LINUX.])
129         fi
130
131         # ------------ LINUXRELEASE and moduledir ------------------
132         AC_MSG_CHECKING([for Linux release])
133
134         # this is bogus, as it doesn't work against kernel-source rpms  
135         dnl We need to rid ourselves of the nasty [ ] quotes.
136         changequote(, )
137         dnl Get release from version.h
138         LINUXRELEASE="`sed -ne 's/.*UTS_RELEASE[ \"]*\([0-9.a-zA-Z_-]*\).*/\1/p' $LINUX/include/linux/version.h`"
139         changequote([, ])
140
141         moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
142         AC_SUBST(moduledir)
143
144         modulefsdir='$(moduledir)/fs/$(PACKAGE)'
145         AC_SUBST(modulefsdir)
146
147         AC_MSG_RESULT($LINUXRELEASE)
148         AC_SUBST(LINUXRELEASE)
149
150         # ------------ RELEASE --------------------------------
151         AC_MSG_CHECKING([lustre release])
152   
153         dnl We need to rid ourselves of the nasty [ ] quotes.
154         changequote(, )
155         dnl Get release from version.h
156         RELEASE="`sed -ne 's/-/_/g' -e 's/.*UTS_RELEASE[ \"]*\([0-9.a-zA-Z_]*\).*/\1/p' $LINUX/include/linux/version.h`_`date +%Y%m%d%H%M`"
157         changequote([, ])
158
159         AC_MSG_RESULT($RELEASE)
160         AC_SUBST(RELEASE)
161 fi
162
163 # ---------- Portals flags --------------------
164
165 #AC_PREFIX_DEFAULT([])
166 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
167 #  usrprefix=/usr
168 #else
169 #  usrprefix='${prefix}'
170 #fi
171 #AC_SUBST(usrprefix)
172
173 AC_MSG_CHECKING([for zero-copy TCP support])
174 AC_ARG_ENABLE([zerocopy],
175         AC_HELP_STRING([--disable-zerocopy],
176                        [disable socknal zerocopy]),
177         [],[enable_zerocopy='yes'])
178 if test x$enable_zerocopy = xno ; then
179         AC_MSG_RESULT([no (by request)])
180 else
181         ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
182         if test "$ZCCD" != 0 ; then
183                 AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
184                 AC_MSG_RESULT(yes)
185         else
186                 AC_MSG_RESULT([no (no kernel support)])
187         fi
188 fi
189
190 AC_MSG_CHECKING([for CPU affinity support])
191 AC_ARG_ENABLE([affinity],
192         AC_HELP_STRING([--disable-affinity],
193                        [disable process/irq affinity]),
194         [],[enable_affinity='yes'])
195 if test x$enable_affinity = xno ; then
196         AC_MSG_RESULT([no (by request)])
197 else
198         SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
199         if test "$SET_CPUS_ALLOW" != 0 ; then
200                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
201                 AC_MSG_RESULT([yes])
202         else
203                 AC_MSG_RESULT([no (no kernel support)])
204         fi
205 fi
206
207
208 #####################################
209
210 AC_MSG_CHECKING([if quadrics kernel headers are present])
211 if test -d $LINUX/drivers/net/qsnet ; then
212         AC_MSG_RESULT([yes])
213         QSWNAL="qswnal"
214         AC_MSG_CHECKING([for multirail EKC])
215         if test -f $LINUX/include/elan/epcomms.h; then
216                 AC_MSG_RESULT([supported])
217                 QSWCPPFLAGS="-DMULTIRAIL_EKC=1"
218         else
219                 AC_MSG_RESULT([not supported])
220                 QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include"
221         fi
222 else
223         AC_MSG_RESULT([no])
224         QSWNAL=""
225         QSWCPPFLAGS=""
226 fi
227 AC_SUBST(QSWCPPFLAGS)
228 AC_SUBST(QSWNAL)
229
230 AC_MSG_CHECKING([if gm support was requested])
231 AC_ARG_WITH([gm],
232         AC_HELP_STRING([--with-gm=path],
233                        [build gmnal against path]),
234         [
235                 case $with_gm in 
236                         yes)
237                                 AC_MSG_RESULT([yes])
238                                 GMCPPFLAGS="-I/usr/local/gm/include"
239                                 GMNAL="gmnal"
240                                 ;;
241                         no)
242                                 AC_MSG_RESULT([no])
243                                 GMCPPFLAGS=""
244                                 GMNAL=""
245                                 ;;
246                         *)
247                                 AC_MSG_RESULT([yes])
248                                 GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
249                                 GMNAL="gmnal"
250                                 ;;
251                 esac
252         ],[
253                 AC_MSG_RESULT([no])
254                 GMCPPFLAGS=""
255                 GMNAL=""
256         ])
257 AC_SUBST(GMCPPFLAGS)
258 AC_SUBST(GMNAL)
259
260
261 #fixme: where are the default IB includes?
262 default_ib_include_dir=/usr/local/ib/include
263 an_ib_include_file=vapi.h
264
265 AC_MSG_CHECKING([if ib nal support was requested])
266 AC_ARG_WITH([ib],
267         AC_HELP_STRING([--with-ib=yes/no/path],
268                        [Path to IB includes]),
269         [
270                 case $with_ib in
271                         yes)
272                                 AC_MSG_RESULT([yes])
273                                 IBCPPFLAGS="-I/usr/local/ib/include"
274                                 IBNAL="ibnal"
275                                 ;;
276                         no)
277                                 AC_MSG_RESULT([no])
278                                 IBCPPFLAGS=""
279                                 IBNAL=""
280                                 ;;
281                         *)
282                                 AC_MSG_RESULT([yes])
283                                 IBCPPFLAGS="-I$with_ib"
284                                 IBNAL=""
285                                 ;;
286                 esac
287         ],[
288                 AC_MSG_RESULT([no])
289                 IBFLAGS=""
290                 IBNAL=""
291         ])
292 AC_SUBST(IBNAL)
293 AC_SUBST(IBCPPFLAGS)
294
295
296 def_scamac=/opt/scali/include
297 AC_MSG_CHECKING([if ScaMAC support was requested])
298 AC_ARG_WITH([scamac],
299         AC_HELP_STRING([--with-scamac=yes/no/path],
300                        [Path to ScaMAC includes (default=/opt/scali/include)]),
301         [
302                 case $with_scamac in
303                         yes)
304                                 AC_MSG_RESULT([yes])
305                                 SCIMACCPPFLAGS="-I/opt/scali/include"
306                                 SCIMACNAL="scimacnal"
307                                 ;;
308                         no)
309                                 AC_MSG_RESULT([no])
310                                 SCIMACCPPFLAGS=""
311                                 SCIMACNAL=""
312                                 ;;
313                         *)
314                                 AC_MSG_RESULT([yes])
315                                 SCIMACCPPFLAGS="-I$with_scamac -I$with_scamac/icm"
316                                 SCIMACNAL="scimacnal"
317                                 ;;
318                 esac
319         ],[
320                 AC_MSG_RESULT([no])
321                 SCIMACCPPFLAGS=""
322                 SCIMACNAL=""
323         ])
324 AC_SUBST(SCIMACCPPFLAGS)
325 AC_SUBST(SCIMACNAL)
326 # if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then
327
328 AC_SUBST(MOD_LINK)
329 AC_SUBST(LINUX25)
330
331 # these are like AC_TRY_COMPILE, but try to build modules against the
332 # kernel, inside the kernel-tests directory
333
334 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
335 [cat >conftest.c <<_ACEOF
336 $1
337 _ACEOF
338 ])
339
340 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
341 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
342 rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko
343 AS_IF([_AC_EVAL_STDERR([cp conftest.c kernel-tests && make modules -C $LINUX $ARCH_UM SUBDIRS=$PWD/kernel-tests >/dev/null]) &&
344         AC_TRY_COMMAND([test -s kernel-tests/conftest.o])],
345         [$2],
346         [_AC_MSG_LOG_CONFTEST
347 m4_ifvaln([$3],[$3])dnl])dnl
348 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
349 ])
350
351 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
352 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4])])
353
354 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
355 # But other kernels don't
356
357 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
358 LUSTRE_MODULE_TRY_COMPILE(
359         [
360                 #include <linux/iobuf.h>
361         ],[
362                 struct kiobuf iobuf;
363                 iobuf.dovary = 1;
364         ],[
365                 AC_MSG_RESULT([yes])
366                 AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
367         ],[
368                 AC_MSG_RESULT([no])
369         ])
370
371 # ----------- 2.6.4 no longer has page->list ---------------
372 AC_MSG_CHECKING([if struct page has a list field])
373 LUSTRE_MODULE_TRY_COMPILE(
374         [
375                 #include <linux/mm.h>
376         ],[
377                 struct page page;
378                 &page.list;
379         ],[
380                 AC_MSG_RESULT([yes])
381                 AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
382         ],[
383                 AC_MSG_RESULT([no])
384         ])
385
386 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
387 # This needs to run after we've defined the KCPPFLAGS
388
389 AC_MSG_CHECKING([for kernel version])
390 LUSTRE_MODULE_TRY_COMPILE(
391         [
392                 #include <linux/sched.h>
393         ],[
394                 struct task_struct p;
395                 p.sighand = NULL;
396         ],[
397                 AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
398                 AC_MSG_RESULT([redhat-2.4.20])
399         ],[
400                 AC_MSG_RESULT([$LINUXRELEASE])
401         ])
402
403 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
404
405 AC_MSG_CHECKING([if kernel defines PDE])
406 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
407 if test "$HAVE_PDE" != 0 ; then
408         AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
409         AC_MSG_RESULT([yes])
410 else
411         AC_MSG_RESULT([no])
412 fi
413
414 AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
415 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
416 if test "$HAVE_DIO_FILE" != 0 ; then
417         AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
418         AC_MSG_RESULT(yes)
419 else
420         AC_MSG_RESULT(no)
421 fi
422
423 if test x$enable_modules != xno ; then
424         # ---------- modules? ------------------------
425         AC_MSG_CHECKING([for module support])
426         LUSTRE_MODULE_TRY_COMPILE(
427                 [
428                         #include <linux/config.h>
429                 ],[
430                         #ifndef CONFIG_MODULES
431                         #error CONFIG_MODULES not #defined
432                         #endif
433                 ],[
434                         AC_MSG_RESULT([yes])
435                 ],[
436                         AC_MSG_RESULT([no])
437                         AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
438                 ])
439
440         # ---------- modversions? --------------------
441         AC_MSG_CHECKING([for MODVERSIONS])
442         LUSTRE_MODULE_TRY_COMPILE(
443                 [
444                         #include <linux/config.h>
445                 ],[
446                         #ifndef CONFIG_MODVERSIONS
447                         #error CONFIG_MODVERSIONS not #defined
448                         #endif
449                 ],[
450                         AC_MSG_RESULT([yes])
451                 ],[
452                         AC_MSG_RESULT([no])
453                 ])
454
455         if test $BACKINGFS = 'ext3' ; then
456                 # --- Check that ext3 and ext3 xattr are enabled in the kernel
457                 AC_MSG_CHECKING([that ext3 is enabled in the kernel])
458                 LUSTRE_MODULE_TRY_COMPILE(
459                         [
460                                 #include <linux/config.h>
461                         ],[
462                                 #ifndef CONFIG_EXT3_FS
463                                 #ifndef CONFIG_EXT3_FS_MODULE
464                                 #error CONFIG_EXT3_FS not #defined
465                                 #endif
466                                 #endif
467                         ],[
468                                 AC_MSG_RESULT([yes])
469                         ],[
470                                 AC_MSG_RESULT([no])
471                                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
472                         ])
473
474                 AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
475                 LUSTRE_MODULE_TRY_COMPILE(
476                         [
477                                 #include <linux/config.h>
478                         ],[
479                                 #ifndef CONFIG_EXT3_FS_XATTR
480                                 #error CONFIG_EXT3_FS_XATTR not #defined
481                                 #endif
482                         ],[
483                                 AC_MSG_RESULT([yes])
484                         ],[
485                                 AC_MSG_RESULT([no])
486                                 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)])
487                                 AC_MSG_WARN([This build may fail.])
488                         ])
489         fi # BACKINGFS = ext3
490 fi
491
492 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
493 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
494 AC_SUBST(EXTRA_KCFLAGS)
495
496 #echo "KCPPFLAGS: $KCPPFLAGS"
497 #echo "KCFLAGS: $KCFLAGS"
498 #echo "LLCPPFLAGS: $LLCPPFLAGS"
499 #echo "LLCFLAGS: $LLCFLAGS"
500 #echo "MOD_LINK: $MOD_LINK"
501 #echo "CFLAGS: $CFLAGS"
502 #echo "CPPFLAGS: $CPPFLAGS"