kernel: update to 4.9.59
[ipfire-2.x.git] / lfs / linux
CommitLineData
df5e82b3 1###############################################################################
df5e82b3 2# #
70df8302 3# IPFire.org - A linux based firewall #
ba957627 4# Copyright (C) 2007-2017 IPFire Team <info@ipfire.org> #
70df8302
MT
5# #
6# This program is free software: you can redistribute it and/or modify #
df5e82b3 7# it under the terms of the GNU General Public License as published by #
70df8302 8# the Free Software Foundation, either version 3 of the License, or #
df5e82b3
MT
9# (at your option) any later version. #
10# #
70df8302 11# This program is distributed in the hope that it will be useful, #
df5e82b3
MT
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
70df8302 17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
df5e82b3 18# #
df5e82b3
MT
19###############################################################################
20
21###############################################################################
22# Definitions
23###############################################################################
24
25include Config
26
35f59319 27VER = 4.9.59
7331b247
AF
28RPI_PATCHES = 3.14.79-grsec-ipfire1
29A7M_PATCHES = 3.14.79-grsec-ipfire1
35f59319 30GRS_PATCHES = grsecurity-3.1-4.9.59-ipfire1.patch.xz
df4eb191 31
df5e82b3
MT
32
33THISAPP = linux-$(VER)
79f94395 34DL_FILE = linux-$(VER).tar.xz
a2cb3a33 35DL_FROM = $(URL_IPFIRE)
df5e82b3
MT
36DIR_APP = $(DIR_SRC)/$(THISAPP)
37CFLAGS =
38CXXFLAGS =
39
4bdbf22e 40PAK_VER = 73
acdf0e61 41DEPS = ""
bd9921dd 42
dc7d6b20 43ifeq "$(BUILD_ARCH)" "i586"
ba583892 44 KERNEL_ARCH = i386
fdfddd64 45else
dc7d6b20
MT
46 KERNEL_ARCH = $(BUILD_ARCH)
47endif
48
49ifeq "$(BUILD_ARCH)" "aarch64"
50 HEADERS_ARCH = arm64
51else
52 HEADERS_ARCH = $(BUILD_PLATFORM)
ba583892
MT
53endif
54
fdf0c7c1 55VERSUFIX=ipfire$(KCFG)
b0d0b681 56
991d11d7 57ifeq "$(TOOLCHAIN)" "1"
cc24c14b 58 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)-tools
51f9e7ac 59 HEADERS_PREFIX = /tools
51f9e7ac
MT
60else
61 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
cc24c14b 62 HEADERS_PREFIX = /usr
51f9e7ac
MT
63endif
64
bc8fe5ff
AF
65ifeq "$(KCFG)" ""
66LASTKERNEL=1
67endif
68ifeq "$(KCFG)" "-kirkwood"
69LASTKERNEL=1
70endif
71
52066677
MT
72# The buildsystem does not correctly detect if our compiler supports plugins
73export DISABLE_PAX_PLUGINS=y
74
df5e82b3
MT
75###############################################################################
76# Top-level Rules
77###############################################################################
78objects =$(DL_FILE) \
68c2cbed 79 rpi-patches-$(RPI_PATCHES).patch.xz \
932a34e5 80 arm7-multi-patches-$(A7M_PATCHES).patch.xz \
68c2cbed 81 $(GRS_PATCHES)
fdecb907 82
e69f1bf2 83
932a34e5
AF
84$(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE)
85rpi-patches-$(RPI_PATCHES).patch.xz = $(URL_IPFIRE)/rpi-patches-$(RPI_PATCHES).patch.xz
86arm7-multi-patches-$(A7M_PATCHES).patch.xz = $(URL_IPFIRE)/arm7-multi-patches-$(A7M_PATCHES).patch.xz
87$(GRS_PATCHES) = $(URL_IPFIRE)/$(GRS_PATCHES)
e69f1bf2 88
35f59319 89$(DL_FILE)_MD5 = 8913eb1ac84eb366d23f72ba8166018a
7331b247
AF
90rpi-patches-$(RPI_PATCHES).patch.xz_MD5 = a02a7fd54c642c1e3578a00ed22f54f8
91arm7-multi-patches-$(A7M_PATCHES).patch.xz_MD5 = 6c3b11e51caa278dbeacd1e23c2b171b
35f59319 92$(GRS_PATCHES)_MD5 = a9897465893229fea1a71d3bdfdc2659
15fa4c32 93
27a271b2 94
df5e82b3
MT
95install : $(TARGET)
96
97check : $(patsubst %,$(DIR_CHK)/%,$(objects))
98
99download :$(patsubst %,$(DIR_DL)/%,$(objects))
100
101md5 : $(subst %,%_MD5,$(objects))
102
f418a984
AF
103dist:
104 @$(PAK)
df5e82b3
MT
105###############################################################################
106# Downloading, checking, md5sum
107###############################################################################
108
109$(patsubst %,$(DIR_CHK)/%,$(objects)) :
110 @$(CHECK)
111
112$(patsubst %,$(DIR_DL)/%,$(objects)) :
113 @$(LOAD)
114
115$(subst %,%_MD5,$(objects)) :
116 @$(MD5)
117
118###############################################################################
119# Installation Details
120###############################################################################
121
122$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
123 @$(PREBUILD)
fdecb907 124 @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
b0d0b681 125
51f9e7ac 126 ln -svf linux-$(VER) $(DIR_SRC)/linux
3a1019f6 127
3c4d4ed0 128 # Linux Intermediate Queueing Device
91648bd1 129 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9-imq.diff
bd9921dd 130
3a1019f6 131 # Layer7-patch
ddc7b38c 132 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.13-layer7.patch
91648bd1 133
e898660a 134
e40740b2 135ifneq "$(KCFG)" "-headers"
bb5f0bf8 136 # Grsecurity-patches
68c2cbed 137 cd $(DIR_APP) && xz -c -d $(DIR_DL)/$(GRS_PATCHES) | patch -Np1
bb5f0bf8 138 cd $(DIR_APP) && rm localversion-grsec
e40740b2 139endif
bb5f0bf8 140
e2b79cd1 141 # DVB Patches
e2b79cd1
AF
142 cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch
143
d33aa452 144 # Wlan Patches
91648bd1
AF
145 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/backports-4.2.6-1_ath10k_remove_logspam.patch
146 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-ath_ignore_eeprom_regd.patch
147 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-iwlwifi-noibss_only_on_radar_chan.patch
148 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-rt2x00usb_suppress_queue_warnings.patch
149# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.39-add_libertas_uap.patch
d33aa452
AF
150
151 # mISDN Patches
152 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN_hfc-s_add_id.patch
153 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN-hfcusb-reportl1down.patch
154
40c7cdd3 155 # Add LED trigger
94112e8b 156 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.16-ledtrig_netdev.patch
40c7cdd3 157
fcffac13
AF
158 # Fix igb and e1000e crash
159 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.17-igb-e1000e_fix_lock_at_update_stats.patch
d52f1169 160
1e67b3c3 161 # cs5535audio spams syslog if no ac97 was present (geos router)
91648bd1 162 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8_cs5535audio_fix_logspam_on_geos.patch
1e67b3c3 163
e583643a 164 # Add PC Engines APU led support
91648bd1 165 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-apu_leds.patch
9a7a6c52 166
87837787 167 # Fix uevent PHYSDEVDRIVER
91648bd1 168 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-2.6.32.27_mcs7830-fix-driver-name.patch
bd64e2a0 169
bc8fe5ff 170ifeq "$(KCFG)" "-kirkwood"
74194478 171 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.10-mv_cesa_disable_failing_hmac_sha1.patch
21147a00 172 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-kirkwood_legacy_boot.patch
8e6fb99d
AF
173endif
174
7284262a 175ifeq "$(KCFG)" "-multi"
7284262a 176 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10-smsc95xx-add_mac_addr_param.patch
9bfde8ed 177
932a34e5
AF
178 # Apply Arm7-multiarch kernel patches.
179 cd $(DIR_APP) && xzcat $(DIR_DL)/arm7-multi-patches-$(A7M_PATCHES).patch.xz | patch -Np1
aa668423 180 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/arm-multi-grsec-compile-fixes.patch
7726e3a6 181
ffeb717f
AF
182 # Install switch api userspace header
183 cd $(DIR_APP) && install -v -m644 include/uapi/linux/switch.h /usr/include/linux/
8602108e 184
fdecb907
AF
185endif
186
187ifeq "$(KCFG)" "-rpi"
188 # Apply Raspberry Pi kernel patches.
189 cd $(DIR_APP) && xzcat $(DIR_DL)/rpi-patches-$(RPI_PATCHES).patch.xz | patch -Np1
ad73e5ec 190 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-rpi-suspend-not-inline.patch
7fbc483a 191endif
8e6fb99d 192
0b4976e2
AF
193 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-amba-fix.patch
194
cee50e12 195ifeq "$(KCFG)" "-headers"
51f9e7ac
MT
196 # Install the header files
197 cd $(DIR_APP) && make ARCH=$(HEADERS_ARCH) INSTALL_HDR_PATH=dest headers_install
198 -mkdir -pv $(BUILDROOT)/$(HEADERS_PREFIX)/include
199 cd $(DIR_APP) && find dest/include \( -name .install -o -name ..install.cmd \) -delete
200 cd $(DIR_APP) && cp -rv dest/include/* $(BUILDROOT)/$(HEADERS_PREFIX)/include
201else
202
aa2049e5
MT
203 # Install ipfire logo
204 cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
205 drivers/video/logo/logo_linux_clut224.ppm
206
df5e82b3 207 # Cleanup kernel source
dc7d6b20 208 cp $(DIR_SRC)/config/kernel/kernel.config.$(BUILD_ARCH)-$(VERSUFIX) $(DIR_APP)/.config
6f67c28d
MT
209 cd $(DIR_APP) && make oldconfig
210 cd $(DIR_APP) && make clean
fdecb907 211 cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ -$(VERSUFIX)/' Makefile
3a1019f6 212
bc8fe5ff 213ifeq "$(KCFG)" "-kirkwood"
6f67c28d 214 cd $(DIR_APP) && make $(MAKETUNING) uImage modules
8e6fb99d 215 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
bc8fe5ff
AF
216 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/uImage-$(VERSUFIX)
217else
7284262a 218ifeq "$(KCFG)" "-multi"
6f67c28d 219 cd $(DIR_APP) && make $(MAKETUNING) zImage modules
7284262a
AF
220 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
221 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/zImage-$(VERSUFIX)
fdecb907
AF
222else
223ifeq "$(KCFG)" "-rpi"
6f67c28d 224 cd $(DIR_APP) && make $(MAKETUNING) zImage modules
74194478
AF
225 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
226 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/kernel.img
92655908 227else
6f67c28d 228 cd $(DIR_APP) && make $(MAKETUNING) bzImage modules
ba583892 229 cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/bzImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
92655908 230endif
3c4d4ed0 231endif
a158cbbb
AF
232endif
233
2b2e03ed
AF
234 cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
235 cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
6f67c28d
MT
236 cd $(DIR_APP) && make $(MAKETUNING) modules_install
237 cd $(DIR_APP) && make $(MAKETUNING) firmware_install
376e42ce 238
dc7d6b20 239ifeq "$(BUILD_PLATFORM)" "arm"
6f67c28d 240 cd $(DIR_APP) && make $(MAKETUNING) dtbs
7284262a
AF
241 cd $(DIR_APP) && for f in $$(find arch/arm/boot/dts/ -name *.dtb); do \
242 mkdir -p /boot/dtb-$(VER)-$(VERSUFIX) ; \
243 install -m 644 $$f /boot/dtb-$(VER)-$(VERSUFIX)/ ; \
244 done
245endif
246
bc8fe5ff
AF
247ifeq "$(LASTKERNEL)" "1"
248 # Only do this once
81e974f3 249 cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
d644d86f 250
efa8b615 251 # Blacklist matroxfb_base
ba109afd 252 echo "blacklist matroxfb_base" >> /etc/modprobe.d/framebuffer.conf
aa1dd878 253 # Blacklist old framebuffer modules
030a57c5 254 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video -name *fb.ko); do \
ba109afd 255 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
030a57c5 256 done
aa1dd878
AF
257 # Blacklist new drm framebuffer modules
258 for f in $$(ls -1 /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm/*/*.ko); do \
ba109afd 259 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
aa1dd878 260 done
ba109afd 261 sed -i -e "s|.ko||g" /etc/modprobe.d/framebuffer.conf
e2e106be
AF
262
263 # Blacklist isdn modules
264 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn -name *.ko); do \
ba109afd 265 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/isdn.conf ; \
e2e106be 266 done
ba109afd 267 sed -i -e "s|.ko||g" /etc/modprobe.d/isdn.conf
78a51aaf
AF
268
269 # Disable ipv6 at runtime
ba109afd 270 echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6.conf
26c1cc71 271endif
51f9e7ac 272endif
8885467f 273
22820bf2
AF
274 #force new build of external modules and initrd if the kernel was rebuild
275 -rm -f /usr/src/log/*-kmod-$(VER)-$(VERSUFIX)
276 -rm -f /usr/src/log/linux-initrd-$(VER)-$(VERSUFIX)
277
d644d86f 278 @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/netfilter-layer7-*
df5e82b3 279 @$(POSTBUILD)