$OpenBSD: patch-configure,v 1.56 2010/05/26 21:29:56 jakemsr Exp $
--- configure.orig	Thu Mar  4 14:46:44 2010
+++ configure	Mon Mar  8 21:09:42 2010
@@ -423,6 +423,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]
@@ -665,6 +666,7 @@ _xf86keysym=auto
 _mlib=no #broken, thus disabled
 _sgiaudio=auto
 _sunaudio=auto
+_sndio=auto
 _alsa=auto
 _fastmemcpy=yes
 hardcoded_tables=no
@@ -1098,6 +1100,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       ;;
@@ -1434,7 +1438,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 ;;
@@ -2456,7 +2460,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\""
@@ -3205,6 +3209,7 @@ if test "$_struct_sockaddr_storage" = auto; then
 #if HAVE_WINSOCK2_H
 #include <winsock2.h>
 #else
+#include <stdlib.h>
 #include <sys/socket.h>
 #endif
 int main(void) { struct sockaddr_storage sas; return 0; }
@@ -3613,7 +3618,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
@@ -4892,6 +4897,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
@@ -5188,14 +5195,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
@@ -5823,6 +5830,7 @@ fi
 if test "$_jack" = yes ; then
   def_jack='#define CONFIG_JACK 1'
   _aomodules="jack $_aomodules"
+  libs_mplayer="$libs_mplayer $(pkg-config --libs jack)"
 else
   _noaomodules="jack $_noaomodules"
 fi
@@ -5985,6 +5993,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"
@@ -6100,7 +6128,7 @@ elif dragonfly ; then
 elif freebsd ; then
   default_cdrom_device="/dev/acd0"
 elif openbsd ; then
-  default_cdrom_device="/dev/rcd0a"
+  default_cdrom_device="/dev/rcd0c"
 elif sunos ; then
   default_cdrom_device="/vol/dev/aliases/cdrom0"
   # Modern Solaris versions use HAL instead of the vold daemon, the volfs
@@ -6169,8 +6197,9 @@ elif test "$_dvdread" = auto ; then
 #include <dvdread/nav_read.h>
 int main(void) { return 0; }
 EOF
-    _dvdreadcflags=$($_dvdreadconfig --cflags)
-    _dvdreadlibs=$($_dvdreadconfig --libs)
+# OpenBSD - we do not use dvdread-config, picked up anyway without
+#    _dvdreadcflags=$($_dvdreadconfig --cflags)
+#    _dvdreadlibs=$($_dvdreadconfig --libs)
     if cc_check -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE \
       $_dvdreadcflags $_dvdreadlibs $_ld_dl ; then
       _dvdread=yes
@@ -6848,7 +6877,7 @@ if test "$_libdca" = auto ; then
 #include <dts.h>
 int main(void) { dts_init(0); return 0; }
 EOF
-  for _ld_dca in -ldca -ldts ; do
+  for _ld_dca in -ldca; do
     cc_check $_ld_dca $_ld_lm && extra_ldflags="$extra_ldflags $_ld_dca" \
       && _libdca=yes && break
   done
@@ -6898,7 +6927,7 @@ int main(void) { unsigned long x, y; faacEncOpen(48000
 EOF
   _faac=no
   for _ld_faac in "-lfaac" "-lfaac -lmp4v2 -lstdc++" ; do
-    cc_check -O4 $_ld_faac $_ld_lm && libs_mencoder="$libs_mencoder $_ld_faac" && _faac=yes && break
+    cc_check $_ld_faac $_ld_lm && libs_mencoder="$libs_mencoder $_ld_faac" && _faac=yes && break
   done
 fi
 if test "$_faac" = yes ; then
@@ -7899,6 +7928,15 @@ if test "$_tv_v4l2" = auto ; then
 int main(void) { return 0; }
 EOF
     cc_check && _tv_v4l2=yes
+  else
+    cat > $TMPC <<EOF
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/videoio.h>
+int main(void) { return 0; }
+EOF
+    cc_check && _tv_v4l2=yes
   fi
 fi
 if test "$_tv_v4l2" = yes ; then
@@ -8637,6 +8675,7 @@ SPEEX = $_speex
 STREAM_CACHE = $_stream_cache
 SGIAUDIO = $_sgiaudio
 SUNAUDIO = $_sunaudio
+SNDIO = $_sndio
 SVGA = $_svga
 TDFXFB = $_tdfxfb
 TDFXVID = $_tdfxvid
@@ -9026,6 +9065,7 @@ $def_ossaudio_devmixer
 $def_pulse
 $def_sgiaudio
 $def_sunaudio
+$def_sndio
 $def_win32waveout
 
 $def_ladspa
