Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ##
  2. # Copyright (C) 2020 Alibaba Group Holding Limited
  3. ##
  4. test = $(shell if [ -f "../.param" ]; then echo "exist"; else echo "noexist"; fi)
  5. ifeq ("$(test)", "exist")
  6. include ../.param
  7. endif
  8. SDK_VER=v0.9
  9. CONFIG_DEBUG_MODE=1
  10. CONFIG_BUILD_LIB_EXTRA_PARAM:=""
  11. CONFIG_BUILD_TST_EXTRA_PARAM:=""
  12. ifeq ("$(BUILD_SYSTEM)","YOCTO_BUILD")
  13. export PATH_TO_SYSROOT=${SYSROOT_DIR}
  14. export TOOLSCHAIN_PATH=${TOOLCHAIN_DIR}
  15. export TOOLCHAIN_HOST=${CROSS_COMPILE}
  16. else
  17. export PATH_TO_SYSROOT=${BUILDROOT_DIR}/output/host/riscv64-buildroot-linux-gnu/sysroot
  18. export TOOLSCHAIN_PATH=${BUILDROOT_DIR}/output/host
  19. export TOOLCHAIN_HOST=${TOOLSCHAIN_PATH}/bin/riscv64-unknown-linux-gnu-
  20. endif
  21. export PATH_TO_BUILDROOT=$(BUILDROOT_DIR)
  22. # Board
  23. CONFIG_BOARD_LIGHT_C910_ARRAY:=light_fpga_fm_c910 light-fm-fpga light-fm light-%
  24. ifneq ($(filter $(CONFIG_BOARD_LIGHT_C910_ARRAY),$(BOARD_NAME)),)
  25. TARGET_DEMO="plink_AI"
  26. else
  27. $(error "Undefined target board:$(BOARD_NAME)")
  28. endif
  29. DIR_TARGET_LIB=lib
  30. DIR_TARGET_TEST=test
  31. DIR_TARGET_MODEL=model
  32. DIR_TARGET_INPUT=input
  33. BUILD_LOG_START="\033[47;30m>>> $(TARGET_DEMO) $@ begin\033[0m"
  34. BUILD_LOG_END ="\033[47;30m<<< $(TARGET_DEMO) $@ end\033[0m"
  35. #
  36. # Do a parallel build with multiple jobs, based on the number of CPUs online
  37. # in this system: 'make -j8' on a 8-CPU system, etc.
  38. #
  39. # (To override it, run 'make JOBS=1' and similar.)
  40. #
  41. ifeq ($(JOBS),)
  42. JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
  43. ifeq ($(JOBS),)
  44. JOBS := 1
  45. endif
  46. endif
  47. all: info lib test install_local_output install_rootfs install_tests
  48. .PHONY: info lib test install_local_output install_rootfs \
  49. install_prepare install_addons install_tests install_lib clean_test clean_lib clean_output clean
  50. info:
  51. @echo $(BUILD_LOG_START)
  52. @echo " ====== Build Info from repo project ======"
  53. @echo " BUILD_SYSTEM="$(BUILD_SYSTEM)
  54. @echo " BUILDROOT_DIR="$(BUILDROOT_DIR)
  55. @echo " SYSROOT_DIR="$(SYSROOT_DIR)
  56. @echo " CROSS_COMPILE="$(CROSS_COMPILE)
  57. @echo " LINUX_DIR="$(LINUX_DIR)
  58. @echo " ARCH="$(ARCH)
  59. @echo " KBUILD_CFLAGS="$(KBUILD_CFLAGS)
  60. @echo " KBUILD_AFLAGS="$(KBUILD_AFLAGS)
  61. @echo " KBUILD_LDFLAGS="$(KBUILD_LDFLAGS)
  62. @echo " BOARD_NAME="$(BOARD_NAME)
  63. @echo " KERNEL_ID="$(KERNELVERSION)
  64. @echo " KERNEL_DIR="$(LINUX_DIR)
  65. @echo " CC="$(CC)
  66. @echo " CXX="$(CXX)
  67. @echo " LD="$(LD)
  68. @echo " LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)
  69. @echo " rpath="$(rpath)
  70. @echo " rpath-link="$(rpath-link)
  71. @echo " INSTALL_DIR_ROOTFS="$(INSTALL_DIR_ROOTFS)
  72. @echo " INSTALL_DIR_SDK="$(INSTALL_DIR_SDK)
  73. @echo " ====== Build configuration by settings ======"
  74. @echo " TARGET_DEMO="$(TARGET_DEMO)
  75. @echo " CONFIG_DEBUG_MODE="$(CONFIG_DEBUG_MODE)
  76. @echo " CONFIG_OUT_ENV="$(CONFIG_OUT_ENV)
  77. @echo " JOBS="$(JOBS)
  78. @echo " SDK_VERSION="$(SDK_VER)
  79. @echo $(BUILD_LOG_END)
  80. test:
  81. @echo $(BUILD_LOG_START)
  82. make -C test/face_detect ARCH=$(ARCH) CROSS=$(CROSS_COMPILE)
  83. @echo $(BUILD_LOG_END)
  84. clean_test:
  85. @echo $(BUILD_LOG_START)
  86. make -C test/face_detect clean
  87. @echo $(BUILD_LOG_END)
  88. install_prepare:
  89. mkdir -p ./output/rootfs/$(TARGET_DEMO)/$(DIR_TARGET_TEST)
  90. mkdir -p ./output/rootfs/$(TARGET_DEMO)/$(DIR_TARGET_INPUT)
  91. mkdir -p ./output/rootfs/$(TARGET_DEMO)/$(DIR_TARGET_MODEL)
  92. install_addons: install_prepare
  93. @if [ -d addons ]; then \
  94. cp -rf addons/* ./output/rootfs/$(TARGET_DEMO); \
  95. fi
  96. install_tests: install_addons test
  97. @if [ -d test/output ]; then \
  98. cp -rf test/output/* ./output/rootfs/$(TARGET_DEMO)/$(DIR_TARGET_TEST); \
  99. fi
  100. install_input: install_prepare
  101. @if [ -d input/install ]; then \
  102. cp -rf input/install/* ./output/rootfs/$(TARGET_DEMO)/$(DIR_TARGET_INPUT); \
  103. fi
  104. install_model: install_prepare
  105. @if [ -d model/install ]; then \
  106. cp -rf model/install/* ./output/rootfs/$(TARGET_DEMO)/$(DIR_TARGET_MODEL); \
  107. fi
  108. install_lib: ;
  109. install_local_output: test \
  110. install_addons install_lib install_tests install_input install_model
  111. @echo $(BUILD_LOG_START)
  112. @if [ `command -v tree` != "" ]; then \
  113. tree ./output/rootfs; \
  114. fi
  115. @echo $(BUILD_LOG_END)
  116. install_rootfs: install_local_output
  117. @echo $(BUILD_LOG_START)
  118. @echo $(BUILD_LOG_END)
  119. clean_output:
  120. @echo $(BUILD_LOG_START)
  121. rm -rf ./output
  122. @echo $(BUILD_LOG_END)
  123. clean: clean_output clean_test clean_lib