setup_variables.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # when options parsed, setup some variables, then build the depends.
  3. OS_KERNEL_NAME=$(uname -s)
  4. OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}')
  5. OS_PREFIX="Platform"
  6. # Build platform cache.
  7. SRS_PLATFORM="${SRS_BUILD_TAG}${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}"
  8. # Build platform cache with gcc version.
  9. if [[ $OS_KERNEL_NAME == Darwin ]]; then
  10. GCC_VERSION="Clang$(gcc --version 2>/dev/null|grep clang|awk '{print $4}')"
  11. SRS_PLATFORM="${SRS_PLATFORM}-${GCC_VERSION}"
  12. else
  13. GCC_VERSION="GCC$(gcc --version 2>/dev/null|grep gcc|awk '{print $3}')"
  14. echo $GCC_VERSION| grep '-' >/dev/null && GCC_VERSION=$(echo $GCC_VERSION| awk -F '-' '{print$1}')
  15. SRS_PLATFORM="${SRS_PLATFORM}-${GCC_VERSION}"
  16. fi
  17. # Use isolate cache for different SRS version.
  18. SRS_PLATFORM="${SRS_PLATFORM}-SRS4-$(uname -m)"
  19. if [[ $SRS_CROSS_BUILD == YES ]]; then
  20. SRS_PLATFORM="${SRS_PLATFORM}-CROSSBUILD-$(echo $SRS_TOOL_CC|awk -F - '{print $1}')"
  21. fi
  22. echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}"
  23. # For src object files on each platform.
  24. (
  25. mkdir -p ${SRS_OBJS_DIR} && cd ${SRS_OBJS_DIR} &&
  26. rm -rf src utest srs srs_utest research include lib srs_hls_ingester srs_mp4_parser &&
  27. mkdir -p ${SRS_PLATFORM}/src && ln -sf ${SRS_PLATFORM}/src &&
  28. mkdir -p ${SRS_PLATFORM}/utest && ln -sf ${SRS_PLATFORM}/utest &&
  29. mkdir -p ${SRS_PLATFORM}/research && ln -sf ${SRS_PLATFORM}/research &&
  30. mkdir -p ${SRS_PLATFORM}/include && ln -sf ${SRS_PLATFORM}/include &&
  31. mkdir -p ${SRS_PLATFORM}/lib && ln -sf ${SRS_PLATFORM}/lib
  32. )
  33. if [[ $SRS_CLEAN == NO ]]; then
  34. echo "Fast cleanup, if need to do full cleanup, please use: make clean"
  35. fi
  36. # Python or python2, for CentOS8.
  37. python2 --version >/dev/null 2>&1 && alias python=python2 &&
  38. echo "Alias python2 as python"