]> git.ipfire.org Git - ipfire-2.x.git/blob - lfs/linux
3c85a23bad155d0700b04ed85952f3e99a709bc9
[ipfire-2.x.git] / lfs / linux
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2017 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 = 3.14.79
28 RPI_PATCHES = 3.14.79-grsec-ipfire1
29 A7M_PATCHES = 3.14.79-grsec-ipfire1
30 GRS_PATCHES = grsecurity-3.1ipfire-3.14.79-v1.patch.xz
31
32
33 THISAPP = linux-$(VER)
34 DL_FILE = linux-$(VER).tar.xz
35 DL_FROM = $(URL_IPFIRE)
36 DIR_APP = $(DIR_SRC)/$(THISAPP)
37 CFLAGS =
38 CXXFLAGS =
39
40 PAK_VER = 73
41 DEPS = ""
42
43 ifeq "$(MACHINE)" "i586"
44 KERNEL_ARCH = i386
45 else
46 KERNEL_ARCH = $(MACHINE)
47 endif
48
49 VERSUFIX=ipfire$(KCFG)
50
51 ifeq "$(TOOLS)" "1"
52 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)-tools
53 HEADERS_PREFIX = /tools
54 else
55 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
56 HEADERS_PREFIX = /usr
57 endif
58
59 ifeq "$(MACHINE)" "armv5tel"
60 HEADERS_ARCH=arm
61 endif
62
63 ifeq "$(MACHINE)" "aarch64"
64 HEADERS_ARCH=arm64
65 endif
66
67 ifeq "$(MACHINE)" "x86_64"
68 HEADERS_ARCH=x86
69 endif
70
71 ifeq "$(MACHINE)" "i586"
72 HEADERS_ARCH=x86
73 endif
74
75 ifeq "$(KCFG)" ""
76 LASTKERNEL=1
77 endif
78 ifeq "$(KCFG)" "-kirkwood"
79 LASTKERNEL=1
80 endif
81
82 ###############################################################################
83 # Top-level Rules
84 ###############################################################################
85 objects =$(DL_FILE) \
86 rpi-patches-$(RPI_PATCHES).patch.xz \
87 arm7-multi-patches-$(A7M_PATCHES).patch.xz \
88 $(GRS_PATCHES)
89
90
91 $(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE)
92 rpi-patches-$(RPI_PATCHES).patch.xz = $(URL_IPFIRE)/rpi-patches-$(RPI_PATCHES).patch.xz
93 arm7-multi-patches-$(A7M_PATCHES).patch.xz = $(URL_IPFIRE)/arm7-multi-patches-$(A7M_PATCHES).patch.xz
94 $(GRS_PATCHES) = $(URL_IPFIRE)/$(GRS_PATCHES)
95
96 $(DL_FILE)_MD5 = ec5b09d8ad2ebf92e6f51a727a338559
97 rpi-patches-$(RPI_PATCHES).patch.xz_MD5 = a02a7fd54c642c1e3578a00ed22f54f8
98 arm7-multi-patches-$(A7M_PATCHES).patch.xz_MD5 = 6c3b11e51caa278dbeacd1e23c2b171b
99 $(GRS_PATCHES)_MD5 = 7fe448b53558082395f68c5db94af1a7
100
101 install : $(TARGET)
102
103 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
104
105 download :$(patsubst %,$(DIR_DL)/%,$(objects))
106
107 md5 : $(subst %,%_MD5,$(objects))
108
109 dist:
110 @$(PAK)
111 ###############################################################################
112 # Downloading, checking, md5sum
113 ###############################################################################
114
115 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
116 @$(CHECK)
117
118 $(patsubst %,$(DIR_DL)/%,$(objects)) :
119 @$(LOAD)
120
121 $(subst %,%_MD5,$(objects)) :
122 @$(MD5)
123
124 ###############################################################################
125 # Installation Details
126 ###############################################################################
127
128 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
129 @$(PREBUILD)
130 @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
131
132 ln -svf linux-$(VER) $(DIR_SRC)/linux
133
134 # Linux Intermediate Queueing Device
135 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-imq.patch
136
137 # Layer7-patch
138 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14-layer7-filter.patch
139
140 ifneq "$(KCFG)" "-headers"
141 # Grsecurity-patches
142 cd $(DIR_APP) && xz -c -d $(DIR_DL)/$(GRS_PATCHES) | patch -Np1
143 cd $(DIR_APP) && rm localversion-grsec
144 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.7-disable-compat_vdso.patch
145 endif
146
147 # DVB Patches
148 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-dvbsky.patch
149 cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch
150
151 # Wlan Patches
152 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/compat-drivers-3.8.3-ath_ignore_eeprom_regdomain.patch
153 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-iwlwifi-noibss_only_on_radar_chan.patch
154 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.37-rt2800usb_add_dlink_dwa137_usbid.patch
155 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.55-rt2800usb-change_queue_warn_to_debug.patch
156 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.25_rt2x00_fix_bss_bcn_num.patch
157 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.25-rt5592_no_special_txop_init.patch
158 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.39-add_libertas_uap.patch
159
160 # mISDN Patches
161 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN_hfc-s_add_id.patch
162 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN-hfcusb-reportl1down.patch
163
164 # Add LED trigger
165 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-ledtrig_netdev.patch
166
167 # cs5535audio spams syslog if no ac97 was present (geos router)
168 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.30_cs5535audio_fix_logspam_on_geos.patch
169
170 # Add PC Engines APU led support
171 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14-apu_leds.patch
172
173 # Add APU2 SoC ID to k10temp
174 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.65-k10temp_add_16H_M30H_id.patch
175
176 # Fix uevent PHYSDEVDRIVER
177 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2.33_ipg-fix-driver-name.patch
178 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.27_mcs7830-fix-driver-name.patch
179
180 # r8169 L23 patch
181 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.32-r8169_disable_L23.patch
182
183 # update the queued trim blacklist from kernel 4.2rc1
184 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.43_new_qtrim_blacklist.patch
185
186 # remove eMMC EXT_CSD revision check to use newer eMMC modules
187 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.79_mmc_remove_EXT_CSD_revision_check.patch
188
189 # Hyper-V patches
190 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0001-Drivers-net-hyperv-Get-rid-of-the-rndis_filter_packe.patch
191 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0002-Drivers-net-hyperv-Cleanup-the-receive-path.patch
192 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0003-Drivers-net-hyperv-Cleanup-the-netvsc-receive-callba.patch
193 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0004-hyperv-Add-latest-NetVSP-versions-to-auto-negotiatio.patch
194 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0005-Drivers-net-hyperv-Enable-scatter-gather-I-O.patch
195 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0006-Drivers-net-hyperv-Cleanup-the-send-path.patch
196 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0007-Drivers-net-hyperv-Enable-offloads-on-the-host.patch
197 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0008-Drivers-net-hyperv-Enable-receive-side-IP-checksum-o.patch
198 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0009-Drivers-net-hyperv-Enable-send-side-checksum-offload.patch
199 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0010-Drivers-net-hyperv-Enable-large-send-offload.patch
200 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0011-hyperv-Change-the-receive-buffer-size-for-legacy-hos.patch
201 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0012-Drivers-net-hyperv-Allocate-memory-for-all-possible-.patch
202 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0013-Drivers-net-hyperv-Negotiate-suitable-ndis-version-f.patch
203 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0014-Drivers-net-hyperv-Address-UDP-checksum-issues.patch
204 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0015-hyperv-Properly-handle-checksum-offload.patch
205 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0016-hyperv-Add-support-for-virtual-Receive-Side-Scaling-.patch
206 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0017-hyperv-Remove-recv_pkt_list-and-lock.patch
207 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0018-hyperv-Simplify-the-send_completion-variables.patch
208 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0019-hyperv-Enable-sendbuf-mechanism-on-the-send-path.patch
209 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0020-Add-support-for-netvsc-build-without-CONFIG_SYSFS-fl.patch
210 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0021-hyperv-Add-hash-value-into-RNDIS-Per-packet-info.patch
211 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0022-hyperv-fix-apparent-cut-n-paste-error-in-send-path-t.patch
212 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0023-hyperv-Fix-error-return-code-in-netvsc_init_buf.patch
213 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0024-hyperv-Fix-a-bug-in-netvsc_send.patch
214 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0025-Drivers-hv-vmbus-Support-per-channel-driver-state.patch
215 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-hyperv_Mark_the_Hyoer-V_TSC_as_unstable.patch
216
217 ifneq "$(KCFG)" "-headers"
218 # fix AES-NI 192 and 256 bits / grsec is needed for this patch version
219 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0100-crypto-aesni-Add-support-for-192-256-bit-keys-to-AES.patch
220 endif
221
222 # fix CVE-2016-5195 (Dirty COW)
223 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0110-mm-remove-gup_flags-FOLL_WRITE-games-from-__get_user.patch
224
225 # fix empty symbol crc's
226 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-genksyms_fix_typeof_handling.patch
227
228 ifeq "$(KCFG)" "-kirkwood"
229 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.10-mv_cesa_disable_failing_hmac_sha1.patch
230 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-kirkwood_legacy_boot.patch
231 endif
232
233 ifeq "$(KCFG)" "-multi"
234 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10-smsc95xx-add_mac_addr_param.patch
235
236 # Apply Arm7-multiarch kernel patches.
237 cd $(DIR_APP) && xzcat $(DIR_DL)/arm7-multi-patches-$(A7M_PATCHES).patch.xz | patch -Np1
238 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/arm-multi-grsec-compile-fixes.patch
239
240 # Install switch api userspace header
241 cd $(DIR_APP) && install -v -m644 include/uapi/linux/switch.h /usr/include/linux/
242
243 endif
244
245 ifeq "$(KCFG)" "-rpi"
246 # Apply Raspberry Pi kernel patches.
247 cd $(DIR_APP) && xzcat $(DIR_DL)/rpi-patches-$(RPI_PATCHES).patch.xz | patch -Np1
248 endif
249
250 ifeq "$(KCFG)" "-headers"
251 # Install the header files
252 cd $(DIR_APP) && make ARCH=$(HEADERS_ARCH) INSTALL_HDR_PATH=dest headers_install
253 -mkdir -pv $(BUILDROOT)/$(HEADERS_PREFIX)/include
254 cd $(DIR_APP) && find dest/include \( -name .install -o -name ..install.cmd \) -delete
255 cd $(DIR_APP) && cp -rv dest/include/* $(BUILDROOT)/$(HEADERS_PREFIX)/include
256 else
257
258 # Install ipfire logo
259 cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
260 drivers/video/logo/logo_linux_clut224.ppm
261
262 # Cleanup kernel source
263 cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE)-$(VERSUFIX) $(DIR_APP)/.config
264 cd $(DIR_APP) && make oldconfig
265 cd $(DIR_APP) && make clean
266 cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ -$(VERSUFIX)/' Makefile
267
268 ifeq "$(KCFG)" "-kirkwood"
269 cd $(DIR_APP) && make $(MAKETUNING) uImage modules
270 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
271 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/uImage-$(VERSUFIX)
272 else
273 ifeq "$(KCFG)" "-multi"
274 cd $(DIR_APP) && make $(MAKETUNING) zImage modules
275 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
276 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/zImage-$(VERSUFIX)
277 else
278 ifeq "$(KCFG)" "-rpi"
279 cd $(DIR_APP) && make $(MAKETUNING) zImage modules
280 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
281 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/kernel.img
282 else
283 cd $(DIR_APP) && make $(MAKETUNING) bzImage modules
284 cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/bzImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
285 endif
286 endif
287 endif
288
289 cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
290 cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
291 cd $(DIR_APP) && make $(MAKETUNING) modules_install
292 cd $(DIR_APP) && make $(MAKETUNING) firmware_install
293
294 ifeq "$(MACHINE_TYPE)" "arm"
295 cd $(DIR_APP) && make $(MAKETUNING) dtbs
296 cd $(DIR_APP) && for f in $$(find arch/arm/boot/dts/ -name *.dtb); do \
297 mkdir -p /boot/dtb-$(VER)-$(VERSUFIX) ; \
298 install -m 644 $$f /boot/dtb-$(VER)-$(VERSUFIX)/ ; \
299 done
300 endif
301
302 ifeq "$(LASTKERNEL)" "1"
303 # Only do this once
304 cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
305
306 # Blacklist matroxfb_base
307 echo "blacklist matroxfb_base" >> /etc/modprobe.d/framebuffer.conf
308 # Blacklist old framebuffer modules
309 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video -name *fb.ko); do \
310 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
311 done
312 # Blacklist new drm framebuffer modules
313 for f in $$(ls -1 /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm/*/*.ko); do \
314 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
315 done
316 sed -i -e "s|.ko||g" /etc/modprobe.d/framebuffer.conf
317
318 # Blacklist isdn modules
319 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn -name *.ko); do \
320 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/isdn.conf ; \
321 done
322 sed -i -e "s|.ko||g" /etc/modprobe.d/isdn.conf
323
324 # Disable ipv6 at runtime
325 echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6.conf
326 endif
327 endif
328
329 #force new build of external modules and initrd if the kernel was rebuild
330 -rm -f /usr/src/log/*-kmod-$(VER)-$(VERSUFIX)
331 -rm -f /usr/src/log/linux-initrd-$(VER)-$(VERSUFIX)
332
333 @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/netfilter-layer7-*
334 @$(POSTBUILD)