Whamcloud - gitweb
c70afbf97658e7c3dd52838e94d5fbf42be189a4
[fs/lustre-release.git] / build / autoconf / lustre-build.m4
1 #
2 # LB_CHECK_VERSION
3 #
4 # Verify that LUSTRE_VERSION was defined properly
5 #
6 AC_DEFUN([LB_CHECK_VERSION],
7 [if test "LUSTRE_VERSION" = "LUSTRE""_VERSION" ; then
8         AC_MSG_ERROR([This script was not built with a version number.])
9 fi
10 ])
11
12 #
13 # LB_CANONICAL_SYSTEM
14 #
15 # fixup $target_os for use in other places
16 #
17 AC_DEFUN([LB_CANONICAL_SYSTEM],
18 [case $target_os in
19         linux*)
20                 lb_target_os="linux"
21                 ;;
22         darwin*)
23                 lb_target_os="darwin"
24                 ;;
25         solaris*)
26                 lb_target_os="SunOS"
27                 ;;esac
28 AC_SUBST(lb_target_os)
29 ])
30
31 #
32 # LB_CHECK_FILE
33 #
34 # Check for file existance even when cross compiling
35 #
36 AC_DEFUN([LB_CHECK_FILE],
37 [AS_VAR_PUSHDEF([lb_File], [lb_cv_file_$1])dnl
38 AC_CACHE_CHECK([for $1], lb_File,
39 [if test -r "$1"; then
40   AS_VAR_SET(lb_File, yes)
41 else
42   AS_VAR_SET(lb_File, no)
43 fi])
44 AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
45 AS_VAR_POPDEF([lb_File])dnl
46 ])# LB_CHECK_FILE
47
48
49 #
50 # LB_ARG_LIBS_INCLUDES
51 #
52 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
53 # a single magical macro
54 #
55 AC_DEFUN([LB_ARG_LIBS_INCLUDES],
56 [lb_pathvar="m4_bpatsubst([$2], -, _)"
57 AC_MSG_CHECKING([for $1])
58 AC_ARG_WITH([$2],
59         AC_HELP_STRING([--with-$2=path],
60                 [path to $1]),
61         [],[withval=$4])
62
63 if test x$withval = xyes ; then
64         eval "$lb_pathvar='$3'"
65 else
66         eval "$lb_pathvar='$withval'"
67 fi
68 AC_MSG_RESULT([${!lb_pathvar:-no}])
69
70 if test x${!lb_pathvar} != x -a x${!lb_pathvar} != xno ; then
71         AC_MSG_CHECKING([for $1 includes])
72         AC_ARG_WITH([$2-includes],
73                 AC_HELP_STRING([--with-$2-includes=path],
74                         [path to $1 includes]),
75                 [],[withval='yes'])
76
77         lb_includevar="${lb_pathvar}_includes"
78         if test x$withval = xyes ; then
79                 eval "${lb_includevar}='${!lb_pathvar}/include'"
80         else
81                 eval "${lb_includevar}='$withval'"
82         fi
83         AC_MSG_RESULT([${!lb_includevar}])
84
85         AC_MSG_CHECKING([for $1 libs])
86         AC_ARG_WITH([$2-libs],
87                 AC_HELP_STRING([--with-$2-libs=path],
88                         [path to $1 libs]),
89                 [],[withval='yes'])
90
91         lb_libvar="${lb_pathvar}_libs"
92         if test x$withval = xyes ; then
93                 eval "${lb_libvar}='${!lb_pathvar}/lib'"
94         else
95                 eval "${lb_libvar}='$withval'"
96         fi
97         AC_MSG_RESULT([${!lb_libvar}])
98 fi
99 ])
100 ])
101
102 #
103 # LB_PATH_LIBSYSIO
104 #
105 # Handle internal/external libsysio
106 #
107 AC_DEFUN([LB_PATH_LIBSYSIO],
108 [AC_ARG_WITH([sysio],
109         AC_HELP_STRING([--with-sysio=path],
110                         [set path to libsysio source (default is included libsysio)]),
111         [],[
112                 case $lb_target_os in
113                         linux)
114                                 with_sysio='yes'
115                                 ;;
116                         *)
117                                 with_sysio='no'
118                                 ;;
119                 esac
120         ])
121 AC_MSG_CHECKING([location of libsysio])
122 enable_sysio="$with_sysio"
123 case x$with_sysio in
124         xyes)
125                 AC_MSG_RESULT([internal])
126                 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[
127                         AC_MSG_ERROR([A complete internal libsysio was not found.])
128                 ])
129                 LIBSYSIO_SUBDIR="libsysio"
130                 SYSIO="$PWD/libsysio"
131                 ;;
132         xno)
133                 AC_MSG_RESULT([disabled])
134                 ;;
135         *)
136                 AC_MSG_RESULT([$with_sysio])
137                 LB_CHECK_FILE([$with_sysio/lib/libsysio.a],[],[
138                         AC_MSG_ERROR([A complete (built) external libsysio was not found.])
139                 ])
140                 SYSIO=$with_sysio
141                 with_sysio="yes"
142                 ;;
143 esac
144
145 # We have to configure even if we don't build here for make dist to work
146 AC_CONFIG_SUBDIRS(libsysio)
147 ])
148
149 #
150 # LB_PATH_LUSTREIOKIT
151 #
152 # Handle internal/external lustre-iokit
153 #
154 AC_DEFUN([LB_PATH_LUSTREIOKIT],
155 [AC_ARG_WITH([lustre-iokit],
156         AC_HELP_STRING([--with-lustre-iokit=path],
157                         [set path to lustre-iokit source (default is included lustre-iokit)]),
158         [],[
159                         with_lustre_iokit='yes'
160         ])
161 AC_MSG_CHECKING([location of lustre-iokit])
162 enable_lustre_iokit="$with_lustre_iokit"
163 case x$with_lustre_iokit in
164         xyes)
165                 AC_MSG_RESULT([internal])
166                 LB_CHECK_FILE([$srcdir/lustre-iokit/ior-survey/ior-survey],[],[
167                         AC_MSG_ERROR([A complete internal lustre-iokit was not found.])
168                 ])
169                 LUSTREIOKIT_SUBDIR="lustre-iokit"
170                 LUSTREIOKIT="$PWD/lustre-iokit"
171                 ;;
172         xno)
173                 AC_MSG_RESULT([disabled])
174                 ;;
175         *)
176                 AC_MSG_RESULT([$with_lustre_iokit])
177                 LB_CHECK_FILE([$with_lustre_iokit/ior-survey/ior_survey],[],[
178                         AC_MSG_ERROR([A complete (built) external lustre-iokit was not found.])
179                 ])
180                 LUSTREIOKIT="$with_lustre_iokit"
181                 with_lustre_iokit="yes"
182                 ;;
183 esac
184 AC_SUBST(LUSTREIOKIT_SUBDIR)
185 # We have to configure even if we don't build here for make dist to work
186 AC_CONFIG_SUBDIRS(lustre-iokit)
187 ])
188
189 #
190 # LB_PATH_LDISKFS
191 #
192 # Handle internal/external ldiskfs
193 #
194 AC_DEFUN([LB_PATH_LDISKFS],
195 [AC_ARG_WITH([ldiskfs],
196         AC_HELP_STRING([--with-ldiskfs=path],
197                         [set path to ldiskfs source (default is included ldiskfs)]),
198         [],[
199                 if test x$linux25$enable_server = xyesyes ; then
200                         with_ldiskfs=yes
201                 else
202                         with_ldiskfs=no
203                 fi
204         ])
205 AC_ARG_WITH([ldiskfs-inkernel],
206         AC_HELP_STRING([--with-ldiskfs-inkernel],
207                         [use ldiskfs built in to the kernel]),
208         [with_ldiskfs=inkernel], [])
209 AC_MSG_CHECKING([location of ldiskfs])
210 case x$with_ldiskfs in
211         xyes)
212                 AC_MSG_RESULT([internal])
213                 LB_CHECK_FILE([$srcdir/ldiskfs/lustre-ldiskfs.spec.in],[],[
214                         AC_MSG_ERROR([A complete internal ldiskfs was not found.])
215                 ])
216                 LDISKFS_SUBDIR="ldiskfs"
217                 LDISKFS_DIR="$PWD/ldiskfs"
218                 ;;
219         xno)
220                 AC_MSG_RESULT([disabled])
221                 ;;
222         xinkernel)
223                 AC_MSG_RESULT([inkernel])
224                 LB_CHECK_FILE([$LINUX/include/linux/ldiskfs_fs.h],[],[
225                         AC_MSG_ERROR([ldiskfs was not found in $LINUX/include/linux/ldiskfs_fs.h])
226                 ])
227                 ;;
228         *)
229                 AC_MSG_RESULT([$with_ldiskfs])
230                 LB_CHECK_FILE([$with_ldiskfs/ldiskfs/linux/ldiskfs_fs.h],[],[
231                         AC_MSG_ERROR([A complete (built) external ldiskfs was not found.])
232                 ])
233                 LDISKFS_DIR=$with_ldiskfs
234                 ;;
235 esac
236 AC_SUBST(LDISKFS_DIR)
237 AC_SUBST(LDISKFS_SUBDIR)
238 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs != xno)
239 AM_CONDITIONAL(LDISKFS_IN_KERNEL, test x$with_ldiskfs = xinkernel)
240
241 if test x$enable_ext4 = xyes ; then
242         AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [build ext4 based ldiskfs])
243 fi
244
245 # We have to configure even if we don't build here for make dist to work
246 AC_CONFIG_SUBDIRS(ldiskfs)
247 ])
248
249 AC_DEFUN([LC_KERNEL_WITH_EXT4],
250 [if test -f $LINUX/fs/ext4/ext4.h ; then
251 $1
252 else
253 $2
254 fi
255 ])
256
257 #
258 # LB_HAVE_EXT4_ENABLED
259 #
260 AC_DEFUN([LB_HAVE_EXT4_ENABLED],
261 [
262 if test x$RHEL_KERNEL = xyes; then
263         AC_ARG_ENABLE([ext4],
264                  AC_HELP_STRING([--enable-ext4],
265                                 [enable building of ldiskfs based on ext4]),
266                 [],
267                 [
268                         if test x$ldiskfs_is_ext4 = xyes; then
269                                 enable_ext4=yes
270                         else
271                                 enable_ext4=no
272                         fi
273                 ])
274 else
275         case $LINUXRELEASE in
276         # ext4 was in 2.6.22-2.6.26 but not stable enough to use
277         2.6.2[[0-9]]*) enable_ext4='no' ;;
278         *)  LC_KERNEL_WITH_EXT4([enable_ext4='yes'],
279                                 [enable_ext4='no']) ;;
280         esac
281 fi
282 if test x$enable_ext4 = xyes; then
283          ac_configure_args="$ac_configure_args --enable-ext4"
284 fi
285 AC_MSG_CHECKING([whether to build ldiskfs based on ext4])
286 AC_MSG_RESULT([$enable_ext4])
287 ])
288
289 # Define no libcfs by default.
290 AC_DEFUN([LB_LIBCFS_DIR],
291 [
292 case x$libcfs_is_module in
293         xyes)
294           LIBCFS_INCLUDE_DIR="libcfs/include"
295           LIBCFS_SUBDIR="libcfs"
296           ;;
297         x*)
298           LIBCFS_INCLUDE_DIR="lnet/include"
299           LIBCFS_SUBDIR=""
300           ;;
301 esac
302 AC_SUBST(LIBCFS_SUBDIR)
303 AC_SUBST(LIBCFS_INCLUDE_DIR)
304 ])
305
306 #
307 # LB_DEFINE_LDISKFS_OPTIONS
308 #
309 # Enable config options related to ldiskfs.  These are used both by ldiskfs
310 # and lvfs (which includes ldiskfs headers.)
311 #
312 AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
313 [
314         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
315         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
316         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
317         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
318         AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
319         AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
320         AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
321 ])
322
323 #
324 # LB_DEFINE_E2FSPROGS_NAMES
325 #
326 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
327 #
328 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
329 [AC_ARG_WITH([ldiskfsprogs],
330         AC_HELP_STRING([--with-ldiskfsprogs],
331                        [use alternate names for ldiskfs-enabled e2fsprogs]),
332         [],[withval='no'])
333
334 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
335 if test x$withval = xyes ; then
336         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
337         E2FSPROGS="ldiskfsprogs"
338         MKE2FS="mkfs.ldiskfs"
339         DEBUGFS="debugfs.ldiskfs"
340         TUNE2FS="tunefs.ldiskfs"
341         E2LABEL="label.ldiskfs"
342         DUMPE2FS="dumpfs.ldiskfs"
343         E2FSCK="fsck.ldiskfs"
344         AC_MSG_RESULT([enabled])
345 else
346         E2FSPROGS="e2fsprogs"
347         MKE2FS="mke2fs"
348         DEBUGFS="debugfs"
349         TUNE2FS="tune2fs"
350         E2LABEL="e2label"
351         DUMPE2FS="dumpe2fs"
352         E2FSCK="e2fsck"
353         AC_MSG_RESULT([disabled])
354 fi
355         AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
356         AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
357         AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
358         AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
359         AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
360         AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
361         AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
362 ])
363
364 #
365 # LB_CONFIG_CRAY_XT3
366 #
367 # Enable Cray XT3 features
368 #
369 AC_DEFUN([LB_CONFIG_CRAY_XT3],
370 [AC_MSG_CHECKING([whether to build Cray XT3 features])
371 AC_ARG_ENABLE([cray_xt3],
372         AC_HELP_STRING([--enable-cray-xt3],
373                         [enable building of Cray XT3 features]),
374         [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
375 AC_MSG_RESULT([$enable_cray_xt3])
376 if test x$enable_cray_xt3 != xno; then
377         AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
378 fi
379 ])
380
381 #
382 # LB_CONFIG_BGL
383 #
384 # Enable BGL features
385 #
386 AC_DEFUN([LB_CONFIG_BGL],
387 [AC_MSG_CHECKING([whether to build BGL features])
388 AC_ARG_ENABLE([bgl],
389         AC_HELP_STRING([--enable-bgl],
390                         [enable building of BGL features]),
391         [enable_bgl='yes'],[enable_bgl='no'])
392 AC_MSG_RESULT([$enable_bgl])
393 if test x$enable_bgl != xno; then
394         AC_DEFINE(HAVE_BGL_SUPPORT, 1, Enable BGL Features)
395         enable_doc='no'
396         enable_tests='no'
397         enable_server='no'
398         enable_liblustre='no'
399         enable_libreadline='no'
400 fi
401 ])
402
403 #
404 # Support for --enable-uoss
405 #
406 AC_DEFUN([LB_UOSS],
407 [AC_MSG_CHECKING([whether to enable uoss])
408 AC_ARG_ENABLE([uoss],
409         AC_HELP_STRING([--enable-uoss],
410                         [enable userspace OSS]),
411         [enable_uoss='yes'],[enable_uoss='no'])
412 AC_MSG_RESULT([$enable_uoss])
413 if test x$enable_uoss = xyes; then
414         AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
415         AC_DEFINE(LUSTRE_ULEVEL_MT, 1, Multi-threaded user-level lustre port)
416         enable_uoss='yes'
417         enable_ulevel_mt='yes'
418         enable_modules='no'
419         enable_client='no'
420         enable_tests='no'
421         enable_liblustre='no'
422         with_ldiskfs='no'
423 fi
424 AC_SUBST(enable_uoss)
425 ])
426
427 #
428 # Support for --enable-posix-osd
429 #
430 AC_DEFUN([LB_POSIX_OSD],
431 [AC_MSG_CHECKING([whether to enable posix osd])
432 AC_ARG_ENABLE([posix-osd],
433         AC_HELP_STRING([--enable-posix-osd],
434                         [enable using of posix osd]),
435         [enable_posix_osd='yes'],[enable_posix_osd='no'])
436 AC_MSG_RESULT([$enable_posix_osd])
437 if test x$enable_uoss = xyes -a x$enable_posix_osd = xyes ; then
438         AC_DEFINE(POSIX_OSD, 1, Enable POSIX OSD)
439         posix_osd='yes'
440 fi
441 AM_CONDITIONAL(POSIX_OSD_ENABLED, test x$posix_osd = xyes)
442 ])
443
444 #
445 # LB_PATH_DMU
446 #
447 AC_DEFUN([LB_PATH_DMU],
448 [AC_ARG_ENABLE([dmu],
449         AC_HELP_STRING([--enable-dmu],
450                        [enable the DMU backend]),
451         [],[with_dmu='default'])
452 AC_MSG_CHECKING([whether to enable DMU])
453 case x$with_dmu in
454         xyes)
455                 dmu_osd='yes'
456                 ;;
457         xno)
458                 dmu_osd='no'
459                 ;;
460         xdefault)
461                 if test x$enable_uoss = xyes -a x$posix_osd != xyes; then
462                         # Enable the DMU if we're configuring a userspace server
463                         dmu_osd='yes'
464                 else
465                         # Enable the DMU by default on the b_hd_kdmu branch
466                         if test -d $PWD/zfs -a x$linux25$enable_server = xyesyes; then
467                                 dmu_osd='yes'
468                         else
469                                 dmu_osd='no'
470                         fi
471                 fi
472                 ;;
473         *)
474                 dmu_osd='yes'
475                 ;;
476 esac
477 AC_MSG_RESULT([$dmu_osd])
478 if test x$dmu_osd = xyes; then
479         AC_DEFINE(DMU_OSD, 1, Enable DMU OSD)
480         if test x$enable_uoss = xyes; then
481                 # Userspace DMU
482                 DMU_SRC="$PWD/lustre/zfs-lustre"
483                 AC_SUBST(DMU_SRC)
484                 LB_CHECK_FILE([$DMU_SRC/src/.patched],[],[
485                         AC_MSG_ERROR([A complete (patched) DMU tree was not found.])
486                 ])
487                 AC_CONFIG_SUBDIRS(lustre/zfs-lustre)
488         else
489                 # Kernel DMU
490                 SPL_SUBDIR="spl"
491                 ZFS_SUBDIR="zfs"
492
493                 SPL_DIR="$PWD/$SPL_SUBDIR"
494                 ZFS_DIR="$PWD/$ZFS_SUBDIR"
495
496                 LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
497                         AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
498                 ])
499
500                 LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
501                         AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
502                 ])
503
504                 AC_CONFIG_SUBDIRS(spl)
505                 ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
506                 AC_CONFIG_SUBDIRS(zfs)
507         fi
508 fi
509 AC_SUBST(SPL_SUBDIR)
510 AC_SUBST(ZFS_SUBDIR)
511 AC_SUBST(SPL_DIR)
512 AC_SUBST(ZFS_DIR)
513 AM_CONDITIONAL(DMU_OSD_ENABLED, test x$dmu_osd = xyes)
514 AM_CONDITIONAL(KDMU, test x$dmu_osd$enable_uoss = xyesno)
515 ])
516
517 #
518 # LB_PATH_SNMP
519 #
520 # check for in-tree snmp support
521 #
522 AC_DEFUN([LB_PATH_SNMP],
523 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
524 AC_SUBST(SNMP_DIST_SUBDIR)
525 AC_SUBST(SNMP_SUBDIR)
526 ])
527
528 #
529 # LB_CONFIG_MODULES
530 #
531 # Build kernel modules?
532 #
533 AC_DEFUN([LB_CONFIG_MODULES],
534 [AC_MSG_CHECKING([whether to build kernel modules])
535 AC_ARG_ENABLE([modules],
536         AC_HELP_STRING([--disable-modules],
537                         [disable building of Lustre kernel modules]),
538         [],[
539                 LC_TARGET_SUPPORTED([
540                         enable_modules='yes'
541                 ],[
542                         enable_modules='no'
543                 ])
544         ])
545 AC_MSG_RESULT([$enable_modules ($target_os)])
546
547 if test x$enable_modules = xyes ; then
548         case $target_os in
549                 linux*)
550                         LB_PROG_LINUX
551                         LIBCFS_PROG_LINUX
552                         LN_PROG_LINUX
553                         LC_PROG_LINUX
554                         ;;
555                 darwin*)
556                         LB_PROG_DARWIN
557                         LIBCFS_PROG_DARWIN
558                         ;;
559                 *)
560                         # This is strange - Lustre supports a target we don't
561                         AC_MSG_ERROR([Modules are not supported on $target_os])
562                         ;;
563         esac
564 fi
565 ])
566
567 #
568 # LB_CONFIG_UTILS
569 #
570 # Build utils?
571 #
572 AC_DEFUN([LB_CONFIG_UTILS],
573 [AC_MSG_CHECKING([whether to build utilities])
574 AC_ARG_ENABLE([utils],
575         AC_HELP_STRING([--disable-utils],
576                         [disable building of Lustre utility programs]),
577         [],[enable_utils='yes'])
578 AC_MSG_RESULT([$enable_utils])
579 if test x$enable_utils = xyes ; then 
580         LB_CONFIG_INIT_SCRIPTS
581 fi
582 ])
583
584 #
585 # LB_CONFIG_TESTS
586 #
587 # Build tests?
588 #
589 AC_DEFUN([LB_CONFIG_TESTS],
590 [AC_MSG_CHECKING([whether to build Lustre tests])
591 AC_ARG_ENABLE([tests],
592         AC_HELP_STRING([--disable-tests],
593                         [disable building of Lustre tests]),
594         [],
595         [
596                 enable_tests='yes'
597         ])
598 AC_MSG_RESULT([$enable_tests])
599 ])
600
601 #
602 # LB_CONFIG_DOCS
603 #
604 # Build docs?
605 #
606 AC_DEFUN([LB_CONFIG_DOCS],
607 [AC_MSG_CHECKING([whether to build docs])
608 AC_ARG_ENABLE(doc,
609         AC_HELP_STRING([--disable-doc],
610                         [skip creation of pdf documentation]),
611         [
612                 if test x$enable_doc = xyes ; then
613                     ENABLE_DOC=1           
614                 else
615                     ENABLE_DOC=0
616                 fi
617         ],[
618                 ENABLE_DOC=0
619                 enable_doc='no'
620         ])
621 AC_MSG_RESULT([$enable_doc])
622 AC_SUBST(ENABLE_DOC)
623 ])
624
625 #
626 # LB_CONFIG_INIT_SCRIPTS
627 #
628 # our init scripts only work on red hat linux
629 #
630 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
631 [ENABLE_INIT_SCRIPTS=0
632 if test x$enable_utils = xyes ; then
633         AC_MSG_CHECKING([whether to install init scripts])
634         # our scripts only work on red hat systems
635         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
636                 ENABLE_INIT_SCRIPTS=1
637                 AC_MSG_RESULT([yes])
638         else
639                 AC_MSG_RESULT([no])
640         fi
641 fi
642 AC_SUBST(ENABLE_INIT_SCRIPTS)
643 ])
644
645 #
646 # LB_CONFIG_HEADERS
647 #
648 # add -include config.h
649 #
650 AC_DEFUN([LB_CONFIG_HEADERS],
651 [AC_CONFIG_HEADERS([config.h])
652 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
653 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
654 AC_SUBST(EXTRA_KCFLAGS)
655 ])
656
657 #
658 # LB_INCLUDE_RULES
659 #
660 # defines for including the toplevel Rules
661 #
662 AC_DEFUN([LB_INCLUDE_RULES],
663 [INCLUDE_RULES="include $PWD/Rules"
664 AC_SUBST(INCLUDE_RULES)
665 ])
666
667 #
668 # LB_PATH_DEFAULTS
669 #
670 # 'fixup' default paths
671 #
672 AC_DEFUN([LB_PATH_DEFAULTS],
673 [# directories for binaries
674 AC_PREFIX_DEFAULT([/usr])
675
676 sysconfdir='/etc'
677 AC_SUBST(sysconfdir)
678
679 # Directories for documentation and demos.
680 docdir='${datadir}/doc/$(PACKAGE)'
681 AC_SUBST(docdir)
682
683 LIBCFS_PATH_DEFAULTS
684 LN_PATH_DEFAULTS
685 LC_PATH_DEFAULTS
686
687 ])
688
689 #
690 # LB_PROG_CC
691 #
692 # checks on the C compiler
693 #
694 AC_DEFUN([LB_PROG_CC],
695 [AC_PROG_RANLIB
696 AC_MSG_CHECKING([for buggy compiler])
697 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
698 bad_cc() {
699         AC_MSG_RESULT([buggy compiler found!])
700         echo
701         echo "   '$CC_VERSION'"
702         echo "  has been known to generate bad code, "
703         echo "  please get an updated compiler."
704         AC_MSG_ERROR([sorry])
705 }
706 case "$CC_VERSION" in
707         "gcc version 2.95"*)
708                 bad_cc
709                 ;;
710         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
711         # without "sub    $0xc,%esp" to protect the stack from being
712         # stomped on by interrupts (bug 606)
713         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
714                 bad_cc
715                 ;;
716         # mandrake's similar sub 0xc compiler bug
717         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
718         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
719                 bad_cc
720                 ;;
721         *)
722                 AC_MSG_RESULT([no known problems])
723                 ;;
724 esac
725
726 # ---------  unsigned long long sane? -------
727 AC_CHECK_SIZEOF(unsigned long long, 0)
728 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
729 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
730 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
731         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
732 fi
733
734 if test $target_cpu == "powerpc64"; then
735         AC_MSG_WARN([set compiler with -m64])
736         CFLAGS="$CFLAGS -m64"
737         CC="$CC -m64"
738 fi
739
740 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
741
742 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
743 AC_SUBST(LLCPPFLAGS)
744
745 # Add _GNU_SOURCE for strnlen on linux
746 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
747 AC_SUBST(LLCFLAGS)
748
749 # everyone builds against lnet and lustre
750 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
751 AC_SUBST(EXTRA_KCFLAGS)
752 ])
753
754 #
755 # LB_CONTITIONALS
756 #
757 # AM_CONDITIONAL instances for everything
758 # (so that portals/lustre can disable some if needed)
759 AC_DEFUN([LB_CONDITIONALS],
760 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
761 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
762 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
763 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
764 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
765 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
766 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
767 AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
768 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
769
770 # this lets lustre cancel libsysio, per-branch or if liblustre is
771 # disabled
772 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
773         if test "x$with_sysio" != xyes ; then
774                 SYSIO=""
775                 LIBSYSIO_SUBDIR=""
776         fi
777 fi
778 AC_SUBST(LIBSYSIO_SUBDIR)
779 AC_SUBST(SYSIO)
780
781 LB_LINUX_CONDITIONALS
782 LB_DARWIN_CONDITIONALS
783
784 LIBCFS_CONDITIONALS
785 LN_CONDITIONALS
786 LC_CONDITIONALS
787 ])
788
789 #
790 # LB_CONFIG_FILES
791 #
792 # build-specific config files
793 #
794 AC_DEFUN([LB_CONFIG_FILES],
795 [
796 AC_CONFIG_FILES(
797 [Makefile
798 autoMakefile
799 ]
800 [Rules:build/Rules.in]
801 AC_PACKAGE_TARNAME[.spec]
802 )
803 ])
804
805 #
806 # LB_CONFIGURE
807 #
808 # main configure steps
809 #
810 AC_DEFUN([LB_CONFIGURE],
811 [LB_CANONICAL_SYSTEM
812
813 LB_LIBCFS_DIR
814
815 LB_INCLUDE_RULES
816
817 LB_CONFIG_CRAY_XT3
818 LB_CONFIG_BGL
819 LB_PATH_DEFAULTS
820
821 LB_PROG_CC
822
823 LB_UOSS
824 LB_POSIX_OSD
825
826 LB_CONFIG_DOCS
827 LB_CONFIG_UTILS
828 LB_CONFIG_TESTS
829 LC_CONFIG_CLIENT_SERVER
830
831 # two macros for cmd3 
832 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
833 LN_CONFIG_CDEBUG
834 LC_QUOTA
835
836 LB_CONFIG_MODULES
837 LN_CONFIG_USERSPACE
838 LB_HAVE_EXT4_ENABLED
839
840 LB_PATH_DMU
841 LB_PATH_LIBSYSIO
842 LB_PATH_SNMP
843 LB_PATH_LDISKFS
844 LB_PATH_LUSTREIOKIT
845
846 LB_DEFINE_E2FSPROGS_NAMES
847
848 LC_CONFIG_LIBLUSTRE
849 LIBCFS_CONFIGURE
850 LN_CONFIGURE
851
852 LC_CONFIGURE
853
854 if test "$SNMP_DIST_SUBDIR" ; then
855         LS_CONFIGURE
856 fi
857
858
859 LB_CONDITIONALS
860 LB_CONFIG_HEADERS
861
862 LIBCFS_CONFIG_FILES
863 LB_CONFIG_FILES
864 LN_CONFIG_FILES
865 LC_CONFIG_FILES
866 if test "$SNMP_DIST_SUBDIR" ; then
867         LS_CONFIG_FILES
868 fi
869
870 AC_SUBST(ac_configure_args)
871
872 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
873 AC_SUBST(MOSTLYCLEANFILES)
874
875 AC_OUTPUT
876
877 cat <<_ACEOF
878
879 CC:            $CC
880 LD:            $LD
881 CPPFLAGS:      $CPPFLAGS
882 LLCPPFLAGS:    $LLCPPFLAGS
883 CFLAGS:        $CFLAGS
884 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
885 LLCFLAGS:      $LLCFLAGS
886
887 Type 'make' to build Lustre.
888 _ACEOF
889 ])