8e1c7021efc3f7335b2fe992b59f72766db7f197
[ipfire-2.x.git] / lfs / linux
1 ###############################################################################
2 #                                                                             #
3 # IPFire.org - A linux based firewall                                         #
4 # Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
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 = .15
28 VER        = 2.6.32.15
29
30 THISAPP    = linux-$(VER)
31 DL_FILE    = $(THISAPP).tar.bz2
32 DL_FROM    = $(URL_IPFIRE)
33 DIR_APP    = $(DIR_SRC)/$(THISAPP)
34 CFLAGS     =
35 CXXFLAGS   =
36
37 PROG       = linux-xen
38 PAK_VER    = 10
39 DEPS       = ""
40
41 # Normal build or XEN build.
42 #
43
44 ifeq "$(XEN)" "1"
45         VERSUFIX=ipfire-xen
46 else
47         VERSUFIX=ipfire
48 endif
49
50 TARGET = $(DIR_INFO)/linux-$(VER)-$(VERSUFIX)
51
52 ###############################################################################
53 # Top-level Rules
54 ###############################################################################
55 objects =$(DL_FILE) \
56         netfilter-layer7-v2.22.tar.gz \
57         patch-2.6.16-nath323-1.3.bz2 \
58         reiser4-for-2.6.32.patch.bz2 \
59         squashfs-lzma-linux-2.6.32-kernel-patches.tar.bz2 \
60         xen-patches-2.6.32-2.tar.bz2
61
62 $(DL_FILE)                              = $(URL_IPFIRE)/$(DL_FILE)
63 netfilter-layer7-v2.22.tar.gz           = $(URL_IPFIRE)/netfilter-layer7-v2.22.tar.gz
64 patch-2.6.16-nath323-1.3.bz2            = $(URL_IPFIRE)/patch-2.6.16-nath323-1.3.bz2
65 reiser4-for-2.6.32.patch.bz2            = $(URL_IPFIRE)/reiser4-for-2.6.32.patch.bz2
66 squashfs-lzma-linux-2.6.32-kernel-patches.tar.bz2 = $(URL_IPFIRE)/squashfs-lzma-linux-2.6.32-kernel-patches.tar.bz2
67 xen-patches-2.6.32-2.tar.bz2            = $(URL_IPFIRE)/xen-patches-2.6.32-2.tar.bz2
68
69 $(DL_FILE)_MD5                          = 1cbbf16e93bbe03368172872690600c0
70 netfilter-layer7-v2.22.tar.gz_MD5       = 98dff8a3d5a31885b73341633f69501f
71 patch-2.6.16-nath323-1.3.bz2_MD5        = f926409ff703a307baf54b57ab75d138
72 reiser4-for-2.6.32.patch.bz2_MD5        = 3246397973d9271eb8e6d7c97c5d2d91
73 squashfs-lzma-linux-2.6.32-kernel-patches.tar.bz2_MD5 = d2a84311081023c7ffd28cdca67c45d4
74 xen-patches-2.6.32-2.tar.bz2_MD5        = d1d78d2e9b9b62dd869a490f4415de04
75
76 install : $(TARGET)
77
78 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
79
80 download :$(patsubst %,$(DIR_DL)/%,$(objects))
81
82 md5 : $(subst %,%_MD5,$(objects))
83
84 dist:
85         @$(PAK)
86 ###############################################################################
87 # Downloading, checking, md5sum
88 ###############################################################################
89
90 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
91         @$(CHECK)
92
93 $(patsubst %,$(DIR_DL)/%,$(objects)) :
94         @$(LOAD)
95
96 $(subst %,%_MD5,$(objects)) :
97         @$(MD5)
98
99 ###############################################################################
100 # Installation Details
101 ###############################################################################
102
103 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
104         @$(PREBUILD)
105         @rm -rf $(DIR_APP) $(DIR_SRC)/linux $(DIR_SRC)/linux-*-suse_xen_patches $(DIR_SRC)/xen-* && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
106
107         ln -s linux-$(VER) /usr/src/linux
108
109 ifeq "$(XEN)" "1"
110         # Apply gentoo Xen patches
111         mkdir -p $(DIR_SRC)/xen-patches
112         cd $(DIR_SRC)/xen-patches && tar jxf $(DIR_DL)/xen-patches-2.6.32-2.tar.bz2
113
114         for x in `ls -1 $(DIR_SRC)/xen-patches/*.patch1`; do \
115                 echo "*********** [Patch: $$x]"; \
116                 cd $(DIR_APP) && pwd && patch -Np1 < $$x || exit 1; \
117         done
118         rm -rf $(DIR_SRC)/xen-patches
119
120         # Linux Intermediate Queueing Device
121         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.8-xen-imq-test2.patch
122 else
123         # Linux Intermediate Queueing Device
124         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32-imq-test2.patch
125 endif
126
127         # Not report deprecated syscall 1.23 (for kudzu)
128         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.25.18-not_report_sysctl_1.23.patch
129
130         # Reiser4 (don't check if fail (some patches are already in xen patchset)
131         -cd $(DIR_APP) && bzcat $(DIR_DL)/reiser4-for-2.6.32.patch.bz2 | patch -Np1
132
133         # ipp2p 0.8.2-pomng
134         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.8-ipp2p-0.8.2-pomng.patch
135
136         # Layer7-patch
137         cd $(DIR_SRC) && rm -rf $(DIR_SRC)/netfilter-layer7-v2.22
138         cd $(DIR_SRC) && tar xzf $(DIR_DL)/netfilter-layer7-v2.22.tar.gz
139         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch
140
141         # Squashfs LZMA support
142         cd $(DIR_APP) && bzcat $(DIR_DL)/squashfs-lzma-linux-2.6.32-kernel-patches.tar.bz2 | patch -Np1
143
144         # mISDN hfcusb fixes
145         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN-hfcusb-reportl1down.patch
146         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/mISDN-hfcusb_bchannels.patch
147
148         # Add some more LED triggers
149         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.11-netdev-1.patch
150
151         # Huawei (Vodafone) K3765 & K4505 Usbids
152         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.11-option_add_vodafone_usbids.patch
153
154         # Cleanup kernel source
155
156         cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE)-$(VERSUFIX) $(DIR_APP)/.config
157         cd $(DIR_APP) && make CC="$(KGCC)" oldconfig
158         cd $(DIR_APP) && make CC="$(KGCC)" clean
159         cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ $(PATCHLEVEL)-$(VERSUFIX)/' Makefile
160
161 ifeq "$(XEN)" "1"
162         cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" vmlinuz
163         cd $(DIR_APP) && cp -v arch/i386/boot/vmlinuz /boot/vmlinuz-$(VER)-$(VERSUFIX)
164 else
165         cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage
166         cd $(DIR_APP) && cp -v arch/i386/boot/bzImage /boot/vmlinuz-$(VER)-$(VERSUFIX)
167 endif
168         cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
169         cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-$(VERSUFIX)
170         ln -sf vmlinuz-$(VER)-$(VERSUFIX) /boot/vmlinuz-$(VERSUFIX)
171         ln -sf System.map-$(VER)-$(VERSUFIX) /boot/System.map-$(VERSUFIX)
172         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules
173         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules_install
174         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) firmware_install
175
176 ifeq "$(XEN)" ""
177         # Only do this once on the non-XEN pass
178         cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/
179 endif
180
181         # Rename ide-cd module to match with old kernel
182         mv /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/ide/ide-cd_mod.ko \
183            /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/ide/ide-cd.ko
184         mv /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/ide/ide-gd_mod.ko \
185            /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/ide/ide-disk.ko
186
187 #       # Remove mISDN modules
188 #       rm -rvf /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn/mISDN
189 #       rm -rvf /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn/hardware/mISDN
190
191 ifneq "$(XEN)" "1"
192         # Blacklist matroxfb_base
193         echo "blacklist matroxfb_base" >> /etc/modprobe.d/framebuffer
194         # Blacklist old framebuffer modules
195         for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/video -name *fb.ko); do \
196                 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer ; \
197         done
198         # Blacklist new drm framebuffer modules
199         for f in $$(ls -1 /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/gpu/drm/*/*.ko); do \
200                 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/framebuffer ; \
201         done
202         sed -i -e "s|.ko||g" /etc/modprobe.d/framebuffer
203
204         # Blacklist isdn modules
205         for f in $$(find /lib/modules/$(VER)-$(VERSUFIX)/kernel/drivers/isdn -name *.ko); do \
206                 echo "blacklist $$(basename $$f)" >> /etc/modprobe.d/isdn ; \
207         done
208 endif
209
210         @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/netfilter-layer7-*
211         @$(POSTBUILD)