Index: Makefile.config
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/Makefile.config,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile.config
--- Makefile.config	3 Jul 2007 05:30:45 -0000	1.58
+++ Makefile.config	11 Jul 2007 15:53:04 -0000
@@ -27,70 +27,70 @@ configs: $(CONFIGFILES)
 clean ::
 	@rm -fv $(CONFIGFILES) $(TEMPFILES) temp-generic kernel-$(VERSION)*config
 
-temp-generic: configs/config-generic Makefile Makefile.config
-	cat configs/config-generic configs/config-nodebug > temp-generic
+temp-generic: config-generic
+	cat config-generic config-nodebug > temp-generic
 
-temp-debug-generic: configs/config-generic Makefile Makefile.config
-	cat configs/config-generic configs/config-debug > temp-debug-generic
+temp-debug-generic: config-generic
+	cat config-generic config-debug > temp-debug-generic
 
-temp-x86-generic: configs/config-x86-generic temp-generic
+temp-x86-generic: config-x86-generic temp-generic
 	perl merge.pl $^  > $@
 
-temp-x86-debug-generic: configs/config-x86-generic temp-debug-generic
+temp-x86-debug-generic: config-x86-generic temp-debug-generic
 	perl merge.pl $^  > $@
 
-temp-x86_64-generic: configs/config-x86_64-generic temp-generic
+temp-x86_64-generic: config-x86_64-generic temp-generic
 	perl merge.pl $^  > $@
 
-temp-x86_64-debug-generic: configs/config-x86_64-generic temp-debug-generic
+temp-x86_64-debug-generic: config-x86_64-generic temp-debug-generic
 	perl merge.pl $^  > $@
 
-temp-sparc-generic: configs/config-sparc-generic temp-generic
+temp-sparc-generic: config-sparc-generic temp-generic
 	perl merge.pl $^  > $@
 
-temp-sparc64-generic: configs/config-sparc64-generic temp-generic
+temp-sparc64-generic: config-sparc64-generic temp-generic
 	perl merge.pl $^  > $@
 
-temp-powerpc-generic: configs/config-powerpc-generic temp-generic
+temp-powerpc-generic: config-powerpc-generic temp-generic
 	perl merge.pl $^  > $@
 
-temp-powerpc32-generic: configs/config-powerpc32-generic temp-powerpc-generic
+temp-powerpc32-generic: config-powerpc32-generic temp-powerpc-generic
 	perl merge.pl $^  > $@
 
-temp-s390-generic: configs/config-s390x temp-generic
+temp-s390-generic: config-s390x temp-generic
 	perl merge.pl $^ > $@
 
-temp-ia64-generic: configs/config-ia64-generic temp-generic
+temp-ia64-generic: config-ia64-generic temp-generic
 	perl merge.pl $^ > $@
 
-temp-x86-xen-generic-tmp: configs/config-xen-generic temp-x86-generic
+temp-x86-xen-generic-tmp: config-xen-generic temp-x86-generic
 	perl merge.pl $^ > $@
 
-temp-x86-xen-generic: configs/config-xen-x86 temp-x86-xen-generic-tmp
+temp-x86-xen-generic: config-xen-x86 temp-x86-xen-generic-tmp
 	perl merge.pl $^ > $@
 
-temp-x86_64-xen-generic-tmp: configs/config-xen-generic temp-x86_64-generic
+temp-x86_64-xen-generic-tmp: config-xen-generic temp-x86_64-generic
 	perl merge.pl $^ > $@
 
-temp-x86_64-xen-generic: configs/config-xen-x86_64 temp-x86_64-xen-generic-tmp
+temp-x86_64-xen-generic: config-xen-x86_64 temp-x86_64-xen-generic-tmp
 	perl merge.pl $^ > $@
 
-temp-ia64-xen-generic: configs/config-xen-generic temp-ia64-generic
+temp-ia64-xen-generic: config-xen-generic temp-ia64-generic
 	perl merge.pl $^ > $@
 
-kernel-$(VERSION)-i686.config: configs/config-i686 temp-x86-generic
+kernel-$(VERSION)-i686.config: config-i686 temp-x86-generic
 	perl merge.pl $^ i386 > $@
 
-kernel-$(VERSION)-i686-debug.config: configs/config-i686 temp-x86-debug-generic
+kernel-$(VERSION)-i686-debug.config: config-i686 temp-x86-debug-generic
 	perl merge.pl $^ i386 > $@
 
-kernel-$(VERSION)-i686-PAE.config: configs/config-i686-PAE temp-x86-generic
+kernel-$(VERSION)-i686-PAE.config: config-i686-PAE temp-x86-generic
 	perl merge.pl $^ i386 > $@
 
-kernel-$(VERSION)-i686-PAE-debug.config: configs/config-i686-PAE temp-x86-debug-generic
+kernel-$(VERSION)-i686-PAE-debug.config: config-i686-PAE temp-x86-debug-generic
 	perl merge.pl $^ i386 > $@
 
-kernel-$(VERSION)-i586.config: configs/config-i586 temp-x86-generic
+kernel-$(VERSION)-i586.config: config-i586 temp-x86-generic
 	perl merge.pl $^ i386 > $@
 
 kernel-$(VERSION)-x86_64.config: /dev/null temp-x86_64-generic
@@ -99,41 +99,41 @@ kernel-$(VERSION)-x86_64.config: /dev/nu
 kernel-$(VERSION)-x86_64-debug.config: /dev/null temp-x86_64-debug-generic
 	perl merge.pl $^ x86_64 > $@
 
-kernel-$(VERSION)-sparc-smp.config: configs/config-sparc-smp temp-sparc-generic
+kernel-$(VERSION)-sparc-smp.config: config-sparc-smp temp-sparc-generic
 	perl merge.pl $^ sparc > $@
 
-kernel-$(VERSION)-sparc.config: configs/config-sparc temp-sparc-generic
+kernel-$(VERSION)-sparc.config: config-sparc temp-sparc-generic
 	perl merge.pl $^ sparc > $@
 
-kernel-$(VERSION)-sparc64-smp.config: configs/config-sparc64-smp temp-sparc64-generic
+kernel-$(VERSION)-sparc64-smp.config: config-sparc64-smp temp-sparc64-generic
 	perl merge.pl $^ sparc64 > $@
 
-kernel-$(VERSION)-sparc64.config: configs/config-sparc64 temp-sparc-generic
+kernel-$(VERSION)-sparc64.config: config-sparc64 temp-sparc-generic
 	perl merge.pl $^ sparc64 > $@
 
-kernel-$(VERSION)-ppc64.config: configs/config-powerpc64 temp-powerpc-generic
+kernel-$(VERSION)-ppc64.config: config-powerpc64 temp-powerpc-generic
 	perl merge.pl $^ powerpc > $@
 
-kernel-$(VERSION)-ppc64-kdump.config: configs/config-powerpc64-kdump kernel-$(VERSION)-ppc64.config
+kernel-$(VERSION)-ppc64-kdump.config: config-powerpc64-kdump kernel-$(VERSION)-ppc64.config
 	perl merge.pl $^ powerpc > $@
 
-kernel-$(VERSION)-s390x.config: configs/config-s390x temp-s390-generic
+kernel-$(VERSION)-s390x.config: config-s390x temp-s390-generic
 	perl merge.pl $^ s390 > $@
 
 kernel-$(VERSION)-ppc.config: /dev/null temp-powerpc32-generic
 	perl merge.pl $^ powerpc > $@
 
-kernel-$(VERSION)-ppc-smp.config: configs/config-powerpc32-smp temp-powerpc32-generic
+kernel-$(VERSION)-ppc-smp.config: config-powerpc32-smp temp-powerpc32-generic
 	perl merge.pl $^ powerpc > $@
 
-kernel-$(VERSION)-ia64.config: configs/config-ia64 temp-ia64-generic
+kernel-$(VERSION)-ia64.config: config-ia64 temp-ia64-generic
 	perl merge.pl $^ ia64 > $@
 
-kernel-$(VERSION)-i686-xen.config: configs/config-i686-PAE temp-x86-xen-generic
+kernel-$(VERSION)-i686-xen.config: config-i686-PAE temp-x86-xen-generic
 	perl merge.pl $^ i386 > $@
 
 kernel-$(VERSION)-x86_64-xen.config: /dev/null temp-x86_64-xen-generic
 	perl merge.pl $^ x86_64 > $@
 
-kernel-$(VERSION)-ia64-xen.config: configs/config-xen-ia64 temp-ia64-xen-generic
+kernel-$(VERSION)-ia64-xen.config: config-xen-ia64 temp-ia64-xen-generic
 	perl merge.pl $^ ia64 > $@
Index: kernel-2.6.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel-2.6.spec,v
retrieving revision 1.3296
diff -u -p -r1.3296 kernel-2.6.spec
--- kernel-2.6.spec	11 Jul 2007 15:36:42 -0000	1.3296
+++ kernel-2.6.spec	11 Jul 2007 15:53:05 -0000
@@ -243,7 +243,7 @@ Summary: The Linux kernel (the core of t
 %ifarch noarch
 %define with_up 0
 %define with_headers 0
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-*.config
+%define all_arch_configs kernel-%{version}-*.config
 %endif
 
 # don't sign modules on these platforms
@@ -259,7 +259,7 @@ Summary: The Linux kernel (the core of t
 # Per-arch tweaks
 
 %ifarch %{all_x86}
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-i?86*.config
+%define all_arch_configs kernel-%{version}-i?86*.config
 %define image_install_path boot
 %define hdrarch i386
 # we build always xen i686 HV with pae
@@ -267,12 +267,12 @@ Summary: The Linux kernel (the core of t
 %endif
 
 %ifarch x86_64
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-x86_64*.config
+%define all_arch_configs kernel-%{version}-x86_64*.config
 %define image_install_path boot
 %endif
 
 %ifarch ppc64
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-ppc64*.config
+%define all_arch_configs kernel-%{version}-ppc64*.config
 %define image_install_path boot
 %define make_target vmlinux
 %define kernel_image vmlinux
@@ -281,7 +281,7 @@ Summary: The Linux kernel (the core of t
 %endif
 
 %ifarch s390x
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-s390x.config
+%define all_arch_configs kernel-%{version}-s390x.config
 %define image_install_path boot
 %define make_target image
 %define kernel_image arch/s390/boot/image
@@ -289,19 +289,19 @@ Summary: The Linux kernel (the core of t
 %endif
 
 %ifarch sparc
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-sparc.config
+%define all_arch_configs kernel-%{version}-sparc.config
 %define make_target image
 %define kernel_image image
 %endif
 
 %ifarch sparc64
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-sparc64*.config
+%define all_arch_configs kernel-%{version}-sparc64*.config
 %define make_target image
 %define kernel_image image
 %endif
 
 %ifarch ppc
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-ppc{-,.}*config
+%define all_arch_configs kernel-%{version}-ppc{-,.}*config
 %define image_install_path boot
 %define make_target vmlinux
 %define kernel_image vmlinux
@@ -310,7 +310,7 @@ Summary: The Linux kernel (the core of t
 %endif
 
 %ifarch ia64
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-ia64*.config
+%define all_arch_configs kernel-%{version}-ia64*.config
 %define image_install_path boot/efi/EFI/redhat
 %define make_target compressed
 %define kernel_image vmlinux.gz
@@ -321,7 +321,7 @@ Summary: The Linux kernel (the core of t
 %endif
 
 %ifarch alpha alphaev56
-%define all_arch_configs $RPM_SOURCE_DIR/kernel-%{version}-alpha*.config
+%define all_arch_configs kernel-%{version}-alpha*.config
 %define image_install_path boot
 %define make_target vmlinux
 %define kernel_image vmlinux
@@ -435,38 +435,42 @@ Source11: genkey
 Source14: find-provides
 Source15: merge.pl
 
-Source20: kernel-%{version}-i586.config
-Source21: kernel-%{version}-i686.config
-Source22: kernel-%{version}-i686-debug.config
-Source23: kernel-%{version}-i686-PAE.config
-Source24: kernel-%{version}-i686-PAE-debug.config
-
-Source25: kernel-%{version}-x86_64.config
-Source26: kernel-%{version}-x86_64-debug.config
-
-Source28: kernel-%{version}-ppc.config
-Source29: kernel-%{version}-ppc-smp.config
-Source30: kernel-%{version}-ppc64.config
-Source31: kernel-%{version}-ppc64-kdump.config
-
-Source35: kernel-%{version}-s390x.config
-
-Source36: kernel-%{version}-ia64.config
-
-Source37: kernel-%{version}-i686-xen.config
-Source38: kernel-%{version}-x86_64-xen.config
-Source39: kernel-%{version}-ia64-xen.config
-
-#Source50: kernel-%{version}-sparc.config
-#Source51: kernel-%{version}-sparc64.config
-#Source52: kernel-%{version}-sparc64-smp.config
-
-#Source60: kernel-%{version}-alpha.config
-#Source61: kernel-%{version}-alphaev56.config
-#Source62: kernel-%{version}-alphaev56-smp.config
-
-Source80: config-rhel-generic
-Source81: config-rhel-x86-generic
+Source20: Makefile.config
+Source21: config-debug
+Source22: config-nodebug
+Source23: config-generic
+Source24: config-xen-generic
+Source25: config-rhel-generic
+Source26: config-rhel-x86-generic
+
+Source30: config-x86-generic
+Source31: config-i586
+Source32: config-i686
+Source33: config-i686-PAE
+Source34: config-xen-x86
+
+Source40: config-x86_64-generic
+Source41: config-xen-x86_64
+
+Source50: config-powerpc-generic
+Source51: config-powerpc32-generic
+Source52: config-powerpc32-smp
+Source53: config-powerpc64
+Source54: config-powerpc64-kdump
+
+Source60: config-ia64-generic
+Source61: config-ia64
+Source62: config-xen-ia64
+
+Source70: config-s390x
+
+Source80: config-sparc-generic
+Source81: config-sparc
+Source82: config-sparc-smp
+
+Source90: config-sparc64-generic
+Source91: config-sparc64
+Source92: config-sparc64-smp
 
 %if %{using_upstream_branch}
 ### BRANCH PATCH ###
@@ -916,23 +920,6 @@ against the kdump kernel package.
 
 
 %prep
-#if a rhel kernel, apply the rhel config options
-%if 0%{?rhel}
-  for i in %{all_arch_configs}
-  do
-    mv $i $i.tmp
-    $RPM_SOURCE_DIR/merge.pl $RPM_SOURCE_DIR/config-rhel-generic $i.tmp > $i
-    rm $i.tmp
-  done
-  for i in $RPM_SOURCE_DIR/kernel-%{version}-{i686,i686-PAE,x86_64}*.config
-  do
-    echo i is this file  $i
-    mv $i $i.tmp
-    $RPM_SOURCE_DIR/merge.pl $RPM_SOURCE_DIR/config-rhel-x86-generic $i.tmp > $i
-    rm $i.tmp
-  done
-%endif
-
 # do a few sanity-checks for --with *only builds
 %if %{with_baseonly}
 %if !%{with_up}
@@ -979,6 +966,30 @@ cp -rl vanilla linux-%{kversion}.%{_targ
 
 cd linux-%{kversion}.%{_target_cpu}
 
+# Drop some necessary files from the source dir into the buildroot
+cp $RPM_SOURCE_DIR/config-* .
+cp %{SOURCE15} .
+
+# Dynamically generate kernel .config files from config-* files
+make -f %{SOURCE20} VERSION=%{version} configs
+
+#if a rhel kernel, apply the rhel config options
+%if 0%{?rhel}
+  for i in %{all_arch_configs}
+  do
+    mv $i $i.tmp
+    ./merge.pl config-rhel-generic $i.tmp > $i
+    rm $i.tmp
+  done
+  for i in kernel-%{version}-{i686,i686-PAE,x86_64}*.config
+  do
+    echo i is this file  $i
+    mv $i $i.tmp
+    ./merge.pl config-rhel-x86-generic $i.tmp > $i
+    rm $i.tmp
+  done
+%endif
+
 patch_command='patch -p1 -F1 -s'
 ApplyPatch()
 {
@@ -1245,7 +1256,12 @@ cp %{SOURCE10} Documentation/
 
 mkdir configs
 
-cp -f %{all_arch_configs} .
+# Remove configs not for the buildarch
+for cfg in kernel-%{version}-*.config; do
+  if [ `echo %{all_arch_configs} | grep -c $cfg` -eq 0 ]; then
+    rm -f $cfg
+  fi
+done
 
 %if !%{with_debug}
 rm -f kernel-%{version}-*-debug.config
