$OpenBSD: patch-configure,v 1.66 2013/01/21 16:23:05 brad Exp $
--- configure.orig	Sat Jan 19 01:18:49 2013
+++ configure	Sat Jan 19 23:35:10 2013
@@ -35,29 +35,32 @@
 #
 #############################################################################
 
-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
+# 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/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
-
 # Prevent locale nonsense from breaking basic text processing utilities
 export LC_ALL=C
 
@@ -538,6 +541,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]
@@ -783,6 +787,7 @@ _xf86keysym=auto
 _mlib=no #broken, thus disabled
 _sgiaudio=auto
 _sunaudio=auto
+_sndio=auto
 _alsa=auto
 _fastmemcpy=yes
 hardcoded_tables=no
@@ -1211,6 +1216,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       ;;
@@ -1527,7 +1534,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 ;;
@@ -2242,7 +2249,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
@@ -2561,7 +2568,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\""
@@ -2609,7 +2616,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"
     WARN_CFLAGS="-Werror-implicit-function-declaration"
     extra_ldflags="$extra_ldflags -ffast-math"
@@ -2879,8 +2886,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
@@ -3488,7 +3498,6 @@ echores "$_fast_inttypes"
 
 echocheck "malloc.h"
 _malloc=no
-header_check malloc.h && _malloc=yes
 if test "$_malloc" = yes ; then
   def_malloc_h='#define HAVE_MALLOC_H 1'
 else
@@ -3507,7 +3516,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"
 
@@ -4673,6 +4683,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
@@ -4852,13 +4864,13 @@ int main(void) {
   return strcmp(PNG_LIBPNG_VER_STRING, png_libpng_ver);
 }
 EOF
-    cc_check -lpng -lz && _png=yes
+    cc_check -lpng -lz -lm && _png=yes
   fi
 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
@@ -5602,6 +5614,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"
@@ -5718,7 +5750,15 @@ else
   default_dvd_device="/dev/dvd"
 fi
 
+if win32 || os2 || dragonfly || freebsd || openbsd || sunos || amigaos ; then
+  default_bluray_device=$default_cdrom_device
+elif darwin ; then
+  default_bluray_device="/dev/rdiskN"
+else
+  default_bluray_device="/dev/dvd"
+fi
 
+
 echocheck "VCD support"
 if test "$_vcd" = auto; then
   _vcd=no
@@ -5868,7 +5908,7 @@ echocheck "cdparanoia"
 if test "$_cdparanoia" = auto ; then
     _cdparanoia=no
     for inc_tmp in "" "-I/usr/include/cdda" "-I/usr/local/include/cdda" ; do
-      statement_check_broken cdda_interface.h cdda_paranoia.h 'paranoia_cachemodel_size(NULL, 0)' $inc_tmp -lcdda_interface -lcdda_paranoia &&
+      statement_check_broken cdda_interface.h cdda_paranoia.h 'paranoia_free(NULL)' $inc_tmp -lcdda_interface -lcdda_paranoia &&
         _cdparanoia=yes && extra_cflags="$extra_cflags $inc_tmp" && break
     done
 fi
@@ -7806,6 +7846,7 @@ echores "$_dvdnav"
 # XML documentation tests
 echocheck "XML catalogs"
 for try_catalog in \
+  ${LOCALBASE}/share/sgml/catalog \
   /etc/sgml/catalog \
   /usr/share/xml/docbook/*/catalog.xml \
   /opt/local/share/xml/docbook-xml/*/catalog.xml \
@@ -7833,6 +7874,7 @@ fi
 
 echocheck "XML chunked stylesheet"
 for try_chunk_xsl in \
+  ${LOCALBASE}/share/xsl/docbook/html/chunk.xsl \
   /usr/share/xml/docbook/*/html/chunk.xsl \
   /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl \
   /usr/share/sgml/docbook/yelp/docbook/html/chunk.xsl \
@@ -7858,6 +7900,7 @@ fi
 
 echocheck "XML monolithic stylesheet"
 for try_docbook_xsl in \
+  ${LOCALBASE}/share/xsl/docbook/html/docbook.xsl \
   /usr/share/xml/docbook/*/html/docbook.xsl \
   /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
   /usr/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
@@ -7911,6 +7954,7 @@ EOF
 echocheck "XML DTD"
 #FIXME: This should prefer higher version numbers, not the other way around ..
 for try_dtd in \
+  ${LOCALBASE}/share/xml/docbook/*/docbookx.dtd \
   /usr/share/xml/docbook/*/dtd/4*/docbookx.dtd \
   /usr/share/xml/docbook/*/docbookx.dtd \
   /usr/share/sgml/docbook/*/docbookx.dtd \
@@ -8179,6 +8223,7 @@ SPEEX = $_speex
 STREAM_CACHE = $_stream_cache
 SGIAUDIO = $_sgiaudio
 SUNAUDIO = $_sunaudio
+SNDIO = $_sndio
 SVGA = $_svga
 TDFXFB = $_tdfxfb
 TDFXVID = $_tdfxvid
@@ -8489,6 +8534,7 @@ $(ff_config_enable "$cpuexts_all" "$cpuexts" "#" "HAVE
 /* Blu-ray/DVD/VCD/CD */
 #define DEFAULT_CDROM_DEVICE "$default_cdrom_device"
 #define DEFAULT_DVD_DEVICE   "$default_dvd_device"
+#define DEFAULT_BLURAY_DEVICE   "$default_bluray_device"
 $def_bluray
 $def_bsdi_dvd
 $def_cddb
@@ -8575,6 +8621,7 @@ $def_ossaudio_devmixer
 $def_pulse
 $def_sgiaudio
 $def_sunaudio
+$def_sndio
 $def_win32waveout
 
 $def_ladspa
