Makefile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. include $(ADK_TOPDIR)/rules.mk
  4. include $(ADK_TOPDIR)/mk/kernel-build.mk
  5. include $(ADK_TOPDIR)/mk/image.mk
  6. KERNEL:=$(LINUX_DIR)/$(ADK_TARGET_KERNEL)
  7. ifeq ($(ADK_TARGET_KERNEL_UIMAGE),y)
  8. KERNEL:=$(LINUX_DIR)/arch/mips/boot/uImage
  9. endif
  10. ifeq ($(ADK_TARGET_KERNEL_UIMAGEGZ),y)
  11. KERNEL:=$(LINUX_DIR)/arch/mips/boot/uImage.gz
  12. endif
  13. ifeq ($(ADK_TARGET_KERNEL_UIMAGEBIN),y)
  14. KERNEL:=$(LINUX_DIR)/arch/mips/boot/uImage.bin
  15. endif
  16. ifeq ($(ADK_TARGET_KERNEL_VMLINUX_BIN),y)
  17. KERNEL:=$(LINUX_DIR)/arch/mips/boot/vmlinux.bin
  18. endif
  19. OSTRIP:=-R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
  20. QEMU_ARGS:=-M malta
  21. QEMU_ARGS+=${ADK_QEMU_ARGS}
  22. QEMU_ARGS+=-device e1000,netdev=adk0 -netdev user,id=adk0
  23. ifeq ($(ADK_TARGET_CPU_MIPS_MIPS32R6),y)
  24. QEMU_ARGS+=-cpu mips32r6-generic
  25. endif
  26. # target helper text
  27. ifeq ($(ADK_TARGET_FS),archive)
  28. targethelp:
  29. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  30. ifeq ($(ADK_TARGET_QEMU),y)
  31. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  32. @echo "Use following command to create a QEMU Image:"
  33. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  34. @echo "Start qemu with following options:"
  35. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  36. endif
  37. ifeq ($(ADK_TARGET_SYSTEM_MIKROTIK_RB532),y)
  38. @echo "Use following command to install it on CF card:"
  39. @echo "sudo ./scripts/install-rb532.sh /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  40. @echo 'Or boot your Routerboard via NFS and'
  41. @echo 'then install kernel and filesystem via:'
  42. @echo 'adkinstall -c -a ${ROOTFSTARBALL}'
  43. endif
  44. ifeq ($(ADK_TARGET_SYSTEM_IMGTEC_CI20),y)
  45. @echo "Use following command to install it on SD card:"
  46. @echo "sudo ./scripts/install.sh $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  47. endif
  48. endif
  49. ifeq ($(ADK_TARGET_FS),initramfs)
  50. targethelp:
  51. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  52. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  53. ifeq ($(ADK_TARGET_QEMU),y)
  54. @echo "Start qemu with following command line:"
  55. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  56. endif
  57. endif
  58. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  59. targethelp:
  60. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  61. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  62. endif
  63. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  64. targethelp:
  65. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  66. ifeq ($(ADK_TARGET_QEMU),y)
  67. @echo "Start qemu with following command line:"
  68. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  69. endif
  70. endif
  71. ifeq ($(ADK_TARGET_FS),nfsroot)
  72. targethelp:
  73. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  74. @echo 'The nfs root tarball is: ${FW_DIR}/${ROOTFSUSERTARBALL}'
  75. endif
  76. ifeq ($(ADK_TARGET_FS),usb)
  77. targethelp:
  78. @echo 'The root tarball is: ${FW_DIR}/${ROOTFSTARBALL}'
  79. endif
  80. ifeq ($(ADK_TARGET_FS),genimage)
  81. targethelp:
  82. @echo "The disk image is: $(FW_DIR)/sdcard.img"
  83. ifeq ($(ADK_TARGET_QEMU),y)
  84. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} $(FW_DIR)/disk.img'
  85. else
  86. @echo "Use following command to install it on SD card:"
  87. @echo 'sudo dd if=$(FW_DIR)/sdcard.img of=/dev/sdX bs=2048k'
  88. endif
  89. endif
  90. ifeq ($(ADK_TARGET_FS),ubifs)
  91. targethelp:
  92. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  93. ifneq ($(ADK_TARGET_WITH_YAFFS_KERNEL),)
  94. @echo 'Use the following command to write it to flash:'
  95. @echo 'nand erase /dev/mtdX && yafut -d /dev/mtdX -i /path/to/kernel -o /kernel'
  96. @echo 'There is also a prepared YAFFS image: $(FW_DIR)/${TARGET_KERNEL}.yaffs2'
  97. @echo 'This might be written to flash using standard utilities'
  98. endif
  99. @echo 'The UBI image is: ${FW_DIR}/${ROOTFSUBIFS}'
  100. @echo 'Use the following command to write it to flash:'
  101. @echo 'ubiformat /dev/mtdX -f /path/to/ubi.img'
  102. endif
  103. kernel-strip:
  104. ifeq ($(ADK_TARGET_KERNEL_UIMAGE)$(ADK_TARGET_KERNEL_UIMAGEBIN)$(ADK_TARGET_KERNEL_UIMAGEGZ)$(ADK_TARGET_KERNEL_VMLINUX_BIN),)
  105. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  106. else
  107. $(CP) $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  108. endif
  109. ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_6_6)$(ADK_TARGET_LINUX_KERNEL_VERSION_6_12)$(ADK_TARGET_LINUX_KERNEL_VERSION_6_18)$(ADK_TARGET_LINUX_KERNEL_VERSION_GIT),y)
  110. VENDOR:=qca/
  111. endif
  112. dtb-install:
  113. ifeq ($(ADK_TARGET_SYSTEM_DRAGINO_MS14S),y)
  114. ${KERNEL_MAKE} $(VENDOR)ar9331_dragino_ms14.dtb $(MAKE_TRACE)
  115. cp $(LINUX_DIR)/arch/mips/boot/dts/$(VENDOR)ar9331_dragino_ms14.dtb ${FW_DIR}/
  116. endif
  117. kernel-install: kernel-strip
  118. $(CP) $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/${TARGET_KERNEL}
  119. ifneq ($(ADK_TARGET_WITH_YAFFS_KERNEL),)
  120. PATH='${HOST_PATH}'; \
  121. PEB_SZ='${ADK_TARGET_FLASH_PEB_SIZE}'; \
  122. KNL_SZ=$$(ls -l $(FW_DIR)/${TARGET_KERNEL} | cut -d' ' -f5); \
  123. IMG_PEB=$$((($$KNL_SZ + $$PEB_SZ - 1) / $$PEB_SZ + 3)); \
  124. dd if=/dev/zero bs=$$PEB_SZ count=$$IMG_PEB | \
  125. tr '\000' '\377' >$(FW_DIR)/${TARGET_KERNEL}.yaffs2; \
  126. yafut -d $(FW_DIR)/${TARGET_KERNEL}.yaffs2 -w $(ADK_YAFUT_OPTS) \
  127. -i $(FW_DIR)/${TARGET_KERNEL} -E -P -S -o /kernel
  128. endif
  129. # filesystem specific targets
  130. ifeq ($(ADK_TARGET_FS),archive)
  131. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  132. endif
  133. ifeq ($(ADK_TARGET_FS),initramfs)
  134. imageinstall: kernel-install $(FW_DIR)/$(INITRAMFS) targethelp
  135. endif
  136. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  137. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  138. endif
  139. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  140. imageinstall: createinitramfs targethelp
  141. endif
  142. ifeq (${ADK_TARGET_FS},genimage)
  143. imageinstall: ${FW_DIR}/${GENIMAGE} targethelp
  144. endif
  145. ifeq ($(ADK_TARGET_FS),nfsroot)
  146. imageinstall: dtb-install kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  147. endif
  148. ifeq ($(ADK_TARGET_FS),ubifs)
  149. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUBIFS) targethelp
  150. endif