kernel: update to 4.14.40
[ipfire-2.x.git] / lfs / linux
1 ###############################################################################
2 #                                                                             #
3 # IPFire.org - A linux based firewall                                         #
4 # Copyright (C) 2007-2018  IPFire Team <info@ipfire.org>                      #
5 #                                                                             #
6 # This program is free software: you can redistribute it and/or modify        #
7 # it under the terms of the GNU General Public License as published by        #
8 # the Free Software Foundation, either version 3 of the License, or           #
9 # (at your option) any later version.                                         #
10 #                                                                             #
11 # This program is distributed in the hope that it will be useful,             #
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           #
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
18 #                                                                             #
19 ###############################################################################
20
21 ###############################################################################
22 # Definitions
23 ###############################################################################
24
25 include Config
26
27 VER         = 4.14.40
28 ARM_PATCHES = 4.14.40-ipfire0
29
30 THISAPP    = linux-$(VER)
31 DL_FILE    = linux-$(VER).tar.xz
32 DL_FROM    = $(URL_IPFIRE)
33 DIR_APP    = $(DIR_SRC)/$(THISAPP)
34 CFLAGS     =
35 CXXFLAGS   =
36
37 PAK_VER    = 73
38 DEPS       = ""
39
40 ifeq "$(BUILD_ARCH)" "i586"
41         KERNEL_ARCH = i386
42 else
43         KERNEL_ARCH = $(BUILD_ARCH)
44 endif
45
46 ifeq "$(BUILD_ARCH)" "aarch64"
47         HEADERS_ARCH = arm64
48 else
49         HEADERS_ARCH = $(BUILD_PLATFORM)
50 endif
51
52 VERSUFIX=ipfire$(KCFG)
53
54 ifeq "$(TOOLCHAIN)" "1"
55         TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)-tools
56         HEADERS_PREFIX = $(TOOLS_DIR)
57 else
58         TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
59         HEADERS_PREFIX = /usr
60 endif
61
62 ifeq "$(KCFG)" ""
63 LASTKERNEL=1
64 endif
65 ifeq "$(KCFG)" "-multi"
66 LASTKERNEL=1
67 endif
68
69 ###############################################################################
70 # Top-level Rules
71 ###############################################################################
72 objects =$(DL_FILE) \
73         arm-multi-patches-$(ARM_PATCHES).patch.xz
74
75 $(DL_FILE)                                      = $(URL_IPFIRE)/$(DL_FILE)
76 arm-multi-patches-$(ARM_PATCHES).patch.xz       = $(URL_IPFIRE)/arm-multi-patches-$(ARM_PATCHES).patch.xz
77
78 $(DL_FILE)_MD5                                  = 8376ed89777760443a359edb1d08ed9a
79 arm-multi-patches-$(ARM_PATCHES).patch.xz_MD5   = ae7091bb79bad05c8394c8bacc48dd60
80
81 install : $(TARGET)
82
83 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
84
85 download :$(patsubst %,$(DIR_DL)/%,$(objects))
86
87 md5 : $(subst %,%_MD5,$(objects))
88
89 dist:
90         @$(PAK)
91 ###############################################################################
92 # Downloading, checking, md5sum
93 ###############################################################################
94
95 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
96         @$(CHECK)
97
98 $(patsubst %,$(DIR_DL)/%,$(objects)) :
99         @$(LOAD)
100
101 $(subst %,%_MD5,$(objects)) :
102         @$(MD5)
103
104 ###############################################################################
105 # Installation Details
106 ###############################################################################
107
108 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
109         @$(PREBUILD)
110         @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
111
112         ln -svf linux-$(VER) $(DIR_SRC)/linux
113
114         # Linux Intermediate Queueing Device
115         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14-imq.diff
116
117         # Layer7-patch
118         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14-layer7.patch
119
120         # DVB Patches
121         cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch
122
123         # Wlan Patches
124 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/backports-4.2.6-1_ath10k_remove_logspam.patch
125         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-ath_ignore_eeprom_regd.patch
126         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-iwlwifi-noibss_only_on_radar_chan.patch
127 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-rt2x00usb_suppress_queue_warnings.patch
128 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.39-add_libertas_uap.patch
129
130         # Add LED trigger
131         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.16-ledtrig_netdev.patch
132
133         # Fix igb and e1000e crash
134         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14.1-igb-e1000e_fix_lock_at_update_stats.patch
135
136         # cs5535audio spams syslog if no ac97 was present (geos router)
137         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8_cs5535audio_fix_logspam_on_geos.patch
138
139         # Add PC Engines APU led support
140         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-apu_leds.patch
141
142         # Fix uevent PHYSDEVDRIVER
143         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-2.6.32.27_mcs7830-fix-driver-name.patch
144
145 ifeq "$(KCFG)" "-kirkwood"
146 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.10-mv_cesa_disable_failing_hmac_sha1.patch
147 endif
148
149 ifeq "$(KCFG)" "-multi"
150         # Apply Arm-multiarch kernel patches.
151         cd $(DIR_APP) && xzcat $(DIR_DL)/arm-multi-patches-$(ARM_PATCHES).patch.xz | patch -Np1
152 endif
153         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-amba-fix.patch
154
155 ifeq "$(KCFG)" "-headers"
156         # Install the header files
157         cd $(DIR_APP) && make ARCH=$(HEADERS_ARCH) INSTALL_HDR_PATH=dest headers_install
158         -mkdir -pv $(BUILDROOT)/$(HEADERS_PREFIX)/include
159         cd $(DIR_APP) && find dest/include \( -name .install -o -name ..install.cmd \) -delete
160         cd $(DIR_APP) && cp -rv dest/include/* $(BUILDROOT)/$(HEADERS_PREFIX)/include
161 else
162
163         # Install ipfire logo
164         cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
165                 drivers/video/logo/logo_linux_clut224.ppm
166
167         # Cleanup kernel source
168         cp $(DIR_SRC)/config/kernel/kernel.config.$(BUILD_ARCH)-$(VERSUFIX) $(DIR_APP)/.config
169         cd $(DIR_APP) && make oldconfig
170         cd $(DIR_APP) && make clean
171         cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ -$(VERSUFIX)/' Makefile
172
173 ifeq "$(KCFG)" "-kirkwood"
174         cd $(DIR_APP) && make $(MAKETUNING) zImage modules
175         cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
176 #       cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/uImage-$(VERSUFIX)
177 else
178 ifeq "$(KCFG)" "-multi"
179         cd $(DIR_APP) && make $(MAKETUNING) zImage modules
180         cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
181 else
182         cd $(DIR_APP) && make $(MAKETUNING) bzImage modules
183         cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/bzImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
184 endif
185 endif
186
187         cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
188         cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
189         cd $(DIR_APP) && make $(MAKETUNING) modules_install
190
191 ifeq "$(BUILD_PLATFORM)" "arm"
192         cd $(DIR_APP) && make $(MAKETUNING) dtbs
193         cd $(DIR_APP) && for f in $$(find arch/arm/boot/dts/ -name *.dtb); do \
194                                 mkdir -p /boot/dtb-$(VER)-$(VERSUFIX) ; \
195                                 install -m 644 $$f /boot/dtb-$(VER)-$(VERSUFIX)/ ; \
196                         done
197 endif
198
199 ifeq "$(LASTKERNEL)" "1"
200         # Only do this once
201         cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
202
203         # disable drm by install drm to /bin/false because i915 ignore blacklisting
204         echo install drm /bin/false > /etc/modprobe.d/framebuffer.conf
205
206         # Blacklist old framebuffer modules
207         for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video/fbdev/ -name *.ko); do \
208                 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
209         done
210         # Blacklist new drm framebuffer modules
211         for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm -name *.ko); do \
212                 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
213         done    
214         sed -i -e "s|.ko||g" /etc/modprobe.d/framebuffer.conf
215
216         # Disable ipv6 at runtime
217         echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6.conf
218 endif
219 endif
220
221         #force new build of external modules and initrd if the kernel was rebuild
222         -rm -f /usr/src/log/*-kmod-$(VER)-$(VERSUFIX)
223         -rm -f /usr/src/log/linux-initrd-$(VER)-$(VERSUFIX)
224
225         @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/netfilter-layer7-*
226         @$(POSTBUILD)