add missing file
[platform/upstream/linux-glibc-devel.git] / packaging / linux-glibc-devel.spec
1
2 Name:           linux-glibc-devel
3 # this confusing version number has no meaning, it's the version
4 # of the Linux kernel where these headers come from
5 Version:        3.4.0
6 Release:        0
7 License:        GPL-2.0
8 Summary:        Linux headers for userspace development
9 # A "-" is not allowed in version
10 %define upstream_version 3.4
11 Url:            http://www.kernel.org/
12 Group:          Development/Libraries/C and C++
13 Source:         %{name}-%{upstream_version}.tar.bz2
14 Source1:        install_all.sh
15 Requires(pre):  coreutils
16 Provides:       kernel-headers
17 Provides:       linux-kernel-headers = %{version}
18 Obsoletes:      linux-kernel-headers < %{version}
19 BuildArch:      noarch
20 BuildRequires:  fdupes
21
22 %description
23 This package provides Linux kernel headers, the kernel API description
24 required for compilation of almost all programs. This is the userspace
25 interface; compiling external kernel modules requires
26 kernel-(flavor)-devel, or kernel-syms to pull in all kernel-*-devel,
27 packages, instead.
28
29 %prep
30 %setup -q -n linux-glibc-devel-%{upstream_version}
31
32 %build
33 cat > version.h <<-BOGUS
34 #ifdef __KERNEL__
35 #error "======================================================="
36 #error "You should not include /usr/include/{linux,asm}/ header"
37 #error "files directly for the compilation of kernel modules."
38 #error ""
39 #error "glibc now uses kernel header files from a well-defined"
40 #error "working kernel version (as recommended by Linus Torvalds)"
41 #error "These files are glibc internal and may not match the"
42 #error "currently running kernel. They should only be"
43 #error "included via other system header files - user space"
44 #error "programs should not directly include <linux/*.h> or"
45 #error "<asm/*.h> as well."
46 #error ""
47 #error "Since Linux 2.6, the kernel module build process has been"
48 #error "updated such that users building modules should not typically"
49 #error "need to specify additional include directories at all."
50 #error ""
51 #error "To build kernel modules, ensure you have the build environment "
52 #error "available either via the kernel-devel and kernel-<flavor>-devel "
53 #error "packages or a properly configured kernel source tree."
54 #error ""
55 #error "Then, modules can be built using:"
56 #error "make -C <path> M=$PWD"
57 #error ""
58 #error "For the currently running kernel there will be a symbolic "
59 #error "link pointing to the build environment located at "
60 #error "/lib/modules/$(uname -r)/build for use as <path>."
61 #error ""
62 #error "If you are seeing this message, your environment is "
63 #error "not configured properly. "
64 #error ""
65 #error "Please adjust the Makefile accordingly."
66 #error "======================================================="
67 #else
68 BOGUS
69 # Get LINUX_VERSION_CODE and KERNEL_VERSION directly from kernel
70 cat usr/include/linux/version.h >> version.h
71 cat >> version.h <<-BOGUS
72 #endif
73 BOGUS
74 cat version.h
75
76 %install
77 cp -a usr %{buildroot}
78 cp -a version.h %{buildroot}/usr/include/linux/
79 # Temporarily exclude i2c header files, which are provided by i2c-tools instead
80 rm -fv   %{buildroot}/usr/include/linux/i2c-dev.h
81 # resolve file conflict with glibc for now
82 rm -fv   %{buildroot}//usr/include/scsi/scsi*
83 # Replace the directory /usr/include/asm with a symlink.
84 # libc contained a symlink /usr/include/asm into kernel-source up to 7.0 (2.1.3)
85 # glibc-devel contained a symlink /usr/include/asm into kernel-source in 7.1 (2.2)
86 # glibc-devel contained a directory /usr/include/asm from 7.2 (2.2.2) up to 10.1/SLES10 (2.4)
87 # The directory moved from glibc-devel to linux-kernel-headers in 10.2 (2.6.18.2)
88 # The directory turned into a symlink in 10.3 (2.6.22)
89 # rpm will remove obsolete files after the post install scripts
90 # A trigger will run after the /usr/include/asm was removed
91 # Create a dummy symlink now for rpmlint happiness, we %%ghost this and create
92 # a proper symlink during %%post:
93 ln -sfn asm-dummy %{buildroot}/usr/include/asm
94 %fdupes %{buildroot}/usr/include
95
96 %postun
97 if test "$1" = 0
98 then
99         rm -f usr/include/asm
100 fi
101 exit 0
102
103 %post
104 asm_link=
105 case "$(uname -m)" in
106         alpha*)  asm_link=alpha      ;;
107         ppc*)    asm_link=powerpc    ;;
108         s390*)   asm_link=s390       ;;
109         ia64)    asm_link=ia64       ;;
110         *arm*)   asm_link=arm        ;;
111         parisc)  asm_link=parisc     ;;
112         *mips*)  asm_link=mips       ;;
113         sparc*)  asm_link=sparc      ;;
114         *)       asm_link=x86  ;;
115 esac
116 if test -L usr/include/asm
117 then
118         case "$(readlink usr/include/asm)" in
119                 *../src/linux/include*)
120                 echo "/usr/include/asm points to kernel-source, waiting for triggerpostun to symlink to asm-$asm_link"
121                 rm -fv usr/include/asm
122                 exit 0
123                 ;;
124         esac
125         : symlink is ok, update it below in case of an arch change
126 elif test -d usr/include/asm
127 then
128         echo "/usr/include/asm is a directory, waiting for triggerpostun to symlink to asm-$asm_link"
129         exit 0
130 fi
131 ln -sfn asm-$asm_link usr/include/asm
132 exit 0
133
134 %triggerpostun -- linux-kernel-headers, glibc-devel < 2.5, libc < 2.2
135 asm_link=
136 case "$(uname -m)" in
137         alpha*)  asm_link=alpha      ;;
138         ppc*)    asm_link=powerpc    ;;
139         s390*)   asm_link=s390       ;;
140         ia64)    asm_link=ia64       ;;
141         *arm*)   asm_link=arm        ;;
142         parisc)  asm_link=parisc     ;;
143         *mips*)  asm_link=mips       ;;
144         sparc*)  asm_link=sparc      ;;
145         *)       asm_link=x86  ;;
146 esac
147 ln -sfn asm-$asm_link usr/include/asm
148 exit 0
149
150 %files
151 %defattr(-,root,root)
152 %{_includedir}/*
153 %ghost %{_includedir}/asm
154
155 %changelog