Whamcloud - gitweb
30960c273a2c912d94e0c9a1f919ee6c70597138
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
1 #
2 # LC_CONFIG_SRCDIR
3 #
4 # Wrapper for AC_CONFIG_SUBDIR
5 #
6 AC_DEFUN([LC_CONFIG_SRCDIR],
7 [AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
8 ])
9
10 #
11 # LC_PATH_DEFAULTS
12 #
13 # lustre specific paths
14 #
15 AC_DEFUN([LC_PATH_DEFAULTS],
16 [# ptlrpc kernel build requires this
17 LUSTRE="$PWD/lustre"
18 AC_SUBST(LUSTRE)
19
20 # mount.lustre
21 rootsbindir='/sbin'
22 AC_SUBST(rootsbindir)
23
24 demodir='$(docdir)/demo'
25 AC_SUBST(demodir)
26
27 pkgexampledir='${pkgdatadir}/examples'
28 AC_SUBST(pkgexampledir)
29
30 pymoddir='${pkglibdir}/python/Lustre'
31 AC_SUBST(pymoddir)
32 ])
33
34 #
35 # LC_TARGET_SUPPORTED
36 #
37 # is the target os supported?
38 #
39 AC_DEFUN([LC_TARGET_SUPPORTED],
40 [case $target_os in
41         linux*)
42 $1
43                 ;;
44         *)
45 $2
46                 ;;
47 esac
48 ])
49
50 #
51 # LC_CONFIG_EXT3
52 #
53 # that ext3 is enabled in the kernel
54 #
55 AC_DEFUN([LC_CONFIG_EXT3],
56 [LB_LINUX_CONFIG([EXT3_FS],[],[
57         LB_LINUX_CONFIG([EXT3_FS_MODULE],[],[$2])
58 ])
59 LB_LINUX_CONFIG([EXT3_FS_XATTR],[$1],[$3])
60 ])
61
62
63 #
64 # LC_FSHOOKS
65 #
66 # If we have (and can build) fshooks.h
67 #
68 AC_DEFUN([LC_FSHOOKS],
69 [AC_CHECK_FILE([$LINUX/include/linux/fshooks.h],[
70         AC_MSG_CHECKING([if fshooks.h can be compiled])
71         LB_LINUX_TRY_COMPILE([
72                 #include <linux/fshooks.h>
73         ],[],[
74                 AC_MSG_RESULT([yes])
75         ],[
76                 AC_MSG_RESULT([no])
77                 AC_MSG_WARN([You might have better luck with gcc 3.3.x.])
78                 AC_MSG_WARN([You can set CC=gcc33 before running configure.])
79                 AC_MSG_ERROR([Your compiler cannot build fshooks.h.])
80         ])
81 $1
82 ],[
83 LB_LINUX_TRY_COMPILE([
84         #include <linux/version.h>
85 ],[
86         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10))
87         #error "linux version < 2.6.10, only support 2.6.7"
88         #endif
89 ],[
90 $2
91 ],[
92 $3 
93 ])
94 ])
95 ])
96
97 #
98 # LC_STRUCT_KIOBUF
99 #
100 # rh 2.4.18 has iobuf->dovary, but other kernels do not
101 #
102 AC_DEFUN([LC_STRUCT_KIOBUF],
103 [AC_MSG_CHECKING([if struct kiobuf has a dovary field])
104 LB_LINUX_TRY_COMPILE([
105         #include <linux/iobuf.h>
106 ],[
107         struct kiobuf iobuf;
108         iobuf.dovary = 1;
109 ],[
110         AC_MSG_RESULT([yes])
111         AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
112 ],[
113         AC_MSG_RESULT([no])
114 ])
115 ])
116
117 #
118 # LC_FUNC_COND_RESCHED
119 #
120 # cond_resched() was introduced in 2.4.20
121 #
122 AC_DEFUN([LC_FUNC_COND_RESCHED],
123 [AC_MSG_CHECKING([if kernel offers cond_resched])
124 LB_LINUX_TRY_COMPILE([
125         #include <linux/sched.h>
126 ],[
127         cond_resched();
128 ],[
129         AC_MSG_RESULT([yes])
130         AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
131 ],[
132         AC_MSG_RESULT([no])
133 ])
134 ])
135
136 #
137 # LC_FUNC_ZAP_PAGE_RANGE
138 #
139 # if zap_page_range() takes a vma arg
140 #
141 AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE],
142 [AC_MSG_CHECKING([if zap_pag_range with vma parameter])
143 ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
144 if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
145         AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
146         AC_MSG_RESULT([yes])
147 else
148         AC_MSG_RESULT([no])
149 fi
150 ])
151
152 #
153 # LC_FUNC_PDE
154 #
155 # if proc_fs.h defines PDE()
156 #
157 AC_DEFUN([LC_FUNC_PDE],
158 [AC_MSG_CHECKING([if kernel defines PDE])
159 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
160 if test "$HAVE_PDE" != 0 ; then
161         AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
162         AC_MSG_RESULT([yes])
163 else
164         AC_MSG_RESULT([no])
165 fi
166 ])
167
168 #
169 # LC_FUNC_DIRECT_IO
170 #
171 # if direct_IO takes a struct file argument
172 #
173 AC_DEFUN([LC_FUNC_DIRECT_IO],
174 [AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
175 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
176 if test "$HAVE_DIO_FILE" != 0 ; then
177         AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
178         AC_MSG_RESULT(yes)
179 else
180         AC_MSG_RESULT(no)
181 fi
182 ])
183
184 #
185 # LC_HEADER_MM_INLINE
186 #
187 # RHEL kernels define page_count in mm_inline.h
188 #
189 AC_DEFUN([LC_HEADER_MM_INLINE],
190 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
191 LB_LINUX_TRY_COMPILE([
192         #include <linux/mm_inline.h>
193 ],[
194         #ifndef page_count
195         #error mm_inline.h does not define page_count
196         #endif
197 ],[
198         AC_MSG_RESULT([yes])
199         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
200 ],[
201         AC_MSG_RESULT([no])
202 ])
203 ])
204
205 #
206 # LC_STRUCT_INODE
207 #
208 # if inode->i_alloc_sem exists
209 #
210 AC_DEFUN([LC_STRUCT_INODE],
211 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
212 LB_LINUX_TRY_COMPILE([
213         #include <linux/fs.h>
214         #include <linux/version.h>
215 ],[
216         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
217         #error "down_read_trylock broken before 2.4.24"
218         #endif
219         struct inode i;
220         return (char *)&i.i_alloc_sem - (char *)&i;
221 ],[
222         AC_MSG_RESULT([yes])
223         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
224 ],[
225         AC_MSG_RESULT([no])
226 ])
227 ])
228
229
230 #
231 # LC_FUNC_DEV_SET_RDONLY
232 #
233 # check for the old-style dev_set_rdonly which took an extra "devno" param
234 # and can only set a single device to discard writes at one time
235 #
236 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
237 [AC_MSG_CHECKING([if kernel has old single-device dev_set_rdonly])
238 HAVE_OLD_DSR="`grep -c -s 'dev_set_rdonly.*no_write' $LINUX/drivers/block/ll_rw_blk.c`"
239 if test x$HAVE_OLD_DSR != "x1" ; then
240         HAVE_OLD_DSR="`grep -c -s 'dev_set_rdonly.*no_write' $LINUX/drivers/block/blkpg.c`"
241 fi
242 if test x$HAVE_OLD_DSR = "x1" ; then
243         AC_DEFINE(HAVE_OLD_DEV_SET_RDONLY, 1,
244                 [kernel has old single-device dev_set_rdonly])
245         AC_MSG_RESULT(yes)
246 else
247         AC_MSG_RESULT(no)
248 fi
249 ])
250
251
252 #
253 # LC_CONFIG_BACKINGFS
254 #
255 # whether to use extN or ldiskfs instead of ext3
256 #
257 AC_DEFUN([LC_CONFIG_BACKINGFS],
258 [
259 BACKINGFS='ext3'
260
261 # LLNL patches their ext3 and calls it extN
262 AC_MSG_CHECKING([whether to use extN])
263 AC_ARG_ENABLE([extN],
264         AC_HELP_STRING([--enable-extN],
265                         [use extN instead of ext3 for lustre backend]),
266         [BACKINGFS='extN'],[enable_extN='no'])
267 AC_MSG_RESULT([$enable_extN])
268
269 # SuSE gets ldiskfs
270 AC_MSG_CHECKING([whether to enable ldiskfs])
271 AC_ARG_ENABLE([ldiskfs],
272         AC_HELP_STRING([--enable-ldiskfs],
273                         [use ldiskfs for the Lustre backing FS]),
274         [],[enable_ldiskfs="$linux25"])
275 AC_MSG_RESULT([$enable_ldiskfs])
276
277 if test x$enable_ldiskfs = xyes ; then
278         BACKINGFS="ldiskfs"
279
280         AC_PATH_PROG(PATCH, patch, [no])
281         AC_PATH_PROG(QUILT, quilt, [no])
282
283         if test x$enable_ldiskfs$PATCH$QUILT = xyesnono ; then
284                 AC_MSG_ERROR([Quilt or patch are needed to build the ldiskfs module (for Linux 2.6)])
285         fi
286
287         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
288         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
289         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls])
290         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security])
291 fi
292
293 AC_MSG_CHECKING([which backing filesystem to use])
294 AC_MSG_RESULT([$BACKINGFS])
295 AC_SUBST(BACKINGFS)
296
297 case $BACKINGFS in
298         ext3)
299                 # --- Check that ext3 and ext3 xattr are enabled in the kernel
300                 LC_CONFIG_EXT3([],[
301                         AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel])
302                 ],[
303                         AC_MSG_ERROR([Lustre requires that extended attributes for ext3 are enabled in the kernel])
304                 ])
305                 ;;
306         ldiskfs)
307                 LC_FSHOOKS([
308                         LDISKFS_SERIES="2.6-suse.series"
309                 ],[
310                         LDISKFS_SERIES="2.6-fc3.series"
311                 ],[
312                         LDISKFS_SERIES="2.6-vanilla.series"             
313                 ]
314                 )
315                 AC_SUBST(LDISKFS_SERIES)
316                 ;;
317 esac # $BACKINGFS
318 ])
319
320 #
321 # LC_CONFIG_PINGER
322 #
323 # the pinger is temporary, until we have the recovery node in place
324 #
325 AC_DEFUN([LC_CONFIG_PINGER],
326 [AC_MSG_CHECKING([whether to enable pinger support])
327 AC_ARG_ENABLE([pinger],
328         AC_HELP_STRING([--disable-pinger],
329                         [disable recovery pinger support]),
330         [],[enable_pinger='yes'])
331 AC_MSG_RESULT([$enable_pinger])
332 if test x$enable_pinger != xno ; then
333   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
334 fi
335 ])
336
337 #
338 # LC_CONFIG_OBD_BUFFER_SIZE
339 #
340 # the maximum buffer size of lctl ioctls
341 #
342 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
343 [AC_MSG_CHECKING([maximum OBD ioctl size])
344 AC_ARG_WITH([obd-buffer-size],
345         AC_HELP_STRING([--with-obd-buffer-size=[size]],
346                         [set lctl ioctl maximum bytes (default=8192)]),
347         [
348                 OBD_BUFFER_SIZE=$with_obd_buffer_size
349         ],[
350                 OBD_BUFFER_SIZE=8192
351         ])
352 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
353 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
354 ])
355
356 #
357 # LC_CONFIG_GSS
358 #
359 # whether build-in gss/krb5 capability
360 #
361 AC_DEFUN([LC_CONFIG_GSS],
362 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
363 AC_ARG_ENABLE([gss],
364         AC_HELP_STRING([--enable-gss],
365                         [enable gss/krb5 support]),
366         [],[enable_gss='yes'])
367 AC_MSG_RESULT([$enable_gss])
368 if test x$enable_gss != xno ; then
369   AC_DEFINE(ENABLE_GSS, 1, Support GSS/krb5)
370 fi
371 ])
372
373 #
374 # LC_CONFIG_SNAPFS
375 #
376 # Whether snapfs is desired
377 #
378 AC_DEFUN([LC_CONFIG_SNAPFS],
379 [# snap compilation
380 AC_MSG_CHECKING([whether to enable snapfs support])
381 AC_ARG_ENABLE([snapfs],
382         AC_HELP_STRING([--enable-snapfs],
383                         [build snapfs]),
384         [],[enable_snapfs='no'])
385 AC_MSG_RESULT([$enable_snapfs])
386 ])
387
388 #
389 # LC_CONFIG_SMFS
390 #
391 # whether smfs is desired
392 #
393 AC_DEFUN([LC_CONFIG_SMFS],
394 [AC_MSG_CHECKING([whether to enable smfs support])
395 AC_ARG_ENABLE([smfs],
396         AC_HELP_STRING([--enable-smfs],
397                         [build smfs]),
398         [],[enable_smfs='no'])
399 AC_MSG_RESULT([$enable_smfs])
400 ])
401
402 #
403 # LC_PROG_LINUX
404 #
405 # Lustre linux kernel checks
406 #
407 AC_DEFUN([LC_PROG_LINUX],
408 [if test x$enable_server = xyes ; then
409         LC_CONFIG_BACKINGFS
410 fi
411 LC_CONFIG_PINGER
412 LC_CONFIG_GSS
413 LC_CONFIG_SNAPFS
414 LC_CONFIG_SMFS
415
416 LC_STRUCT_KIOBUF
417 LC_FUNC_COND_RESCHED
418 LC_FUNC_ZAP_PAGE_RANGE
419 LC_FUNC_PDE
420 LC_FUNC_DIRECT_IO
421 LC_HEADER_MM_INLINE
422 LC_STRUCT_INODE
423 LC_FUNC_DEV_SET_RDONLY
424 ])
425
426 #
427 # LC_CONFIG_CLIENT_SERVER
428 #
429 # Build client/server sides of Lustre
430 #
431 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
432 [AC_MSG_CHECKING([whether to build Lustre server support])
433 AC_ARG_ENABLE([server],
434         AC_HELP_STRING([--disable-server],
435                         [disable Lustre server support]),
436         [],[enable_server='yes'])
437 AC_MSG_RESULT([$enable_server])
438
439 AC_MSG_CHECKING([whether to build Lustre client support])
440 AC_ARG_ENABLE([client],
441         AC_HELP_STRING([--disable-client],
442                         [disable Lustre client support]),
443         [],[enable_client='yes'])
444 AC_MSG_RESULT([$enable_client])])
445
446 #
447 # LC_CONFIG_LIBLUSTRE
448 #
449 # whether to build liblustre
450 #
451 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
452 [AC_MSG_CHECKING([whether to build Lustre library])
453 AC_ARG_ENABLE([liblustre],
454         AC_HELP_STRING([--disable-liblustre],
455                         [disable building of Lustre library]),
456         [],[enable_liblustre=$with_sysio])
457 AC_MSG_RESULT([$enable_liblustre])
458 # only build sysio if liblustre is built
459 with_sysio="$enable_liblustre"
460
461 AC_MSG_CHECKING([whether to build mpitests])
462 AC_ARG_ENABLE([mpitests],
463         AC_HELP_STRING([--enable-mpitests],
464                         [build liblustre mpi tests]),
465         [],[enable_mpitests=no])
466 AC_MSG_RESULT([$enable_mpitests])
467 ])
468
469 #
470 # LC_CONFIGURE
471 #
472 # other configure checks
473 #
474 AC_DEFUN([LC_CONFIGURE],
475 [LC_CONFIG_OBD_BUFFER_SIZE
476
477 # include/liblustre.h
478 AC_CHECK_HEADERS([asm/page.h sys/user.h stdint.h])
479
480 # liblustre/llite_lib.h
481 AC_CHECK_HEADERS([xtio.h file.h])
482
483 # liblustre/dir.c
484 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
485
486 # liblustre/lutil.c
487 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
488 AC_CHECK_FUNCS([inet_ntoa])
489 ])
490
491 #
492 # LC_CONDITIONALS
493 #
494 # AM_CONDITIONALS for lustre
495 #
496 AC_DEFUN([LC_CONDITIONALS],
497 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
498 AM_CONDITIONAL(EXTN, test x$enable_extN = xyes)
499 AM_CONDITIONAL(LDISKFS, test x$enable_ldiskfs = xyes)
500 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
501 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
502 AM_CONDITIONAL(SNAPFS, test x$enable_snapfs = xyes)
503 AM_CONDITIONAL(SMFS, test x$enable_smfs = xyes)
504 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
505 AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
506 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
507 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
508 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
509 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
510 ])
511
512 #
513 # LC_CONFIG_FILES
514 #
515 # files that should be generated with AC_OUTPUT
516 #
517 AC_DEFUN([LC_CONFIG_FILES],
518 [AC_CONFIG_FILES([
519 lustre/Makefile
520 lustre/autoMakefile
521 lustre/autoconf/Makefile
522 lustre/cmobd/Makefile
523 lustre/cmobd/autoMakefile
524 lustre/cobd/Makefile
525 lustre/cobd/autoMakefile
526 lustre/conf/Makefile
527 lustre/doc/Makefile
528 lustre/include/Makefile
529 lustre/include/linux/Makefile
530 lustre/include/lustre/Makefile
531 lustre/ldiskfs/Makefile
532 lustre/ldiskfs/autoMakefile
533 lustre/ldlm/Makefile
534 lustre/liblustre/Makefile
535 lustre/llite/Makefile
536 lustre/llite/autoMakefile
537 lustre/lmv/Makefile
538 lustre/lmv/autoMakefile
539 lustre/lov/Makefile
540 lustre/lov/autoMakefile
541 lustre/lvfs/Makefile
542 lustre/lvfs/autoMakefile
543 lustre/mdc/Makefile
544 lustre/mdc/autoMakefile
545 lustre/mds/Makefile
546 lustre/mds/autoMakefile
547 lustre/obdclass/Makefile
548 lustre/obdclass/autoMakefile
549 lustre/obdecho/Makefile
550 lustre/obdecho/autoMakefile
551 lustre/obdfilter/Makefile
552 lustre/obdfilter/autoMakefile
553 lustre/osc/Makefile
554 lustre/osc/autoMakefile
555 lustre/ost/Makefile
556 lustre/ost/autoMakefile
557 lustre/ptlbd/Makefile
558 lustre/ptlbd/autoMakefile
559 lustre/ptlrpc/Makefile
560 lustre/ptlrpc/autoMakefile
561 lustre/scripts/Makefile
562 lustre/scripts/version_tag.pl
563 lustre/sec/Makefile
564 lustre/sec/autoMakefile
565 lustre/sec/gss/Makefile
566 lustre/sec/gss/autoMakefile
567 lustre/smfs/Makefile
568 lustre/smfs/autoMakefile
569 lustre/snapfs/Makefile
570 lustre/snapfs/autoMakefile
571 lustre/snapfs/utils/Makefile
572 lustre/tests/Makefile
573 lustre/utils/Lustre/Makefile
574 lustre/utils/Makefile
575 ])
576 ])