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