File drm.spec of Package drm

#
# spec file for package drm
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild
# needssslcertforbuild

%define rename_symbols	1
%define rename_modules	1

%define kernel_version 3.17.8

Name:           drm
BuildRequires:  kernel-source %kernel_module_package_buildreqs
License:        GPL-2.0
Url:            http://kernel.org/
Group:          System/Kernel
AutoReqProv:    on
Summary:        Backported drm kernel modules
ExclusiveArch:  x86_64
Version:        3.17.8
Release:        0
Source0:        drm-%{kernel_version}.tar.xz
Source1:        Makefile
Source2:        Module.supported
Source3:        preamble
#
Source10:       intel-mid.h
Source20:       drm-rpmlintrc
# upstream fix patches
Patch1:         0001-drm-i915-Rework-ppgtt-init-to-no-require-an-aliasing.patch
Patch2:         0002-drm-i915-Rework-GPU-reset-sequence-to-match-driver-l.patch
Patch3:         0003-drm-i915-call-lpt_init_clock_gating-on-BDW-too.patch
Patch4:         0004-drm-i915-bdw-Apply-workarounds-in-render-ring-init-f.patch
Patch5:         0005-drm-i915-bdw-Export-workaround-data-to-debugfs.patch
Patch6:         0006-drm-i915-Add-IS_BDW_GT3-macro.patch
Patch7:         0007-drm-i915-bdw-WaDisableFenceDestinationToSLM.patch
Patch8:         0008-drm-i915-Build-workaround-list-in-ring-initializatio.patch
Patch9:         0009-drm-i915-Check-workaround-status-on-dfs-read-time.patch
Patch10:        0010-drm-i915-Init-PPGTT-before-context-enable.patch
# SUSE xen flavor fixes
Patch50:        xen3-patch-2.6.29
Patch51:        xen3-patch-2.6.31
Patch52:        xen3-patch-2.6.35
Patch53:        xen3-patch-3.1
Patch54:        xen3-patch-3.4
Patch55:        xen3-patch-3.5
Patch56:        xen3-patch-3.8
Patch57:        xen3-patch-3.10
Patch58:        xen3-patch-3.14
# 3.14 build fix
Patch100:       revert-acpi-dsm-helper.diff
Patch101:       revert-acpi_os_ioremap.diff
Patch102:       revert-drm-replace_fops.diff
Patch103:       revert-clflushopt.diff
# 3.16 build fix
Patch104:       revert-smp_mb.diff
Patch105:       kill-acpi_video_verify_backlight_support.diff
Patch106:       disable-vgacon-kickout.diff
Patch107:       build-interval-tree.diff
Patch108:       add-simple_dname.diff
# 3.17 build fix
Patch109:       revert-ktime_mono_to_real.diff
Patch110:       revert-hlist_add_behind_rcu.diff
Patch111:       revert-drm_buf_export-reservation.diff
Patch112:       revert-i915-ktime_get_raw_ns.diff
Patch113:       hack-acpi_target_system_state.diff
# build stubs
Patch200:       Makefile-include-fixes.diff
Patch201:       drm-Makefile-reduce.diff
Patch202:       enable-drm-i915-fbdev.diff
Patch203:       makefile-include-renames.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%kernel_module_package -p preamble

%description
Backported drm kernel modules for Intel Media SDK.

%prep
%setup -q -c -n %{name} -T -a 0
mkdir -p include/asm
cp %{S:10} include/asm
#
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
#
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
#
%patch100 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p1
%patch108 -p1
%patch109 -p1
%patch110 -p1
%patch111 -p1
%patch112 -p1
%patch113 -p1
#
cp %{S:1} .
cp %{S:2} .
ln -s /usr/src/linux/drivers/platform drivers/
%patch200 -p1
%patch201 -p1
%patch202 -p1
#
%if %{rename_symbols}
%patch203 -p1
# rename symbols
echo '#ifndef _DRM_RENAME_SYMBOLS_H
#define _DRM_RENAME_SYMBOLS_H' > include/rename-symbols.h
find drivers/gpu/drm -name '*.c' | xargs grep 'EXPORT_SYMBOL.*(' | \
  grep -v 'EXPORT_SYMBOL.*(i915_' | \
  sed -e's/^.*(\(.*\));.*$/#define \1 _drm_kmp_\1/g' >> include/rename-symbols.h
echo '#endif' >> include/rename-symbols.h
%endif
#
%if %{rename_modules}
sed -i -e's/drm\.ko/drm-kmp-drm.ko/' \
    -e's/drm_kms_helper\.ko/drm-kmp-drm_kms_helper.ko/' \
    -e's/ttm\.ko/drm-kmp-ttm\.ko/' \
    Module.supported
%endif

%build
# copy to each flavor
set -- *
for flavor in %flavors_to_build; do
  mkdir -p build-$flavor && cp -al "$@" build-$flavor
done
for flavor in %flavors_to_build; do
  make %{?jobs:-j %jobs} -C /usr/src/linux-obj/%_target_cpu/$flavor \
    M=$(pwd)/build-$flavor \
    CONFIG_DRM_I915_FBDEV=y \
    CONFIG_DRM_KMS_FB_HELPER=y \
    CONFIG_DRM_RADEON= \
    CONFIG_DRM_TDFX= \
    CONFIG_DRM_R128= \
    CONFIG_DRM_I810= \
    CONFIG_DRM_MGA= \
    CONFIG_DRM_SIS= \
    CONFIG_DRM_VIA= \
    CONFIG_DRM_SAVAGE=
done

%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=updates
export BRP_PESIGN_FILES="*.ko"
for flavor in %flavors_to_build; do
  make -C /usr/src/linux-obj/%_target_cpu/$flavor \
    M=$(pwd)/build-$flavor \
    modules_install \
    CONFIG_DRM_I915_FBDEV=y \
    CONFIG_DRM_KMS_FB_HELPER=y \
    CONFIG_DRM_RADEON= \
    CONFIG_DRM_TDFX= \
    CONFIG_DRM_R128= \
    CONFIG_DRM_I810= \
    CONFIG_DRM_MGA= \
    CONFIG_DRM_SIS= \
    CONFIG_DRM_VIA= \
    CONFIG_DRM_SAVAGE=
done
%if %{rename_modules}
# rename some modules to avoid conflict
for i in $(find $RPM_BUILD_ROOT/lib/modules -name '*.ko'); do
    m=$(basename $i)
    case $m in
	drm*.ko|ttm*.ko)
	    mv $i $(dirname $i)/drm-kmp-$m;;
    esac
done
%endif

%changelog