Skip to content

Commit

Permalink
SRS5: Configure: Reorder the functions, nothing changed.
Browse files Browse the repository at this point in the history
PICK bdacd31
  • Loading branch information
winlinvip committed Dec 31, 2022
1 parent 2031a98 commit 55dce2c
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,37 @@ SRS_DEBUG=NO
SRS_DEBUG_STATS=NO

#####################################################################################
# menu
function apply_system_options() {
OS_IS_OSX=$(uname -s |grep -q Darwin && echo YES)
OS_IS_LINUX=$(uname -s |grep -q Linux && echo YES)
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
}
apply_system_options

#####################################################################################
# Show help menu.
#####################################################################################
function show_help() {
cat << END
Expand Down Expand Up @@ -208,6 +238,9 @@ For example:
END
}

#####################################################################################
# Parse user options
#####################################################################################
function parse_user_option() {
# Ignore the options.
if [[ $option == '--demo' || $option == '--dev' || $option == '--fast-dev' || $option == '--pi'
Expand Down Expand Up @@ -424,39 +457,6 @@ function switch2value() {
fi
}

#####################################################################################
function apply_system_options() {
OS_IS_OSX=$(uname -s |grep -q Darwin && echo YES)
OS_IS_LINUX=$(uname -s |grep -q Linux && echo YES)
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
}
apply_system_options

#####################################################################################
# parse preset options
#####################################################################################
opt=

for option
Expand All @@ -466,6 +466,9 @@ do
parse_user_option
done

#####################################################################################
# Apply auto options
#####################################################################################
function apply_auto_options() {
if [[ $OS_IS_CYGWIN == YES ]]; then
SRS_CYGWIN64=YES
Expand Down Expand Up @@ -548,17 +551,16 @@ function apply_auto_options() {
export SRS_JOBS="--jobs=${SRS_JOBS}"
fi
}
apply_auto_options

if [[ $help == YES ]]; then
apply_auto_options
show_help
exit 0
fi

#####################################################################################
# apply options
# Apply detail options
#####################################################################################

function apply_detail_options() {
# Always enable HTTP utilies.
if [[ $SRS_HTTP_CORE == NO ]]; then SRS_HTTP_CORE=YES; echo -e "${YELLOW}[WARN] Always enable HTTP utilies.${BLACK}"; fi
Expand All @@ -573,9 +575,11 @@ function apply_detail_options() {
if [[ $SRS_HLS == NO ]]; then SRS_HLS=YES; echo -e "${YELLOW}[WARN] Always enable HLS.${BLACK}"; fi
if [[ $SRS_DVR == NO ]]; then SRS_DVR=YES; echo -e "${YELLOW}[WARN] Always enable DVR.${BLACK}"; fi
}
apply_auto_options
apply_detail_options

#####################################################################################
# Regenerate options for tracing.
#####################################################################################
function regenerate_options() {
# save all config options to macro to write to auto headers file
SRS_AUTO_USER_CONFIGURE=`echo $opt`
Expand Down Expand Up @@ -653,7 +657,7 @@ function regenerate_options() {
regenerate_options

#####################################################################################
# check user options
# Check conflicted options
#####################################################################################
function check_option_conflicts() {
if [[ $SRS_TOOL_CC == '' || $SRS_TOOL_CXX == '' || $SRS_TOOL_AR == '' || $SRS_TOOL_LD == '' || $SRS_TOOL_RANDLIB == '' ]]; then
Expand Down

0 comments on commit 55dce2c

Please sign in to comment.