$NetBSD: patch-aa,v 1.27 2011/07/09 15:51:52 jmcneill Exp $

--- configure.orig	2010-09-13 03:12:07.000000000 +0000
+++ configure
@@ -1471,6 +1471,12 @@ if test -z "$_target" ; then
    powerpc) # Darwin returns 'powerpc'
      host_arch=ppc
      ;;
+   mipseb|mipsel) # NetBSD
+     host_arch=mips
+     ;;
+   sh3eb|sh3el) # NetBSD
+     host_arch=sh
+     ;;
    *) # uname -p on Linux returns 'unknown' for the processor type,
       # OpenBSD returns 'Intel Pentium/MMX ("Genuine Intel" 586-class)'
 
@@ -1488,7 +1494,8 @@ if test -z "$_target" ; then
       sparc64) host_arch=sparc64 ;;
       parisc*|hppa*|9000*) host_arch=hppa ;;
       arm*|zaurus|cats) host_arch=arm ;;
-      sh3|sh4|sh4a) host_arch=sh ;;
+      sh3) host_arch=sh ;;
+      sh4|sh4a) host_arch=sh4 ;;
       s390) host_arch=s390 ;;
       s390x) host_arch=s390x ;;
       *mips*) host_arch=mips ;;
@@ -1645,7 +1652,7 @@ else
       cc_name=$cc_name_tmp
       echocheck "$_cc version"
       cc_vendor=gnu
-      cc_version=$($_cc -dumpversion 2>&1)
+      cc_version=$( ( $_cc -dumpversion | sed -e 's/-nb[0-9]//' ) 2>&1 )
       case $cc_version in
         2.96*)
           cc_fail=yes
@@ -1763,7 +1770,7 @@ if x86 ; then
   # gather more CPU information
   pname=$($_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -n 1)
   pvendor=$($_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2  | cut -d ' ' -f 2 | head -n 1)
-  pfamily=$($_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1)
+  pfamily=$($_cpuinfo | grep -i 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1)
   pmodel=$($_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1)
   pstepping=$($_cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1)
 
@@ -2238,7 +2245,12 @@ case "$host_arch" in
     test $_fast_clz = "auto" && _fast_clz=yes
     ;;
 
-  sh|sh4)
+  sh)
+    arch='sh'
+    iproc='sh'
+    ;;
+
+  sh4)
     arch='sh4'
     iproc='sh4'
     ;;
@@ -3713,7 +3725,6 @@ test "$_w32threads" = yes && def_threads
 echores "$_w32threads"
 
 echocheck "rpath"
-netbsd &&_rpath=yes
 if test "$_rpath" = yes ; then
   for I in $(echo $extra_ldflags | sed 's/-L//g') ; do
     tmp="$tmp $(echo $I | sed 's/.*/ -L& -Wl,-R&/')"
@@ -3978,7 +3989,6 @@ echores "$_vsscanf"
 
 echocheck "swab()"
 cat > $TMPC << EOF
-#define _XOPEN_SOURCE 600
 #include <unistd.h>
 int main(void) { swab(0, 0, 0); return 0; }
 EOF
@@ -4488,7 +4498,11 @@ EOF
            -L/usr/X11/lib -L/usr/lib32 -L/usr/openwin/lib -L/usr/local/lib64 -L/usr/X11R6/lib64 \
            -L/usr/lib ; do
     if netbsd; then
-      _ld_tmp="$I -lXext -lX11 $_ld_pthread -Wl,-R$(echo $I | sed s/^-L//)"
+      if test -n "$I" ; then
+        _ld_tmp="$I -lXext -lX11 $_ld_pthread -Wl,-R$(echo $I | sed s/^-L//)"
+      else
+        _ld_tmp="-lXext -lX11 $_ld_pthread"
+      fi
     else
       _ld_tmp="$I -lXext -lX11 $_ld_pthread"
     fi
@@ -5016,7 +5016,6 @@ EOF
       extra_cflags="$extra_cflags $_inc_tmp" && break
   done
 fi
-echores "$_dvb"
 if test "$_dvb" = yes ; then
   _dvbin=yes
   inputmodules="dvb $inputmodules"
@@ -5025,14 +5024,28 @@ if test "$_dvb" = yes ; then
   aomodules="mpegpes(dvb) $aomodules"
   vomodules="mpegpes(dvb) $vomodules"
 else
-  _dvbin=no
-  noinputmodules="dvb $noinputmodules"
-  def_dvb='#undef CONFIG_DVB'
-  def_dvbin='#undef CONFIG_DVBIN '
-  aomodules="mpegpes(file) $aomodules"
-  vomodules="mpegpes(file) $vomodules"
+  cat >$TMPC <<EOF
+#include <dev/dtv/dtvio.h>
+int main(void) {return 0;}
+EOF
+  cc_check && _dvb=yes
+  if test "$_dvb" = yes ; then
+    _dvbin=yes
+    inputmodules="dvb $inputmodules"
+    def_dvb='#undef CONFIG_DVB'
+    def_dvbin='#define CONFIG_DVBIN 1'
+    aomodules="mpegpes(file) $aomodules"
+    vomodules="mpegpes(file) $vomodules"
+  else
+    _dvbin=no
+    noinputmodules="dvb $noinputmodules"
+    def_dvb='#undef CONFIG_DVB'
+    def_dvbin='#undef CONFIG_DVBIN '
+    aomodules="mpegpes(file) $aomodules"
+    vomodules="mpegpes(file) $vomodules"
+  fi
 fi
-
+echores "$_dvb"
 
 if darwin; then
 
@@ -5623,8 +5637,13 @@ if test "$_ivtv" = auto ; then
   cat > $TMPC << EOF
 #include <stdlib.h>
 #include <inttypes.h>
++#ifdef __linux__
 #include <linux/types.h>
 #include <linux/videodev2.h>
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#include <sys/types.h>
+#include <sys/videoio.h>
+#endif
 #include <linux/ivtv.h>
 #include <sys/ioctl.h>
 int main(void) {
@@ -8057,7 +8076,7 @@ echores "$_tv_v4l1"
 echocheck "Video 4 Linux 2 TV interface"
 if test "$_tv_v4l2" = auto ; then
   _tv_v4l2=no
-  if test "$_tv" = yes && linux ; then
+  if test "$_tv" = yes && (linux || netbsd || openbsd) ; then
     header_check linux/videodev2.h && _tv_v4l2=yes
   fi
 fi
