Zwischencommit fuer LFS. Bis Kernel.
[people/pmueller/ipfire-2.x.git] / lfs / linux
1 ###############################################################################
2 # This file is part of the IPCop Firewall.                                    #
3 #                                                                             #
4 # IPCop is free software; you can redistribute it and/or modify               #
5 # it under the terms of the GNU General Public License as published by        #
6 # the Free Software Foundation; either version 2 of the License, or           #
7 # (at your option) any later version.                                         #
8 #                                                                             #
9 # IPCop is distributed in the hope that it will be useful,                    #
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
12 # GNU General Public License for more details.                                #
13 #                                                                             #
14 # You should have received a copy of the GNU General Public License           #
15 # along with IPCop; if not, write to the Free Software                        #
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
17 #                                                                             #
18 # Makefiles are based on LFSMake, which is                                    #
19 # Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
20 #                                                                             #
21 ###############################################################################
22
23 ###############################################################################
24 # Definitions
25 ###############################################################################
26
27 include Config
28
29 VER        = 2.6.16
30 PATCHLEVEL = 2.6.16.27
31
32 THISAPP    = linux-$(VER)
33 DL_FILE    = $(THISAPP).tar.gz
34 DL_FROM    = $(URL_IPFIRE)
35 DIR_APP    = $(DIR_SRC)/$(THISAPP)
36 CFLAGS     =
37 CXXFLAGS   =
38
39 # Normal build or /tools build.
40 #
41 ifeq "$(SMP)" ""
42   TARGET = $(DIR_INFO)/linux-$(PATCHLEVEL)-ipfire
43 endif
44 ifeq "$(SMP)" "1"
45   TARGET = $(DIR_INFO)/linux-$(PATCHLEVEL)-ipfire-smp
46 endif
47 ifeq "$(SMP)" "installer"
48   TARGET = $(DIR_INFO)/linux-$(PATCHLEVEL)-ipfire-installer
49 endif
50
51 ###############################################################################
52 # Top-level Rules
53 ###############################################################################
54 objects =$(DL_FILE) \
55         openswan-2.4.6.kernel-2.6-natt.patch.gz \
56         iptables-1.3.5.tar.bz2 \
57         patch-o-matic-ng-20060206.tar.bz2 \
58         kbc_option_2420.patch \
59         net4801.kernel.patch_2.4.31 \
60         netfilter-layer7-v2.1.tar.gz \
61         patch-$(PATCHLEVEL).gz
62
63 $(DL_FILE)                                      = $(DL_FROM)/$(DL_FILE)
64 patch-$(PATCHLEVEL)gz                   = $(DL_FROM)/patch-$(PATCHLEVEL).bz2
65 openswan-2.4.6.kernel-2.6-natt.patch.gz = $(URL_IPFIRE)/openswan-2.4.6.kernel-2.6-natt.patch.gz
66 patch-o-matic-ng-20060206.tar.bz2       = $(URL_IPFIRE)/patch-o-matic-ng-20060206.tar.bz2
67 iptables-1.3.5.tar.bz2                  = $(URL_IPFIRE)/iptables-1.3.5.tar.bz2
68 kbc_option_2420.patch                   = $(URL_IPFIRE)/kbc_option_2420.patch
69 net4801.kernel.patch_2.4.31                     = $(URL_IPFIRE)/net4801.kernel.patch_2.4.31
70 netfilter-layer7-v2.1.tar.gz            = $(URL_IPFIRE)/netfilter-layer7-v2.1.tar.gz
71
72 $(DL_FILE)_MD5                                  = 50695965725367f39007023feac5e256
73 patch-$(PATCHLEVEL).gz_MD5                              = 4b09dd018286850c20c0f051ced7b583
74 openswan-2.4.6.kernel-2.6-natt.patch.gz_MD5     = 398110db4372ea3acc45bd66d6d86eac
75 patch-o-matic-ng-20060206.tar.bz2_MD5           = eca9893afb753e331caddfe63142b566
76 iptables-1.3.5.tar.bz2_MD5                              = 00fb916fa8040ca992a5ace56d905ea5
77 kbc_option_2420.patch_MD5                               = 6d37870344f7fcf97ace1fbf43323c60
78 net4801.kernel.patch_2.4.31_MD5                 = c7d64e3caedb2f2b10e1c11db7f73a04
79 netfilter-layer7-v2.1.tar.gz_MD5                        = 551626a158c2a2cbfd937d27ecc7fac1
80
81 install : $(TARGET)
82
83 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
84
85 download :$(patsubst %,$(DIR_DL)/%,$(objects))
86
87 md5 : $(subst %,%_MD5,$(objects))
88
89 ###############################################################################
90 # Downloading, checking, md5sum
91 ###############################################################################
92
93 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
94         @$(CHECK)
95
96 $(patsubst %,$(DIR_DL)/%,$(objects)) :
97         @$(LOAD)
98
99 $(subst %,%_MD5,$(objects)) :
100         @$(MD5)
101
102 ###############################################################################
103 # Installation Details
104 ###############################################################################
105
106 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
107         @$(PREBUILD)
108         @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
109         cd $(DIR_APP) && zcat $(DIR_DL)/patch-$(PATCHLEVEL).gz | patch -p1
110         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.16.27-utf8_input-1.patch
111         # Remove patch level in EXTRAVERSION.
112         # We want to avoid the need to supply a full kernel
113         # (installed in a different place) if only one part could be updated
114         cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =/' Makefile
115         cd $(DIR_APP) && sed -i -e 's/-Werror//' drivers/scsi/aic7xxx/Makefile
116
117         # Openswan-2
118         # cd $(DIR_SRC) && zcat $(DIR_DL)/openswan-2.4.6.kernel-2.6-natt.patch.gz | patch -Np0
119
120         # Patch-o-matic
121         cd $(DIR_SRC) && rm -rf iptables-*
122         cd $(DIR_SRC) && tar xfj $(DIR_DL)/iptables-1.3.5.tar.bz2
123         cd $(DIR_SRC) && ln -sf iptables-1.3.5 iptables
124         cd $(DIR_SRC) && rm -rf patch-o-matic*
125         cd $(DIR_SRC) && tar xfj $(DIR_DL)/patch-o-matic-ng-20060206.tar.bz2
126
127 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ pending
128 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ base
129 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ h323-conntrack-nat
130 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ cuseeme-nat
131 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ mms-conntrack-nat
132 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ pptp-conntrack-nat
133 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ rtsp-conntrack
134 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ quake3-conntrack-nat
135 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ sip-conntrack-nat
136 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ ip_queue_vwmark
137 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ ipp2p
138 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ ipsec-01-output-hooks
139 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ ipsec-02-input-hooks
140 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ ipsec-03-policy-lookup
141 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ ipsec-04-policy-checks
142 #       cd $(DIR_SRC)/patch-o-matic* && yes 'y' | ./runme --kernel-path=$(DIR_APP) --iptables-path=$(ROOT)/usr/src/iptables/ TARPIT
143
144         # imq-patch
145         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.16-imq2.diff
146         
147         #layer7-patch
148         cd $(DIR_SRC) && tar xzf $(DIR_DL)/netfilter-layer7-v2.6.tar.gz
149         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/netfilter-layer7-v2.6/for_older_kernels/kernel-2.6.13-2.6.16-layer7-2.2.patch
150
151         # ip_conntrack permissions from 440 to 444
152         # cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/ip_conntrack_standalone-patch-for-ipfire.patch
153
154 ifeq "$(SMP)" ""
155         # Only do this once on the non-SMP pass
156         cd $(DIR_SRC) && tar czf $(DIR_DL)/iptables-fixed.tar.gz iptables-1.3.5
157 endif
158
159         # Olitec isdn gazel patch
160 #       cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/linux-2.4.23-olitec-isdn.patch
161
162         # Fix /proc/stat output
163 #       cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/linux-2.4.26-proc-stat.patch
164
165         # Fix libata-core.c
166         # cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/linux-2.4.26-scsi.patch
167
168         # frandom patch
169 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.4.27-frandom-2.patch
170
171         # Propolice
172 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.4.27-ssp-1.patch
173
174         # Support ppp-2.4.3 multilink behavior (terminate when no channel is connected)
175         # need updated libpcap older than 0.8.3
176         # cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/ppp_generic-ppp-2.4.3_multilink.patch
177
178         # R8169 clone D-link GSE-528T
179 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.4.29_r8169clone.patch
180
181         # bootsplash
182 #       cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/bootsplash-3.0.7-2.4.31-vanilla.diff
183
184         # Cleanup kernel source
185         cd $(DIR_APP) && make mrproper
186 ifeq "$(SMP)" ""
187         cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE) $(DIR_APP)/.config
188 endif
189 ifeq "$(SMP)" "1"
190         cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE).smp $(DIR_APP)/.config
191 endif
192 ifeq "$(SMP)" "installer"
193         cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE).installer $(DIR_APP)/.config
194         cd $(DIR_APP) && sed -i -e 's/-O2/-Os/g' Makefile
195 endif
196
197         cd $(DIR_APP) && make CC="$(KGCC)" oldconfig
198         cd $(DIR_APP) && make CC="$(KGCC)" dep
199         cd $(DIR_APP) && make CC="$(KGCC)" clean
200         if [ "$(SMP)" = "" ]; then \
201                 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage; \
202                 cd $(DIR_APP) && cp arch/$(MACHINE)/boot/bzImage /boot/vmlinuz-$(VER); \
203                 cd $(DIR_APP) && cp System.map /boot/System.map-$(VER); \
204                 ln -sf vmlinuz-$(VER) /boot/vmlinuz; \
205                 ln -sf System.map-$(VER) /boot/System.map; \
206                 cd $(DIR_APP) && make CC="$(KGCC)" modules; \
207                 cd $(DIR_APP) && make CC="$(KGCC)" modules_install; \
208         elif [ "$(SMP)" = "1" ]; then \
209                 cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =/EXTRAVERSION\ =\ -smp/' Makefile; \
210                 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage; \
211                 cd $(DIR_APP) && cp arch/$(MACHINE)/boot/bzImage /boot/vmlinuz-$(VER)-smp; \
212                 cd $(DIR_APP) && cp System.map /boot/System.map-$(VER)-smp; \
213                 ln -sf vmlinuz-$(VER)-smp /boot/vmlinuz-smp; \
214                 cd $(DIR_APP) && make CC="$(KGCC)" modules; \
215                 cd $(DIR_APP) && make CC="$(KGCC)" modules_install; \
216         elif [ "$(SMP)" = "installer" ]; then \
217                 cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage; \
218                 cd $(DIR_APP) && cp arch/$(MACHINE)/boot/bzImage /boot/vmlinuz-installer; \
219         fi
220         # remove symlinked pcmcia directory
221 ifeq "$(SMP)" ""
222         rm -rf /lib/modules/$(VER)/pcmcia
223         find /lib/modules/$(VER)/ -name '*.o' -a -type f | xargs gzip -f9
224
225         # Move these SCSI drivers into same directory for probescsi.sh
226         mv -f  /lib/modules/$(VER)/kernel/drivers/scsi/aic7xxx/*     /lib/modules/$(VER)/kernel/drivers/scsi
227         rm -rf /lib/modules/$(VER)/kernel/drivers/scsi/aic7xxx
228         mv -f  /lib/modules/$(VER)/kernel/drivers/scsi/aacraid/*     /lib/modules/$(VER)/kernel/drivers/scsi
229         rm -rf /lib/modules/$(VER)/kernel/drivers/scsi/aacraid
230         mv -f  /lib/modules/$(VER)/kernel/drivers/scsi/sym53c8xx_2/* /lib/modules/$(VER)/kernel/drivers/scsi
231         rm -rf /lib/modules/$(VER)/kernel/drivers/scsi/sym53c8xx_2
232 endif
233 ifeq "$(SMP)" "1"
234         rm -rf /lib/modules/$(VER)-smp/pcmcia
235         find /lib/modules/$(VER)-smp/ -name '*.o' -a -type f | xargs gzip -f9
236
237         # Move these SCSI drivers into same directory for probescsi.sh
238         mv -f  /lib/modules/$(VER)-smp/kernel/drivers/scsi/aic7xxx/*     /lib/modules/$(VER)-smp/kernel/drivers/scsi
239         rm -rf /lib/modules/$(VER)-smp/kernel/drivers/scsi/aic7xxx
240         mv -f  /lib/modules/$(VER)-smp/kernel/drivers/scsi/aacraid/*     /lib/modules/$(VER)-smp/kernel/drivers/scsi
241         rm -rf /lib/modules/$(VER)-smp/kernel/drivers/scsi/aacraid
242         mv -f  /lib/modules/$(VER)-smp/kernel/drivers/scsi/sym53c8xx_2/* /lib/modules/$(VER)-smp/kernel/drivers/scsi
243         rm -rf /lib/modules/$(VER)-smp/kernel/drivers/scsi/sym53c8xx_2
244 endif
245
246 ifeq "$(SMP)" ""
247         # Only do this once on the non-SMP pass
248         cd $(DIR_APP) && make mandocs
249         -mkdir -p /usr/share/man/man9/
250         cd $(DIR_APP) && cp -af Documentation/man/* /usr/share/man/man9/
251 endif
252         @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables*
253         @$(POSTBUILD)