Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ##
  2. # Copyright (C) 2021 Alibaba Group Holding Limited
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License version 2 as
  6. # published by the Free Software Foundation.
  7. ##
  8. test = $(shell if [ -f "../.param" ]; then echo "exist"; else echo "noexist"; fi)
  9. ifeq ("$(test)", "exist")
  10. include ../.param
  11. endif
  12. CONFIG_DRIVER_BUILD_PARAMS=KERNEL=$(LINUX_DIR) CROSS=$(CROSS_COMPILE) ARCH=$(ARCH) BOARD_NAME=$(BOARD_NAME)
  13. CONFIG_LIB_BUILD_PARAMS=CROSS=$(CROSS_COMPILE) ARCH=$(ARCH) BOARD_NAME=$(BOARD_NAME)
  14. CONFIG_TEST_BUILD_PARAMS=CROSS=$(CROSS_COMPILE) ARCH=$(ARCH) BOARD_NAME=$(BOARD_NAME)
  15. MODULE_NAME=xtensa_dsp
  16. BUILD_LOG_START="\033[47;30m>>> $(MODULE_NAME) $@ begin\033[0m"
  17. BUILD_LOG_END ="\033[47;30m<<< $(MODULE_NAME) $@ end\033[0m"
  18. DIR_TARGET_BASE=bsp/xtensa_dsp
  19. DIR_TARGET_LIB =bsp/xtensa_dsp/lib
  20. DIR_TARGET_KO =bsp/xtensa_dsp/ko
  21. DIR_TARGET_TEST=bsp/xtensa_dsp/test
  22. #
  23. # Do a parallel build with multiple jobs, based on the number of CPUs online
  24. # in this system: 'make -j8' on a 8-CPU system, etc.
  25. #
  26. # (To override it, run 'make JOBS=1' and similar.)
  27. #
  28. ifeq ($(JOBS),)
  29. JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
  30. ifeq ($(JOBS),)
  31. JOBS := 1
  32. endif
  33. endif
  34. all: info lib driver test install_local_output install_rootfs
  35. .PHONY: info driver lib test install_local_output install_rootfs \
  36. clean_driver clean_lib clean_test clean_tools clean_output clean
  37. info:
  38. @echo $(BUILD_LOG_START)
  39. @echo " ====== Build Info from repo project ======"
  40. @echo " BUILDROOT_DIR="$(BUILDROOT_DIR)
  41. @echo " CROSS_COMPILE="$(CROSS_COMPILE)
  42. @echo " LINUX_DIR="$(LINUX_DIR)
  43. @echo " ARCH="$(ARCH)
  44. @echo " BOARD_NAME="$(BOARD_NAME)
  45. @echo " KERNEL_ID="$(KERNELVERSION)
  46. @echo " KERNEL_DIR="$(LINUX_DIR)
  47. @echo " INSTALL_DIR_ROOTFS="$(INSTALL_DIR_ROOTFS)
  48. @echo " INSTALL_DIR_SDK="$(INSTALL_DIR_SDK)
  49. @echo " CONFIG_DRIVER_BUILD_PARAMS="$(CONFIG_DRIVER_BUILD_PARAMS)
  50. @echo " CONFIG_LIB_BUILD_PARAMS="$(CONFIG_LIB_BUILD_PARAMS)
  51. @echo " CONFIG_TEST_BUILD_PARAMS="$(CONFIG_TEST_BUILD_PARAMS)
  52. @echo $(BUILD_LOG_END)
  53. driver:
  54. @echo $(BUILD_LOG_START)
  55. make -C driver/xrp-kernel $(CONFIG_DRIVER_BUILD_PARAMS) BUILD_TYPE=DEBUG
  56. @echo $(BUILD_LOG_END)
  57. clean_driver:
  58. @echo $(BUILD_LOG_START)
  59. make -C driver/xrp-kernel $(CONFIG_DRIVER_BUILD_PARAMS) clean
  60. @echo $(BUILD_LOG_END)
  61. lib:
  62. @echo $(BUILD_LOG_START)
  63. # make -C driver/xrp-user/xrp-host $(CONFIG_LIB_BUILD_PARAMS)
  64. # make -C driver/xrp-user/xrp-common $(CONFIG_LIB_BUILD_PARAMS)
  65. make -C driver/xrp-user/ $(CONFIG_LIB_BUILD_PARAMS)
  66. @echo $(BUILD_LOG_END)
  67. clean_lib:
  68. @echo $(BUILD_LOG_START)
  69. make -C driver/xrp-user/xrp-host clean
  70. make -C driver/xrp-user/xrp-common clean
  71. make -C driver/xrp-user/ clean
  72. @echo $(BUILD_LOG_END)
  73. test: lib driver
  74. @echo $(BUILD_LOG_START)
  75. make -C test/vi_test $(CONFIG_TEST_BUILD_PARAMS)
  76. make -C test/npu_test $(CONFIG_TEST_BUILD_PARAMS)
  77. make -C test/ip_test $(CONFIG_TEST_BUILD_PARAMS)
  78. make -C test/drv_test $(CONFIG_TEST_BUILD_PARAMS)
  79. @echo $(BUILD_LOG_END)
  80. clean_test:
  81. @echo $(BUILD_LOG_START)
  82. make -C test/vi_test clean
  83. make -C test/npu_test clean
  84. make -C test/ip_test clean
  85. make -C test/drv_test clean
  86. @echo $(BUILD_LOG_END)
  87. install_local_output: driver lib test
  88. @echo $(BUILD_LOG_START)
  89. # driver files
  90. mkdir -p ./output/rootfs/$(DIR_TARGET_KO)
  91. cp -f ./driver/xrp-kernel/*.ko ./output/rootfs/$(DIR_TARGET_KO)
  92. # lib files
  93. mkdir -p ./output/rootfs/$(DIR_TARGET_LIB)
  94. cp -f ./driver/xrp-user/*.so ./output/rootfs/$(DIR_TARGET_LIB)
  95. # test files
  96. mkdir -p ./output/rootfs/$(DIR_TARGET_TEST)
  97. cp -rf ./test/vi_test/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  98. cp -rf ./test/npu_test/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  99. cp -rf ./test/ip_test/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  100. cp -rf ./test/drv_test/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  101. @if [ `command -v tree` != "" ]; then \
  102. tree ./output/rootfs -I 'sdk' | grep -v "\.json"; \
  103. echo "INFO: The files above, has filter out the sdk folder and .json files"; \
  104. fi
  105. @echo $(BUILD_LOG_END)
  106. install_rootfs: install_local_output
  107. @echo $(BUILD_LOG_START)
  108. # cp -rf output/rootfs/* $(INSTALL_DIR_ROOTFS)
  109. @echo $(BUILD_LOG_END)
  110. clean_output:
  111. @echo $(BUILD_LOG_START)
  112. rm -rf ./output
  113. rm -rf $(INSTALL_DIR_ROOTFS)/$(DIR_TARGET_BASE)
  114. @echo $(BUILD_LOG_END)
  115. clean: clean_output clean_driver clean_lib clean_test