Whamcloud - gitweb
LU-278 only use the v* tag and limit the match
[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_ERROR([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$enable_ext4 = xyes ; then
324         AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [build ext4 based ldiskfs])
325 fi
326
327 # We have to configure even if we don't build here for make dist to work
328 AC_CONFIG_SUBDIRS(ldiskfs)
329 ])
330
331 AC_DEFUN([LC_KERNEL_WITH_EXT4],
332 [if test -f $LINUX/fs/ext4/ext4.h ; then
333 $1
334 else
335 $2
336 fi
337 ])
338
339 #
340 # LB_HAVE_EXT4_ENABLED
341 #
342 AC_DEFUN([LB_HAVE_EXT4_ENABLED],
343 [
344 if test x$RHEL_KERNEL = xyes; then
345         AC_ARG_ENABLE([ext4],
346                  AC_HELP_STRING([--enable-ext4],
347                                 [enable building of ldiskfs based on ext4]),
348                 [],
349                 [
350                         if test x$ldiskfs_is_ext4 = xyes; then
351                                 enable_ext4=yes
352                         else
353                                 enable_ext4=no
354                         fi
355                 ])
356 else
357         case $LINUXRELEASE in
358         # ext4 was in 2.6.22-2.6.26 but not stable enough to use
359         2.6.2[[0-9]]*) enable_ext4='no' ;;
360         *)  LC_KERNEL_WITH_EXT4([enable_ext4='yes'],
361                                 [enable_ext4='no']) ;;
362         esac
363 fi
364 if test x$enable_ext4 = xyes; then
365          ac_configure_args="$ac_configure_args --enable-ext4"
366 fi
367 AC_MSG_CHECKING([whether to build ldiskfs based on ext4])
368 AC_MSG_RESULT([$enable_ext4])
369 ])
370
371 # Define no libcfs by default.
372 AC_DEFUN([LB_LIBCFS_DIR],
373 [
374 case x$libcfs_is_module in
375         xyes)
376           LIBCFS_INCLUDE_DIR="libcfs/include"
377           LIBCFS_SUBDIR="libcfs"
378           ;;
379         x*)
380           LIBCFS_INCLUDE_DIR="lnet/include"
381           LIBCFS_SUBDIR=""
382           ;;
383 esac
384 AC_SUBST(LIBCFS_SUBDIR)
385 AC_SUBST(LIBCFS_INCLUDE_DIR)
386 ])
387
388 #
389 # LB_DEFINE_LDISKFS_OPTIONS
390 #
391 # Enable config options related to ldiskfs.  These are used both by ldiskfs
392 # and lvfs (which includes ldiskfs headers.)
393 #
394 AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
395 [
396         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
397         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
398         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
399         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
400         AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
401         AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
402         AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
403 ])
404
405 #
406 # LB_DEFINE_E2FSPROGS_NAMES
407 #
408 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
409 #
410 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
411 [AC_ARG_WITH([ldiskfsprogs],
412         AC_HELP_STRING([--with-ldiskfsprogs],
413                        [use alternate names for ldiskfs-enabled e2fsprogs]),
414         [],[withval='no'])
415
416 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
417 if test x$withval = xyes ; then
418         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
419         E2FSPROGS="ldiskfsprogs"
420         MKE2FS="mkfs.ldiskfs"
421         DEBUGFS="debugfs.ldiskfs"
422         TUNE2FS="tunefs.ldiskfs"
423         E2LABEL="label.ldiskfs"
424         DUMPE2FS="dumpfs.ldiskfs"
425         E2FSCK="fsck.ldiskfs"
426         AC_MSG_RESULT([enabled])
427 else
428         E2FSPROGS="e2fsprogs"
429         MKE2FS="mke2fs"
430         DEBUGFS="debugfs"
431         TUNE2FS="tune2fs"
432         E2LABEL="e2label"
433         DUMPE2FS="dumpe2fs"
434         E2FSCK="e2fsck"
435         AC_MSG_RESULT([disabled])
436 fi
437         AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
438         AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
439         AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
440         AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
441         AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
442         AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
443         AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
444 ])
445
446 #
447 # LB_CONFIG_CRAY_XT3
448 #
449 # Enable Cray XT3 features
450 #
451 AC_DEFUN([LB_CONFIG_CRAY_XT3],
452 [AC_MSG_CHECKING([whether to build Cray XT3 features])
453 AC_ARG_ENABLE([cray_xt3],
454         AC_HELP_STRING([--enable-cray-xt3],
455                         [enable building of Cray XT3 features]),
456         [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
457 AC_MSG_RESULT([$enable_cray_xt3])
458 if test x$enable_cray_xt3 != xno; then
459         AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
460 fi
461 ])
462
463 #
464 # LB_CONFIG_BGL
465 #
466 # Enable BGL features
467 #
468 AC_DEFUN([LB_CONFIG_BGL],
469 [AC_MSG_CHECKING([whether to build BGL features])
470 AC_ARG_ENABLE([bgl],
471         AC_HELP_STRING([--enable-bgl],
472                         [enable building of BGL features]),
473         [enable_bgl='yes'],[enable_bgl='no'])
474 AC_MSG_RESULT([$enable_bgl])
475 if test x$enable_bgl != xno; then
476         AC_DEFINE(HAVE_BGL_SUPPORT, 1, Enable BGL Features)
477         enable_doc='no'
478         enable_tests='no'
479         enable_server='no'
480         enable_liblustre='no'
481         enable_libreadline='no'
482 fi
483 ])
484
485 #
486 # Support for --enable-uoss
487 #
488 AC_DEFUN([LB_UOSS],
489 [AC_MSG_CHECKING([whether to enable uoss])
490 AC_ARG_ENABLE([uoss],
491         AC_HELP_STRING([--enable-uoss],
492                         [enable userspace OSS]),
493         [enable_uoss='yes'],[enable_uoss='no'])
494 AC_MSG_RESULT([$enable_uoss])
495 if test x$enable_uoss = xyes; then
496         AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
497         AC_DEFINE(LUSTRE_ULEVEL_MT, 1, Multi-threaded user-level lustre port)
498         enable_uoss='yes'
499         enable_ulevel_mt='yes'
500         enable_modules='no'
501         enable_client='no'
502         enable_tests='no'
503         enable_liblustre='no'
504         with_ldiskfs='no'
505 fi
506 AC_SUBST(enable_uoss)
507 ])
508
509 #
510 # Support for --enable-posix-osd
511 #
512 AC_DEFUN([LB_POSIX_OSD],
513 [AC_MSG_CHECKING([whether to enable posix osd])
514 AC_ARG_ENABLE([posix-osd],
515         AC_HELP_STRING([--enable-posix-osd],
516                         [enable using of posix osd]),
517         [enable_posix_osd='yes'],[enable_posix_osd='no'])
518 AC_MSG_RESULT([$enable_posix_osd])
519 if test x$enable_uoss = xyes -a x$enable_posix_osd = xyes ; then
520         AC_DEFINE(POSIX_OSD, 1, Enable POSIX OSD)
521         posix_osd='yes'
522 fi
523 AM_CONDITIONAL(POSIX_OSD_ENABLED, test x$posix_osd = xyes)
524 ])
525
526 #
527 # LB_PATH_DMU
528 #
529 AC_DEFUN([LB_PATH_DMU],
530 [AC_ARG_ENABLE([dmu],
531         AC_HELP_STRING([--enable-dmu],
532                        [enable the DMU backend]),
533         [],[with_dmu='default'])
534 AC_MSG_CHECKING([whether to enable DMU])
535 case x$with_dmu in
536         xyes)
537                 dmu_osd='yes'
538                 ;;
539         xno)
540                 dmu_osd='no'
541                 ;;
542         xdefault)
543                 if test x$enable_uoss = xyes -a x$posix_osd != xyes; then
544                         # Enable the DMU if we're configuring a userspace server
545                         dmu_osd='yes'
546                 else
547                         # Enable the DMU by default on the b_hd_kdmu branch
548                         if test -d $PWD/zfs -a x$linux25$enable_server = xyesyes; then
549                                 dmu_osd='yes'
550                         else
551                                 dmu_osd='no'
552                         fi
553                 fi
554                 ;;
555         *)
556                 dmu_osd='yes'
557                 ;;
558 esac
559 AC_MSG_RESULT([$dmu_osd])
560 if test x$dmu_osd = xyes; then
561         AC_DEFINE(DMU_OSD, 1, Enable DMU OSD)
562         if test x$enable_uoss = xyes; then
563                 # Userspace DMU
564                 DMU_SRC="$PWD/lustre/zfs-lustre"
565                 AC_SUBST(DMU_SRC)
566                 LB_CHECK_FILE([$DMU_SRC/src/.patched],[],[
567                         AC_MSG_ERROR([A complete (patched) DMU tree was not found.])
568                 ])
569                 AC_CONFIG_SUBDIRS(lustre/zfs-lustre)
570         else
571                 # Kernel DMU
572                 SPL_SUBDIR="spl"
573                 ZFS_SUBDIR="zfs"
574
575                 SPL_DIR="$PWD/$SPL_SUBDIR"
576                 ZFS_DIR="$PWD/$ZFS_SUBDIR"
577
578                 LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
579                         AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
580                 ])
581
582                 LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
583                         AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
584                 ])
585
586                 AC_CONFIG_SUBDIRS(spl)
587                 ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
588                 AC_CONFIG_SUBDIRS(zfs)
589         fi
590 fi
591 AC_SUBST(SPL_SUBDIR)
592 AC_SUBST(ZFS_SUBDIR)
593 AC_SUBST(SPL_DIR)
594 AC_SUBST(ZFS_DIR)
595 AM_CONDITIONAL(DMU_OSD_ENABLED, test x$dmu_osd = xyes)
596 AM_CONDITIONAL(KDMU, test x$dmu_osd$enable_uoss = xyesno)
597 ])
598
599 #
600 # LB_PATH_SNMP
601 #
602 # check for in-tree snmp support
603 #
604 AC_DEFUN([LB_PATH_SNMP],
605 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
606 AC_SUBST(SNMP_DIST_SUBDIR)
607 AC_SUBST(SNMP_SUBDIR)
608 ])
609
610 #
611 # LB_CONFIG_MODULES
612 #
613 # Build kernel modules?
614 #
615 AC_DEFUN([LB_CONFIG_MODULES],
616 [AC_MSG_CHECKING([whether to build kernel modules])
617 AC_ARG_ENABLE([modules],
618         AC_HELP_STRING([--disable-modules],
619                         [disable building of Lustre kernel modules]),
620         [],[
621                 LC_TARGET_SUPPORTED([
622                         enable_modules='yes'
623                 ],[
624                         enable_modules='no'
625                 ])
626         ])
627 AC_MSG_RESULT([$enable_modules ($target_os)])
628
629 if test x$enable_modules = xyes ; then
630         case $target_os in
631                 linux*)
632                         LB_PROG_LINUX
633                         LIBCFS_PROG_LINUX
634                         LN_PROG_LINUX
635                         LC_PROG_LINUX
636                         ;;
637                 darwin*)
638                         LB_PROG_DARWIN
639                         LIBCFS_PROG_DARWIN
640                         ;;
641                 *)
642                         # This is strange - Lustre supports a target we don't
643                         AC_MSG_ERROR([Modules are not supported on $target_os])
644                         ;;
645         esac
646 fi
647 ])
648
649 #
650 # LB_CONFIG_UTILS
651 #
652 # Build utils?
653 #
654 AC_DEFUN([LB_CONFIG_UTILS],
655 [AC_MSG_CHECKING([whether to build utilities])
656 AC_ARG_ENABLE([utils],
657         AC_HELP_STRING([--disable-utils],
658                         [disable building of Lustre utility programs]),
659         [],[enable_utils='yes'])
660 AC_MSG_RESULT([$enable_utils])
661 if test x$enable_utils = xyes ; then 
662         LB_CONFIG_INIT_SCRIPTS
663 fi
664 ])
665
666 #
667 # LB_CONFIG_TESTS
668 #
669 # Build tests?
670 #
671 AC_DEFUN([LB_CONFIG_TESTS],
672 [AC_MSG_CHECKING([whether to build Lustre tests])
673 AC_ARG_ENABLE([tests],
674         AC_HELP_STRING([--disable-tests],
675                         [disable building of Lustre tests]),
676         [],
677         [
678                 enable_tests='yes'
679         ])
680 AC_MSG_RESULT([$enable_tests])
681 ])
682
683 #
684 # LB_CONFIG_DIST
685 #
686 # Just enough configure so that "make dist" is useful
687 #
688 # this simply re-adjusts some defaults, which of course can be overridden
689 # on the configure line after the --for-dist option
690 #
691 AC_DEFUN([LB_CONFIG_DIST],
692 [AC_MSG_CHECKING([whether to configure just enough for make dist])
693 AC_ARG_ENABLE([dist],
694         AC_HELP_STRING([--enable-dist],
695                         [only configure enough for make dist]),
696         [enable_dist='yes'],[enable_dist='no'])
697 AC_MSG_RESULT([$enable_dist])
698 if test x$enable_dist != xno; then
699         enable_modules='no'
700         enable_utils='no'
701         enable_liblustre='no'
702         enable_doc='no'
703         enable_tests='no'
704 fi
705 ])
706
707 #
708 # LB_CONFIG_DOCS
709 #
710 # Build docs?
711 #
712 AC_DEFUN([LB_CONFIG_DOCS],
713 [AC_MSG_CHECKING([whether to build docs])
714 AC_ARG_ENABLE(doc,
715         AC_HELP_STRING([--disable-doc],
716                         [skip creation of pdf documentation]),
717         [
718                 if test x$enable_doc = xyes ; then
719                     ENABLE_DOC=1
720                 else
721                     ENABLE_DOC=0
722                 fi
723         ],[
724                 ENABLE_DOC=0
725                 enable_doc='no'
726         ])
727 AC_MSG_RESULT([$enable_doc])
728 AC_SUBST(ENABLE_DOC)
729 ])
730
731 #
732 # LB_CONFIG_INIT_SCRIPTS
733 #
734 # our init scripts only work on red hat linux
735 #
736 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
737 [ENABLE_INIT_SCRIPTS=0
738 if test x$enable_utils = xyes ; then
739         AC_MSG_CHECKING([whether to install init scripts])
740         # our scripts only work on red hat systems
741         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
742                 ENABLE_INIT_SCRIPTS=1
743                 AC_MSG_RESULT([yes])
744         else
745                 AC_MSG_RESULT([no])
746         fi
747 fi
748 AC_SUBST(ENABLE_INIT_SCRIPTS)
749 ])
750
751 #
752 # LB_CONFIG_HEADERS
753 #
754 # add -include config.h
755 #
756 AC_DEFUN([LB_CONFIG_HEADERS],
757 [AC_CONFIG_HEADERS([config.h])
758 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
759 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
760 AC_SUBST(EXTRA_KCFLAGS)
761 ])
762
763 #
764 # LB_INCLUDE_RULES
765 #
766 # defines for including the toplevel Rules
767 #
768 AC_DEFUN([LB_INCLUDE_RULES],
769 [INCLUDE_RULES="include $PWD/Rules"
770 AC_SUBST(INCLUDE_RULES)
771 ])
772
773 #
774 # LB_PATH_DEFAULTS
775 #
776 # 'fixup' default paths
777 #
778 AC_DEFUN([LB_PATH_DEFAULTS],
779 [# directories for binaries
780 AC_PREFIX_DEFAULT([/usr])
781
782 sysconfdir='/etc'
783 AC_SUBST(sysconfdir)
784
785 # Directories for documentation and demos.
786 docdir='${datadir}/doc/$(PACKAGE)'
787 AC_SUBST(docdir)
788
789 LIBCFS_PATH_DEFAULTS
790 LN_PATH_DEFAULTS
791 LC_PATH_DEFAULTS
792
793 ])
794
795 #
796 # LB_PROG_CC
797 #
798 # checks on the C compiler
799 #
800 AC_DEFUN([LB_PROG_CC],
801 [AC_PROG_RANLIB
802 AC_MSG_CHECKING([for buggy compiler])
803 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
804 bad_cc() {
805         AC_MSG_RESULT([buggy compiler found!])
806         echo
807         echo "   '$CC_VERSION'"
808         echo "  has been known to generate bad code, "
809         echo "  please get an updated compiler."
810         AC_MSG_ERROR([sorry])
811 }
812 case "$CC_VERSION" in
813         "gcc version 2.95"*)
814                 bad_cc
815                 ;;
816         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
817         # without "sub    $0xc,%esp" to protect the stack from being
818         # stomped on by interrupts (bug 606)
819         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
820                 bad_cc
821                 ;;
822         # mandrake's similar sub 0xc compiler bug
823         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
824         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
825                 bad_cc
826                 ;;
827         *)
828                 AC_MSG_RESULT([no known problems])
829                 ;;
830 esac
831
832 # ---------  unsigned long long sane? -------
833 AC_CHECK_SIZEOF(unsigned long long, 0)
834 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
835 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
836 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
837         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
838 fi
839
840 if test $target_cpu == "powerpc64"; then
841         AC_MSG_WARN([set compiler with -m64])
842         CFLAGS="$CFLAGS -m64"
843         CC="$CC -m64"
844 fi
845
846 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
847
848 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
849 AC_SUBST(LLCPPFLAGS)
850
851 # Add _GNU_SOURCE for strnlen on linux
852 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
853 AC_SUBST(LLCFLAGS)
854
855 # everyone builds against lnet and lustre
856 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
857 AC_SUBST(EXTRA_KCFLAGS)
858 ])
859
860 #
861 # LB_CONTITIONALS
862 #
863 # AM_CONDITIONAL instances for everything
864 # (so that portals/lustre can disable some if needed)
865 AC_DEFUN([LB_CONDITIONALS],
866 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
867 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
868 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
869 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
870 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
871 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
872 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
873 AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
874 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
875 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
876
877 # this lets lustre cancel libsysio, per-branch or if liblustre is
878 # disabled
879 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
880         if test "x$with_sysio" != xyes ; then
881                 SYSIO=""
882                 LIBSYSIO_SUBDIR=""
883         fi
884 fi
885 AC_SUBST(LIBSYSIO_SUBDIR)
886 AC_SUBST(SYSIO)
887
888 LB_LINUX_CONDITIONALS
889 LB_DARWIN_CONDITIONALS
890
891 LIBCFS_CONDITIONALS
892 LN_CONDITIONALS
893 LC_CONDITIONALS
894 ])
895
896 #
897 # LB_CONFIG_FILES
898 #
899 # build-specific config files
900 #
901 AC_DEFUN([LB_CONFIG_FILES],
902 [
903 AC_CONFIG_FILES(
904 [Makefile
905 autoMakefile
906 ]
907 [Rules:build/Rules.in]
908 AC_PACKAGE_TARNAME[.spec]
909 )
910 ])
911
912 #
913 # LB_CONFIGURE
914 #
915 # main configure steps
916 #
917 AC_DEFUN([LB_CONFIGURE],
918 [LB_CANONICAL_SYSTEM
919
920 LB_CONFIG_DIST
921
922 LB_DOWNSTREAM_RELEASE
923 LB_USES_DPKG
924 LB_BUILDID
925
926 LB_LIBCFS_DIR
927
928 LB_INCLUDE_RULES
929
930 LB_CONFIG_CRAY_XT3
931 LB_CONFIG_BGL
932 LB_PATH_DEFAULTS
933
934 LB_PROG_CC
935
936 LB_UOSS
937 LB_POSIX_OSD
938
939 LB_CONFIG_DOCS
940 LB_CONFIG_UTILS
941 LB_CONFIG_TESTS
942 LC_CONFIG_CLIENT_SERVER
943
944 # two macros for cmd3
945 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
946 LN_CONFIG_CDEBUG
947 LC_QUOTA
948
949 LB_CONFIG_MODULES
950 LN_CONFIG_USERSPACE
951 LB_HAVE_EXT4_ENABLED
952
953 LB_PATH_DMU
954 LB_PATH_LIBSYSIO
955 LB_PATH_SNMP
956 LB_PATH_LDISKFS
957 LB_PATH_LUSTREIOKIT
958
959 LB_DEFINE_E2FSPROGS_NAMES
960
961 LC_CONFIG_LIBLUSTRE
962 LIBCFS_CONFIGURE
963 LN_CONFIGURE
964
965 LC_CONFIGURE
966
967 if test "$SNMP_DIST_SUBDIR" ; then
968         LS_CONFIGURE
969 fi
970
971
972 LB_CONDITIONALS
973 LB_CONFIG_HEADERS
974
975 LIBCFS_CONFIG_FILES
976 LB_CONFIG_FILES
977 LN_CONFIG_FILES
978 LC_CONFIG_FILES
979 if test "$SNMP_DIST_SUBDIR" ; then
980         LS_CONFIG_FILES
981 fi
982
983 AC_SUBST(ac_configure_args)
984
985 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
986 AC_SUBST(MOSTLYCLEANFILES)
987
988 AC_OUTPUT
989
990 cat <<_ACEOF
991
992 CC:            $CC
993 LD:            $LD
994 CPPFLAGS:      $CPPFLAGS
995 LLCPPFLAGS:    $LLCPPFLAGS
996 CFLAGS:        $CFLAGS
997 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
998 LLCFLAGS:      $LLCFLAGS
999
1000 Type 'make' to build Lustre.
1001 _ACEOF
1002 ])