File kernel.spec of Package kernel

# Spec file originally created for Fedora, modified for Moblin Linux
#

Summary: The Linux kernel (the core of the Linux operating system)


# For a stable, released kernel, released_kernel should be 1. For rawhide
# and/or a kernel built from an rc snapshot, released_kernel should
# be 0.
%define released_kernel 1

# Versions of various parts

# base_sublevel is the kernel version we're starting with and patching
# on top of -- for example, 2.6.22-rc7 starts with a 2.6.21 base,
# which yields a base_sublevel of 21.

%define base_sublevel 33


## If this is a released kernel ##
%if 0%{?released_kernel}
# Do we have a 2.6.21.y update to apply?
%define stable_update 2
# Set rpm version accordingly
%if 0%{?stable_update}
%define stablerev .%{stable_update}
%endif
%define rpmversion 2.6.%{base_sublevel}%{?stablerev}

## The not-released-kernel case ##
%else
# The next upstream release sublevel (base_sublevel+1)
%define upstream_sublevel %(expr %{base_sublevel} + 1)
# The rc snapshot level

%define rcrev 8


%if 0%{?rcrev}
%define rctag ~rc%rcrev
%endif

%if !0%{?rcrev}
%define rctag ~rc0
%endif

# Set rpm version accordingly
%define rpmversion 2.6.%{upstream_sublevel}%{?rctag}
%endif

# The kernel tarball/base version
%define kversion 2.6.%{base_sublevel}

%define make_target bzImage

%define KVERREL %{version}-%{release}
%define hdrarch %_target_cpu

%define all_x86 i386 i586 i686 %{ix86}

%define all_arm %{arm}

# Per-arch tweaks

%ifarch %{all_x86}
%define image_install_path boot
%define hdrarch i386
%define kernel_image arch/x86/boot/bzImage
%endif

%ifarch x86_64
%define image_install_path boot
%define kernel_image arch/x86/boot/bzImage
%endif

%ifarch %{all_arm}
%define image_install_path boot
%define kernel_image arch/arm/boot/zImage
%define make_target zImage
%endif

%define oldconfig_target nonint_oldconfig

#
# Packages that need to be installed before the kernel is, because the %post
# scripts use them.
#
%define kernel_prereq  fileutils, module-init-tools, fastinit, mkinitrd >= 6.0.39-1

#
# This macro does requires, provides, conflicts, obsoletes for a kernel package.
#	%%kernel_reqprovconf <subpackage>
# It uses any kernel_<subpackage>_conflicts and kernel_<subpackage>_obsoletes
# macros defined above.
#
%define kernel_reqprovconf \
Provides: kernel = %{rpmversion}-%{release}\
Provides: kernel-drm = 4.3.0\
Provides: kernel-uname-r = %{KVERREL}%{?1:-%{1}}\
Requires(pre): %{kernel_prereq}\
%{?1:%{expand:%%{?kernel_%{1}_conflicts:Conflicts: %%{kernel_%{1}_conflicts}}}}\
%{?1:%{expand:%%{?kernel_%{1}_obsoletes:Obsoletes: %%{kernel_%{1}_obsoletes}}}}\
%{?1:%{expand:%%{?kernel_%{1}_provides:Provides: %%{kernel_%{1}_provides}}}}\
# We can't let RPM do the dependencies automatic because it'll then pick up\
# a correct but undesirable perl dependency from the module headers which\
# isn't required for the kernel proper to function\
AutoReq: no\
AutoProv: yes\
%{nil}

Name: kernel%{?variant}
Group: System/Kernel
License: GPLv2
URL: http://www.kernel.org/
Version: %{rpmversion}
Release: 4

%kernel_reqprovconf

#
# List the packages used during the kernel build
#
BuildRequires: module-init-tools, bash >= 2.03, sh-utils
BuildRequires:  findutils,  make >= 3.78
BuildRequires: linux-firmware
BuildRequires: elfutils-libelf-devel binutils-devel

Source0: http://www.kernel.org/pub/linux/kernel/v2.6/linux-%{kversion}.tar.bz2

Source10: COPYING.modules

Source15: merge.pl
Source20: Makefile.config

Source100: config-generic
Source101: config-menlow
Source102: config-ivi
Source103: config-netbook
Source104: config-shcdk
Source105: config-aava

Source106: config-arm-generic
Source107: config-arm-n900

# For a stable release kernel
%if 0%{?stable_update}
Patch00: patch-2.6.%{base_sublevel}.%{stable_update}.bz2
%endif
%if 0%{?rcrev}
Patch00: patch-2.6.%{upstream_sublevel}-rc%{rcrev}.bz2
%endif

#
# Reminder of the patch filename format:
# linux-<version it is supposed to be upstream>-<description-separated-with-dashes>.patch
#


#
# Stable patch - critical bugfixes
#
Patch1: patch-2.6.33.2.bz2

#
# Patch to add a "nonintconfig" option to the Makefile
# needed for unattended builds
#
Patch2: linux-2.6-build-nonintconfig.patch


# Backport section.. only patches already in Linus' or maintainer git trees
# should go here.

# MeeGo bug 331: drm/i915 EDID warning
Patch3: linux-2.6.34-drm-i915-Ignore-LVDS-EDID-when-it-is-unavailabe-or-invalid.patch

# MeeGo bug 99: touchpad press buttons not work
Patch4: linux-2.6.34-input-synaptics-clickpad-support.patch

# MeeGo bug 131: Broadcom BCM57780 Gigabit Ethernet Network Card driver
Patch5: linux-2.6.35-phylib-Support-phy-module-autoloading.patch
Patch6: linux-2.6.35-phylib-Add-module-table-to-all-existing-phy-drivers.patch

# Kernel CVE patches - these go last in the backport section
# no non-cve patches should go here!
Patch7: linux-2.6.34-CVE-tipc-Fix-oops-on-send-prior-to-entering-networked-mode.patch

#
# End of the "straight backport" patches
#


# core architecture and other invasive patches go first, then minor tweaks

Patch8: linux-2.6.34-moorestown-platform-enabling.patch
Patch9: linux-2.6.34-moorestown-nand-driver-2.0.patch
Patch10: linux-2.6.34-moorestown-touchscreen-driver.patch
Patch11: linux-2.6.34-moorestown-usb-otg-and-still-image-driver.patch

Patch12: linux-2.6.35-moorestown-camera-driver-10.0-1-3.patch
Patch13: linux-2.6.35-moorestown-camera-driver-10.0-2-3.patch
Patch14: linux-2.6.35-moorestown-camera-driver-10.0-3-3.patch

Patch15: linux-2.6.34-moorestown-keypad-driver.patch

Patch16: linux-2.6.34-moorestown-audio-driver-6.0-1-8.patch
Patch17: linux-2.6.34-moorestown-audio-driver-6.0-2-8.patch
Patch18: linux-2.6.34-moorestown-audio-driver-6.0-3-8.patch
Patch19: linux-2.6.34-moorestown-audio-driver-6.0-4-8.patch
Patch20: linux-2.6.34-moorestown-audio-driver-6.0-5-8.patch
Patch21: linux-2.6.34-moorestown-audio-driver-6.0-6-8.patch
Patch22: linux-2.6.34-moorestown-audio-driver-6.0-7-8.patch
Patch23: linux-2.6.34-moorestown-audio-driver-6.0-8-8.patch

Patch24: linux-2.6.34-moorestown-ericsson-mbm-driver.patch
Patch25: linux-2.6.34-moorestown-langwell-dma-driver-3.0.patch
Patch26: linux-2.6.34-moorestown-sensor-driver-1.1.patch
Patch27: linux-2.6.34-moorestown-gpe-fix-for-sensor.patch
Patch28: linux-2.6.34-moorestown-analog-accelerometer-driver.patch
Patch29: linux-2.6.34-moorestown-pmic-battery-driver.patch
Patch30: linux-2.6.34-moorestown-thermal-emc1403-driver.patch
Patch31: linux-2.6.34-moorestown-spi-slave-controller-driver-1.1.patch
Patch32: linux-2.6.34-moorestown-gtm501l-driver-1.2.patch
Patch33: linux-2.6.34-moorestown-rar-handler-driver-3.1.patch
Patch34: linux-2.6.34-moorestown-ifxgps-driver.patch
Patch35: linux-2.6.34-moorestown-ipc-host-driver.patch
Patch36: linux-2.6.34-moorestown-mmc-driver-1.0.patch
Patch37: linux-2.6.34-moorestown-img-graphics-driver-5.3.0.0007.patch
Patch38: linux-2.6.34-moorestown-graphics-changes-for-aava-koski-dv1-hardware.patch

Patch39: linux-2.6.34-moorestown-aava-specific-changes-no-audio.patch
Patch40: linux-2.6.34-cypress-touch-driver.patch
Patch41: linux-2.6.33-i2c-workaround-for-aava-koski-touchscreen.patch
Patch42: linux-2.6.34-hack-to-fix-aava-camera-sensor-issue.patch
Patch43: linux-2.6.34-moorestown-only-enable-mrst-pciquirks-on-mrst.patch
Patch44: linux-2.6.34-moorestown-fix-hw-qh-prefetch-bug.patch


#
# Patch to try mounting / before all devices (the mouse)
# are done probing. This saves several seconds of boot time.
#
Patch45: linux-2.6.29-dont-wait-for-mouse.patch
#
# Patch to support the old sreadahead versions
#
Patch46: linux-2.6.29-sreadahead.patch
#
# KMS (note: upstream backports go in the backport section higher up!)
#
Patch47: linux-2.6.29-kms-edid-cache.patch
Patch48: linux-2.6.29-kms-run-async.patch
Patch49: linux-2.6.29-kms-after-sata.patch

#
# Quiet down some printks that shows up falsly during boot
#
Patch50: linux-2.6.29-silence-acer-message.patch
Patch51: linux-2.6.31-silence-wacom.patch

# Timberdale drivers
Patch52: linux-2.6.33-rc8-timberdale.patch
Patch53: linux-2.6.33-timberdale-audio-fix.patch

#
# USB Selective Suspend patches
#
Patch54: linux-2.6-driver-level-usb-autosuspend.patch
Patch55: linux-2.6-usb-uvc-autosuspend.patch
Patch56: linux-2.6-usb-bt-autosuspend.patch

#
# Patches to fix performance issues of ondemand governor
#
Patch57: linux-2.6.34-ondemand-fix-1-7.patch
Patch58: linux-2.6.34-ondemand-fix-2-7.patch
Patch59: linux-2.6.34-ondemand-fix-3-7.patch
Patch60: linux-2.6.34-ondemand-fix-4-7.patch
Patch61: linux-2.6.34-ondemand-fix-5-7.patch
Patch62: linux-2.6.34-ondemand-fix-6-7.patch
Patch63: linux-2.6.34-ondemand-fix-7-7.patch

#
# Patches to help PowerTOP
#
Patch64: linux-2.6.33-vfs-tracepoints.patch
Patch65: linux-2.6.33-ahci-alpm-accounting.patch
Patch66: linux-2.6.33-ahci-fix-oops-on-dummy-port.patch
# two patches to expose driver state to powertop
# linux-2.6.33-drm-fbc-status.patch
# linux-2.6.33-drm-sr-status.patch 

# spurious debug spew
Patch67: linux-2.6.34-rt2860-no-debug.patch

# Fix 2 bugs in the rt2860 driver
Patch68: linux-2.6.33-rt2860-1-2.patch
Patch69: linux-2.6.33-rt2860-2-2.patch

# Patchset from Sam to fix MB#6315
Patch70: rtl8192_no_autoconnect.patch
Patch71: rtl8192_no_WAP_unassoc.patch
Patch72: rtl8192_carrier_off.patch


# OKI device drivers -- posted upstream already
Patch73: linux-2.6.34-pch-gbe.patch
Patch74: linux-2.6.34-pch-i2c.patch
Patch75: linux-2.6.34-pch-ieee1588.patch
Patch76: linux-2.6.34-pch-pcieqos.patch
Patch77: linux-2.6.34-pch-gpio.patch
Patch78: linux-2.6.34-pch-spi.patch
Patch79: linux-2.6.34-pch-usbdev.patch
Patch80: linux-2.6.34-pch-can.patch
Patch81: linux-2.6.34-pch-dma.patch
Patch82: linux-2.6.34-pch-uart.patch

#Multitouch drivers and configs posted upstream
Patch83: linux-2.6.34-stantum-and-mosart-multitouch-drivers.patch
Patch84: linux-2.6.34-cando-dual-touch-driver.patch


Patch85: linux-2.6.34-fix-marvell-firmware-path.patch

#
# ARM N900 patches
#

# Display
Patch86: linux-2.6.35-OMAP-DSS2-Add-Kconfig-option-for-DPI-display-type.patch
Patch87: linux-2.6.35-OMAP-DSS2-Use-vdds_sdi-regulator-supply-in-SDI.patch
Patch88: linux-2.6.35-OMAP-DSS2-Add-ACX565AKM-Panel-Driver.patch
Patch89: linux-2.6.35-OMAP-RX51-Add-LCD-Panel-support.patch
Patch90: linux-2.6.35-OMAP-RX51-Add-vdds_sdi-supply-voltage-for-SDI.patch
Patch91: linux-2.6.35-OMAP-RX51-Add-Touch-Controller-in-SPI-board-info.patch
# Touch screen
Patch92: linux-2.6.35-input-touchscreen-introduce-tsc2005-driver.patch
Patch93: linux-2.6.35-omap-rx-51-enable-tsc2005.patch
# USB
Patch94: linux-2.6.34-USB-gadget-introduce-g_nokia-gadget-driver.patch
Patch95: linux-2.6.34-USB-otg-add-notifier-support.patch

# Multitouch input driver for event devices
Patch96: linux-2.6.34-multi-touch-input-driver-for-event-devices.patch

# Enable stantum and cando drivers to use mtdev driver
Patch97: linux-2.6.34-enable-hid-dg-contact-count-stantum-and-cando-touch-drivers.patch



BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root

%description
The kernel package contains the Linux kernel (vmlinuz), the core of any
Linux operating system.  The kernel handles the basic functions
of the operating system: memory allocation, process allocation, device
input and output, etc.


#
# This macro creates a kernel-<subpackage>-devel package.
#	%%kernel_devel_package <subpackage> <pretty-name>
#
%define kernel_devel_package() \
%package %{?1:%{1}-}devel\
Summary: Development package for building kernel modules to match the %{?2:%{2} }kernel\
Group: System/Kernel\
Provides: kernel%{?1:-%{1}}-devel = %{version}-%{release}\
Provides: kernel-devel = %{version}-%{release}%{?1:-%{1}}\
Provides: kernel-devel = %{version}-%{release}%{?1:-%{1}}\
Provides: kernel-devel-uname-r = %{KVERREL}%{?1:-%{1}}\
Requires: kernel%{?1:-%{1}} = %{version}-%{release}\
AutoReqProv: no\
Requires(pre): /usr/bin/find\
%description -n kernel%{?variant}%{?1:-%{1}}-devel\
This package provides kernel headers and makefiles sufficient to build modules\
against the %{?2:%{2} }kernel package.\
%{nil}

#
# This macro creates a kernel-<subpackage> and its -devel too.
#	%%define variant_summary The Linux kernel compiled for <configuration>
#	%%kernel_variant_package [-n <pretty-name>] <subpackage>
#
%define kernel_variant_package(n:) \
%package %1\
Summary: %{variant_summary}\
Group: System/Kernel\
%kernel_reqprovconf\
%{expand:%%kernel_devel_package %1 %{!?-n:%1}%{?-n:%{-n*}}}\
%{nil}


# First the auxiliary packages of the main kernel package.
%kernel_devel_package

%package -n perf
Summary: The 'perf' performance counter tool
Group: System/Performance
%description -n perf
This package provides the "perf" tool that can be used to monitor performance counter events
as well as various kernel internal events.
Obsoletes: oprofile <= 0.9.5



# Now, each variant package.

%ifarch %all_x86

%define variant_summary Kernel for Netbooks
%kernel_variant_package netbook
%description netbook
This package contains the kernel optimized for the various popular netbooks.

%define variant_summary Kernel for Menlow
%kernel_variant_package menlow
%description menlow
This package contains the kernel optimized for the Menlow platform



%define variant_summary Kernel for IVI
%kernel_variant_package ivi
%description ivi
This package contains the kernel optimized for In Vehicle Infotainment segments

%endif

%ifarch %{all_arm}


#Put other ARM variants here

%endif


%prep

# First we unpack the kernel tarball.
# If this isn't the first make prep, we use links to the existing clean tarball
# which speeds things up quite a bit.

# Update to latest upstream.
%if 0%{?released_kernel}
%define vanillaversion 2.6.%{base_sublevel}
# released_kernel with stable_update available case
%if 0%{?stable_update}
%define vanillaversion 2.6.%{base_sublevel}.%{stable_update}
%endif
# non-released_kernel case
%else
%if 0%{?rcrev}
%define vanillaversion 2.6.%{upstream_sublevel}-rc%{rcrev}
%endif
%else
# pre-{base_sublevel+1}-rc1 case
%endif

if [ ! -d kernel-%{kversion}/vanilla-%{vanillaversion} ]; then
  # Ok, first time we do a make prep.
  rm -f pax_global_header
%setup -q -n kernel-%{kversion} -c
  mv linux-%{kversion} vanilla-%{vanillaversion}
  cd vanilla-%{vanillaversion}


%if 0%{?rcrev}
# patch-2.6.%{upstream_sublevel}-rc%{rcrev}.bz2
%patch00 -p1
%endif

#
# Reminder of the patch filename format:
# linux-<version it is supposed to be upstream>-<description-separated-with-dashes>.patch
#


#
# Stable patch - critical bugfixes
#
# patch-2.6.33.2.bz2
%patch1 -p1

#
# Patch to add a "nonintconfig" option to the Makefile
# needed for unattended builds
#
# linux-2.6-build-nonintconfig.patch
%patch2 -p1


# Backport section.. only patches already in Linus' or maintainer git trees
# should go here.

# MeeGo bug 331: drm/i915 EDID warning
# linux-2.6.34-drm-i915-Ignore-LVDS-EDID-when-it-is-unavailabe-or-invalid.patch
%patch3 -p1

# MeeGo bug 99: touchpad press buttons not work
# linux-2.6.34-input-synaptics-clickpad-support.patch
%patch4 -p1

# MeeGo bug 131: Broadcom BCM57780 Gigabit Ethernet Network Card driver
# linux-2.6.35-phylib-Support-phy-module-autoloading.patch
%patch5 -p1
# linux-2.6.35-phylib-Add-module-table-to-all-existing-phy-drivers.patch
%patch6 -p1

# Kernel CVE patches - these go last in the backport section
# no non-cve patches should go here!
# linux-2.6.34-CVE-tipc-Fix-oops-on-send-prior-to-entering-networked-mode.patch
%patch7 -p1

#
# End of the "straight backport" patches
#


# core architecture and other invasive patches go first, then minor tweaks

# linux-2.6.34-moorestown-platform-enabling.patch
%patch8 -p1
# linux-2.6.34-moorestown-nand-driver-2.0.patch
%patch9 -p1
# linux-2.6.34-moorestown-touchscreen-driver.patch
%patch10 -p1
# linux-2.6.34-moorestown-usb-otg-and-still-image-driver.patch
%patch11 -p1

# linux-2.6.35-moorestown-camera-driver-10.0-1-3.patch
%patch12 -p1
# linux-2.6.35-moorestown-camera-driver-10.0-2-3.patch
%patch13 -p1
# linux-2.6.35-moorestown-camera-driver-10.0-3-3.patch
%patch14 -p1

# linux-2.6.34-moorestown-keypad-driver.patch
%patch15 -p1

# linux-2.6.34-moorestown-audio-driver-6.0-1-8.patch
%patch16 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-2-8.patch
%patch17 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-3-8.patch
%patch18 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-4-8.patch
%patch19 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-5-8.patch
%patch20 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-6-8.patch
%patch21 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-7-8.patch
%patch22 -p1
# linux-2.6.34-moorestown-audio-driver-6.0-8-8.patch
%patch23 -p1

# linux-2.6.34-moorestown-ericsson-mbm-driver.patch
%patch24 -p1
# linux-2.6.34-moorestown-langwell-dma-driver-3.0.patch
%patch25 -p1
# linux-2.6.34-moorestown-sensor-driver-1.1.patch
%patch26 -p1
# linux-2.6.34-moorestown-gpe-fix-for-sensor.patch
%patch27 -p1
# linux-2.6.34-moorestown-analog-accelerometer-driver.patch
%patch28 -p1
# linux-2.6.34-moorestown-pmic-battery-driver.patch
%patch29 -p1
# linux-2.6.34-moorestown-thermal-emc1403-driver.patch
%patch30 -p1
# linux-2.6.34-moorestown-spi-slave-controller-driver-1.1.patch
%patch31 -p1
# linux-2.6.34-moorestown-gtm501l-driver-1.2.patch
%patch32 -p1
# linux-2.6.34-moorestown-rar-handler-driver-3.1.patch
%patch33 -p1
# linux-2.6.34-moorestown-ifxgps-driver.patch
%patch34 -p1
# linux-2.6.34-moorestown-ipc-host-driver.patch
%patch35 -p1
# linux-2.6.34-moorestown-mmc-driver-1.0.patch
%patch36 -p1
# linux-2.6.34-moorestown-img-graphics-driver-5.3.0.0007.patch
%patch37 -p1
# linux-2.6.34-moorestown-graphics-changes-for-aava-koski-dv1-hardware.patch
%patch38 -p1

# linux-2.6.34-moorestown-aava-specific-changes-no-audio.patch
%patch39 -p1
# linux-2.6.34-cypress-touch-driver.patch
%patch40 -p1
# linux-2.6.33-i2c-workaround-for-aava-koski-touchscreen.patch
%patch41 -p1
# linux-2.6.34-hack-to-fix-aava-camera-sensor-issue.patch
%patch42 -p1
# linux-2.6.34-moorestown-only-enable-mrst-pciquirks-on-mrst.patch
%patch43 -p1
# linux-2.6.34-moorestown-fix-hw-qh-prefetch-bug.patch
%patch44 -p1


#
# Patch to try mounting / before all devices (the mouse)
# are done probing. This saves several seconds of boot time.
#
# linux-2.6.29-dont-wait-for-mouse.patch
%patch45 -p1
#
# Patch to support the old sreadahead versions
#
# linux-2.6.29-sreadahead.patch
%patch46 -p1
#
# KMS (note: upstream backports go in the backport section higher up!)
#
# linux-2.6.29-kms-edid-cache.patch
%patch47 -p1
# linux-2.6.29-kms-run-async.patch
%patch48 -p1
# linux-2.6.29-kms-after-sata.patch
%patch49 -p1

#
# Quiet down some printks that shows up falsly during boot
#
# linux-2.6.29-silence-acer-message.patch
%patch50 -p1
# linux-2.6.31-silence-wacom.patch
%patch51 -p1

# Timberdale drivers
# linux-2.6.33-rc8-timberdale.patch
%patch52 -p1
# linux-2.6.33-timberdale-audio-fix.patch
%patch53 -p1

#
# USB Selective Suspend patches
#
# linux-2.6-driver-level-usb-autosuspend.patch
%patch54 -p1
# linux-2.6-usb-uvc-autosuspend.patch
%patch55 -p1
# linux-2.6-usb-bt-autosuspend.patch
%patch56 -p1

#
# Patches to fix performance issues of ondemand governor
#
# linux-2.6.34-ondemand-fix-1-7.patch
%patch57 -p1
# linux-2.6.34-ondemand-fix-2-7.patch
%patch58 -p1
# linux-2.6.34-ondemand-fix-3-7.patch
%patch59 -p1
# linux-2.6.34-ondemand-fix-4-7.patch
%patch60 -p1
# linux-2.6.34-ondemand-fix-5-7.patch
%patch61 -p1
# linux-2.6.34-ondemand-fix-6-7.patch
%patch62 -p1
# linux-2.6.34-ondemand-fix-7-7.patch
%patch63 -p1

#
# Patches to help PowerTOP
#
# linux-2.6.33-vfs-tracepoints.patch
%patch64 -p1
# linux-2.6.33-ahci-alpm-accounting.patch
%patch65 -p1
# linux-2.6.33-ahci-fix-oops-on-dummy-port.patch
%patch66 -p1
# two patches to expose driver state to powertop
# linux-2.6.33-drm-fbc-status.patch
# linux-2.6.33-drm-sr-status.patch 

# spurious debug spew
# linux-2.6.34-rt2860-no-debug.patch
%patch67 -p1

# Fix 2 bugs in the rt2860 driver
# linux-2.6.33-rt2860-1-2.patch
%patch68 -p1
# linux-2.6.33-rt2860-2-2.patch
%patch69 -p1

# Patchset from Sam to fix MB#6315
# rtl8192_no_autoconnect.patch
%patch70 -p1
# rtl8192_no_WAP_unassoc.patch
%patch71 -p1
# rtl8192_carrier_off.patch
%patch72 -p1


# OKI device drivers -- posted upstream already
# linux-2.6.34-pch-gbe.patch
%patch73 -p1
# linux-2.6.34-pch-i2c.patch
%patch74 -p1
# linux-2.6.34-pch-ieee1588.patch
%patch75 -p1
# linux-2.6.34-pch-pcieqos.patch
%patch76 -p1
# linux-2.6.34-pch-gpio.patch
%patch77 -p1
# linux-2.6.34-pch-spi.patch
%patch78 -p1
# linux-2.6.34-pch-usbdev.patch
%patch79 -p1
# linux-2.6.34-pch-can.patch
%patch80 -p1
# linux-2.6.34-pch-dma.patch
%patch81 -p1
# linux-2.6.34-pch-uart.patch
%patch82 -p1

#Multitouch drivers and configs posted upstream
# linux-2.6.34-stantum-and-mosart-multitouch-drivers.patch
%patch83 -p1
# linux-2.6.34-cando-dual-touch-driver.patch
%patch84 -p1


# linux-2.6.34-fix-marvell-firmware-path.patch
%patch85 -p1

#
# ARM N900 patches
#

# Display
# linux-2.6.35-OMAP-DSS2-Add-Kconfig-option-for-DPI-display-type.patch
%patch86 -p1
# linux-2.6.35-OMAP-DSS2-Use-vdds_sdi-regulator-supply-in-SDI.patch
%patch87 -p1
# linux-2.6.35-OMAP-DSS2-Add-ACX565AKM-Panel-Driver.patch
%patch88 -p1
# linux-2.6.35-OMAP-RX51-Add-LCD-Panel-support.patch
%patch89 -p1
# linux-2.6.35-OMAP-RX51-Add-vdds_sdi-supply-voltage-for-SDI.patch
%patch90 -p1
# linux-2.6.35-OMAP-RX51-Add-Touch-Controller-in-SPI-board-info.patch
%patch91 -p1
# Touch screen
# linux-2.6.35-input-touchscreen-introduce-tsc2005-driver.patch
%patch92 -p1
# linux-2.6.35-omap-rx-51-enable-tsc2005.patch
%patch93 -p1
# USB
# linux-2.6.34-USB-gadget-introduce-g_nokia-gadget-driver.patch
%patch94 -p1
# linux-2.6.34-USB-otg-add-notifier-support.patch
%patch95 -p1

# Multitouch input driver for event devices
# linux-2.6.34-multi-touch-input-driver-for-event-devices.patch
%patch96 -p1

# Enable stantum and cando drivers to use mtdev driver
# linux-2.6.34-enable-hid-dg-contact-count-stantum-and-cando-touch-drivers.patch
%patch97 -p1


cd ..

else
  # We already have a vanilla dir.
  cd kernel-%{kversion}
  if [ -d linux-%{kversion} ]; then
     # Just in case we ctrl-c'd a prep already
     rm -rf deleteme
     # Move away the stale away, and delete in background.
     mv linux-%{kversion} deleteme
     rm -rf deleteme &
  fi
fi

cp -rl vanilla-%{vanillaversion} linux-%{kversion}

cd linux-%{kversion}

# 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


# Any further pre-build tree manipulations happen here.

chmod +x scripts/checkpatch.pl

cp %{SOURCE10} Documentation/

# only deal with configs if we are going to build for the arch
%ifnarch %nobuildarches

mkdir configs

# now run oldconfig over all the config files
for i in kernel-*.config
do
  mv $i .config
  Arch="x86"

  #get ARCH from .config file for other platforms
  if [ `cat .config | grep -c CONFIG_ARM=y` -eq 1 ]; then
    Arch="arm"
  fi

  # make oldconfig > /dev/null
  echo Doing $i
  make ARCH=$Arch %{oldconfig_target} > /dev/null
  echo "# $Arch" > configs/$i
  cat .config >> configs/$i
done
# end of kernel config
%endif

# get rid of unwanted files resulting from patch fuzz
find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null

cd ..


###
### build
###
%build


cp_vmlinux()
{
  eu-strip --remove-comment -o "$2" "$1"
}

BuildKernel() {
    MakeTarget=$1
    KernelImage=$2
    Flavour=$3
    InstallName=${4:-vmlinuz}

    # Pick the right config file for the kernel we're building
    Config=kernel${Flavour:+-${Flavour}}.config
    DevelDir=/usr/src/kernels/%{KVERREL}${Flavour:+-${Flavour}}

    # When the bootable image is just the ELF kernel, strip it.
    # We already copy the unstripped file into the debuginfo package.
    if [ "$KernelImage" = vmlinux ]; then
      CopyKernel=cp_vmlinux
    else
      CopyKernel=cp
    fi

    KernelVer=%{version}-%{release}${Flavour:+-${Flavour}}
    echo BUILDING A KERNEL FOR ${Flavour} %{_target_cpu}...

    # make sure EXTRAVERSION says what we want it to say
    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{?stablerev}%{?rctag}-%{release}/" Makefile

    # and now to start the build process

    make -s mrproper
    cp configs/$Config .config

    Arch="x86"
%ifarch %{all_arm}
    Arch="arm"
%endif
    echo USING ARCH=$Arch

    make -s ARCH=$Arch %{oldconfig_target} > /dev/null
    make -s ARCH=$Arch %{?_smp_mflags} $MakeTarget %{?sparse_mflags} \
    	 ${idhack+"$idhack"}
    make -s ARCH=$Arch %{?_smp_mflags} modules %{?sparse_mflags} || exit 1

    # Start installing the results
    mkdir -p $RPM_BUILD_ROOT/%{image_install_path}
    install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer
    install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-$KernelVer
    touch $RPM_BUILD_ROOT/boot/initrd-$KernelVer.img
    if [ -f arch/$Arch/boot/zImage.stub ]; then
      cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/%{image_install_path}/zImage.stub-$KernelVer || :
    fi
    $CopyKernel $KernelImage \
    		$RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
    chmod 755 $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer

    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer
    make -s ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer
%ifnarch %{all_arm}
    make -s ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT vdso_install KERNELRELEASE=$KernelVer
%endif

    # And save the headers/makefiles etc for building modules against
    #
    # This all looks scary, but the end result is supposed to be:
    # * all arch relevant include/ files
    # * all Makefile/Kconfig files
    # * all script/ files

    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/source
    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    (cd $RPM_BUILD_ROOT/lib/modules/$KernelVer ; ln -s build source)
    # dirs for additional modules per module-init-tools, kbuild/modules.txt
    # first copy everything
    cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    cp System.map $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    if [ -s Module.markers ]; then
      cp Module.markers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    fi
    # then drop all but the needed Makefiles/Kconfig files
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
    cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
    if [ -d arch/%{_arch}/scripts ]; then
      cp -a arch/%{_arch}/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch} || :
    fi
    if [ -f arch/%{_arch}/*lds ]; then
      cp -a arch/%{_arch}/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/ || :
    fi
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*.o
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*/*.o
%ifarch %{all_x86}
    cp -a --parents arch/x86/include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
%endif
%ifarch %{all_arm}
    cp -a --parents arch/arm/include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
%endif
    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
    cd include
    cp -a acpi asm-generic config crypto drm generated keys linux math-emu media mtd net pcmcia rdma rxrpc scsi sound video trace $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
    #cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
    # While arch/powerpc/include/asm is still a symlink to the old
    # include/asm-ppc{64,} directory, include that in kernel-devel too.
    if [ "$Arch" = "powerpc" -a -r ../arch/powerpc/include/asm ]; then
      cp -a `readlink ../arch/powerpc/include/asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
      mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/$Arch/include
      pushd $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/$Arch/include
      ln -sf ../../../include/asm-ppc* asm
      popd
    fi

    # Make sure the Makefile and version.h have a matching timestamp so that
    # external modules can be built
    touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Makefile $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/version.h
    touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/autoconf.h
    # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
    cp $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/config/auto.conf
    cd ..

    #
    # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm
    #
    # cp vmlinux $RPM_BUILD_ROOT/lib/modules/$KernelVer

    find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f >modnames

    # mark modules executable so that strip-to-file can strip them
    xargs --no-run-if-empty chmod u+x < modnames

    # Generate a list of modules for block and networking.

    fgrep /drivers/ modnames | xargs --no-run-if-empty nm -upA |
    sed -n 's,^.*/\([^/]*\.ko\):  *U \(.*\)$,\1 \2,p' > drivers.undef

    collect_modules_list()
    {
      sed -r -n -e "s/^([^ ]+) \\.?($2)\$/\\1/p" drivers.undef |
      LC_ALL=C sort -u > $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.$1
    }

    collect_modules_list networking \
    			 'register_netdev|ieee80211_register_hw|usbnet_probe'
    collect_modules_list block \
    			 'ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans'

    # remove files that will be auto generated by depmod at rpm -i time
    for i in alias ccwmap dep ieee1394map inputmap isapnpmap ofmap pcimap seriomap symbols usbmap
    do
      rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.$i
    done

    # Move the devel headers out of the root file system
    mkdir -p $RPM_BUILD_ROOT/usr/src/kernels
    mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir
    ln -sf ../../..$DevelDir $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
}

###
# DO it...
###

# prepare directories
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/boot

cd linux-%{kversion}

%ifarch %all_x86
BuildKernel %make_target %kernel_image netbook
%endif

%ifarch %all_arm
%endif

cd tools/perf
unset LD_AS_NEEDED
chmod a+x util/generate-cmdlist.sh
make
cd ../..




###
### install
###

%define install  %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
%%install


%install

cd linux-%{kversion}

cd tools/perf
make DESTDIR=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT/usr/bin/
mkdir -p $RPM_BUILD_ROOT/usr/libexec/
mv $RPM_BUILD_ROOT/bin/* $RPM_BUILD_ROOT/usr/bin/
mv $RPM_BUILD_ROOT/libexec/* $RPM_BUILD_ROOT/usr/libexec/


rm -rf $RPM_BUILD_ROOT/lib/firmware


###
### clean
###

%clean
rm -rf $RPM_BUILD_ROOT

###
### scripts
###

#
# This macro defines a %%post script for a kernel*-devel package.
#	%%kernel_devel_post <subpackage>
#
%define kernel_devel_post() \
%{expand:%%post %{?1:%{1}-}devel}\
if [ -f /etc/sysconfig/kernel ]\
then\
    . /etc/sysconfig/kernel || exit $?\
fi\
if [ "$HARDLINK" != "no" -a -x /usr/sbin/hardlink ]\
then\
    (cd /usr/src/kernels/%{KVERREL}%{?1:-%{1}} &&\
     /usr/bin/find . -type f | while read f; do\
       hardlink -c /usr/src/kernels/*.fc*.*/$f $f\
     done)\
fi\
%{nil}

# This macro defines a %%posttrans script for a kernel package.
#	%%kernel_variant_posttrans [-v <subpackage>] [-s <s> -r <r>] <mkinitrd-args>
# More text can follow to go at the end of this variant's %%post.
#
%define kernel_variant_posttrans(s:r:v:) \
%{expand:%%posttrans %{?-v*}}\
/sbin/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --rpmposttrans %{KVERREL}%{?-v:-%{-v*}} || exit $?\
%{nil}

#
# This macro defines a %%post script for a kernel package and its devel package.
#	%%kernel_variant_post [-v <subpackage>] [-s <s> -r <r>] <mkinitrd-args>
# More text can follow to go at the end of this variant's %%post.
#
%define kernel_variant_post(s:r:v:) \
%{expand:%%kernel_devel_post %{?-v*}}\
%{expand:%%kernel_variant_posttrans %{?-v*}}\
%{expand:%%post %{?-v*}}\
%{-s:\
if [ `uname -i` == "x86_64" -o `uname -i` == "i386" ] &&\
   [ -f /etc/sysconfig/kernel ]; then\
  /bin/sed -i -e 's/^DEFAULTKERNEL=%{-s*}$/DEFAULTKERNEL=%{-r*}/' /etc/sysconfig/kernel || exit $?\
fi}\
/sbin/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --mkinitrd --depmod --install %{*} %{KVERREL}%{?-v:-%{-v*}} || exit $?\
%{nil}

#
# This macro defines a %%preun script for a kernel package.
#	%%kernel_variant_preun <subpackage>
#
%define kernel_variant_preun() \
%{expand:%%preun %{?1}}\
/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}%{?1:-%{1}} || exit $?\
%{nil}


%ifarch %all_x86

%kernel_variant_preun netbook
%kernel_variant_post -v netbook





%endif

%ifarch %{all_arm}


%endif

%ifnarch %{all_arm}
if [ -x /sbin/ldconfig ]
then
    /sbin/ldconfig -X || exit $?
fi
%endif

###
### file lists
###



# This is %{image_install_path} on an arch where that includes ELF files,
# or empty otherwise.
%define elf_image_install_path %{?kernel_image_elf:%{image_install_path}}

#
# This macro defines the %%files sections for a kernel package
# and its devel packages.
#	%%kernel_variant_files [-k vmlinux] [-a <extra-files-glob>] [-e <extra-nonbinary>] <condition> <subpackage>
#
%define kernel_variant_files(a:e:k:) \
%if %{1}\
%{expand:%%files %{?2}}\
%defattr(-,root,root)\
/%{image_install_path}/%{?-k:%{-k*}}%{!?-k:vmlinuz}-%{KVERREL}%{?2:-%{2}}\
/boot/System.map-%{KVERREL}%{?2:-%{2}}\
#/boot/symvers-%{KVERREL}%{?2:-%{2}}.gz\
/boot/config-%{KVERREL}%{?2:-%{2}}\
%{?-a:%{-a*}}\
%dir /lib/modules/%{KVERREL}%{?2:-%{2}}\
/lib/modules/%{KVERREL}%{?2:-%{2}}/kernel\
/lib/modules/%{KVERREL}%{?2:-%{2}}/build\
/lib/modules/%{KVERREL}%{?2:-%{2}}/source\
%ifnarch %{all_arm}\
/lib/modules/%{KVERREL}%{?2:-%{2}}/vdso\
%endif\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.block\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.dep.bin\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.alias.bin\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.symbols.bin\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.networking\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.order\
/lib/modules/%{KVERREL}%{?2:-%{2}}/modules.builtin*\
%ghost /boot/initrd-%{KVERREL}%{?2:-%{2}}.img\
%{?-e:%{-e*}}\
%{expand:%%files %{?2:%{2}-}devel}\
%defattr(-,root,root)\
%verify(not mtime) /usr/src/kernels/%{KVERREL}%{?2:-%{2}}\
%endif\
%{nil}


%files -n perf
/usr/bin/perf
/usr/libexec/perf-core/


%ifarch %all_x86
%kernel_variant_files 1 netbook
%endif

%ifarch %{all_arm}
%endif


#
openSUSE Build Service is sponsored by