4 # Verify that LUSTRE_VERSION was defined properly
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.])
15 # fixup $target_os for use in other places
17 AC_DEFUN([LB_CANONICAL_SYSTEM],
28 AC_SUBST(lb_target_os)
32 # LB_DOWNSTREAM_RELEASE
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],
40 # if not specified, see if it's in the META file
42 DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)
45 AC_SUBST(DOWNSTREAM_RELEASE)
51 # Check if the source is a GA release and if not, set a "BUILDID"
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],
59 AC_MSG_CHECKING([for buildid])
61 if git branch >/dev/null 2>&1; then
64 ver=$(git describe --match v[[0-9]]_*_[[0-9]]* --tags)
65 if [[[ $ver = *-*-* ]]]; then
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
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')
79 # a "lustre fix" value of .0 should be truncated
80 if [[[ $ver = *.*.*.0 ]]]; then
83 # ditto for a "lustre fix" value of _0
84 if [[[ $ver = v*_*_*_0 ]]]; then
87 if [[[ $ver = v*_*_* ]]]; then
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.])
97 if test "$ffw" != "0"; then
99 msg="$BUILDID (ahead by $ffw commits)"
100 AC_MSG_RESULT([$msg])
102 AC_MSG_RESULT([none... congratulations, you must be on a tag])
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])
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.])
117 # Check for file existance even when cross compiling
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)
125 AS_VAR_SET(lb_File, no)
127 AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
128 AS_VAR_POPDEF([lb_File])dnl
133 # LB_ARG_LIBS_INCLUDES
135 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
136 # a single magical macro
138 AC_DEFUN([LB_ARG_LIBS_INCLUDES],
139 [lb_pathvar="m4_bpatsubst([$2], -, _)"
140 AC_MSG_CHECKING([for $1])
142 AC_HELP_STRING([--with-$2=path],
146 if test x$withval = xyes ; then
147 eval "$lb_pathvar='$3'"
149 eval "$lb_pathvar='$withval'"
151 AC_MSG_RESULT([${!lb_pathvar:-no}])
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]),
160 lb_includevar="${lb_pathvar}_includes"
161 if test x$withval = xyes ; then
162 eval "${lb_includevar}='${!lb_pathvar}/include'"
164 eval "${lb_includevar}='$withval'"
166 AC_MSG_RESULT([${!lb_includevar}])
168 AC_MSG_CHECKING([for $1 libs])
169 AC_ARG_WITH([$2-libs],
170 AC_HELP_STRING([--with-$2-libs=path],
174 lb_libvar="${lb_pathvar}_libs"
175 if test x$withval = xyes ; then
176 eval "${lb_libvar}='${!lb_pathvar}/lib'"
178 eval "${lb_libvar}='$withval'"
180 AC_MSG_RESULT([${!lb_libvar}])
188 # Handle internal/external libsysio
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)]),
195 case $lb_target_os in
204 AC_MSG_CHECKING([location of libsysio])
205 enable_sysio="$with_sysio"
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.])
212 LIBSYSIO_SUBDIR="libsysio"
213 SYSIO="$PWD/libsysio"
216 AC_MSG_RESULT([disabled])
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.])
228 # We have to configure even if we don't build here for make dist to work
229 AC_CONFIG_SUBDIRS(libsysio)
233 # LB_PATH_LUSTREIOKIT
235 # Handle internal/external lustre-iokit
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)]),
242 with_lustre_iokit='yes'
244 AC_MSG_CHECKING([location of lustre-iokit])
245 enable_lustre_iokit="$with_lustre_iokit"
246 case x$with_lustre_iokit in
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.])
252 LUSTREIOKIT_SUBDIR="lustre-iokit"
253 LUSTREIOKIT="$PWD/lustre-iokit"
256 AC_MSG_RESULT([disabled])
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.])
263 LUSTREIOKIT="$with_lustre_iokit"
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)
271 # Define no libcfs by default.
272 AC_DEFUN([LB_LIBCFS_DIR],
274 case x$libcfs_is_module in
276 LIBCFS_INCLUDE_DIR="libcfs/include"
277 LIBCFS_SUBDIR="libcfs"
280 LIBCFS_INCLUDE_DIR="lnet/include"
284 AC_SUBST(LIBCFS_SUBDIR)
285 AC_SUBST(LIBCFS_INCLUDE_DIR)
291 # Enable Cray XT3 features
293 AC_DEFUN([LB_CONFIG_CRAY_XT3],
294 [AC_MSG_CHECKING([whether to build Cray XT3 features])
295 AC_ARG_ENABLE([cray_xt3],
296 AC_HELP_STRING([--enable-cray-xt3],
297 [enable building of Cray XT3 features]),
298 [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
299 AC_MSG_RESULT([$enable_cray_xt3])
300 if test x$enable_cray_xt3 != xno; then
301 AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
308 # Enable BGL features
310 AC_DEFUN([LB_CONFIG_BGL],
311 [AC_MSG_CHECKING([whether to build BGL features])
313 AC_HELP_STRING([--enable-bgl],
314 [enable building of BGL features]),
315 [enable_bgl='yes'],[enable_bgl='no'])
316 AC_MSG_RESULT([$enable_bgl])
317 if test x$enable_bgl != xno; then
318 AC_DEFINE(HAVE_BGL_SUPPORT, 1, Enable BGL Features)
322 enable_liblustre='no'
323 enable_libreadline='no'
328 # Support for --enable-uoss
331 [AC_MSG_CHECKING([whether to enable uoss])
332 AC_ARG_ENABLE([uoss],
333 AC_HELP_STRING([--enable-uoss],
334 [enable userspace OSS]),
335 [enable_uoss='yes'],[enable_uoss='no'])
336 AC_MSG_RESULT([$enable_uoss])
337 if test x$enable_uoss = xyes; then
338 AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
339 AC_DEFINE(LUSTRE_ULEVEL_MT, 1, Multi-threaded user-level lustre port)
341 enable_ulevel_mt='yes'
345 enable_liblustre='no'
348 AC_SUBST(enable_uoss)
352 # Support for --enable-posix-osd
354 AC_DEFUN([LB_POSIX_OSD],
355 [AC_MSG_CHECKING([whether to enable posix osd])
356 AC_ARG_ENABLE([posix-osd],
357 AC_HELP_STRING([--enable-posix-osd],
358 [enable using of posix osd]),
359 [enable_posix_osd='yes'],[enable_posix_osd='no'])
360 AC_MSG_RESULT([$enable_posix_osd])
361 if test x$enable_uoss = xyes -a x$enable_posix_osd = xyes ; then
362 AC_DEFINE(POSIX_OSD, 1, Enable POSIX OSD)
365 AM_CONDITIONAL(POSIX_OSD_ENABLED, test x$posix_osd = xyes)
371 AC_DEFUN([LB_PATH_DMU],
372 [AC_ARG_ENABLE([dmu],
373 AC_HELP_STRING([--enable-dmu],
374 [enable the DMU backend]),
375 [],[with_dmu='default'])
376 AC_MSG_CHECKING([whether to enable DMU])
385 if test x$enable_uoss = xyes -a x$posix_osd != xyes; then
386 # Enable the DMU if we're configuring a userspace server
389 # Enable the DMU by default on the b_hd_kdmu branch
390 if test -d $PWD/zfs -a x$linux25$enable_server = xyesyes; then
401 AC_MSG_RESULT([$dmu_osd])
402 if test x$dmu_osd = xyes; then
403 AC_DEFINE(DMU_OSD, 1, Enable DMU OSD)
404 if test x$enable_uoss = xyes; then
406 DMU_SRC="$PWD/lustre/zfs-lustre"
408 LB_CHECK_FILE([$DMU_SRC/src/.patched],[],[
409 AC_MSG_ERROR([A complete (patched) DMU tree was not found.])
411 AC_CONFIG_SUBDIRS(lustre/zfs-lustre)
417 SPL_DIR="$PWD/$SPL_SUBDIR"
418 ZFS_DIR="$PWD/$ZFS_SUBDIR"
420 LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
421 AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
424 LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
425 AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
428 AC_CONFIG_SUBDIRS(spl)
429 ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
430 AC_CONFIG_SUBDIRS(zfs)
437 AM_CONDITIONAL(DMU_OSD_ENABLED, test x$dmu_osd = xyes)
438 AM_CONDITIONAL(KDMU, test x$dmu_osd$enable_uoss = xyesno)
444 # check for in-tree snmp support
446 AC_DEFUN([LB_PATH_SNMP],
447 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
448 AC_SUBST(SNMP_DIST_SUBDIR)
449 AC_SUBST(SNMP_SUBDIR)
455 # Build kernel modules?
457 AC_DEFUN([LB_CONFIG_MODULES],
458 [AC_MSG_CHECKING([whether to build kernel modules])
459 AC_ARG_ENABLE([modules],
460 AC_HELP_STRING([--disable-modules],
461 [disable building of Lustre kernel modules]),
463 LC_TARGET_SUPPORTED([
469 AC_MSG_RESULT([$enable_modules ($target_os)])
471 if test x$enable_modules = xyes ; then
484 # This is strange - Lustre supports a target we don't
485 AC_MSG_ERROR([Modules are not supported on $target_os])
496 AC_DEFUN([LB_CONFIG_UTILS],
497 [AC_MSG_CHECKING([whether to build utilities])
498 AC_ARG_ENABLE([utils],
499 AC_HELP_STRING([--disable-utils],
500 [disable building of Lustre utility programs]),
501 [],[enable_utils='yes'])
502 AC_MSG_RESULT([$enable_utils])
503 if test x$enable_utils = xyes ; then
504 LB_CONFIG_INIT_SCRIPTS
513 AC_DEFUN([LB_CONFIG_TESTS],
514 [AC_MSG_CHECKING([whether to build Lustre tests])
515 AC_ARG_ENABLE([tests],
516 AC_HELP_STRING([--disable-tests],
517 [disable building of Lustre tests]),
522 AC_MSG_RESULT([$enable_tests])
528 # Just enough configure so that "make dist" is useful
530 # this simply re-adjusts some defaults, which of course can be overridden
531 # on the configure line after the --for-dist option
533 AC_DEFUN([LB_CONFIG_DIST],
534 [AC_MSG_CHECKING([whether to configure just enough for make dist])
535 AC_ARG_ENABLE([dist],
536 AC_HELP_STRING([--enable-dist],
537 [only configure enough for make dist]),
538 [enable_dist='yes'],[enable_dist='no'])
539 AC_MSG_RESULT([$enable_dist])
540 if test x$enable_dist != xno; then
543 enable_liblustre='no'
554 AC_DEFUN([LB_CONFIG_DOCS],
555 [AC_MSG_CHECKING([whether to build docs])
557 AC_HELP_STRING([--disable-doc],
558 [skip creation of pdf documentation]),
560 if test x$enable_doc = xyes ; then
569 AC_MSG_RESULT([$enable_doc])
574 # LB_CONFIG_INIT_SCRIPTS
576 # our init scripts only work on red hat linux
578 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
579 [ENABLE_INIT_SCRIPTS=0
580 if test x$enable_utils = xyes ; then
581 AC_MSG_CHECKING([whether to install init scripts])
582 # our scripts only work on red hat systems
583 if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
584 ENABLE_INIT_SCRIPTS=1
590 AC_SUBST(ENABLE_INIT_SCRIPTS)
596 # add -include config.h
598 AC_DEFUN([LB_CONFIG_HEADERS],
599 [AC_CONFIG_HEADERS([config.h])
600 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
601 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
602 AC_SUBST(EXTRA_KCFLAGS)
608 # defines for including the toplevel Rules
610 AC_DEFUN([LB_INCLUDE_RULES],
611 [INCLUDE_RULES="include $PWD/Rules"
612 AC_SUBST(INCLUDE_RULES)
618 # 'fixup' default paths
620 AC_DEFUN([LB_PATH_DEFAULTS],
621 [# directories for binaries
622 AC_PREFIX_DEFAULT([/usr])
627 # Directories for documentation and demos.
628 docdir='${datadir}/doc/$(PACKAGE)'
640 # checks on the C compiler
642 AC_DEFUN([LB_PROG_CC],
644 AC_MSG_CHECKING([for buggy compiler])
645 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
647 AC_MSG_RESULT([buggy compiler found!])
649 echo " '$CC_VERSION'"
650 echo " has been known to generate bad code, "
651 echo " please get an updated compiler."
652 AC_MSG_ERROR([sorry])
654 case "$CC_VERSION" in
658 # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
659 # without "sub $0xc,%esp" to protect the stack from being
660 # stomped on by interrupts (bug 606)
661 "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
664 # mandrake's similar sub 0xc compiler bug
665 # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
666 "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
670 AC_MSG_RESULT([no known problems])
674 # --------- unsigned long long sane? -------
675 AC_CHECK_SIZEOF(unsigned long long, 0)
676 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
677 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
678 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
679 AC_MSG_ERROR([** we assume that sizeof(long long) == 8. Tell phil@clusterfs.com])
682 if test $target_cpu == "powerpc64"; then
683 AC_MSG_WARN([set compiler with -m64])
684 CFLAGS="$CFLAGS -m64"
688 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
690 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
693 # Add _GNU_SOURCE for strnlen on linux
694 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
697 # everyone builds against lnet and lustre
698 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
699 AC_SUBST(EXTRA_KCFLAGS)
705 # AM_CONDITIONAL instances for everything
706 # (so that portals/lustre can disable some if needed)
707 AC_DEFUN([LB_CONDITIONALS],
708 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
709 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
710 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
711 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
712 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
713 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
714 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
715 AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
716 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
717 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
719 # this lets lustre cancel libsysio, per-branch or if liblustre is
721 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
722 if test "x$with_sysio" != xyes ; then
727 AC_SUBST(LIBSYSIO_SUBDIR)
730 LB_LINUX_CONDITIONALS
731 LB_DARWIN_CONDITIONALS
741 # build-specific config files
743 AC_DEFUN([LB_CONFIG_FILES],
749 [Rules:build/Rules.in]
750 AC_PACKAGE_TARNAME[.spec]
757 # main configure steps
759 AC_DEFUN([LB_CONFIGURE],
764 LB_DOWNSTREAM_RELEASE
784 LC_CONFIG_CLIENT_SERVER
786 # two macros for cmd3
787 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
800 LB_DEFINE_E2FSPROGS_NAMES
808 if test "$SNMP_DIST_SUBDIR" ; then
820 if test "$SNMP_DIST_SUBDIR" ; then
824 AC_SUBST(ac_configure_args)
826 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
827 AC_SUBST(MOSTLYCLEANFILES)
836 LLCPPFLAGS: $LLCPPFLAGS
838 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
841 Type 'make' to build Lustre.