configure.in
changeset 381 bc1401311390
parent 378 6089cd59e3ca
child 382 74bdcae44bf5
     1.1 --- a/configure.in	Tue May 28 19:31:32 2002 +0000
     1.2 +++ b/configure.in	Tue May 28 20:01:29 2002 +0000
     1.3 @@ -1445,6 +1445,86 @@
     1.4      fi
     1.5  }
     1.6  
     1.7 +dnl Check for the usbhid(3) library on *BSD
     1.8 +CheckUSBHID()
     1.9 +{
    1.10 +    if test x$enable_joystick = xyes; then
    1.11 +        have_libusbhid=no
    1.12 +        have_libusb=no
    1.13 +        AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
    1.14 +        AC_CHECK_LIB(usb, hid_init, have_libusb=yes)
    1.15 +        if test x$have_libusbhid = xyes; then
    1.16 +            SYSTEM_LIBS="$SYSTEM_LIBS -lusbhid"
    1.17 +        fi
    1.18 +        if test x$have_libusb = xyes; then
    1.19 +            SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
    1.20 +        fi
    1.21 +
    1.22 +        AC_CHECK_HEADER(usbhid.h, have_usbhid_h=yes)
    1.23 +        AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
    1.24 +        AC_CHECK_HEADER(libusbhid.h, have_libusbhid_h=yes)
    1.25 +        if test x$have_usbhid_h = xyes; then
    1.26 +            CFLAGS="$CFLAGS -DHAVE_USBHID_H"
    1.27 +        fi
    1.28 +        if test x$have_libusb_h = xyes; then
    1.29 +            CFLAGS="$CFLAGS -DHAVE_LIBUSB_H"
    1.30 +        fi
    1.31 +        if test x$have_libusbhid_h = xyes; then
    1.32 +            CFLAGS="$CFLAGS -DHAVE_LIBUSBHID_H"
    1.33 +        fi
    1.34 +
    1.35 +        AC_MSG_CHECKING(for usbhid)
    1.36 +        have_usbhid=no
    1.37 +        AC_TRY_COMPILE([
    1.38 +          #include <dev/usb/usb.h>
    1.39 +          #include <dev/usb/usbhid.h>
    1.40 +          #if defined(HAVE_USBHID_H)
    1.41 +          #include <usbhid.h>
    1.42 +          #elif defined(HAVE_LIBUSB_H)
    1.43 +          #include <libusb.h>
    1.44 +          #elif defined(HAVE_LIBUSBHID_H)
    1.45 +          #include <libusbhid.h>
    1.46 +          #endif
    1.47 +        ],[
    1.48 +          struct report_desc *repdesc;
    1.49 +          struct usb_ctl_report *repbuf;
    1.50 +          enum hid_kind hidkind;
    1.51 +        ],[
    1.52 +        have_usbhid=yes
    1.53 +        ])
    1.54 +        AC_MSG_RESULT($have_usbhid)
    1.55 +
    1.56 +        if test x$have_usbhid = xyes; then
    1.57 +            AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
    1.58 +            have_usbhid_ucr_data=no
    1.59 +            AC_TRY_COMPILE([
    1.60 +              #include <dev/usb/usb.h>
    1.61 +              #include <dev/usb/usbhid.h>
    1.62 +              #include <stdio.h>
    1.63 +              #if defined(HAVE_USBHID_H)
    1.64 +              #include <usbhid.h>
    1.65 +              #elif defined(HAVE_LIBUSB_H)
    1.66 +              #include <libusb.h>
    1.67 +              #elif defined(HAVE_LIBUSBHID_H)
    1.68 +              #include <libusbhid.h>
    1.69 +              #endif
    1.70 +            ],[
    1.71 +              struct usb_ctl_report buf;
    1.72 +              if (buf.ucr_data) { }
    1.73 +            ],[
    1.74 +            have_usbhid_ucr_data=yes
    1.75 +            ])
    1.76 +            if test x$have_usbhid_ucr_data = xyes; then
    1.77 +                CFLAGS="$CFLAGS -DUSBHID_UCR_DATA"
    1.78 +            fi
    1.79 +            AC_MSG_RESULT($have_usbhid_ucr_data)
    1.80 +
    1.81 +            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
    1.82 +            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
    1.83 +        fi
    1.84 +    fi
    1.85 +}
    1.86 +
    1.87  case "$target" in
    1.88      *-*-linux*)
    1.89          ARCH=linux
    1.90 @@ -1598,6 +1678,7 @@
    1.91          CheckAAlib
    1.92          CheckOpenGL
    1.93          CheckPTHREAD
    1.94 +        CheckUSBHID
    1.95          # Set up files for the main() stub
    1.96          COPY_ARCH_SRC(src/main, linux, SDL_main.c)
    1.97          # Set up files for the audio library
    1.98 @@ -1607,12 +1688,6 @@
    1.99          #    AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
   1.100          #    AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
   1.101          #fi
   1.102 -        # Set up files for the joystick library
   1.103 -        if test x$enable_joystick = xyes; then
   1.104 -            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
   1.105 -            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
   1.106 -            SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
   1.107 -        fi
   1.108          # Set up files for the cdrom library
   1.109          if test x$enable_cdrom = xyes; then
   1.110              CDROM_SUBDIRS="$CDROM_SUBDIRS freebsd"
   1.111 @@ -1652,6 +1727,7 @@
   1.112          CheckAAlib
   1.113          CheckOpenGL
   1.114          CheckPTHREAD
   1.115 +        CheckUSBHID
   1.116          # Set up files for the main() stub
   1.117          COPY_ARCH_SRC(src/main, linux, SDL_main.c)
   1.118          # Set up files for the audio library
   1.119 @@ -1660,12 +1736,6 @@
   1.120              AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
   1.121              AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
   1.122          fi
   1.123 -        # Set up files for the joystick library
   1.124 -        if test x$enable_joystick = xyes; then
   1.125 -            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
   1.126 -            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
   1.127 -            SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
   1.128 -        fi
   1.129          # Set up files for the cdrom library
   1.130          if test x$enable_cdrom = xyes; then
   1.131              CDROM_SUBDIRS="$CDROM_SUBDIRS openbsd"
   1.132 @@ -1707,6 +1777,7 @@
   1.133          CheckAAlib
   1.134          CheckOpenGL
   1.135          CheckPTHREAD
   1.136 +        CheckUSBHID
   1.137          # Set up files for the main() stub
   1.138          COPY_ARCH_SRC(src/main, linux, SDL_main.c)
   1.139          # Set up files for the audio library
   1.140 @@ -1719,12 +1790,6 @@
   1.141          if test x$have_oss = xyes; then
   1.142              SYSTEM_LIBS="$SYSTEM_LIBS -lossaudio"
   1.143          fi
   1.144 -        # Set up files for the joystick library
   1.145 -        if test x$enable_joystick = xyes; then
   1.146 -            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
   1.147 -            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
   1.148 -            SYSTEM_LIBS="$SYSTEM_LIBS -lusbhid"
   1.149 -        fi
   1.150          # Set up files for the cdrom library
   1.151          if test x$enable_cdrom = xyes; then
   1.152              CDROM_SUBDIRS="$CDROM_SUBDIRS openbsd"