1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2021 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 ARM_PATCHES = 4.14.232-ipfire0
30 THISAPP = linux-$(VER)
31 DL_FILE = linux-$(VER).tar.xz
32 DL_FROM = $(URL_IPFIRE)
33 DIR_APP = $(DIR_SRC)/$(THISAPP)
37 HEADERS_ARCH = $(BUILD_PLATFORM)
38 KERNEL_ARCH = $(BUILD_ARCH)
39 KERNEL_TARGET = bzImage
41 ifeq "$(BUILD_ARCH)" "i586"
45 ifeq "$(BUILD_ARCH)" "aarch64"
51 ifeq "$(BUILD_ARCH)" "armv5tel"
53 KERNEL_TARGET = zImage
56 VERSUFIX=ipfire$(KCFG)
58 ifeq "$(TOOLCHAIN)" "1"
59 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)-tools
60 HEADERS_PREFIX = $(TOOLS_DIR)
62 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
69 ifeq "$(KCFG)" "-multi"
73 ###############################################################################
75 ###############################################################################
77 arm-multi-patches-$(ARM_PATCHES).patch.xz
79 $(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE)
80 arm-multi-patches-$(ARM_PATCHES).patch.xz = $(URL_IPFIRE)/arm-multi-patches-$(ARM_PATCHES).patch.xz
82 $(DL_FILE)_MD5 = f9dbc2f2656f30aef8394ac9d4ee88b3
83 arm-multi-patches-$(ARM_PATCHES).patch.xz_MD5 = a04b842733999abb818cabb0388572b8
87 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
89 download :$(patsubst %,$(DIR_DL)/%,$(objects))
91 md5 : $(subst %,%_MD5,$(objects))
95 ###############################################################################
96 # Downloading, checking, md5sum
97 ###############################################################################
99 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
102 $(patsubst %,$(DIR_DL)/%,$(objects)) :
105 $(subst %,%_MD5,$(objects)) :
108 ###############################################################################
109 # Installation Details
110 ###############################################################################
112 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
114 @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
116 ln -svf linux-$(VER) $(DIR_SRC)/linux
119 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14-layer7.patch
122 cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch
125 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14_ath_user_regd.patch
126 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8-iwlwifi-noibss_only_on_radar_chan.patch
129 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.16-ledtrig_netdev.patch
131 # Fix igb and e1000e crash
132 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14.1-igb-e1000e_fix_lock_at_update_stats.patch
134 # cs5535audio spams syslog if no ac97 was present (geos router)
135 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.9.8_cs5535audio_fix_logspam_on_geos.patch
137 # Add PC Engines APU led support
138 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14-apu_leds.patch
140 # Fix uevent PHYSDEVDRIVER
141 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-2.6.32.27_mcs7830-fix-driver-name.patch
143 # Active try to add entropy if the kernel wait for it
144 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-random_try_to_actively_add_entropy.patch
145 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14.x-add_timer_setup_on_stack.patch
147 ifeq "$(KCFG)" "-multi"
148 # Apply Arm-multiarch kernel patches.
149 cd $(DIR_APP) && xzcat $(DIR_DL)/arm-multi-patches-$(ARM_PATCHES).patch.xz | patch -Np1
151 ifeq "$(BUILD_ARCH)" "aarch64"
152 # Apply Arm-multiarch kernel patches.
153 cd $(DIR_APP) && xzcat $(DIR_DL)/arm-multi-patches-$(ARM_PATCHES).patch.xz | patch -Np1
155 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-amba-fix.patch
157 ifeq "$(KCFG)" "-headers"
158 # Install the header files
159 cd $(DIR_APP) && make ARCH=$(HEADERS_ARCH) INSTALL_HDR_PATH=dest headers_install
160 -mkdir -pv $(BUILDROOT)/$(HEADERS_PREFIX)/include
161 cd $(DIR_APP) && find dest/include \( -name .install -o -name ..install.cmd \) -delete
162 cd $(DIR_APP) && cp -rv dest/include/* $(BUILDROOT)/$(HEADERS_PREFIX)/include
165 # Install ipfire logo
166 cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
167 drivers/video/logo/logo_linux_clut224.ppm
169 # Cleanup kernel source
170 cp $(DIR_SRC)/config/kernel/kernel.config.$(BUILD_ARCH)-$(VERSUFIX) $(DIR_APP)/.config
171 cd $(DIR_APP) && make oldconfig
172 cd $(DIR_APP) && make clean
173 cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ -$(VERSUFIX)/' Makefile
175 # Copy Module signing key configuration
176 cp -f $(DIR_SRC)/config/kernel/x509.genkey $(DIR_APP)/certs/x509.genkey
178 # Remove modules folder if exists
179 rm -rf /lib/modules/$(VER)-$(VERSUFIX)
182 cd $(DIR_APP) && make $(MAKETUNING) $(KERNEL_TARGET) modules
185 cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/$(KERNEL_TARGET) /boot/vmlinuz-$(VER)-$(VERSUFIX)
186 cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
187 cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
188 cd $(DIR_APP) && make $(MAKETUNING) modules_install
190 ifeq "$(BUILD_PLATFORM)" "arm"
191 cd $(DIR_APP) && make $(MAKETUNING) dtbs
192 mkdir -p /boot/dtb-$(VER)-$(VERSUFIX)
193 cd $(DIR_APP)/arch/$(KERNEL_ARCH)/boot/dts && for f in $$(find -name "*.dtb"); do \
194 cp -v --parents $$f /boot/dtb-$(VER)-$(VERSUFIX)/ ; \
195 chmod 644 /boot/dtb-$(VER)-$(VERSUFIX)/$$f ; \
199 # Recreate source and build links
200 rm -rf /lib/modules/$(VER)-$(VERSUFIX)/{build,source}
201 mkdir -p /lib/modules/$(VER)-$(VERSUFIX)/build
202 ln -sf build /lib/modules/$(VER)-$(VERSUFIX)/source
204 # Create dirs for extra modules
205 mkdir -p /lib/modules/$(VER)-$(VERSUFIX)/extra
207 cd $(DIR_APP) && cp --parents $$(find -type f -name "Makefile*" -o -name "Kconfig*") \
208 /lib/modules/$(VER)-$(VERSUFIX)/build
209 cd $(DIR_APP) && cp Module.symvers System.map /lib/modules/$(VER)-$(VERSUFIX)/build
210 rm -rf /lib/modules/$(VER)-$(VERSUFIX)/build/{Documentation,scripts,include}
212 cd $(DIR_APP) && cp .config /lib/modules/$(VER)-$(VERSUFIX)/build
213 cd $(DIR_APP) && cp -a scripts /lib/modules/$(VER)-$(VERSUFIX)/build
214 find /lib/modules/$(VER)-$(VERSUFIX)/build/scripts -name "*.o" -exec rm -vf {} \;
216 cd $(DIR_APP) && cp -a --parents arch/$(HEADERS_ARCH)/include /lib/modules/$(VER)-$(VERSUFIX)/build
217 cd $(DIR_APP) && cp -a include /lib/modules/$(VER)-$(VERSUFIX)/build/include
219 # Copy module signing key for off tree modules
220 cd $(DIR_APP) && cp -f certs/signing_key.* /lib/modules/$(VER)-$(VERSUFIX)/build/certs/
223 cd $(DIR_APP) && cp -a tools/objtool/objtool \
224 /lib/modules/$(VER)-$(VERSUFIX)/build/tools/objtool/ || :
225 cd $(DIR_APP) && cp -a --parents tools/build/{Build,Build.include,fixdep.c} \
226 tools/scripts/utilities.mak /lib/modules/$(VER)-$(VERSUFIX)/build
228 # Make sure we can build external modules
229 touch -r /lib/modules/$(VER)-$(VERSUFIX)/build/Makefile \
230 /lib/modules/$(VER)-$(VERSUFIX)/build/include/generated/uapi/linux/version.h
231 touch -r /lib/modules/$(VER)-$(VERSUFIX)/build/.config \
232 /lib/modules/$(VER)-$(VERSUFIX)/build/autoconf.h
233 cp /lib/modules/$(VER)-$(VERSUFIX)/build/.config \
234 /lib/modules/$(VER)-$(VERSUFIX)/build/include/config/auto.conf
237 find /lib/modules/$(VER)-$(VERSUFIX) -name "modules.order" \
238 -exec chmod 644 {} \;
240 find /lib/modules/$(VER)-$(VERSUFIX) -name ".*.cmd" -exec rm -f {} \;
242 ifeq "$(LASTKERNEL)" "1"
244 cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
246 # disable drm by install drm to /bin/false because i915 ignore blacklisting
247 echo install drm /bin/false > /etc/modprobe.d/framebuffer.conf
249 # Blacklist old framebuffer modules
250 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video/fbdev/ -name *.ko.xz); do \
251 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
253 # Blacklist new drm framebuffer modules
254 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm -name *.ko.xz); do \
255 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer.conf ; \
257 sed -i -e "s|.ko.xz||g" /etc/modprobe.d/framebuffer.conf
259 # Disable ipv6 at runtime
260 echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6.conf
264 #force new build of external modules and initrd if the kernel was rebuild
265 -rm -f /usr/src/log/*-kmod-$(VER)-$(VERSUFIX)
266 -rm -f /usr/src/log/linux-initrd-$(VER)-$(VERSUFIX)
268 @rm -rf $(DIR_APP) $(DIR_SRC)/linux