94233dc5479cd4b99e1e68e3589385dc177464fe
[people/teissler/ipfire-2.x.git] / lfs / linux3
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2012 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 PATCHLEVEL = .20
28
29 VER = 2.6.42.20
30
31 XVERS = 3.2.20
32 XVERSION = 2
33 XPATCHLEVEL = 6
34 XSUBLEVEL = 42
35 XEXTRAVERSION = .20
36
37 RPI_PATCHES = linux-3.2-bootc-6ab6087
38
39 THISAPP = linux-$(VER)
40 DL_FILE = linux-$(XVERS).tar.bz2
41 DL_FROM = $(URL_IPFIRE)
42 DIR_APP = $(DIR_SRC)/$(THISAPP)
43 CFLAGS =
44 CXXFLAGS =
45
46 PAK_VER = 20
47 DEPS = ""
48
49 VERSUFIX=ipfire$(KCFG)
50
51 ifeq "$(HEADERS)" "1"
52 ifeq "$(TOOLS)" "1"
53 TARGET = $(DIR_INFO)/linux-libc-headers-$(VER)-$(VERSUFIX)-tools
54 HEADERS_PREFIX = /tools
55 else
56 TARGET = $(DIR_INFO)/linux-libc-headers-$(VER)-$(VERSUFIX)
57 HEADERS_PREFIX = /usr
58 endif
59 else
60 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
61 endif
62
63 ifeq "$(MACHINE_TYPE)" "arm"
64 HEADERS_ARCH=arm
65 else
66 HEADERS_ARCH=x86
67 endif
68
69 ifeq "$(KCFG)" ""
70 LASTKERNEL=1
71 endif
72 ifeq "$(KCFG)" "-kirkwood"
73 LASTKERNEL=1
74 endif
75
76 ###############################################################################
77 # Top-level Rules
78 ###############################################################################
79 objects =$(DL_FILE) \
80 rpi-patches-$(RPI_PATCHES).patch.xz
81
82
83 $(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE)
84 rpi-patches-$(RPI_PATCHES).patch.xz = $(URL_IPFIRE)/rpi-patches-$(RPI_PATCHES).patch.xz
85
86 $(DL_FILE)_MD5 = bd0063a747c3ea0ecdcc85a512d9760a
87 rpi-patches-$(RPI_PATCHES).patch.xz_MD5 = fd87188cbd0b168a2b335db3d661ece9
88
89 install : $(TARGET)
90
91 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
92
93 download :$(patsubst %,$(DIR_DL)/%,$(objects))
94
95 md5 : $(subst %,%_MD5,$(objects))
96
97 dist:
98 @$(PAK)
99 ###############################################################################
100 # Downloading, checking, md5sum
101 ###############################################################################
102
103 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
104 @$(CHECK)
105
106 $(patsubst %,$(DIR_DL)/%,$(objects)) :
107 @$(LOAD)
108
109 $(subst %,%_MD5,$(objects)) :
110 @$(MD5)
111
112 ###############################################################################
113 # Installation Details
114 ###############################################################################
115
116 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
117 @$(PREBUILD)
118 @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
119
120 # Change version from 3.x to 2.6.4x
121 cd $(DIR_SRC)/linux-$(XVERS) && sed -i -e "s/^VERSION =.*$$/VERSION = $(XVERSION)/g" Makefile
122 cd $(DIR_SRC)/linux-$(XVERS) && sed -i -e "s/^PATCHLEVEL =.*$$/PATCHLEVEL = $(XPATCHLEVEL)/g" Makefile
123 cd $(DIR_SRC)/linux-$(XVERS) && sed -i -e "s/^SUBLEVEL =.*$$/SUBLEVEL = $(XSUBLEVEL)/g" Makefile
124 cd $(DIR_SRC)/linux-$(XVERS) && sed -i -e "s/^EXTRAVERSION =.*$$/EXTRAVERSION = $(XEXTRAVERSION)/g" Makefile
125 mv $(DIR_SRC)/linux-$(XVERS) $(DIR_SRC)/linux-$(VER)
126
127 ln -svf linux-$(VER) $(DIR_SRC)/linux
128
129 # Linux Intermediate Queueing Device
130 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-imq.patch
131
132 # Not report deprecated syscall 1.23 (for kudzu)
133 # cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.25.18-not_report_sysctl_1.23.patch
134
135
136 # ipp2p 0.8.2-ipfire
137 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.0-ipp2p-0.8.2-ipfire.patch
138
139 # Layer7-patch
140 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/netfilter_layer7_2.22_kernel3.0.patch
141
142 # Add some more LED triggers
143 # cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.11-netdev-1.patch
144
145 # Huawei Android Phones (Vodafone V845, T-Mobile Pulse/mini ...)
146 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.15-option_add_huawei_android.patch
147
148 # Fix uevent PHYSDEVDRIVER
149 # cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.27_ipg-fix-driver-name.patch
150 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.27_mcs7830-fix-driver-name.patch
151
152 ifeq "$(KCFG)" "-kirkwood"
153 # Add dreamplug,guruplug and icy 62x0 support on ARM-kirkwood
154 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.45-arm_kirkwood_setups.patch
155 endif
156
157 ifeq "$(MACHINE_TYPE)" "arm"
158 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.45_align_ssb_modtable_32bit_boundary.patch
159
160 # Reverse some asm optimizations that are incompatible with older gcc
161 cd $(DIR_APP) && patch -p1 -R < $(DIR_SRC)/src/patches/linux-2.6-arm-asm-constraint.patch
162 endif
163
164 ifeq "$(KCFG)" "-omap"
165 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-0001-panda-wlan-fix.patch
166 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-0002-panda-i2c.patch
167 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-panda-reboot.patch
168 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.x-smsc95xx-add_mac_addr_param.patch
169 endif
170
171 ifeq "$(KCFG)" "-rpi"
172 # Apply Raspberry Pi kernel patches. (only avail for 3.1.x kernel yet)
173 cd $(DIR_APP) && xzcat $(DIR_DL)/rpi-patches-$(RPI_PATCHES).patch.xz | patch -Np1
174 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-bcm2835-alsamixer.patch
175 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-bcm2835-limit_volume.patch
176 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2-bcm2708-sdhci_patches.patch
177 endif
178
179 ifeq "$(HEADERS)" "1"
180 # Install the header files
181 cd $(DIR_APP) && make ARCH=$(HEADERS_ARCH) INSTALL_HDR_PATH=dest headers_install
182 -mkdir -pv $(BUILDROOT)/$(HEADERS_PREFIX)/include
183 cd $(DIR_APP) && find dest/include \( -name .install -o -name ..install.cmd \) -delete
184 cd $(DIR_APP) && cp -rv dest/include/* $(BUILDROOT)/$(HEADERS_PREFIX)/include
185 else
186
187 # Install ipfire logo
188 cd $(DIR_APP) && cp -vf $(DIR_SRC)/config/kernel/ipfire_logo.ppm \
189 drivers/video/logo/logo_linux_clut224.ppm
190
191 # Cleanup kernel source
192 cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE)-$(VERSUFIX) $(DIR_APP)/.config
193 cd $(DIR_APP) && make CC="$(KGCC)" oldconfig
194 cd $(DIR_APP) && make CC="$(KGCC)" clean
195 cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ $(PATCHLEVEL)-$(VERSUFIX)/' Makefile
196
197 ifeq "$(KCFG)" "-kirkwood"
198 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" uImage
199 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
200 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/uImage-$(VERSUFIX)
201 else
202 ifeq "$(KCFG)" "-omap"
203 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" uImage
204 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
205 cd $(DIR_APP) && cp -v arch/arm/boot/uImage /boot/uImage-$(VERSUFIX)
206 else
207 ifeq "$(KCFG)" "-rpi"
208 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" zImage
209 cd /boot && cat first32k.bin $(DIR_APP)/arch/arm/boot/Image > kernel.img
210 cd $(DIR_APP) && cp -v /boot/kernel.img /boot/vmlinuz-$(VER)-$(VERSUFIX)
211 else
212 ifeq "$(KCFG)" "-versatile"
213 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" zImage
214 cd $(DIR_APP) && cp -v arch/arm/boot/zImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
215 else
216 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage
217 cd $(DIR_APP) && cp -v arch/i386/boot/bzImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
218 endif
219 endif
220 endif
221 endif
222 cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
223 cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
224 ln -sf vmlinuz-$(VER)-$(VERSUFIX) /boot/vmlinuz-$(VERSUFIX)
225 ln -sf System.map-$(VER)-$(VERSUFIX) /boot/System.map-$(VERSUFIX)
226 cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules
227 cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules_install
228 cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) firmware_install
229
230 ifeq "$(LASTKERNEL)" "1"
231 # Only do this once
232 cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
233
234 # Blacklist matroxfb_base
235 echo "blacklist matroxfb_base" >> /etc/modprobe.d/framebuffer
236 # Blacklist old framebuffer modules
237 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video -name *fb.ko); do \
238 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer ; \
239 done
240 # Blacklist new drm framebuffer modules
241 for f in $$(ls -1 /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm/*/*.ko); do \
242 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer ; \
243 done
244 sed -i -e "s|.ko||g" /etc/modprobe.d/framebuffer
245
246 # Blacklist isdn modules
247 for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn -name *.ko); do \
248 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/isdn ; \
249 done
250 sed -i -e "s|.ko||g" /etc/modprobe.d/isdn
251
252 # Disable ipv6 at runtime
253 echo "options ipv6 disable_ipv6=1" > /etc/modprobe.d/ipv6
254 endif
255
256 ifneq "$(MACHINE_TYPE)" "arm"
257 # Disable geode_aes modul
258 mv /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/crypto/geode-aes.ko \
259 /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/crypto/geode-aes.ko.off
260 endif
261 endif
262
263 @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/netfilter-layer7-*
264 @$(POSTBUILD)