From 84fb4893cf0a414bfc2e7228a5100a11120f34c2 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Tue, 10 Oct 2017 20:22:15 -0400 Subject: [PATCH] Check SDL_UDEV_DYNAMIC first, then SDL_UDEV_LIBS separately --- src/core/linux/SDL_udev.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 502490b70..37bc4224f 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -36,14 +36,7 @@ #include "SDL_timer.h" #include "../unix/SDL_poll.h" -static const char *SDL_UDEV_LIBS[] = { -#ifdef SDL_UDEV_DYNAMIC - SDL_UDEV_DYNAMIC -#else - "libudev.so.1", - "libudev.so.0" -#endif -}; +static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" }; #define _THIS SDL_UDEV_PrivateData *_this static _THIS = NULL; @@ -261,6 +254,19 @@ SDL_UDEV_LoadLibrary(void) return 0; } +#ifdef SDL_UDEV_DYNAMIC + /* Check for the build environment's libudev first */ + if (_this->udev_handle == NULL) { + _this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC); + if (_this->udev_handle != NULL) { + retval = SDL_UDEV_load_syms(); + if (retval < 0) { + SDL_UDEV_UnloadLibrary(); + } + } + } +#endif + if (_this->udev_handle == NULL) { for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);