configure: Windows and macOS now respect --enable-hidapi.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 08 Jul 2019 16:08:16 -0400
changeset 12931881705583f45
parent 12930 92e72926b7f5
child 12932 800524378309
configure: Windows and macOS now respect --enable-hidapi.

(and it defaults to "yes" on those platforms. Other places, which use libusb,
still default to no because they probably need root permissions to work.)
configure
configure.ac
     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
     2.1 --- a/configure.ac	Sun Jul 07 11:23:16 2019 -0700
     2.2 +++ b/configure.ac	Mon Jul 08 16:08:16 2019 -0400
     2.3 @@ -3199,26 +3199,50 @@
     2.4      # so we'll just use libusb when it's available.
     2.5      #
     2.6      # Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
     2.7 +    #
     2.8 +    #  On macOS and Windows, where you don't need libusb or root, we default to yes.
     2.9 +    skiplibusb=no
    2.10 +    case "$host" in
    2.11 +        *-*-cygwin* | *-*-mingw32* | *-*-darwin* )
    2.12 +            skiplibusb=yes
    2.13 +            ;;
    2.14 +    esac
    2.15 +
    2.16      AC_ARG_ENABLE(hidapi,
    2.17 -AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=no]]]),
    2.18 -                  , enable_hidapi=no)
    2.19 +AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]),
    2.20 +                  , enable_hidapi=maybe)
    2.21 +    hidapi_support=no
    2.22 +
    2.23 +    if test x$enable_hidapi = xmaybe; then
    2.24 +      enable_hidapi=$skiplibusb
    2.25 +    fi
    2.26 +
    2.27      if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
    2.28 -        PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
    2.29 -        hidapi_support=no
    2.30 -        save_CFLAGS="$CFLAGS"
    2.31 -        CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
    2.32 -        AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
    2.33 -        CFLAGS="$save_CFLAGS"
    2.34 -
    2.35 -        if test x$have_libusb_h = xyes; then
    2.36 +        if test x$skiplibusb = xyes; then
    2.37              hidapi_support=yes
    2.38 +        else
    2.39 +            PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
    2.40 +            save_CFLAGS="$CFLAGS"
    2.41 +            CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
    2.42 +            AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
    2.43 +            CFLAGS="$save_CFLAGS"
    2.44 +            if test x$have_libusb_h = xyes; then
    2.45 +                hidapi_support=yes
    2.46 +            fi
    2.47 +        fi
    2.48 +
    2.49 +        if test x$hidapi_support = xyes; then
    2.50              AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
    2.51              EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    2.52              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    2.53 -            SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    2.54 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    2.55 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    2.56 +
    2.57 +            if test x$skiplibusb = xno; then
    2.58 +                SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    2.59 +                EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    2.60 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    2.61 +            fi
    2.62          fi
    2.63 +
    2.64          AC_MSG_CHECKING(for hidapi support)
    2.65          AC_MSG_RESULT($hidapi_support)
    2.66      fi
    2.67 @@ -3521,6 +3545,7 @@
    2.68          CheckWINDOWSGLES
    2.69          CheckVulkan
    2.70          CheckDIRECTX
    2.71 +        CheckHIDAPI
    2.72  
    2.73          # Set up the core platform files
    2.74          SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
    2.75 @@ -3572,12 +3597,11 @@
    2.76              else
    2.77                  AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
    2.78              fi
    2.79 -            AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
    2.80              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
    2.81 -            SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    2.82 -            SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    2.83 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    2.84              have_joystick=yes
    2.85 +            if test x$hidapi_support = xyes; then
    2.86 +                SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    2.87 +            fi
    2.88          fi
    2.89          if test x$enable_haptic = xyes; then
    2.90              if test x$have_dinput = xyes -o x$have_xinput = xyes; then
    2.91 @@ -3803,6 +3827,7 @@
    2.92          CheckOpenGLX11
    2.93          CheckVulkan
    2.94          CheckPTHREAD
    2.95 +        CheckHIDAPI
    2.96  
    2.97          # Set up files for the audio library
    2.98          if test x$enable_audio = xyes; then
    2.99 @@ -3815,12 +3840,11 @@
   2.100          # Set up files for the joystick library
   2.101          if test x$enable_joystick = xyes; then
   2.102              AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
   2.103 -            AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
   2.104              SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
   2.105 -            SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
   2.106 -            SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   2.107 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
   2.108              have_joystick=yes
   2.109 +            if test x$hidapi_support = xyes; then
   2.110 +                SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   2.111 +            fi
   2.112          fi
   2.113          # Set up files for the haptic library
   2.114          if test x$enable_haptic = xyes; then