$NetBSD: patch-ao,v 1.2 2002/03/23 02:36:48 wiz Exp $

--- configure.orig	Sun Sep  9 10:55:54 2001
+++ configure
@@ -20,7 +20,7 @@
 ac_help="$ac_help
   --enable-debug	  enable debug flags (default: no)"
 ac_help="$ac_help
-  --enable-rtaudio={oss|alsa|esd} enable real-time audio (default: oss)"
+  --enable-rtaudio={oss|alsa|esd|netbsd} enable real-time audio (default: oss)"
 ac_help="$ac_help
   --enable-OSC-opcodes	  enable OSC opcodes (default: no)
                           (requires the OSC library - read new-src/README.OSC)"
@@ -969,6 +969,96 @@
 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
+echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+echo "configure:974: checking whether byte ordering is bigendian" >&5
+if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_c_bigendian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+cat > conftest.$ac_ext <<EOF
+#line 981 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/param.h>
+int main() {
+
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:992: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  # It does; now see whether it defined to BIG_ENDIAN or not.
+cat > conftest.$ac_ext <<EOF
+#line 996 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/param.h>
+int main() {
+
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1007: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_c_bigendian=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_c_bigendian=no
+fi
+rm -f conftest*
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+if test $ac_cv_c_bigendian = unknown; then
+if test "$cross_compiling" = yes; then
+    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1027 "configure"
+#include "confdefs.h"
+main () {
+  /* Are we little or big endian?  From Harbison&Steele.  */
+  union
+  {
+    long l;
+    char c[sizeof (long)];
+  } u;
+  u.l = 1;
+  exit (u.c[sizeof (long) - 1] == 1);
+}
+EOF
+if { (eval echo configure:1040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_c_bigendian=no
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_c_bigendian=yes
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_c_bigendian" 1>&6
+if test $ac_cv_c_bigendian = yes; then
+  cat >> confdefs.h <<\EOF
+#define WORDS_BIGENDIAN 1
+EOF
+
+fi
+
 
 
 # Find a good install program.  We prefer a C program (faster),
@@ -1213,7 +1303,7 @@
   fi
 fi
 
-for ac_prog in gawk mawk nawk awk
+for ac_prog in mawk gawk nawk awk
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -2451,6 +2541,7 @@
     oss) ;;
     alsa) ;;
 	esd) ;;
+	netbsd) ;;
     *) { echo "configure: error: bad value ${enable_rtaudio} for the real-time audio option" 1>&2; exit 1; } ;;
    esac
 else
@@ -2482,6 +2573,14 @@
 	DEFS="${DEFS} -DESDRTAUDIO"
 fi
 
+if test "${enable_rtaudio}" = "netbsd"
+then
+	echo "enable the netbsd audio driver..." 1>&6
+echo "configure:2580: enable the netbsd audio driver..." >&5
+	RTAUDIO_DRIVER=\${LINUX_DISTRIB_DIR}/rtNetBSD.c
+	DEFS="${DEFS} -DNETBSDRTAUDIO"
+fi
+
 # Check whether --enable-OSC_opcodes or --disable-OSC_opcodes was given.
 if test "${enable_OSC_opcodes+set}" = set; then
   enableval="$enable_OSC_opcodes"
@@ -3020,8 +3119,8 @@
 
 
 case $host in
-	*linux)
-		local_defines="-DRTAUDIO -DLINUX ${DEFS}"
+	*linux|*bsd)
+		local_defines="-DRTAUDIO -DLINUX -DBSD ${DEFS}"
 		;;
 	*)
 		;;
@@ -3249,6 +3348,7 @@
 s%@LD@%$LD%g
 s%@CSOUND_INSTALLATION_MODE@%$CSOUND_INSTALLATION_MODE%g
 s%@csound_float@%$csound_float%g
+s%@WORDS_BIGENDIAN@%$WORDS_BIGENDIAN%g
 
 CEOF
 EOF
