Whamcloud - gitweb
b=18656
[fs/lustre-release.git] / build / lmake
index c742972..a018011 100755 (executable)
@@ -47,6 +47,7 @@ KERNEL_FILE=
 SERIES_FILE=
 CONFIG_FILE=
 RPMBUILD=
+XEN=false
 
 canon()
 {
@@ -160,6 +161,9 @@ Options:
   --unpack-kernel
     Untars and patches the kernel source.
 
+  --xen
+    Builds a Xen domX kernel.
+
   The order that commands (--build-lustre, --unpack-kernel) are
   specified on the command line is ignored; ${0##*/} will always
   execute them in the correct order (unpack, then build, then install
@@ -228,6 +232,11 @@ load_target()
 
     . "$TARGET_FILE"
 
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
     [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
 # Suse 2.6 has our patches in already
 #    [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
@@ -248,8 +257,13 @@ load_target()
        done
     fi
 
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
+    fi
+
     TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
-    CONFIG_TARGET="$TARGET-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
+    CONFIG_TARGET="${TARGET}${XENPOSTFIX}-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
     CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
     [ -r "$CONFIG_FILE" ] ||
        fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs."
@@ -344,9 +358,13 @@ patch_kernel()
 set_make()
 {
     MAKE="make -s"
-    if [ "$CC" ] ; then
-       MAKE_CC="CC=$CC"
-    fi
+    [ "$CC" ] && {
+        if [ "$TARGET_ARCH" == "ppc64" ] ; then
+                MAKE_CC="CC=$CC -m64"
+        else 
+                MAKE_CC="CC=$CC"
+        fi
+    }
     if [ "$ARCH" ] ; then
        MAKE_ARCH="$MAKE ARCH=$ARCH"
     else
@@ -437,28 +455,31 @@ depend_kernel()
             fi
             fatal 1 "update_oldconfig failed: $RC. See log above."
         fi
-        rm -f $logfile
-        # now notify if resulting .config is different than $CONFIG_FILE
-        local tmpfile=$(mktemp /tmp/XXXXXX)
-        diff -I '^#.*' -u "$CONFIG_FILE" .config >$tmpfile
-        if [ -s $tmpfile ]; then
-            { cat <<EOF
-To: qa@lists.clusterfs.com
+    fi
+    rm -f $logfile
+    # now notify if resulting .config is different than $CONFIG_FILE
+    local tmpfile=$(mktemp /tmp/XXXXXX)
+    diff -I '^#.*' -u "$CONFIG_FILE" .config >$tmpfile
+    if [ -s $tmpfile ]; then
+        { cat <<EOF
+To: lustre-qa-team@sun.com
 Subject: kernel_config change 
 
 The result of a make oldconfig on file $CONFIG_FILE resulted in a
 difference when compared to .config in the following way:
 
 EOF
-            cat $tmpfile
-            echo -e "\n\nPlease consider updating $CONFIG_FILE."
-           # not sure these are entirely useful.  the above and "patch" are good
-           #echo -e "\nThe entire new .config file:\n"
-            #cat .config
-            } | sendmail -fqa@clusterfs.com -t
-        fi
-        rm -f $tmpfile
+        cat $tmpfile
+        echo -e "\n\nPlease consider updating $CONFIG_FILE for version: $extra_version."
+        # not sure these are entirely useful.  the above and "patch" are good
+        #echo -e "\nThe entire new .config file:\n"
+        #cat .config
+        # sadly, the build roots can't e-mail out, so we can only display this
+        # to stderr for an interested party to inspect
+        #} | sendmail -flustre-qa-team@sun.com -t
+        } >&2
     fi
+    rm -f $tmpfile
 
     case "$VERSION" in
        2.6*)
@@ -477,22 +498,68 @@ build_kernel()
     (( $BUILD_KERNEL )) || return 0
     set_make
     echo "Building kernel in $PWD..."
+    if $XEN; then
+        $MAKE_J "$MAKE_CC" vmlinuz || fatal 1 "Error making vmlinux."
+    else
+        case "$TARGET_ARCH" in
+           i386 | i586 | i686 | athlon | x86_64)
+               $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
+               ;;
+            ia64 | ppc | ppc64)
+               $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
+               ;;
+           *)
+               $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
+               ;;
+        esac
+    fi
+    $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
+
+    popd >/dev/null
+}
+
+build_kernel_ib()
+{
+    (( $BUILD_KERNEL )) || return 0
+    # build kernel-ib{,-devel}
+    # some I/B drivers are architecture dependent and kernel-ib's configure
+    # does not figure it out for us ~sigh~
+    local configure_options=""
     case "$TARGET_ARCH" in
-       i386 | i586 | i686 | athlon | x86_64)
-           $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
+       x86_64 | ia64)
+           configure_options="--with-ipath_inf-mod"
            ;;
-    ia64 | ppc | ppc64)
-           $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
-           ;;
-       *)
-           $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
+       ppc64)
+           configure_options="--with-ipath_inf-mod --with-ehca-mod"
            ;;
     esac
-    $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
+    local K_SRC="K_SRC"
+    # ofed 1.3 had a bug in the rpm spec
+    if [ "$OFED_VERSION" = "1.3" ]; then
+        K_SRC="KSRC"
+    fi
+    $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
+             --define "_topdir $(lbuild_topdir)" --target ${TARGET_ARCH} \
+             --define "KVERSION ${FULL_VERSION}" \
+             --define "$K_SRC ${PWD}/linux" \
+             --define "LIB_MOD_DIR /lib/modules/${FULL_VERSION}" \
+             --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
+
+    if [ ${PIPESTATUS[0]} != 0 ]; then
+        fatal 1 "Error building kernel-ib"
+    fi
 
+    pushd "$TOPDIR" >/dev/null
+    rm -rf kernel-ib-devel
+    mkdir kernel-ib-devel
+    cd kernel-ib-devel
+    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${FULL_VERSION//-/_}.*.rpm)
+    rpm2cpio -itv < $rpm | cpio -id
+    CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
     popd >/dev/null
 }
 
+
 configure_lustre()
 {
     return 0
@@ -543,37 +610,42 @@ install_kernel()
        -s modules_install || \
        fatal 1 "Error installing modules."
 
-    case "$TARGET_ARCH" in
-       i386 | i586 | i686 | athlon)
-           cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-           ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ;;
-       x86_64)
-           cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-           ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ;;
-        ppc | ppc64)
-           cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
-           ;;
-       ia64)
-           gzip -cfv vmlinux > vmlinuz
-           mkdir -p "$DESTDIR/boot/efi/redhat"
-           install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-           install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
-           ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
-           ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           ;;
-       *)
-           cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
-           ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-
-           ;;
-    esac
+    if $XEN; then
+       cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+       cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+       ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+    else
+        case "$TARGET_ARCH" in
+           i386 | i586 | i686 | athlon)
+               cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+               ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ;;
+           x86_64)
+               cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+               ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ;;
+            ppc | ppc64)
+               cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
+               ;;
+           ia64)
+               gzip -cfv vmlinux > vmlinuz
+               mkdir -p "$DESTDIR/boot/efi/redhat"
+               install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+               install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
+               ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
+               ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               ;;
+           *)
+               cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+               ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ;;
+       esac
+    fi
     if [ -e init/kerntypes.o ] ; then
        cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}"
     fi
@@ -715,7 +787,7 @@ save_all_headers()
 
 longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
 longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
-longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel"
+longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel,xen"
 
 options=$(getopt -o hj: -l "$longopts" -- "$@")
 
@@ -798,6 +870,10 @@ while [ "$1" ] ; do
            UNPACK_KERNEL=1
            shift
            ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
        --)
            shift
            CONFIGURE_FLAGS=$@
@@ -824,6 +900,14 @@ patch_kernel
 depend_kernel
 build_kernel
 
+if [ -n "$OFED_VERSION" ]; then
+    if [ "$OFED_VERSION" = "inkernel" ]; then
+       CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
+    else
+    build_kernel_ib
+    fi
+fi
+
 configure_lustre
 build_lustre