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

diff -Naur x264-snapshot-20140709-2245-stable.orig/configure x264-snapshot-20140709-2245-stable/configure
--- x264-snapshot-20140709-2245-stable.orig/configure	2014-07-09 22:45:07.000000000 +0200
+++ x264-snapshot-20140709-2245-stable/configure	2014-07-31 21:34:57.292364000 +0200
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
 cat <<EOF
@@ -78,12 +78,12 @@
     # suppress them by disabling all warnings rather than having to use #pragmas to disable most of them
     for arg in $*; do
         [ $arg = -ffast-math ] && arg=
-        [[ "$arg" = -falign-loops* ]] && arg=
+        [ ! "${arg##-falign-loops*}" ] && arg=
         [ "$arg" = -fno-tree-vectorize ] && arg=
         [ "$arg" = -Wshadow ] && 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 = ICL ]; then
             [ "$arg" = -Wall ] && arg=-W0
             [ "$arg" = -g ] && arg=-Z7
@@ -100,14 +100,14 @@
 
 icl_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=
         [ "$arg" = -Wl,-Bsymbolic ] && 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
 
@@ -164,7 +164,7 @@
     log_check "whether $3 is true"
     rm -f conftest.c
     [ -n "$1" ] && echo "#include <$1>" > conftest.c
-    echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
+    printf "#if !($3) \n#error $4 \n#endif \n" >> conftest.c
 
     if $CC conftest.c $CFLAGS $2 -E -o conftest >conftest.log 2>&1; then
         res=$?
@@ -440,10 +440,10 @@
 host_os="${host#*-}"
 
 # test for use of Intel Compiler
-if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
-    if [[ `basename "$CC"` = icl* ]]; then
+if [ ! "${host_os##mingw*}" ] || [ ! "${host_os##cygwin*}" ]; then
+    if case `basename "$CC"` in icl*) true;; *) false;; esac; 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
         CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
         QPRE="-Q"
@@ -452,7 +452,7 @@
         cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
     fi
 else
-    if [[ `basename "$CC"` = icc* ]]; then
+    if case `basename "$CC"` in icc*) true;; *) false;; esac; then
         AR="xiar"
         compiler=ICC
         QPRE="-"
@@ -563,10 +563,10 @@
         AS="yasm"
         ASFLAGS="$ASFLAGS -O2"
         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"
             fi
             CFLAGS="-m32 $CFLAGS"
@@ -1134,7 +1134,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
@@ -1295,7 +1295,7 @@
 rm conftest.log
 
 [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
-mkdir -p common/{arm,ppc,sparc,x86} encoder extras filters/video input output tools
+mkdir -p common/arm common/ppc common/sparc common/x86 encoder extras filters/video input output tools
 
 echo
 echo "You can run 'make' or 'make fprofiled' now."
