Whamcloud - gitweb
LU-723 Enhance lustre/ldiskfs build system
[fs/lustre-release.git] / build / autoconf / lustre-build.m4
index 77117ef..11fdcae 100644 (file)
@@ -22,14 +22,96 @@ AC_DEFUN([LB_CANONICAL_SYSTEM],
        darwin*)
                lb_target_os="darwin"
                ;;
-       solaris2.11*)
+       solaris*)
                lb_target_os="SunOS"
-               ;;
-esac
+               ;;esac
 AC_SUBST(lb_target_os)
 ])
 
 #
+# LB_DOWNSTREAM_RELEASE
+#
+AC_DEFUN([LB_DOWNSTREAM_RELEASE],
+[AC_ARG_WITH([downstream-release],
+       AC_HELP_STRING([--with-downstream-release=string],
+                      [set a string in the BUILD_VERSION and RPM Release: (default is nothing)]),
+       [DOWNSTREAM_RELEASE=$with_downstream_release],
+       [
+       # if not specified, see if it's in the META file
+       if test -f META; then
+               DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)
+       fi
+       ])
+AC_SUBST(DOWNSTREAM_RELEASE)
+])
+
+#
+# LB_BUILDID
+#
+# Check if the source is a GA release and if not, set a "BUILDID"
+#
+# Currently there are at least two ways/modes of/for doing this.  One
+# is if we are in a valid git repository, the other is if we are in a
+# non-git source tree of some form.  Building the latter from the former
+# will be handled here.
+AC_DEFUN([LB_BUILDID],
+[
+AC_MSG_CHECKING([for buildid])
+BUILDID=""
+if git branch >/dev/null 2>&1; then
+       ffw=0
+       hash=""
+       ver=$(git describe --match v[[0-9]]_*_[[0-9]] --tags)
+       if [[[ $ver = *-*-* ]]]; then
+               hash=${ver##*-}
+               ffw=${ver#*-}
+               ffw=${ffw%-*}
+               ver=${ver%%-*}
+       fi
+       # it's tempting to use [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]
+       # here but the portability of the regex on the right is dismal
+       # (thanx suse)
+       if echo "$ver" | egrep -q "^v([0-9]+_)+([0-9]+|RC[0-9]+)$"; then
+               ver=$(echo $ver | sed -e 's/^v\(.*\)/\1/' \
+                                     -e 's/_RC[[0-9]].*$//' -e 's/_/./g')
+       fi
+
+       # a "lustre fix" value of .0 should be truncated
+       if [[[ $ver = *.*.*.0 ]]]; then
+               ver=${ver%.0}
+       fi
+       # ditto for a "lustre fix" value of _0
+       if [[[ $ver = v*_*_*_0 ]]]; then
+               ver=${ver%_0}
+       fi
+       if [[[ $ver = v*_*_* ]]]; then
+               ver=${ver#v}
+               ver=${ver//_/.}
+       fi
+
+       # only do this test for lustre (not ldiskfs)
+       if test "$PACKAGE" = "lustre" -a "$ver" != "$VERSION"; then
+               AC_MSG_WARN([most recent tag found: $ver does not match current version $VERSION.])
+       fi
+
+       if test "$ffw" != "0"; then
+               BUILDID="$hash"
+               msg="$BUILDID (ahead by $ffw commits)"
+               AC_MSG_RESULT([$msg])
+       else
+               AC_MSG_RESULT([none... congratulations, you must be on a tag])
+       fi
+elif test -f META; then
+       BUILDID=$(sed -ne '/^BUILDID =/s/.*= *//p' META)
+       msg="$BUILDID (from META file)"
+       AC_MSG_RESULT([$msg])
+else
+       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.])
+fi
+AC_SUBST(BUILDID)
+])
+
+#
 # LB_CHECK_FILE
 #
 # Check for file existance even when cross compiling
@@ -46,19 +128,6 @@ AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([lb_File])dnl
 ])# LB_CHECK_FILE
 
-#
-# LB_CHECK_FILES
-#
-# LB_CHECK_FILE over multiple files
-#
-AC_DEFUN([LB_CHECK_FILES],
-[AC_FOREACH([AC_FILE_NAME], [$1],
-  [LB_CHECK_FILE(AC_FILE_NAME,
-                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
-                                    [Define to 1 if you have the
-                                     file `]AC_File['.])
-$2],
-                 [$3])])])
 
 #
 # LB_ARG_LIBS_INCLUDES
@@ -156,12 +225,67 @@ case x$with_sysio in
                ;;
 esac
 
-# We have to configure even if we don't build here for make dist to
-# work
+# We have to configure even if we don't build here for make dist to work
 AC_CONFIG_SUBDIRS(libsysio)
 ])
 
 #
+# LB_PATH_LUSTREIOKIT
+#
+# Handle internal/external lustre-iokit
+#
+AC_DEFUN([LB_PATH_LUSTREIOKIT],
+[AC_ARG_WITH([lustre-iokit],
+       AC_HELP_STRING([--with-lustre-iokit=path],
+                       [set path to lustre-iokit source (default is included lustre-iokit)]),
+       [],[
+                       with_lustre_iokit='yes'
+       ])
+AC_MSG_CHECKING([location of lustre-iokit])
+enable_lustre_iokit="$with_lustre_iokit"
+case x$with_lustre_iokit in
+       xyes)
+               AC_MSG_RESULT([internal])
+               LB_CHECK_FILE([$srcdir/lustre-iokit/ior-survey/ior-survey],[],[
+                       AC_MSG_ERROR([A complete internal lustre-iokit was not found.])
+               ])
+               LUSTREIOKIT_SUBDIR="lustre-iokit"
+               LUSTREIOKIT="$PWD/lustre-iokit"
+               ;;
+       xno)
+               AC_MSG_RESULT([disabled])
+               ;;
+       *)
+               AC_MSG_RESULT([$with_lustre_iokit])
+               LB_CHECK_FILE([$with_lustre_iokit/ior-survey/ior_survey],[],[
+                       AC_MSG_ERROR([A complete (built) external lustre-iokit was not found.])
+               ])
+               LUSTREIOKIT="$with_lustre_iokit"
+               ;;
+esac
+AC_SUBST(LUSTREIOKIT_SUBDIR)
+# We have to configure even if we don't build here for make dist to work
+AC_CONFIG_SUBDIRS(lustre-iokit)
+])
+
+# Define no libcfs by default.
+AC_DEFUN([LB_LIBCFS_DIR],
+[
+case x$libcfs_is_module in
+       xyes)
+          LIBCFS_INCLUDE_DIR="libcfs/include"
+          LIBCFS_SUBDIR="libcfs"
+          ;;
+        x*)
+          LIBCFS_INCLUDE_DIR="lnet/include"
+          LIBCFS_SUBDIR=""
+          ;;
+esac
+AC_SUBST(LIBCFS_SUBDIR)
+AC_SUBST(LIBCFS_INCLUDE_DIR)
+])
+
+#
 # LB_CONFIG_CRAY_XT3
 #
 # Enable Cray XT3 features
@@ -191,7 +315,7 @@ AC_ARG_ENABLE([bgl],
        [enable_bgl='yes'],[enable_bgl='no'])
 AC_MSG_RESULT([$enable_bgl])
 if test x$enable_bgl != xno; then
-        AC_DEFINE(BGL_SUPPORT, 1, Enable BGL Features)
+        AC_DEFINE(HAVE_BGL_SUPPORT, 1, Enable BGL Features)
         enable_doc='no'
         enable_tests='no'
         enable_server='no'
@@ -200,21 +324,118 @@ if test x$enable_bgl != xno; then
 fi
 ])
 
-
-#
-# LB_CONFIG_UOSS
 #
+# Support for --enable-uoss
 #
-AC_DEFUN([LB_CONFIG_UOSS],
-[AC_MSG_CHECKING([whether to build user-level oss])
+AC_DEFUN([LB_UOSS],
+[AC_MSG_CHECKING([whether to enable uoss])
 AC_ARG_ENABLE([uoss],
        AC_HELP_STRING([--enable-uoss],
-                       [enable building of user-level oss]),
+                       [enable userspace OSS]),
        [enable_uoss='yes'],[enable_uoss='no'])
-if test x$enable_uoss != xno; then
-        AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
-        enable_modules='no'
+AC_MSG_RESULT([$enable_uoss])
+if test x$enable_uoss = xyes; then
+       AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
+       AC_DEFINE(LUSTRE_ULEVEL_MT, 1, Multi-threaded user-level lustre port)
+       enable_uoss='yes'
+       enable_ulevel_mt='yes'
+       enable_modules='no'
+       enable_client='no'
+       enable_tests='no'
+       enable_liblustre='no'
+       with_ldiskfs='no'
+fi
+AC_SUBST(enable_uoss)
+])
+
+#
+# Support for --enable-posix-osd
+#
+AC_DEFUN([LB_POSIX_OSD],
+[AC_MSG_CHECKING([whether to enable posix osd])
+AC_ARG_ENABLE([posix-osd],
+       AC_HELP_STRING([--enable-posix-osd],
+                       [enable using of posix osd]),
+       [enable_posix_osd='yes'],[enable_posix_osd='no'])
+AC_MSG_RESULT([$enable_posix_osd])
+if test x$enable_uoss = xyes -a x$enable_posix_osd = xyes ; then
+       AC_DEFINE(POSIX_OSD, 1, Enable POSIX OSD)
+       posix_osd='yes'
 fi
+AM_CONDITIONAL(POSIX_OSD_ENABLED, test x$posix_osd = xyes)
+])
+
+#
+# LB_PATH_DMU
+#
+AC_DEFUN([LB_PATH_DMU],
+[AC_ARG_ENABLE([dmu],
+       AC_HELP_STRING([--enable-dmu],
+                      [enable the DMU backend]),
+       [],[with_dmu='default'])
+AC_MSG_CHECKING([whether to enable DMU])
+case x$with_dmu in
+       xyes)
+               dmu_osd='yes'
+               ;;
+       xno)
+               dmu_osd='no'
+               ;;
+       xdefault)
+               if test x$enable_uoss = xyes -a x$posix_osd != xyes; then
+                       # Enable the DMU if we're configuring a userspace server
+                       dmu_osd='yes'
+               else
+                       # Enable the DMU by default on the b_hd_kdmu branch
+                       if test -d $PWD/zfs -a x$linux25$enable_server = xyesyes; then
+                               dmu_osd='yes'
+                       else
+                               dmu_osd='no'
+                       fi
+               fi
+               ;;
+       *)
+               dmu_osd='yes'
+               ;;
+esac
+AC_MSG_RESULT([$dmu_osd])
+if test x$dmu_osd = xyes; then
+       AC_DEFINE(DMU_OSD, 1, Enable DMU OSD)
+       if test x$enable_uoss = xyes; then
+               # Userspace DMU
+               DMU_SRC="$PWD/lustre/zfs-lustre"
+               AC_SUBST(DMU_SRC)
+               LB_CHECK_FILE([$DMU_SRC/src/.patched],[],[
+                       AC_MSG_ERROR([A complete (patched) DMU tree was not found.])
+               ])
+               AC_CONFIG_SUBDIRS(lustre/zfs-lustre)
+       else
+               # Kernel DMU
+               SPL_SUBDIR="spl"
+               ZFS_SUBDIR="zfs"
+
+               SPL_DIR="$PWD/$SPL_SUBDIR"
+               ZFS_DIR="$PWD/$ZFS_SUBDIR"
+
+               LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
+                       AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
+               ])
+
+               LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
+                       AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
+               ])
+
+               AC_CONFIG_SUBDIRS(spl)
+               ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
+               AC_CONFIG_SUBDIRS(zfs)
+       fi
+fi
+AC_SUBST(SPL_SUBDIR)
+AC_SUBST(ZFS_SUBDIR)
+AC_SUBST(SPL_DIR)
+AC_SUBST(ZFS_DIR)
+AM_CONDITIONAL(DMU_OSD_ENABLED, test x$dmu_osd = xyes)
+AM_CONDITIONAL(KDMU, test x$dmu_osd$enable_uoss = xyesno)
 ])
 
 #
@@ -251,9 +472,13 @@ if test x$enable_modules = xyes ; then
        case $target_os in
                linux*)
                        LB_PROG_LINUX
+                       LIBCFS_PROG_LINUX
+                       LN_PROG_LINUX
+                       LC_PROG_LINUX
                        ;;
                darwin*)
                        LB_PROG_DARWIN
+                       LIBCFS_PROG_DARWIN
                        ;;
                *)
                        # This is strange - Lustre supports a target we don't
@@ -298,6 +523,30 @@ AC_MSG_RESULT([$enable_tests])
 ])
 
 #
+# LB_CONFIG_DIST
+#
+# Just enough configure so that "make dist" is useful
+#
+# this simply re-adjusts some defaults, which of course can be overridden
+# on the configure line after the --for-dist option
+#
+AC_DEFUN([LB_CONFIG_DIST],
+[AC_MSG_CHECKING([whether to configure just enough for make dist])
+AC_ARG_ENABLE([dist],
+       AC_HELP_STRING([--enable-dist],
+                       [only configure enough for make dist]),
+       [enable_dist='yes'],[enable_dist='no'])
+AC_MSG_RESULT([$enable_dist])
+if test x$enable_dist != xno; then
+       enable_modules='no'
+       enable_utils='no'
+        enable_liblustre='no'
+        enable_doc='no'
+        enable_tests='no'
+fi
+])
+
+#
 # LB_CONFIG_DOCS
 #
 # Build docs?
@@ -309,7 +558,7 @@ AC_ARG_ENABLE(doc,
                        [skip creation of pdf documentation]),
        [
                if test x$enable_doc = xyes ; then
-                   ENABLE_DOC=1           
+                   ENABLE_DOC=1
                else
                    ENABLE_DOC=0
                fi
@@ -348,7 +597,7 @@ AC_SUBST(ENABLE_INIT_SCRIPTS)
 #
 AC_DEFUN([LB_CONFIG_HEADERS],
 [AC_CONFIG_HEADERS([config.h])
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
 ])
@@ -359,7 +608,7 @@ AC_SUBST(EXTRA_KCFLAGS)
 # defines for including the toplevel Rules
 #
 AC_DEFUN([LB_INCLUDE_RULES],
-[INCLUDE_RULES="include $PWD/build/Rules"
+[INCLUDE_RULES="include $PWD/Rules"
 AC_SUBST(INCLUDE_RULES)
 ])
 
@@ -379,6 +628,7 @@ AC_SUBST(sysconfdir)
 docdir='${datadir}/doc/$(PACKAGE)'
 AC_SUBST(docdir)
 
+LIBCFS_PATH_DEFAULTS
 LN_PATH_DEFAULTS
 LC_PATH_DEFAULTS
 
@@ -429,33 +679,23 @@ if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
 fi
 
-# FIXME
-AC_CHECK_DECL([__i386__], [], [
-
-if test x$enable_bgl != xyes; then
-AC_MSG_CHECKING([if $CC accepts -m64])
-CC_save="$CC"
-CC="$CC -m64"
-AC_TRY_COMPILE([],[],[
-       AC_MSG_RESULT([yes])
-],[
-       AC_MSG_RESULT([no])
-       CC="$CC_save"
-])
+if test $target_cpu == "powerpc64"; then
+       AC_MSG_WARN([set compiler with -m64])
+       CFLAGS="$CFLAGS -m64"
+       CC="$CC -m64"
 fi
 
-])
-
-CPPFLAGS="-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 AC_SUBST(LLCPPFLAGS)
 
-LLCFLAGS="-g -Wall -fPIC"
+# Add _GNU_SOURCE for strnlen on linux
+LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
 AC_SUBST(LLCFLAGS)
 
 # everyone builds against lnet and lustre
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/lnet/include -I$PWD/lustre/include"
+EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
 AC_SUBST(EXTRA_KCFLAGS)
 ])
 
@@ -474,6 +714,7 @@ AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
 AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
+AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
 
 # this lets lustre cancel libsysio, per-branch or if liblustre is
 # disabled
@@ -488,13 +729,29 @@ AC_SUBST(SYSIO)
 
 LB_LINUX_CONDITIONALS
 LB_DARWIN_CONDITIONALS
-LB_SUNOS_CONDITIONALS
 
+LIBCFS_CONDITIONALS
 LN_CONDITIONALS
 LC_CONDITIONALS
 ])
 
 #
+# LB_CONFIG_FILES
+#
+# build-specific config files
+#
+AC_DEFUN([LB_CONFIG_FILES],
+[
+AC_CONFIG_FILES(
+[Makefile
+autoMakefile
+]
+[Rules:build/Rules.in]
+AC_PACKAGE_TARNAME[.spec]
+)
+])
+
+#
 # LB_CONFIGURE
 #
 # main configure steps
@@ -502,31 +759,48 @@ LC_CONDITIONALS
 AC_DEFUN([LB_CONFIGURE],
 [LB_CANONICAL_SYSTEM
 
+LB_CONFIG_DIST
+
+LB_DOWNSTREAM_RELEASE
+LB_USES_DPKG
+LB_BUILDID
+
+LB_LIBCFS_DIR
+
 LB_INCLUDE_RULES
 
 LB_CONFIG_CRAY_XT3
 LB_CONFIG_BGL
-LB_CONFIG_UOSS
 LB_PATH_DEFAULTS
 
 LB_PROG_CC
 
-LB_PATH_LIBSYSIO
-LB_PATH_SNMP
+LB_UOSS
+LB_POSIX_OSD
 
 LB_CONFIG_DOCS
 LB_CONFIG_UTILS
 LB_CONFIG_TESTS
 LC_CONFIG_CLIENT_SERVER
 
-# three macros for cmd3 
-LC_CONFIG_SPLIT
-LC_CONFIG_LDISKFS
-LC_CONFIG_CDEBUG
+# two macros for cmd3
+m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
+LN_CONFIG_CDEBUG
+LC_QUOTA
 
 LB_CONFIG_MODULES
+LN_CONFIG_USERSPACE
+
+LB_PATH_DMU
+LB_PATH_LIBSYSIO
+LB_PATH_SNMP
+LB_PATH_LDISKFS
+LB_PATH_LUSTREIOKIT
+
+LB_DEFINE_E2FSPROGS_NAMES
 
 LC_CONFIG_LIBLUSTRE
+LIBCFS_CONFIGURE
 LN_CONFIGURE
 
 LC_CONFIGURE
@@ -535,18 +809,12 @@ if test "$SNMP_DIST_SUBDIR" ; then
        LS_CONFIGURE
 fi
 
+
 LB_CONDITIONALS
 LB_CONFIG_HEADERS
 
-AC_CONFIG_FILES(
-[Makefile:build/Makefile.in.toplevel]
-[autoMakefile
-build/autoMakefile
-build/autoconf/Makefile
-build/Rules
-build/lustre.spec
-])
-
+LIBCFS_CONFIG_FILES
+LB_CONFIG_FILES
 LN_CONFIG_FILES
 LC_CONFIG_FILES
 if test "$SNMP_DIST_SUBDIR" ; then
@@ -555,7 +823,7 @@ fi
 
 AC_SUBST(ac_configure_args)
 
-MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.*'
+MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
 AC_SUBST(MOSTLYCLEANFILES)
 
 AC_OUTPUT