$OpenBSD: patch-configure,v 1.59 2011/06/25 14:15:43 edd Exp $
--- configure.orig	Wed Mar  9 00:33:03 2011
+++ configure	Fri Jun 24 12:19:32 2011
@@ -35,29 +35,33 @@
 #
 #############################################################################
 
-if test -e ffmpeg/.svn ; then
-  echo "You have an outdated FFmpeg SVN checkout in ffmpeg/, please (re)move or replace it"
-  exit 1
-fi
 
-if test -e ffmpeg/mp_auto_pull ; then
-  if ! (cd ffmpeg && git pull --rebase --ff-only) ; then
-    echo "git pull failed, (re)move ffmpeg/mp_auto_pull to disable pulling"
-    exit 1
-  fi
-fi
+# OpenBSD
+# Don't do anything funky with git or svn, we will provide mplayer with ffmpeg
+#
+#if test -e ffmpeg/.svn ; then
+#  echo "You have an outdated FFmpeg SVN checkout in ffmpeg/, please (re)move or replace it"
+#  exit 1
+#fi
+#
+#if test -e ffmpeg/mp_auto_pull ; then
+#  if ! (cd ffmpeg && git pull --rebase --ff-only) ; then
+#    echo "git pull failed, (re)move ffmpeg/mp_auto_pull to disable pulling"
+#    exit 1
+#  fi
+#fi
+#
+#if ! test -e ffmpeg ; then
+#  echo "No FFmpeg checkout, press enter to download one with git or CTRL+C to abort"
+#  read tmp
+#  if ! git clone --depth 1 git://git.videolan.org/ffmpeg.git ffmpeg ; then
+#    rm -rf ffmpeg
+#    echo "Failed to get a FFmpeg checkout"
+#    exit 1
+#  fi
+#  touch ffmpeg/mp_auto_pull
+#fi
 
-if ! test -e ffmpeg ; then
-  echo "No FFmpeg checkout, press enter to download one with git or CTRL+C to abort"
-  read tmp
-  if ! git clone --depth 1 git://git.videolan.org/ffmpeg.git ffmpeg ; then
-    rm -rf ffmpeg
-    echo "Failed to get a FFmpeg checkout"
-    exit 1
-  fi
-  touch ffmpeg/mp_auto_pull
-fi
-
 # Prevent locale nonsense from breaking basic text processing utils
 export LC_ALL=C
 
@@ -510,6 +514,7 @@ Audio output:
   --disable-nas          disable NAS audio output [autodetect]
   --disable-sgiaudio     disable SGI audio output [autodetect]
   --disable-sunaudio     disable Sun audio output [autodetect]
+  --disable-sndio        disable OpenBSD sndio audio output [autodetect]
   --disable-kai          disable KAI audio output [autodetect]
   --disable-dart         disable DART audio output [autodetect]
   --disable-win32waveout disable Windows waveout audio output [autodetect]
@@ -745,6 +750,7 @@ _xf86keysym=auto
 _mlib=no #broken, thus disabled
 _sgiaudio=auto
 _sunaudio=auto
+_sndio=auto
 _alsa=auto
 _fastmemcpy=yes
 hardcoded_tables=no
@@ -1169,6 +1175,8 @@ for ac_option do
   --disable-mlib)       _mlib=no        ;;
   --enable-sunaudio)    _sunaudio=yes   ;;
   --disable-sunaudio)   _sunaudio=no    ;;
+  --enable-sndio)	_sndio=yes	;;
+  --disable-sndio)	_sndio=no	;;
   --enable-sgiaudio)    _sgiaudio=yes   ;;
   --disable-sgiaudio)   _sgiaudio=no    ;;
   --enable-alsa)        _alsa=yes       ;;
@@ -1489,7 +1497,7 @@ if test -z "$_target" ; then
       sh3|sh4|sh4a) host_arch=sh ;;
       s390) host_arch=s390 ;;
       s390x) host_arch=s390x ;;
-      *mips*) host_arch=mips ;;
+      sgi|mips*|loongson) host_arch=mips ;;
       vax) host_arch=vax ;;
       xtensa*) host_arch=xtensa ;;
       *) host_arch=UNKNOWN ;;
@@ -2200,7 +2208,7 @@ case "$host_arch" in
     arch='sparc'
     iproc='sparc'
     if test "$host_arch" = "sparc64" ; then
-      _vis='yes'
+      # _vis='yes'
       proc='ultrasparc'
       def_fast_64bit='#define HAVE_FAST_64BIT 1'
     elif sunos ; then
@@ -2519,7 +2527,7 @@ cat > $TMPC << EOF
 int ff_extern;
 EOF
 cc_check -c || die "Symbol mangling check failed."
-sym=$($_nm -P -g $TMPEXE)
+sym=$($_nm -g $TMPEXE | grep ff_extern | cut -d ' ' -f 3)
 extern_prefix=${sym%%ff_extern*}
 def_extern_asm="#define EXTERN_ASM $extern_prefix"
 def_extern_prefix="#define EXTERN_PREFIX \"$extern_prefix\""
@@ -2578,7 +2586,7 @@ elif test -z "$CFLAGS" ; then
   elif test "$cc_vendor" != "gnu" ; then
     CFLAGS="-O2 $_march $_mcpu $_pipe"
   else
-    CFLAGS="-O4 $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer"
+    CFLAGS="$_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer"
     WARNFLAGS="-Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls"
     extra_ldflags="$extra_ldflags -ffast-math"
   fi
@@ -2860,8 +2868,11 @@ echores "$ibm_asm"
 def_gnu_as='#define HAVE_GNU_AS 0'
 gnu_as=no
 echocheck "GNU assembler"
-inline_asm_check '".macro m n\n\\n:.int 0\n.endm\nm x"' &&
-  gnu_as=yes && def_gnu_as='#define HAVE_GNU_AS 1'
+# OpenBSD - some altivec stuff causes build failures, fix from kili
+if ! ppc; then
+	inline_asm_check '".macro m n\n\\n:.int 0\n.endm\nm x"' &&
+	  gnu_as=yes && def_gnu_as='#define HAVE_GNU_AS 1'
+fi
 echores "$gnu_as"
 
 fi
@@ -3480,7 +3491,8 @@ if test "$_memalign" = yes ; then
 else
   def_memalign='#define HAVE_MEMALIGN 0'
   def_map_memalign='#define memalign(a, b) malloc(b)'
-  darwin || def_memalign_hack='#define CONFIG_MEMALIGN_HACK 1'
+  # OpenBSD - prevent CONFIG_MEMALIGN_HACK which causes exit crash
+  #darwin || def_memalign_hack='#define CONFIG_MEMALIGN_HACK 1'
 fi
 echores "$_memalign"
 
@@ -3585,7 +3597,7 @@ int main(void) { pthread_t tid; return pthread_create(
 EOF
 _pthreads=no
 if ! hpux ; then
-  for _ld_tmp in "-lpthreadGC2" "" "-lpthread" "-pthread" ; do
+  for _ld_tmp in "-lpthreadGC2" "" "-pthread" "-lpthread" ; do
     # for crosscompilation, we cannot execute the program, be happy if we can link statically
     cc_check $THREAD_CFLAGS $_ld_tmp && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && break
   done
@@ -4661,6 +4673,8 @@ if test "$_aa" = yes ; then
   def_aa='#define CONFIG_AA 1'
   if cygwin ; then
     libs_mplayer="$libs_mplayer $(aalib-config --libs | cut -d " " -f 2,5,6)"
+  else
+    libs_mplayer="$libs_mplayer $(aalib-config --libs)"
   fi
   vomodules="aa $vomodules"
 else
@@ -4846,7 +4860,7 @@ fi
 echores "$_png"
 if test "$_png" = yes ; then
   def_png='#define CONFIG_PNG 1'
-  extra_ldflags="$extra_ldflags -lpng -lz"
+  extra_ldflags="$extra_ldflags -lpng -lz -lm"
 else
   def_png='#undef CONFIG_PNG'
 fi
@@ -4854,12 +4868,12 @@ fi
 echocheck "MNG support"
 if test "$_mng" = auto ; then
   _mng=no
-  return_statement_check libmng.h 'const char * p_ver = mng_version_text()' '!p_ver || p_ver[0] == 0' -lmng -lz $_ld_lm && _mng=yes
+  return_statement_check libmng.h 'const char * p_ver = mng_version_text()' '!p_ver || p_ver[0] == 0' -llcms -ljpeg -lmng -lz $_ld_lm && _mng=yes
 fi
 echores "$_mng"
 if test "$_mng" = yes ; then
   def_mng='#define CONFIG_MNG 1'
-  extra_ldflags="$extra_ldflags -lmng -lz"
+  extra_ldflags="$extra_ldflags -lmng -llcms -lz -ljpeg $_ld_m"
 else
   def_mng='#undef CONFIG_MNG'
 fi
@@ -5663,6 +5677,26 @@ fi
 echores "$_sunaudio"
 
 
+echocheck "sndio audio"
+if test "$_sndio" = auto ; then
+  cat > $TMPC << EOF
+#include <sndio.h>
+int main(void) { struct sio_par par; sio_initpar(&par); return 0; }
+EOF
+  _sndio=no
+  cc_check -lsndio && _sndio=yes
+fi
+if test "$_sndio" = yes ; then
+  def_sndio='#define CONFIG_SNDIO_AUDIO 1'
+  _aomodules="sndio $_aomodules"
+  extra_ldflags="$extra_ldflags -lsndio"
+else
+  def_sndio='#undef CONFIG_SNDIO_AUDIO'
+  _noaomodules="sndio $_noaomodules"
+fi
+echores "$_sndio"
+
+
 def_mlib='#define CONFIG_MLIB 0'
 if sunos; then
 echocheck "Sun mediaLib"
@@ -5832,8 +5866,9 @@ if test "$_dvdread_internal" = auto ; then
 elif test "$_dvdread" = auto ; then
   _dvdread=no
   if test "$_dl" = yes; then
-    _dvdreadcflags=$($_dvdreadconfig --cflags 2> /dev/null)
-    _dvdreadlibs=$($_dvdreadconfig --libs 2> /dev/null)
+# OpenBSD - we do not use dvdread-config, picked up anyway without
+#    _dvdreadcflags=$($_dvdreadconfig --cflags 2> /dev/null)
+#    _dvdreadlibs=$($_dvdreadconfig --libs 2> /dev/null)
     if header_check dvdread/dvd_reader.h $_dvdreadcflags $_dvdreadlibs $_ld_dl ; then
       _dvdread=yes
       extra_cflags="$extra_cflags $_dvdreadcflags"
@@ -6521,7 +6556,7 @@ echores "$_libmpeg2"
 echocheck "libdca support"
 if test "$_libdca" = auto ; then
   _libdca=no
-  for _ld_dca in -ldca -ldts ; do
+  for _ld_dca in -ldca; do
     statement_check_broken stdint.h dts.h 'dts_init(0)' $_ld_dca $_ld_lm &&
       extra_ldflags="$extra_ldflags $_ld_dca" && _libdca=yes && break
   done
@@ -7360,6 +7395,8 @@ if test "$_tv_v4l2" = auto ; then
   _tv_v4l2=no
   if test "$_tv" = yes && linux ; then
     header_check_broken sys/time.h linux/videodev2.h && _tv_v4l2=yes
+  elif test "$_tv" = yes && openbsd ; then
+    header_check sys/videoio.h && _tv_v4l2=yes
   fi
 fi
 if test "$_tv_v4l2" = yes ; then
@@ -8069,6 +8106,7 @@ SPEEX = $_speex
 STREAM_CACHE = $_stream_cache
 SGIAUDIO = $_sgiaudio
 SUNAUDIO = $_sunaudio
+SNDIO = $_sndio
 SVGA = $_svga
 TDFXFB = $_tdfxfb
 TDFXVID = $_tdfxvid
@@ -8445,6 +8483,7 @@ $def_ossaudio_devmixer
 $def_pulse
 $def_sgiaudio
 $def_sunaudio
+$def_sndio
 $def_win32waveout
 
 $def_ladspa
