build_libyuv.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. CWD="$( cd "$( dirname "$0" )" && pwd )"
  3. PACKAGE_NAME=libyuv
  4. LIBYUV_INST_DIR=${CWD}/../3rdparty/libyuv
  5. CMAKE_C_COMPILER=$1
  6. CMAKE_CXX_COMPILER=$2
  7. if [ -f "$LIBYUV_INST_DIR/lib/libyuv.a" ] && [ -f "$LIBYUV_INST_DIR/include/libyuv.h" ];then
  8. echo "libyuv has been built and installed already"
  9. exit 0
  10. fi
  11. if [ -d ${LIBYUV_INST_DIR} ]; then
  12. rm -rf "${LIBYUV_INST_DIR}"
  13. fi
  14. SRC_TYPE=0
  15. if [ -d ${CWD}/${PACKAGE_NAME} ]; then
  16. SRC_TYPE=1
  17. elif [ -f ${CWD}/${PACKAGE_NAME}.tar.gz ]; then
  18. SRC_TYPE=2
  19. else
  20. echo "<<<you need download libyuv first>>>"
  21. exit 0
  22. fi
  23. if [ ${SRC_TYPE} = 2 ]; then
  24. tar xf "${CWD}/${PACKAGE_NAME}.tar.gz" -C ${CWD}
  25. cd ${CWD}/${PACKAGE_NAME}
  26. git apply ../libyuv-1766.patch
  27. fi
  28. cd ${CWD}/${PACKAGE_NAME}
  29. if [ ${CMAKE_C_COMPILER} ] && [ ${CMAKE_CXX_COMPILER} ]; then
  30. make -f linux.mk CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS="-O2 -fomit-frame-pointer -fPIC -I./include" CXXFLAGS="-O2 -fomit-frame-pointer -fPIC -I./include"
  31. else
  32. make -f linux.mk CFLAGS="-O2 -fomit-frame-pointer -fPIC -I./include" CXXFLAGS="-O2 -fomit-frame-pointer -fPIC -I./include"
  33. fi
  34. if [ $? = 0 ]; then
  35. echo "build ${PACKAGE_NAME} done"
  36. mkdir -p $LIBYUV_INST_DIR
  37. mkdir -p $LIBYUV_INST_DIR/lib
  38. mkdir -p $LIBYUV_INST_DIR/include
  39. cp -rf include/* $LIBYUV_INST_DIR/include
  40. cp libyuv.a $LIBYUV_INST_DIR/lib
  41. echo "install ${PACKAGE_NAME} done"
  42. fi
  43. make -f linux.mk clean
  44. cd ${CWD}
  45. if [ ${SRC_TYPE} = 2 ]; then
  46. rm -rf ${CWD}/${PACKAGE_NAME}
  47. fi