$OpenBSD: patch-configure,v 1.57 2010/11/08 21:25:44 edd Exp $
--- configure.orig	Thu Oct 21 10:35:56 2010
+++ configure	Sat Nov  6 13:41:02 2010
@@ -461,6 +461,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]
@@ -698,6 +699,7 @@ _xf86keysym=auto
 _mlib=no #broken, thus disabled
 _sgiaudio=auto
 _sunaudio=auto
+_sndio=auto
 _alsa=auto
 _fastmemcpy=yes
 hardcoded_tables=no
@@ -1126,6 +1128,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       ;;
@@ -1446,7 +1450,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 ;;
@@ -2157,7 +2161,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
@@ -2476,7 +2480,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\""
@@ -2535,7 +2539,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
@@ -2817,8 +2821,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
@@ -3436,7 +3443,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"
 
@@ -3543,7 +3551,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
@@ -4664,6 +4672,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
@@ -4873,14 +4883,14 @@ int main(void) {
   return !p_ver || p_ver[0] == 0;
 }
 EOF
-  if cc_check -lmng -lz $_ld_lm ; then
+  if cc_check -lmng -llcms -ljpeg -lz -lm $_ld_lm ; then
     _mng=yes
   fi
 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 -ljpeg -lz -lm"
 else
   def_mng='#undef CONFIG_MNG'
 fi
@@ -5691,6 +5701,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"
@@ -5860,8 +5890,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"
@@ -6347,7 +6378,7 @@ elif test "$_libvorbis" = yes ; then
   def_vorbis='#define CONFIG_OGGVORBIS 1'
   codecmodules="libvorbis $codecmodules"
   res_comment="libvorbis"
-  extra_ldflags="$extra_ldflags -lvorbis -logg"
+  extra_ldflags="$extra_ldflags -lvorbisenc -lvorbis -logg"
   libavencoders="$libavencoders LIBVORBIS_ENCODER"
 else
   _vorbis=no
@@ -6547,7 +6578,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
@@ -7448,6 +7479,8 @@ if test "$_tv_v4l2" = auto ; then
   _tv_v4l2=no
   if test "$_tv" = yes && linux ; then
     header_check 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
@@ -8158,6 +8191,7 @@ SPEEX = $_speex
 STREAM_CACHE = $_stream_cache
 SGIAUDIO = $_sgiaudio
 SUNAUDIO = $_sunaudio
+SNDIO = $_sndio
 SVGA = $_svga
 TDFXFB = $_tdfxfb
 TDFXVID = $_tdfxvid
@@ -8540,6 +8574,7 @@ $def_ossaudio_devmixer
 $def_pulse
 $def_sgiaudio
 $def_sunaudio
+$def_sndio
 $def_win32waveout
 
 $def_ladspa
