kernel: add kernel for Raspberry Pi.
[ipfire-2.x.git] / lfs / linux-rpi
1 ###############################################################################
2 #                                                                             #
3 # IPFire.org - A linux based firewall                                         #
4 # Copyright (C) 2007-2011  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 = .10
28 VER           = 2.6.41.10
29
30 XVERS         = 3.1.10
31 XVERSION      = 2
32 XPATCHLEVEL   = 6
33 XSUBLEVEL     = 41
34 XEXTRAVERSION = .10
35
36 THISAPP    = linux-$(VER)
37 DL_FILE    = linux-$(XVERS).tar.bz2
38 DL_FROM    = $(URL_IPFIRE)
39 DIR_APP    = $(DIR_SRC)/$(THISAPP)
40 CFLAGS     =
41 CXXFLAGS   =
42
43 PAK_VER    = 20
44 DEPS       = ""
45
46 VERSUFIX=ipfire$(KCFG)
47
48 ifeq "$(HEADERS)" "1"
49 ifeq "$(TOOLS)" "1"
50         TARGET = $(DIR_INFO)/linux-libc-headers-$(VER)-$(VERSUFIX)-tools
51         HEADERS_PREFIX = /tools
52 else
53         TARGET = $(DIR_INFO)/linux-libc-headers-$(VER)-$(VERSUFIX)
54         HEADERS_PREFIX = /usr
55 endif
56 else
57         TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
58 endif
59
60 ifeq "$(MACHINE_TYPE)" "arm"
61         HEADERS_ARCH=arm
62 else
63         HEADERS_ARCH=x86
64 endif
65
66 ifeq "$(KCFG)" ""
67 LASTKERNEL=1
68 endif
69 ifeq "$(KCFG)" "-kirkwood"
70 LASTKERNEL=1
71 endif
72
73 ###############################################################################
74 # Top-level Rules
75 ###############################################################################
76 objects =$(DL_FILE) \
77         patch-2.6.16-nath323-1.3.bz2 \
78         rpi-patches-9efb470.patch.xz
79
80
81 $(DL_FILE)                              = $(URL_IPFIRE)/$(DL_FILE)
82 patch-2.6.16-nath323-1.3.bz2            = $(URL_IPFIRE)/patch-2.6.16-nath323-1.3.bz2
83 rpi-patches-9efb470.patch.xz            = $(URL_IPFIRE)/rpi-patches-9efb470.patch.xz
84
85 $(DL_FILE)_MD5                          = 3649bdaa50ffd9114cc16486ec54d83a
86 patch-2.6.16-nath323-1.3.bz2_MD5        = f926409ff703a307baf54b57ab75d138
87 rpi-patches-9efb470.patch.xz_MD5        = 833274ba420078d22f7f7b7f56debe1d
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.1-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-2.6.40-pandaboard-wlan-fix.patch
166         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.40-pandaboard-dvi720p.patch
167         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.40-pandaboard-i2c-fix.patch
168         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.40-pandaboard-reboot.patch
169         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.40-pandaboard-rtc-twl-irq.patch
170         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.40-pandaboard-memcpy.patch
171         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.x-smsc95xx-add_mac_addr_param.patch
172 endif
173
174 ifeq "$(KCFG)" "-rpi"
175         # Apply Raspberry Pi kernel patches. (only avail for 3.1.x kernel yet)
176         -cd $(DIR_APP) && xzcat $(DIR_DL)/rpi-patches-9efb470.patch.xz | patch -Np1
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)