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