921734a2cba7903dada52002b27585612093aea6
[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.10
6 Release:        0
7 License:        GPL-2.0, GPL-2.1
8 Summary:        Linux headers for userspace development
9 # A "-" is not allowed in version
10 Url:            http://www.kernel.org/
11 Group:          Development/Libraries
12 Source:         %{name}-%{version}.tar.bz2
13 Source1:        install_all.sh
14 Source1001:     linux-glibc-devel.manifest
15 Requires(pre):  coreutils
16 Provides:       kernel-headers
17 Provides:       linux-kernel-headers = %{version}
18 Obsoletes:      linux-kernel-headers < %{version}
19 BuildRequires:  fdupes
20
21 %description
22 This package provides Linux kernel headers, the kernel API description
23 required for compilation of almost all programs. This is the userspace
24 interface; compiling external kernel modules requires
25 kernel-(flavor)-devel, or kernel-syms to pull in all kernel-*-devel,
26 packages, instead.
27
28 %prep
29 %setup -q -n linux-glibc-devel-%{version}
30 cp %{SOURCE1001} .
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=%{_arch}
105 # Note that you must use the %{_arch} macro instead of "uname -m"
106 # to handle a software platform environment that consists of arm64-based Linux kernel
107 # and arm32-based Platform packages.
108 case "$asm_link" in
109         *alpha*)   asm_link=alpha      ;;
110         *ppc*)     asm_link=powerpc    ;;
111         *s390*)    asm_link=s390       ;;
112         *ia64*)    asm_link=ia64       ;;
113         *arm*)     asm_link=arm        ;;
114         *aarch64*) asm_link=arm64      ;;
115         *parisc*)  asm_link=parisc     ;;
116         *mips*)    asm_link=mips       ;;
117         *sparc* )  asm_link=sparc      ;;
118         *)         asm_link=x86        ;;
119 esac
120 if test -L usr/include/asm
121 then
122         case "$(readlink usr/include/asm)" in
123                 *../src/linux/include*)
124                 echo "/usr/include/asm points to kernel-source, waiting for triggerpostun to symlink to asm-$asm_link"
125                 rm -fv usr/include/asm
126                 exit 0
127                 ;;
128         esac
129         : symlink is ok, update it below in case of an arch change
130 elif test -d usr/include/asm
131 then
132         echo "/usr/include/asm is a directory, waiting for triggerpostun to symlink to asm-$asm_link"
133         exit 0
134 fi
135 ln -sfn asm-$asm_link usr/include/asm
136 exit 0
137
138 %triggerpostun -- linux-kernel-headers, glibc-devel < 2.5, libc < 2.2
139 asm_link=%{_arch}
140 # Note that you must use the %{_arch} macro instead of "uname -m"
141 # to handle a software platform environment that consists of arm64-based Linux kernel
142 # and arm32-based Platform packages.
143 case "$asm_link" in
144         *alpha*)   asm_link=alpha      ;;
145         *ppc*)     asm_link=powerpc    ;;
146         *s390*)    asm_link=s390       ;;
147         *ia64*)    asm_link=ia64       ;;
148         *arm*)     asm_link=arm        ;;
149         *aarch64*) asm_link=arm64      ;;
150         *parisc*)  asm_link=parisc     ;;
151         *mips*)    asm_link=mips       ;;
152         *sparc* )  asm_link=sparc      ;;
153         *)         asm_link=x86        ;;
154 esac
155 ln -sfn asm-$asm_link usr/include/asm
156 exit 0
157
158 %files
159 %manifest %{name}.manifest
160 %defattr(-,root,root)
161 %{_includedir}/*
162 %ghost %{_includedir}/asm
163
164 %changelog
165
166 * Mon Mar 09 2020 Geunsik Lim <geunsik.lim@samsung.com>
167 - Replaced "uname -m" with "_arch" macro to build platform packages.