Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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=BAREMETAL
  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/baremetal
  19. DIR_TARGET_LIB =bsp/baremetal/lib
  20. DIR_TARGET_KO =bsp/baremetal/ko
  21. DIR_TARGET_TEST=bsp/baremetal/test
  22. DIR_TARGET_TOOLS=bsp/baremetal/tools
  23. #
  24. # Do a parallel build with multiple jobs, based on the number of CPUs online
  25. # in this system: 'make -j8' on a 8-CPU system, etc.
  26. #
  27. # (To override it, run 'make JOBS=1' and similar.)
  28. #
  29. ifeq ($(JOBS),)
  30. JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
  31. ifeq ($(JOBS),)
  32. JOBS := 1
  33. endif
  34. endif
  35. all: info lib driver test tools install_local_output install_rootfs
  36. .PHONY: info driver lib test tools install_local_output install_rootfs \
  37. clean_driver clean_lib clean_test clean_tools clean_output clean
  38. info:
  39. @echo $(BUILD_LOG_START)
  40. @echo " ====== Build Info from repo project ======"
  41. @echo " BUILDROOT_DIR="$(BUILDROOT_DIR)
  42. @echo " CROSS_COMPILE="$(CROSS_COMPILE)
  43. @echo " LINUX_DIR="$(LINUX_DIR)
  44. @echo " ARCH="$(ARCH)
  45. @echo " BOARD_NAME="$(BOARD_NAME)
  46. @echo " KERNEL_ID="$(KERNELVERSION)
  47. @echo " KERNEL_DIR="$(LINUX_DIR)
  48. @echo " INSTALL_DIR_ROOTFS="$(INSTALL_DIR_ROOTFS)
  49. @echo " INSTALL_DIR_SDK="$(INSTALL_DIR_SDK)
  50. @echo " CONFIG_DRIVER_BUILD_PARAMS="$(CONFIG_DRIVER_BUILD_PARAMS)
  51. @echo " CONFIG_LIB_BUILD_PARAMS="$(CONFIG_LIB_BUILD_PARAMS)
  52. @echo " CONFIG_TEST_BUILD_PARAMS="$(CONFIG_TEST_BUILD_PARAMS)
  53. @echo $(BUILD_LOG_END)
  54. driver:
  55. @echo $(BUILD_LOG_START)
  56. make -C driver/demo $(CONFIG_DRIVER_BUILD_PARAMS)
  57. make -C driver/visys $(CONFIG_DRIVER_BUILD_PARAMS) #BUILD_TYPE=DEBUG
  58. make -C driver/isp $(CONFIG_DRIVER_BUILD_PARAMS)
  59. make -C driver/csi $(CONFIG_DRIVER_BUILD_PARAMS) BUILD_TYPE=DEBUG
  60. @echo $(BUILD_LOG_END)
  61. clean_driver:
  62. @echo $(BUILD_LOG_START)
  63. make -C driver/demo $(CONFIG_DRIVER_BUILD_PARAMS) clean
  64. make -C driver/visys $(CONFIG_DRIVER_BUILD_PARAMS) clean
  65. make -C driver/isp $(CONFIG_DRIVER_BUILD_PARAMS) clean
  66. make -C driver/csi $(CONFIG_DRIVER_BUILD_PARAMS) clean
  67. @echo $(BUILD_LOG_END)
  68. lib:
  69. @echo $(BUILD_LOG_START)
  70. @echo $(BUILD_LOG_END)
  71. clean_lib:
  72. @echo $(BUILD_LOG_START)
  73. @echo $(BUILD_LOG_END)
  74. test: lib driver
  75. @echo $(BUILD_LOG_START)
  76. make -C test/visys
  77. make -C test/csi
  78. make -C test/isp
  79. @echo $(BUILD_LOG_END)
  80. clean_test:
  81. @echo $(BUILD_LOG_START)
  82. make -C test/visys clean
  83. make -C test/isp clean
  84. @echo $(BUILD_LOG_END)
  85. tools:
  86. @echo $(BUILD_LOG_START)
  87. make -C tools/reg_analyzer -j $(JOBS)
  88. @echo $(BUILD_LOG_END)
  89. clean_tools:
  90. @echo $(BUILD_LOG_START)
  91. make -C tools/reg_analyzer clean
  92. make -C test/csi clean
  93. make -C test/isp clean
  94. @echo $(BUILD_LOG_END)
  95. install_local_output: driver lib test
  96. @echo $(BUILD_LOG_START)
  97. # driver files
  98. mkdir -p ./output/rootfs/$(DIR_TARGET_KO)
  99. cp -f ./driver/demo/*.ko ./output/rootfs/$(DIR_TARGET_KO)
  100. cp -f ./driver/visys/*.ko ./output/rootfs/$(DIR_TARGET_KO)
  101. cp -f ./driver/csi/*.ko ./output/rootfs/$(DIR_TARGET_KO)
  102. cp -f ./driver/isp/*.ko ./output/rootfs/$(DIR_TARGET_KO)
  103. # lib files
  104. mkdir -p ./output/rootfs/$(DIR_TARGET_LIB)
  105. # test files
  106. mkdir -p ./output/rootfs/$(DIR_TARGET_TEST)
  107. cp -rf ./test/visys/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  108. cp -rf ./test/isp/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  109. # tools files
  110. mkdir -p ./output/rootfs/$(DIR_TARGET_TOOLS)
  111. cp -f ./tools/reg_analyzer/output/* ./output/rootfs/$(DIR_TARGET_TOOLS)
  112. cp -f ./test/csi/output/* ./output/rootfs/$(DIR_TARGET_TEST)
  113. @if [ `command -v tree` != "" ]; then \
  114. tree ./output/rootfs -I 'sdk' | grep -v "\.json"; \
  115. echo "INFO: The files above, has filter out the sdk folder and .json files"; \
  116. fi
  117. @echo $(BUILD_LOG_END)
  118. install_rootfs: install_local_output
  119. @echo $(BUILD_LOG_START)
  120. # cp -rf output/rootfs/* $(INSTALL_DIR_ROOTFS)
  121. @echo $(BUILD_LOG_END)
  122. clean_output:
  123. @echo $(BUILD_LOG_START)
  124. rm -rf ./output
  125. rm -rf $(INSTALL_DIR_ROOTFS)/$(DIR_TARGET_BASE)
  126. @echo $(BUILD_LOG_END)
  127. clean: clean_output clean_driver clean_lib clean_test clean_tools