1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2016 IPFire Team <info@ipfire.org> #
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. #
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. #
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/>. #
19 ###############################################################################
21 ###############################################################################
23 ###############################################################################
28 RPI_PATCHES = 3.14.64-grsec-ipfire1
29 A7M_PATCHES = 3.14.64-grsec-ipfire1
30 GRS_PATCHES = grsecurity-3.1ipfire-3.14.64-v1.patch.xz
33 THISAPP = linux-$(VER)
34 DL_FILE = linux-$(VER).tar.xz
35 DL_FROM = $(URL_IPFIRE)
36 DIR_APP = $(DIR_SRC)/$(THISAPP)
43 KERNEL_ARCH = $(MACHINE)
45 ifeq "$(MACHINE)" "i586"
49 VERSUFIX=ipfire$(KCFG)
52 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)-tools
53 HEADERS_PREFIX = /tools
55 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
59 ifeq "$(MACHINE_TYPE)" "arm"
68 ifeq "$(KCFG)" "-kirkwood"
72 ###############################################################################
74 ###############################################################################
76 rpi-patches-$(RPI_PATCHES).patch.xz \
77 arm7-multi-patches-$(A7M_PATCHES).patch.xz \
81 $(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE)
82 rpi-patches-$(RPI_PATCHES).patch.xz = $(URL_IPFIRE)/rpi-patches-$(RPI_PATCHES).patch.xz
83 arm7-multi-patches-$(A7M_PATCHES).patch.xz = $(URL_IPFIRE)/arm7-multi-patches-$(A7M_PATCHES).patch.xz
84 $(GRS_PATCHES) = $(URL_IPFIRE)/$(GRS_PATCHES)
86 $(DL_FILE)_MD5 = d68173a31fb60e2195a4015fe1f83e97
87 rpi-patches-$(RPI_PATCHES).patch.xz_MD5 = 0d1059c18f4810abbe9aafb6beab445b
88 arm7-multi-patches-$(A7M_PATCHES).patch.xz_MD5 = 589eb8703fa2ba2944b2f925b7f7ffb3
89 $(GRS_PATCHES)_MD5 = 209ff5232dc4141789bc90f34b87d906
93 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
95 download :$(patsubst %,$(DIR_DL)/%,$(objects))
97 md5 : $(subst %,%_MD5,$(objects))
101 ###############################################################################
102 # Downloading, checking, md5sum
103 ###############################################################################
105 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
108 $(patsubst %,$(DIR_DL)/%,$(objects)) :
111 $(subst %,%_MD5,$(objects)) :
114 ###############################################################################
115 # Installation Details
116 ###############################################################################
118 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
120 @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
122 ln -svf linux-$(VER) $(DIR_SRC)/linux
124 # Linux Intermediate Queueing Device
125 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-imq.patch
128 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14-layer7-filter.patch
130 ifneq "$(KCFG)" "-headers"
132 cd $(DIR_APP) && xz -c -d $(DIR_DL)/$(GRS_PATCHES) | patch -Np1
133 cd $(DIR_APP) && rm localversion-grsec
134 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.7-disable-compat_vdso.patch
138 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-dvbsky.patch
139 cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch
142 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/compat-drivers-3.8.3-ath_ignore_eeprom_regdomain.patch
143 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-iwlwifi-noibss_only_on_radar_chan.patch
144 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.37-rt2800usb_add_dlink_dwa137_usbid.patch
145 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.55-rt2800usb-change_queue_warn_to_debug.patch
146 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.25_rt2x00_fix_bss_bcn_num.patch
147 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.25-rt5592_no_special_txop_init.patch
148 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.39-add_libertas_uap.patch
151 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN_hfc-s_add_id.patch
152 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN-hfcusb-reportl1down.patch
155 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-ledtrig_netdev.patch
157 # cs5535audio spams syslog if no ac97 was present (geos router)
158 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.30_cs5535audio_fix_logspam_on_geos.patch
160 # Add PC Engines APU led support
161 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14-apu_leds.patch
163 # Fix uevent PHYSDEVDRIVER
164 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2.33_ipg-fix-driver-name.patch
165 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.27_mcs7830-fix-driver-name.patch
168 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.32-r8169_disable_L23.patch
170 # update the queued trim blacklist from kernel 4.2rc1
171 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.43_new_qtrim_blacklist.patch
174 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0001-Drivers-net-hyperv-Get-rid-of-the-rndis_filter_packe.patch
175 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0002-Drivers-net-hyperv-Cleanup-the-receive-path.patch
176 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0003-Drivers-net-hyperv-Cleanup-the-netvsc-receive-callba.patch
177 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0004-hyperv-Add-latest-NetVSP-versions-to-auto-negotiatio.patch
178 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0005-Drivers-net-hyperv-Enable-scatter-gather-I-O.patch
179 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0006-Drivers-net-hyperv-Cleanup-the-send-path.patch
180 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0007-Drivers-net-hyperv-Enable-offloads-on-the-host.patch
181 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0008-Drivers-net-hyperv-Enable-receive-side-IP-checksum-o.patch
182 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0009-Drivers-net-hyperv-Enable-send-side-checksum-offload.patch
183 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0010-Drivers-net-hyperv-Enable-large-send-offload.patch
184 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0011-hyperv-Change-the-receive-buffer-size-for-legacy-hos.patch
185 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0012-Drivers-net-hyperv-Allocate-memory-for-all-possible-.patch
186 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0013-Drivers-net-hyperv-Negotiate-suitable-ndis-version-f.patch
187 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0014-Drivers-net-hyperv-Address-UDP-checksum-issues.patch
188 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0015-hyperv-Properly-handle-checksum-offload.patch
189 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0016-hyperv-Add-support-for-virtual-Receive-Side-Scaling-.patch
190 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0017-hyperv-Remove-recv_pkt_list-and-lock.patch
191 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0018-hyperv-Simplify-the-send_completion-variables.patch
192 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0019-hyperv-Enable-sendbuf-mechanism-on-the-send-path.patch
193 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0020-Add-support-for-netvsc-build-without-CONFIG_SYSFS-fl.patch
194 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0021-hyperv-Add-hash-value-into-RNDIS-Per-packet-info.patch
195 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0022-hyperv-fix-apparent-cut-n-paste-error-in-send-path-t.patch
196 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0023-hyperv-Fix-error-return-code-in-netvsc_init_buf.patch
197 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0024-hyperv-Fix-a-bug-in-netvsc_send.patch
198 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0025-Drivers-hv-vmbus-Support-per-channel-driver-state.patch
200 # fix empty symbol crc's
201 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-genksyms_fix_typeof_handling.patch
203 ifeq "$(KCFG)" "-kirkwood"
204 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.10-mv_cesa_disable_failing_hmac_sha1.patch
205 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-kirkwood_legacy_boot.patch
208 ifeq "$(KCFG)" "-multi"
209 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10-smsc95xx-add_mac_addr_param.patch
211 # Apply Arm7-multiarch kernel patches.
212 cd $(DIR_APP) && xzcat $(DIR_DL)/arm7-multi-patches-$(A7M_PATCHES).patch.xz | patch -Np1
213 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/arm-multi-grsec-compile-fixes.patch
215 # Install switch api userspace header
216 cd $(DIR_APP) && install -v -m644 include/uapi/linux/switch.h /usr/include/linux/
220 ifeq "$(KCFG)" "-rpi"
221 # Apply Raspberry Pi kernel patches.
222 cd $(DIR_APP) && xzcat $(DIR_DL)/rpi-patches-$(RPI_PATCHES).patch.xz | patch -Np1
225 ifeq "$(KCFG)" "-headers"
226 # Install the header files
227 cd $(DIR_APP) && make ARCH=$(HEADERS_ARCH) INSTALL_HDR_PATH=dest headers_install
228 -mkdir -pv $(BUILDROOT)/$(HEADERS_PREFIX)/include
229 cd $(DIR_APP) && find dest/include \( -name .install -o -name ..install.cmd \) -delete
230 cd $(DIR_APP) && cp -rv dest/include/* $(BUILDROOT)/$(HEADERS_PREFIX)/include
233 # Install ipfire logo
234 cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
235 drivers/video/logo/logo_linux_clut224.ppm
237 # Cleanup kernel source
238 cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE)-$(VERSUFIX) $(DIR_APP)/.config
239 cd $(DIR_APP) && make oldconfig
240 cd $(DIR_APP) && make clean
241 cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ -$(VERSUFIX)/' Makefile
243 ifeq "$(KCFG)" "-kirkwood"
244 cd $(DIR_APP) && make $(MAKETUNING) uImage modules
245 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
246 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/uImage-$(VERSUFIX)
248 ifeq "$(KCFG)" "-multi"
249 cd $(DIR_APP) && make $(MAKETUNING) zImage modules
250 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
251 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/zImage-$(VERSUFIX)
253 ifeq "$(KCFG)" "-rpi"
254 cd $(DIR_APP) && make $(MAKETUNING) zImage modules
255 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
256 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/kernel.img
258 cd $(DIR_APP) && make $(MAKETUNING) bzImage modules
259 cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/bzImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
264 cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
265 cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
266 cd $(DIR_APP) && make $(MAKETUNING) modules_install
267 cd $(DIR_APP) && make $(MAKETUNING) firmware_install
269 ifeq "$(MACHINE_TYPE)" "arm"
270 cd $(DIR_APP) && make $(MAKETUNING) dtbs
271 cd $(DIR_APP) && for f in $$(find arch/arm/boot/dts/ -name *.dtb); do \
272 mkdir -p /boot/dtb-$(VER)-$(VERSUFIX) ; \
273 install -m 644 $$f /boot/dtb-$(VER)-$(VERSUFIX)/ ; \
277 ifeq "$(LASTKERNEL)" "1"
279 cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
281 # Blacklist matroxfb_base
282 echo "blacklist matroxfb_base" >> /etc/modprobe.d/framebuffer.conf
283 # Blacklist old framebuffer modules
284 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video -name *fb.ko); do \
285 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
287 # Blacklist new drm framebuffer modules
288 for f in $$(ls -1 /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm/*/*.ko); do \
289 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
291 sed -i -e "s|.ko||g" /etc/modprobe.d/framebuffer.conf
293 # Blacklist isdn modules
294 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn -name *.ko); do \
295 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/isdn.conf ; \
297 sed -i -e "s|.ko||g" /etc/modprobe.d/isdn.conf
299 # Disable ipv6 at runtime
300 echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6.conf
304 #force new build of external modules and initrd if the kernel was rebuild
305 -rm -f /usr/src/log/*-kmod-$(VER)-$(VERSUFIX)
306 -rm -f /usr/src/log/linux-initrd-$(VER)-$(VERSUFIX)
308 @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/netfilter-layer7-*