Updated to 2.6.26 for stable and 2.6.27 for development
[nslu2-linux/kernel.git] / Makefile
blob1f6d7105ce9c474e6dc7b0f39eda317390264c36
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
21 # Previous Stable
22 # BASEVER = 2.6.25.6
23 # PATCHVER = 2.6.25
25 # Latest Stable
26 BASEVER = 2.6.26
27 PATCHVER = 2.6.26
29 # Latest Development
30 # BASEVER = 2.6.26
31 # PATCHVER = 2.6.27
33 # CROSS_COMPILE = /home/slug/angstrom/tmp/cross/bin/${ARCH}-angstrom-linux-gnueabi-
35 REVISION := $(shell sed -e 's/-\(git\|v\).*//' patches/${PATCHVER}/KERNEL)
36 SNAPSHOT := $(shell sed -e 's/-v.*//' patches/${PATCHVER}/KERNEL)
37 COMMITID := $(shell sed -e 's/.*-\(v[0-9.]*.*\)/\1/' patches/${PATCHVER}/KERNEL)
39 U-BOOT_COMMIT = v1.3.2
41 APEX_REVISION = 1.5.14
42 APEX_CONFIG = slugos
44 ARM_KERNEL_SHIM_REVISION = 1.5
46 DEFCONFIG=defconfig
48 ifeq (${ENDIAN},b)
49 ARCH = armeb
50 else
51 ARCH = arm
52 endif
54 KERNEL_SOURCE = http://www2.kernel.org/pub/linux/kernel/v${MAJORVER}/linux-${BASEVER}.tar.bz2
55 KERNEL_PATCH = http://www2.kernel.org/pub/linux/kernel/v${MAJORVER}/testing/patch-${REVISION}.bz2
56 KERNEL_SNAPSHOT = http://www2.kernel.org/pub/linux/kernel/v${MAJORVER}/snapshots/patch-${SNAPSHOT}.bz2
58 APEX_SOURCE = ftp://ftp.buici.com/pub/apex/apex-${APEX_REVISION}.tar.gz
60 ARM_KERNEL_SHIM_SOURCE = ftp://ftp.buici.com/pub/arm/arm-kernel-shim/arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}.tar.gz
62 U-BOOT_SITE = http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=snapshot;sf=tgz
63 U-BOOT_SNAPSHOT = ${U-BOOT_SITE};h=${U-BOOT_COMMIT}
64 U-BOOT_DIR = u-boot
66 # CROSS_COMPILE ?= ${ARCH}-linux-gnu-
67 CROSS_COMPILE ?= ${ARCH}-linux-
69 ifdef CROSS_COMPILE
70 CROSS_COMPILE_FLAGS = CROSS_COMPILE=${CROSS_COMPILE}
71 else
72 CROSS_COMPILE_FLAGS =
73 endif
75 all: kernel modules arm-kernel-shim apex u-boot
77 kernel: vmlinuz-nslu2-${SNAPSHOT}-${ARCH} vmlinuz-nas100d-${SNAPSHOT}-${ARCH} vmlinuz-ixp4xx-${SNAPSHOT}-${ARCH} vmlinuz-dsmg600-${SNAPSHOT}-${ARCH} vmlinuz-fsg3-${SNAPSHOT}-${ARCH}
78 modules: modules-${SNAPSHOT}-${ARCH}.tar.gz
79 patched: linux-${SNAPSHOT}-${ARCH}/.config
80 u-boot uboot: u-boot-nslu2.bin
81 apex: apex-${APEX_CONFIG}-nslu2-${ARCH}-${APEX_REVISION}.bin \
82 apex-${APEX_CONFIG}-nslu2-16mb-${ARCH}-${APEX_REVISION}.bin \
83 apex-${APEX_CONFIG}-nas100d-${ARCH}-${APEX_REVISION}.bin \
84 apex-${APEX_CONFIG}-dsmg600-${ARCH}-${APEX_REVISION}.bin \
85 apex-${APEX_CONFIG}-fsg3-${ARCH}-${APEX_REVISION}.bin
86 arm-kernel-shim: \
87 arm-kernel-shim-nslu2${ENDIAN}e.bin \
88 arm-kernel-shim-nas100d${ENDIAN}e.bin \
89 arm-kernel-shim-dsmg600${ENDIAN}e.bin \
90 arm-kernel-shim-fsg3${ENDIAN}e.bin
92 u-boot-nslu2.bin: \
93 ${U-BOOT_DIR}/include/configs/nslu2.h \
94 ${U-BOOT_DIR}/cpu/ixp/npe/IxNpeMicrocode.c
95 ${MAKE} -C ${U-BOOT_DIR} ${CROSS_COMPILE_FLAGS} distclean
96 ${MAKE} -C ${U-BOOT_DIR} ${CROSS_COMPILE_FLAGS} nslu2_config
97 ${MAKE} -C ${U-BOOT_DIR} ${CROSS_COMPILE_FLAGS} all
98 ifeq (${ENDIAN},b)
99 devio '<<'${U-BOOT_DIR}/u-boot.bin >$@ 'cp$$'
100 else
101 devio '<<'${U-BOOT_DIR}/u-boot.bin >$@ 'xp $$,4'
102 endif
104 .PRECIOUS: ${U-BOOT_DIR}/cpu/ixp/npe/IxNpeMicrocode.c
105 ${U-BOOT_DIR}/cpu/ixp/npe/IxNpeMicrocode.c: \
106 downloads/IPL_ixp400NpeLibrary-2_1.zip
107 unzip -p -j downloads/IPL_ixp400NpeLibrary-2_1.zip \
108 ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.c \
109 > ${U-BOOT_DIR}/cpu/ixp/npe/IxNpeMicrocode.c
111 .PRECIOUS: ${U-BOOT_DIR}/include/configs/nslu2.h
113 ${U-BOOT_DIR}/include/configs/nslu2.h: \
114 downloads/u-boot-${U-BOOT_COMMIT}.tar.gz
115 [ -e ${U-BOOT_DIR} ] || \
116 ( tar zxf downloads/u-boot-${U-BOOT_COMMIT}.tar.gz ; \
117 cd ${U-BOOT_DIR} ; \
118 ln -s ../patches/u-boot patches ; \
119 [ ! -e patches/series ] || quilt push -a )
120 touch ${U-BOOT_DIR}/include/configs/nslu2.h
122 downloads/u-boot-${U-BOOT_COMMIT}.tar.gz:
123 [ -e downloads/u-boot-${U-BOOT_COMMIT}.tar.gz ] || \
124 ( mkdir -p downloads ; cd downloads ; \
125 wget -O u-boot-${U-BOOT_COMMIT}.tar.gz '${U-BOOT_SNAPSHOT}' )
127 apex-${APEX_CONFIG}-%-${ARCH}-${APEX_REVISION}.bin: apex-${APEX_REVISION}/src/mach-ixp42x/${APEX_CONFIG}-%-${ARCH}_config
128 ( cd apex-${APEX_REVISION} ; \
129 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm clean ; \
130 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm ${APEX_CONFIG}-$*-${ARCH}_config )
131 ( cd apex-${APEX_REVISION} ; \
132 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm all )
133 ifeq (${ENDIAN},b)
134 devio '<<'apex-${APEX_REVISION}/apex.bin >$@ 'cp$$'
135 else
136 devio '<<'apex-${APEX_REVISION}/apex.bin >$@ 'xp $$,4'
137 endif
139 .PRECIOUS: apex-${APEX_REVISION}/src/mach-ixp42x/${APEX_CONFIG}-%-${ARCH}_config
141 apex-${APEX_REVISION}/src/mach-ixp42x/${APEX_CONFIG}-%-${ARCH}_config: \
142 downloads/apex-${APEX_REVISION}.tar.gz
143 [ -e apex-${APEX_REVISION} ] || \
144 ( tar zxf downloads/apex-${APEX_REVISION}.tar.gz ; \
145 cd apex-${APEX_REVISION} ; \
146 ln -s ../patches/apex patches ; \
147 [ ! -e patches/series ] || quilt push -a )
148 touch apex-${APEX_REVISION}/Makefile
150 downloads/apex-${APEX_REVISION}.tar.gz :
151 [ -e downloads/apex-${APEX_REVISION}.tar.gz ] || \
152 ( mkdir -p downloads ; cd downloads ; \
153 wget ${APEX_SOURCE} )
155 arm-kernel-shim-%${ENDIAN}e.bin: arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}/config-%${ENDIAN}e.h
156 ( cd arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION} ; \
157 mv config.h config.h.orig ; cp config-$*${ENDIAN}e.h config.h ; \
158 ${MAKE} ${CROSS_COMPILE_FLAGS} clean arm-kernel-shim.bin )
159 cp arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}/arm-kernel-shim.bin \
160 arm-kernel-shim-$*${ENDIAN}e.bin
162 arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}/config-%${ENDIAN}e.h: \
163 downloads/arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}.tar.gz
164 [ -e arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION} ] || \
165 ( tar zxf downloads/arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}.tar.gz ; \
166 cd arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION} ; \
167 ln -s ../patches/arm-kernel-shim patches ; \
168 [ ! -e patches/series ] || quilt push -a )
169 ifeq (${ENDIAN},b)
170 sed -e 's|//#define FORCE_BIGENDIAN|#define FORCE_BIGENDIAN|' patches/arm-kernel-shim/config-$*.h \
171 > arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}/config-$*${ENDIAN}e.h
172 else
173 sed -e 's|//#define FORCE_LITTLEENDIAN|#define FORCE_LITTLEENDIAN|' patches/arm-kernel-shim/config-$*.h \
174 > arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}/config-$*${ENDIAN}e.h
175 endif
177 downloads/arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}.tar.gz :
178 [ -e downloads/arm-kernel-shim-${ARM_KERNEL_SHIM_REVISION}.tar.gz ] || \
179 ( mkdir -p downloads ; cd downloads ; \
180 wget ${ARM_KERNEL_SHIM_SOURCE} )
182 modules-${SNAPSHOT}-${ARCH}.tar.gz: vmlinuz-${SNAPSHOT}-${ARCH}
183 ( cd linux-${SNAPSHOT}-${ARCH} ; \
184 INSTALL_MOD_PATH="../modules-${SNAPSHOT}-${ARCH}" ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm modules modules_install ) || true
185 rm -f modules-${SNAPSHOT}-${ARCH}/lib/modules/${SNAPSHOT}/build modules-${SNAPSHOT}-${ARCH}/lib/modules/${SNAPSHOT}/source
186 ifeq (${SNAPSHOT},${BASEVER})
187 tar -C modules-${SNAPSHOT}-${ARCH} -zcf modules-${SNAPSHOT}-${ARCH}.tar.gz .
188 else
189 tar -C modules-${SNAPSHOT}-${ARCH} -zcf modules-${SNAPSHOT}-${ARCH}.tar.gz .
190 endif
192 vmlinuz-ixp4xx-${SNAPSHOT}-${ARCH}: vmlinuz-${SNAPSHOT}-${ARCH}
193 ifeq (${ENDIAN},b)
194 devio '<<'$< >$@ \
195 'cp$$'
196 else
197 devio '<<'$< >$@ \
198 'wb 0xee110f10,4' \
199 'wb 0xe3c00080,4' \
200 'wb 0xee010f10,4' \
201 'xp $$,4'
202 endif
204 vmlinuz-%-${SNAPSHOT}-${ARCH}: vmlinuz-${SNAPSHOT}-${ARCH} arm-kernel-shim-%${ENDIAN}e.bin
205 ifeq (${ENDIAN},b)
206 cat arm-kernel-shim-$*${ENDIAN}e.bin vmlinuz-${SNAPSHOT}-${ARCH} > $@
207 else
208 ( cat arm-kernel-shim-$*${ENDIAN}e.bin vmlinuz-${SNAPSHOT}-${ARCH} > $$$$ ; \
209 devio '<<'$$$$ >$@ 'xp $$,4' ; \
210 rm -f $$$$ )
211 endif
213 vmlinuz-${SNAPSHOT}-${ARCH}: linux-${SNAPSHOT}-${ARCH}/.config
214 ( cd linux-${SNAPSHOT}-${ARCH} ; \
215 ${MAKE} ${CROSS_COMPILE_FLAGS} ARCH=arm bzImage )
216 cp linux-${SNAPSHOT}-${ARCH}/arch/arm/boot/zImage vmlinuz-${SNAPSHOT}-${ARCH}
218 menuconfig: linux-${SNAPSHOT}-${ARCH}/.config
219 ${MAKE} -C linux-${SNAPSHOT}-${ARCH} ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} menuconfig
221 ifneq (${SNAPSHOT},${COMMITID})
222 linux-${SNAPSHOT}-${ARCH}/.config: \
223 patches/${PATCHVER}/$(DEFCONFIG)
224 [ -e linux-${SNAPSHOT}-${ARCH} ] || \
225 ( git clone -q \
226 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git \
227 linux-${SNAPSHOT}-${ARCH} )
228 ( cd linux-${SNAPSHOT}-${ARCH} ; \
229 git checkout master ; \
230 git reset --hard ${COMMITID} ; \
231 git clean -d -x )
232 ( cd linux-${SNAPSHOT}-${ARCH} ; \
233 ln -s ../patches/${PATCHVER} patches ; \
234 [ ! -e patches/series ] || quilt push -a )
235 else
236 ifeq (${SNAPSHOT},${BASEVER})
237 linux-${SNAPSHOT}-${ARCH}/.config: \
238 downloads/linux-${BASEVER}.tar.bz2 \
239 patches/${PATCHVER}/$(DEFCONFIG)
240 [ -e linux-${SNAPSHOT}-${ARCH} ] || \
241 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
242 mv linux-${BASEVER} linux-${SNAPSHOT}-${ARCH} ; \
243 cd linux-${SNAPSHOT}-${ARCH} ; \
244 ln -s ../patches/${PATCHVER} patches ; \
245 [ ! -e patches/series ] || quilt push -a )
246 else
247 ifeq (${REVISION},${SNAPSHOT})
248 linux-${SNAPSHOT}-${ARCH}/.config: \
249 downloads/linux-${BASEVER}.tar.bz2 \
250 downloads/patch-${REVISION}.bz2 \
251 patches/${PATCHVER}/$(DEFCONFIG)
252 [ -e linux-${SNAPSHOT}-${ARCH} ] || \
253 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
254 mv linux-${BASEVER} linux-${SNAPSHOT}-${ARCH} ; \
255 bzcat downloads/patch-${REVISION}.bz2 | \
256 patch -d linux-${SNAPSHOT}-${ARCH} -p1 ; \
257 cd linux-${SNAPSHOT}-${ARCH} ; \
258 ln -s ../patches/${PATCHVER} patches ; \
259 [ ! -e patches/series ] || quilt push -a )
260 else
261 ifeq (${REVISION},${BASEVER})
262 linux-${SNAPSHOT}-${ARCH}/.config: \
263 downloads/linux-${BASEVER}.tar.bz2 \
264 downloads/patch-${SNAPSHOT}.bz2 \
265 patches/${PATCHVER}/$(DEFCONFIG)
266 [ -e linux-${SNAPSHOT}-${ARCH} ] || \
267 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
268 mv linux-${BASEVER} linux-${SNAPSHOT}-${ARCH} ; \
269 bzcat downloads/patch-${SNAPSHOT}.bz2 | \
270 patch -d linux-${SNAPSHOT}-${ARCH} -p1 ; \
271 cd linux-${SNAPSHOT}-${ARCH} ; \
272 ln -s ../patches/${PATCHVER} patches ; \
273 [ ! -e patches/series ] || quilt push -a )
274 else
275 linux-${SNAPSHOT}-${ARCH}/.config: \
276 downloads/linux-${BASEVER}.tar.bz2 \
277 downloads/patch-${REVISION}.bz2 \
278 downloads/patch-${SNAPSHOT}.bz2 \
279 patches/${PATCHVER}/$(DEFCONFIG)
280 [ -e linux-${SNAPSHOT}-${ARCH} ] || \
281 ( tar xjf downloads/linux-${BASEVER}.tar.bz2 ; \
282 mv linux-${BASEVER} linux-${SNAPSHOT}-${ARCH} ; \
283 bzcat downloads/patch-${REVISION}.bz2 downloads/patch-${SNAPSHOT}.bz2 | \
284 patch -d linux-${SNAPSHOT}-${ARCH} -p1 ; \
285 cd linux-${SNAPSHOT}-${ARCH} ; \
286 ln -s ../patches/${PATCHVER} patches ; \
287 [ ! -e patches/series ] || quilt push -a )
288 endif
289 endif
290 endif
291 endif
292 ifeq (${ENDIAN},b)
293 sed -e 's/.*CONFIG_CPU_BIG_ENDIAN.*/CONFIG_CPU_BIG_ENDIAN=y/' \
294 < patches/${PATCHVER}/$(DEFCONFIG) > linux-${SNAPSHOT}-${ARCH}/.config
295 else
296 sed -e 's/.*CONFIG_CPU_BIG_ENDIAN.*/\# CONFIG_CPU_BIG_ENDIAN is not set/' \
297 < patches/${PATCHVER}/$(DEFCONFIG) > linux-${SNAPSHOT}-${ARCH}/.config
298 endif
300 downloads/linux-${BASEVER}.tar.bz2 :
301 [ -e downloads/linux-${BASEVER}.tar.bz2 ] || \
302 ( mkdir -p downloads ; cd downloads ; \
303 wget ${KERNEL_SOURCE} )
305 downloads/patch-${REVISION}.bz2 :
306 [ -e downloads/patch-${REVISION}.bz2 ] || \
307 ( mkdir -p downloads ; cd downloads ; \
308 wget ${KERNEL_PATCH} )
310 ifneq (${REVISION},${SNAPSHOT})
311 downloads/patch-${SNAPSHOT}.bz2 :
312 [ -e downloads/patch-${SNAPSHOT}.bz2 ] || \
313 ( mkdir -p downloads ; cd downloads ; \
314 wget ${KERNEL_SNAPSHOT} )
315 endif
317 downloads:
318 mkdir -p downloads
320 clobber: clobber-kernel clobber-apex clobber-arm-kernel-shim clobber-u-boot
321 rm -rf *~
323 clobber-kernel:
324 rm -rf vmlinuz-* modules-*.tar.gz
325 rm -rf linux-* modules-*
327 clobber-apex:
328 rm -rf apex-*
330 clobber-u-boot clobber-uboot:
331 rm -rf u-boot-* ${U-BOOT_DIR}
333 clobber-arm-kernel-shim:
334 rm -rf arm-kernel-shim-*
336 .PHONY: all kernel menuconfig modules clobber apex clobber-apex clobber-arm-kernel-shim
338 # End of Makefile