Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Directory structure
  2. CUR_PATH := $(shell pwd)
  3. LIB_PATH := $(CUR_PATH)/lib
  4. LIB_PATH_OUT := $(CUR_PATH)/out/lib
  5. OPENCV_PATH := $(CUR_PATH)/3rdparty/opencv-arm-linux
  6. OPENCV_LIB_PATH := $(OPENCV_PATH)/lib
  7. OPENCV_LIB2_PATH := $(OPENCV_PATH)/lib/opencv4/3rdparty
  8. OPENCV_INCLUDE := $(OPENCV_PATH)/include/opencv4
  9. # Compiler flags
  10. CROSS_COMPILE := /root/axera/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  11. CPP := $(CROSS_COMPILE)g++
  12. CC := $(CROSS_COMPILE)gcc
  13. CFLAGS := -Wall -DAX620A
  14. CFLAGS += -O2
  15. CFLAGS += -fPIC
  16. # Dependency libraries
  17. CLIB += -lm -lpthread -L$(LIB_PATH) -lax_run_joint -lax_interpreter_external -lax_interpreter -lax_sys -laxsyslog -lstdc++fs -ldl
  18. CLIB += -L$(OPENCV_LIB_PATH) -L$(OPENCV_LIB2_PATH) -lopencv_imgproc -lopencv_core
  19. # Source and header files directories
  20. INC_DIR := -I$(CUR_PATH)/include
  21. INC_DIR += -I$(CUR_PATH)/include/npu_cv_kit
  22. INC_DIR += -I$(OPENCV_INCLUDE)
  23. INC_DIR += -I$(CUR_PATH)/out/include
  24. INC_DIR_OUT := $(CUR_PATH)/out/include
  25. SRC_DIR := $(CUR_PATH)/src
  26. # Source files
  27. SRCS := $(wildcard $(SRC_DIR)/*.cpp)
  28. # Object files
  29. OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(LIB_PATH_OUT)/%.o, $(SRCS))
  30. # Target static library
  31. TARGET := $(LIB_PATH_OUT)/libxw_m1.a
  32. # Compilation rule
  33. $(TARGET): $(OBJS)
  34. @echo "Building $@..."
  35. ar rcs $@ $(OBJS)
  36. # Rule to compile source files to object files
  37. $(LIB_PATH_OUT)/%.o: $(SRC_DIR)/%.cpp
  38. $(CPP) $(CFLAGS) $(INC_DIR) -c $< -o $@
  39. # Clean rule
  40. clean:
  41. rm -f $(OBJS) $(TARGET)