[x264-devel] [PATCH 2/4] configure: replace usage of [[ with POSIX-compatible [

Ethan Sommer e5ten.arch at gmail.com
Tue Jan 14 18:18:15 CET 2020


---
 configure | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/configure b/configure
index 02c44c1a..d9c62730 100755
--- a/configure
+++ b/configure
@@ -78,13 +78,12 @@ cc_cflags() {
     # several non gcc compilers issue an incredibly large number of warnings on high warning levels,
     # suppress them by reducing the warning level rather than having to use #pragmas
     for arg in $*; do
-        [[ "$arg" = -falign-loops* ]] && arg=
+        [ "${arg#-falign-loops}" = "$arg" ] || arg=
         [ "$arg" = -fno-tree-vectorize ] && arg=
         [ "$arg" = -Wshadow ] && arg=
         [ "$arg" = -Wno-maybe-uninitialized ] && arg=
-        [[ "$arg" = -mpreferred-stack-boundary* ]] && arg=
-        [[ "$arg" = -l* ]] && arg=
-        [[ "$arg" = -L* ]] && arg=
+        [ "${arg#-mpreferred-stack-boundary}" = "$arg" ] || arg=
+        [ "${arg#-[Ll]}" = "$arg" ] || arg=
         if [ $compiler_style = MS ]; then
             [ "$arg" = -ffast-math ] && arg="-fp:fast"
             [ "$arg" = -Wall ] && arg=
@@ -107,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" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
         [ "${arg#-L}" != "$arg" ] && arg=-libpath:${arg#-L}
         [ "$arg" = -Wl,--large-address-aware ] && arg=-largeaddressaware
         [ "$arg" = -s ] && arg=
@@ -116,7 +115,7 @@ cl_ldflags() {
         [ "$arg" = -Werror ] && arg=
         [ "$arg" = -Wshadow ] && arg=
         [ "$arg" = -Wmaybe-uninitialized ] && arg=
-        [[ "$arg" = -Qdiag-error* ]] && arg=
+        [ "${arg#-Qdiag-error}" = "$arg" ] || arg=
 
         arg=${arg/pthreadGC/pthreadVC}
         [ "$arg" = avifil32.lib ] && arg=vfw32.lib
@@ -340,7 +339,7 @@ relative_path() {
     local path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")"
     local up=''
 
-    while [[ $path != "$base/"* ]]; do
+    while [ "${path#$base/}" = "$path" ]; do
         base="${base%/*}"
         up="../$up"
     done
@@ -573,10 +572,10 @@ trap 'rm -rf conftest*' EXIT
 # test for use of compilers that require specific handling
 cc_base="$(basename "$CC")"
 QPRE="-"
-if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
-    if [[ "$cc_base" = icl || "$cc_base" = icl[\ .]* ]]; then
+if [ "${host_os#mingw}" != "$host_os" ] || [ "${host_os#cygwin}" != "$host_os" ]; then
+    if [ "$cc_base" = icl ] || [ "${cc_base#icl[ .]}" != "$cc_base" ]; then
         # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
-        [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
+        [ "${host_os#cygwin}" = "$host_os" ] || die "Windows Intel Compiler support requires MSYS"
         compiler=ICL
         compiler_style=MS
         CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
@@ -590,7 +589,7 @@ if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
         if cc_check '' -Qdiag-error:10006,10157 ; then
             CHECK_CFLAGS="$CHECK_CFLAGS -Qdiag-error:10006,10157"
         fi
-    elif [[ "$cc_base" = cl || "$cc_base" = cl[\ .]* ]]; then
+    elif [ "$cc_base" = cl ] || [ "${cc_base#cl[ .]}" != "$cc_base" ]; then
         # Standard Microsoft Visual Studio
         compiler=CL
         compiler_style=MS
@@ -609,11 +608,9 @@ if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
         # MinGW uses broken pre-VS2015 Microsoft printf functions unless it's told to use the POSIX ones.
         CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
     fi
-else
-    if [[ "$cc_base" = icc || "$cc_base" = icc[\ .]* ]]; then
-        AR="xiar"
-        compiler=ICC
-    fi
+elif [ "$cc_base" = icc ] || [ "${cc_base#icc[ .]}" != "$cc_base" ]; then
+    AR="xiar"
+    compiler=ICC
 fi
 
 if [ $compiler = GNU ]; then
@@ -673,7 +670,7 @@ case $host_os in
         ;;
     cygwin*|mingw*|msys*)
         EXE=".exe"
-        if [[ $host_os = cygwin* ]] && cpp_check "" "" "defined(__CYGWIN__)" ; then
+        if [ "${host_os#cygwin}" != "$host_os" ] && cpp_check "" "" "defined(__CYGWIN__)" ; then
             SYS="CYGWIN"
             define HAVE_MALLOC_H
         else
@@ -728,10 +725,10 @@ case $host_cpu in
         AS_EXT=".asm"
         ASFLAGS="$ASFLAGS -DARCH_X86_64=0 -I\$(SRCPATH)/common/x86/"
         if [ $compiler = GNU ]; then
-            if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
+            if [ "$asm" = auto ] && [ "${CFLAGS#*-march}" = "$CFLAGS" ]; then
                 CFLAGS="$CFLAGS -march=i686"
             fi
-            if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
+            if [ "$asm" = auto ] && [ "${CFLAGS#*-mfpmath}" = "$CFLAGS" ]; then
                 CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
             fi
             CFLAGS="-m32 $CFLAGS"
@@ -951,7 +948,7 @@ fi
 
 if [ $asm = auto -a $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"
+    [ $compiler = CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
 
     cc_check '' '' '__asm__("add r0, r1, r2");' && define HAVE_ARM_INLINE_ASM
     if [ $compiler = CL ] && cpp_check '' '' 'defined(_M_ARM) && _M_ARM >= 7' ; then
@@ -1020,7 +1017,7 @@ if [ $compiler = GNU ]; then
     if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
         define WORDS_BIGENDIAN
         CPU_ENDIAN="big-endian"
-    elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
+    elif ! (${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
         die "endian test failed"
     fi
 fi
@@ -1276,7 +1273,7 @@ cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {
 
 if [ "$pic" = "yes" ] ; then
     [ "$SYS" != WINDOWS -a "$SYS" != CYGWIN ] && CFLAGS="$CFLAGS -fPIC"
-    [[ "$ASFLAGS" != *"-DPIC"* ]] && ASFLAGS="$ASFLAGS -DPIC"
+    [ "${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"
@@ -1611,7 +1608,8 @@ cat conftest.log >> config.log
 cat conftest.log
 
 [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
-mkdir -p common/{aarch64,arm,mips,ppc,x86} encoder extras filters/video input output tools
+mkdir -p common/aarch64 common/arm common/mips common/ppc common/x86 \
+    encoder extras filters/video input output tools
 
 echo
 echo "You can run 'make' or 'make fprofiled' now."
-- 
2.25.0



More information about the x264-devel mailing list