}
cc_cflags() {
- # several non gcc compilers issue an incredibly large number of warnings on any warning level,
- # suppress them by disabling all warnings rather than having to use #pragmas to disable most of them
+ # 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" = -ffast-math ] && arg=
[[ "$arg" = -falign-loops* ]] && arg=
[ "$arg" = -fno-tree-vectorize ] && arg=
[ "$arg" = -Wshadow ] && arg=
[[ "$arg" = -l* ]] && arg=
[[ "$arg" = -L* ]] && arg=
if [ $compiler_style = MS ]; then
- [ "$arg" = -Wall ] && arg=-W0
+ [ "$arg" = -ffast-math ] && arg="-fp:fast"
+ [ "$arg" = -Wall ] && arg=
[ "$arg" = -Werror ] && arg="-W3 -WX"
[ "$arg" = -g ] && arg=-Z7
[ "$arg" = -fomit-frame-pointer ] && arg=
[ "$arg" = -s ] && arg=
[ "$arg" = -fPIC ] && arg=
else
- [ "$arg" = -Wall ] && arg=-w0
+ [ "$arg" = -ffast-math ] && arg=
+ [ "$arg" = -Wall ] && arg=
[ "$arg" = -Werror ] && arg="-w3 -Werror"
fi
[ $compiler = CL -a "$arg" = -O3 ] && arg=-O2
rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
-SRCPATH="$(cd $(dirname $0); pwd)"
-[ "$SRCPATH" = "$(pwd)" ] && SRCPATH=.
-[ -n "$(echo $SRCPATH | grep ' ')" ] && die "Out of tree builds are impossible with whitespace in source path."
+# 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"
+ done
+
+ dirname "$up${path#"$base/"}"
+}
+
+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."
prefix='/usr/local'
fi
elif [[ "$cc_base" = cl || "$cc_base" = cl[\ .]* ]]; then
# Standard Microsoft Visual Studio
- # Dependency creation includes absolute windows paths, Cygwin's make does not support Windows paths.
- [[ $host_os = cygwin* ]] && die "Microsoft Visual Studio support requires MSYS"
compiler=CL
compiler_style=MS
- CFLAGS="$CFLAGS -nologo -DHAVE_STRING_H -I\$(SRCPATH)/extras"
- `$CC 2>&1 | grep -q 'for x86'` && host_cpu=i486
- `$CC 2>&1 | grep -q 'for x64'` && host_cpu=x86_64
+ CFLAGS="$CFLAGS -nologo -GS- -DHAVE_STRING_H -I\$(SRCPATH)/extras"
+ `$CC 2>&1 | grep -q 'x86'` && host_cpu=i486
+ `$CC 2>&1 | grep -q 'x64'` && host_cpu=x86_64
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
;;
cygwin*)
EXE=".exe"
- if cc_check "" -mno-cygwin; then
+ if [ $compiler_style = GNU ] && cc_check "" -mno-cygwin; then
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
fi
CFLAGS="$CFLAGS -march=i686"
fi
if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
- CFLAGS="$CFLAGS -mfpmath=sse -msse"
+ CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
fi
CFLAGS="-m32 $CFLAGS"
LDFLAGS="-m32 $LDFLAGS"
elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
- [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--nxcompat -Wl,--dynamicbase"
+ [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
[ $compiler = GNU ] && RCFLAGS="--target=pe-i386 $RCFLAGS"
else
ASFLAGS="$ASFLAGS -f elf32"
ASFLAGS="$ASFLAGS -f win64"
# only the GNU toolchain is inconsistent in prefixing function names with _
[ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
- [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--nxcompat -Wl,--dynamicbase"
+ [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
[ $compiler = GNU ] && RCFLAGS="--target=pe-x86-64 $RCFLAGS"
else
ASFLAGS="$ASFLAGS -f elf64"
fi
;;
- powerpc|powerpc64)
+ powerpc*)
ARCH="PPC"
if [ $asm = auto ] ; then
define HAVE_ALTIVEC
fi
if [ $asm = auto -a $ARCH = AARCH64 ] ; then
- # set flags so neon is built by default
- echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-arch)' || CFLAGS="$CFLAGS -arch arm64 -mfpu=neon"
-
if cc_check '' '' '__asm__("cmeq v0.8h, v0.8h, #0");' ; then define HAVE_NEON
ASFLAGS="$ASFLAGS -c"
else
ASFLAGS="$ASFLAGS -DSTACK_ALIGNMENT=$stack_alignment"
# skip endianness check for Intel Compiler and MSVS, as all supported platforms are little. each have flags that will cause the check to fail as well
+CPU_ENDIAN="little-endian"
if [ $compiler = GNU ]; then
echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
$CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
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
die "endian test failed"
fi
#define X264_CHROMA_FORMAT $config_chroma_format
EOF
-${SRCPATH}/version.sh "${SRCPATH}" >> x264_config.h
+${SRCPATH}/version.sh >> x264_config.h
if [ "$cli_libx264" = "system" ] ; then
if [ "$shared" = "yes" ]; then
if [ $compiler_style = MS ]; then
AR="lib -nologo -out:"
LD="link -out:"
- [ $compiler = ICL ] && AR="xi$AR" && LD="xi$LD"
+ if [ $compiler = ICL ]; then
+ AR="xi$AR"
+ LD="xi$LD"
+ else
+ mslink="$(dirname "$(command -v cl 2>/dev/null)")/link"
+ [ -x "$mslink" ] && LD="\"$mslink\" -out:"
+ fi
HAVE_GETOPT_LONG=0
LDFLAGS="-nologo -incremental:no $(cl_ldflags $LDFLAGS)"
LDFLAGSCLI="$(cl_ldflags $LDFLAGSCLI)"
cat > conftest.log <<EOF
platform: $ARCH
+byte order: $CPU_ENDIAN
system: $SYS
cli: $cli
libx264: $cli_libx264