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