Repository: ossrs/srs
File: trunk/auto/options.sh (Shell)

Code before:
    OS_IS_CYGWIN=$(uname -s |grep -q CYGWIN && echo YES)

    OS_IS_CENTOS=$(yum --version >/dev/null 2>&1 && echo YES)
    # For Debian, we think it's ubuntu also.
    # For example, the wheezy/sid which is debian armv7 linux, can not identified by uname -v.
    OS_IS_UBUNTU=$(apt-get --version >/dev/null 2>&1 && echo YES)
    OS_IS_LOONGSON=$(uname -r |grep -q loongson && echo YES)

    # Use gcc to detect the CPU arch.
    gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then echo "Please install gcc"; exit 1; fi
    OS_IS_LOONGARCH64=$(gcc -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
    OS_IS_MIPS64=$(gcc -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
    OS_IS_X86_64=$(gcc -dM -E - </dev/null |grep -q '#define __x86_64 1' && echo YES)
    OS_IS_RISCV=$(gcc -dM -E - </dev/null |grep -q '#define __riscv 1' && echo YES)

    # Set the os option automatically.
    if [[ $OS_IS_OSX == YES ]]; then SRS_OSX=YES; fi
    if [[ $OS_IS_CYGWIN == YES ]]; then SRS_CYGWIN64=YES; fi

    if [[ $OS_IS_OSX == YES ]]; then SRS_JOBS=$(sysctl -n hw.ncpu 2>/dev/null || echo 1); fi
    if [[ $OS_IS_LINUX == YES || $OS_IS_CYGWIN == YES ]]; then
        SRS_JOBS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || echo 1)
    fi

    # Set centos version
    if [[ $OS_IS_CENTOS == YES ]]; then
        OS_CENTOS_VERSION=$(rpm -q centos-release|cut -d- -f3)
    fi
}
apply_system_options

#####################################################################################
# Show help menu.
#####################################################################################
function show_help() {
    cat << END

Configure to generate Makefile.
  -h, --help                Print this message and exit 0.

Features:
  --https=on|off            Whether enable HTTPS client and server. Default: $(value2switch $SRS_HTTPS)
  --utest=on|off            Whether build the utest. Default: $(value2switch $SRS_UTEST)
  --srt=on|off              Whether build the SRT. Default: $(value2switch $SRS_SRT)
  --rtc=on|off              Whether build the WebRTC. Default: $(value2switch $SRS_RTC)
  --gb28181=on|off          Whether build the GB28181. Default: $(value2switch $SRS_GB28181)
  --cxx11=on|off            Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
  --cxx14=on|off            Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
  --ffmpeg-fit=on|off       Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
  --apm=on|off              Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)
  --h265=on|off             Whether build the HEVC(H.265) support. Default: $(value2switch $SRS_H265)

Review comment (security):
No need to check the version, let's disable Asan by default for all CentOS. But simply turning it off is not enough, we still need to support users to enable it themselves.

First, mark SRS_SANITIZER as RESERVED, and then set the initial value based on different systems.

Additionally, by default, enable asan static linking if possible.

`TRANS_BY_GPT3`

Code after:

    OS_IS_CENTOS=$(yum --version >/dev/null 2>&1 && echo YES)
    # For Debian, we think it's ubuntu also.
    # For example, the wheezy/sid which is debian armv7 linux, can not identified by uname -v.
    OS_IS_UBUNTU=$(apt-get --version >/dev/null 2>&1 && echo YES)
    OS_IS_LOONGSON=$(uname -r |grep -q loongson && echo YES)

    # Use gcc to detect the CPU arch.
    gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then echo "Please install gcc"; exit 1; fi
    OS_IS_LOONGARCH64=$(gcc -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
    OS_IS_MIPS64=$(gcc -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
    OS_IS_X86_64=$(gcc -dM -E - </dev/null |grep -q '#define __x86_64 1' && echo YES)
    OS_IS_RISCV=$(gcc -dM -E - </dev/null |grep -q '#define __riscv 1' && echo YES)

    # Set the os option automatically.
    if [[ $OS_IS_OSX == YES ]]; then SRS_OSX=YES; fi
    if [[ $OS_IS_CYGWIN == YES ]]; then SRS_CYGWIN64=YES; fi

    if [[ $OS_IS_OSX == YES ]]; then SRS_JOBS=$(sysctl -n hw.ncpu 2>/dev/null || echo 1); fi
    if [[ $OS_IS_LINUX == YES || $OS_IS_CYGWIN == YES ]]; then
        SRS_JOBS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || echo 1)
    fi
}
apply_system_options

#####################################################################################
# Show help menu.
#####################################################################################
function show_help() {
    cat << END

Configure to generate Makefile.
  -h, --help                Print this message and exit 0.

Features:
  --https=on|off            Whether enable HTTPS client and server. Default: $(value2switch $SRS_HTTPS)
  --utest=on|off            Whether build the utest. Default: $(value2switch $SRS_UTEST)
  --srt=on|off              Whether build the SRT. Default: $(value2switch $SRS_SRT)
  --rtc=on|off              Whether build the WebRTC. Default: $(value2switch $SRS_RTC)
  --gb28181=on|off          Whether build the GB28181. Default: $(value2switch $SRS_GB28181)
  --cxx11=on|off            Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
  --cxx14=on|off            Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
  --ffmpeg-fit=on|off       Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
  --apm=on|off              Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)

  --prefix=<path>           The absolute installation path. Default: $SRS_PREFIX
  --jobs[=N]                Allow N jobs at once; infinite jobs with no arg. Default: $SRS_JOBS
  --config=<path>           The default config file for SRS. Default: $SRS_DEFAULT_CONFIG

Performance:                @see https://ossrs.net/lts/zh-cn/docs/v5/doc/performance
  --valgrind=on|off         Whether build valgrind for memory check. Default: $(value2switch $SRS_VALGRIND)