From 0aca81616800c9dbd18927df99d90e7389fc3666 Mon Sep 17 00:00:00 2001
From: scjody <scjody>
Date: Fri, 24 Aug 2007 18:14:39 +0000
Subject: [PATCH] Branch b1_6

Modify mkmakefile usage and add buildsubdir workaround to fix RPM build on
RHEL 5.

b=13422
i=yangsheng
---
 build/lustre-kernel-2.4.spec.in | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/build/lustre-kernel-2.4.spec.in b/build/lustre-kernel-2.4.spec.in
index 208bc77202..d77a0b8310 100644
--- a/build/lustre-kernel-2.4.spec.in
+++ b/build/lustre-kernel-2.4.spec.in
@@ -364,6 +364,11 @@ is necessary if you want to access a Lustre filesystem.
 #The Lustre book, sample configurations, and other documentation for
 #Lustre.
 
+# This is required in rpm >= 4.4.? and _should_ be set by the %setup macro
+# but isn't, at least for 4.4.2.  Yay RPM.
+%define buildsubdir lustre-kernel-%{version}
+%define _buildsubdir lustre-kernel-%{version}
+
 %prep
 %setup -n lustre-kernel-%{version} -q -c
 if [ ! -d lustre ] ; then
@@ -648,16 +653,25 @@ BuildObj ()
 	$MAKE clean
 	rm -rf $o/.config.old $o/include/config
         # Replace the Makefile in the object directory with a version
-        # that has relative path names.
+        # that has relative path names.  This is done by fixing the Makefile
+        # after the fact to work with 2.6.17 and newer mkmakefile.
         read VERSION PATCHLEVEL SUBLEVEL <<-EOF
 $(set -- 2.6.5 ; echo ${*//./ })
 EOF
+	rm -f $o/Makefile
         source scripts/mkmakefile \
 	    ../../../linux-%{KVERREL} \
-            ../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor \
+            $o \
 	    $VERSION \
 	    $PATCHLEVEL \
-	    > $o/Makefile
+	    > $o/Makefile.in
+	if [ -f $o/Makefile ] ; then
+		# will exist only for 2.6.17 and newer because mkmakefile
+		# now writes the makefile to $o instead of stdout
+		mv -f $o/Makefile $o/Makefile.in
+	fi
+	sed -e "s^$o^../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor^" \
+		$o/Makefile.in > $o/Makefile
 	zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavtgt}.gz" \
 	    > $o/Module.symvers
 }
-- 
GitLab