Submitted By:            Igor Živković
Date:                    2014-07-31
Initial Package Version: snapshot-20140709-2245-stable
Upstream Status:         Not submitted
Origin:                  Self
Description:             Improves configure shell script portability and removes
                         dependency on bash.

diff -Naur x264-snapshot-20160220-2245-stable.orig/configure x264-snapshot-20160220-2245-stable/configure
--- x264-snapshot-20160220-2245-stable.orig/configure	2016-02-20 22:45:07.000000000 +0100
+++ x264-snapshot-20160220-2245-stable/configure	2016-03-26 00:03:43.299732942 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
 cat <<EOF
@@ -77,13 +77,13 @@
     # 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" = -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##-l*}" ] && arg=
+        [ ! "${arg##-L*}" ] && arg=
         if [ $compiler_style = MS ]; then
             [ "$arg" = -ffast-math ] && arg="-fp:fast"
             [ "$arg" = -Wall ] && arg=
@@ -105,8 +105,8 @@
 
 cl_ldflags() {
     for arg in $*; do
-        arg=${arg/LIBPATH/libpath}
-        [ "${arg#-libpath:}" == "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
+        arg=$(echo $arg | sed -e "s/LIBPATH/libpath/")
+        [ ${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=
@@ -115,9 +115,9 @@
         [ "$arg" = -Werror ] && arg=
         [ "$arg" = -Wshadow ] && arg=
         [ "$arg" = -Wmaybe-uninitialized ] && arg=
-        [[ "$arg" = -Qdiag-error* ]] && arg=
+        [ ! "${arg##-Qdiag-error*}" ] && arg=
 
-        arg=${arg/pthreadGC/pthreadVC}
+        arg=$(echo $arg | sed -e "s/pthreadGC/pthreadVC/")
         [ "$arg" = avifil32.lib ] && arg=vfw32.lib
         [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
         [ "$arg" = x264.lib ] && arg=libx264.lib
@@ -179,7 +179,7 @@
     for arg in $1; do
         echo "#include <$arg>" >> conftest.c
     done
-    echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
+    printf "#if !($3) \n#error $4 \n#endif \n" >> conftest.c
     if [ $compiler_style = MS ]; then
         cpp_cmd="$CC conftest.c $(cc_cflags $CFLAGS $2) -P"
     else
@@ -312,7 +312,7 @@
     local path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")"
     local up=''
 
-    while [[ $path != "$base/"* ]]; do
+    while [ ${path##"$base/"*} ]; do
         base="${base%/*}"
         up="../$up"
     done
@@ -525,10 +525,10 @@
 # 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##cygwin*}" ]; then
+    if [ "$cc_base" = icl ] || [ ! "${cc_base##icl.*}" ]; 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*}" ] && die "Windows Intel Compiler support requires MSYS"
         compiler=ICL
         compiler_style=MS
         CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
@@ -539,7 +539,7 @@
         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.*}" ]; then
         # Standard Microsoft Visual Studio
         compiler=CL
         compiler_style=MS
@@ -549,13 +549,13 @@
         cpp_check '' '' '_MSC_VER > 1800 || (_MSC_VER == 1800 && _MSC_FULL_VER >= 180030324)' || die "Microsoft Visual Studio support requires Visual Studio 2013 Update 2 or newer"
     fi
 else
-    if [[ "$cc_base" = icc || "$cc_base" = icc[\ .]* ]]; then
+    if [ "$cc_base" = icc ] || [ ! "${cc_base##icc.*}" ]; then
         AR="xiar"
         compiler=ICC
     fi
 fi
 
-if [[ "$cc_base" = clang || "$cc_base" = clang[\ .]* ]]; then
+if [ "$cc_base" = clang ] || [ ! "${cc_base##clang.*}" ]; then
     if cc_check '' -Werror=unknown-warning-option ; then
         CHECK_CFLAGS="$CHECK_CFLAGS -Werror=unknown-warning-option"
     fi
@@ -669,10 +669,10 @@
         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*}" ]; then
                 CFLAGS="$CFLAGS -march=i686"
             fi
-            if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
+            if [ "$asm" = auto ] && [ "${CFLAGS##*-mfpmath*}" ]; then
                 CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
             fi
             CFLAGS="-m32 $CFLAGS"
@@ -1237,7 +1237,7 @@
 # generate exported config file
 
 config_chroma_format="X264_CSP_I$chroma_format"
-[ "$config_chroma_format" == "X264_CSP_Iall" ] && config_chroma_format="0"
+[ "$config_chroma_format" = "X264_CSP_Iall" ] && config_chroma_format="0"
 cat > x264_config.h << EOF
 #define X264_BIT_DEPTH     $bit_depth
 #define X264_GPL           $x264_gpl
@@ -1458,7 +1458,7 @@
 cat conftest.log
 
 [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
-mkdir -p common/{aarch64,arm,ppc,x86} encoder extras filters/video input output tools
+mkdir -p common/aarch64 common/arm common/ppc common/x86 encoder extras filters/video input output tools
 
 echo
 echo "You can run 'make' or 'make fprofiled' now."
