Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. NAND_BLOCKSIZE := 2048-128k
  10. define sanitize_profile_name
  11. $(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]')
  12. endef
  13. define Image/BuildKernel/Template
  14. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
  15. echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage
  16. $(call Image/BuildKernel/MkuImage, \
  17. none, 0x8000, 0x8000, \
  18. $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
  19. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  20. )
  21. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  22. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  23. echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  24. $(call Image/BuildKernel/MkuImage, \
  25. none, 0x8000, 0x8000, \
  26. $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
  27. $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
  28. )
  29. endif
  30. ifneq ($(1),)
  31. $(CP) $(DTS_DIR)/kirkwood-$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
  32. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage
  33. cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage
  34. $(call Image/BuildKernel/MkuImage, \
  35. none, 0x8000, 0x8000, \
  36. $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage, \
  37. $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-uImage \
  38. )
  39. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  40. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage-initramfs
  41. cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage-initramfs
  42. $(call Image/BuildKernel/MkuImage, \
  43. none, 0x8000, 0x8000, \
  44. $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage-initramfs, \
  45. $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-uImage-initramfs \
  46. )
  47. endif
  48. endif
  49. endef
  50. define Image/InstallKernel/Template
  51. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
  52. $(INSTALL_DIR) $(TARGET_DIR)/boot
  53. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
  54. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
  55. ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
  56. endif
  57. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
  58. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
  59. ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
  60. endif
  61. endif
  62. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
  63. $(INSTALL_DIR) $(TARGET_DIR)/boot
  64. ifneq ($(1),)
  65. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/
  66. ln -sf $(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/$(1).dtb
  67. endif
  68. endif
  69. endef
  70. define Image/Build/jffs2-nand-2048-128k
  71. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
  72. bs=2048 conv=sync
  73. endef
  74. define Image/Build/squashfs
  75. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  76. ( \
  77. dd if=$(KDIR)/zImage bs=4096k conv=sync; \
  78. dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
  79. ) > $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img
  80. endef
  81. define Image/mkfs/targz
  82. $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
  83. endef
  84. define Image/Build/ubifs
  85. ifneq ($($(PROFILE)_UBIFS_OPTS),)
  86. $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.ubifs
  87. endif
  88. endef
  89. define Image/Build/ubi
  90. ifneq ($($(PROFILE)_UBI_OPTS),)
  91. $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.ubi
  92. endif
  93. endef
  94. Image/BuildKernel/Template/Generic=$(call Image/BuildKernel/Template)
  95. Image/InstallKernel/Template/Generic=$(call Image/InstallKernel/Template)
  96. Image/BuildKernel/Template/DOCKSTAR=$(call Image/BuildKernel/Template,dockstar)
  97. Image/InstallKernel/Template/DOCKSTAR=$(call Image/InstallKernel/Template,dockstar)
  98. Image/BuildKernel/Template/EA3500=$(call Image/BuildKernel/Template,ea3500)
  99. Image/InstallKernel/Template/EA3500=$(call Image/InstallKernel/Template,ea3500)
  100. Image/BuildKernel/Template/EA4500=$(call Image/BuildKernel/Template,ea4500)
  101. Image/InstallKernel/Template/EA4500=$(call Image/InstallKernel/Template,ea4500)
  102. Image/BuildKernel/Template/GOFLEXHOME=$(call Image/BuildKernel/Template,goflexhome)
  103. Image/InstallKernel/Template/GOFLEXHOME=$(call Image/InstallKernel/Template,goflexhome)
  104. Image/BuildKernel/Template/GOFLEXNET=$(call Image/BuildKernel/Template,goflexnet)
  105. Image/InstallKernel/Template/GOFLEXNET=$(call Image/InstallKernel/Template,goflexnet)
  106. Image/BuildKernel/Template/IB62X0=$(call Image/BuildKernel/Template,ib62x0)
  107. Image/InstallKernel/Template/IB62X0=$(call Image/InstallKernel/Template,ib62x0)
  108. Image/BuildKernel/Template/ICONNECT=$(call Image/BuildKernel/Template,iconnect)
  109. Image/InstallKernel/Template/ICONNECT=$(call Image/InstallKernel/Template,iconnect)
  110. Image/BuildKernel/Template/IOMEGA_IX2_200=$(call Image/BuildKernel/Template,iomega_ix2_200)
  111. Image/InstallKernel/Template/IOMEGA_IX2_200=$(call Image/InstallKernel/Template,iomega_ix2_200)
  112. Image/BuildKernel/Template/POGOE02=$(call Image/BuildKernel/Template,pogo_e02)
  113. Image/InstallKernel/Template/POGOE02=$(call Image/InstallKernel/Template,pogo_e02)
  114. Image/BuildKernel/Template/SHEEVAPLUG=$(call Image/BuildKernel/Template,sheevaplug)
  115. Image/InstallKernel/Template/SHEEVAPLUG=$(call Image/InstallKernel/Template,sheevaplug)
  116. Image/BuildKernel/Template/SHEEVAPLUGSATA=$(call Image/BuildKernel/Template,sheevaplug-esata)
  117. Image/InstallKernel/Template/SHEEVAPLUGSATA=$(call Image/InstallKernel/Template,sheevaplug-esata)
  118. Image/BuildKernel/Template/GuruplugServerPlus=$(call Image/BuildKernel/Template,guruplug-server-plus)
  119. Image/InstallKernel/Template/GuruplugServerPlus=$(call Image/InstallKernel/Template,guruplug-server-plus)
  120. Image/BuildKernel/Template/Topkick1281P2=$(call Image/BuildKernel/Template,topkick)
  121. Image/InstallKernel/Template/Topkick1281P2=$(call Image/InstallKernel/Template,topkick)
  122. define Image/BuildKernel
  123. $(call Image/BuildKernel/Template/$(PROFILE))
  124. endef
  125. define Image/InstallKernel
  126. $(call Image/InstallKernel/Template/$(PROFILE))
  127. endef
  128. define Image/Build
  129. $(if $(Image/Build/$(1)), \
  130. $(call Image/Build/$(1),$(1)), \
  131. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
  132. )
  133. endef
  134. $(eval $(call BuildImage))