Whamcloud - gitweb
b=17258 fix error with make rpms after configure --disable-tests
[fs/lustre-release.git] / build / lustre-kernel-2.4.spec.in
diff --git a/build/lustre-kernel-2.4.spec.in b/build/lustre-kernel-2.4.spec.in
new file mode 100644 (file)
index 0000000..a96b074
--- /dev/null
@@ -0,0 +1,980 @@
+Summary: The Linux kernel (the core of the Linux operating system)
+
+# Versions of various parts
+
+#
+# Polite request for people who spin their own kernel rpms:
+# please modify the "release" field in a way that identifies
+# that the kernel isn't the stock RHL kernel, for example by
+# adding some text to the end of the version number.
+#
+%define kversion @KERNEL_VERSION@
+%define kextraver @KERNEL_EXTRA_VERSION@
+%define kextraverdelim @KERNEL_EXTRA_VERSION_DELIMITER@
+%define flavordelim "@KERNEL_TARGET_DELIMITER@"
+%define release @KERNEL_RELEASE@
+# /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
+%define kslnk linux-2.4
+%define kprovides %(bash -c "echo %{kversion}%{kextraverdelim}%{kextraver} | sed -e 's/-[^0-9]*smp$//'")
+
+# groups of related archs
+%define all_x86 i386 i686 i586 athlon
+#define all_x86 i686 i386 i586 athlon
+
+%define nptlarchs %{all_x86}
+#define nptlarchs noarch
+%define rhbuild @RHBUILD@
+%define susebuild @SUSEBUILD@
+%define linux26 @LINUX26@
+%define lmakeopts @LMAKEOPTS@
+
+# disable build root strip policy
+%define __spec_install_post /usr/lib/rpm/brp-compress || :
+#
+# RPM foo magic
+%define _missing_doc_files_terminate_build 0
+%define _unpackaged_files_terminate_build 0
+%define debug_package %{nil}
+
+# Enable this to build a board-specific kernel configuration 
+# some architectures have LOTS of different setups and this 
+# is a way to deal with that cleanly.
+#
+#define targetboard assabet
+%define dashtargetboard %{?targetboard:-%{targetboard}}
+%define withtargetboard 0
+%{?targetboard: %{expand: %%define withtargetboard 1}}
+
+# Override generic defaults with per-arch defaults (which can
+# themselves be overridden with --with/--without).  These must
+# ONLY be "0", never "1"
+
+%define buildbase 0
+%define buildbigmem 0
+%define buildBOOT 0
+%define buildjensen 0
+%define buildsmp 0
+%define buildbigsmp 0
+%define buildpseries64 0
+%define buildup 0
+%define buildsrc 0
+
+%ifarch @BASE_ARCHS@
+%define buildbase 1
+%endif
+
+%ifarch @BIGMEM_ARCHS@
+%define buildbigmem 1
+%endif
+
+%ifarch @BOOT_ARCHS@
+%define buildBOOT 1
+%endif
+
+%ifarch @JENSEN_ARCHS@
+%define buildjensen 1
+%endif
+
+%ifarch @SMP_ARCHS@
+%define buildsmp 1
+%endif
+
+%ifarch @BIGSMP_ARCHS@
+%define buildbigsmp 1
+%endif
+
+%ifarch @PSERIES64_ARCHS@
+%define buildpseries64 1
+%endif
+
+%ifarch @UP_ARCHS@
+%define buildup 1
+%endif
+
+# For board-specific kernels, build only the normal kernel (which may actually be smp, not up).
+%if %{withtargetboard}
+%define buildsmp 0
+%define buildbigsmp 0
+%define buildBOOT 0
+%define buildbigmem 0
+%define buildpseries64 0
+%define buildjensen 0
+%endif
+
+%if 0
+Second, per-architecture exclusions (ifarch)
+%ifarch i386
+%define buildsmp 0
+%endif
+%ifarch ia64
+%define buildBOOT 0
+%endif
+%endif
+
+# we can't test values inline, only whether a macro exists
+%{expand: %%define buildup_%{buildup} yadda}
+%{expand: %%define buildsmp_%{buildsmp} yadda}
+%{expand: %%define buildbigsmp_%{buildbigsmp} yadda}
+%{expand: %%define buildpseries64_%{buildpseries64} yadda}
+%{expand: %%define buildBOOT_%{buildBOOT} yadda}
+%{expand: %%define buildbigmem_%{buildbigmem} yadda}
+%{expand: %%define buildjensen_%{buildjensen} yadda}
+%{expand: %%define ikd_%{ikd} yadda}
+%{expand: %%define ibcs_%{ibcs} yadda}
+%{expand: %%define debuglevel_%{debugging} yadda}
+
+%{expand: %%define kernel_conflicts  ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 0.3.1, cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, e2fsprogs < 1.22, initscripts < 5.84, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0, oprofile < 0.4}
+
+%if %{rhbuild}
+%define BOOT_kernel_prereq fileutils, modutils >=  2.4.18
+%define kernel_prereq %{BOOT_kernel_prereq}, initscripts >= 5.83, mkinitrd >= 3.2.6
+%endif
+
+%ifarch ia64
+%define initrd_dir /boot/efi/redhat
+%else
+%define initrd_dir /boot
+%endif
+
+%ifarch %{all_x86} x86_64
+%define kernel_glob vmlinu?-%{KVERREL}
+%endif
+%ifarch ia64
+# <sigh>, no GLOB_BRACE for filelists, efi needs to be done separately
+%define kernel_glob vmlinuz-%{KVERREL}
+%endif
+%ifarch alpha
+%define kernel_glob vmlinu?-%{KVERREL}
+%endif
+%ifarch ppc ppc64
+%define kernel_glob vmlinu?-%{KVERREL}
+%endif
+
+Name: kernel-lustre
+Version: %{kversion}
+Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
+%define KVERREL %{PACKAGE_VERSION}%{kextraverdelim}%{kextraver}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
+License: GPL
+Group: System Environment/Kernel
+ExclusiveArch: %{all_x86} x86_64 ia64 ppc ppc64
+ExclusiveOS: Linux
+Obsoletes: kernel-modules, kernel-sparc
+Provides: kernel = %{kprovides}
+BuildConflicts: rhbuildsys(DiscFree) < 500Mb
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+Autoreqprov: no
+%if %{rhbuild}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+
+BuildPreReq: patch >= 2.5.4, bash >= 2.03, sh-utils, gnupg, tar
+BuildPreReq: bzip2, findutils, dev, gzip, m4
+%endif
+
+Vendor: Sun Microsystems, Inc.
+URL: http://www.kernel.org/
+Buildroot: %{_tmppath}/%{name}-%{version}-root
+
+Source0: @LUSTRE_SOURCE@
+Source1: @KERNEL_SOURCE@
+Source2: external-patches.tar.gz
+
+Source15: linux-rhconfig.h
+Source16: linux-merge-config.awk
+Source17: linux-merge-modules.awk
+
+Source25: suse-functions.sh
+Source26: suse-post.sh
+Source27: suse-postun.sh
+Source28: suse-trigger-script.sh.in
+Source29: sles8-post.sh
+Source30: sles8-postun.sh
+Source31: sles8-pre.sh
+Source32: sles8-update_INITRD_MODULES.sh
+Source33: sles8-update_rcfile_setting.sh
+
+%package source
+Summary: The source code for the Linux kernel.
+Group: Development/System
+Prereq: fileutils
+Requires: gawk
+Requires: gcc >= 2.96-98
+Autoreqprov: 0
+
+%package doc
+Summary: Various documentation bits found in the kernel source.
+Group: Documentation
+
+%description
+The kernel package contains the Linux kernel (vmlinuz), the core of a
+Linux operating system.  The kernel handles the basic functions of the
+operating system: memory allocation, process allocation, device input
+and output, etc.
+
+%description source
+The kernel-source package contains the source code files for the Linux
+kernel. These source files are needed to build custom/third party device
+drivers. The source files can also be used to build a custom kernel that is
+better tuned to your particular hardware, if you are so inclined (and you
+know what you're doing).
+
+%description doc
+This package contains documentation files form the kernel
+source. Various bits of information about the Linux kernel and the
+device drivers shipped with it are documented in these files. 
+
+You'll want to install this package if you need a reference to the
+options that can be passed to Linux kernel modules at load time.
+
+%package smp
+Summary: The Linux kernel compiled for SMP machines.
+Group: System Environment/Kernel
+Provides: module-info, kernel = %{kprovides}
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+%if %{rhbuild}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+%endif
+
+%description smp
+This package includes a SMP version of the Linux kernel. It is
+required only on machines with two or more CPUs, although it should
+work fine on single-CPU boxes.
+
+Install the kernel-smp package if your machine uses two or more CPUs.
+
+%package bigsmp
+Summary: The Linux kernel compiled for SMP machines.
+Group: System/Kernel
+Provides: module-info, kernel = %{kprovides}, k_smp4G
+Obsoletes: k_smp4G
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+%if %{rhbuild}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+%endif
+
+%description bigsmp
+This package includes a SMP version of the Linux kernel. It is
+required only on machines with two or more CPUs, although it should
+work fine on single-CPU boxes.
+
+Install the kernel-bigsmp package if your machine uses two or more CPUs.
+
+%package pseries64
+Summary: Standard Kernel for 64-bit Power based SMP and LPAR Machines
+Group: System/Kernel
+Provides: module-info, kernel = %{kprovides}, k_smp4G
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+%if %{rhbuild}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+%endif
+
+%description pseries64
+The standard kernel for Power3, Power4 and PowerPC 970 64-bit SMP
+machines.
+
+This kernel can be used for all 64bit RS/6000, pSeries and JS20
+machines.
+
+%package bigmem
+Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
+Group: System Environment/Kernel
+Provides: module-info, kernel = %{kprovides}
+%ifarch %{all_x86} ia64 x86_64
+Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
+%endif
+%if %{rhbuild}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+Obsoletes: kernel-enterprise <= 2.4.10
+%endif
+
+%description bigmem
+This package includes a kernel that has appropriate configuration options
+enabled for Pentium III machines with 4 Gigabyte of memory or more.
+
+%package BOOT
+Summary: The version of the Linux kernel used on installation boot disks.
+Group: System Environment/Kernel
+Provides: kernel = %{kprovides}
+%if %{rhbuild}
+Prereq: %{BOOT_kernel_prereq}
+Conflicts: %{kernel_conflicts}
+%endif
+
+%description BOOT
+This package includes a trimmed down version of the Linux kernel.
+This kernel is used on the installation boot disks only and should not
+be used for an installed system, as many features in this kernel are
+turned off because of the size constraints.
+
+%package BOOTsmp
+Summary: The Linux kernel used on installation boot disks for SMP machines.
+Group: System Environment/Kernel
+Provides: kernel = %{kprovides}
+%if %{rhbuild}
+Prereq: %{BOOT_kernel_prereq}
+Conflicts: %{kernel_conflicts}
+%endif
+
+%description BOOTsmp
+This package includes a trimmed down version of the Linux kernel. This
+kernel is used on the installation boot disks only and should not be used
+for an installed system, as many features in this kernel are turned off
+because of the size constraints. This kernel is used when booting SMP
+machines that have trouble coming up to life with the uniprocessor kernel.
+
+%package jensen
+Summary: The Linux Kernel compiled for the Alpha Jensen platform.
+Group: System Environment/Kernel
+Provides: kernel = %{kprovides}
+%if %{rhbuild}
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_conflicts}
+%endif
+
+%description jensen
+This package includes a kernel that has appropriate configuration
+options enabled for use on the Alpha Jensen platform.  The Jensen
+platform is not supported in the normal generic alpha kernel support.
+
+%package -n lustre-lite-utils
+Summary: Lustre utils for Linux
+Group: Applications/System
+
+%description -n lustre-lite-utils
+The Lustre Lite file system utilities.  This includes the tools needed
+to configure, mount, and administer a Lustre filesystem.  This package
+is necessary if you want to access a Lustre filesystem.
+
+# the lustre-doc files are just included as %doc with
+# lustre-lite-utils
+
+#%package -n lustre-doc
+#Summary: Sample Lustre configurations and documentation
+#Group: Documentation
+
+#%description -n lustre-doc
+#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
+    ln -sf lustre* lustre
+fi
+pushd lustre >/dev/null
+if [ -s "%{SOURCE2}" ] ; then
+       tar zxf "%{SOURCE2}" -C lustre/kernel_patches
+fi
+bash -x ./build/lmake \
+       --unpack-kernel \
+       --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       --kerneldir $RPM_SOURCE_DIR %{lmakeopts}
+popd >/dev/null
+
+# handle both SuSE and Red Hat's new-kernel-pkg bits
+for flavor in "" smp bigmem bigsmp pseries64 BOOT jensen ; do
+       [ -n "$flavor" ] && delim_flavor="%{flavordelim}$flavor"
+       for when in pre preun post postun ; do
+               script="${when}${flavor}.sh"
+               cat %{SOURCE25} %{SOURCE32} %{SOURCE33} > ${script}
+               echo "if [ -d /etc/susehelp.d ] ; then" >> ${script}
+               sed -e "s/@when@/$when/g" -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" %{SOURCE28} >> ${script}
+               case $when in
+                       pre)
+                               echo "if [ ! -f /etc/modprobe.conf ] ; then" >> ${script}
+                               cat %{SOURCE31} >> ${script}
+                               echo "fi" >> ${script}
+                               ;;
+                       post)
+                               # /sbin/update-modules.dep compares when the modules were built, rather
+                               # than installed, so force modules.dep to be recreated
+                               echo "rm -f /lib/modules/%{KVERREL}${delim_flavor}/modules.dep" >> ${script}
+                               echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}
+                               sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" -e "s^%flavor^${flavor}^" %{SOURCE26} >> ${script}
+
+                               echo "else" >> ${script}
+                               sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" -e "s^%%{cfg_name}^${delim_flavor}^g" %{SOURCE29} >> ${script}
+                               echo "fi" >> ${script}
+                               ;;
+                       postun)
+                               echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}
+                               sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" %{SOURCE27} >> ${script}
+
+                               echo "else" >> ${script}
+                               sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" %{SOURCE30} >> ${script}
+                               echo "fi" >> ${script}
+                               ;;
+               esac
+               echo "exit 0; fi" >> ${script}
+               case $when in
+                       post)
+                               if [ -z "${flavor}" ] ; then
+                                       cat >> ${script} <<EOF
+cd /boot
+%ifnarch ia64
+ln -sf vmlinuz-%{KVERREL} vmlinuz
+%endif
+ln -sf System.map-%{KVERREL} System.map
+ln -sf module-info-%{KVERREL} module-info
+EOF
+                               fi
+                               cat >> ${script} <<EOF
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
+[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
+if [ -x /sbin/new-kernel-pkg ] ; then
+       if /sbin/new-kernel-pkg 2>&1 | grep package >/dev/null ; then
+               PACKAGE_ARG="--package kernel-${flavor}"
+       fi
+        /sbin/new-kernel-pkg $PACKAGE_ARG --mkinitrd --depmod \
+               --install %{KVERREL}${delim_flavor}
+fi
+EOF
+                               ;;
+                       postun)
+                               ;;
+                       pre)
+                               cat >> ${script} <<EOF
+/sbin/modprobe loop 2>/dev/null >/dev/null || :
+exit 0
+EOF
+                               ;;
+                       preun)
+                               cat >> ${script} <<EOF
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+rm -f /lib/modules/%{KVERREL}${delim_flavor}/modules.*
+if [ -x /sbin/new-kernel-pkg ] ; then
+ /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${delim_flavor}
+fi
+EOF
+                               ;;
+               esac
+       done
+
+       cat > "kernel$flavor.files" <<EOF
+%%defattr(-, root, root)
+/boot/%{kernel_glob}${delim_flavor}
+/boot/System.map-%{KVERREL}${delim_flavor}
+/boot/config-%{KVERREL}${delim_flavor}
+%%dir /lib/modules
+%%dir /dev/shm
+/lib/modules/%{KVERREL}${delim_flavor}
+%ifarch ia64
+/boot/efi/redhat/%{kernel_glob}${delim_flavor}
+%endif
+%if %{linux26}
+%if %{susebuild}
+/boot/Kerntypes-%{KVERREL}${delim_flavor}
+%endif
+/boot/symvers-%{KVERREL}-%{_target_cpu}${delim_flavor}.gz
+%endif
+EOF
+
+done
+
+cat > kernel-source.files <<EOF
+%%defattr(-,root,root)
+%%dir /usr/src/linux-%{KVERREL}
+/usr/src/linux-%{KVERREL}/*
+%if %{linux26}
+%%dir /usr/src/linux-%{KVERREL}-obj
+/usr/src/linux-%{KVERREL}-obj/*
+%endif
+EOF
+
+%build
+# if RPM_BUILD_NCPUS unset, set it
+if [ -z "$RPM_BUILD_NCPUS" ] ; then
+    RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :)
+    if [ $RPM_BUILD_NCPUS -eq 0 ] ; then
+        RPM_BUILD_NCPUS=1
+    fi
+    if [ $RPM_BUILD_NCPUS -gt 8 ] ; then
+        RPM_BUILD_NCPUS=8
+    fi
+fi
+
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT
+
+DependKernel()
+{
+  target_config=${1:+--target-config $1}
+  bash -x ./build/lmake \
+       --depend-kernel \
+       --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       ${target_config} \
+       --extraversion %{kextraver} \
+       -j $RPM_BUILD_NCPUS %{lmakeopts}
+}
+
+BuildKernel()
+{
+  target_config=${1:+--target-config $1}
+  bash -x ./build/lmake \
+       --build-kernel --build-lustre \
+       --install \
+       --save-headers \
+       --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       ${target_config} \
+       --extraversion %{kextraver} \
+       --kerneldir $RPM_SOURCE_DIR \
+       -j $RPM_BUILD_NCPUS \
+       --destdir $RPM_BUILD_ROOT %{lmakeopts} \
+       -- --enable-tests \
+       @CONFIGURE_FLAGS@
+}
+
+BuildLustre()
+{
+  target_config=${1:+--target-config $1}
+  bash -x ./build/lmake \
+       --build-lustre \
+       --install-lustre \
+       --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       ${target_config} \
+       --extraversion %{kextraver} \
+       --kerneldir $RPM_SOURCE_DIR \
+       -j $RPM_BUILD_NCPUS \
+       --destdir $RPM_BUILD_ROOT %{lmakeopts} \
+       -- --enable-utils \
+       --disable-doc --disable-tests \
+       --disable-modules --disable-liblustre \
+       --sysconfdir=%{_sysconfdir} \
+       --mandir=%{_mandir} \
+       @CONFIGURE_FLAGS@
+}
+
+SaveHeaders()
+{
+  bash -x ./build/lmake \
+       --save-headers \
+       --target @LUSTRE_TARGET@ \
+       --target-arch %{_target_cpu} \
+       --extraversion %{kextraver} \
+       --destdir $RPM_BUILD_ROOT %{lmakeopts}
+}
+
+pushd lustre >/dev/null
+
+%if %{buildbigmem}
+BuildKernel bigmem
+%endif
+
+%if %{buildBOOT}
+BuildKernel BOOT
+%endif
+
+%if %{buildjensen}
+BuildKernel jensen
+%endif
+
+%if %{buildsmp}
+BuildKernel smp
+%endif
+
+%if %{buildbigsmp}
+BuildKernel bigsmp
+%endif
+
+%if %{buildpseries64}
+BuildKernel pseries64
+%endif
+
+%if %{buildup}
+BuildKernel
+%endif
+
+%if %{buildbase}
+# BuildLustre
+%endif
+
+popd >/dev/null
+
+%install
+pushd lustre >/dev/null
+# it's already installed, so just clean up some things that are rpm
+# specific
+for i in $RPM_BUILD_ROOT/lib/modules/* ; do
+  rm -f $i/modules.*
+%ifarch %{ntplarchs}
+  # remove legacy pcmcia symlink that's no longer useful
+  rm -rf $i/pcmcia
+%endif
+done
+
+# mark the vmlinux* non-executable to fool strip-to-file
+chmod a-x $RPM_BUILD_ROOT/boot/vmlinux*
+
+BuildObj ()
+{
+       flavor=$1
+       if [ $flavor = "up" ] ; then
+               flavext=""
+               flavtgt=""
+       else
+               flavext="%{flavordelim}$flavor"
+               flavtgt="$flavor"
+       fi
+        perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{kextraverdelim}%{kextraver}${flavext}/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
+       c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}"
+       o="${c}-obj/%{_target_cpu}/$flavor"
+       mkdir -p $o
+        # use the one we just built
+       #cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.config \
+       cp .config $o/.config
+        for oc in oldconfig_nonint silentoldconfig oldconfig ; do
+           if grep -q "$oc" Makefile ; then
+               OLDCONFIG="$oc"
+               break
+           fi
+        done
+       MAKE="make -s O=$o -C ${c}"
+       if [ "$CC" ] ; then
+           MAKE_CC="CC=$CC"
+       fi
+       $MAKE "$MAKE_CC" $OLDCONFIG
+       $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.  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
+       ARCH=%{_target_cpu} /bin/bash scripts/mkmakefile ../../../linux-%{KVERREL} $o \
+               $VERSION $PATCHLEVEL > $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}${flavext}.gz" \
+           > $o/Module.symvers
+}
+
+##
+## do -source package cleanup/install
+##
+if [ "%{buildbase}" -ne 0 ] ; then
+    pushd linux >/dev/null
+    mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+    rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
+    tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+    ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
+    # install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+
+    #clean up the destination
+    make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+    rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
+    mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
+    cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
+    if [ "%{linux26}" -ne 0 ] ; then
+        # this only works because Sun only builds one kernel per target/arch per kernel-source rpm
+       objdir=$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}-obj
+       mkdir -p $objdir
+        if [ "%{buildbigmem}" -ne 0 ] ; then
+           BuildObj bigmem
+        fi
+        if [ "%{buildBOOT}" -ne 0 ] ; then
+           BuildObj BOOT
+        fi
+        if [ "%{buildjensen}" -ne 0 ] ; then
+           BuildObj jensen
+        fi
+        if [ "%{buildsmp}" -ne 0 ] ; then
+           BuildObj smp
+        fi
+       if [ "%{buildbigsmp}" -ne 0 ] ; then
+           BuildObj bigsmp
+        fi
+       if [ "%{buildpseries64}" -ne 0 ] ; then
+           BuildObj pseries64
+        fi
+        if [ "%{buildup}" -ne 0 ] ; then
+           BuildObj up
+        fi
+        perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{kextraverdelim}%{kextraver}%{flavordelim}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
+       # Remove $RPM_BUILD_ROOT prefix from symlinks.
+       for link in $(find $objdir -type l); do
+           target=$(readlink $link)
+           rm -f $link
+           ln -s ${target/$RPM_BUILD_ROOT/} $link
+       done
+    else # 2.4 rh-style
+        perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{kextraverdelim}%{kextraver}%{flavordelim}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
+        # get the one from the build we just completed as it might have picked
+        # up new options
+        #cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
+        cp .config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
+        for oc in oldconfig_nonint silentoldconfig oldconfig ; do
+           if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
+               OLDCONFIG="$oc"
+               break
+           fi
+        done
+       if [ "$CC" ] ; then
+           MAKE_CC="CC=$CC"
+       fi
+        make "$MAKE_CC" -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+        make "$MAKE_CC" -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+        make "$MAKE_CC" -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+
+        #this generates modversions info which we want to include and we may as
+        #well include the depends stuff as well, after we fix the paths
+        make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+        find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \
+        while read file ; do
+            mv $file $file.old
+            sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file
+            rm -f $file.old
+        done
+
+        # Try to put some smarter autoconf.h and version.h files in place
+        pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; {
+        rm -rf modules modversions.h autoconf.h version.h
+        cat > modversions.h <<EOF
+#ifndef _LINUX_MODVERSIONS_H
+#define _LINUX_MODVERSIONS_H
+#include <linux/rhconfig.h>
+#include <linux/modsetver.h>
+EOF
+        echo '#include <linux/rhconfig.h>' > autoconf.h
+        list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort`
+        mkdir modules
+        for l in $list; do
+            sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l
+            touch -r modules/$l modules/`basename $l .ver`.stamp
+            echo '#include <linux/modules/'$l'>' >> modversions.h
+        done
+        echo '#endif' >> modversions.h
+        sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
+        install -m 644 %{SOURCE15} rhconfig.h
+        echo "#include <linux/rhconfig.h>" >> version.h
+        keyword=if
+        for i in smp BOOT BOOTsmp bigmem bigsmp pseries64 up ; do
+            # When we build in an i386, we don't have an bigmem header directory
+            # in savedheaders/i386/bigmem.  We also don't have a BOOT directory
+            # anywhere except in savedheaders/i386.  So, we need to use this method
+            # of determining if a kernel version string needs to be included in the
+            # version.h file
+            verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
+            if [ -n "$verh" -a -f "$verh" ]; then
+                if [ "$i" = up ]; then
+                   if [ "$keyword" = if ]; then
+                       echo "#if 0" >> version.h
+                   fi
+                   echo "#else" >> version.h
+               else
+                   echo "#$keyword defined(__module__$i)" >> version.h
+                   keyword=elif
+                fi
+               grep UTS_RELEASE $verh >> version.h
+            fi
+            done
+        echo "#endif" >> version.h
+        if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then
+            # keep to a standard normally
+            HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h
+        else
+            # test build not including uniprocessor, must get info from somewhere
+            HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -n 1)
+        fi
+        grep -v UTS_RELEASE $HEADER_FILE >> version.h
+        rm -rf ../../savedheaders
+        } ; popd
+        touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion}
+        
+        # rm -f $RPM_BUILD_ROOT/usr/include/linux
+        
+        rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders
+        
+        if [ "%{rhbuild}" -ne 0 ] ; then
+            # fix up the tmp_include_depends file wrt the buildroot
+            perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends
+        fi
+    fi # linux26
+    popd >/dev/null
+fi # buildbase
+
+popd >/dev/null
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+###
+### scripts
+###
+
+# do this for upgrades...in case the old modules get removed we have
+# loopback in the kernel so that mkinitrd will work.
+%pre -f pre.sh
+
+%pre smp -f presmp.sh
+
+%pre bigsmp -f prebigsmp.sh
+
+%pre pseries64 -f prepseries64.sh
+
+%pre bigmem -f prebigmem.sh
+
+%post -f post.sh
+
+%post pseries64 -f postpseries64.sh
+
+%post smp -f postsmp.sh
+
+%post bigsmp -f postbigsmp.sh
+
+%post bigmem -f postbigmem.sh
+
+%post jensen -f postjensen.sh
+
+%ifnarch ia64
+%post BOOT -f postBOOT.sh
+
+%endif
+
+%post -n lustre-lite-utils
+if [ -f /etc/init.d/lustre ] ; then
+       /sbin/chkconfig --add lustre
+       /sbin/chkconfig --add lustrefs
+fi
+
+# Allow clean removal of modules directory
+%preun -f preun.sh
+
+%preun pseries64 -f preunpseries64.sh
+
+%preun smp -f preunsmp.sh
+
+%preun bigsmp -f preunbigsmp.sh
+
+%preun bigmem -f preunbigmem.sh
+
+%preun BOOT -f preunBOOT.sh
+
+%preun jensen -f preunjensen.sh
+
+# suse needs these i guess
+%postun -f postun.sh
+
+%postun pseries64 -f postunpseries64.sh
+
+%postun smp -f postunsmp.sh
+
+%postun bigsmp -f postunbigsmp.sh
+
+%postun bigmem -f postunbigmem.sh
+
+%postun BOOT -f postunBOOT.sh
+
+%postun jensen -f postunjensen.sh
+
+# We need this here because we don't prereq kudzu; it could be
+# installed after the kernel
+%triggerin -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin smp -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin bigsmp -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin pseries64 -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin bigmem -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin BOOT -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+%triggerin jensen -- kudzu
+[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
+
+
+# Old kernel-headers packages owned include symlinks; new
+# ones just make them so that we can have multiple kernel-headers
+# packages installed.
+
+%triggerpostun source -- kernel-headers < 2.2.16
+cd /usr/src
+rm -f %{kslnk}
+ln -snf linux-%{KVERREL} %{kslnk}
+exit 0
+
+%post source
+cd /usr/src
+rm -f %{kslnk}
+ln -snf linux-%{KVERREL} %{kslnk}
+
+%postun source
+if [ -L /usr/src/%{kslnk} ]; then 
+    if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then
+       [ $1 = 0 ] && rm -f /usr/src/%{kslnk}
+    fi
+fi
+exit 0
+
+%preun -n lustre-lite-utils
+if [ $1 = 0 -a -f /etc/init.d/lustre ]; then
+       /sbin/chkconfig --del lustre
+       /sbin/chkconfig --del lustrefs
+fi
+
+###
+### file lists
+###
+
+%if %{buildup}
+%files -f kernel.files
+%endif
+
+%if %{buildsmp}
+%files smp -f kernelsmp.files
+%endif
+
+%if %{buildbigsmp}
+%files bigsmp -f kernelbigsmp.files
+%endif
+
+%if %{buildpseries64}
+%files pseries64 -f kernelpseries64.files
+%endif
+
+%if %{buildbigmem}
+%files bigmem -f kernelbigmem.files
+%endif
+
+%if %{buildBOOT}
+%files BOOT -f kernelBOOT.files
+%endif
+
+%if %{buildbase}
+%files source -f kernel-source.files
+%endif