$NetBSD: patch-am,v 1.12 2003/09/04 09:57:43 wiz Exp $

--- configure.orig	Sat Aug 30 21:13:23 2003
+++ configure
@@ -3132,6 +3132,8 @@ rm -f conftest*
         echo "$ac_t""$have_oss" 1>&6
         if test x$have_oss = xyes; then
             CFLAGS="$CFLAGS -DOSS_SUPPORT"
+	    LDFLAGS="$LDFLAGS $LIBOSSAUDIO"
+	    SDL_LIBS="$SDL_LIBS $LIBOSSAUDIO"
             AUDIO_SUBDIRS="$AUDIO_SUBDIRS dsp"
             AUDIO_DRIVERS="$AUDIO_DRIVERS dsp/libaudio_dsp.la"
             AUDIO_SUBDIRS="$AUDIO_SUBDIRS dma"
@@ -3667,9 +3669,9 @@ fi
 
     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
         echo $ac_n "checking for NAS audio support""... $ac_c" 1>&6
-echo "configure:3671: checking for NAS audio support" >&5
+echo "configure:3673: checking for NAS audio support" >&5
         have_nas=no
-        if test -r /usr/X11R6/include/audio/audiolib.h; then
+        if true; then
             have_nas=yes
             CFLAGS="$CFLAGS -DNAS_SUPPORT"
             SYSTEM_LIBS="$SYSTEM_LIBS -laudio -lXt"
@@ -3826,7 +3828,7 @@ fi
                   NASMFLAGS="-f aoutb"
                   ;;
               *)
-                  NASMFLAGS="-f elf"
+                  test -n "$NASMFLAGS" || NASMFLAGS="-f elf"
                   ;;
             esac
             
@@ -5429,34 +5431,53 @@ else
 fi
 
     if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
-        echo $ac_n "checking for AAlib support""... $ac_c" 1>&6
-echo "configure:5434: checking for AAlib support" >&5
-        video_aalib=no
-        cat > conftest.$ac_ext <<EOF
-#line 5437 "configure"
-#include "confdefs.h"
-
-         #include <aalib.h>
-        
-int main() {
-
-        
-; return 0; }
-EOF
-if { (eval echo configure:5447: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  
-        video_aalib=yes
-        
+        # Extract the first word of "aalib-config", so it can be a program name with args.
+set dummy aalib-config; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:5438: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_AALIB_CONFIG'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  case "$AALIB_CONFIG" in
+  /*)
+  ac_cv_path_AALIB_CONFIG="$AALIB_CONFIG" # Let the user override the test with a path.
+  ;;
+  ?:/*)			 
+  ac_cv_path_AALIB_CONFIG="$AALIB_CONFIG" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_AALIB_CONFIG="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
 fi
-rm -f conftest*
+AALIB_CONFIG="$ac_cv_path_AALIB_CONFIG"
+if test -n "$AALIB_CONFIG"; then
+  echo "$ac_t""$AALIB_CONFIG" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+        echo $ac_n "checking for AAlib support""... $ac_c" 1>&6
+echo "configure:5471: checking for AAlib support" >&5
+        if test x$AALIB_CONFIG = x; then
+            video_aalib=no
+	else
+            AALIB_LIBS=`$AALIB_CONFIG --libs`
+            video_aalib=yes
+        fi
         echo "$ac_t""$video_aalib" 1>&6
         if test x$video_aalib = xyes; then
             CFLAGS="$CFLAGS -DENABLE_AALIB"
-            SYSTEM_LIBS="$SYSTEM_LIBS -laa"
+            SYSTEM_LIBS="$SYSTEM_LIBS $AALIB_LIBS"
 
             VIDEO_SUBDIRS="$VIDEO_SUBDIRS aalib"
             VIDEO_DRIVERS="$VIDEO_DRIVERS aalib/libvideo_aa.la"
@@ -5881,19 +5902,20 @@ else
 fi
 
     if test x$enable_threads = xyes -a x$enable_pth = xyes; then
-        # Extract the first word of "pth-config", so it can be a program name with args.
-set dummy pth-config; ac_word=$2
+        # Use the libpthread version of the pth library.
+        # Extract the first word of "pthread-config", so it can be a program name with args.
+set dummy pthread-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5888: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_PTH_CONFIG'+set}'`\" = set"; then
+echo "configure:5910: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_PTHREAD_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  case "$PTH_CONFIG" in
+  case "$PTHREAD_CONFIG" in
   /*)
-  ac_cv_path_PTH_CONFIG="$PTH_CONFIG" # Let the user override the test with a path.
+  ac_cv_path_PTHREAD_CONFIG="$PTHREAD_CONFIG" # Let the user override the test with a path.
   ;;
   ?:/*)			 
-  ac_cv_path_PTH_CONFIG="$PTH_CONFIG" # Let the user override the test with a dos path.
+  ac_cv_path_PTHREAD_CONFIG="$PTHREAD_CONFIG" # Let the user override the test with a dos path.
   ;;
   *)
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
@@ -5901,27 +5923,27 @@ else
   for ac_dir in $ac_dummy; do 
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
-      ac_cv_path_PTH_CONFIG="$ac_dir/$ac_word"
+      ac_cv_path_PTHREAD_CONFIG="$ac_dir/$ac_word"
       break
     fi
   done
   IFS="$ac_save_ifs"
-  test -z "$ac_cv_path_PTH_CONFIG" && ac_cv_path_PTH_CONFIG="no"
+  test -z "$ac_cv_path_PTHREAD_CONFIG" && ac_cv_path_PTHREAD_CONFIG="no"
   ;;
 esac
 fi
-PTH_CONFIG="$ac_cv_path_PTH_CONFIG"
-if test -n "$PTH_CONFIG"; then
-  echo "$ac_t""$PTH_CONFIG" 1>&6
+PTHREAD_CONFIG="$ac_cv_path_PTHREAD_CONFIG"
+if test -n "$PTHREAD_CONFIG"; then
+  echo "$ac_t""$PTHREAD_CONFIG" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
-        if test "$PTH_CONFIG" = "no"; then
+        if test "$PTHREAD_CONFIG" = "no"; then
             use_pth=no
         else
-            PTH_CFLAGS=`$PTH_CONFIG --cflags`
-            PTH_LIBS=`$PTH_CONFIG --libs --all`
+            PTH_CFLAGS=`$PTHREAD_CONFIG --cflags`
+            PTH_LIBS=`$PTHREAD_CONFIG --libs --all`
             SDL_CFLAGS="$SDL_CFLAGS $PTH_CFLAGS"
             SDL_LIBS="$SDL_LIBS $PTH_LIBS"
             CFLAGS="$CFLAGS -DENABLE_PTH"
@@ -5970,8 +5992,8 @@ fi
             pthread_lib="-pthread"
             ;;
         *-*-netbsd*)
-            pthread_cflags="-I/usr/pkg/include -D_REENTRANT"
-            pthread_lib="-L/usr/pkg/lib -lpthread -lsem"
+            pthread_cflags="-D_REENTRANT"
+            pthread_lib="-lpthread"
             ;;
         *-*-openbsd*)
             pthread_cflags="-D_REENTRANT"
@@ -7045,56 +7067,45 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
-        echo $ac_n "checking for hid_init in -lusb""... $ac_c" 1>&6
-echo "configure:7050: checking for hid_init in -lusb" >&5
-ac_lib_var=`echo usb'_'hid_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+        if test x$have_libusbhid = xyes; then
+            SYSTEM_LIBS="$SYSTEM_LIBS -lusbhid"
+
+            ac_safe=`echo "usbhid.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for usbhid.h""... $ac_c" 1>&6
+echo "configure:7076: checking for usbhid.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lusb  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 7058 "configure"
+  cat > conftest.$ac_ext <<EOF
+#line 7081 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char hid_init();
-
-int main() {
-hid_init()
-; return 0; }
+#include <usbhid.h>
 EOF
-if { (eval echo configure:7069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:7086: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_libusb=yes
+  have_usbhid_h=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
-        if test x$have_libusbhid = xyes; then
-            SYSTEM_LIBS="$SYSTEM_LIBS -lusbhid"
-        fi
-        if test x$have_libusb = xyes; then
-            SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
-        fi
-
-        ac_safe=`echo "usb.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for usb.h""... $ac_c" 1>&6
-echo "configure:7098: checking for usb.h" >&5
+            ac_safe=`echo "libusbhid.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for libusbhid.h""... $ac_c" 1>&6
+echo "configure:7109: checking for libusbhid.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7099,12 +7110,12 @@ if eval "test \"`echo '$''{'ac_cv_header
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7103 "configure"
+#line 7114 "configure"
 #include "confdefs.h"
-#include <usb.h>
+#include <libusbhid.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7108: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7119: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7120,47 +7131,64 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_usb_h=yes
+  have_libusbhid_h=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
-        ac_safe=`echo "usbhid.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for usbhid.h""... $ac_c" 1>&6
-echo "configure:7131: checking for usbhid.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+            if test x$have_usbhid_h = xyes; then
+                CFLAGS="$CFLAGS -DHAVE_USBHID_H"
+            fi
+            if test x$have_libusbhid_h = xyes; then
+                CFLAGS="$CFLAGS -DHAVE_LIBUSBHID_H"
+        fi
+	else
+            echo $ac_n "checking for hid_init in -lusb""... $ac_c" 1>&6
+echo "configure:7148: checking for hid_init in -lusb" >&5
+ac_lib_var=`echo usb'_'hid_init | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 7136 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-lusb  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 7156 "configure"
 #include "confdefs.h"
-#include <usbhid.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char hid_init();
+
+int main() {
+hid_init()
+; return 0; }
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
+if { (eval echo configure:7167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
-  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
+LIBS="$ac_save_LIBS"
+
 fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_usbhid_h=yes
+  have_libusb=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
-        ac_safe=`echo "libusb.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for libusb.h""... $ac_c" 1>&6
-echo "configure:7164: checking for libusb.h" >&5
+        if test x$have_libusb = xyes; then
+            SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
+
+        ac_safe=`echo "usb.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for usb.h""... $ac_c" 1>&6
+echo "configure:7192: checking for usb.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7165,12 +7193,12 @@ if eval "test \"`echo '$''{'ac_cv_header
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7169 "configure"
+#line 7197 "configure"
 #include "confdefs.h"
-#include <libusb.h>
+#include <usb.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7174: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7202: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7186,14 +7214,14 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_libusb_h=yes
+  have_usb_h=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
-        ac_safe=`echo "libusbhid.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for libusbhid.h""... $ac_c" 1>&6
-echo "configure:7197: checking for libusbhid.h" >&5
+        ac_safe=`echo "libusb.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for libusb.h""... $ac_c" 1>&6
+echo "configure:7225: checking for libusb.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7198,12 +7226,12 @@ if eval "test \"`echo '$''{'ac_cv_header
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7202 "configure"
+#line 7230 "configure"
 #include "confdefs.h"
-#include <libusbhid.h>
+#include <libusb.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7235: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7219,7 +7247,7 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_libusbhid_h=yes
+  have_libusb_h=yes
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -7227,14 +7255,10 @@ fi
         if test x$have_usb_h = xyes; then
             CFLAGS="$CFLAGS -DHAVE_USB_H"
         fi
-        if test x$have_usbhid_h = xyes; then
-            CFLAGS="$CFLAGS -DHAVE_USBHID_H"
-        fi
         if test x$have_libusb_h = xyes; then
             CFLAGS="$CFLAGS -DHAVE_LIBUSB_H"
         fi
-        if test x$have_libusbhid_h = xyes; then
-            CFLAGS="$CFLAGS -DHAVE_LIBUSBHID_H"
+            fi
         fi
 
         echo $ac_n "checking for usbhid""... $ac_c" 1>&6
@@ -7598,6 +7622,7 @@ __EOF__
         CheckESD
         CheckNAS
         CheckX11
+        CheckDGA
         CheckAAlib
         CheckOpenGL
         CheckPTHREAD
@@ -7616,9 +7641,9 @@ __EOF__
 
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
-            CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
-            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
-            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+            CFLAGS="$CFLAGS -DOPENBSD_AUDIO_SUPPORT"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS openbsd"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS openbsd/libaudio_openbsd.la"
         fi
         # Set up files for the cdrom library
         if test x$enable_cdrom = xyes; then
@@ -7627,9 +7652,6 @@ __EOF__
         fi
         # Set up files for the thread library
         if test x$enable_threads = xyes; then
-            if test x$use_pthreads = xyes; then
-                CFLAGS="$CFLAGS -D_POSIX_THREAD_SYSCALL_SOFT=1"
-            fi
             CopyUnixThreadSource
         fi
         # Set up files for the timer library
@@ -9105,7 +9127,7 @@ fi
 
 # Set runtime shared library paths as needed
 
-if test $ARCH = linux -o $ARCH = freebsd -o $ARCH = bsdi; then
+if test $ARCH = linux -o $ARCH = freebsd -o $ARCH = bsdi -o $ARCH = netbsd; then
   SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib"
 fi
 if test $ARCH = solaris; then
@@ -9504,7 +9526,8 @@ s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
 s%@PKG_CONFIG@%$PKG_CONFIG%g
 s%@DIRECTFB_CFLAGS@%$DIRECTFB_CFLAGS%g
 s%@DIRECTFB_LIBS@%$DIRECTFB_LIBS%g
-s%@PTH_CONFIG@%$PTH_CONFIG%g
+s%@AALIB_CONFIG@%$AALIB_CONFIG%g
+s%@PTHREAD_CONFIG@%$PTHREAD_CONFIG%g
 s%@ARCH@%$ARCH%g
 s%@TARGET_LINUX_TRUE@%$TARGET_LINUX_TRUE%g
 s%@TARGET_LINUX_FALSE@%$TARGET_LINUX_FALSE%g
