Makefile 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #
  2. # Copyright (C) 2008-2009 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. IMGNAME:=$(BIN_DIR)/openwrt-$(BOARD)
  10. define imgname
  11. $(IMGNAME)-$(2)-$(patsubst jffs2-%,jffs2,$(1))
  12. endef
  13. VMLINUX:=$(IMGNAME)-vmlinux
  14. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  15. VMLINUX:=$(IMGNAME)-vmlinux-initramfs
  16. endif
  17. define Image/BuildKernel
  18. cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
  19. cp $(KDIR)/vmlinux $(VMLINUX).bin
  20. gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
  21. $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
  22. $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux -lc1 -lp2 -pb2 $(KDIR)/vmlinux.bin.lzma
  23. dd if=$(KDIR)/vmlinux.bin.l7 of=$(VMLINUX).lzma bs=65536 conv=sync
  24. dd if=$(KDIR)/vmlinux.bin.gz of=$(VMLINUX).gz bs=65536 conv=sync
  25. mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip -e \
  26. 0x80060000 \
  27. -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  28. -d $(KDIR)/vmlinux.bin.gz $(IMGNAME)-uImage-gzip.bin
  29. mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
  30. 0x80060000 \
  31. -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  32. -d $(KDIR)/vmlinux.bin.lzma $(IMGNAME)-uImage-lzma.bin
  33. endef
  34. define Image/Build/AP81
  35. cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(2)
  36. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(2) '$(strip $(3))'
  37. $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux-$(2) $(KDIR)/vmlinux-$(2).bin.lzma
  38. if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 786432 ]; then \
  39. echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
  40. else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 3080192 ]; then \
  41. echo "Warning: $(KDIR)/root.$(1) is too big"; \
  42. else \
  43. mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
  44. 0x80060000 \
  45. -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  46. -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
  47. ( \
  48. dd if=$(KDIR)/vmlinux-$(2).uImage bs=768k conv=sync; \
  49. dd if=$(KDIR)/root.$(1) bs=3008k conv=sync; \
  50. echo -n $(4); \
  51. ) > $(call imgname,$(1),$(2)).uni; \
  52. fi; fi
  53. endef
  54. define Image/Build/MyLoader
  55. -$(STAGING_DIR_HOST)/bin/mkmylofw -B $(2) \
  56. -p0x30000:0xc0000:ahl:0x80060000:kernel:$(KDIR)/vmlinux.bin.lzma \
  57. -p0xf0000:0:::rootfs:$(KDIR)/root.$(1) \
  58. $(call imgname,$(1),$(2)).img
  59. endef
  60. define Image/Build/UBNT
  61. cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(2)
  62. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(2) '$(strip $(3))'
  63. $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux-$(2) $(KDIR)/vmlinux-$(2).lzma
  64. dd if=$(KDIR)/vmlinux-$(2).lzma of=$(KDIR)/vmlinux-$(2).bin.lzma bs=64k conv=sync
  65. -$(STAGING_DIR_HOST)/bin/mkfwimage \
  66. -B $(4) -v $(5).ar7100.OpenWrt.$(REVISION) \
  67. -k $(KDIR)/vmlinux-$(2).bin.lzma \
  68. -r $(BIN_DIR)/openwrt-$(BOARD)-root.$(1) \
  69. -o $(BIN_DIR)/openwrt-$(BOARD)-$(2)-$(1).bin
  70. endef
  71. define Image/Build/Planex
  72. cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(2)
  73. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(2) '$(strip $(3))'
  74. gzip -9 -c $(KDIR)/vmlinux-$(2) > $(KDIR)/vmlinux-$(2).bin.gzip
  75. if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gzip"` -gt 1441792 ]; then \
  76. echo "Warning: $(KDIR)/vmlinux-$(2).bin.gzip is too big"; \
  77. else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6356992 ]; then \
  78. echo "Warning: $(KDIR)/root.$(1) is too big"; \
  79. else \
  80. mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip -e \
  81. 0x80060000 \
  82. -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  83. -d $(KDIR)/vmlinux-$(2).bin.gzip $(KDIR)/vmlinux-$(2).uImage; \
  84. ( \
  85. dd if=$(KDIR)/vmlinux-$(2).uImage bs=1408k conv=sync; \
  86. dd if=$(KDIR)/root.$(1) bs=6208k conv=sync; \
  87. ) > $(call imgname,$(1),$(2)).bin; \
  88. $(STAGING_DIR_HOST)/bin/mkplanexfw -v 2.00.00 \
  89. -i $(call imgname,$(1),$(2)).bin \
  90. -o $(call imgname,$(1),$(2)).webui; \
  91. fi; fi
  92. endef
  93. define Image/Build/TPLINK
  94. cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(2)
  95. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(2) '$(strip $(3))'
  96. gzip -9 -c $(KDIR)/vmlinux-$(2) > $(KDIR)/vmlinux-$(2).bin.gzip
  97. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  98. -B $(4) -N OpenWrt -V $(REVISION)\
  99. -k $(KDIR)/vmlinux-$(2).bin.gzip \
  100. -r $(BIN_DIR)/openwrt-$(BOARD)-root.$(1) \
  101. -o $(BIN_DIR)/openwrt-$(BOARD)-$(2)-$(1).uni
  102. endef
  103. define Image/Build/Template/Compex
  104. $(call Image/Build/MyLoader,$(1),$(2))
  105. endef
  106. define Image/Build/Template/Compex/squashfs
  107. $(call Image/Build/Template/Compex,squashfs,$(1))
  108. endef
  109. define Image/Build/Template/AP81
  110. $(call Image/Build/AP81,$(1),$(2),$(3),$(4))
  111. endef
  112. define Image/Build/Template/AP81/squashfs
  113. $(call Image/Build/Template/AP81,squashfs,$(1),$(2),$(3))
  114. endef
  115. define Image/Build/Template/TPLINK
  116. $(call Image/Build/TPLINK,$(1),$(2),$(3),$(4))
  117. endef
  118. define Image/Build/Template/TPLINK/squashfs
  119. $(call Image/Build/Template/TPLINK,squashfs,$(1),$(2),$(3))
  120. endef
  121. define Image/Build/Template/UBNT
  122. $(call Image/Build/UBNT,$(1),$(2),$(3),$(4),$(5))
  123. endef
  124. define Image/Build/Template/UBNT/squashfs
  125. $(call Image/Build/Template/UBNT,squashfs,$(1),$(2),$(3),$(4))
  126. endef
  127. define Image/Build/Template/Planex
  128. $(call Image/Build/Planex,$(1),$(2),$(3))
  129. endef
  130. define Image/Build/Template/Planex/squashfs
  131. $(call Image/Build/Template/Planex,squashfs,$(1),$(2))
  132. endef
  133. define Image/Build/Profile/WP543
  134. $(call Image/Build/Template/Compex/$(1),wp543)
  135. endef
  136. define Image/Build/Profile/DIR615C1
  137. $(call Image/Build/Template/AP81/$(1),dir-615c1,board=TEW-632BRP,"AP81-AR9130-RT-070614-02")
  138. endef
  139. define Image/Build/Profile/TEW632BRP
  140. $(call Image/Build/Template/AP81/$(1),tew-632brp,board=TEW-632BRP,"AP81-AR9130-RT-070614-00")
  141. endef
  142. define Image/Build/Profile/TEW652BRP
  143. $(call Image/Build/Template/AP81/$(1),tew-652brp,board=TEW-632BRP,"AP81-AR9130-RT-080609-05")
  144. endef
  145. define Image/Build/Profile/A02RBW300N
  146. $(call Image/Build/Template/AP81/$(1),a02-rb-w300n,board=TEW-632BRP,"AP81-AR9130-RT-070614-03")
  147. endef
  148. define Image/Build/Profile/UBNTRS
  149. $(call Image/Build/Template/UBNT/$(1),ubnt-rs,board=UBNT-RS,RS,RSx)
  150. endef
  151. define Image/Build/Profile/UBNTLSSR71
  152. $(call Image/Build/Template/UBNT/$(1),ubnt-ls-sr71,board=UBNT-LS-SR71,LS-SR71,LS-SR71)
  153. endef
  154. define Image/Build/Profile/MZKW04NU
  155. $(call Image/Build/Template/Planex/$(1),mzk-w04nu,board=MZK-W04NU)
  156. endef
  157. define Image/Build/Profile/TLWR941NDV2
  158. $(call Image/Build/Template/TPLINK/$(1),tl-wr941ndv2,board=TL-WR941ND,TL-WR941NDv2)
  159. endef
  160. define Image/Build/Profile/Default
  161. $(call Image/Build/Profile/A02RBW300N,$(1))
  162. $(call Image/Build/Profile/DIR615C1,$(1))
  163. $(call Image/Build/Profile/MZKW04NU,$(1))
  164. $(call Image/Build/Profile/TEW632BRP,$(1))
  165. $(call Image/Build/Profile/TEW652BRP,$(1))
  166. $(call Image/Build/Profile/TLWR941NDV2,$(1))
  167. $(call Image/Build/Profile/UBNTRS,$(1))
  168. $(call Image/Build/Profile/UBNTLSSR71,$(1))
  169. $(call Image/Build/Profile/WP543,$(1))
  170. endef
  171. define Image/Build/Profile/Madwifi
  172. $(call Image/Build/Profile/UBNTRS,$(1))
  173. $(call Image/Build/Profile/WP543,$(1))
  174. endef
  175. define Image/Build/squashfs
  176. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  177. endef
  178. define Image/Build
  179. $(call Image/Build/$(1))
  180. dd if=$(KDIR)/root.$(1) of=$(IMGNAME)-root.$(1) bs=128k conv=sync
  181. $(call Image/Build/Profile/$(PROFILE),$(1))
  182. endef
  183. $(eval $(call BuildImage))