2 # Copyright (C) 2008-2009 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR
)/rules.mk
8 include $(INCLUDE_DIR
)/image.mk
10 IMGNAME
:=$(BIN_DIR
)/openwrt-
$(BOARD
)
13 $(IMGNAME
)-$(2)-$(patsubst jffs2-
%,jffs2
,$(patsubst squashfs-
%,squashfs
,$(1)))
16 VMLINUX
:=$(IMGNAME
)-vmlinux
17 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
18 VMLINUX
:=$(IMGNAME
)-vmlinux-initramfs
21 define Image
/BuildKernel
22 cp
$(KDIR
)/vmlinux.elf
$(VMLINUX
).elf
23 cp
$(KDIR
)/vmlinux
$(VMLINUX
).bin
24 gzip
-9 -c
$(KDIR
)/vmlinux
> $(KDIR
)/vmlinux.bin.gz
25 $(STAGING_DIR_HOST
)/bin
/lzma e
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux.bin.l7
26 $(STAGING_DIR_HOST
)/bin
/lzma e
$(KDIR
)/vmlinux
-lc1
-lp2
-pb2
$(KDIR
)/vmlinux.bin.lzma
27 dd if
=$(KDIR
)/vmlinux.bin.l7 of
=$(VMLINUX
).lzma bs
=65536 conv
=sync
28 dd if
=$(KDIR
)/vmlinux.bin.gz of
=$(VMLINUX
).gz bs
=65536 conv
=sync
29 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C gzip
-e \
31 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
32 -d
$(KDIR
)/vmlinux.bin.gz
$(IMGNAME
)-uImage-gzip.bin
33 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C lzma
-e \
35 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
36 -d
$(KDIR
)/vmlinux.bin.lzma
$(IMGNAME
)-uImage-lzma.bin
39 define Image
/Build
/WRT400N
40 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
41 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
42 $(STAGING_DIR_HOST
)/bin
/lzma e
$(KDIR
)/vmlinux-
$(2) $(KDIR
)/vmlinux-
$(2).bin.lzma
43 if
[ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt
1310720 ]; then \
44 echo
"Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
45 else if
[ `stat -c%s $(KDIR)/root.$(1)` -gt
6488064 ]; then \
46 echo
"Warning: $(KDIR)/root.$(1) is too big"; \
48 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C lzma
-e \
50 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
51 -d
$(KDIR
)/vmlinux-
$(2).bin.lzma
$(KDIR
)/vmlinux-
$(2).uImage
; \
53 dd if
=$(KDIR
)/vmlinux-
$(2).uImage bs
=1280k conv
=sync
; \
54 dd if
=$(KDIR
)/root.
$(1) bs
=6336k conv
=sync
; \
56 ) > $(call imgname
,$(1),$(2)).bin
; \
57 wrt400n
$(KDIR
)/vmlinux-
$(2).uImage
$(KDIR
)/root.
$(1) $(call imgname
,$(1),$(2)).webui
; \
61 define Image
/Build
/AP81
62 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
63 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
64 $(STAGING_DIR_HOST
)/bin
/lzma e
$(KDIR
)/vmlinux-
$(2) $(KDIR
)/vmlinux-
$(2).bin.lzma
65 if
[ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt
851968 ]; then \
66 echo
"Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
67 else if
[ `stat -c%s $(KDIR)/root.$(1)` -gt
3014656 ]; then \
68 echo
"Warning: $(KDIR)/root.$(1) is too big"; \
70 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C lzma
-e \
72 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
73 -d
$(KDIR
)/vmlinux-
$(2).bin.lzma
$(KDIR
)/vmlinux-
$(2).uImage
; \
75 dd if
=$(KDIR
)/vmlinux-
$(2).uImage bs
=832k conv
=sync
; \
76 dd if
=$(KDIR
)/root.
$(1) bs
=2944k conv
=sync
; \
78 ) > $(call imgname
,$(1),$(2)).uni
; \
82 define Image
/Build
/AP83
83 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
84 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
85 gzip
-9 -c
$(KDIR
)/vmlinux-
$(2) > $(KDIR
)/vmlinux-
$(2).bin.gz
86 if
[ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gz"` -gt
1310720 ]; then \
87 echo
"Warning: $(KDIR)/vmlinux-$(2).bin.gz is too big"; \
88 else if
[ `stat -c%s $(KDIR)/root.$(1)` -gt
6619136 ]; then \
89 echo
"Warning: $(KDIR)/root.$(1) is too big"; \
91 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C gzip
-e \
93 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
94 -d
$(KDIR
)/vmlinux-
$(2).bin.gz \
95 $(KDIR
)/vmlinux-
$(2).uImage
; \
96 dd if
=$(KDIR
)/vmlinux-
$(2).uImage \
97 of
=$(call imgname
,kernel
,$(2)).bin bs
=64k conv
=sync
; \
98 dd if
=$(KDIR
)/root.
$(1) \
99 of
=$(call imgname
,$(1),$(2)-rootfs
).bin bs
=128k conv
=sync
; \
101 dd if
=$(KDIR
)/vmlinux-
$(2).uImage bs
=1280k conv
=sync
; \
102 dd if
=$(KDIR
)/root.
$(1); \
103 ) > $(call imgname
,$(1),$(2)-firmware
).bin
; \
107 define Image
/Build
/MyLoader
108 -$(STAGING_DIR_HOST
)/bin
/mkmylofw
-B
$(2) \
109 -p0x030000
:0xd0000:al
:0x80060000:kernel
:$(KDIR
)/vmlinux.bin.lzma \
110 -p0x100000
:0:::rootfs
:$(KDIR
)/root.
$(1) \
111 $(call imgname
,$(1),$(2))-2M.img
112 -$(STAGING_DIR_HOST
)/bin
/mkmylofw
-B
$(2) -s
0x400000 \
113 -p0x030000
:0xd0000:al
:0x80060000:kernel
:$(KDIR
)/vmlinux.bin.lzma \
114 -p0x100000
:0:::rootfs
:$(KDIR
)/root.
$(1) \
115 $(call imgname
,$(1),$(2))-4M.img
116 -$(STAGING_DIR_HOST
)/bin
/mkmylofw
-B
$(2) -s
0x800000 \
117 -p0x030000
:0xd0000:al
:0x80060000:kernel
:$(KDIR
)/vmlinux.bin.lzma \
118 -p0x100000
:0:::rootfs
:$(KDIR
)/root.
$(1) \
119 $(call imgname
,$(1),$(2))-8M.img
120 -$(STAGING_DIR_HOST
)/bin
/mkmylofw
-B
$(2) -s
0x1000000 \
121 -p0x030000
:0xd0000:al
:0x80060000:kernel
:$(KDIR
)/vmlinux.bin.lzma \
122 -p0x100000
:0:::rootfs
:$(KDIR
)/root.
$(1) \
123 $(call imgname
,$(1),$(2))-16M.img
126 define Image
/Build
/UBNT
127 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
128 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
129 $(STAGING_DIR_HOST
)/bin
/lzma e
$(KDIR
)/vmlinux-
$(2) $(KDIR
)/vmlinux-
$(2).lzma
130 dd if
=$(KDIR
)/vmlinux-
$(2).lzma of
=$(KDIR
)/vmlinux-
$(2).bin.lzma bs
=64k conv
=sync
131 -$(STAGING_DIR_HOST
)/bin
/mkfwimage \
132 -B
$(4) -v
$(5).
$(6).OpenWrt.
$(REVISION
) \
133 -k
$(KDIR
)/vmlinux-
$(2).bin.lzma \
134 -r
$(BIN_DIR
)/openwrt-
$(BOARD
)-root.
$(1) \
135 -o
$(call imgname
,$(1),$(2)).bin
138 define Image
/Build
/Planex
139 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
140 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
141 gzip
-9 -c
$(KDIR
)/vmlinux-
$(2) > $(KDIR
)/vmlinux-
$(2).bin.gzip
142 if
[ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gzip"` -gt
1441792 ]; then \
143 echo
"Warning: $(KDIR)/vmlinux-$(2).bin.gzip is too big"; \
144 else if
[ `stat -c%s $(KDIR)/root.$(1)` -gt
6356992 ]; then \
145 echo
"Warning: $(KDIR)/root.$(1) is too big"; \
147 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C gzip
-e \
149 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
150 -d
$(KDIR
)/vmlinux-
$(2).bin.gzip
$(KDIR
)/vmlinux-
$(2).uImage
; \
152 dd if
=$(KDIR
)/vmlinux-
$(2).uImage bs
=1408k conv
=sync
; \
153 dd if
=$(KDIR
)/root.
$(1) bs
=6208k conv
=sync
; \
154 ) > $(call imgname
,$(1),$(2)).bin
; \
155 $(STAGING_DIR_HOST
)/bin
/mkplanexfw \
158 -i
$(call imgname
,$(1),$(2)).bin \
159 -o
$(call imgname
,$(1),$(2)).webui
; \
163 define Image
/Build
/TPLINK
164 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
165 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
166 gzip
-9 -c
$(KDIR
)/vmlinux-
$(2) > $(KDIR
)/vmlinux-
$(2).bin.gzip
167 -$(STAGING_DIR_HOST
)/bin
/mktplinkfw \
168 -B
$(4) -N OpenWrt
-V
$(REVISION
)\
169 -k
$(KDIR
)/vmlinux-
$(2).bin.gzip \
170 -r
$(BIN_DIR
)/openwrt-
$(BOARD
)-root.
$(1) \
171 -o
$(call imgname
,$(1),$(2)).uni
174 define Image
/Build
/CyberTAN
175 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(2)
176 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(2) '$(strip $(3))'
177 gzip
-9 -c
$(KDIR
)/vmlinux-
$(2) > $(KDIR
)/vmlinux-
$(2).bin.gzip
178 mkimage
-A mips
-O linux
-T kernel
-a
0x80060000 -C gzip
-e \
180 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
181 -d
$(KDIR
)/vmlinux-
$(2).bin.gzip
$(KDIR
)/vmlinux-
$(2).uImage
183 dd if
=$(KDIR
)/vmlinux-
$(2).uImage bs
=64k conv
=sync
; \
184 dd if
=/dev
/zero bs
=1 count
=65476; \
185 dd if
=$(KDIR
)/root.
$(1) bs
=64k
; \
186 ) > $(KDIR
)/vmlinux-
$(2).image
187 $(STAGING_DIR_HOST
)/bin
/trx
-o
$(KDIR
)/vmlinux-
$(2).trx \
188 -f
$(KDIR
)/vmlinux-
$(2).image
189 -$(STAGING_DIR_HOST
)/bin
/addpattern
-B
$(2) -v v
$(4) -g \
190 -i
$(KDIR
)/vmlinux-
$(2).trx \
191 -o
$(call imgname
,$(1),$(2)).bin
194 define Image
/Build
/Template
/Compex
195 $(call Image
/Build
/MyLoader
,$(1),$(2))
198 define Image
/Build
/Template
/Compex
/squashfs
199 $(call Image
/Build
/Template
/Compex
,squashfs
,$(1))
202 define Image
/Build
/Template
/WRT400N
203 $(call Image
/Build
/WRT400N
,$(1),$(2),$(3),$(4))
206 define Image
/Build
/Template
/WRT400N
/squashfs
207 $(call Image
/Build
/Template
/WRT400N
,squashfs
,$(1),$(2),$(3))
210 define Image
/Build
/Template
/WRT400N
/jffs2-64k
211 $(call Image
/Build
/Template
/WRT400N
,jffs2-64k
,$(1),$(2),$(3))
214 define Image
/Build
/Template
/CyberTAN
215 $(call Image
/Build
/CyberTAN
,$(1),$(2),$(3),$(4))
218 define Image
/Build
/Template
/CyberTAN
/squashfs
219 $(call Image
/Build
/Template
/CyberTAN
,squashfs
,$(1),$(2),$(3))
222 define Image
/Build
/Template
/CyberTAN
/jffs2-64k
223 $(call Image
/Build
/Template
/CyberTAN
,jffs2-64k
,$(1),$(2),$(3))
226 define Image
/Build
/Template
/AP81
227 $(call Image
/Build
/AP81
,$(1),$(2),$(3),$(4))
230 define Image
/Build
/Template
/AP81
/squashfs
231 $(call Image
/Build
/Template
/AP81
,squashfs
,$(1),$(2),$(3))
234 define Image
/Build
/Template
/AP83
235 $(call Image
/Build
/AP83
,$(1),$(2),$(3))
238 define Image
/Build
/Template
/AP83
/squashfs
239 $(call Image
/Build
/Template
/AP83
,squashfs
,$(1),$(2))
242 define Image
/Build
/Template
/AP83
/jffs2-64k
243 $(call Image
/Build
/Template
/AP83
,jffs2-64k
,$(1),$(2))
246 define Image
/Build
/Template
/TPLINK
247 $(call Image
/Build
/TPLINK
,$(1),$(2),$(3),$(4))
250 define Image
/Build
/Template
/TPLINK
/squashfs
251 $(call Image
/Build
/Template
/TPLINK
,squashfs
,$(1),$(2),$(3))
254 define Image
/Build
/Template
/TPLINK4K
255 $(call Image
/Build
/TPLINK
,$(1),$(2),$(3),$(4))
258 define Image
/Build
/Template
/TPLINK4K
/squashfs
259 $(call Image
/Build
/Template
/TPLINK
,squashfs-4k
,$(1),$(2),$(3))
262 define Image
/Build
/Template
/UBNT
263 $(call Image
/Build
/UBNT
,$(1),$(2),$(3),$(4),$(5),$(6))
266 define Image
/Build
/Template
/UBNT
/squashfs
267 $(call Image
/Build
/Template
/UBNT
,squashfs
,$(1),$(2),$(3),$(4),$(5))
270 define Image
/Build
/Template
/UBNT
/jffs2-64k
271 $(call Image
/Build
/Template
/UBNT
,jffs2-64k
,$(1),$(2),$(3),$(4),$(5))
274 define Image
/Build
/Template
/Planex
275 $(call Image
/Build
/Planex
,$(1),$(2),$(3))
278 define Image
/Build
/Template
/Planex
/squashfs
279 $(call Image
/Build
/Template
/Planex
,squashfs
,$(1),$(2))
282 define Image
/Build
/Template
/Planex
/jffs2-64k
283 $(call Image
/Build
/Template
/Planex
,jffs2-64k
,$(1),$(2))
286 define Image
/Build
/Profile
/AP83
287 $(call Image
/Build
/Template
/AP83
/$(1),ap83
,board
=AP83
)
290 define Image
/Build
/Profile
/WP543
291 $(call Image
/Build
/Template
/Compex
/$(1),wp543
)
294 define Image
/Build
/Profile
/DIR615C1
295 $(call Image
/Build
/Template
/AP81
/$(1),dir-615c1
,board
=TEW-632BRP
,"AP81-AR9130-RT-070614-02")
298 define Image
/Build
/Profile
/TEW632BRP
299 $(call Image
/Build
/Template
/AP81
/$(1),tew-632brp
,board
=TEW-632BRP
,"AP81-AR9130-RT-070614-00")
302 define Image
/Build
/Profile
/TEW652BRP
303 $(call Image
/Build
/Template
/AP81
/$(1),tew-652brp
,board
=TEW-632BRP
,"AP81-AR9130-RT-080609-05")
306 define Image
/Build
/Profile
/A02RBW300N
307 $(call Image
/Build
/Template
/AP81
/$(1),a02-rb-w300n
,board
=TEW-632BRP
,"AP81-AR9130-RT-070614-03")
310 define Image
/Build
/Profile
/UBNTRS
311 $(call Image
/Build
/Template
/UBNT
/$(1),ubnt-rs
,board
=UBNT-RS
,RS
,RSx
,ar7100
)
314 define Image
/Build
/Profile
/UBNTRSPRO
315 $(call Image
/Build
/Template
/UBNT
/$(1),ubnt-rspro
,board
=UBNT-RSPRO
,RSPRO
,RSPRO
,ar7100pro
)
318 define Image
/Build
/Profile
/UBNTLSSR71
319 $(call Image
/Build
/Template
/UBNT
/$(1),ubnt-ls-sr71
,board
=UBNT-LS-SR71
,LS-SR71
,LS-SR71
,ar7100
)
322 define Image
/Build
/Profile
/UBNT
323 $(call Image
/Build
/Profile
/UBNTRS
,$(1))
324 $(call Image
/Build
/Profile
/UBNTRSPRO
,$(1))
325 $(call Image
/Build
/Profile
/UBNTLSSR71
,$(1))
328 define Image
/Build
/Profile
/MZKW04NU
329 $(call Image
/Build
/Template
/Planex
/$(1),mzk-w04nu
,board
=MZK-W04NU
)
332 define Image
/Build
/Profile
/MZKW300NH
333 $(call Image
/Build
/Template
/Planex
/$(1),mzk-w300nh
,board
=MZK-W300NH
)
336 define Image
/Build
/Profile
/TLWR741NDV1
337 $(call Image
/Build
/Template
/TPLINK4K
/$(1),tl-wr741ndv1
,board
=TL-WR741ND
,TL-WR741NDv1
)
340 define Image
/Build
/Profile
/TLWR841NDV3
341 $(call Image
/Build
/Template
/TPLINK
/$(1),tl-wr841ndv3
,board
=TL-WR941ND
,TL-WR841NDv3
)
344 define Image
/Build
/Profile
/TLWR941NDV2
345 $(call Image
/Build
/Template
/TPLINK
/$(1),tl-wr941ndv2
,board
=TL-WR941ND
,TL-WR941NDv2
)
348 define Image
/Build
/Profile
/WRT400N
349 $(call Image
/Build
/Template
/WRT400N
/$(1),wrt400n
,board
=WRT400N
)
352 define Image
/Build
/Profile
/WRT160NL
353 $(call Image
/Build
/Template
/CyberTAN
/$(1),wrt160nl
,board
=WRT160NL
,1.00.01)
356 define Image
/Build
/Profile
/Default
357 $(call Image
/Build
/Profile
/AP83
,$(1))
358 $(call Image
/Build
/Profile
/A02RBW300N
,$(1))
359 $(call Image
/Build
/Profile
/DIR615C1
,$(1))
360 $(call Image
/Build
/Profile
/MZKW04NU
,$(1))
361 $(call Image
/Build
/Profile
/MZKW300NH
,$(1))
362 $(call Image
/Build
/Profile
/TEW632BRP
,$(1))
363 $(call Image
/Build
/Profile
/TEW652BRP
,$(1))
364 $(call Image
/Build
/Profile
/TLWR741NDV1
,$(1))
365 $(call Image
/Build
/Profile
/TLWR841NDV3
,$(1))
366 $(call Image
/Build
/Profile
/TLWR941NDV2
,$(1))
367 $(call Image
/Build
/Profile
/UBNT
,$(1))
368 $(call Image
/Build
/Profile
/WP543
,$(1))
369 $(call Image
/Build
/Profile
/WRT400N
,$(1))
370 $(call Image
/Build
/Profile
/WRT160NL
,$(1))
373 define Image
/Build
/Profile
/Madwifi
374 $(call Image
/Build
/Profile
/UBNT
,$(1))
375 $(call Image
/Build
/Profile
/WP543
,$(1))
378 define Image
/Build
/squashfs
379 dd if
=$(KDIR
)/root.squashfs of
=$(IMGNAME
)-root.squashfs-4k bs
=4k conv
=sync
380 $(call add_jffs2_mark
,$(IMGNAME
)-root.squashfs-4k
)
381 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
385 $(call Image
/Build
/$(1))
386 dd if
=$(KDIR
)/root.
$(1) of
=$(IMGNAME
)-root.
$(1) bs
=128k conv
=sync
388 $(call Image
/Build
/Profile
/$(PROFILE
),$(1))
391 $(eval
$(call BuildImage
))