changeset 27906:257f974b7cd9

Add yasm support to the build system. This allows to use yasm assembler optimizations from FFmpeg code, in particular, from libavcodec/fft.c.
author bircoph
date Sun, 16 Nov 2008 13:04:16 +0000
parents fdf5209968a6
children 05841116681a
files Makefile configure
diffstat 2 files changed, 58 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Nov 16 12:20:14 2008 +0000
+++ b/Makefile	Sun Nov 16 13:04:16 2008 +0000
@@ -873,10 +873,10 @@
 	doxygen DOCS/tech/Doxyfile
 
 TAGS:
-	rm -f $@; ( find -name '*.[chS]' -print ) | xargs etags -a
+	rm -f $@; ( find -name '*.[chS]' -o -name '*.asm' -print ) | xargs etags -a
 
 tags:
-	rm -f $@; ( find -name '*.[chS]' -print ) | xargs ctags -a
+	rm -f $@; ( find -name '*.[chS]' -o -name '*.asm' -print ) | xargs ctags -a
 
 
 
--- a/configure	Sun Nov 16 12:20:14 2008 +0000
+++ b/configure	Sun Nov 16 13:04:16 2008 +0000
@@ -78,6 +78,19 @@
   compile_check $TMPCPP $@ -lstdc++
 }
 
+yasm_check() {
+  echo >> "$TMPLOG"
+  cat "$TMPS" >> "$TMPLOG"
+  echo >> "$TMPLOG"
+  echo "$_yasm $YASMFLAGS -o $TMPEXE $TMPS $@" >> "$TMPLOG"
+  rm -f "$TMPEXE"
+  $_yasm $YASMFLAGS -o "$TMPEXE" "$TMPS" "$@" >> "$TMPLOG" 2>&1
+  TMP="$?"
+  echo >> "$TMPLOG"
+  echo >> "$TMPLOG"
+  return "$TMP"
+}
+
 tmp_run() {
   "$TMPEXE" >> "$TMPLOG" 2>&1
 }
@@ -408,6 +421,7 @@
   --cc=COMPILER          C compiler to build MPlayer [gcc]
   --host-cc=COMPILER     C compiler for tools needed while building [gcc]
   --as=ASSEMBLER         assembler to build MPlayer [as]
+  --yasm=YASM            Yasm assembler to build MPlayer [yasm]
   --ar=AR                librarian to build MPlayer [ar]
   --ranlib=RANLIB        ranlib to build MPlayer [ranlib]
   --windres=WINDRES      windres to build MPlayer [windres]
@@ -493,6 +507,7 @@
 _ar=ar
 test "$CC" && _cc="$CC"
 _as=auto
+_yasm=yasm
 _runtime_cpudetection=no
 _cross_compile=auto
 _prefix="/usr/local"
@@ -790,6 +805,9 @@
   --as=*)
     _as=`echo $ac_option | cut -d '=' -f 2`
     ;;
+  --yasm=*)
+    _yasm=`echo $ac_option | cut -d '=' -f 2`
+    ;;
   --ar=*)
     _ar=`echo $ac_option | cut -d '=' -f 2`
     ;;
@@ -2385,6 +2403,37 @@
 fi
 echores $_asmalign_pot
 
+echocheck "yasm"
+if test -z "$YASMFLAGS" ; then
+  if darwin ; then
+    x86_64 && objformat="macho64" || objformat="macho32"
+  elif win32 ; then
+    objformat="win32"
+  else 
+    objformat="elf"
+  fi
+  # currently tested for Linux x86, x86_64
+  YASMFLAGS="-f $objformat"
+  x86_64 && YASMFLAGS="$YASMFLAGS -m amd64"
+  case "$objformat" in
+    elf) test $_debug && YASMFLAGS="$YASMFLAGS -g dwarf2" ;;
+    macho64)             YASMFLAGS="$YASMFLAGS -DPIC -DPREFIX" ;;
+    *)                   YASMFLAGS="$YASMFLAGS -DPREFIX"  ;;
+  esac
+else
+  _warn_CFLAGS=yes
+fi
+
+echo "pabsw xmm0, xmm0" > $TMPS
+yasm_check || _yasm=""
+if test $_yasm ; then
+  _def_yasm='#define HAVE_YASM 1'
+  _have_yasm="yes"
+  echores "$_yasm"
+else
+  _def_yasm='#undef HAVE_YASM'
+  echores "no"
+fi
 
 #FIXME: This should happen before the check for CFLAGS..
 if ppc && ( test "$_altivec" = yes || test "$_runtime_cpudetection" = yes ) ; then
@@ -7798,6 +7847,7 @@
 CC = $_cc
 CXX = $_cc
 HOST_CC = $_host_cc
+YASM = $_yasm
 INSTALL = $_install
 INSTALLSTRIP = $_install_strip
 RANLIB = $_ranlib
@@ -7816,6 +7866,7 @@
 CFLAGS_STACKREALIGN = $cflags_stackrealign
 CFLAGS_SVGALIB_HELPER = $cflags_svgalib_helper
 CFLAGS_TREMOR_LOW = $cflags_tremor_low
+YASMFLAGS = $YASMFLAGS
 
 EXTRALIBS = $_extra_libs
 EXTRA_LIB = $_ld_extra $_ld_static $_ld_lm
@@ -7983,6 +8034,7 @@
 
 # Some FFmpeg codecs depend on these. Enable them unconditionally for now.
 CONFIG_FFT=yes
+CONFIG_FFT_MMX=$_mmx
 CONFIG_GOLOMB=yes
 CONFIG_MDCT=yes
 
@@ -8007,6 +8059,7 @@
 
 HAVE_PTHREADS = $_pthreads
 HAVE_W32THREADS = $_w32threads
+HAVE_YASM = $_have_yasm
 
 `echo $_libavdecoders | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
 `echo $_libavencoders | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
@@ -8410,6 +8463,7 @@
 #else
 #define ENABLE_THREADS 0
 #endif
+$_def_yasm
 
 #define CONFIG_GPL 1
 #define ENABLE_SMALL 0
@@ -8538,7 +8592,8 @@
 if test "$_warn_CFLAGS" = yes; then
   cat <<EOF
 
-MPlayer compilation will use the CPPFLAGS/CFLAGS/LDFLAGS set by you, but:
+MPlayer compilation will use the CPPFLAGS/CFLAGS/LDFLAGS/YASMFLAGS set by you,
+but:
 
     *** ***  DO NOT REPORT BUGS IF IT DOES NOT COMPILE/WORK!  *** ***