Avoid conflicts with multiple versions of udev by first trying the library that is linked with the executable, if any, and then picking the one that is in the build environment.
authorSam Lantinga <slouken@libsdl.org>
Tue, 29 Nov 2016 05:34:20 -0800
changeset 106601ae4e8001b73
parent 10659 419028eda223
child 10661 74b42fb2a9e4
Avoid conflicts with multiple versions of udev by first trying the library that is linked with the executable, if any, and then picking the one that is in the build environment.
This fixes joystick detection for applications using the Steam Linux Runtime
configure
configure.in
include/SDL_config.h.in
src/core/linux/SDL_dbus.c
src/core/linux/SDL_ibus.c
src/core/linux/SDL_ime.c
src/core/linux/SDL_udev.c
     1.1 --- a/configure	Tue Nov 29 05:04:42 2016 -0800
     1.2 +++ b/configure	Tue Nov 29 05:34:20 2016 -0800
     1.3 @@ -21578,6 +21578,16 @@
     1.4  
     1.5  $as_echo "#define HAVE_LIBUDEV_H 1" >>confdefs.h
     1.6  
     1.7 +
     1.8 +            udev_lib=`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`
     1.9 +            if test x$udev_lib != x; then
    1.10 +                echo "-- dynamic udev -> $udev_lib"
    1.11 +
    1.12 +cat >>confdefs.h <<_ACEOF
    1.13 +#define SDL_UDEV_DYNAMIC "$udev_lib"
    1.14 +_ACEOF
    1.15 +
    1.16 +            fi
    1.17          fi
    1.18      fi
    1.19  }
     2.1 --- a/configure.in	Tue Nov 29 05:04:42 2016 -0800
     2.2 +++ b/configure.in	Tue Nov 29 05:34:20 2016 -0800
     2.3 @@ -2231,6 +2231,12 @@
     2.4                          have_libudev_h_hdr=no)
     2.5          if test x$have_libudev_h_hdr = xyes; then
     2.6              AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
     2.7 +
     2.8 +            udev_lib=[`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
     2.9 +            if test x$udev_lib != x; then
    2.10 +                echo "-- dynamic udev -> $udev_lib"
    2.11 +                AC_DEFINE_UNQUOTED(SDL_UDEV_DYNAMIC, "$udev_lib", [ ])
    2.12 +            fi
    2.13          fi
    2.14      fi
    2.15  }
     3.1 --- a/include/SDL_config.h.in	Tue Nov 29 05:04:42 2016 -0800
     3.2 +++ b/include/SDL_config.h.in	Tue Nov 29 05:34:20 2016 -0800
     3.3 @@ -360,4 +360,7 @@
     3.4  /* Enable ime support */
     3.5  #undef SDL_USE_IME
     3.6  
     3.7 +/* Enable dynamic udev support */
     3.8 +#undef SDL_UDEV_DYNAMIC
     3.9 +
    3.10  #endif /* SDL_config_h_ */
     4.1 --- a/src/core/linux/SDL_dbus.c	Tue Nov 29 05:04:42 2016 -0800
     4.2 +++ b/src/core/linux/SDL_dbus.c	Tue Nov 29 05:34:20 2016 -0800
     4.3 @@ -237,3 +237,5 @@
     4.4      }
     4.5  }
     4.6  #endif
     4.7 +
     4.8 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/core/linux/SDL_ibus.c	Tue Nov 29 05:04:42 2016 -0800
     5.2 +++ b/src/core/linux/SDL_ibus.c	Tue Nov 29 05:34:20 2016 -0800
     5.3 @@ -680,3 +680,5 @@
     5.4  }
     5.5  
     5.6  #endif
     5.7 +
     5.8 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/core/linux/SDL_ime.c	Tue Nov 29 05:04:42 2016 -0800
     6.2 +++ b/src/core/linux/SDL_ime.c	Tue Nov 29 05:34:20 2016 -0800
     6.3 @@ -136,3 +136,5 @@
     6.4      if (SDL_IME_PumpEvents_Real)
     6.5          SDL_IME_PumpEvents_Real();
     6.6  }
     6.7 +
     6.8 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/core/linux/SDL_udev.c	Tue Nov 29 05:04:42 2016 -0800
     7.2 +++ b/src/core/linux/SDL_udev.c	Tue Nov 29 05:34:20 2016 -0800
     7.3 @@ -33,7 +33,14 @@
     7.4  
     7.5  #include "SDL.h"
     7.6  
     7.7 -static const char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
     7.8 +static const char *SDL_UDEV_LIBS[] = {
     7.9 +#ifdef SDL_UDEV_DYNAMIC
    7.10 +	SDL_UDEV_DYNAMIC
    7.11 +#else
    7.12 +	"libudev.so.1",
    7.13 +	"libudev.so.0"
    7.14 +#endif
    7.15 +};
    7.16  
    7.17  #define _THIS SDL_UDEV_PrivateData *_this
    7.18  static _THIS = NULL;
    7.19 @@ -252,8 +259,12 @@
    7.20      if (_this == NULL) {
    7.21          return SDL_SetError("UDEV not initialized");
    7.22      }
    7.23 -    
    7.24 -   
    7.25 + 
    7.26 +    /* See if there is a udev library already loaded */
    7.27 +    if (SDL_UDEV_load_syms() == 0) {
    7.28 +        return 0;
    7.29 +    }
    7.30 +
    7.31      if (_this->udev_handle == NULL) {
    7.32          for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
    7.33              _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
    7.34 @@ -536,3 +547,5 @@
    7.35  
    7.36  
    7.37  #endif /* SDL_USE_LIBUDEV */
    7.38 +
    7.39 +/* vi: set ts=4 sw=4 expandtab: */