Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. include $(TOPDIR)/rules.mk
  3. include $(INCLUDE_DIR)/image.mk
  4. KERNEL_LOADADDR = 0x80100000
  5. DEVICE_VARS += \
  6. BELKIN_HEADER \
  7. BELKIN_MODEL \
  8. CAMEO_BOARD_MODEL \
  9. CAMEO_BOARD_VERSION \
  10. CAMEO_CUSTOMER_SIGNATURE \
  11. CAMEO_KERNEL_PART \
  12. CAMEO_KERNEL_PART_SIZE \
  13. CAMEO_ROOTFS_PART \
  14. H3C_DEVICE_ID \
  15. H3C_PRODUCT_ID \
  16. LINKSYS_HEADER \
  17. ZYXEL_VERS
  18. define Build/rt-compress
  19. $(STAGING_DIR_HOST)/bin/xz -9 --format=lzma --stdout "$@" > "[email protected]"
  20. mv "[email protected]" "$@"
  21. endef
  22. define Build/rt-loader
  23. $(MAKE) all clean -C rt-loader CROSS_COMPILE="$(TARGET_CROSS)" \
  24. KERNEL_IMG_IN="$@" KERNEL_IMG_OUT="[email protected]" BUILD_DIR="[email protected]"
  25. mv "[email protected]" "$@"
  26. endef
  27. define Build/rt-loader-no-uimage
  28. $(MAKE) all clean -C rt-loader CROSS_COMPILE="$(TARGET_CROSS)" \
  29. KERNEL_ADDR="$(KERNEL_LOADADDR)" KERNEL_IMG_IN="$@" \
  30. KERNEL_IMG_OUT="[email protected]" BUILD_DIR="[email protected]"
  31. mv "[email protected]" "$@"
  32. endef
  33. define Build/zyxel-vers
  34. ( echo VERS;\
  35. for hw in $(ZYXEL_VERS); do\
  36. echo -n "V9.99($$hw.0) | ";\
  37. date -d @$(SOURCE_DATE_EPOCH) +%m/%d/%Y;\
  38. done ) >> $@
  39. endef
  40. define Build/cameo-tag
  41. $(SCRIPT_DIR)/cameo-tag.py $@ $(CAMEO_KERNEL_PART_SIZE)
  42. endef
  43. define Build/cameo-version
  44. echo -n "OpenWrt" >> $@
  45. dd if=/dev/zero bs=25 count=1 >> $@
  46. endef
  47. define Build/cameo-headers
  48. dd if=$@ bs=$(CAMEO_KERNEL_PART_SIZE) count=1 [email protected]_part; \
  49. dd if=$@ bs=$(CAMEO_KERNEL_PART_SIZE) skip=1 [email protected]_part; \
  50. $(SCRIPT_DIR)/cameo-imghdr.py [email protected]_part [email protected]_part.hex \
  51. "$(CAMEO_BOARD_MODEL)" os $(CAMEO_KERNEL_PART) \
  52. $(CAMEO_CUSTOMER_SIGNATURE) \
  53. $(CAMEO_BOARD_VERSION) \
  54. $(KERNEL_LOADADDR); \
  55. $(SCRIPT_DIR)/cameo-imghdr.py [email protected]_part [email protected]_part.hex \
  56. "$(CAMEO_BOARD_MODEL)" squashfs $(CAMEO_ROOTFS_PART) \
  57. $(CAMEO_CUSTOMER_SIGNATURE) \
  58. $(CAMEO_BOARD_VERSION); \
  59. cat [email protected]_part.hex [email protected]_part.hex > $@
  60. endef
  61. define Build/7z
  62. $(STAGING_DIR_HOST)/bin/7zr a $(@).new -t7z -m0=lzma $(@)
  63. mv [email protected] $@
  64. endef
  65. define Build/h3c-image
  66. $(STAGING_DIR_HOST)/bin/mkh3cimg \
  67. -i $(@) \
  68. -o $(@).new \
  69. -c 7z \
  70. -p $(H3C_PRODUCT_ID) \
  71. -d $(H3C_DEVICE_ID)
  72. mv [email protected] $@
  73. endef
  74. define Build/h3c-vfs
  75. $(STAGING_DIR_HOST)/bin/mkh3cvfs \
  76. -i $(@) \
  77. -o $(@).new \
  78. -f openwrt-kernel.bin
  79. mv [email protected] $@
  80. endef
  81. define Build/belkin-header
  82. $(SCRIPT_DIR)/belkin-header.py $(@) $(@).new $(BELKIN_HEADER) ${BELKIN_MODEL}
  83. mv [email protected] $@
  84. endef
  85. define Build/linksys-image
  86. $(SCRIPT_DIR)/linksys-image.sh $(@) $(@).new $(LINKSYS_MODEL)
  87. mv [email protected] $@
  88. endef
  89. define Device/Default
  90. PROFILES = Default
  91. KERNEL := \
  92. kernel-bin | \
  93. append-dtb | \
  94. libdeflate-gzip | \
  95. uImage gzip
  96. KERNEL_INITRAMFS := \
  97. kernel-bin | \
  98. append-dtb | \
  99. libdeflate-gzip | \
  100. uImage gzip
  101. DEVICE_DTS_DIR := ../dts
  102. DEVICE_DTS = $$(SOC)_$(1)
  103. IMAGES := sysupgrade.bin
  104. IMAGE/sysupgrade.bin := \
  105. append-kernel | \
  106. pad-to 64k | \
  107. append-rootfs | \
  108. pad-rootfs | \
  109. check-size | \
  110. append-metadata
  111. endef
  112. define Device/kernel-lzma
  113. KERNEL := \
  114. kernel-bin | \
  115. append-dtb | \
  116. lzma | \
  117. uImage lzma
  118. KERNEL_INITRAMFS := \
  119. kernel-bin | \
  120. append-dtb | \
  121. lzma | \
  122. uImage lzma
  123. endef
  124. define Device/uimage-rt-loader
  125. KERNEL/rt-loader := kernel-bin | append-dtb | rt-compress | rt-loader
  126. KERNEL := $$(KERNEL/rt-loader) | uImage none
  127. KERNEL_INITRAMFS := $$(KERNEL/rt-loader) | uImage none
  128. endef
  129. include $(SUBTARGET).mk
  130. $(eval $(call BuildImage))