Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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)/vmlinux
  7. OSTRIP:=-R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
  8. QEMU_ARGS:=-M virt -m 256 -nographic
  9. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  10. QEMU_ARGS+=-netdev user,id=eth0 -device virtio-net-device,netdev=eth0
  11. endif
  12. ifeq ($(ADK_TARGET_FS),archive)
  13. QEMU_ARGS+=-device virtio-blk-device,drive=vda -drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=none,id=vda,format=raw
  14. endif
  15. # target helper text
  16. ifeq ($(ADK_TARGET_FS),archive)
  17. targethelp:
  18. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  19. ifeq ($(ADK_TARGET_QEMU),y)
  20. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  21. @echo "Use following command to create a QEMU Image:"
  22. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  23. @echo "Start qemu with following options:"
  24. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  25. endif
  26. endif
  27. ifeq ($(ADK_TARGET_FS),initramfs)
  28. targethelp:
  29. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  30. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  31. ifeq ($(ADK_TARGET_QEMU),y)
  32. @echo "Start qemu with following command line:"
  33. @echo 'qemu-system-riscv64 ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  34. endif
  35. endif
  36. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  37. targethelp:
  38. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  39. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  40. endif
  41. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  42. targethelp:
  43. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  44. ifeq ($(ADK_TARGET_QEMU),y)
  45. @echo "Start qemu with following command line:"
  46. @echo 'qemu-system-riscv64 ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  47. endif
  48. endif
  49. kernel-strip:
  50. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  51. kernel-install: kernel-strip
  52. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  53. bbl:
  54. @mkdir -p $(BUILD_DIR)/bbl
  55. @rm -rf $(BUILD_DIR)/riscv-pk
  56. (cd $(BUILD_DIR)/ && git clone https://github.com/riscv/riscv-pk.git)
  57. (cd $(BUILD_DIR)/bbl && PATH='$(HOST_PATH)' ../riscv-pk/configure \
  58. --host=$(GNU_TARGET_NAME) --target=$(GNU_TARGET_NAME) \
  59. --with-payload=$(FW_DIR)/$(TARGET_KERNEL))
  60. (cd $(BUILD_DIR)/bbl && PATH='$(HOST_PATH)' make)
  61. cp $(BUILD_DIR)/bbl/bbl $(FW_DIR)/$(TARGET_KERNEL)
  62. # filesystem specific targets
  63. ifeq ($(ADK_TARGET_FS),archive)
  64. imageinstall: kernel-install bbl $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  65. endif
  66. ifeq ($(ADK_TARGET_FS),initramfs)
  67. imageinstall: kernel-install bbl $(FW_DIR)/$(INITRAMFS) targethelp
  68. endif
  69. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  70. imageinstall: kernel-install bbl $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  71. endif
  72. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  73. imageinstall: createinitramfs bbl targethelp
  74. endif