3
0

Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ARM_ABI = arm8#[arm7/arm8]
  2. export ARM_ABI
  3. ifeq ($(ARM_ABI), arm8)
  4. ARM_PLAT=arm64-v8a
  5. else
  6. ARM_PLAT=armeabi-v7a
  7. endif
  8. ${info ARM_ABI: ${ARM_ABI}}
  9. ${info ARM_PLAT: ${ARM_PLAT}; option[arm7/arm8]}
  10. include ../Makefile.def
  11. LITE_ROOT=../../../
  12. ${info LITE_ROOT: $(abspath ${LITE_ROOT})}
  13. THIRD_PARTY_DIR=third_party
  14. ${info THIRD_PARTY_DIR: $(abspath ${THIRD_PARTY_DIR})}
  15. OPENCV_VERSION=opencv4.1.0
  16. OPENCV_LIBS = ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/libs/libopencv_imgcodecs.a \
  17. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/libs/libopencv_imgproc.a \
  18. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/libs/libopencv_core.a \
  19. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libtegra_hal.a \
  20. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibjpeg-turbo.a \
  21. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibwebp.a \
  22. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibpng.a \
  23. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibjasper.a \
  24. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/liblibtiff.a \
  25. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libIlmImf.a \
  26. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libtbb.a \
  27. ${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/3rdparty/libs/libcpufeatures.a
  28. LITE_LIBS = -L${LITE_ROOT}/cxx/lib/ -lpaddle_light_api_shared
  29. ###############################################################
  30. # How to use one of static libaray: #
  31. # `libpaddle_api_full_bundled.a` #
  32. # `libpaddle_api_light_bundled.a` #
  33. ###############################################################
  34. # Note: default use lite's shared library. #
  35. ###############################################################
  36. # 1. Comment above line using `libpaddle_light_api_shared.so`
  37. # 2. Undo comment below line using `libpaddle_api_light_bundled.a`
  38. # LITE_LIBS = ${LITE_ROOT}/cxx/lib/libpaddle_api_light_bundled.a
  39. CXX_LIBS = $(LITE_LIBS) ${OPENCV_LIBS} $(SYSTEM_LIBS)
  40. LOCAL_DIRSRCS=$(wildcard src/*.cc)
  41. LOCAL_SRCS=$(notdir $(LOCAL_DIRSRCS))
  42. LOCAL_OBJS=$(patsubst %.cpp, %.o, $(patsubst %.cc, %.o, $(LOCAL_SRCS)))
  43. JSON_OBJS = json_reader.o json_value.o json_writer.o
  44. main: $(LOCAL_OBJS) $(JSON_OBJS) fetch_opencv
  45. $(CC) $(SYSROOT_LINK) $(CXXFLAGS_LINK) $(LOCAL_OBJS) $(JSON_OBJS) -o main $(CXX_LIBS) $(LDFLAGS)
  46. fetch_opencv:
  47. @ test -d ${THIRD_PARTY_DIR} || mkdir ${THIRD_PARTY_DIR}
  48. @ test -e ${THIRD_PARTY_DIR}/${OPENCV_VERSION}.tar.gz || \
  49. (echo "fetch opencv libs" && \
  50. wget -P ${THIRD_PARTY_DIR} https://paddle-inference-dist.bj.bcebos.com/${OPENCV_VERSION}.tar.gz)
  51. @ test -d ${THIRD_PARTY_DIR}/${OPENCV_VERSION} || \
  52. tar -zxf ${THIRD_PARTY_DIR}/${OPENCV_VERSION}.tar.gz -C ${THIRD_PARTY_DIR}
  53. fetch_json_code:
  54. @ test -d ${THIRD_PARTY_DIR} || mkdir ${THIRD_PARTY_DIR}
  55. @ test -e ${THIRD_PARTY_DIR}/jsoncpp_code.tar.gz || \
  56. (echo "fetch jsoncpp_code.tar.gz" && \
  57. wget -P ${THIRD_PARTY_DIR} https://bj.bcebos.com/v1/paddledet/deploy/jsoncpp_code.tar.gz )
  58. @ test -d ${THIRD_PARTY_DIR}/jsoncpp_code || \
  59. tar -zxf ${THIRD_PARTY_DIR}/jsoncpp_code.tar.gz -C ${THIRD_PARTY_DIR}
  60. LOCAL_INCLUDES = -I./ -Iinclude
  61. OPENCV_INCLUDE = -I${THIRD_PARTY_DIR}/${OPENCV_VERSION}/${ARM_PLAT}/include
  62. JSON_INCLUDE = -I${THIRD_PARTY_DIR}/jsoncpp_code/include
  63. CXX_INCLUDES = ${LOCAL_INCLUDES} ${INCLUDES} ${OPENCV_INCLUDE} ${JSON_INCLUDE} -I$(LITE_ROOT)/cxx/include
  64. $(LOCAL_OBJS): %.o: src/%.cc fetch_opencv fetch_json_code
  65. $(CC) $(SYSROOT_COMPLILE) $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -c $< -o $@
  66. $(JSON_OBJS): %.o: ${THIRD_PARTY_DIR}/jsoncpp_code/%.cpp fetch_json_code
  67. $(CC) $(SYSROOT_COMPLILE) $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -c $< -o $@
  68. .PHONY: clean fetch_opencv fetch_json_code
  69. clean:
  70. rm -rf $(LOCAL_OBJS) $(JSON_OBJS)
  71. rm -f main