Whamcloud - gitweb
liblustre:
[fs/lustre-release.git] / lnet / archdep.m4
1
2 # -------- in kernel compilation? (2.5 only) -------------
3 AC_ARG_ENABLE(inkernel, [  --enable-inkernel set up 2.5 kernel makefiles])
4 AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes)
5 echo "Makefile for in kernel build: $INKERNEL"
6
7 # -------- are we building against an external portals? -------
8 # haha, I wonder how one is really supposed to do this
9 # automake seems to have a DEFS variable which looks good
10 AC_ARG_WITH(cray-portals, [  --with-cray-portals=[path] path to cray portals],
11         CRAY_PORTALS_INCLUDE="-I$with_cray_portals"
12         CC="$CC -DCRAY_PORTALS=1"
13         )
14 AC_SUBST(CRAY_PORTALS_INCLUDE)
15 AM_CONDITIONAL(CRAY_PORTALS, test ! "x$with_cray_portals" = x)
16
17 # -------- liblustre compilation --------------
18 AC_ARG_WITH(lib, [  --with-lib compile lustre library], host_cpu="lib")
19
20 # -------- set linuxdir ------------
21
22 AC_ARG_WITH(linux, [  --with-linux=[path] set path to Linux source (default=/usr/src/linux)],LINUX=$with_linux,LINUX=/usr/src/linux)
23 AC_SUBST(LINUX)
24 if test x$enable_inkernel = xyes ; then
25         echo ln -s `pwd` $LINUX/fs/lustre
26         rm $LINUX/fs/lustre
27         ln -s `pwd` $LINUX/fs/lustre
28 fi
29
30 #  --------------------
31 AC_MSG_CHECKING(if you are running user mode linux for $host_cpu ...)
32 if test $host_cpu = "lib" ; then 
33         host_cpu="lib"
34         AC_MSG_RESULT(no building Lustre library)
35 else
36   if test -e $LINUX/include/asm-um ; then
37     if test  X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
38         host_cpu="um";
39         AC_MSG_RESULT(yes)
40     else
41         AC_MSG_RESULT(no (asm doesn't point at asm-um))
42     fi
43
44   else 
45         AC_MSG_RESULT(no (asm-um missing))
46   fi
47 fi
48
49 # --------- Linux 25 ------------------
50
51 AC_MSG_CHECKING(if you are running linux 2.5)
52 if test -e $LINUX/include/linux/namei.h ; then
53         linux25="yes"
54         AC_MSG_RESULT(yes)
55 else
56         linux25="no"
57         AC_MSG_RESULT(no)
58 fi
59 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
60 echo "Makefiles for in linux 2.5 build: $LINUX25"
61
62 # -------  Makeflags ------------------
63
64 AC_MSG_CHECKING(setting make flags system architecture: )
65 case ${host_cpu} in
66         lib )
67         AC_MSG_RESULT($host_cpu)
68         KCFLAGS='-g -Wall '
69         KCPPFLAGS='-D__arch_lib__ '
70         libdir='${exec_prefix}/lib/lustre'
71         MOD_LINK=elf_i386
72 ;;
73         um )
74         AC_MSG_RESULT($host_cpu)
75         KCFLAGS='-g -Wall -pipe -Wno-trigraphs -Wstrict-prototypes -fno-strict-aliasing -fno-common '
76         case ${linux25} in
77                 yes )
78                 KCPPFLAGS='-D__KERNEL__ -U__i386__ -Ui386 -DUM_FASTCALL -D__arch_um__ -DSUBARCH="i386" -DNESTING=0 -D_LARGEFILE64_SOURCE  -Derrno=kernel_errno -DPATCHLEVEL=4 -DMODULE -I$(LINUX)/arch/um/include -I$(LINUX)/arch/um/kernel/tt/include -I$(LINUX)/arch/um/kernel/skas/include -O2 -nostdinc -iwithprefix include'
79         ;;
80                 * )
81                 KCPPFLAGS='-D__KERNEL__ -U__i386__ -Ui386 -DUM_FASTCALL -D__arch_um__ -DSUBARCH="i386" -DNESTING=0 -D_LARGEFILE64_SOURCE  -Derrno=kernel_errno -DPATCHLEVEL=4 -DMODULE -I$(LINUX)/arch/um/kernel/tt/include -I$(LINUX)/arch/um/include '
82         ;;
83         esac
84
85         MOD_LINK=elf_i386
86 ;;
87         i*86 )
88         AC_MSG_RESULT($host_cpu)
89         KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -pipe'
90         case ${linux25} in
91                 yes )
92                 KCPPFLAGS='-D__KERNEL__ -DMODULE -march=i686 -I$(LINUX)/include/asm-i386/mach-default -nostdinc -iwithprefix include '
93         ;;
94                 * )
95                 KCPPFLAGS='-D__KERNEL__ -DMODULE '
96         ;;
97         esac
98         MOD_LINK=elf_i386
99 ;;
100
101         alphaev6 )
102         AC_MSG_RESULT($host_cpu)
103         KCFLAGS='-g -O2  -Wall -Wstrict-prototypes -Wno-trigraphs -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mno-fp-regs -ffixed-8 -mcpu=ev5 -Wa,-mev6'
104         KCPPFLAGS='-D__KERNEL__ -DMODULE '
105         MOD_LINK=elf64alpha
106 ;;
107
108         alphaev67 )
109         AC_MSG_RESULT($host_cpu)
110         KCFLAGS='-g -O2  -Wall -Wstrict-prototypes -Wno-trigraphs -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mno-fp-regs -ffixed-8 -mcpu=ev5 -Wa,-mev6'
111         KCPPFLAGS='-D__KERNEL__ -DMODULE '
112         MOD_LINK=elf64alpha
113 ;;
114
115         alpha* )
116         AC_MSG_RESULT($host_cpu)
117         KCFLAGS='-g -O2  -Wall -Wstrict-prototypes -Wno-trigraphs -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mno-fp-regs -ffixed-8 -mcpu=ev5 -Wa,-mev5'
118         KCPPFLAGS='-D__KERNEL__ -DMODULE '
119         MOD_LINK=elf64alpha
120 ;;
121
122         ia64 )
123         AC_MSG_RESULT($host_cpu)
124         KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step'
125         KCPPFLAGS='-D__KERNEL__ -DMODULE'
126         MOD_LINK=elf64_ia64
127 ;;
128
129         x86_64 )
130         AC_MSG_RESULT($host_cpu)
131         KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fomit-frame-pointer -mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce -fno-asynchronous-unwind-tables'
132         KCPPFLAGS='-D__KERNEL__ -DMODULE'
133         MOD_LINK=elf_x86_64
134 ;;
135
136         sparc64 )
137         AC_MSG_RESULT($host_cpu)
138         KCFLAGS='-O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fomit-frame-pointer -fno-strict-aliasing -fno-common -Wno-unused -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare -Wa,--undeclared-regs'
139         KCPPFLAGS='-D__KERNEL__'
140         MOD_LINK=elf64_sparc
141
142 ;;
143
144         powerpc )
145         AC_MSG_RESULT($host_cpu)
146         KCFLAGS='-O2 -g -Wall -Wstrict-prototypes -Wno-trigraphs -fomit-frame-pointer -fno-strict-aliasing -fno-common -D__powerpc__ -fsigned-char -msoft-float -pipe -ffixed-r2 -Wno-uninitialized -mmultiple -mstring'
147         KCPPFLAGS='-D__KERNEL__ -DMODULE'
148         MOD_LINK=elf32ppclinux
149 ;;
150
151         *)
152         AC_ERROR("Unknown Linux Platform: $host_cpu")
153 ;;
154 esac
155
156 # ----------- make dep run? ------------------
157
158 if test $host_cpu != "lib" ; then 
159   AC_MSG_CHECKING(if make dep has been run in kernel source (host $host_cpu) )
160   if test -f $LINUX/include/linux/config.h ; then
161   AC_MSG_RESULT(yes)
162  else
163   AC_MSG_ERROR(** cannot find $LINUX/include/linux/config.h. Run make dep in $LINUX.)
164   fi
165 fi
166
167 # ------------ include paths ------------------
168
169 KINCFLAGS="$CRAY_PORTALS_INCLUDE $CRAY_PORTALS_COMMANDLINE \
170         -I\$(top_srcdir)/include \
171         -I\$(top_srcdir)/portals/include"
172 if test $host_cpu != "lib" ; then 
173     KINCFLAGS="$KINCFLAGS -I$LINUX/include -I$LINUX/include"
174 else
175     KINCFLAGS="$KINCFLAGS -I\$(top_srcdir)/utils -I\$(top_srcdir)/portals/unals"
176 fi
177 CPPFLAGS="$KINCFLAGS $ARCHCPPFLAGS"
178
179 if test $host_cpu != "lib" ; then 
180 # ------------ autoconf.h ------------------
181   AC_MSG_CHECKING(if autoconf.h is in kernel source)
182   if test -f $LINUX/include/linux/autoconf.h ; then
183       AC_MSG_RESULT(yes)
184   else
185       AC_MSG_ERROR(** cannot find $LINUX/include/linux/autoconf.h. Run make config in $LINUX.)
186   fi
187
188 # ------------ LINUXRELEASE and moduledir ------------------
189   AC_MSG_CHECKING(for Linux release)
190   
191   dnl We need to rid ourselves of the nasty [ ] quotes.
192   changequote(, )
193   dnl Get release from version.h
194   LINUXRELEASE="`sed -ne 's/.*UTS_RELEASE[ \"]*\([0-9.a-zA-Z_-]*\).*/\1/p' $LINUX/include/linux/version.h`"
195   changequote([, ])
196   
197   moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
198   AC_SUBST(moduledir)
199   
200   modulefsdir='$(moduledir)/fs/$(PACKAGE)'
201   AC_SUBST(modulefsdir)
202   
203   AC_MSG_RESULT($LINUXRELEASE)
204   AC_SUBST(LINUXRELEASE)
205
206 # ------------ RELEASE --------------------------------
207   AC_MSG_CHECKING(lustre release)
208   
209   dnl We need to rid ourselves of the nasty [ ] quotes.
210   changequote(, )
211   dnl Get release from version.h
212   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`"
213   changequote([, ])
214
215   AC_MSG_RESULT($RELEASE)
216   AC_SUBST(RELEASE)
217
218 # ---------- modversions? --------------------
219   AC_MSG_CHECKING(for MODVERSIONS)
220   if egrep -e 'MODVERSIONS.*1' $LINUX/include/linux/autoconf.h >/dev/null 2>&1;
221   then
222         if test $linux25 != "yes"; then
223                 MFLAGS="-DMODULE -DMODVERSIONS -include $LINUX/include/linux/modversions.h -DEXPORT_SYMTAB"
224                 AC_MSG_RESULT(yes)
225         fi
226   fi
227 fi
228
229 # ---------- Portals flags --------------------
230
231 #AC_PREFIX_DEFAULT([])
232 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
233 #  usrprefix=/usr
234 #else
235 #  usrprefix='${prefix}'
236 #fi
237 #AC_SUBST(usrprefix)
238
239 AC_MSG_CHECKING(if kernel has CPU affinity support)
240 SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
241 if test "$SET_CPUS_ALLOW" != 0 ; then
242   enable_affinity_temp="-DCPU_AFFINITY=1"
243   AC_MSG_RESULT(yes)
244 else
245   enable_affinity_temp=""
246   AC_MSG_RESULT(no)
247 fi
248
249 AC_MSG_CHECKING(if kernel has zero-copy TCP support)
250 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
251 if test "$ZCCD" != 0 ; then
252   enable_zerocopy_temp="-DSOCKNAL_ZC=1"
253   AC_MSG_RESULT(yes)
254 else
255   enable_zerocopy_temp=""
256   AC_MSG_RESULT(no)
257 fi
258
259 AC_ARG_ENABLE(zerocopy, [  --disable-zerocopy disable socknal zerocopy],enable_zerocopy="", enable_zerocopy=$enable_zerocopy_temp)
260
261 AC_ARG_ENABLE(affinity, [  --disable-affinity disable process/irq affinity],enable_affinity="", enable_affinity=$enable_affinity_temp)
262 #####################################
263
264 AC_MSG_CHECKING(if quadrics kernel headers are present)
265 if test -d $LINUX/drivers/net/qsnet ; then
266   AC_MSG_RESULT(yes)
267   QSWNAL="qswnal"
268   AC_MSG_CHECKING(for multirail EKC)
269   if test -f $LINUX/include/elan/epcomms.h; then
270         AC_MSG_RESULT(supported)
271         with_quadrics="-DMULTIRAIL_EKC=1"
272   else
273         AC_MSG_RESULT(not supported)
274         with_quadrics="-I$LINUX/drivers/net/qsnet/include"
275   fi
276   :
277 else
278   AC_MSG_RESULT(no)
279   QSWNAL=""
280   with_quadrics=""
281   :
282 fi
283 AC_SUBST(with_quadrics)
284 AC_SUBST(QSWNAL)
285
286 # R. Read 5/02
287 GMNAL=""
288 echo "checking with-gm=" ${with_gm}
289 if test "${with_gm+set}" = set; then
290   if test "${with_gm}" = yes; then
291     with_gm="-I/usr/local/gm/include"
292   else
293     with_gm="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
294   fi
295   GMNAL="gmnal"
296 else
297 # default case - no GM
298   with_gm=""
299 fi
300 AC_SUBST(with_gm)
301 AC_SUBST(GMNAL)
302
303
304 #fixme: where are the default IB includes?
305 default_ib_include_dir=/usr/local/ib/include
306 an_ib_include_file=vapi.h
307
308 AC_ARG_WITH(ib, [  --with-ib=[yes/no/path] Path to IB includes], with_ib=$withval, with_ib=$default_ib)
309 AC_MSG_CHECKING(if IB headers are present)
310 if test "$with_ib" = yes; then
311     with_ib=$default_ib_include_dir
312 fi
313 if test "$with_ib" != no -a -f ${with_ib}/${an_ib_include_file}; then
314     AC_MSG_RESULT(yes)
315     IBNAL="ibnal"
316     with_ib="-I${with_ib}"
317 else
318     AC_MSG_RESULT(no)
319     IBNAL=""
320     with_ib=""
321 fi
322 AC_SUBST(IBNAL)
323 AC_SUBST(with_ib)
324
325
326 def_scamac=/opt/scali/include
327 AC_ARG_WITH(scamac, [  --with-scamac=[yes/no/path] Path to ScaMAC includes (default=/opt/scali/include)], with_scamac=$withval, with_scamac=$def_scamac)
328 AC_MSG_CHECKING(if ScaMAC headers are present)
329 if test "$with_scamac" = yes; then
330   with_scamac=$def_scamac
331 fi
332 if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then
333   AC_MSG_RESULT(yes)
334   SCIMACNAL="scimacnal"
335   with_scamac="-I${with_scamac} -I${with_scamac}/icm"
336 else
337   AC_MSG_RESULT(no)
338   SCIMACNAL=""
339   with_scamac=""
340 fi
341
342 AC_SUBST(with_scamac)
343 AC_SUBST(SCIMACNAL)
344
345 CFLAGS="$KCFLAGS"
346 CPPFLAGS="$KINCFLAGS $KCPPFLAGS $MFLAGS $enable_zerocopy $enable_affinity $with_quadrics $with_gm $with_scamac $with_ib"
347 if test $host_cpu == "lib" ; then 
348 CPPFLAGS="$CPPFLAGS -fPIC -D_LARGEFILE64_SOURCE=1 -g"
349 fi
350
351 AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib)
352 AC_SUBST(MOD_LINK)
353 AC_SUBST(LINUX25)
354 AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib)
355
356 # ---------- Red Hat 2.4.18 has iobuf->dovary --------------
357 # But other kernels don't
358
359 AC_MSG_CHECKING([if struct kiobuf has a dovary field])
360 AC_TRY_COMPILE([#define __KERNEL__
361                 #include <linux/iobuf.h>],
362                [struct kiobuf iobuf;
363                 iobuf.dovary = 1;],
364                [AC_MSG_RESULT([yes])
365                 CPPFLAGS="$CPPFLAGS -DHAVE_KIOBUF_DOVARY"],
366                [AC_MSG_RESULT([no])])
367
368 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
369 # This needs to run after we've defined the KCPPFLAGS
370
371 AC_MSG_CHECKING(for kernel version)
372 AC_TRY_COMPILE([#define __KERNEL__
373              #include <linux/sched.h>],
374             [struct task_struct p;
375              p.sighand = NULL;],
376             [RH_2_4_20=1],
377             [RH_2_4_20=0])
378
379 if test $RH_2_4_20 = 1; then
380         AC_MSG_RESULT(redhat-2.4.20)
381         CPPFLAGS="$CPPFLAGS -DCONFIG_RH_2_4_20"
382 else
383         AC_MSG_RESULT($LINUXRELEASE)
384 fi 
385
386 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
387
388 AC_MSG_CHECKING(if kernel defines PDE)
389 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
390 if test "$HAVE_PDE" != 0 ; then
391   CPPFLAGS="$CPPFLAGS -DHAVE_PDE"
392   AC_MSG_RESULT(yes)
393 else
394   AC_MSG_RESULT(no)
395 fi
396
397 AC_MSG_CHECKING(if kernel passes struct file to direct_IO)
398 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
399 if test "$HAVE_DIO_FILE" != 0 ; then
400   CPPFLAGS="$CPPFLAGS -DHAVE_DIO_FILE"
401   AC_MSG_RESULT(yes)
402 else
403   AC_MSG_RESULT(no)
404 fi
405
406 # --- Check that ext3 and ext3 xattr are enabled in the kernel
407 if test "$host_cpu" != "lib" ; then 
408         AC_MSG_CHECKING([that ext3 is enabled in the kernel])
409         AC_TRY_COMPILE([
410 #define __KERNEL__
411 #include <linux/config.h>
412                 ],
413                 [
414 #ifdef CONFIG_EXT3_FS
415         return 0;
416 #else
417 #error CONFIG_EXT3_FS not #defined
418 #endif
419                 ],[AC_MSG_RESULT([yes])],
420                 [AC_MSG_RESULT([no])
421                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)])
422                 ])
423 # disable this check until our xattr patches define it!
424 #       AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel])
425 #       AC_TRY_COMPILE([
426 ##define __KERNEL__
427 ##include <linux/config.h>
428 #               ],
429 #               [
430 ##ifdef CONFIG_EXT3_FS_XATTR
431 #       return 0;
432 ##else
433 ##error CONFIG_EXT3_FS_XATTR not #defined
434 ##endif
435 #               ],[AC_MSG_RESULT([yes])],
436 #               [AC_MSG_RESULT([no])
437 #               AC_MSG_ERROR([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR)])
438 #               ])
439 fi
440