Files
patches/x264/x264-posixify.patch
T
2026-05-26 02:08:47 -05:00

283 lines
9.1 KiB
Diff

--- a/configure 2025-08-16 00:29:41.000000000 -0500
+++ b/configure 2026-03-25 01:07:23.787385597 -0500
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat <<EOF
@@ -62,7 +62,7 @@
fi
log_check() {
- echo -n "checking $1... " >> config.log
+ printf 'checking %s... ' "$1" >> config.log
}
log_ok() {
@@ -81,13 +81,14 @@
# 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=
+ case $arg in
+ -falign-loops*|-mpreferred-stack-boundary*|-l*|-L*)
+ arg=
+ ;;
+ esac
[ "$arg" = -fno-tree-vectorize ] && arg=
[ "$arg" = -Wshadow ] && arg=
[ "$arg" = -Wno-maybe-uninitialized ] && 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=
@@ -103,15 +104,27 @@
fi
[ $compiler = CL -a "$arg" = -O3 ] && arg=-O2
- [ -n "$arg" ] && echo -n "$arg "
+ [ -n "$arg" ] && printf '%s ' "$arg"
done
}
cl_ldflags() {
for arg in $*; do
- arg=${arg/LIBPATH/libpath}
- [ "${arg#-libpath:}" == "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
- [ "${arg#-L}" != "$arg" ] && arg=-libpath:${arg#-L}
+ case $arg in
+ *LIBPATH*)
+ arg=$(printf '%s\n' "$arg" | sed 's/LIBPATH/libpath/')
+ ;;
+ esac
+ case $arg in
+ -libpath:*)
+ ;;
+ -l*)
+ arg=${arg#-l}.lib
+ ;;
+ -L*)
+ arg=-libpath:${arg#-L}
+ ;;
+ esac
[ "$arg" = -Wl,--large-address-aware ] && arg=-largeaddressaware
[ "$arg" = -s ] && arg=
[ "$arg" = -Wl,-Bsymbolic ] && arg=
@@ -119,15 +132,23 @@
[ "$arg" = -Werror ] && arg=
[ "$arg" = -Wshadow ] && arg=
[ "$arg" = -Wmaybe-uninitialized ] && arg=
- [[ "$arg" = -Qdiag-error* ]] && arg=
-
- arg=${arg/pthreadGC/pthreadVC}
+ case $arg in
+ -Qdiag-error*)
+ arg=
+ ;;
+ esac
+
+ case $arg in
+ *pthreadGC*)
+ arg=$(printf '%s\n' "$arg" | sed 's/pthreadGC/pthreadVC/')
+ ;;
+ esac
[ "$arg" = avifil32.lib ] && arg=vfw32.lib
[ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
[ "$arg" = gpac.lib ] && arg=libgpac.lib
[ "$arg" = x264.lib ] && arg=libx264.lib
- [ -n "$arg" ] && echo -n "$arg "
+ [ -n "$arg" ] && printf '%s ' "$arg"
done
}
@@ -191,7 +212,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 !(%s)\n#error %s\n#endif\n' "$3" "$4" >> conftest.c
if [ $compiler_style = MS ]; then
cpp_cmd="$CC conftest.c $(cc_cflags $CFLAGS $2) -P"
else
@@ -352,16 +373,21 @@
# Construct a path to the specified directory relative to the working directory
relative_path() {
- local base="${PWD%/}"
- local path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")"
- local up=''
-
- while [[ $path != "$base/"* ]]; do
- base="${base%/*}"
- up="../$up"
+ relative_base="${PWD%/}"
+ relative_pathname=$(cd "$1" >/dev/null && printf '%s/.' "${PWD%/}") || return 1
+ relative_up=
+
+ while :; do
+ case $relative_pathname in
+ "$relative_base"/*)
+ break
+ ;;
+ esac
+ relative_base=${relative_base%/*}
+ relative_up="../$relative_up"
done
- dirname "$up${path#"$base/"}"
+ dirname "$relative_up${relative_pathname#"$relative_base/"}"
}
SRCPATH="$(relative_path "$(dirname "$0")")"
@@ -604,10 +630,16 @@
# test for use of compilers that require specific handling
cc_base="$(basename "$CC")"
QPRE="-"
-if [[ $host_os = mingw* || $host_os = msys* || $host_os = cygwin* ]]; then
- if [[ "$cc_base" = icl || "$cc_base" = icl[\ .]* ]]; then
+case $host_os in
+mingw*|msys*|cygwin*)
+ case $cc_base in
+ icl|icl.*|icl\ *)
# 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"
+ case $host_os in
+ cygwin*)
+ die "Windows Intel Compiler support requires MSYS"
+ ;;
+ esac
compiler=ICL
compiler_style=MS
CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
@@ -621,7 +653,8 @@
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
+ ;;
+ cl|cl.*|cl\ *)
# Standard Microsoft Visual Studio
compiler=CL
compiler_style=MS
@@ -636,16 +669,22 @@
elif cpp_check '' '' 'defined(_M_ARM)' ; then
host_cpu=arm
fi
- else
+ ;;
+ *)
# 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
+ ;;
+ esac
+ ;;
+*)
+ case $cc_base in
+ icc|icc.*|icc\ *)
AR="xiar"
compiler=ICC
- fi
-fi
+ ;;
+ esac
+ ;;
+esac
if [ $compiler = GNU ]; then
if cc_check '' -Werror=unknown-warning-option ; then
@@ -711,7 +750,7 @@
;;
cygwin*|mingw*|msys*)
EXE=".exe"
- if [[ $host_os = cygwin* ]] && cpp_check "" "" "defined(__CYGWIN__)" ; then
+ if case $host_os in cygwin*) true ;; *) false ;; esac && cpp_check "" "" "defined(__CYGWIN__)" ; then
SYS="CYGWIN"
define HAVE_MALLOC_H
else
@@ -766,11 +805,23 @@
AS_EXT=".asm"
ASFLAGS="$ASFLAGS -DARCH_X86_64=0 -I\$(SRCPATH)/common/x86/"
if [ $compiler = GNU ]; then
- if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
- CFLAGS="$CFLAGS -march=i686"
+ if [ "$asm" = auto ]; then
+ case " $CFLAGS " in
+ *" -march"*)
+ ;;
+ *)
+ CFLAGS="$CFLAGS -march=i686"
+ ;;
+ esac
fi
- if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
- CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
+ if [ "$asm" = auto ]; then
+ case " $CFLAGS " in
+ *" -mfpmath"*)
+ ;;
+ *)
+ CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
+ ;;
+ esac
fi
CFLAGS="-m32 $CFLAGS"
LDFLAGS="-m32 $LDFLAGS"
@@ -1000,7 +1051,7 @@
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 ] || printf '%s\n' "$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
@@ -1392,7 +1443,13 @@
if [ "$pic" = "yes" ] ; then
[ "$SYS" != WINDOWS -a "$SYS" != CYGWIN ] && CFLAGS="$CFLAGS -fPIC"
- [[ "$ASFLAGS" != *"-DPIC"* ]] && ASFLAGS="$ASFLAGS -DPIC"
+ case " $ASFLAGS " in
+ *" -DPIC "*)
+ ;;
+ *)
+ ASFLAGS="$ASFLAGS -DPIC"
+ ;;
+ esac
# 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"
@@ -1682,8 +1739,14 @@
if [ "$bashcompletion" = "auto" ]; then
if [ "$cli" = "no" ]; then
bashcompletion="no"
- elif [[ -z "$bashcompletionsdir" && "$prefix" != "/usr" && "$prefix" != "/usr/"* ]]; then
- bashcompletion="no"
+ elif [ -z "$bashcompletionsdir" ]; then
+ case $prefix in
+ /usr|/usr/*)
+ ;;
+ *)
+ bashcompletion="no"
+ ;;
+ esac
fi
fi
@@ -1750,8 +1813,7 @@
cat conftest.log
[ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
-mkdir -p common/{aarch64,arm,mips,ppc,x86,loongarch} encoder extras filters/video input output tools
+mkdir -p common/aarch64 common/arm common/mips common/ppc common/x86 common/loongarch encoder extras filters/video input output tools
echo
echo "You can run 'make' or 'make fprofiled' now."
-