LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File linux-kernel-headers.spec.in of Package orig-linux-kernel-headers (Project Ports:ARM:Base:build:cross)

#
# spec file for package linux-kernel-headers (Version 2.6.32)
#
# Copyright (c) 2009 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
%define origname linux-kernel-headers

Name:           linux-kernel-headers
License:        GPL v2 only
Summary:        Linux Kernel Headers
Group:          Development/Libraries/C and C++
ExcludeArch:    %arm
BuildArch:      noarch
# this confusing version number has no meaning
Version:        2.6.32
Release:        1
Url:            http://www.kernel.org/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       kernel-headers
PreReq:         coreutils
Source:         %{origname}-%{version}.tar.bz2
Source1:        linux-kernel-headers_install_all.sh
Patch0:         linux-kernel-headers.SuSE.TIOCGDEV.patch
Patch1:         linux-kernel-headers.SuSE.SO_BSDCOMPAT.patch

%description
This package provides Linux kernel headers, the kernel API description
required for compilation of almost all programs. This is the userspace
interface; compiling external kernel modules requires kernel-source
instead.


# start if != "linux-kernel-headers"
%if "%{name}" != "linux-kernel-headers"

%define HOST %(echo %{_target_cpu}|sed -e "s/parisc/hppa/" -e "s/i.86/i586/" -e "s/ppc/powerpc/")-suse-linux
%define _cross_target_cpu %{_target_cpu}
%define _prefix /usr

%define TARGET %(echo %{name}|sed -e "s/cross-\\(.*\\)-linux-kernel-headers/\\1/;s/-/_/g;s/parisc/hppa/;s/i.86/i586/;s/ppc/powerpc/")
%define _cross_target_cpu %{TARGET}

%if "%{TARGET}" == "sh4"
%define _cross_target_cpu sh
%endif

%if "%{TARGET}" == "i586"
%define _cross_target_cpu x86
%endif

%if "%{TARGET}" == "x86_64"
%define _cross_target_cpu x86
%endif

#
# TARGET-TUPLE
#
%if "%{TARGET}" == "avr" || "%{TARGET}" == "spu"
%define TARGET_OS %{TARGET}
%else
%define TARGET_OS %{TARGET}-suse-linux-gnu
%endif
%if "%{TARGET}" == "armv5tel"
%define TARGET_OS %{TARGET}-suse-linux-gnueabi
%define _cross_target_cpu arm
%endif

%if "%{TARGET}" == "armv7l"
%define TARGET_OS %{TARGET}-suse-linux-gnueabi
%define _cross_target_cpu arm
%endif


%define _prefix /opt/cross/%{TARGET_OS}/sys-root/usr

# end if != "linux-kernel-headers"
%endif


%prep
%setup -q -n %{origname}-%{version}
%patch0
%patch1

%build
cat > version.h <<-BOGUS
#ifdef __KERNEL__
#error "======================================================="
#error "You should not include /usr/include/{linux,asm}/ header"
#error "files directly for the compilation of kernel modules."
#error ""
#error "glibc now uses kernel header files from a well-defined"
#error "working kernel version (as recommended by Linus Torvalds)"
#error "These files are glibc internal and may not match the"
#error "currently running kernel. They should only be"
#error "included via other system header files - user space"
#error "programs should not directly include <linux/*.h> or"
#error "<asm/*.h> as well."
#error ""
#error "To build kernel modules please do the following:"
#error ""
#error " o Have the kernel sources installed"
#error ""
#error " o Make sure that the symbolic link"
#error "   /lib/modules/\`uname -r\`/build exists and points to"
#error "   the matching kernel source directory"
#error ""
#error " o When compiling, make sure to use the following"
#error "   compiler option to use the correct include files:"
#error ""
#error "   -I/lib/modules/\`uname -r\`/build/include"
#error ""
#error "   instead of"
#error ""
#error "   -I/usr/include/linux"
#error ""
#error "   Please adjust the Makefile accordingly."
#error "======================================================="
#else
#define UTS_RELEASE "%{version}"
#define LINUX_VERSION_CODE `bash -c 'v="%{version}";read a b c d <<< "${v//./ }";echo "$(( (($a) << 16) + (($b) << 8) + ($c) ))"'`
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
BOGUS
cat version.h

%install
%if "%{_cross_target_cpu}" != "%{_target_cpu}"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/include
cp -a $RPM_BUILD_DIR/%{origname}-%{version}/usr/include/asm-%{_cross_target_cpu} $RPM_BUILD_ROOT%{_prefix}/include/asm

rm -f $RPM_BUILD_ROOT%{_prefix}/include/asm-generic
cp -a $RPM_BUILD_DIR/%{origname}-%{version}/usr/include/asm-generic $RPM_BUILD_ROOT%{_prefix}/include/
rm -f $RPM_BUILD_ROOT%{_prefix}/usr/include/linux
cp -a $RPM_BUILD_DIR/%{origname}-%{version}/usr/include/linux $RPM_BUILD_ROOT%{_prefix}/include/linux
%else

rm -rf    $RPM_BUILD_ROOT
mkdir     $RPM_BUILD_ROOT
cp -a usr $RPM_BUILD_ROOT
cp -a version.h $RPM_BUILD_ROOT/usr/include/linux/
# Temporarily exclude i2c header files, which are provided by i2c-tools instead
rm -fv   $RPM_BUILD_ROOT/usr/include/linux/i2c-dev.h
# resolve file conflict with glibc for now
rm -fv   $RPM_BUILD_ROOT//usr/include/scsi/scsi*
# Replace the directory /usr/include/asm with a symlink.
# libc contained a symlink /usr/include/asm into kernel-source up to 7.0 (2.1.3)
# glibc-devel contained a symlink /usr/include/asm into kernel-source in 7.1 (2.2)
# glibc-devel contained a directory /usr/include/asm from 7.2 (2.2.2) up to 10.1/SLES10 (2.4)
# The directory moved from glibc-devel to linux-kernel-headers in 10.2 (2.6.18.2)
# The directory turned into a symlink in 10.3 (2.6.22)
# rpm will remove obsolete files after the post install scripts
# A trigger will run after the /usr/include/asm was removed
%endif

%if "%{_cross_target_cpu}" != "%{_target_cpu}"
%else
%postun
echo "postun %{name}-%{version}-%{release} $0 $*"
if test "$1" = 0
then
	rm -f usr/include/asm
fi
exit 0
%endif

%if "%{_cross_target_cpu}" != "%{_target_cpu}"
%else
%post
echo "post %{name}-%{version}-%{release} $0 $*"
asm_link=
case "$(uname -m)" in
	alpha*)  asm_link=alpha      ;;
	ppc*)    asm_link=powerpc    ;;
	s390*)   asm_link=s390       ;;
	ia64)    asm_link=ia64       ;;
	*arm*)   asm_link=arm        ;;
	parisc)  asm_link=parisc     ;;
	*mips*)  asm_link=mips       ;;
	*sparc*) asm_link=bi-sparc64 ;;
	*)       asm_link=x86  ;;
esac
if test -L usr/include/asm
then
	case "$(readlink usr/include/asm)" in
		*../src/linux/include*)
		echo "/usr/include/asm points to kernel-source, waiting for triggerpostun to symlink to asm-$asm_link"
		rm -fv usr/include/asm
		exit 0
		;;
	esac
	: symlink is ok, update it below in case of an arch change
elif test -d usr/include/asm
then
	echo "/usr/include/asm is a directory, waiting for triggerpostun to symlink to asm-$asm_link"
	exit 0
fi
ln -sfn asm-$asm_link usr/include/asm
exit 0
%endif

%if "%{_cross_target_cpu}" != "%{_target_cpu}"
%else
%triggerpostun -- linux-kernel-headers < 2.6.22 , glibc-devel < 2.5, libc < 2.2
echo "triggerpostun %{name}-%{version}-%{release} $# $0 $*"
asm_link=
case "$(uname -m)" in
	alpha*)  asm_link=alpha      ;;
	ppc*)    asm_link=powerpc    ;;
	s390*)   asm_link=s390       ;;
	ia64)    asm_link=ia64       ;;
	*arm*)   asm_link=arm        ;;
	parisc)  asm_link=parisc     ;;
	*mips*)  asm_link=mips       ;;
	*sparc*) asm_link=bi-sparc64 ;;
	*)       asm_link=x86  ;;
esac
ln -sfvn asm-$asm_link usr/include/asm
exit 0
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{_prefix}/include/*
%if "%{_cross_target_cpu}" != "%{_target_cpu}"
%dir /opt/cross
%dir /opt/cross/%{TARGET_OS}
%dir /opt/cross/%{TARGET_OS}/sys-root
%dir /opt/cross/%{TARGET_OS}/sys-root/usr
%dir /opt/cross/%{TARGET_OS}/sys-root/usr/include
%endif


%changelog