]> git.ipfire.org Git - ipfire-3.x.git/blame - kernel/kernel.nm
kernel: ARM configuration changes.
[ipfire-3.x.git] / kernel / kernel.nm
CommitLineData
166a6c21 1###############################################################################
802ea3af
MT
2# IPFire.org - An Open Source Firewall Solution #
3# Copyright (C) - IPFire Development Team <info@ipfire.org> #
166a6c21
MT
4###############################################################################
5
15a11c5b 6name = kernel
26814ce0 7version = 3.9.5
a18df16e 8release = 0.3
15a11c5b 9thisapp = linux-%{version}
166a6c21 10
81bb0557 11maintainer = Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
802ea3af
MT
12groups = System/Kernels
13url = http://www.kernel.org/
14license = GPLv2
15summary = The Linux kernel.
166a6c21 16
802ea3af 17description
4c928ab7
MT
18 The kernel package contains the Linux kernel (vmlinuz), the core of any
19 Linux operating system. The kernel handles the basic functions
20 of the operating system: memory allocation, process allocation, device
166a6c21 21 input and output, etc.
802ea3af 22end
166a6c21 23
802ea3af 24# Version helper variables.
bcf38aec
MT
25localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH}
26fullver = %{version}-%{localversion}
802ea3af 27
fe014038
MT
28source_dl = http://www.kernel.org/pub/linux/kernel/v3.x/
29sources = %{thisapp}.tar.xz
802ea3af
MT
30
31build
ebeed08a
MT
32 # icecream cannot be used to compile the kernel.
33 # Because the PaX patch does use GCC plugins to harden the kernel which
34 # are not available on the remote compilers, we need to disable it here.
35 export ICECC=no
36
6b6a8ff6
MT
37 kernel_logo = /usr/share/pixmaps/kernel-logo.ppm
38
802ea3af 39 requires
662414a4 40 asciidoc
81bb0557 41 audit-devel
7f6f4de5 42 bc
7c69f2c2 43 binutils >= 2.23.51.0.3-3
bcf38aec 44 binutils-devel
c6e2a6c8 45 bison
bcf38aec 46 elfutils-devel
c6e2a6c8 47 flex
fe2de317 48 gcc-plugin-devel
6e9df6a3 49 gettext
81bb0557 50 libunwind-devel
802ea3af 51 ncurses-devel
ebeed08a 52 net-tools
7c69f2c2
MT
53 newt-devel
54 pciutils-devel
802ea3af 55 perl
bcf38aec 56 python-devel
7c69f2c2 57 slang-devel
662414a4 58 xmlto
4c928ab7
MT
59
60 /sbin/depmod
6b6a8ff6 61 %{kernel_logo}
bcf38aec
MT
62 end
63
7c69f2c2
MT
64 # i686 needs librmi for cpupower.
65 if "%{DISTRO_ARCH}" == "i686"
66 requires += liblrmi-devel
13c9d848
MT
67 end
68
bcf38aec 69 # A list of kernels to build.
45088e83 70 kernels =
bcf38aec 71
572b4308
MT
72 # Arguments that are passed to the kernel build command.
73 kernel_build_flags =
74
45088e83 75 kernel_target = bzImage
967da24b
MT
76 kernel_image = arch/%{kernel_arch}/boot/%{kernel_target}
77
bcf38aec 78 if "%{DISTRO_ARCH}" == "i686"
1c9b6c79 79 # Build a default and legacy kernel for the
45088e83
MT
80 # i686 architecture.
81 build_kernel_default = 1
1c9b6c79 82 build_kernel_legacy = 1
bcf38aec 83
967da24b 84 kernel_arch = x86
45088e83
MT
85 end
86
c112b2e3
MT
87 if "%{DISTRO_ARCH}" == "x86_64"
88 build_kernel_default = 1
89
967da24b 90 kernel_arch = x86
c112b2e3
MT
91 end
92
45088e83 93 if "%{DISTRO_ARCH}" == "armv5tel"
4c928ab7
MT
94 # ERROR Currently all kernel images are disabled, because they
95 # won't build with the grsecurity patch.
96
4c928ab7 97 # Build a kernel for Marvell Kirkwood-based devices.
c6e2a6c8 98 build_kernel_kirkwood = 1
45088e83 99
967da24b
MT
100 kernel_arch = arm
101 kernel_target = zImage
45088e83 102
572b4308
MT
103 # http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091404.html
104 kernel_build_flags = KALLSYMS_EXTRA_PASS=1
45088e83
MT
105 end
106
13c9d848 107 if "%{DISTRO_ARCH}" == "armv7hl"
7f6f4de5
MT
108 # Build the default unified kernel.
109 build_kernel_default = 1
110
81bb0557
MT
111 # Build a kernel for Samsung's Exynos SoCs.
112 build_kernel_exynos = 1
113
967da24b 114 kernel_arch = arm
7f6f4de5 115 kernel_target = zImage
967da24b
MT
116 end
117
118 # mkimage is a requirement to build uImage images.
119 if "%{kernel_target}" == "uImage"
120 requires += u-boot-tools
13c9d848
MT
121 end
122
45088e83
MT
123 # Build default kernel.
124 if "%{build_kernel_default}" == "1"
125 kernels += default
126 end
127
81bb0557
MT
128 # Build exynos kernel.
129 if "%{build_kernel_exynos}" == "1"
130 kernels += exynos
131 end
132
1c9b6c79
MT
133 # Build legacy kernel.
134 if "%{build_kernel_legacy}" == "1"
135 kernels += legacy
45088e83
MT
136 end
137
4c928ab7
MT
138 # Build ARM kirkwood kernel.
139 if "%{build_kernel_kirkwood}" == "1"
140 kernels += kirkwood
141 end
142
802ea3af 143 prepare_cmds
802ea3af
MT
144 rm -f %{DIR_APP}/localversion-grsec
145
5e856224
MT
146 # Remove -Werror flag to fix ARMv5 build.
147 sed -e "s/-Werror//g" -i grsecurity/Makefile
148
149 # Disable the colorize plugin.
150 # It's generally very nice but it clutters our
151 # logfiles.
152 sed -e "/^COLORIZE_PLUGIN_CFLAGS/d" \
153 -i Makefile
154
802ea3af
MT
155 sed -e "s/^HOSTCFLAGS.*=.*/& -fPIC/g" -i Makefile
156
6b6a8ff6 157 cp -vf %{kernel_logo} \
802ea3af
MT
158 drivers/video/logo/logo_linux_clut224.ppm
159
bcf38aec
MT
160 # Get rid of unwanted files resulting from patch fuzz.
161 find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
162
163 # Remove unnecessary SCM files.
164 find . -name .gitignore -exec rm -f {} \; >/dev/null
165
ebeed08a
MT
166 # This prevents scripts/setlocalversion from mucking with our version numbers.
167 touch .scmversion
168
bcf38aec 169 mkdir -pv configs
4c928ab7
MT
170
171 cd %{DIR_SOURCE}
bcf38aec
MT
172 configure_kernel() {
173 local flavour=${1}
174 local suffix
175 if [ "${flavour}" != "default" ]; then
176 suffix="-${flavour}"
177 fi
178
4c928ab7
MT
179 scripts/configure --kernel-dir=%{DIR_APP} \
180 merge %{DISTRO_ARCH} ${flavour} %{DIR_APP}/configs/config.${flavour}
bcf38aec
MT
181 }
182
183 # Generate configuration files for all kernels we are going to
184 # build.
185 for kernel in %{kernels}; do
186 configure_kernel ${kernel}
187 done
802ea3af
MT
188 end
189
190 build
bcf38aec
MT
191 build_kernel() {
192 local flavour=${1}
193 local suffix
194 local localversion="%{localversion}"
195 local fullversion="%{fullver}"
196 if [ "${flavour}" != "default" ]; then
197 suffix="-${flavour}"
198 localversion="${localversion}.${flavour}"
199 fullversion="${fullversion}.${flavour}"
200 fi
802ea3af 201
ebeed08a
MT
202 # Label the build.
203 sed -i Makefile \
204 -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/"
205
bcf38aec
MT
206 # Clean up the source tree.
207 make mrproper
802ea3af 208
bcf38aec
MT
209 # Install configuration file.
210 cp configs/config.${flavour} .config
c6e2a6c8 211 cat .config
802ea3af 212
bcf38aec 213 # Run the build.
ebeed08a 214 make ARCH=%{kernel_arch} oldnoconfig >/dev/null
572b4308
MT
215 make ARCH=%{kernel_arch} CC="gcc -fno-PIE" %{kernel_target} modules \
216 %{kernel_build_flags} %{PARALLELISMFLAGS}
bcf38aec 217
9d4be168
MT
218 # Compile Flattened Device Tree database
219 case "${DISTRO_ARCH}" in
220 arm*)
221 make ARCH=%{kernel_arch} dtbs
222
223 mkdir -pv %{BUILDROOT}/boot/dtb-${fullversion}
224 for file in arch/arm/boot/dts/*.dtb; do
225 [ -e "${file}" ] || continue
226
227 install -m 644 ${file} %{BUILDROOT}/boot/dtb-${fullversion} || exit 1
228 rm -f ${file}
229 done
230 ;;
231 esac
232
bcf38aec 233 # Install the results.
c4ef5c45 234 mkdir -pv %{BUILDROOT}/boot %{BUILDROOT}/usr/lib/modules/${fullversion}
bcf38aec
MT
235 install -m 755 %{kernel_image} %{BUILDROOT}/boot/vmlinuz-${fullversion}
236 install -m 644 .config %{BUILDROOT}/boot/config-${fullversion}
237 install -m 644 System.map %{BUILDROOT}/boot/System.map-${fullversion}
238
239 # Create empty initramfs (20M).
240 dd if=/dev/zero of=%{BUILDROOT}/boot/initramfs-${fullversion}.img bs=1M count=20
241
242 # Install modules.
81bb0557 243 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT}/usr mod-fw= V=1 \
bcf38aec 244 KERNELRELEASE=${fullversion} modules_install
c8f122e5
MT
245
246 # Install vdso.
247 case "%{DISTRO_ARCH}" in
248 i686)
249 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT} \
250 KERNELRELEASE=${fullversion} vdso_install
251 ;;
252 esac
802ea3af 253
bcf38aec 254 # Create an empty settings file for dracut
7c69f2c2 255 mkdir -p %{BUILDROOT}/etc/ld.so.conf.d
bcf38aec
MT
256 echo "# Placeholder file, no vDSO hwcap entries used in this kernel." \
257 > %{BUILDROOT}/etc/ld.so.conf.d/kernel-${fullversion}.conf
802ea3af 258
bcf38aec
MT
259 # And now the scary looking part.
260 #
261 # Recreate source and build links.
7c69f2c2
MT
262 rm -f %{BUILDROOT}/usr/lib/modules/${fullversion}/{build,source}
263 mkdir -p %{BUILDROOT}/usr/lib/modules/${fullversion}/build
264 ln -sf build %{BUILDROOT}/usr/lib/modules/${fullversion}/source
802ea3af 265
bcf38aec 266 # Create dirs for extra modules.
7c69f2c2 267 mkdir -p %{BUILDROOT}/usr/lib/modules/${fullversion}/extra
802ea3af 268
7c69f2c2 269 cp --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") \
c4ef5c45 270 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
7c69f2c2 271 cp Module.symvers System.map \
c4ef5c45 272 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
7c69f2c2 273 rm -rf %{BUILDROOT}/usr/lib/modules/${fullversion}/build/{Documentation,scripts,include}
bcf38aec 274
7c69f2c2
MT
275 cp .config %{BUILDROOT}/usr/lib/modules/${fullversion}/build
276 cp -a scripts %{BUILDROOT}/usr/lib/modules/${fullversion}/build
c4ef5c45 277 find %{BUILDROOT}/usr/lib/modules/${fullversion}/build/scripts -name "*.o" \
bcf38aec
MT
278 -exec rm -vf {} \;
279
7c69f2c2 280 cp -a --parents arch/%{kernel_arch}/include \
c4ef5c45 281 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
7c69f2c2 282 cp -a include %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include
bcf38aec
MT
283
284 # Make sure we can build external modules.
c4ef5c45
MT
285 touch -r %{BUILDROOT}/usr/lib/modules/${fullversion}/build/Makefile \
286 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/linux/version.h
287 touch -r %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
288 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/autoconf.h
7c69f2c2 289 cp %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
c4ef5c45
MT
290 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/config/auto.conf
291
292 find %{BUILDROOT}/usr/lib/modules/${fullversion} -name "*.ko" -type f | \
bcf38aec
MT
293 xargs chmod u+x
294
bcf38aec 295 # Move all development files to /usr/src.
7c69f2c2
MT
296 mkdir -p %{BUILDROOT}/usr/src/kernels
297 mv %{BUILDROOT}/usr/lib/modules/${fullversion}/build \
bcf38aec 298 %{BUILDROOT}/usr/src/kernels/${fullversion}
7c69f2c2 299 ln -sf ../../../src/kernels/${fullversion} \
c4ef5c45 300 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
bcf38aec 301
81bb0557
MT
302 # Fix permissions.
303 find %{BUILDROOT}/usr/src/kernels -name "modules.order" \
304 -exec chmod 644 {} \;
305
bcf38aec
MT
306 find %{BUILDROOT}/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
307 }
308
309 for kernel in %{kernels}; do
310 build_kernel ${kernel}
311 done
6e9df6a3
MT
312
313 # Build tools.
314 # cpupower
7c69f2c2
MT
315 chmod +x tools/power/cpupower/utils/version-gen.sh
316 make -C tools/power/cpupower CPUFREQ_BENCH=false %{PARALLELISMFLAGS}
317
318 if [ "%{DISTRO_ARCH}" = "x86_64" ]; then
319 pushd tools/power/cpupower/debug/x86_64
320 make %{MAKETUNING}
321 popd
322 elif [ "%{DISTRO_ARCH}" = "i686" ]; then
323 pushd tools/power/cpupower/debug/i386
324 make %{MAKETUNING}
325 popd
45088e83 326 fi
bcf38aec
MT
327 end
328
329 install
4c928ab7
MT
330 # When no kernels are configured, we create a default config
331 # which enables us to install at least the header files.
332 [ -n "%{kernels}" ] || make ARCH=%{kernel_arch} defconfig
333
802ea3af 334 # Install the header files
c8f122e5 335 make ARCH=%{kernel_arch} INSTALL_HDR_PATH=dest headers_install
802ea3af
MT
336 mkdir -pv %{BUILDROOT}/usr/include
337 find dest/include \( -name .install -o -name ..install.cmd \) -delete
338 cp -rv dest/include/* %{BUILDROOT}/usr/include
339
340 # Glibc provides these headers
341 rm -rfv %{BUILDROOT}/usr/include/scsi \
342 %{BUILDROOT}/usr/include/asm*/atomic.h \
343 %{BUILDROOT}/usr/include/asm*/io.h \
344 %{BUILDROOT}/usr/include/asm*/irq.h
345
15a11c5b
MT
346 # Remove all firmware files which are distributed by linux-firmware
347 rm -rfv %{BUILDROOT}/lib/firmware
bcf38aec
MT
348
349 # Install tools.
028e459b 350 make -C tools/perf DESTDIR=%{BUILDROOT} WERROR=0 \
ebeed08a 351 HAVE_CPLUS_DEMANGLE=1 prefix=/usr perfexecdir=lib/perf-core \
7c69f2c2 352 install install-man install-python_ext
6e9df6a3
MT
353
354 # cpupower
7c69f2c2
MT
355 make -C tools/power/cpupower DESTDIR=%{BUILDROOT} libdir=%{libdir} \
356 mandir=%{mandir} CPUFREQ_BENCH=false install
357
358 if [ "%{DISTRO_ARCH}" = "x86_64" ]; then
359 pushd tools/power/cpupower/debug/x86_64
360 install -m 755 centrino-decode \
361 %{BUILDROOT}/usr/bin/centrino-decode
362 install -m 755 powernow-k8-decode \
363 %{BUILDROOT}/usr/bin/powernow-k8-decode
364 popd
365 elif [ "%{DISTRO_ARCH}" = "i686" ]; then
366 pushd tools/power/cpupower/debug/i386
367 install -m 755 centrino-decode \
368 %{BUILDROOT}/usr/bin/centrino-decode
369 install -m 755 powernow-k8-decode \
370 %{BUILDROOT}/usr/bin/powernow-k8-decode
371 popd
45088e83 372 fi
7c69f2c2
MT
373
374 chmod 0755 %{BUILDROOT}%{libdir}/libcpupower.so*
802ea3af
MT
375 end
376end
377
378packages
bcf38aec 379 template KERNEL
aa3ab846 380 kernel_name = kernel
bcf38aec
MT
381 kernel_release = %{fullver}
382
383 summary = The Linux kernel %{kernel_release}.
384
1c9b6c79 385 prerequires
4c928ab7 386 /sbin/depmod
1c9b6c79
MT
387 end
388
389 provides
390 kernel=%{kernel_release}
391 end
392
802ea3af 393 requires
4c928ab7
MT
394 dracut
395 grubby
802ea3af
MT
396 linux-firmware
397 end
ad1ea534 398
bcf38aec
MT
399 files
400 /boot/System.map-%{kernel_release}
9d4be168 401 /boot/dtb-%{kernel_release}
bcf38aec
MT
402 /boot/vmlinuz-%{kernel_release}
403 /boot/initramfs-%{kernel_release}.img
404 /etc/ld.so.conf.d/kernel-%{kernel_release}.conf
c4ef5c45 405 /usr/lib/modules/%{kernel_release}
bcf38aec
MT
406 end
407
aa3ab846 408 _posttrans
c8f9fe35
MT
409 /sbin/new-kernel-pkg --package %{kernel_name} --mkinitrd --dracut --depmod --update %{kernel_release}
410 /sbin/new-kernel-pkg --package %{kernel_name} --rpmposttrans %{kernel_release}
aa3ab846
MT
411 end
412
ad1ea534 413 script posttransin
aa3ab846
MT
414 %{_posttrans}
415 end
416
417 script posttransup
418 %{_posttrans}
419 end
420
421 script postin
c8f9fe35 422 /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release}
aa3ab846
MT
423 end
424
425 script postup
426 /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release}
427 end
428
429 script preun
430 /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{kernel_release}
bcf38aec
MT
431 end
432 end
433
434 template KERNELDEVEL
435 kernel_release = %{fullver}
436
437 summary = Development files of kernel-%{kernel_release}.
438 description
439 %{summary}
440
441 Install this package in order to compile modules for
442 kernel release %{kernel_release}.
443 end
444
10756fd5
MT
445 provides
446 kernel-devel = %{thisver}
447 end
448
bcf38aec
MT
449 filter_requires
450 perl>=[0-9]\:.*
ad1ea534
MT
451 end
452
bcf38aec 453 files
c4ef5c45
MT
454 /usr/lib/modules/%{kernel_release}/build
455 /usr/lib/modules/%{kernel_release}/source
bcf38aec 456 /usr/src/kernels/%{kernel_release}
ad1ea534 457 end
802ea3af 458 end
bcf38aec 459
45088e83 460 if "%{build_kernel_default}" == "1"
7f6f4de5
MT
461 if "%{DISTRO_ARCH}" == "armv7hl"
462 package kernel
463 template KERNEL
58dc2060 464
7f6f4de5
MT
465 kernel_name = kernel
466 kernel_release = %{fullver}
bcf38aec 467
7f6f4de5
MT
468 # Replace the OMAP kernel.
469 obsoletes += kernel-omap < %{kernel_release}
470 conflicts += kernel-omap < %{kernel_release}
471 end
472
473 package kernel-devel
474 template KERNELDEVEL
475
476 kernel_name = kernel
477 kernel_release = %{fullver}
478
479 # Replace the OMAP kernel.
480 obsoletes += kernel-omap-devel < %{kernel_release}
481 conflicts += kernel-omap-devel < %{kernel_release}
482 end
58dc2060 483
7f6f4de5
MT
484 else
485 package kernel
486 template KERNEL
487
488 kernel_name = kernel
489 kernel_release = %{fullver}
490 end
491
492 package kernel-devel
493 template KERNELDEVEL
494
495 kernel_name = kernel
496 kernel_release = %{fullver}
497 end
45088e83 498 end
bcf38aec
MT
499 end
500
81bb0557
MT
501 if "%{build_kernel_exynos}" == "1"
502 package kernel-exynos
503 template KERNEL
504
505 kernel_name = kernel-exynos
506 kernel_release = %{fullver}.exynos
507 end
508
509 package kernel-exynos-devel
510 template KERNELDEVEL
511
512 kernel_name = kernel-exynos
513 kernel_release = %{fullver}.exynos
514 end
515 end
516
1c9b6c79
MT
517 if "%{build_kernel_legacy}" == "1"
518 package kernel-legacy
45088e83 519 template KERNEL
bcf38aec 520
1c9b6c79
MT
521 kernel_name = kernel-legacy
522 kernel_release = %{fullver}.legacy
45088e83
MT
523 end
524
1c9b6c79 525 package kernel-legacy-devel
45088e83
MT
526 template KERNELDEVEL
527
1c9b6c79
MT
528 kernel_name = kernel-legacy
529 kernel_release = %{fullver}.legacy
45088e83 530 end
bcf38aec
MT
531 end
532
4c928ab7
MT
533 if "%{build_kernel_kirkwood}" == "1"
534 package kernel-kirkwood
535 template KERNEL
536
537 kernel_name = kernel-kirkwood
538 kernel_release = %{fullver}.kirkwood
539 end
540
541 package kernel-kirkwood-devel
542 template KERNELDEVEL
543
544 kernel_name = kernel-kirkwood
545 kernel_release = %{fullver}.kirkwood
546 end
547 end
548
802ea3af 549 package kernel-headers
802ea3af
MT
550 summary = Header files of the kernel release %{fullver}.
551 desciption = %{summary}
c698e4be
MT
552
553 files
554 /usr/include
555 end
802ea3af 556 end
bcf38aec 557
ebeed08a
MT
558 package kernel-tools
559 summary = Assortment of tools for the Linux kernel.
560 description = %{summary}
561
562 filter_requires
563 perl>=[0-9]\:.*
564 end
565
566 files
567 /
568 !/boot
ebeed08a 569 !/usr/include
c4ef5c45 570 !/usr/lib/modules
ebeed08a 571 !/usr/src
fe2de317
MT
572 !/usr/src/debug
573 !/usr/lib/debug
ebeed08a
MT
574 end
575 end
802ea3af 576end