Check SDL_UDEV_DYNAMIC first, then SDL_UDEV_LIBS separately

This commit is contained in:
Ethan Lee 2017-10-10 20:22:15 -04:00
parent c0019b7f49
commit 84fb4893cf
1 changed files with 14 additions and 8 deletions
src/core/linux

View File

@ -36,14 +36,7 @@
#include "SDL_timer.h" #include "SDL_timer.h"
#include "../unix/SDL_poll.h" #include "../unix/SDL_poll.h"
static const char *SDL_UDEV_LIBS[] = { static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
#ifdef SDL_UDEV_DYNAMIC
SDL_UDEV_DYNAMIC
#else
"libudev.so.1",
"libudev.so.0"
#endif
};
#define _THIS SDL_UDEV_PrivateData *_this #define _THIS SDL_UDEV_PrivateData *_this
static _THIS = NULL; static _THIS = NULL;
@ -261,6 +254,19 @@ SDL_UDEV_LoadLibrary(void)
return 0; 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) { if (_this->udev_handle == NULL) {
for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
_this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);