Makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #
  2. # Copyright (C) 2009-2013 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. NAND_BLOCKSIZE := 2048-128k
  8. include $(TOPDIR)/rules.mk
  9. include $(INCLUDE_DIR)/image.mk
  10. DEVICE_VARS += DEVICE_DTS KERNEL_SIZE PAGESIZE BLOCKSIZE SUBPAGESIZE KERNEL_IN_UBI
  11. KERNEL_LOADADDR:=0x8000
  12. TARGET_DEVICES = linksys-audi linksys-viper dockstar goflexnet goflexhome iconnect
  13. define Device/Default
  14. KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
  15. KERNEL := kernel-bin | append-dtb | uImage none
  16. KERNEL_NAME := zImage
  17. KERNEL_IN_UBI :=
  18. endef
  19. define Device/dockstar
  20. DEVICE_DTS := kirkwood-dockstar
  21. PAGESIZE := 2048
  22. SUBPAGESIZE := 512
  23. BLOCKSIZE := 128KiB
  24. FILESYSTEMS := squashfs
  25. PROFILES := Generic DOCKSTAR
  26. IMAGES := factory.bin sysupgrade.tar
  27. IMAGE/factory.bin := append-ubi
  28. IMAGE/sysupgrade.tar := sysupgrade-nand
  29. KERNEL_IN_UBI := 1
  30. KERNEL := kernel-bin | append-dtb
  31. endef
  32. define Device/goflexnet
  33. $(Device/dockstar)
  34. PROFILES := Generic GOFLEXNET
  35. DEVICE_DTS := kirkwood-goflexnet
  36. endef
  37. define Device/goflexhome
  38. $(Device/dockstar)
  39. PROFILES := Generic GOFLEXHOME
  40. DEVICE_DTS := kirkwood-goflexhome
  41. endef
  42. define Device/iconnect
  43. $(Device/dockstar)
  44. PROFILES := Generic ICONNECT
  45. DEVICE_DTS := kirkwood-iconnect
  46. endef
  47. define Device/linksys-audi
  48. DEVICE_DTS := kirkwood-linksys-audi
  49. PAGESIZE := 512
  50. SUBPAGESIZE := 256
  51. BLOCKSIZE := 16KiB
  52. KERNEL_SIZE := 2624k
  53. FILESYSTEMS := squashfs
  54. PROFILES := Generic AUDI
  55. IMAGES := factory.bin sysupgrade.tar
  56. IMAGE/factory.bin := append-kernel $$$$(KERNEL_SIZE) | append-ubi
  57. IMAGE/sysupgrade.tar := sysupgrade-nand
  58. endef
  59. define Device/linksys-viper
  60. DEVICE_DTS := kirkwood-linksys-viper
  61. PAGESIZE := 2048
  62. SUBPAGESIZE := 512
  63. BLOCKSIZE := 128KiB
  64. KERNEL_SIZE := 2688k
  65. FILESYSTEMS := squashfs
  66. PROFILES := Generic VIPER
  67. IMAGES := factory.bin sysupgrade.tar
  68. IMAGE/factory.bin := append-kernel $$$$(KERNEL_SIZE) | append-ubi
  69. IMAGE/sysupgrade.tar := sysupgrade-nand
  70. endef
  71. define Build/append-dtb
  72. cat $(DTS_DIR)/$(DEVICE_DTS).dtb >> $@
  73. endef
  74. define Image/BuildKernel/Template
  75. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
  76. echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage
  77. $(call Image/BuildKernel/MkuImage, \
  78. none, 0x8000, 0x8000, \
  79. $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
  80. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  81. )
  82. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  83. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  84. echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  85. $(call Image/BuildKernel/MkuImage, \
  86. none, 0x8000, 0x8000, \
  87. $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
  88. $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
  89. )
  90. endif
  91. ifneq ($(1),)
  92. $(CP) $(DTS_DIR)/kirkwood-$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
  93. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage
  94. cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage
  95. $(call Image/BuildKernel/MkuImage, \
  96. none, 0x8000, 0x8000, \
  97. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage, \
  98. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-uImage \
  99. )
  100. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  101. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage-initramfs
  102. cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage-initramfs
  103. $(call Image/BuildKernel/MkuImage, \
  104. none, 0x8000, 0x8000, \
  105. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage-initramfs, \
  106. $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-uImage-initramfs \
  107. )
  108. endif
  109. endif
  110. endef
  111. define Image/InstallKernel/Template
  112. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
  113. $(INSTALL_DIR) $(TARGET_DIR)/boot
  114. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
  115. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
  116. ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
  117. endif
  118. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
  119. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
  120. ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
  121. endif
  122. endif
  123. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
  124. $(INSTALL_DIR) $(TARGET_DIR)/boot
  125. ifneq ($(1),)
  126. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/
  127. ln -sf $(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/$(1).dtb
  128. endif
  129. endif
  130. endef
  131. define Image/Build/jffs2-nand-2048-128k
  132. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-$(1).img \
  133. bs=2048 conv=sync
  134. endef
  135. define Image/Build/squashfs
  136. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  137. ( \
  138. dd if=$(KDIR)/zImage bs=4096k conv=sync; \
  139. dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
  140. ) > $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-$(1).img
  141. endef
  142. define Image/Build/ubifs
  143. ifneq ($($(PROFILE)_UBIFS_OPTS),)
  144. $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-rootfs.ubifs
  145. endif
  146. endef
  147. define Image/Build/ubi
  148. ifneq ($($(PROFILE)_UBI_OPTS),)
  149. $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-rootfs.ubi
  150. endif
  151. endef
  152. Image/BuildKernel/Template/Generic=$(call Image/BuildKernel/Template)
  153. Image/InstallKernel/Template/Generic=$(call Image/InstallKernel/Template)
  154. Image/BuildKernel/Template/IB62X0=$(call Image/BuildKernel/Template,ib62x0)
  155. Image/InstallKernel/Template/IB62X0=$(call Image/InstallKernel/Template,ib62x0)
  156. Image/BuildKernel/Template/IOMEGA_IX2_200=$(call Image/BuildKernel/Template,iomega_ix2_200)
  157. Image/InstallKernel/Template/IOMEGA_IX2_200=$(call Image/InstallKernel/Template,iomega_ix2_200)
  158. Image/BuildKernel/Template/NSA310S=$(call Image/BuildKernel/Template,nsa310s)
  159. Image/InstallKernel/Template/NSA310S=$(call Image/InstallKernel/Template,nsa310s)
  160. Image/BuildKernel/Template/POGOE02=$(call Image/BuildKernel/Template,pogo_e02)
  161. Image/InstallKernel/Template/POGOE02=$(call Image/InstallKernel/Template,pogo_e02)
  162. Image/BuildKernel/Template/SHEEVAPLUG=$(call Image/BuildKernel/Template,sheevaplug)
  163. Image/InstallKernel/Template/SHEEVAPLUG=$(call Image/InstallKernel/Template,sheevaplug)
  164. Image/BuildKernel/Template/SHEEVAPLUGSATA=$(call Image/BuildKernel/Template,sheevaplug-esata)
  165. Image/InstallKernel/Template/SHEEVAPLUGSATA=$(call Image/InstallKernel/Template,sheevaplug-esata)
  166. Image/BuildKernel/Template/GuruplugServerPlus=$(call Image/BuildKernel/Template,guruplug-server-plus)
  167. Image/InstallKernel/Template/GuruplugServerPlus=$(call Image/InstallKernel/Template,guruplug-server-plus)
  168. Image/BuildKernel/Template/Topkick1281P2=$(call Image/BuildKernel/Template,topkick)
  169. Image/InstallKernel/Template/Topkick1281P2=$(call Image/InstallKernel/Template,topkick)
  170. define Image/BuildKernel
  171. $(call Image/BuildKernel/Template/$(PROFILE))
  172. endef
  173. define Image/InstallKernel
  174. $(call Image/InstallKernel/Template/$(PROFILE))
  175. endef
  176. define Image/Build
  177. $(if $(Image/Build/$(1)), \
  178. $(call Image/Build/$(1),$(1)), \
  179. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-$(1).img \
  180. )
  181. endef
  182. $(eval $(call BuildImage))