Updated to 2.6.20-rc4
[nslu2-linux/kernel.git] / Makefile
blobc3ef3853d1a6d0bb716f49c75cf63a318758bab1
1 # Makefile for building the IXP4xx kernel.
3 # Based on the build script for the Loft from Giant Shoulder, Inc.
4 # written by Tommy B.
5 # Based on the great work done in OpenEmbedded for the Linksys NSLU2
6 # written by the nslu2-linux development community.
8 # This builds the kernel in the linux-${REVISION} directory.
9 # It then installs all the kernel modules in lib
10 # and creates a tarball there containing all the modules
11 # under the lib/modules/${REVISION} directory.
13 # N.B. You may need to change your crosstool path
17 ENDIAN = l
18 #ENDIAN = b
19 MAJORVER = 2.6
20 BASEVER = 2.6.19
21 PATCHVER = 2.6.20
22 REVISION := $(shell sed -e 's/-git.*//' patches/${PATCHVER}/KERNEL)
23 SNAPSHOT := $(shell cat patches/${PATCHVER}/KERNEL)
25 APEX_REVISION = 1.4.7
26 APEX_TARGET = nslu2
27 APEX_CONFIG = slugos
29 MADWIFIVER = r1503-20060415
31 DEFCONFIG=defconfig
33 ifeq (${ENDIAN},b)
34 DEBIAN_ARCH = armeb
35 else
36 DEBIAN_ARCH = arm
37 endif
39 KERNEL_SOURCE = http://www2.kernel.org/pub/linux/kernel/v${MAJORVER}/linux-${BASEVER}.tar.bz2
40 KERNEL_PATCH = http://www2.kernel.org/pub/linux/kernel/v${MAJORVER}/testing/patch-${REVISION}.bz2
41 KERNEL_SNAPSHOT = http://www2.kernel.org/pub/linux/kernel/v${MAJORVER}/snapshots/patch-${SNAPSHOT}.bz2
43 APEX_SOURCE = ftp://ftp.buici.com/pub/apex/apex-${APEX_REVISION}.tar.gz
45 MADWIFI_SOURCE = http://snapshots.madwifi.org/madwifi-ng/madwifi-ng-${MADWIFIVER}.tar.gz
47 #CROSS_COMPILE = ${DEBIAN_ARCH}-linux-gnu-
48 CROSS_COMPILE ?= ${DEBIAN_ARCH}-linux-
50 ifdef CROSS_COMPILE
51 CROSS_COMPILE_FLAGS = CROSS_COMPILE=${CROSS_COMPILE}
52 else
53 CROSS_COMPILE_FLAGS =
54 endif
56 all: kernel modules apex
58 kernel: vmlinuz-nslu2-${SNAPSHOT} vmlinuz-nas100d-${SNAPSHOT} vmlinuz-loft-${SNAPSHOT} vmlinuz-dsmg600-${SNAPSHOT} vmlinuz-fsg3-${SNAPSHOT}
59 madwifi: lib/modules/${SNAPSHOT}/net/ath_hal.ko
60 modules: modules-${SNAPSHOT}.tar.gz
61 patched: linux-${SNAPSHOT}/.config
62 apex: apex-${APEX_CONFIG}-${APEX_TARGET}-${DEBIAN_ARCH}-${APEX_REVISION}.bin
64 # ifeq (${APEX_TARGET},fsg3)
65 # sed -i -e '/CONFIG_MACH_FSG/d' apex-${APEX_REVISION}/.config
66 # echo 'CONFIG_MACH_FSG=y' >> apex-${APEX_REVISION}/.config
67 # echo 'CONFIG_ARCH_NUMBER=1091' >> apex-${APEX_REVISION}/.config
68 # endif
70 apex-${APEX_CONFIG}-${APEX_TARGET}-${DEBIAN_ARCH}-${APEX_REVISION}.bin: apex-${APEX_REVISION}/.config
71 ( cd apex-${APEX_REVISION} ; \
72 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm all )
73 ifeq (${ENDIAN},b)
74 devio '<<'apex-${APEX_REVISION}/apex.bin >$@ 'cp$$'
75 else
76 devio '<<'apex-${APEX_REVISION}/apex.bin >$@ 'xp $$,4'
77 endif
79 apex-${APEX_REVISION}/.config: apex-${APEX_REVISION}/src/mach-ixp42x/${APEX_CONFIG}-${APEX_TARGET}-${DEBIAN_ARCH}_config
80 ( cd apex-${APEX_REVISION} ; \
81 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm clean ; \
82 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm ${APEX_CONFIG}-${APEX_TARGET}-${DEBIAN_ARCH}_config )
84 apex-${APEX_REVISION}/src/mach-ixp42x/${APEX_CONFIG}-${APEX_TARGET}-${DEBIAN_ARCH}_config: \
85 downloads/apex-${APEX_REVISION}.tar.gz
86 [ -e apex-${APEX_REVISION} ] || \
87 ( tar zxf downloads/apex-${APEX_REVISION}.tar.gz ; \
88 cd apex-${APEX_REVISION} ; \
89 ln -s ../patches/apex patches ; \
90 quilt push -a )
91 touch apex-${APEX_REVISION}/Makefile
93 downloads/apex-${APEX_REVISION}.tar.gz :
94 [ -e downloads/apex-${APEX_REVISION}.tar.gz ] || \
95 ( mkdir -p downloads ; cd downloads ; \
96 wget ${APEX_SOURCE} )
98 usr: usr-${SNAPSHOT}.tar.gz
100 usr-${SNAPSHOT}.tar.gz: vmlinuz-${SNAPSHOT} \
101 usr/local/bin/wlanconfig
102 tar zcf usr-${SNAPSHOT}.tar.gz usr/local
104 # Add the following depedency if you want madwifi built.
105 # lib/modules/${SNAPSHOT}/net/ath_hal.ko
107 modules-${SNAPSHOT}.tar.gz: vmlinuz-${SNAPSHOT}
108 tar zcf modules-${SNAPSHOT}.tar.gz lib/modules/${SNAPSHOT}
110 lib/modules/${SNAPSHOT}/net/ath_hal.ko usr/local/bin/wlanconfig: \
111 madwifi-ng/Makefile \
112 vmlinuz-${SNAPSHOT}
113 rm -rf lib/modules/${SNAPSHOT}/net
114 ( cd madwifi-ng ; \
115 ${MAKE} CROSS_COMPILE=${CROSS_COMPILE} TOOLPATH=${CROSS_COMPILE} \
116 TARGET=xscale-${ENDIAN}e-elf \
117 KERNELPATH=`cd .. ; pwd`/linux-${SNAPSHOT} \
118 DESTDIR=`cd .. ; pwd` \
119 all install )
121 madwifi-ng/Makefile: \
122 downloads/madwifi-ng-${MADWIFIVER}.tar.gz
123 [ -e madwifi-ng ] || \
124 ( tar zxf downloads/madwifi-ng-${MADWIFIVER}.tar.gz ; \
125 mv madwifi-ng-${MADWIFIVER} madwifi-ng ; \
126 ( cd patches/madwifi ; \
127 grep -v \# series | \
128 while read f; do case "$$f" in http:*) wget -O - "$$f";; *) cat "$$f";; esac; done \
129 ) | \
130 patch -d madwifi-ng -p1 )
131 touch $@
133 downloads/madwifi-ng-${MADWIFIVER}.tar.gz :
134 [ -e downloads/madwifi-ng-${MADWIFIVER}.tar.gz ] || \
135 ( mkdir -p downloads ; cd downloads ; \
136 wget ${MADWIFI_SOURCE} )
138 vmlinuz-loft-${SNAPSHOT}: vmlinuz-${SNAPSHOT}
139 ifeq (${ENDIAN},b)
140 devio '<<'$< >$@ \
141 'wb 0xe3a01c03,4' 'wb 0xe3811051,4' \
142 'cp$$'
143 else
144 devio '<<'$< >$@ \
145 'wb 0xe3a01c03,4' 'wb 0xe3811051,4' \
146 'wb 0xee110f10,4' \
147 'wb 0xe3c00080,4' \
148 'wb 0xee010f10,4' \
149 'xp $$,4'
150 endif
152 vmlinuz-nas100d-${SNAPSHOT}: vmlinuz-${SNAPSHOT}
153 ifeq (${ENDIAN},b)
154 cp $< $@
155 else
156 devio '<<'$< >$@ \
157 'wb 0xee110f10,4' \
158 'wb 0xe3c00080,4' \
159 'wb 0xee010f10,4' \
160 'xp $$,4'
161 endif
163 vmlinuz-nslu2-${SNAPSHOT}: vmlinuz-${SNAPSHOT}
164 ifeq (${ENDIAN},b)
165 devio '<<'$< >$@ \
166 'wb 0xe3a01c02,4' 'wb 0xe3811055,4' \
167 'cp$$'
168 else
169 devio '<<'$< >$@ \
170 'wb 0xe3a01c02,4' 'wb 0xe3811055,4' \
171 'wb 0xee110f10,4' \
172 'wb 0xe3c00080,4' \
173 'wb 0xee010f10,4' \
174 'xp $$,4'
175 endif
177 vmlinuz-dsmg600-${SNAPSHOT}: vmlinuz-${SNAPSHOT}
178 ifeq (${ENDIAN},b)
179 devio '<<'$< >$@ \
180 'wb 0xe3a01c03,4' 'wb 0xe38110c4,4' \
181 'cp$$'
182 else
183 devio '<<'$< >$@ \
184 'wb 0xe3a01c03,4' 'wb 0xe38110c4,4' \
185 'wb 0xee110f10,4' \
186 'wb 0xe3c00080,4' \
187 'wb 0xee010f10,4' \
188 'xp $$,4'
189 endif
192 vmlinuz-fsg3-${SNAPSHOT}: vmlinuz-${SNAPSHOT}
193 ifeq (${ENDIAN},b)
194 devio '<<'$< >$@ \
195 'wb 0xe3a01c04,4' 'wb 0xe3811043,4' \
196 'cp$$'
197 else
198 devio '<<'$< >$@ \
199 'wb 0xe3a01c04,4' 'wb 0xe3811043,4' \
200 'wb 0xee110f10,4' \
201 'wb 0xe3c00080,4' \
202 'wb 0xee010f10,4' \
203 'xp $$,4'
204 endif
207 vmlinuz-${SNAPSHOT}: linux-${SNAPSHOT}/.config
208 ( cd linux-${SNAPSHOT} ; \
209 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm bzImage modules )
210 ( cd linux-${SNAPSHOT} ; \
211 INSTALL_MOD_PATH=".." ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm modules_install )
212 rm -f lib/modules/${SNAPSHOT}/build lib/modules/${SNAPSHOT}/source
213 cp linux-${SNAPSHOT}/arch/arm/boot/zImage vmlinuz-${SNAPSHOT}
215 menuconfig: linux-${SNAPSHOT}/.config
216 ${MAKE} -C linux-${SNAPSHOT} ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} menuconfig
218 ifeq (${SNAPSHOT},${BASEVER})
219 linux-${SNAPSHOT}/.config: \
220 downloads/linux-${BASEVER}.tar.bz2 \
221 patches/${PATCHVER}/series patches/${PATCHVER}/??-*.patch patches/${PATCHVER}/$(DEFCONFIG)
222 [ -e linux-${REVISION} ] || \
223 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
224 cd linux-${SNAPSHOT} ; \
225 ln -s ../patches/${PATCHVER} patches ; \
226 quilt push -a )
227 else
228 ifeq (${REVISION},${SNAPSHOT})
229 linux-${SNAPSHOT}/.config: \
230 downloads/linux-${BASEVER}.tar.bz2 \
231 downloads/patch-${REVISION}.bz2 \
232 patches/${PATCHVER}/series patches/${PATCHVER}/??-*.patch patches/${PATCHVER}/$(DEFCONFIG)
233 [ -e linux-${REVISION} ] || \
234 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
235 mv linux-${BASEVER} linux-${SNAPSHOT} ; \
236 bzcat downloads/patch-${REVISION}.bz2 | \
237 patch -d linux-${SNAPSHOT} -p1 ; \
238 cd linux-${SNAPSHOT} ; \
239 ln -s ../patches/${PATCHVER} patches ; \
240 quilt push -a )
241 else
242 linux-${SNAPSHOT}/.config: \
243 downloads/linux-${BASEVER}.tar.bz2 \
244 downloads/patch-${REVISION}.bz2 \
245 downloads/patch-${SNAPSHOT}.bz2 \
246 patches/${PATCHVER}/series patches/${PATCHVER}/??-*.patch patches/${PATCHVER}/$(DEFCONFIG)
247 [ -e linux-${REVISION} ] || \
248 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
249 mv linux-${BASEVER} linux-${SNAPSHOT} ; \
250 bzcat downloads/patch-${REVISION}.bz2 downloads/patch-${SNAPSHOT}.bz2 | \
251 patch -d linux-${SNAPSHOT} -p1 ; \
252 cd linux-${SNAPSHOT} ; \
253 ln -s ../patches/${PATCHVER} patches ; \
254 quilt push -a )
255 endif
256 endif
257 ifeq (${ENDIAN},b)
258 sed -e 's/.*CONFIG_CPU_BIG_ENDIAN.*/CONFIG_CPU_BIG_ENDIAN=y/' \
259 < patches/${PATCHVER}/$(DEFCONFIG) > linux-${SNAPSHOT}/.config
260 else
261 sed -e 's/.*CONFIG_CPU_BIG_ENDIAN.*/\# CONFIG_CPU_BIG_ENDIAN is not set/' \
262 < patches/${PATCHVER}/$(DEFCONFIG) > linux-${SNAPSHOT}/.config
263 endif
265 downloads/linux-${BASEVER}.tar.bz2 :
266 [ -e downloads/linux-${BASEVER}.tar.bz2 ] || \
267 ( mkdir -p downloads ; cd downloads ; \
268 wget ${KERNEL_SOURCE} )
270 downloads/patch-${REVISION}.bz2 :
271 [ -e downloads/patch-${REVISION}.bz2 ] || \
272 ( mkdir -p downloads ; cd downloads ; \
273 wget ${KERNEL_PATCH} )
275 ifneq (${REVISION},${SNAPSHOT})
276 downloads/patch-${SNAPSHOT}.bz2 :
277 [ -e downloads/patch-${SNAPSHOT}.bz2 ] || \
278 ( mkdir -p downloads ; cd downloads ; \
279 wget ${KERNEL_SNAPSHOT} )
280 endif
282 downloads:
283 mkdir -p downloads
285 clobber: clobber-apex
286 rm -rf vmlinuz-* modules-*.tar.gz usr-*.tar.gz
287 rm -rf linux-*
288 rm -rf madwifi-ng
289 rm -rf lib usr
291 clobber-apex:
292 rm -rf apex-*
294 .PHONY: all kernel menuconfig modules clobber apex clobber-apex
296 # End of Makefile