configure
changeset 12931 881705583f45
parent 12899 11cb5d784a3a
child 12974 0fef4b21fa1d
     1.1 --- a/configure	Sun Jul 07 11:23:16 2019 -0700
     1.2 +++ b/configure	Mon Jul 08 16:08:16 2019 -0400
     1.3 @@ -1675,7 +1675,7 @@
     1.4    --enable-wasapi         use the Windows WASAPI audio driver [[default=yes]]
     1.5    --enable-sdl-dlopen     use dlopen for shared object loading [[default=yes]]
     1.6    --enable-hidapi         use HIDAPI for low level joystick drivers
     1.7 -                          [[default=no]]
     1.8 +                          [[default=maybe]]
     1.9    --enable-clock_gettime  use clock_gettime() instead of gettimeofday() on
    1.10                            UNIX [[default=yes]]
    1.11    --enable-rpath          use an rpath when linking SDL [[default=yes]]
    1.12 @@ -24107,14 +24107,32 @@
    1.13      # so we'll just use libusb when it's available.
    1.14      #
    1.15      # Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
    1.16 +    #
    1.17 +    #  On macOS and Windows, where you don't need libusb or root, we default to yes.
    1.18 +    skiplibusb=no
    1.19 +    case "$host" in
    1.20 +        *-*-cygwin* | *-*-mingw32* | *-*-darwin* )
    1.21 +            skiplibusb=yes
    1.22 +            ;;
    1.23 +    esac
    1.24 +
    1.25      # Check whether --enable-hidapi was given.
    1.26  if test "${enable_hidapi+set}" = set; then :
    1.27    enableval=$enable_hidapi;
    1.28  else
    1.29 -  enable_hidapi=no
    1.30 -fi
    1.31 +  enable_hidapi=maybe
    1.32 +fi
    1.33 +
    1.34 +    hidapi_support=no
    1.35 +
    1.36 +    if test x$enable_hidapi = xmaybe; then
    1.37 +      enable_hidapi=$skiplibusb
    1.38 +    fi
    1.39  
    1.40      if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
    1.41 +        if test x$skiplibusb = xyes; then
    1.42 +            hidapi_support=yes
    1.43 +        else
    1.44  
    1.45  pkg_failed=no
    1.46  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB" >&5
    1.47 @@ -24184,28 +24202,34 @@
    1.48  $as_echo "yes" >&6; }
    1.49  	have_libusb=yes
    1.50  fi
    1.51 -        hidapi_support=no
    1.52 -        save_CFLAGS="$CFLAGS"
    1.53 -        CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
    1.54 -        ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
    1.55 +            save_CFLAGS="$CFLAGS"
    1.56 +            CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
    1.57 +            ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
    1.58  if test "x$ac_cv_header_libusb_h" = xyes; then :
    1.59    have_libusb_h=yes
    1.60  fi
    1.61  
    1.62  
    1.63 -        CFLAGS="$save_CFLAGS"
    1.64 -
    1.65 -        if test x$have_libusb_h = xyes; then
    1.66 -            hidapi_support=yes
    1.67 +            CFLAGS="$save_CFLAGS"
    1.68 +            if test x$have_libusb_h = xyes; then
    1.69 +                hidapi_support=yes
    1.70 +            fi
    1.71 +        fi
    1.72 +
    1.73 +        if test x$hidapi_support = xyes; then
    1.74  
    1.75  $as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
    1.76  
    1.77              EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    1.78              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    1.79 -            SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.80 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    1.81 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.82 -        fi
    1.83 +
    1.84 +            if test x$skiplibusb = xno; then
    1.85 +                SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.86 +                EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    1.87 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.88 +            fi
    1.89 +        fi
    1.90 +
    1.91          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hidapi support" >&5
    1.92  $as_echo_n "checking for hidapi support... " >&6; }
    1.93          { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hidapi_support" >&5
    1.94 @@ -24632,6 +24656,7 @@
    1.95          CheckWINDOWSGLES
    1.96          CheckVulkan
    1.97          CheckDIRECTX
    1.98 +        CheckHIDAPI
    1.99  
   1.100          # Set up the core platform files
   1.101          SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
   1.102 @@ -24705,14 +24730,11 @@
   1.103  $as_echo "#define SDL_JOYSTICK_WINMM 1" >>confdefs.h
   1.104  
   1.105              fi
   1.106 -
   1.107 -$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
   1.108 -
   1.109              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
   1.110 -            SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
   1.111 -            SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
   1.112 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
   1.113              have_joystick=yes
   1.114 +            if test x$hidapi_support = xyes; then
   1.115 +                SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
   1.116 +            fi
   1.117          fi
   1.118          if test x$enable_haptic = xyes; then
   1.119              if test x$have_dinput = xyes -o x$have_xinput = xyes; then
   1.120 @@ -25036,6 +25058,7 @@
   1.121          CheckOpenGLX11
   1.122          CheckVulkan
   1.123          CheckPTHREAD
   1.124 +        CheckHIDAPI
   1.125  
   1.126          # Set up files for the audio library
   1.127          if test x$enable_audio = xyes; then
   1.128 @@ -25052,14 +25075,11 @@
   1.129  
   1.130  $as_echo "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h
   1.131  
   1.132 -
   1.133 -$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
   1.134 -
   1.135              SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
   1.136 -            SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
   1.137 -            SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   1.138 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
   1.139              have_joystick=yes
   1.140 +            if test x$hidapi_support = xyes; then
   1.141 +                SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   1.142 +            fi
   1.143          fi
   1.144          # Set up files for the haptic library
   1.145          if test x$enable_haptic = xyes; then