[x264-devel] [PATCH v2 6/8] configure: remove use of test's poorly defined -o and -a operators
Ethan Sommer
e5ten.arch at gmail.com
Thu Jan 16 22:23:40 CET 2020
---
configure | 101 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 58 insertions(+), 43 deletions(-)
diff --git a/configure b/configure
index 280e7d3b..ae89850a 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/bash
-if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
+if [ "$1" = -h ] || [ "$1" = --help ]; then
cat <<EOF
Usage: ./configure [options]
@@ -97,7 +97,7 @@ cc_cflags() {
[ "$arg" = -Wall ] && arg=
[ "$arg" = -Werror ] && arg="-w3 -Werror"
fi
- [ $compiler = CL -a "$arg" = -O3 ] && arg=-O2
+ [ "$compiler" = CL ] && [ "$arg" = -O3 ] && arg=-O2
[ -n "$arg" ] && printf '%s ' "$arg"
done
@@ -106,7 +106,7 @@ cc_cflags() {
cl_ldflags() {
for arg in $*; do
arg=${arg/LIBPATH/libpath}
- [ "${arg#-libpath:}" = "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
+ [ "${arg#-libpath:}" = "$arg" ] && [ "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
[ "${arg#-L}" != "$arg" ] && arg=-libpath:${arg#-L}
[ "$arg" = -Wl,--large-address-aware ] && arg=-largeaddressaware
[ "$arg" = -s ] && arg=
@@ -349,7 +349,9 @@ relative_path() {
SRCPATH="$(relative_path "$(dirname "$0")")"
echo "$SRCPATH" | grep -q ' ' && die "Out of tree builds are impossible with whitespace in source path."
-[ -e "$SRCPATH/config.h" -o -e "$SRCPATH/x264_config.h" ] && die "Out of tree builds are impossible with config.h/x264_config.h in source dir."
+if [ -e "$SRCPATH/config.h" ] || [ -e "$SRCPATH/x264_config.h" ]; then
+ die "Out of tree builds are impossible with config.h/x264_config.h in source dir."
+fi
prefix='/usr/local'
exec_prefix='${prefix}'
@@ -518,17 +520,23 @@ for opt do
;;
--bit-depth=*)
bit_depth="$optarg"
- if [ "$bit_depth" != "8" -a "$bit_depth" != "10" -a "$bit_depth" != "all" ]; then
- echo "Supplied bit depth must be 8, 10 or all."
- exit 1
- fi
+ case "$bit_depth" in
+ 8|10|all) ;;
+ *)
+ echo "Supplied bit depth must be 8, 10 or all."
+ exit 1
+ ;;
+ esac
;;
--chroma-format=*)
chroma_format="$optarg"
- if [ $chroma_format != "400" -a $chroma_format != "420" -a $chroma_format != "422" -a $chroma_format != "444" -a $chroma_format != "all" ]; then
- echo "Supplied chroma format must be 400, 420, 422, 444 or all."
- exit 1
- fi
+ case "$chroma_format" in
+ 400|420|422|444|all) ;;
+ *)
+ echo "Supplied chroma format must be 400, 420, 422, 444 or all."
+ exit 1
+ ;;
+ esac
;;
*)
echo "Unknown option $opt, ignored"
@@ -536,7 +544,8 @@ for opt do
esac
done
-[ "$cli" = "no" -a "$shared" = "no" -a "$static" = "no" ] && die "Nothing to build. Enable cli, shared or static."
+[ "$cli" = "no" ] && [ "$shared" = "no" ] && [ "$static" = "no" ] &&
+ die "Nothing to build. Enable cli, shared or static."
CC="${CC-${cross_prefix}gcc}"
STRIP="${STRIP-${cross_prefix}strip}"
@@ -736,7 +745,7 @@ case $host_cpu in
fi
if [ "$SYS" = MACOSX ]; then
ASFLAGS="$ASFLAGS -f macho32 -DPREFIX"
- elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
+ elif [ "$SYS" = WINDOWS ] || [ "$SYS" = CYGWIN ]; then
ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
[ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
@@ -758,7 +767,7 @@ case $host_cpu in
CFLAGS="$CFLAGS -arch x86_64"
LDFLAGS="$LDFLAGS -arch x86_64"
fi
- elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
+ elif [ "$SYS" = WINDOWS ] || [ "$SYS" = CYGWIN ]; then
ASFLAGS="$ASFLAGS -f win64"
if [ $compiler = GNU ]; then
# only the GNU toolchain is inconsistent in prefixing function names with _
@@ -897,12 +906,14 @@ if [ $compiler_style = GNU ]; then
fi
fi
-if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" -o $ARCH = "PARISC" -o $ARCH = "MIPS" -o $ARCH = "AARCH64" \) ] ; then
- pic="yes"
+if [ "$shared" = yes ]; then
+ case "$ARCH" in
+ X86_64|PPC|ALPHA|ARM|IA64|PARISC|MIPS|AARCH64) pic=yes ;;
+ esac
fi
if cc_check '' '' '' '__attribute__((force_align_arg_pointer))' ; then
- if [ $compiler = GNU -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
+ if [ "$compiler" = GNU ] && [ "${ARCH%_64}" = X86 ]; then
if cc_check '' -mpreferred-stack-boundary=6 ; then
CFLAGS="$CFLAGS -mpreferred-stack-boundary=6"
stack_alignment=64
@@ -918,7 +929,7 @@ if cc_check '' '' '' '__attribute__((force_align_arg_pointer))' ; then
stack_alignment=16
fi
fi
- elif [ $compiler = ICC -a $ARCH = X86 ]; then
+ elif [ "$compiler" = ICC ] && [ "$ARCH" = X86 ]; then
# icc on linux has various degrees of mod16 stack support
if [ $SYS = LINUX ]; then
# >= 12 defaults to a mod16 stack
@@ -934,7 +945,7 @@ if cc_check '' '' '' '__attribute__((force_align_arg_pointer))' ; then
fi
fi
-if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
+if [ "$asm" = auto ] && [ "${ARCH%_64}" = X86 ]; then
if ! as_check "vmovdqa32 [eax]{k1}{z}, zmm0" ; then
VER="$( ($AS --version || echo no assembler) 2>/dev/null | head -n 1 )"
echo "Found $VER"
@@ -946,7 +957,7 @@ if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
define HAVE_MMX
fi
-if [ $asm = auto -a $ARCH = ARM ] ; then
+if [ "$asm" = auto ] && [ "$ARCH" = ARM ]; then
# set flags so neon is built by default
[ $compiler = CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
@@ -966,7 +977,7 @@ if [ $asm = auto -a $ARCH = ARM ] ; then
fi
fi
-if [ $asm = auto -a $ARCH = AARCH64 ] ; then
+if [ "$asm" = auto ] && [ "$ARCH" = AARCH64 ] ; then
if [ $compiler = CL ] && cpp_check '' '' 'defined(_M_ARM64)' ; then
define HAVE_AARCH64
define HAVE_NEON
@@ -981,12 +992,16 @@ if [ $asm = auto -a $ARCH = AARCH64 ] ; then
fi
fi
-if [ $asm = auto -a \( $ARCH = ARM -o $ARCH = AARCH64 \) ] ; then
- # check if the assembler supports '.func' (clang 3.5 does not)
- as_check ".func test${NL}.endfunc" && define HAVE_AS_FUNC 1
+if [ "$asm" = auto ]; then
+ case "$ARCH" in
+ ARM|AARCH64)
+ # check if the assembler supports '.func' (clang 3.5 does not)
+ as_check ".func test${NL}.endfunc" && define HAVE_AS_FUNC 1
+ ;;
+ esac
fi
-if [ $asm = auto -a $ARCH = MIPS ] ; then
+if [ "$asm" = auto ] && [ "$ARCH" = MIPS ] ; then
if ! echo $CFLAGS | grep -Eq '(-march|-mmsa|-mno-msa)' ; then
cc_check '' '-mmsa -mfp64 -mhard-float' && CFLAGS="-mmsa -mfp64 -mhard-float $CFLAGS"
fi
@@ -1022,7 +1037,7 @@ if [ $compiler = GNU ]; then
fi
fi
-if [ "$cli_libx264" = "system" -a "$shared" != "yes" ] ; then
+if [ "$cli_libx264" = "system" ] && [ "$shared" != "yes" ] ; then
[ "$static" = "yes" ] && die "Option --system-libx264 can not be used together with --enable-static"
if pkg_check x264 ; then
X264_LIBS="$($PKGCONFIG --libs x264)"
@@ -1037,7 +1052,7 @@ fi
# autodetect options that weren't forced nor disabled
libpthread=""
-if [ "$SYS" = "WINDOWS" -a "$thread" = "posix" ] ; then
+if [ "$SYS" = "WINDOWS" ] && [ "$thread" = "posix" ] ; then
if [ "$gpl" = "no" ] ; then
echo "Warning: pthread-win32 is LGPL and is therefore not supported with --disable-gpl"
thread="no"
@@ -1106,7 +1121,7 @@ if [ "$SYS" != "WINDOWS" ] && cpp_check "sys/mman.h unistd.h" "" "defined(MAP_PR
define HAVE_MMAP
fi
-if [ "$SYS" = "LINUX" -a \( "$ARCH" = "X86" -o "$ARCH" = "X86_64" \) ] && cc_check "sys/mman.h" "" "MADV_HUGEPAGE;" ; then
+if [ "$SYS" = "LINUX" ] && [ "${ARCH%_64}" = X86 ] && cc_check "sys/mman.h" "" "MADV_HUGEPAGE;" ; then
define HAVE_THP
fi
@@ -1157,7 +1172,7 @@ if [ "$lavf" = "auto" ] ; then
echo "Warning: libavformat is too old"
fi
fi
- if [ "$lavf" = "yes" -a "$swscale" = "no" ]; then
+ if [ "$lavf" = "yes" ] && [ "$swscale" = "no" ]; then
echo "Warning: libavformat is not supported without swscale support"
lavf="no"
fi
@@ -1185,7 +1200,7 @@ if [ "$ffms" = "auto" ] ; then
ffms="no"
echo "Warning: $error"
fi
- if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
+ if [ "$ffms" = "yes" ] && [ "$swscale" = "no" ]; then
echo "Warning: ffms is not supported without swscale support"
ffms="no"
fi
@@ -1224,7 +1239,7 @@ if [ "$lsmash" = "auto" ] ; then
fi
fi
-if [ "$gpac" = "auto" -a "$lsmash" != "yes" ] ; then
+if [ "$gpac" = "auto" ] && [ "$lsmash" != "yes" ] ; then
gpac="no"
GPAC_LIBS="-lgpac_static"
cc_check "" -lz && GPAC_LIBS="$GPAC_LIBS -lz"
@@ -1259,7 +1274,7 @@ if [ "$avs" = "auto" ] ; then
avs="avisynth"
define HAVE_AVS
define USE_AVXSYNTH 0
- elif [ "$SYS" = "LINUX" -o "$SYS" = "MACOSX" ] ; then
+ elif [ "$SYS" = "LINUX" ] || [ "$SYS" = "MACOSX" ] ; then
# AvxSynth currently only supports Linux and OSX
avs="avxsynth"
define HAVE_AVS
@@ -1272,14 +1287,14 @@ fi
cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
if [ "$pic" = "yes" ] ; then
- [ "$SYS" != WINDOWS -a "$SYS" != CYGWIN ] && CFLAGS="$CFLAGS -fPIC"
+ [ "$SYS" != WINDOWS ] && [ "$SYS" != CYGWIN ] && CFLAGS="$CFLAGS -fPIC"
[ "${ASFLAGS#*-DPIC}" = "$ASFLAGS" ] && ASFLAGS="$ASFLAGS -DPIC"
# resolve textrels in the x86 asm
cc_check stdio.h "-shared -Wl,-Bsymbolic" && SOFLAGS="$SOFLAGS -Wl,-Bsymbolic"
- [ $SYS = SunOS -a "$ARCH" = "X86" ] && SOFLAGS="$SOFLAGS -mimpure-text"
+ [ $SYS = SunOS ] && [ "$ARCH" = "X86" ] && SOFLAGS="$SOFLAGS -mimpure-text"
fi
-if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
+if [ "$debug" != "yes" ] && [ "$gprof" != "yes" ]; then
CFLAGS="$CFLAGS -fomit-frame-pointer"
fi
@@ -1304,7 +1319,7 @@ if cc_check '' -fno-tree-vectorize ; then
CFLAGS="$CFLAGS -fno-tree-vectorize"
fi
-if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
+if [ "$SYS" = WINDOWS ] && [ "$ARCH" = X86 ] && [ "$compiler" = GNU ] ; then
# workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
fi
@@ -1332,7 +1347,7 @@ if [ $compiler = GNU ] && cc_check '' -fvisibility=hidden ; then
CFLAGS="$CFLAGS -fvisibility=hidden"
fi
-if [ $compiler = ICC -o $compiler = ICL ] ; then
+if [ $compiler = ICC ] || [ $compiler = ICL ] ; then
if cc_check 'extras/intel_dispatcher.h' '' 'x264_intel_dispatcher_override();' ; then
define HAVE_INTEL_DISPATCHER
fi
@@ -1363,7 +1378,7 @@ if [ "$opencl" = "yes" ]; then
if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then
opencl="yes"
define HAVE_OPENCL "(BIT_DEPTH==8)"
- elif [ "$SYS" = "LINUX" -o "$SYS" = "MACOSX" ] ; then
+ elif [ "$SYS" = "LINUX" ] || [ "$SYS" = "MACOSX" ] ; then
opencl="yes"
define HAVE_OPENCL "(BIT_DEPTH==8)"
libdl="-ldl"
@@ -1395,7 +1410,7 @@ fi
if [ "$cli_libx264" = "system" ] ; then
if [ "$shared" = "yes" ]; then
- if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
+ if [ "$SYS" = "WINDOWS" ] || [ "$SYS" = "CYGWIN" ]; then
CLI_LIBX264='$(IMPLIBNAME)'
else
CLI_LIBX264='$(SONAME)'
@@ -1448,9 +1463,9 @@ if [ $compiler != GNU ]; then
CFLAGSSO="$(cc_cflags $CFLAGSSO)"
CFLAGSCLI="$(cc_cflags $CFLAGSCLI)"
fi
-if [ $compiler = ICC -o $compiler = ICL ]; then
+if [ $compiler = ICC ] || [ $compiler = ICL ]; then
# icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
- [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
+ [ "${ARCH%_64}" = X86 ] && [ "$asm" = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
PROF_GEN_LD=
PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
@@ -1528,7 +1543,7 @@ fi
if [ "$shared" = "yes" ]; then
API=$(grep '#define X264_BUILD' < ${SRCPATH}/x264.h | cut -f 3 -d ' ')
- if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
+ if [ "$SYS" = "WINDOWS" ] || [ "$SYS" = "CYGWIN" ]; then
echo "SONAME=libx264-$API.dll" >> config.mak
if [ $compiler_style = MS ]; then
echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
--
2.25.0
More information about the x264-devel
mailing list