ce4e15230d7d9a7493c251938195c20460cab623
[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 PATCHLEVEL = .42
30 VER        = 2.6.16.42
31
32 THISAPP    = linux-$(VER)
33 DL_FILE    = $(THISAPP).tar.bz2
34 DL_FROM    = $(URL_IPFIRE)
35 DIR_APP    = $(DIR_SRC)/$(THISAPP)
36 CFLAGS     =
37 CXXFLAGS   =
38
39 # Normal build or SMP build.
40 #
41 ifeq "$(SMP)" "1"
42         TARGET = $(DIR_INFO)/linux-$(VER)-smp
43 else
44         TARGET = $(DIR_INFO)/linux-$(VER)
45 endif
46
47 ###############################################################################
48 # Top-level Rules
49 ###############################################################################
50 objects =$(DL_FILE) \
51         mISDN-CVS-2007-01-26.tar.bz2 \
52         squashfs3.0.tar.gz \
53         iptables-1.3.5.tar.bz2 \
54         patch-o-matic-ng-20061210.tar.bz2 \
55         netfilter-layer7-v2.6.tar.gz \
56         patch-2.6.16-nath323-1.3.bz2
57
58 $(DL_FILE)                                      = $(DL_FROM)/$(DL_FILE)
59 patch-o-matic-ng-20061210.tar.bz2       = $(URL_IPFIRE)/patch-o-matic-ng-20061210.tar.bz2
60 iptables-1.3.5.tar.bz2                  = $(URL_IPFIRE)/iptables-1.3.5.tar.bz2
61 netfilter-layer7-v2.6.tar.gz            = $(URL_IPFIRE)/netfilter-layer7-v2.6.tar.gz
62 patch-2.6.16-nath323-1.3.bz2            = $(URL_IPFIRE)/patch-2.6.16-nath323-1.3.bz2
63 squashfs3.0.tar.gz                              = $(URL_IPFIRE)/squashfs3.0.tar.gz
64 mISDN-CVS-2007-01-26.tar.bz2            = $(URL_IPFIRE)/mISDN-CVS-2007-01-26.tar.bz2
65
66 $(DL_FILE)_MD5                                  = 87e998bb87839b962702815dd5aecc73
67 patch-o-matic-ng-20061210.tar.bz2_MD5           = 76edac76301b45f89e467b41c8cf4393
68 iptables-1.3.5.tar.bz2_MD5                              = 00fb916fa8040ca992a5ace56d905ea5
69 netfilter-layer7-v2.6.tar.gz_MD5                        = 58135cd1aafaf4ae2fa478159206f064
70 patch-2.6.16-nath323-1.3.bz2_MD5                        = f926409ff703a307baf54b57ab75d138
71 squashfs3.0.tar.gz_MD5                          = 9fd05d0bfbb712f5fb95edafea5bc733
72 mISDN-CVS-2007-01-26.tar.bz2_MD5                        = 844c70dc851faffcae7549fd738c7b49
73
74 install : $(TARGET)
75
76 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
77
78 download :$(patsubst %,$(DIR_DL)/%,$(objects))
79
80 md5 : $(subst %,%_MD5,$(objects))
81
82 ###############################################################################
83 # Downloading, checking, md5sum
84 ###############################################################################
85
86 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
87         @$(CHECK)
88
89 $(patsubst %,$(DIR_DL)/%,$(objects)) :
90         @$(LOAD)
91
92 $(subst %,%_MD5,$(objects)) :
93         @$(MD5)
94
95 ###############################################################################
96 # Installation Details
97 ###############################################################################
98
99 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
100         @$(PREBUILD)
101         @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
102         ln -s linux-$(VER) /usr/src/linux
103
104         # Openswan 2
105         cd $(DIR_SRC) && rm -rf openswan-*
106         cd $(DIR_SRC) && tar xfz $(DIR_DL)/openswan-2.4.7.tar.gz
107         #cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openswan-2.4.7.kernel-2.6-natt.patch
108         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openswan-2.4.7.kernel-2.6-klips.patch
109         cd $(DIR_SRC)/openswan-* && sed -i -e 's/INC_USRLOCAL=\/usr\/local/INC_USRLOCAL=\/usr/' Makefile.inc
110
111         # H323 conntrack
112         cd $(DIR_APP) && bunzip2 -cd $(DIR_DL)/patch-2.6.16-nath323-1.3.bz2 | patch -Np1
113
114         # SquashFS
115         cd $(DIR_SRC) && rm -rf squashfs*
116         cd $(DIR_SRC) && tar xfz $(DIR_DL)/squashfs3.0.tar.gz
117         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/squashfs3.0/linux-2.6.15/squashfs3.0-patch
118
119         # Reiser4
120         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/reiser4-for-2.6.16-5.patch
121
122         # Patch-o-matic
123         cd $(DIR_SRC) && rm -rf iptables-*
124         cd $(DIR_SRC) && tar xfj $(DIR_DL)/iptables-1.3.5.tar.bz2
125         cd $(DIR_SRC) && ln -sf iptables-1.3.5 iptables
126         cd $(DIR_SRC) && rm -rf patch-o-matic*
127         cd $(DIR_SRC) && tar xfj $(DIR_DL)/patch-o-matic-ng-20061210.tar.bz2
128         cd $(DIR_SRC)/patch-o-matic-ng* && \
129                 ./runme --batch --kernel-path=$(ROOT)/usr/src/$(THISAPP)/ \
130                         --iptables-path=$(ROOT)/usr/src/iptables/ \
131                         TARPIT sip-conntrack-nat rtsp-conntrack-nat \
132                         mms-conntrack-nat
133
134         # Layer7-patch
135         cd $(DIR_SRC) && rm -rf $(DIR_SRC)/netfilter-layer7-v2.9
136         cd $(DIR_SRC) && tar xzf $(DIR_DL)/netfilter-layer7-v2.9.tar.gz
137         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/netfilter-layer7-v2.9/for_older_kernels/kernel-2.6.13-2.6.16-layer7-2.2.patch
138
139         # Linux Intermediate Queueing Device
140         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.16-imq2.diff
141
142         # ip_conntrack permissions from 440 to 444
143         cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/ip_conntrack_standalone-patch-for-ipfire.patch
144
145         # mISDN
146         cd $(DIR_SRC) && rm -rf mISDN-*
147         cd $(DIR_SRC) && tar xfj $(DIR_DL)/mISDN-CVS-2007-01-26.tar.bz2
148         cd $(DIR_SRC)/mISDN-CVS-2007-01-26 && yes 'yes' | ./std2kern -k /usr/src/linux
149
150 ifeq "$(SMP)" ""
151         # Only do this once on the non-SMP pass
152         cd $(DIR_SRC) && tar czf $(DIR_DL)/iptables-fixed.tar.gz iptables-1.3.5
153 endif
154
155         # Bootsplash
156         cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/bootsplash-3.1.6-2.6.15.diff
157
158         # Cleanup kernel source
159         cd $(DIR_APP) && make mrproper
160
161 ifeq "$(SMP)" ""
162         cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE) $(DIR_APP)/.config
163 endif
164 ifeq "$(SMP)" "1"
165         cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE).smp $(DIR_APP)/.config
166 endif
167
168         cd $(DIR_APP) && make CC="$(KGCC)" oldconfig
169         cd $(DIR_APP) && make CC="$(KGCC)" clean
170
171 ifeq "$(SMP)" "1"
172         cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ $(PATCHLEVEL)-ipfire-smp/' Makefile
173         cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage
174         cd $(DIR_APP) && cp -v arch/i386/boot/bzImage /boot/vmlinuz-$(VER)-ipfire-smp
175         cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-ipfire-smp
176         cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-ipfire
177         ln -sf vmlinuz-$(VER)-ipfire-smp /boot/vmlinuz-ipfire-smp
178         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules
179         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules_install
180         #cd $(DIR_SRC)/openswan-* && make KERNELSRC=/usr/src/$(THISAPP) CC=$(CC) module
181         #cd $(DIR_SRC)/openswan-* && make KERNELSRC=/usr/src/$(THISAPP) CC=$(CC) minstall
182 else
183         cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ $(PATCHLEVEL)-ipfire/' Makefile
184         cd $(DIR_APP) && make $(MAKETUNING) CC="$(KGCC)" bzImage
185         cd $(DIR_APP) && cp -v arch/i386/boot/bzImage /boot/vmlinuz-$(VER)-ipfire
186         cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-ipfire
187         cd $(DIR_APP) && cp -v .config /boot/config-$(VER)-ipfire
188         ln -sf vmlinuz-$(VER)-ipfire /boot/vmlinuz
189         ln -sf System.map-$(VER)-ipfire /boot/System.map
190         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules
191         cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules_install
192         #cd $(DIR_SRC)/openswan-* && make KERNELSRC=/usr/src/$(THISAPP) CC=$(CC) module
193         #cd $(DIR_SRC)/openswan-* && make KERNELSRC=/usr/src/$(THISAPP) CC=$(CC) minstall
194 endif
195
196         # remove symlinked pcmcia directory
197         -rm -rf /lib/modules/$(VER)-ipfire{,-smp}/pcmcia
198
199         @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/mISDN-* $(DIR_SRC)/netfilter-layer7-*
200         @$(POSTBUILD)