[backfire] ar71xx: merge r28597
[openwrt-10.03/.git] / target / linux / ar71xx / image / Makefile
1 #
2 # Copyright (C) 2008-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 define imgname
11 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
12 endef
13
14 VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
15 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
16 fs_squash:=squashfs-only
17 fs_all:=all
18 fs_4k:=4k
19 fs_64k:=64k
20 fs_128k:=128k
21 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
22         fs_squash:=initramfs
23         fs_all:=initramfs
24         fs_4k:=initramfs
25         fs_64k:=initramfs
26         fs_128k:=initramfs
27         VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs
28         UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs
29 endif
30
31 define CompressLzma
32   $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
33 endef
34
35 define PatchKernelLzma
36         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
37         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
38         $(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).bin.lzma)
39 endef
40
41 define PatchKernelGzip
42         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
43         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
44         gzip -9 -c $(KDIR)/vmlinux-$(1) > $(KDIR)/vmlinux-$(1).bin.gz
45 endef
46
47 define MkImageLzma
48         mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma \
49                 -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
50                 -d $(1) $(2)
51 endef
52
53 define MkImageGzip
54         mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip \
55                 -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
56                 -d $(1) $(2)
57 endef
58
59 define Image/BuildKernel
60         cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
61         cp $(KDIR)/vmlinux $(VMLINUX).bin
62         gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
63         $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
64         dd if=$(KDIR)/vmlinux.bin.lzma of=$(VMLINUX).lzma bs=65536 conv=sync
65         dd if=$(KDIR)/vmlinux.bin.gz of=$(VMLINUX).gz bs=65536 conv=sync
66         $(call MkImageGzip,$(KDIR)/vmlinux.bin.gz,$(UIMAGE)-gzip.bin)
67         $(call MkImageLzma,$(KDIR)/vmlinux.bin.lzma,$(UIMAGE)-lzma.bin)
68         $(call Image/Build/Initramfs)
69 endef
70
71 define Image/Build/WRT400N
72         $(call PatchKernelLzma,$(2),$(3))
73         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1310720 ]; then \
74                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
75         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6488064 ]; then \
76                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
77         else \
78                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
79                         0x80060000 \
80                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
81                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
82                 ( \
83                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1280k conv=sync; \
84                         dd if=$(KDIR)/root.$(1) \
85                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
86                 wrt400n $(KDIR)/vmlinux-$(2).uImage $(KDIR)/root.$(1) $(call imgname,$(1),$(2))-factory.bin; \
87         fi; fi
88 endef
89
90 dir825b1_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),5184k(rootfs),64k(caldata)ro,1600k(unknown)ro,6208k@0x50000(firmware)
91 define Image/Build/DIR825B1
92         $(call PatchKernelLzma,$(2),$(3) $(dir825b1_mtdlayout))
93         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1048576 ]; then \
94                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
95         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 5308416 ]; then \
96                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
97         else \
98                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
99                         0x80060000 \
100                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
101                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
102                 ( \
103                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync; \
104                         dd if=$(KDIR)/root.$(1) \
105                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
106                 ( \
107                         dd if=$(call imgname,$(1),$(2))-sysupgrade.bin; \
108                         echo -n "01AP94-AR7161-RT-080619-00"; \
109                 ) > $(call imgname,$(1),$(2))-backup-loader.bin; \
110                 if [ `stat -c%s $(call imgname,$(1),$(2))-sysupgrade.bin` -gt 4194304 ]; then \
111                         echo "Warning: $(call imgname,$(1),$(2))-sysupgrade.bin is too big"; \
112                 else \
113                         ( \
114                                 dd if=$(call imgname,$(1),$(2))-sysupgrade.bin bs=4096k conv=sync; \
115                                 echo -n "00AP94-AR7161-RT-080619-00"; \
116                         ) > $(call imgname,$(1),$(2))-factory.bin; \
117                 fi; \
118         fi; fi
119 endef
120
121 define Image/Build/WZRHPG300NH
122         $(call PatchKernelLzma,$(2),$(3))
123         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1048576 ]; then \
124                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
125         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 31850496 ]; then \
126                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
127         else \
128                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
129                         0x80060000 \
130                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
131                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
132                 ( \
133                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync; \
134                         dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
135                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
136                 ( \
137                         echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \
138                         dd if=$(call imgname,$(1),$(2))-sysupgrade.bin; \
139                 ) > $(call imgname,$(1),$(2))-tftp.bin; \
140         fi; fi
141 endef
142
143 cameo_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,896k(kernel),2944k(rootfs),64k(art)ro,3840k@0x30000(firmware)
144 define Image/Build/Cameo
145         $(call PatchKernelLzma,$(2),$(3) $(cameo_mtdlayout))
146         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 917504 ]; then \
147                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
148         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 2949120 ]; then \
149                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
150         else \
151                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
152                         0x80060000 \
153                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
154                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
155                 ( \
156                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=896k conv=sync; \
157                         dd if=$(KDIR)/root.$(1) \
158                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
159                 ( \
160                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=896k conv=sync; \
161                         dd if=$(KDIR)/root.$(1) bs=2880k conv=sync; \
162                         echo -n $(4); \
163                 ) > $(call imgname,$(1),$(2))-factory.bin; \
164         fi; fi
165 endef
166
167 cameo7240_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,896k(kernel),2816k(rootfs),64k(mac)ro,64k(art)ro,3712k@0x40000(firmware)
168 define Image/Build/Cameo7240
169         $(call PatchKernelLzma,$(2),$(3) $(cameo7240_mtdlayout))
170         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 917504 ]; then \
171                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
172         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 2818048 ]; then \
173                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
174         else \
175                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
176                         0x80060000 \
177                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
178                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
179                 ( \
180                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=896k conv=sync; \
181                         dd if=$(KDIR)/root.$(1) \
182                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
183                 ( \
184                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=896k conv=sync; \
185                         dd if=$(KDIR)/root.$(1) bs=2752k conv=sync; \
186                         echo -n $(4); \
187                 ) > $(call imgname,$(1),$(2))-factory.bin; \
188         fi; fi
189 endef
190
191 define Image/Build/AP83
192         $(call PatchKernelGzip,$(2),$(3))
193         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gz"` -gt 1310720 ]; then \
194                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.gz is too big"; \
195         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6619136 ]; then \
196                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
197         else \
198                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip -e \
199                         0x80060000 \
200                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
201                         -d $(KDIR)/vmlinux-$(2).bin.gz \
202                         $(KDIR)/vmlinux-$(2).uImage; \
203                 dd if=$(KDIR)/vmlinux-$(2).uImage \
204                         of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
205                 dd if=$(KDIR)/root.$(1) \
206                         of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
207                 ( \
208                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1280k conv=sync; \
209                         dd if=$(KDIR)/root.$(1); \
210                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
211         fi; fi
212 endef
213
214 define Image/Build/PB4X
215         $(call PatchKernelLzma,$(2),$(3))
216         dd if=$(KDIR)/vmlinux-$(2).bin.lzma \
217            of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync
218         dd if=$(KDIR)/root.$(1) \
219            of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync
220         -sh $(TOPDIR)/scripts/combined-image.sh \
221                 "$(call imgname,kernel,$(2)).bin" \
222                 "$(call imgname,$(1),$(2)-rootfs).bin" \
223                 $(call imgname,$(1),$(2))-sysupgrade.bin
224 endef
225
226 define Image/Build/MyLoader
227         -$(STAGING_DIR_HOST)/bin/mkmylofw -B $(2) -s $(3) \
228                 -p0x030000:0xe0000:al:0x80060000:kernel:$(KDIR)/vmlinux.bin.lzma \
229                 -p0x110000:0:::rootfs:$(KDIR)/root.$(1) \
230                 $(call imgname,$(1),$(2))-$(4)-factory.img
231 endef
232
233 ubntxm_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1024k(kernel),6528k(rootfs),256k(cfg)ro,64k(EEPROM)ro,7552k@0x50000(firmware)
234 define Image/Build/UBNTXM
235         $(call PatchKernelLzma,$(2),$(3) $(ubntxm_mtdlayout))
236         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(KDIR)/vmlinux-$(2).uImage.bin)
237         dd if=$(KDIR)/vmlinux-$(2).uImage.bin of=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync
238         -$(STAGING_DIR_HOST)/bin/mkfwimage \
239                 -B $(4) -v $(5).$(6).OpenWrt.$(REVISION) \
240                 -k $(KDIR)/vmlinux-$(2).uImage \
241                 -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
242                 -o $(call imgname,$(1),$(2))-factory.bin
243         ( \
244                 dd if=$(KDIR)/vmlinux-$(2).uImage; \
245                 dd if=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1); \
246         ) > $(call imgname,$(1),$(2))-sysupgrade.bin
247 endef
248
249 define Image/Build/UBNT
250         $(call PatchKernelLzma,$(2),$(3))
251         dd if=$(KDIR)/vmlinux-$(2).bin.lzma of=$(KDIR)/vmlinux-$(2).lzma bs=64k conv=sync
252         -$(STAGING_DIR_HOST)/bin/mkfwimage \
253                 -B $(4) -v $(5).$(6).OpenWrt.$(REVISION) \
254                 -k $(KDIR)/vmlinux-$(2).lzma \
255                 -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
256                 -o $(call imgname,$(1),$(2))-factory.bin
257         -sh $(TOPDIR)/scripts/combined-image.sh \
258                 "$(KDIR)/vmlinux-$(2).lzma" \
259                 "$(BIN_DIR)/$(IMG_PREFIX)-root.$(1)" \
260                 $(call imgname,$(1),$(2))-sysupgrade.bin
261 endef
262
263 define Image/Build/Planex
264         $(call PatchKernelGzip,$(2),$(3))
265         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gz"` -gt 1441792 ]; then \
266                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.gz is too big"; \
267         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6356992 ]; then \
268                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
269         else \
270                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip -e \
271                         0x80060000 \
272                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
273                         -d $(KDIR)/vmlinux-$(2).bin.gz $(KDIR)/vmlinux-$(2).uImage; \
274                 ( \
275                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1408k conv=sync; \
276                         dd if=$(KDIR)/root.$(1); \
277                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
278                 $(STAGING_DIR_HOST)/bin/mkplanexfw \
279                         -B $(2) \
280                         -v 2.00.00 \
281                         -i $(call imgname,$(1),$(2))-sysupgrade.bin \
282                         -o $(call imgname,$(1),$(2))-factory.bin; \
283         fi; fi
284 endef
285
286 define Image/Build/TPLINK
287         $(call PatchKernelGzip,$(2),$(3))
288         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
289                 -B $(4) -N OpenWrt -V $(REVISION)\
290                 -k $(KDIR)/vmlinux-$(2).bin.gz \
291                 -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
292                 -o $(call imgname,$(1),$(2))-factory.bin
293         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
294                 -B $(4) -N OpenWrt -V $(REVISION) -s \
295                 -k $(KDIR)/vmlinux-$(2).bin.gz \
296                 -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
297                 -o $(call imgname,$(1),$(2))-sysupgrade.bin
298 endef
299
300 define Image/Build/TPLINK/initramfs
301         $(call PatchKernelGzip,$(2),$(3))
302         -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
303                 -B $(4) -N OpenWrt -V $(REVISION) -s \
304                 -k $(KDIR)/vmlinux-$(2).bin.gz \
305                 -o $(call imgname,$(1),$(2))-uImage.bin
306 endef
307
308 define Image/Build/CyberTAN
309         $(call PatchKernelGzip,$(2),$(3))
310         $(call MkImageGzip,$(KDIR)/vmlinux-$(2).bin.gz,$(KDIR)/vmlinux-$(2).uImage)
311         $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp -f $(KDIR)/vmlinux-$(2).uImage \
312                 -x 32 -a 0x10000 -x -32 -f $(KDIR)/root.$(1)
313         -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(4) \
314                 -i $(KDIR)/image.tmp \
315                 -o $(call imgname,$(1),$(2))-sysupgrade.bin
316         -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(4) -g \
317                 -i $(KDIR)/image.tmp \
318                 -o $(call imgname,$(1),$(2))-factory.bin
319         rm $(KDIR)/image.tmp
320 endef
321
322 define Image/Build/Netgear
323         $(call PatchKernelLzma,$(2),$(3) $($(4)))
324         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(KDIR)/vmlinux-$(2).uImage)
325         mkdir -p $(KDIR)/wndr3700/image
326         $(STAGING_DIR_HOST)/bin/wndr3700 \
327                 $(KDIR)/vmlinux-$(2).uImage \
328                 $(KDIR)/wndr3700/image/uImage \
329                 $(5)
330         $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
331                 $(KDIR)/wndr3700 $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp \
332                 -nopad -noappend -root-owned -be
333         -rm -rf $(KDIR)/wndr3700
334         mkimage -A mips -O linux -T filesystem -C none \
335                 -a 0xbf070000 -e 0xbf070000 \
336                 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
337                 -d $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp \
338                 $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp2
339         $(STAGING_DIR_HOST)/bin/wndr3700 \
340                 $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp2 \
341                 $(KDIR)/vmlinux-$(2).uImage.squashfs \
342                 $(5)
343         -rm -f $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp*
344         ( \
345                 dd if=$(KDIR)/vmlinux-$(2).uImage.squashfs bs=1024k conv=sync; \
346                 dd if=$(KDIR)/root.$(1) bs=64k; \
347         ) > $(call imgname,$(1),$(2))-sysupgrade.bin
348         $(STAGING_DIR_HOST)/bin/mkdniimg \
349                 -B $(6) -v OpenWrt.$(REVISION) \
350                 -i $(call imgname,$(1),$(2))-sysupgrade.bin \
351                 -o $(call imgname,$(1),$(2))-factory.img
352         $(STAGING_DIR_HOST)/bin/mkdniimg \
353                 -B $(6) -v OpenWrt.$(REVISION) -r "NA" \
354                 -i $(call imgname,$(1),$(2))-sysupgrade.bin \
355                 -o $(call imgname,$(1),$(2))-factory-NA.img
356 endef
357
358 define Image/Build/Netgear/initramfs
359         $(call PatchKernelLzma,$(2),$(3) $($(4)))
360         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(KDIR)/vmlinux-$(2).uImage)
361         $(STAGING_DIR_HOST)/bin/wndr3700 \
362                 $(KDIR)/vmlinux-$(2).uImage \
363                 $(call imgname,$(1),$(2))-uImage.bin \
364                 $(5)
365 endef
366
367 define Image/Build/Template/initramfs/initramfs
368         $(call Image/Build/$(1)/initramfs,initramfs,$(2),$(3),$(4),$(5),$(6),$(7))
369 endef
370
371 define Image/Build/Template/all/squashfs
372         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
373 endef
374
375 define Image/Build/Template/all/jffs2-64k
376         $(call Image/Build/$(1),jffs2-64k,$(2),$(3),$(4),$(5),$(6),$(7))
377 endef
378
379 define Image/Build/Template/all/jffs2-128k
380         $(call Image/Build/$(1),jffs2-128k,$(2),$(3),$(4),$(5),$(6),$(7))
381 endef
382
383 define Image/Build/Template/squashfs-only/squashfs
384         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
385 endef
386
387 define Image/Build/Template/4k/squashfs
388         $(call Image/Build/$(1),squashfs-4k,$(2),$(3),$(4),$(5),$(6),$(7))
389 endef
390
391 define Image/Build/Template/64k/squashfs
392         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
393 endef
394
395 define Image/Build/Template/64k/jffs2-64k
396         $(call Image/Build/$(1),jffs2-64k,$(2),$(3),$(4),$(5),$(6),$(7))
397 endef
398
399 define Image/Build/Template/128k/squashfs
400         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
401 endef
402
403 define Image/Build/Template/128k/jffs2-128k
404         $(call Image/Build/$(1),jffs2-128k,$(2),$(3),$(4),$(5),$(6),$(7))
405 endef
406
407 define Image/Build/Profile/AP81
408         $(call Image/Build/Template/$(fs_64k)/$(1),AP83,ap81,board=AP81)
409 endef
410
411 define Image/Build/Profile/AP83
412         $(call Image/Build/Template/$(fs_64k)/$(1),AP83,ap83,board=AP83)
413 endef
414
415 define Image/Build/Profile/PB42
416         $(call Image/Build/Template/$(fs_64k)/$(1),PB4X,pb42,board=PB42)
417 endef
418
419 define Image/Build/Profile/PB44
420         $(call Image/Build/Template/$(fs_64k)/$(1),PB4X,pb44,board=PB44)
421 endef
422
423 define Image/Build/Profile/WP543
424         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x200000,2M)
425         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x400000,4M)
426         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x800000,8M)
427         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x1000000,16M)
428 endef
429
430 define Image/Build/Profile/DIR600A1
431         $(call Image/Build/Template/$(fs_64k)/$(1),Cameo7240,dir-600-a1,board=DIR-600-A1,"AP91-AR7240-RT-090223-00")
432 endef
433
434 define Image/Build/Profile/FR54RTR
435         $(call Image/Build/Template/$(fs_64k)/$(1),Cameo7240,fr-54rtr,board=DIR-600-A1,"AP91-AR7240-RT-090223-01")
436 endef
437
438 define Image/Build/Profile/DIR615C1
439         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,dir-615-c1,board=DIR-615-C1,"AP81-AR9130-RT-070614-02")
440 endef
441
442 define Image/Build/Profile/TEW632BRP
443         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,tew-632brp,board=TEW-632BRP,"AP81-AR9130-RT-070614-00")
444 endef
445
446 define Image/Build/Profile/TEW652BRP
447         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,tew-652brp,board=TEW-632BRP,"AP81-AR9130-RT-080609-05")
448         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,tew-652brp-recovery,board=TEW-632BRP,"AP81-AR9130-RT-070614-02")
449 endef
450
451 define Image/Build/Profile/A02RBW300N
452         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,a02-rb-w300n,board=TEW-632BRP,"AP81-AR9130-RT-070614-03")
453 endef
454
455 define Image/Build/Profile/UBNTRS
456         $(call Image/Build/Template/$(fs_64k)/$(1),UBNT,ubnt-rs,board=UBNT-RS,RS,RSx,ar7100)
457 endef
458
459 define Image/Build/Profile/UBNTRSPRO
460         $(call Image/Build/Template/$(fs_64k)/$(1),UBNT,ubnt-rspro,board=UBNT-RSPRO,RSPRO,RSPRO,ar7100pro)
461 endef
462
463 define Image/Build/Profile/UBNTLSSR71
464         $(call Image/Build/Template/$(fs_64k)/$(1),UBNT,ubnt-ls-sr71,board=UBNT-LS-SR71,LS-SR71,LS-SR71,ar7100)
465 endef
466
467 define Image/Build/Profile/UBNTBULLETM
468         $(call Image/Build/Template/$(fs_64k)/$(1),UBNTXM,ubnt-bullet-m,board=UBNT-BM,XM,UBNTXM,ar7240)
469 endef
470
471 define Image/Build/Profile/UBNTROCKETM
472         $(call Image/Build/Template/$(fs_64k)/$(1),UBNTXM,ubnt-rocket-m,board=UBNT-RM,XM,UBNTXM,ar7240)
473 endef
474
475 define Image/Build/Profile/UBNTNANOM
476         $(call Image/Build/Template/$(fs_64k)/$(1),UBNTXM,ubnt-nano-m,board=UBNT-NM,XM,UBNTXM,ar7240)
477 endef
478
479 define Image/Build/Profile/UBNT
480         $(call Image/Build/Profile/UBNTRS,$(1))
481         $(call Image/Build/Profile/UBNTRSPRO,$(1))
482         $(call Image/Build/Profile/UBNTLSSR71,$(1))
483         $(call Image/Build/Profile/UBNTBULLETM,$(1))
484         $(call Image/Build/Profile/UBNTROCKETM,$(1))
485         $(call Image/Build/Profile/UBNTNANOM,$(1))
486 endef
487
488 define Image/Build/Profile/MZKW04NU
489         $(call Image/Build/Template/$(fs_64k)/$(1),Planex,mzk-w04nu,board=MZK-W04NU)
490 endef
491
492 define Image/Build/Profile/MZKW300NH
493         $(call Image/Build/Template/$(fs_64k)/$(1),Planex,mzk-w300nh,board=MZK-W300NH)
494 endef
495
496 define Image/Build/Profile/TLMR3420V1
497         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-mr3420-v1,board=TL-MR3420,TL-MR3420v1)
498 endef
499
500 define Image/Build/Profile/TLWR741NDV1
501         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr741nd-v1,board=TL-WR741ND,TL-WR741NDv1)
502 endef
503
504 define Image/Build/Profile/TLWR740NV1
505         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr740n-v1,board=TL-WR741ND,TL-WR740Nv1)
506 endef
507
508 define Image/Build/Profile/TLWR841NV15
509         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr841n-v1.5,board=TL-WR841N-v1.5,TL-WR841Nv1.5)
510 endef
511
512 define Image/Build/Profile/TLWR841NDV3
513         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr841nd-v3,board=TL-WR941ND,TL-WR841NDv3)
514 endef
515
516 define Image/Build/Profile/TLWR841NDV5
517         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr841nd-v5,board=TL-WR741ND,TL-WR841NDv5)
518 endef
519
520 define Image/Build/Profile/TLWR941NDV2
521         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr941nd-v2,board=TL-WR941ND,TL-WR941NDv2)
522 endef
523
524 define Image/Build/Profile/TLWR941NDV3
525         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr941nd-v3,board=TL-WR941ND,TL-WR941NDv2)
526 endef
527
528 define Image/Build/Profile/TLWR941NDV4
529         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr941nd-v4,board=TL-WR741ND,TL-WR941NDv4)
530 endef
531
532 define Image/Build/Profile/TLWR1043NDV1
533         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr1043nd-v1,board=TL-WR1043ND,TL-WR1043NDv1)
534 endef
535
536 wndr3700_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1024k(kernel),6656k(rootfs),64k(art)ro,7680k@0x70000(firmware)
537 wndr3700v2_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1024k(kernel),14848k(rootfs),64k(art)ro,15872k@0x70000(firmware)
538 define Image/Build/Profile/WNDR3700
539         $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3700,board=WNDR3700,wndr3700_mtdlayout,3700,WNDR3700)
540         $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3700v2,board=WNDR3700v2,wndr3700v2_mtdlayout,3701,WNDR3700v2)
541         $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3800,$(wndr3700v2_cmdline),wndr3700v2_mtdlayout,3701,WNDR3800,"",-H 29763654+16+128)
542 endef
543
544 define Image/Build/Profile/WRT400N
545         $(call Image/Build/Template/$(fs_64k)/$(1),WRT400N,wrt400n,board=WRT400N)
546 endef
547
548 define Image/Build/Profile/DIR825B1
549         $(call Image/Build/Template/$(fs_64k)/$(1),DIR825B1,dir-825-b1,board=DIR-825-B1)
550 endef
551
552 define Image/Build/Profile/WRT160NL
553         $(call Image/Build/Template/$(fs_64k)/$(1),CyberTAN,wrt160nl,board=WRT160NL,1.00.01)
554 endef
555
556 define Image/Build/Profile/WZRHPG300NH
557         $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG300NH,wzr-hp-g300nh,board=WZR-HP-G300NH)
558 endef
559
560 define Image/Build/Profile/Default
561         $(call Image/Build/Profile/AP81,$(1))
562         $(call Image/Build/Profile/AP83,$(1))
563         $(call Image/Build/Profile/A02RBW300N,$(1))
564         $(call Image/Build/Profile/DIR600A1,$(1))
565         $(call Image/Build/Profile/DIR615C1,$(1))
566         $(call Image/Build/Profile/DIR825B1,$(1))
567         $(call Image/Build/Profile/FR54RTR,$(1))
568         $(call Image/Build/Profile/MZKW04NU,$(1))
569         $(call Image/Build/Profile/MZKW300NH,$(1))
570         $(call Image/Build/Profile/PB42,$(1))
571         $(call Image/Build/Profile/PB44,$(1))
572         $(call Image/Build/Profile/TEW632BRP,$(1))
573         $(call Image/Build/Profile/TEW652BRP,$(1))
574         $(call Image/Build/Profile/TLMR3420V1,$(1))
575         $(call Image/Build/Profile/TLWR741NDV1,$(1))
576         $(call Image/Build/Profile/TLWR740NV1,$(1))
577         $(call Image/Build/Profile/TLWR841NV15,$(1))
578         $(call Image/Build/Profile/TLWR841NDV3,$(1))
579         $(call Image/Build/Profile/TLWR841NDV5,$(1))
580         $(call Image/Build/Profile/TLWR941NDV2,$(1))
581         $(call Image/Build/Profile/TLWR941NDV3,$(1))
582         $(call Image/Build/Profile/TLWR941NDV4,$(1))
583         $(call Image/Build/Profile/TLWR1043NDV1,$(1))
584         $(call Image/Build/Profile/UBNT,$(1))
585         $(call Image/Build/Profile/WP543,$(1))
586         $(call Image/Build/Profile/WNDR3700,$(1))
587         $(call Image/Build/Profile/WRT400N,$(1))
588         $(call Image/Build/Profile/WRT160NL,$(1))
589         $(call Image/Build/Profile/WZRHPG300NH,$(1))
590 endef
591
592 define Image/Build/Profile/Madwifi
593         $(call Image/Build/Profile/UBNTRS,$(1))
594         $(call Image/Build/Profile/UBNTRSPRO,$(1))
595         $(call Image/Build/Profile/UBNTLSSR71,$(1))
596         $(call Image/Build/Profile/WP543,$(1))
597 endef
598
599 define Image/Build/squashfs
600         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
601         dd if=$(KDIR)/root.squashfs of=$(KDIR)/root.squashfs-4k.tmp0 bs=4k conv=sync
602         $(call add_jffs2_mark,$(KDIR)/root.squashfs-4k.tmp0)
603         dd if=$(KDIR)/root.squashfs-4k.tmp0 of=$(BIN_DIR)/$(IMG_PREFIX)-root.squashfs-4k bs=4k conv=sync
604         $(call add_jffs2_mark,$(BIN_DIR)/$(IMG_PREFIX)-root.squashfs-4k)
605         rm -f $(KDIR)/root.squashfs-4k.tmp0
606 endef
607
608 define Image/Build/Initramfs
609         $(call Image/Build/Profile/$(PROFILE),initramfs)
610 endef
611
612 define Image/Build
613         $(call Image/Build/$(1))
614         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
615
616         $(call Image/Build/Profile/$(PROFILE),$(1))
617 endef
618
619 $(eval $(call BuildImage))