Whamcloud - gitweb
e955c3388f3c1f9f90e5e45a53d2bc17720c1266
[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 # -------- liblustre compilation --------------
8 AC_ARG_WITH(lib, [  --with-lib compile lustre library], host_cpu="lib")
9
10 # -------- set linuxdir ------------
11
12 AC_ARG_WITH(linux, [  --with-linux=[path] set path to Linux source (default=/usr/src/linux)],LINUX=$with_linux,LINUX=/usr/src/linux)
13 AC_SUBST(LINUX)
14 if test x$enable_inkernel = xyes ; then
15         echo ln -s `pwd` $LINUX/fs/lustre
16         rm $LINUX/fs/lustre
17         ln -s `pwd` $LINUX/fs/lustre
18 fi
19
20 #  --------------------
21 AC_MSG_CHECKING(if you are running user mode linux for $host_cpu ...)
22 if test $host_cpu = "lib" ; then 
23         host_cpu="lib"
24         AC_MSG_RESULT(no building Lustre library)
25 else
26   if test -e $LINUX/include/asm-um ; then
27     if test  X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
28         host_cpu="um";
29         AC_MSG_RESULT(yes)
30     else
31         AC_MSG_RESULT(no (asm doesn't point at asm-um))
32     fi
33
34   else 
35         AC_MSG_RESULT(no (asm-um missing))
36   fi
37 fi
38
39 # --------- Linux 25 ------------------
40
41 AC_MSG_CHECKING(if you are running linux 2.5)
42 if test -e $LINUX/include/linux/namei.h ; then
43         linux25="yes"
44         AC_MSG_RESULT(yes)
45 else
46         linux25="no"
47         AC_MSG_RESULT(no)
48 fi
49 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
50 echo "Makefiles for in linux 2.5 build: $LINUX25"
51
52 # -------  Makeflags ------------------
53
54 AC_MSG_CHECKING(setting make flags system architecture: )
55 case ${host_cpu} in
56         lib )
57         AC_MSG_RESULT($host_cpu)
58         KCFLAGS='-g -Wall '
59         KCPPFLAGS='-D__arch_lib__ '
60         libdir='${exec_prefix}/lib/lustre'
61         MOD_LINK=elf_i386
62 ;;
63         um )
64         AC_MSG_RESULT($host_cpu)
65         KCFLAGS='-g -Wall -pipe -Wno-trigraphs -Wstrict-prototypes -fno-strict-aliasing -fno-common '
66         case ${linux25} in
67                 yes )
68                 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 -DKBUILD_BASENAME=$(MODULE) -DKBUILD_MODNAME=$(MODULE) '
69         ;;
70                 * )
71                 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 '
72         ;;
73         esac
74
75         MOD_LINK=elf_i386
76 ;;
77         i*86 )
78         AC_MSG_RESULT($host_cpu)
79         KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -pipe'
80         case ${linux25} in
81                 yes )
82                 KCPPFLAGS='-D__KERNEL__ -DMODULE -march=i686 -I$(LINUX)/include/asm-i386/mach-default -nostdinc -iwithprefix include '
83         ;;
84                 * )
85                 KCPPFLAGS='-D__KERNEL__ -DMODULE '
86         ;;
87         esac
88         MOD_LINK=elf_i386
89 ;;
90
91         alphaev6 )
92         AC_MSG_RESULT($host_cpu)
93         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'
94         KCPPFLAGS='-D__KERNEL__ -DMODULE '
95         MOD_LINK=elf64alpha
96 ;;
97
98         alphaev67 )
99         AC_MSG_RESULT($host_cpu)
100         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'
101         KCPPFLAGS='-D__KERNEL__ -DMODULE '
102         MOD_LINK=elf64alpha
103 ;;
104
105         alpha* )
106         AC_MSG_RESULT($host_cpu)
107         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'
108         KCPPFLAGS='-D__KERNEL__ -DMODULE '
109         MOD_LINK=elf64alpha
110 ;;
111
112         ia64 )
113         AC_MSG_RESULT($host_cpu)
114         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'
115         KCPPFLAGS='-D__KERNEL__ -DMODULE'
116         MOD_LINK=elf64_ia64
117 ;;
118
119         x86_64 )
120         AC_MSG_RESULT($host_cpu)
121         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'
122         KCPPFLAGS='-D__KERNEL__ -DMODULE'
123         MOD_LINK=elf_x86_64
124 ;;
125
126         sparc64 )
127         AC_MSG_RESULT($host_cpu)
128         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'
129         KCPPFLAGS='-D__KERNEL__'
130         MOD_LINK=elf64_sparc
131
132 ;;
133
134         powerpc )
135         AC_MSG_RESULT($host_cpu)
136         KCFLAGS='-O2 -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'
137         KCPPFLAGS='-D__KERNEL__'
138         MOD_LINK=elf32ppclinux
139 ;;
140
141         *)
142         AC_ERROR("Unknown Linux Platform: $host_cpu")
143 ;;
144 esac
145
146 # ----------- make dep run? ------------------
147
148 if test $host_cpu != "lib" ; then 
149   AC_MSG_CHECKING(if make dep has been run in kernel source (host $host_cpu) )
150   if test -f $LINUX/include/linux/config.h ; then
151   AC_MSG_RESULT(yes)
152  else
153   AC_MSG_ERROR(** cannot find $LINUX/include/linux/config.h. Run make dep in $LINUX.)
154   fi
155 fi
156
157 # ------------ include paths ------------------
158
159 if test $host_cpu != "lib" ; then 
160     KINCFLAGS="-I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include -I$LINUX/include"
161 else
162     KINCFLAGS='-I$(top_srcdir)/include -I$(top_srcdir)/portals/include'
163 fi
164 CPPFLAGS="$KINCFLAGS $ARCHCPPFLAGS"
165
166 if test $host_cpu != "lib" ; then 
167 # ------------ autoconf.h ------------------
168   AC_MSG_CHECKING(if autoconf.h is in kernel source)
169   if test -f $LINUX/include/linux/autoconf.h ; then
170       AC_MSG_RESULT(yes)
171   else
172       AC_MSG_ERROR(** cannot find $LINUX/include/linux/autoconf.h. Run make config in $LINUX.)
173   fi
174
175 # ------------ LINUXRELEASE and moduledir ------------------
176   AC_MSG_CHECKING(for Linux release)
177   
178   dnl We need to rid ourselves of the nasty [ ] quotes.
179   changequote(, )
180   dnl Get release from version.h
181   LINUXRELEASE="`sed -ne 's/.*UTS_RELEASE[ \"]*\([0-9.a-zA-Z_-]*\).*/\1/p' $LINUX/include/linux/version.h`"
182   changequote([, ])
183   
184   moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
185   AC_SUBST(moduledir)
186   
187   modulefsdir='$(moduledir)/fs/$(PACKAGE)'
188   AC_SUBST(modulefsdir)
189   
190   AC_MSG_RESULT($LINUXRELEASE)
191   AC_SUBST(LINUXRELEASE)
192
193 # ------------ RELEASE --------------------------------
194   AC_MSG_CHECKING(lustre release)
195   
196   dnl We need to rid ourselves of the nasty [ ] quotes.
197   changequote(, )
198   dnl Get release from version.h
199   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`"
200   changequote([, ])
201
202   AC_MSG_RESULT($RELEASE)
203   AC_SUBST(RELEASE)
204
205 # ---------- modversions? --------------------
206   AC_MSG_CHECKING(for MODVERSIONS)
207   if egrep -e 'MODVERSIONS.*1' $LINUX/include/linux/autoconf.h >/dev/null 2>&1;
208   then
209         MFLAGS="-DMODULE -DMODVERSIONS -include $LINUX/include/linux/modversions.h -DEXPORT_SYMTAB"
210         AC_MSG_RESULT(yes)
211   else
212         MFLAGS=
213         AC_MSG_RESULT(no)
214   fi
215 fi
216
217 # ---------- Portals flags --------------------
218
219 #AC_PREFIX_DEFAULT([])
220 #if test "x$prefix" = xNONE || test "x$prefix" = x; then
221 #  usrprefix=/usr
222 #else
223 #  usrprefix='${prefix}'
224 #fi
225 #AC_SUBST(usrprefix)
226
227 AC_MSG_CHECKING(if kernel has CPU affinity support)
228 SET_CPUS_ALLOW="`grep -c set_cpus_allowed $LINUX/kernel/softirq.c`"
229 if test "$SET_CPUS_ALLOW" != 0 ; then
230   enable_affinity_temp="-DCPU_AFFINITY=1"
231   AC_MSG_RESULT(yes)
232 else
233   enable_affinity_temp=""
234   AC_MSG_RESULT(no)
235 fi
236
237 AC_MSG_CHECKING(if kernel has zero-copy TCP support)
238 ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
239 if test "$ZCCD" != 0 ; then
240   enable_zerocopy_temp="-DSOCKNAL_ZC=1"
241   AC_MSG_RESULT(yes)
242 else
243   enable_zerocopy_temp=""
244   AC_MSG_RESULT(no)
245 fi
246
247 AC_ARG_ENABLE(zerocopy, [  --disable-zerocopy disable socknal zerocopy],enable_zerocopy="", enable_zerocopy=$enable_zerocopy_temp)
248
249 AC_ARG_ENABLE(affinity, [  --disable-affinity disable process/irq affinity],enable_affinity="", enable_affinity=$enable_affinity_temp)
250 #####################################
251
252 AC_MSG_CHECKING(if quadrics kernel headers are present)
253 if test -d $LINUX/drivers/net/qsnet ; then
254   AC_MSG_RESULT(yes)
255   QSWNAL="qswnal"
256   AC_MSG_CHECKING(for multirail EKC)
257   if test -f $LINUX/include/elan/epcomms.h; then
258         AC_MSG_RESULT(supported)
259         with_quadrics="-DMULTIRAIL_EKC=1"
260   else
261         AC_MSG_RESULT(not supported)
262         with_quadrics="-I$LINUX/drivers/net/qsnet/include"
263   fi
264   :
265 else
266   AC_MSG_RESULT(no)
267   QSWNAL=""
268   with_quadrics=""
269   :
270 fi
271 AC_SUBST(with_quadrics)
272 AC_SUBST(QSWNAL)
273
274 # R. Read 5/02
275 GMNAL=""
276 echo "checking with-gm=" ${with_gm}
277 if test "${with_gm+set}" = set; then
278   if test "${with_gm}" = yes; then
279     with_gm="-I/usr/local/gm/include"
280   else
281     with_gm="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm"
282   fi
283   GMNAL="gmnal"
284 else
285 # default case - no GM
286   with_gm=""
287 fi
288 AC_SUBST(with_gm)
289 AC_SUBST(GMNAL)
290
291
292 #fixme: where are the default IB includes?
293 default_ib_include_dir=/usr/local/ib/include
294 an_ib_include_file=vapi.h
295
296 AC_ARG_WITH(ib, [ --with-ib=[yes/no/path] Path to IB includes], with_ib=$withval, with_ib=$default_ib)
297 AC_MSG_CHECKING(if IB headers are present)
298 if test "$with_ib" = yes; then
299     with_ib=$default_ib_include_dir
300 fi
301 if test "$with_ib" != no -a -f ${with_ib}/${an_ib_include_file}; then
302     AC_MSG_RESULT(yes)
303     IBNAL="ibnal"
304     with_ib="-I${with_ib}"
305 else
306     AC_MSG_RESULT(no)
307     IBNAL=""
308     with_ib=""
309 fi
310 AC_SUBST(IBNAL)
311 AC_SUBST(with_ib)
312
313
314 def_scamac=/opt/scali/include
315 AC_ARG_WITH(scamac, [  --with-scamac=[yes/no/path] Path to ScaMAC includes (default=/opt/scali/include)], with_scamac=$withval, with_scamac=$def_scamac)
316 AC_MSG_CHECKING(if ScaMAC headers are present)
317 if test "$with_scamac" = yes; then
318   with_scamac=$def_scamac
319 fi
320 if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then
321   AC_MSG_RESULT(yes)
322   SCIMACNAL="scimacnal"
323   with_scamac="-I${with_scamac} -I${with_scamac}/icm"
324 else
325   AC_MSG_RESULT(no)
326   SCIMACNAL=""
327   with_scamac=""
328 fi
329
330 AC_SUBST(with_scamac)
331 AC_SUBST(SCIMACNAL)
332
333 CFLAGS="$KCFLAGS"
334 CPPFLAGS="$KINCFLAGS $KCPPFLAGS $MFLAGS $enable_zerocopy $enable_affinity $with_quadrics $with_gm $with_scamac $with_ib"
335
336 AC_SUBST(MOD_LINK)
337 AC_SUBST(LINUX25)
338 AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib)
339
340 # ---------- Red Hat 2.4.20 backports some 2.5 bits --------
341 # This needs to run after we've defined the KCPPFLAGS
342
343 AC_MSG_CHECKING(for kernel version)
344 AC_TRY_COMPILE([#define __KERNEL__
345              #include <linux/sched.h>],
346             [struct task_struct p;
347              p.sighand = NULL;],
348             [RH_2_4_20=1],
349             [RH_2_4_20=0])
350
351 if test $RH_2_4_20 = 1; then
352         AC_MSG_RESULT(redhat-2.4.20)
353         CPPFLAGS="$CPPFLAGS -DCONFIG_RH_2_4_20"
354 else
355         AC_MSG_RESULT($LINUXRELEASE)
356 fi 
357
358 # ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
359
360 AC_MSG_CHECKING(if kernel defines PDE)
361 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
362 if test "$HAVE_PDE" != 0 ; then
363   CPPFLAGS="$CPPFLAGS -DHAVE_PDE"
364   AC_MSG_RESULT(yes)
365 else
366   AC_MSG_RESULT(no)
367 fi
368
369 AC_MSG_CHECKING(if kernel passes struct file to direct_IO)
370 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
371 if test "$HAVE_DIO_FILE" != 0 ; then
372   CPPFLAGS="$CPPFLAGS -DHAVE_DIO_FILE"
373   AC_MSG_RESULT(yes)
374 else
375   AC_MSG_RESULT(no)
376 fi