Whamcloud - gitweb
LU-1199 build: Untangle the ldiskfs build system from lustre 09/4409/10
authorChristopher J. Morrone <morrone2@llnl.gov>
Mon, 26 Nov 2012 21:38:35 +0000 (13:38 -0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Jan 2013 15:35:16 +0000 (10:35 -0500)
Make ldiskfs have its own independant build system, with no
sharing of files from higher up the tree in lustre.  To begin
with, this means some minor duplication of functions in build
scripts.  However, it is my opinion that the simpicity that
is gained by having a clear separation of the build systems
far outweighs the costs of some initial duplication.  It
also opens up the possibility of easily moving ldiskfs into
its own separate git repo should we choose to do so in the
future.

The separation of the build systems began by removing the
ldiskfs/build->lustre/build symbolic link, and making a
complete copy of the lustre/build tree into ldiskfs/build.
Then I iterated on removing everything from ldiskfs/build
that was unnecessary to build ldiskfs.

Since lustre's build/autogen.sh is no longer shared between
two build systems, I removed the wrapper autogen.sh scripts
and made the upper-level autogen.sh in both lustre and
ldiskfs full-fledged scripts.  This meant making a minor
change to remove bash specific language (pushd/popd).

Now the ldiskfs subtree is capable of being built completely
absent of the lustre tree.  There are no doubt more things
that can be trimmed and cleaned up, but that much is now
complete.

Also, along the way I noted build/Makefile is being ignored
by git, even though it is part of the source tree, and not
auto-generated by the build system.  I added "!Makefile" to
.gitignore in the lustre/build directory so that it is no
longer ignored.

Change-Id: I98e437a0da897680e3ea6f21f15bcd6287367166
Signed-off-by: Christopher J. Morrone <morrone2@llnl.gov>
Reviewed-on: http://review.whamcloud.com/4409
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Brian J. Murrell <brian.murrell@intel.com>
20 files changed:
autogen.sh
build/autoconf/lustre-build-ldiskfs.m4
build/autoconf/lustre-build.m4
build/autogen.sh [deleted file]
ldiskfs/.gitignore
ldiskfs/autoMakefile.am
ldiskfs/autogen.sh
ldiskfs/build [deleted symlink]
ldiskfs/build/.gitignore [new file with mode: 0644]
ldiskfs/build/Makefile [new file with mode: 0644]
ldiskfs/build/Rules.in [new file with mode: 0644]
ldiskfs/build/autoMakefile.am [new file with mode: 0644]
ldiskfs/build/autoMakefile.am.toplevel [new file with mode: 0644]
ldiskfs/build/autoconf/.gitignore [new file with mode: 0644]
ldiskfs/build/autoconf/Makefile.am [new file with mode: 0644]
ldiskfs/build/autoconf/ldiskfs-build-linux.m4 [new file with mode: 0644]
ldiskfs/build/autoconf/ldiskfs-build.m4 [new file with mode: 0644]
ldiskfs/build/autoconf/ldiskfs.m4 [new file with mode: 0644]
ldiskfs/build/quiltrc [new file with mode: 0644]
ldiskfs/configure.ac

index 1fce0a4..d87fbb6 100644 (file)
@@ -1,9 +1,152 @@
 #!/bin/sh
 
+# NOTE: Please avoid bashisms (bash specific syntax) in this script
+
 # install Lustre Git commit hooks by default - LU-2083
 for HOOK in commit-msg prepare-commit-msg; do
        [ -e .git/hooks/$HOOK ] || ln -sf ../build/$HOOK .git/hooks/
 done
 
-exec bash build/autogen.sh $@ 
+# taken from gnome-common/macros2/autogen.sh
+compare_versions() {
+       ch_min_version=$1
+       ch_actual_version=$2
+       ch_status=0
+       IFS="${IFS=     }"; ch_save_IFS="$IFS"; IFS="."
+       set $ch_actual_version
+       for ch_min in $ch_min_version; do
+               # remove letter suffixes
+               ch_cur=$(echo $1 | sed 's/[^0-9].*$//'); shift
+               if [ -z "$ch_min" ]; then break; fi
+               if [ -z "$ch_cur" ]; then ch_status=1; break; fi
+               if [ $ch_cur -gt $ch_min ]; then break; fi
+               if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
+       done
+       IFS="$ch_save_IFS"
+       return $ch_status
+}
+
+error_msg() {
+       echo "$cmd is $1.  Version $required (or higher) is"\
+            " required to build Lustre."
+
+       if [ ! -x /usr/bin/lsb_release ]; then
+               echo "lsb_release could not be found.  "\
+                    "If it were available more help on how to resolve this"
+               echo "situation would be available."
+                exit 1
+       fi
+
+       local dist_id="$(lsb_release -is)"
+       local howto=""
+       howto() {
+               echo -e "To install $cmd, you can use the command:\n# $1"
+       }
+       case $dist_id in
+                Ubuntu|Debian) howto "apt-get install $cmd" ;;
+       CentOS|RedHat*|Fedora*) howto "yum install $cmd" ;;
+                        SUSE*) howto "yast -i $cmd" ;;
+                            *) cat <<EOF
+Installation instructions for the package $cmd on $dist_id are not known.
+If you know how to install the required package, please file a bug at
+http://bugs.whamcloud.com/ and include your distribution and the output from:
+"lsb_release -is" is: "$dist_id"
+EOF
+                       ;;
+       esac
+
+       exit 1
+}
+
+check_version() {
+       local tool
+       local cmd
+       local required
+       local version
+
+       tool=$1
+       cmd=$2
+       required=$3
+       echo -n "checking for $cmd >= $required... "
+       if ! $cmd --version >/dev/null ; then
+               error_msg "missing"
+       fi
+       version=$($cmd --version | awk "/$tool \(GNU/ { print \$4 }")
+       echo "found $version"
+       if ! compare_versions "$required" "$version" ; then
+               error_msg "too old"
+       fi
+}
+
+echo "Checking for a complete tree..."
+REQUIRED_DIRS="build libcfs lnet lustre"
+OPTIONAL_DIRS="snmp portals"
+CONFIGURE_DIRS="libsysio lustre-iokit ldiskfs"
+
+for dir in $REQUIRED_DIRS ; do
+       if [ ! -d "$dir" ] ; then
+               cat >&2 <<EOF
+Your tree seems to be missing $dir.
+Please read README.lustrecvs for details.
+EOF
+               exit 1
+       fi
+       ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
+done
+# optional directories for Lustre
+for dir in $OPTIONAL_DIRS; do
+       if [ -d "$dir" ] ; then
+               ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
+       fi
+done
+
+found=false
+for AMVER in 1.9 1.10 1.11; do
+       if which automake-$AMVER 2> /dev/null; then
+               found=true
+               break
+       fi
+done
+
+if ! $found; then
+       cmd=automake required="1.9" error_msg "not found"
+       exit 1
+fi
+
+[ "${AMVER#1.}" -ge "10" ] && AMOPT="-W no-portability"
 
+check_version automake automake-$AMVER "1.9"
+check_version autoconf autoconf "2.57"
+
+run_cmd()
+{
+       cmd="$@"
+       echo -n "Running $cmd"
+       eval $cmd
+       res=$?
+       if [ $res -ne 0 ]; then
+               echo " failed: $res"
+               echo "Aborting"
+               exit 1
+       fi
+       echo
+}
+
+export ACLOCAL="aclocal-$AMVER"
+export AUTOMAKE="automake-$AMVER"
+
+run_cmd "$ACLOCAL $ACLOCAL_FLAGS"
+run_cmd "autoheader"
+run_cmd "$AUTOMAKE -a -c $AMOPT"
+run_cmd autoconf
+
+# Run autogen.sh in these directories
+PWD_SAVE=$PWD
+for dir in $CONFIGURE_DIRS; do
+       if [ -d $dir ] ; then
+               cd $dir
+               echo "Running autogen for $dir..."
+               run_cmd "sh autogen.sh"
+       fi
+       cd $PWD_SAVE
+done
index db24ac5..bff29da 100644 (file)
@@ -419,33 +419,3 @@ AC_SUBST([DUMPE2FS], [$DUMPE2FS])
 AC_SUBST([E2FSCK], [$E2FSCK])
 AC_SUBST([PFSCK], [$PFSCK])
 ])
-
-AC_DEFUN([LB_LDISKFS_SERIES],
-[
-if $1; then
-       AC_MSG_CHECKING([which ldiskfs series to use])
-       case $LINUXRELEASE in
-       2.6.18*)
-               if test x$RHEL_KERNEL = xyes; then
-                       LDISKFS_SERIES="2.6-rhel5-ext4.series"
-               fi
-               ;;
-       2.6.32*)
-               if test x$RHEL_KERNEL = xyes; then
-                       LDISKFS_SERIES="2.6-rhel6.series"
-               fi
-               if test x$SUSE_KERNEL = xyes; then
-                       LDISKFS_SERIES="2.6-sles11.series"
-               fi
-               ;;
-       *)
-               AC_MSG_WARN([Unknown kernel version $LINUXRELEASE])
-               LDISKFS_SERIES=
-               ;;
-       esac
-       AC_MSG_RESULT([$LDISKFS_SERIES])
-else
-       LDISKFS_SERIES=
-fi
-AC_SUBST(LDISKFS_SERIES)
-])
index ef1ced2..df48f11 100644 (file)
@@ -698,13 +698,12 @@ LC_CONDITIONALS
 #
 AC_DEFUN([LB_CONFIG_FILES],
 [
-AC_CONFIG_FILES(
-[Makefile
-autoMakefile
-]
-[Rules:build/Rules.in]
-AC_PACKAGE_TARNAME[.spec]
-)
+       AC_CONFIG_FILES([
+               Makefile
+               autoMakefile]
+               [Rules:build/Rules.in]
+               AC_PACKAGE_TARNAME[.spec]
+       )
 ])
 
 #
diff --git a/build/autogen.sh b/build/autogen.sh
deleted file mode 100644 (file)
index f2582b8..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/bin/bash
-
-# taken from gnome-common/macros2/autogen.sh
-compare_versions() {
-       ch_min_version=$1
-       ch_actual_version=$2
-       ch_status=0
-       IFS="${IFS=     }"; ch_save_IFS="$IFS"; IFS="."
-       set $ch_actual_version
-       for ch_min in $ch_min_version; do
-               # remove letter suffixes
-               ch_cur=$(echo $1 | sed 's/[^0-9].*$//'); shift
-               if [ -z "$ch_min" ]; then break; fi
-               if [ -z "$ch_cur" ]; then ch_status=1; break; fi
-               if [ $ch_cur -gt $ch_min ]; then break; fi
-               if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
-       done
-       IFS="$ch_save_IFS"
-       return $ch_status
-}
-
-error_msg() {
-       echo "$cmd is $1.  Version $required (or higher) is"\
-            " required to build Lustre."
-
-       if [ ! -x /usr/bin/lsb_release ]; then
-               echo "lsb_release could not be found.  "\
-                    "If it were available more help on how to resolve this"
-               echo "situation would be available."
-                exit 1
-       fi
-
-       local dist_id="$(lsb_release -is)"
-       local howto=""
-       howto() {
-               echo -e "To install $cmd, you can use the command:\n# $1"
-       }
-       case $dist_id in
-                Ubuntu|Debian) howto "apt-get install $cmd" ;;
-       CentOS|RedHat*|Fedora*) howto "yum install $cmd" ;;
-                        SUSE*) howto "yast -i $cmd" ;;
-                            *) cat <<EOF
-Installation instructions for the package $cmd on $dist_id are not known.
-If you know how to install the required package, please file a bug at
-http://bugs.whamcloud.com/ and include your distribution and the output from:
-"lsb_release -is" is: "$dist_id"
-EOF
-                       ;;
-       esac
-
-       exit 1
-}
-
-check_version() {
-       local tool
-       local cmd
-       local required
-       local version
-
-       tool=$1
-       cmd=$2
-       required=$3
-       echo -n "checking for $cmd >= $required... "
-       if ! $cmd --version >/dev/null ; then
-               error_msg "missing"
-       fi
-       version=$($cmd --version | awk "/$tool \(GNU/ { print \$4 }")
-       echo "found $version"
-       if ! compare_versions "$required" "$version" ; then
-               error_msg "too old"
-       fi
-}
-
-echo "Checking for a complete tree..."
-if [ -d kernel_patches ] ; then
-    # This is ldiskfs
-       REQUIRED_DIRS="build"
-       CONFIGURE_DIRS=""
-else
-       REQUIRED_DIRS="build libcfs lnet lustre"
-       OPTIONAL_DIRS="snmp portals"
-       CONFIGURE_DIRS="libsysio lustre-iokit ldiskfs"
-fi
-
-for dir in $REQUIRED_DIRS ; do
-       if [ ! -d "$dir" ] ; then
-               cat >&2 <<EOF
-Your tree seems to be missing $dir.
-Please read README.lustrecvs for details.
-EOF
-               exit 1
-       fi
-       ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
-done
-# optional directories for Lustre
-for dir in $OPTIONAL_DIRS; do
-       if [ -d "$dir" ] ; then
-               ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
-       fi
-done
-
-found=false
-for AMVER in 1.9 1.10 1.11; do
-       if which automake-$AMVER 2> /dev/null; then
-               found=true
-               break
-       fi
-done
-
-if ! $found; then
-       cmd=automake required="1.9" error_msg "not found"
-       exit 1
-fi
-
-[ "${AMVER#1.}" -ge "10" ] && AMOPT="-W no-portability"
-
-check_version automake automake-$AMVER "1.9"
-check_version autoconf autoconf "2.57"
-
-run_cmd()
-{
-       cmd="$@"
-       echo -n "Running $cmd"
-       eval $cmd
-       res=$?
-       if [ $res -ne 0 ]; then
-               echo " failed: $res"
-               echo "Aborting"
-               exit 1
-       fi
-       echo
-}
-
-export ACLOCAL="aclocal-$AMVER"
-export AUTOMAKE="automake-$AMVER"
-
-run_cmd "$ACLOCAL $ACLOCAL_FLAGS"
-run_cmd "autoheader"
-run_cmd "$AUTOMAKE -a -c $AMOPT"
-run_cmd autoconf
-
-# Run autogen.sh in these directories
-for dir in $CONFIGURE_DIRS; do
-       if [ -d $dir ] ; then
-               pushd $dir >/dev/null
-               echo "Running autogen for $dir..."
-               run_cmd "sh autogen.sh"
-               popd >/dev/null
-       fi
-done
index 8cb3258..50ae1e2 100644 (file)
@@ -1,14 +1,10 @@
 /Rules
 /aclocal.m4
 /autom4te.cache
-/config.guess
 /config.h
 /config.h.in
-/config.sub
-/install-sh
 /lustre-ldiskfs-*.tar.gz
 /lustre-ldiskfs.spec
-/missing
 /mkinstalldirs
 /module.order
 /modules.order
index 2b5f9ec..c57711f 100644 (file)
@@ -2,11 +2,6 @@ SUBDIRS = . ldiskfs
 SOURCES_SUBDIRS = ldiskfs
 DIST_SUBDIRS = ldiskfs
 
-# this is in fact irrelevant in this file but needed to keep
-# autoMakefile.am.toplevel happy
-BUILD_SERVER = true
-BUILD_TESTS = false
-
 include build/autoMakefile.am.toplevel
 
 EXTRA_DIST += kernel_patches
@@ -17,8 +12,5 @@ module-dist-hook:
        if ! grep "AC_INIT(\[Lustre\], \[LUSTRE_VERSION\], \[http:\/\/bugs\.whamcloud\.com\/], \[lustre\])" ../configure.ac; then \
            if [ -f META ]; then \
                cp META $(distdir)/META; \
-           else \
-               echo -e "I have no idea how to create a META file in $(distdir).\nPlease file a bug at http://bugs.whamcloud.com/"; \
-               exit 1; \
            fi; \
        fi
index d763634..908ec11 100644 (file)
@@ -1,2 +1,116 @@
-#!/bin/bash
-exec bash build/autogen.sh $@ 
+#!/bin/sh
+
+# NOTE: Please avoid bashisms (bash specific syntax) in this script
+
+# taken from gnome-common/macros2/autogen.sh
+compare_versions() {
+       ch_min_version=$1
+       ch_actual_version=$2
+       ch_status=0
+       IFS="${IFS=     }"; ch_save_IFS="$IFS"; IFS="."
+       set $ch_actual_version
+       for ch_min in $ch_min_version; do
+               # remove letter suffixes
+               ch_cur=$(echo $1 | sed 's/[^0-9].*$//'); shift
+               if [ -z "$ch_min" ]; then break; fi
+               if [ -z "$ch_cur" ]; then ch_status=1; break; fi
+               if [ $ch_cur -gt $ch_min ]; then break; fi
+               if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
+       done
+       IFS="$ch_save_IFS"
+       return $ch_status
+}
+
+error_msg() {
+       echo "$cmd is $1.  Version $required (or higher) is"\
+            " required to build Lustre."
+
+       if [ ! -x /usr/bin/lsb_release ]; then
+               echo "lsb_release could not be found.  "\
+                    "If it were available more help on how to resolve this"
+               echo "situation would be available."
+                exit 1
+       fi
+
+       local dist_id="$(lsb_release -is)"
+       local howto=""
+       howto() {
+               echo -e "To install $cmd, you can use the command:\n# $1"
+       }
+       case $dist_id in
+                Ubuntu|Debian) howto "apt-get install $cmd" ;;
+       CentOS|RedHat*|Fedora*) howto "yum install $cmd" ;;
+                        SUSE*) howto "yast -i $cmd" ;;
+                            *) cat <<EOF
+Installation instructions for the package $cmd on $dist_id are not known.
+If you know how to install the required package, please file a bug at
+http://bugs.whamcloud.com/ and include your distribution and the output from:
+"lsb_release -is" is: "$dist_id"
+EOF
+                       ;;
+       esac
+
+       exit 1
+}
+
+check_version() {
+       local tool
+       local cmd
+       local required
+       local version
+
+       tool=$1
+       cmd=$2
+       required=$3
+       echo -n "checking for $cmd >= $required... "
+       if ! $cmd --version >/dev/null ; then
+               error_msg "missing"
+       fi
+       version=$($cmd --version | awk "/$tool \(GNU/ { print \$4 }")
+       echo "found $version"
+       if ! compare_versions "$required" "$version" ; then
+               error_msg "too old"
+       fi
+}
+
+found=false
+for AMVER in 1.9 1.10 1.11; do
+       if which automake-$AMVER 2> /dev/null; then
+               found=true
+               break
+       fi
+done
+
+if ! $found; then
+       cmd=automake required="1.9" error_msg "not found"
+       exit 1
+fi
+
+[ "${AMVER#1.}" -ge "10" ] && AMOPT="-W no-portability"
+
+check_version automake automake-$AMVER "1.9"
+check_version autoconf autoconf "2.57"
+
+run_cmd()
+{
+       cmd="$@"
+       echo -n "Running $cmd"
+       eval $cmd
+       res=$?
+       if [ $res -ne 0 ]; then
+               echo " failed: $res"
+               echo "Aborting"
+               exit 1
+       fi
+       echo
+}
+
+ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/build/autoconf"
+
+export ACLOCAL="aclocal-$AMVER"
+export AUTOMAKE="automake-$AMVER"
+
+run_cmd "$ACLOCAL $ACLOCAL_FLAGS"
+run_cmd "autoheader"
+run_cmd "$AUTOMAKE -a -c $AMOPT"
+run_cmd autoconf
diff --git a/ldiskfs/build b/ldiskfs/build
deleted file mode 120000 (symlink)
index ab18017..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../build
\ No newline at end of file
diff --git a/ldiskfs/build/.gitignore b/ldiskfs/build/.gitignore
new file mode 100644 (file)
index 0000000..fff7fcd
--- /dev/null
@@ -0,0 +1,7 @@
+/Rules
+/modules.order
+/Module.markers
+/lustre.spec
+/Module.symvers
+/Modules.symvers
+!Makefile
diff --git a/ldiskfs/build/Makefile b/ldiskfs/build/Makefile
new file mode 100644 (file)
index 0000000..da0cda4
--- /dev/null
@@ -0,0 +1,55 @@
+#
+# There are four ways this Makefile can be called:
+#
+#
+# 1.  As a subdirectory from the toplevel, for automake
+#
+# 2.  A wrapper around the kernel's makefile when building modules, to
+#     possibly override the .config file
+#
+# 3.  At configure time, as the toplevel module dir for building
+#     kernel tests
+#
+# 4.  At configure time, to determine the kernel's idea of $(ARCH)
+#
+
+ifeq ($(PATCHLEVEL),)
+
+ifeq ($(LUSTRE_LINUX_CONFIG),)
+
+# case #1
+include autoMakefile
+
+else
+
+# case #2
+# Note that this comes from make -C $LINUX -f $LUSTRE/build/Makefile
+# so "include Makefile" below includes $LINUX/Makefile, not this file
+include $(LUSTRE_LINUX_CONFIG)
+include Makefile
+
+endif # LUSTRE_LINUX_CONFIG
+
+else # PATCHLEVEL
+
+# case 3
+
+ifneq ($(LUSTRE_KERNEL_TEST),)
+extra-y = $(LUSTRE_KERNEL_TEST)
+endif
+
+obj-m := conftest.o
+
+endif # PATCHLEVEL
+
+# case 4
+
+echoarch:
+       echo $(ARCH) >$(ARCHFILE)
+
+TESTS := $(wildcard commit.*)
+check-commit:
+       SHELL="$(SHELL)" $(SHELL) test-commit-msg.sh $(TESTS)
+
+check: check-commit
+.PHONY: check-commit
diff --git a/ldiskfs/build/Rules.in b/ldiskfs/build/Rules.in
new file mode 100644 (file)
index 0000000..95a6d0e
--- /dev/null
@@ -0,0 +1,39 @@
+# Directories building kernel modules should have two files:
+#
+# Makefile.in:
+#
+# MODULES := <module-name>
+# <module-name>-objs := file1.o file2.o file3.o
+# @INCLUDE_RULES@
+#
+# and autoMakefile.am:
+#
+# if MODULES
+# modulefs_DATA = <module-name>$(KMODEXT)
+# endif
+#
+# DIST_SOURCES = $(<module-name>-objs:.o=.c) <other sources>
+# MOSTLYCLEANFILES = *.o *.ko *.mod.c
+
+ifeq ($(PATCHLEVEL),)
+
+include autoMakefile
+
+fix-kext-ownership:
+       @if test -d $(DESTDIR)$(kextdir) ; then \
+               echo chown -R root:wheel $(DESTDIR)$(kextdir) ; \
+               chown -R root:wheel $(DESTDIR)$(kextdir) || \
+                       echo >&2 "*** WARNING: Could not fix kext ownership for $(DESTDIR)$(kextdir)" ; \
+       fi
+
+else
+
+include @LINUX_CONFIG@
+
+EXTRA_CFLAGS := $(EXTRA_PRE_CFLAGS)
+EXTRA_CFLAGS += @EXTRA_KCFLAGS@ @UML_CFLAGS@ @CFLAGS@
+EXTRA_CFLAGS += $(EXTRA_POST_CFLAGS)
+
+obj-m := $(patsubst %,%.o,$(MODULES))
+
+endif # PATCHLEVEL
diff --git a/ldiskfs/build/autoMakefile.am b/ldiskfs/build/autoMakefile.am
new file mode 100644 (file)
index 0000000..16df9c0
--- /dev/null
@@ -0,0 +1,10 @@
+# EXTRA_DIST is not actually taken from here but rather from
+# build/autoMakefile.am.toplevel
+
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
+
+# Override the default distclean, which removes Makefile
+distclean: distclean-recursive
+       @true
+
+SUBDIRS = autoconf
diff --git a/ldiskfs/build/autoMakefile.am.toplevel b/ldiskfs/build/autoMakefile.am.toplevel
new file mode 100644 (file)
index 0000000..daff703
--- /dev/null
@@ -0,0 +1,107 @@
+# -*- Makefile -*-
+# This file is included by each package's toplevel autoMakefile[.am],
+# which must define SUBDIRS as a minimum.
+
+AUTOMAKE_OPTIONS = foreign
+
+FIND_TAG_FILES_CMD = find $(top_srcdir) \
+                    -path $(top_srcdir)/ldiskfs/ldiskfs/linux-stage \
+                    -prune -false -o -type f -name '*.[hc]'
+
+# these empty rules are needed so that automake doesn't add its own
+# recursive rules
+etags-recursive:
+
+ctags-recursive:
+
+tags-recursive:
+
+TAGS: etags
+
+tags: ctags etags
+
+etags:
+       $(RM) $(top_srcdir)/TAGS
+       ETAGSF=`etags --version | grep -iq exuberant && \
+               echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
+       $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
+
+ctags:
+       $(RM) $(top_srcdir)/tags
+       CTAGSF=`ctags --version | grep -iq exuberant && \
+               echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
+       $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
+
+cscope-recursive:
+
+cscope:
+       $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
+       $(FIND_TAG_FILES_CMD) > cscope.files
+       cscope -bRq
+
+mkid:
+       $(FIND_TAG_FILES_CMD) | xargs mkid
+
+
+doxygen:  doxygen-api doxygen-ref
+
+doxygen-%: build/doxyfile.%
+          doxygen $<
+
+if MODULES
+sources: all-sources
+
+all-sources: $(MODULE_SYMVERS_DEPS)
+       for dir in $(SOURCES_SUBDIRS) ; do \
+               $(MAKE) sources -C $$dir || exit $$? ; \
+       done
+
+if LINUX
+all-am: modules
+
+modules: $(DEP) all-sources
+       $(MAKE) $(ARCH_UM) CC="$(CC)" -C $(LINUX_OBJ)                \
+       -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
+        LINUXINCLUDE='$(EXTRA_LNET_INCLUDE) -I$$(srctree)/arch/$$(SRCARCH)/include -I$$(srctree)/arch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC),-Iinclude2 -I$$(srctree)/include) -include $(CONFIG_INCLUDE)' \
+       $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
+       include/config/MARKER $@
+endif # LINUX
+
+endif # MODULES
+
+dist-hook:
+       find $(distdir) -name .deps -o \
+                       -name .git -o \
+                       -name .#* | xargs rm -rf
+       $(MAKE) $(AM_MAKEFLAGS) \
+         top_distdir="$(top_distdir)" distdir="$(distdir)" \
+         module-dist-hook
+
+EXTRA_DIST = @PACKAGE_TARNAME@.spec                                    \
+       build/Makefile build/autoMakefile.am.toplevel                   \
+       build/Rules.in                                                  \
+       build/autoconf/ldiskfs-build-linux.m4                           \
+       build/autoconf/ldiskfs-build.m4                                 \
+       build/autoconf/ldiskfs.m4
+
+rpms: @PACKAGE_TARNAME@.spec dist Makefile
+       CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | \
+               sed -re 's/--(en|dis)able-tests//'); \
+       if [ -n "@LINUX@" ]; then \
+               CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
+                       sed -re 's/--with-linux=[^ ][^ ]*//'); \
+               RPMARGS="--define \"kdir @LINUX@\""; \
+               CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
+                       sed -re 's/--with-linux-obj=[^ ][^ ]*//'); \
+               if [ -n "@LINUX_OBJ@" -a "@LINUX_OBJ@" != "@LINUX@" ]; then \
+                       RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
+               fi; \
+       fi; \
+       CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
+               sed -re 's/--with-release=[^ ][^ ]*//'); \
+       RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
+       echo "Building ldiskfs RPM with $$RPMARGS"; \
+       eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
+
+srpm: @PACKAGE_TARNAME@.spec dist Makefile
+       eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
diff --git a/ldiskfs/build/autoconf/.gitignore b/ldiskfs/build/autoconf/.gitignore
new file mode 100644 (file)
index 0000000..0e60bf1
--- /dev/null
@@ -0,0 +1,5 @@
+/config.guess
+/config.sub
+/install-sh
+/missing
+/Makefile.in
diff --git a/ldiskfs/build/autoconf/Makefile.am b/ldiskfs/build/autoconf/Makefile.am
new file mode 100644 (file)
index 0000000..b301472
--- /dev/null
@@ -0,0 +1 @@
+EXTRA_DIST  = ldiskfs.m4 ldiskfs-build.m4 ldiskfs-build-linux.m4
diff --git a/ldiskfs/build/autoconf/ldiskfs-build-linux.m4 b/ldiskfs/build/autoconf/ldiskfs-build-linux.m4
new file mode 100644 (file)
index 0000000..4a81b4b
--- /dev/null
@@ -0,0 +1,578 @@
+#
+# LB_LINUX_VERSION
+#
+# Set things accordingly for a linux kernel
+#
+AC_DEFUN([LB_LINUX_VERSION],[
+KMODEXT=".ko"
+
+MODULE_TARGET="SUBDIRS"
+makerule="$PWD/build"
+AC_MSG_CHECKING([for external module build support])
+rm -f build/conftest.i
+LB_LINUX_TRY_MAKE([],[],
+       [$makerule LUSTRE_KERNEL_TEST=conftest.i],
+       [test -s build/conftest.i],
+       [
+               AC_MSG_RESULT([no])
+       ],[
+               makerule="_module_$makerule"
+               MODULE_TARGET="M"
+               LB_LINUX_TRY_MAKE([],[],
+                       [$makerule LUSTRE_KERNEL_TEST=conftest.i],
+                       [test -s build/conftest.i],
+                       [
+                               AC_MSG_RESULT([yes])
+                       ],[
+                               AC_MSG_ERROR([unknown; check config.log for details])
+                       ])
+       ])
+
+AC_SUBST(MODULE_TARGET)
+AC_SUBST(KMODEXT)
+])
+
+#
+# LB_LINUX_RELEASE
+#
+# get the release version of linux
+#
+AC_DEFUN([LB_LINUX_RELEASE],
+[LINUXRELEASE=
+rm -f build/conftest.i
+AC_MSG_CHECKING([for Linux release])
+if test -s $LINUX_OBJ/include/$AUTOCONF_HDIR/utsrelease.h ; then
+       LINUXRELEASEHEADER=$AUTOCONF_HDIR/utsrelease.h
+else
+       LINUXRELEASEHEADER=linux/version.h
+fi
+LB_LINUX_TRY_MAKE([
+       #include <$LINUXRELEASEHEADER>
+],[
+       char *LINUXRELEASE;
+       LINUXRELEASE=UTS_RELEASE;
+],[
+       $makerule LUSTRE_KERNEL_TEST=conftest.i
+],[
+       test -s build/conftest.i
+],[
+       # LINUXRELEASE="UTS_RELEASE"
+       eval $(grep "LINUXRELEASE=" build/conftest.i)
+],[
+       AC_MSG_RESULT([unknown])
+       AC_MSG_ERROR([Could not preprocess test program.  Consult config.log for details.])
+])
+rm -f build/conftest.i
+if test x$LINUXRELEASE = x ; then
+       AC_MSG_RESULT([unknown])
+       AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
+fi
+AC_MSG_RESULT([$LINUXRELEASE])
+AC_SUBST(LINUXRELEASE)
+
+moduledir='/lib/modules/'$LINUXRELEASE/updates/kernel
+AC_SUBST(moduledir)
+
+modulefsdir='$(moduledir)/fs/$(PACKAGE)'
+AC_SUBST(modulefsdir)
+
+modulenetdir='$(moduledir)/net/$(PACKAGE)'
+AC_SUBST(modulenetdir)
+
+# ------------ RELEASE --------------------------------
+AC_MSG_CHECKING([for ldiskfs release])
+AC_ARG_WITH([release],
+       AC_HELP_STRING([--with-release=string],
+                      [set the release string (default=$kvers_YYYYMMDDhhmm)]),
+       [RELEASE=$withval],
+       RELEASE=""
+       if test -n "$DOWNSTREAM_RELEASE"; then
+               RELEASE="${DOWNSTREAM_RELEASE}_"
+       fi
+       RELEASE="$RELEASE`echo ${LINUXRELEASE} | tr '-' '_'`_$BUILDID")
+AC_MSG_RESULT($RELEASE)
+AC_SUBST(RELEASE)
+
+# check is redhat/suse kernels
+AC_MSG_CHECKING([that RedHat kernel])
+LB_LINUX_TRY_COMPILE([
+               #include <linux/version.h>
+       ],[
+               #ifndef RHEL_RELEASE_CODE
+               #error "not redhat kernel"
+               #endif
+       ],[
+               RHEL_KERNEL="yes"
+               AC_MSG_RESULT([yes])
+       ],[
+               AC_MSG_RESULT([no])
+])
+
+LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
+
+])
+
+# LB_ARG_REPLACE_PATH(PACKAGE, PATH)
+AC_DEFUN([LB_ARG_REPLACE_PATH],[
+       new_configure_args=
+       eval "set x $ac_configure_args"
+       shift
+       for arg; do
+               case $arg in
+                       --with-[$1]=*)
+                               arg=--with-[$1]=[$2]
+                               ;;
+                       *\'*)
+                               arg=$(printf %s\n ["$arg"] | \
+                                     sed "s/'/'\\\\\\\\''/g")
+                               ;;
+               esac
+               dnl AS_VAR_APPEND([new_configure_args], [" '$arg'"])
+               new_configure_args="$new_configure_args \"$arg\""
+       done
+       ac_configure_args=$new_configure_args
+])
+
+# this is the work-horse of the next function
+AC_DEFUN([__LB_ARG_CANON_PATH], [
+       [$3]=$(readlink -f $with_$2)
+       LB_ARG_REPLACE_PATH([$1], $[$3])
+])
+
+# a front-end for the above function that transforms - and . in the
+# PACKAGE portion of --with-PACKAGE into _ suitable for variable names
+AC_DEFUN([LB_ARG_CANON_PATH], [
+       __LB_ARG_CANON_PATH([$1], m4_translit([$1], [-.], [__]), [$2])
+])
+
+#
+#
+# LB_LINUX_PATH
+#
+# Find paths for linux, handling kernel-source rpms
+#
+AC_DEFUN([LB_LINUX_PATH],
+[# prep some default values
+for DEFAULT_LINUX in /lib/modules/$(uname -r)/{source,build} /usr/src/linux; do
+       if readlink -q -e $DEFAULT_LINUX; then
+               break
+       fi
+done
+if test "$DEFAULT_LINUX" = "/lib/modules/$(uname -r)/source"; then
+       PATHS="/lib/modules/$(uname -r)/build"
+fi
+PATHS+=" $DEFAULT_LINUX"
+for DEFAULT_LINUX_OBJ in $PATHS; do
+       if readlink -q -e $DEFAULT_LINUX_OBJ; then
+               break
+       fi
+done
+AC_MSG_CHECKING([for Linux sources])
+AC_ARG_WITH([linux],
+       AC_HELP_STRING([--with-linux=path],
+                      [set path to Linux source (default=/lib/modules/$(uname -r)/{source,build},/usr/src/linux)]),
+       [LB_ARG_CANON_PATH([linux], [LINUX])
+       DEFAULT_LINUX_OBJ=$LINUX],
+       [LINUX=$DEFAULT_LINUX])
+AC_MSG_RESULT([$LINUX])
+AC_SUBST(LINUX)
+
+# -------- check for linux --------
+LB_CHECK_FILE([$LINUX],[],
+       [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
+
+# -------- linux objects (for 2.6) --
+AC_MSG_CHECKING([for Linux objects dir])
+AC_ARG_WITH([linux-obj],
+       AC_HELP_STRING([--with-linux-obj=path],
+                       [set path to Linux objects dir (default=/lib/modules/$(uname -r)/build,/usr/src/linux)]),
+       [LB_ARG_CANON_PATH([linux-obj], [LINUX_OBJ])],
+       [LINUX_OBJ=$DEFAULT_LINUX_OBJ])
+
+AC_MSG_RESULT([$LINUX_OBJ])
+AC_SUBST(LINUX_OBJ)
+
+# -------- check for .config --------
+AC_ARG_WITH([linux-config],
+       [AC_HELP_STRING([--with-linux-config=path],
+                       [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
+       [LB_ARG_CANON_PATH([linux-config], [LINUX_CONFIG])],
+       [LINUX_CONFIG=$LINUX_OBJ/.config])
+AC_SUBST(LINUX_CONFIG)
+
+LB_CHECK_FILE([/boot/kernel.h],
+       [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
+       [LB_CHECK_FILE([/var/adm/running-kernel.h],
+               [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
+
+AC_ARG_WITH([kernel-source-header],
+       AC_HELP_STRING([--with-kernel-source-header=path],
+                       [Use a different kernel version header.  Consult build/README.kernel-source for details.]),
+       [LB_ARG_CANON_PATH([kernel-source-header], [KERNEL_SOURCE_HEADER])])
+
+# ------------ .config exists ----------------
+LB_CHECK_FILE([$LINUX_CONFIG],[],
+       [AC_MSG_ERROR([Kernel config could not be found.  If you are building from a kernel-source rpm consult build/README.kernel-source])])
+
+# ----------- make dep run? ------------------
+# at 2.6.19 # $LINUX/include/linux/config.h is removed
+# and at more old has only one line
+# include <autoconf.h>
+LB_CHECK_FILE([$LINUX_OBJ/include/generated/autoconf.h],[AUTOCONF_HDIR=generated],
+        [LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[AUTOCONF_HDIR=linux],
+       [AC_MSG_ERROR([Run make config in $LINUX.])])])
+        AC_SUBST(AUTOCONF_HDIR)
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
+       [AC_MSG_ERROR([Run make config in $LINUX.])])
+
+# ----------- kconfig.h exists ---------------
+# kernel 3.1, $LINUX/include/linux/kconfig.h is added
+# see kernel commit 2a11c8ea20bf850b3a2c60db8c2e7497d28aba99
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/kconfig.h],
+              [CONFIG_INCLUDE=include/linux/kconfig.h],
+              [CONFIG_INCLUDE=include/$AUTOCONF_HDIR/autoconf.h])
+       AC_SUBST(CONFIG_INCLUDE)
+
+# ------------ rhconfig.h includes runtime-generated bits --
+# red hat kernel-source checks
+
+# we know this exists after the check above.  if the user
+# tarred up the tree and ran make dep etc. in it, then
+# version.h gets overwritten with a standard linux one.
+
+if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
+       # This is a clean kernel-source tree, we need to
+       # enable extensive workarounds to get this to build
+       # modules
+       LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
+               [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
+                       AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
+                       AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
+                       AC_MSG_WARN([Consult build/README.kernel-source for details.])
+               fi],
+               [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found.  Consult build/README.kernel-source for details.])])
+       EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
+fi
+
+# this is needed before we can build modules
+LB_LINUX_UML
+LB_LINUX_VERSION
+
+# --- check that we can build modules at all
+AC_MSG_CHECKING([that modules can be built at all])
+LB_LINUX_TRY_COMPILE([],[],[
+       AC_MSG_RESULT([yes])
+],[
+       AC_MSG_RESULT([no])
+       AC_MSG_WARN([Consult config.log for details.])
+       AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
+       AC_MSG_ERROR([Kernel modules cannot be built.])
+])
+
+LB_LINUX_RELEASE
+]) # end of LB_LINUX_PATH
+
+# LB_LINUX_SYMVERFILE
+# SLES 9 uses a different name for this file - unsure about vanilla kernels
+# around this version, but it matters for servers only.
+AC_DEFUN([LB_LINUX_SYMVERFILE],
+       [AC_MSG_CHECKING([name of module symbol version file])
+       if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost ; then
+               SYMVERFILE=Modules.symvers
+       else
+               SYMVERFILE=Module.symvers
+       fi
+       AC_MSG_RESULT($SYMVERFILE)
+       AC_SUBST(SYMVERFILE)
+])
+
+#
+#
+# LB_LINUX_MODPOST
+#
+# Find modpost and check it
+#
+AC_DEFUN([LB_LINUX_MODPOST],
+[
+# Find the modpost utility
+LB_CHECK_FILE([$LINUX_OBJ/scripts/mod/modpost],
+       [MODPOST=$LINUX_OBJ/scripts/mod/modpost],
+       [LB_CHECK_FILE([$LINUX_OBJ/scripts/modpost],
+               [MODPOST=$LINUX_OBJ/scripts/modpost],
+               AC_MSG_ERROR([modpost not found.])
+       )]
+)
+AC_SUBST(MODPOST)
+
+# Ensure it can run
+AC_MSG_CHECKING([if modpost can be run])
+if $MODPOST ; then
+       AC_MSG_RESULT([yes])
+else
+       AC_MSG_ERROR([modpost can not be run.])
+fi
+
+# Check if modpost supports (and therefore requires) -m
+AC_MSG_CHECKING([if modpost supports -m])
+if $MODPOST -m 2>/dev/null ; then
+       AC_MSG_RESULT([yes])
+       MODPOST_ARGS=-m
+else
+       AC_MSG_RESULT([no])
+       MODPOST_ARGS=""
+fi
+AC_SUBST(MODPOST_ARGS)
+])
+
+#
+# LB_LINUX_UML
+#
+# check for a uml kernel
+#
+AC_DEFUN([LB_LINUX_UML],
+[ARCH_UM=
+UML_CFLAGS=
+
+AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
+if test -e $LINUX/include/asm-um ; then
+       if test  X`ls -id $LINUX/include/asm/ 2>/dev/null | awk '{print [$]1}'` = X`ls -id $LINUX/include/asm-um 2>/dev/null | awk '{print [$]1}'` ; then
+               ARCH_UM='ARCH=um'
+               # see notes in Rules.in
+               UML_CFLAGS='-O0'
+               AC_MSG_RESULT(yes)
+       else
+               AC_MSG_RESULT([no])
+       fi
+else
+       AC_MSG_RESULT([no (asm-um missing)])
+fi
+AC_SUBST(ARCH_UM)
+AC_SUBST(UML_CFLAGS)
+])
+
+# these are like AC_TRY_COMPILE, but try to build modules against the
+# kernel, inside the build directory
+
+# LB_LANG_PROGRAM(C)([PROLOGUE], [BODY])
+# --------------------------------------
+m4_define([LB_LANG_PROGRAM],
+[
+#include <linux/kernel.h>
+$1
+int
+main (void)
+{
+dnl Do *not* indent the following line: there may be CPP directives.
+dnl Don't move the `;' right after for the same reason.
+$2
+  ;
+  return 0;
+}])
+
+#
+# LB_LINUX_COMPILE_IFELSE
+#
+# like AC_COMPILE_IFELSE
+#
+AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
+[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/arch/`echo $target_cpu|sed -e 's/powerpc64/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include -I$LINUX/arch/`echo $target_cpu|sed -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include/generated -I$LINUX_OBJ/include -I$LINUX/include -I$LINUX_OBJ/include2 -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
+       [$4],
+       [_AC_MSG_LOG_CONFTEST
+m4_ifvaln([$5],[$5])dnl])
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl
+])
+
+#
+# LB_LINUX_ARCH
+#
+# Determine the kernel's idea of the current architecture
+#
+AC_DEFUN([LB_LINUX_ARCH],
+         [AC_MSG_CHECKING([Linux kernel architecture])
+          AS_IF([rm -f $PWD/build/arch
+                 make -s --no-print-directory echoarch -f $PWD/build/Makefile \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
+                     ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
+                [AC_MSG_RESULT([$LINUX_ARCH])],
+                [AC_MSG_ERROR([Could not determine the kernel architecture.])])
+          rm -f build/arch])
+
+#
+# LB_LINUX_TRY_COMPILE
+#
+# like AC_TRY_COMPILE
+#
+AC_DEFUN([LB_LINUX_TRY_COMPILE],
+[LB_LINUX_COMPILE_IFELSE(
+       [AC_LANG_SOURCE([LB_LANG_PROGRAM([[$1]], [[$2]])])],
+       [modules],
+       [test -s build/conftest.o],
+       [$3], [$4])])
+
+#
+# LB_LINUX_CONFIG
+#
+# check if a given config option is defined
+#
+AC_DEFUN([LB_LINUX_CONFIG],[
+       AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
+       LB_LINUX_TRY_COMPILE([
+               #include <$AUTOCONF_HDIR/autoconf.h>
+       ],[
+               #ifndef CONFIG_$1
+               #error CONFIG_$1 not #defined
+               #endif
+       ],[
+               AC_MSG_RESULT([yes])
+               $2
+       ],[
+               AC_MSG_RESULT([no])
+               $3
+       ])
+])
+
+#
+# LB_LINUX_CONFIG_IM
+#
+# check if a given config option is builtin or as module
+#
+AC_DEFUN([LB_LINUX_CONFIG_IM],[
+       AC_MSG_CHECKING([if Linux was built with CONFIG_$1 in or as module])
+       LB_LINUX_TRY_COMPILE([
+               #include <$AUTOCONF_HDIR/autoconf.h>
+       ],[
+               #if !(defined(CONFIG_$1) || defined(CONFIG_$1_MODULE))
+               #error CONFIG_$1 and CONFIG_$1_MODULE not #defined
+               #endif
+       ],[
+               AC_MSG_RESULT([yes])
+               $2
+       ],[
+               AC_MSG_RESULT([no])
+               $3
+       ])
+])
+
+#
+# LB_LINUX_TRY_MAKE
+#
+# like LB_LINUX_TRY_COMPILE, but with different arguments
+#
+AC_DEFUN([LB_LINUX_TRY_MAKE],
+       [LB_LINUX_COMPILE_IFELSE(
+               [AC_LANG_SOURCE(
+                       [LB_LANG_PROGRAM([[$1]], [[$2]])]
+               )],
+               [$3], [$4], [$5], [$6]
+       )]
+)
+
+# LC_MODULE_LOADING
+# after 2.6.28 CONFIG_KMOD is removed, and only CONFIG_MODULES remains
+# so we test if request_module is implemented or not
+AC_DEFUN([LC_MODULE_LOADING],
+[AC_MSG_CHECKING([if kernel module loading is possible])
+LB_LINUX_TRY_MAKE([
+       #include <linux/kmod.h>
+],[
+       int myretval=ENOSYS ;
+       return myretval;
+],[
+       $makerule LUSTRE_KERNEL_TEST=conftest.i
+],[dnl
+       grep request_module build/conftest.i |dnl
+               grep -v `grep "int myretval=" build/conftest.i |dnl
+                       cut -d= -f2 | cut -d" "  -f1`dnl
+               >/dev/null dnl
+],[
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_MODULE_LOADING_SUPPORT, 1,
+                 [kernel module loading is possible])
+],[
+       AC_MSG_RESULT(no)
+       AC_MSG_WARN([])
+       AC_MSG_WARN([Kernel module loading support is highly recommended.])
+       AC_MSG_WARN([])
+])
+])
+
+#
+# LB_PROG_LINUX
+#
+# linux tests
+#
+AC_DEFUN([LB_PROG_LINUX],
+[LB_LINUX_PATH
+LB_LINUX_ARCH
+LB_LINUX_SYMVERFILE
+
+
+LB_LINUX_CONFIG([MODULES],[],[
+       AC_MSG_ERROR([module support is required to build ldiskfs kernel module.])
+])
+
+LB_LINUX_CONFIG([MODVERSIONS])
+
+LB_LINUX_CONFIG([KALLSYMS],[],[
+if test "x$ARCH_UM" = "x" ; then
+       AC_MSG_ERROR([ldiskfs requires that CONFIG_KALLSYMS is enabled in your kernel.])
+fi
+])
+
+# 2.6.28
+LC_MODULE_LOADING
+])
+
+#
+# LB_CHECK_SYMBOL_EXPORT
+# check symbol exported or not
+# $1 - symbol
+# $2 - file(s) for find.
+# $3 - do 'yes'
+# $4 - do 'no'
+#
+# 2.6 based kernels - put modversion info into $LINUX/Module.modvers
+# or check
+AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
+[AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
+grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+       export=0
+       for file in $2; do
+               grep -q -E "EXPORT_SYMBOL.*\($1\)" "$LINUX/$file" 2>/dev/null
+               rc=$?
+               if test $rc -eq 0; then
+                       export=1
+                       break;
+               fi
+       done
+       if test $export -eq 0; then
+               AC_MSG_RESULT([no])
+               $4
+       else
+               AC_MSG_RESULT([yes])
+               $3
+       fi
+else
+       AC_MSG_RESULT([yes])
+       $3
+fi
+])
+
+#
+# Like AC_CHECK_HEADER but checks for a kernel-space header
+#
+m4_define([LB_CHECK_LINUX_HEADER],
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AC_CACHE_CHECK([for $1], ac_Header,
+              [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
+                                 [modules],
+                                 [test -s build/conftest.o],
+                                 [AS_VAR_SET(ac_Header, [yes])],
+                                 [AS_VAR_SET(ac_Header, [no])])])
+AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([ac_Header])dnl
+])
diff --git a/ldiskfs/build/autoconf/ldiskfs-build.m4 b/ldiskfs/build/autoconf/ldiskfs-build.m4
new file mode 100644 (file)
index 0000000..cc55395
--- /dev/null
@@ -0,0 +1,164 @@
+#
+# 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
+
+       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
+#
+AC_DEFUN([LB_CHECK_FILE],
+[AS_VAR_PUSHDEF([lb_File], [lb_cv_file_$1])dnl
+AC_CACHE_CHECK([for $1], lb_File,
+[if test -r "$1"; then
+       AS_VAR_SET(lb_File, yes)
+else
+       AS_VAR_SET(lb_File, no)
+fi])
+AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([lb_File])dnl
+])# LB_CHECK_FILE
+
+#
+# LB_CONFIG_HEADERS
+#
+# add -include config.h
+#
+AC_DEFUN([LB_CONFIG_HEADERS],[
+       AC_CONFIG_HEADERS([config.h])
+       CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
+       EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
+       AC_SUBST(EXTRA_KCFLAGS)
+])
+
+#
+# LB_INCLUDE_RULES
+#
+# defines for including the toplevel Rules
+#
+AC_DEFUN([LB_INCLUDE_RULES],[
+       INCLUDE_RULES="include $PWD/Rules"
+       AC_SUBST(INCLUDE_RULES)
+])
+
+#
+# LB_PROG_CC
+#
+# checks on the C compiler
+#
+AC_DEFUN([LB_PROG_CC],
+[AC_PROG_RANLIB
+
+# ---------  unsigned long long sane? -------
+AC_CHECK_SIZEOF(unsigned long long, 0)
+echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
+echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
+if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
+       AC_MSG_ERROR([** we assume that sizeof(long long) == 8.])
+fi
+
+if test $target_cpu == "powerpc64"; then
+       AC_MSG_WARN([set compiler with -m64])
+       CFLAGS="$CFLAGS -m64"
+       CC="$CC -m64"
+fi
+
+LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
+AC_SUBST(LLCPPFLAGS)
+
+# Add _GNU_SOURCE for strnlen on linux
+LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
+AC_SUBST(LLCFLAGS)
+
+CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
+AC_SUBST(CCASFLAGS)
+])
+
+#
+# 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]
+       )
+])
diff --git a/ldiskfs/build/autoconf/ldiskfs.m4 b/ldiskfs/build/autoconf/ldiskfs.m4
new file mode 100644 (file)
index 0000000..e1f7d24
--- /dev/null
@@ -0,0 +1,224 @@
+
+#
+# LB_LDISKFS_EXT_DIR
+#
+# Determine the location of the ext4 source code.  It is required
+# for several configure tests and to build ldiskfs.
+#
+AC_DEFUN([LB_LDISKFS_EXT_DIR],
+[
+# Kernel ext source located with devel headers
+linux_src=$LINUX
+if test -e "$linux_src/fs/ext4/super.c"; then
+       EXT_DIR=$linux_src/fs/ext4
+else
+       # Kernel ext source provided by kernel-debuginfo-common package
+       linux_src=$(ls -1d /usr/src/debug/*/linux-$LINUXRELEASE \
+               2>/dev/null | tail -1)
+       if test -e "$linux_src/fs/ext4/super.c"; then
+               EXT_DIR=$linux_src/fs/ext4
+       else
+               EXT_DIR=
+       fi
+fi
+
+AC_MSG_CHECKING([ext4 source directory])
+AC_MSG_RESULT([$EXT_DIR])
+AC_SUBST(EXT_DIR)
+])
+
+#
+# LB_LDISKFS_EXT_SOURCE
+#
+# Spot check the existance of several source files common to ext4.
+# Detecting this at configure time allows us to avoid a potential build
+# failure and provide a useful error message to explain what is wrong.
+#
+AC_DEFUN([LB_LDISKFS_EXT_SOURCE],
+[
+if test x$EXT_DIR = x; then
+       enable_ldiskfs_build='no'
+else
+       LB_CHECK_FILE([$EXT_DIR/dir.c], [], [
+               enable_ldiskfs_build='no'
+               AC_MSG_WARN([ext4 must exist for ldiskfs build])])
+       LB_CHECK_FILE([$EXT_DIR/file.c], [], [
+               enable_ldiskfs_build='no'
+               AC_MSG_WARN([ext4 must exist for ldiskfs build])])
+       LB_CHECK_FILE([$EXT_DIR/inode.c], [], [
+               enable_ldiskfs_build='no'
+               AC_MSG_WARN([ext4 must exist for ldiskfs build])])
+       LB_CHECK_FILE([$EXT_DIR/super.c], [], [
+               enable_ldiskfs_build='no'
+               AC_MSG_WARN([ext4 must exist for ldiskfs build])])
+fi
+
+if test x$enable_ldiskfs_build = xno; then
+       enable_server='no'
+       enable_ldiskfs_build='no'
+       with_ldiskfs='no'
+       LDISKFS_SUBDIR=
+
+       AC_MSG_WARN([
+
+Disabling server because complete ext4 source does not exist.
+
+If you are building using kernel-devel packages and require ldiskfs
+server support then ensure that the matching kernel-debuginfo-common
+and kernel-debuginfo-common-<arch> packages are installed.
+
+])
+
+fi
+])
+
+#
+# LB_LDISKFS_DEFINE_OPTIONS
+#
+# Enable config options related to ldiskfs.  These are used by ldiskfs,
+# lvfs, and the osd-ldiskfs code (which includes ldiskfs headers.)
+#
+AC_DEFUN([LB_LDISKFS_DEFINE_OPTIONS],
+[
+AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
+
+with_ldiskfs_pdo=no
+case $LINUXRELEASE in
+2.6.32*)
+       if test x$RHEL_KERNEL = xyes; then
+               with_ldiskfs_pdo=yes
+               AC_DEFINE(HAVE_LDISKFS_PDO, 1, [have ldiskfs PDO patch])
+       fi
+       if test x$SUSE_KERNEL = xyes; then
+               with_ldiskfs_pdo=yes
+               AC_DEFINE(HAVE_LDISKFS_PDO, 1, [have ldiskfs PDO patch])
+       fi
+       ;;
+esac
+LB_LDISKFS_JBD2_JOURNAL_CALLBACK_SET
+
+AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1,
+       [enable extended attributes for ldiskfs])
+AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1,
+       [enable posix acls for ldiskfs])
+AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1,
+       [enable fs security for ldiskfs])
+AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1,
+       [enable posix acls for ldiskfs])
+AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1,
+       [enable extented attributes for ldiskfs])
+AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1,
+       [enable fs security for ldiskfs])
+])
+
+#
+# Check for jbd2_journal_callback_set(), which is needed for commit
+# callbacks.  When LU-433 lands jbd2_journal_callback_set() will only
+# remain for legacy reasons and AC_MSG_ERROR can be removed.
+#
+AC_DEFUN([LB_LDISKFS_JBD2_JOURNAL_CALLBACK_SET],
+[
+       LB_CHECK_SYMBOL_EXPORT([jbd2_journal_callback_set],
+               [fs/jbd2/journal.c],
+               [AC_DEFINE(HAVE_JBD2_JOURNAL_CALLBACK_SET, 1,
+                       [kernel exports jbd2_journal_callback_set])])
+])
+
+
+AC_DEFUN([LB_LDISKFS_SYMVERS],
+[
+AC_MSG_CHECKING([ldiskfs module symbols])
+if test -r $LDISKFS_OBJ/Module.symvers; then
+       LDISKFS_SYMBOLS=Module.symvers
+elif test -r $LDISKFS_OBJ/Modules.symvers; then
+       LDISKFS_SYMBOLS=Modules.symvers
+elif test -r $LDISKFS_OBJ/ldiskfs/Module.symvers; then
+       LDISKFS_SYMBOLS=Module.symvers
+elif test -r $LDISKFS_OBJ/ldiskfs/Modules.symvers; then
+       LDISKFS_SYMBOLS=Modules.symvers
+else
+       LDISKFS_SYMBOLS=$SYMVERFILE
+fi
+
+AC_MSG_RESULT([$LDISKFS_SYMBOLS])
+AC_SUBST(LDISKFS_SYMBOLS)
+])
+
+AC_DEFUN([LB_LDISKFS_RELEASE],
+[
+AC_MSG_CHECKING([ldiskfs source release])
+if test -r $LDISKFS_OBJ/config.h; then
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-I$LDISKFS_DIR $EXTRA_KCFLAGS"
+       LB_LINUX_TRY_MAKE([
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE
+               #undef VERSION
+               #undef STDC_HEADERS
+
+               #include <$LDISKFS_OBJ/config.h>
+       ],[
+               char *LDISKFS_RELEASE;
+               LDISKFS_RELEASE=VERSION;
+       ],[
+               $makerule LUSTRE_KERNEL_TEST=conftest.i
+       ],[
+               test -s build/conftest.i
+       ],[
+               eval $(grep "LDISKFS_RELEASE=" build/conftest.i)
+       ],[
+               AC_MSG_RESULT([unknown])
+               AC_MSG_ERROR([Could not preprocess test program.])
+       ])
+       EXTRA_KCFLAGS="$tmp_flags"
+       rm build/conftest.i
+elif test -r $LDISKFS_DIR/configure.ac; then
+       LDISKFS_RELEASE=$(awk '/AC\_INIT/ { print [$]3 }' \
+                $LDISKFS_DIR/configure.ac | tr ',' '\n')
+else
+       AC_MSG_RESULT([unknown])
+       AC_MSG_ERROR([Could not locate config.h, META, or configure.ac to check release.])
+fi
+
+if test x$LDISKFS_RELEASE = x; then
+       AC_MSG_RESULT([unknown])
+       AC_MSG_ERROR([Could not determine ldiskfs release.])
+fi
+
+AC_MSG_RESULT([$LDISKFS_RELEASE])
+AC_SUBST(LDISKFS_RELEASE)
+])
+
+AC_DEFUN([LB_LDISKFS_SERIES],
+[
+if $1; then
+       AC_MSG_CHECKING([which ldiskfs series to use])
+       case $LINUXRELEASE in
+       2.6.18*)
+               if test x$RHEL_KERNEL = xyes; then
+                       LDISKFS_SERIES="2.6-rhel5-ext4.series"
+               fi
+               ;;
+       2.6.32*)
+               if test x$RHEL_KERNEL = xyes; then
+                       LDISKFS_SERIES="2.6-rhel6.series"
+               fi
+               if test x$SUSE_KERNEL = xyes; then
+                       LDISKFS_SERIES="2.6-sles11.series"
+               fi
+               ;;
+       *)
+               AC_MSG_WARN([Unknown kernel version $LINUXRELEASE])
+               LDISKFS_SERIES=
+               ;;
+       esac
+       AC_MSG_RESULT([$LDISKFS_SERIES])
+else
+       LDISKFS_SERIES=
+fi
+AC_SUBST(LDISKFS_SERIES)
+])
diff --git a/ldiskfs/build/quiltrc b/ldiskfs/build/quiltrc
new file mode 100644 (file)
index 0000000..60ec0d9
--- /dev/null
@@ -0,0 +1,2 @@
+export QUILT_DIFF_OPTS="-upa"
+export QUILT_NO_DIFF_TIMESTAMPS=1
index 5f3a1ec..ec43958 100644 (file)
@@ -4,7 +4,9 @@ AC_INIT([Lustre ldiskfs], 3.3.0, [http://bugs.whamcloud.com/])
 AC_CONFIG_SRCDIR([lustre-ldiskfs.spec.in])
 
 # Don't look for install-sh, etc. in ..
-AC_CONFIG_AUX_DIR([.])
+AC_CONFIG_AUX_DIR([build/autoconf])
+
+AC_CONFIG_MACRO_DIR([build/autoconf])
 
 AC_CANONICAL_SYSTEM
 
@@ -12,8 +14,6 @@ AM_INIT_AUTOMAKE([1.9 tar-ustar])
 
 AC_PROG_CC
 
-LB_CANONICAL_SYSTEM
-
 LB_DOWNSTREAM_RELEASE
 
 LB_BUILDID