summaryrefslogtreecommitdiff
path: root/src/drivers/Posix/Fl_Posix_System_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-10-30 17:25:49 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-10-30 17:25:49 +0100
commit2f64c6a86194db91be2ca873036b683f8f5b8739 (patch)
treeb550a610346859721e378fb602fbeec91c80d4da /src/drivers/Posix/Fl_Posix_System_Driver.cxx
parentffcf8bd0b78255ad7ad3a62a5826c1fa6096cd5e (diff)
Concentrate source code that supports Darwin + XQuartz + fink as test platform
Diffstat (limited to 'src/drivers/Posix/Fl_Posix_System_Driver.cxx')
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.cxx35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx
index c2576b268..6cf7bef55 100644
--- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx
+++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx
@@ -47,14 +47,43 @@
#endif /* !S_ISDIR */
+static void* double_dlopen(const char *filename1)
+{
+ void *ptr = ::dlopen(filename1, RTLD_LAZY | RTLD_GLOBAL);
+ if (!ptr) {
+ char filename2[FL_PATH_MAX];
+ sprintf(filename2, "%s.0", filename1);
+ ptr = dlopen(filename2, RTLD_LAZY | RTLD_GLOBAL);
+ }
+ return ptr;
+}
void *Fl_Posix_System_Driver::dlopen(const char *filename)
{
+ void *ptr = NULL;
#if HAVE_DLSYM
- return ::dlopen(filename, RTLD_LAZY);
-#endif
- return NULL;
+ ptr = double_dlopen(filename);
+# ifdef __APPLE_CC__ // allows testing on Darwin + XQuartz + fink
+ if (!ptr) {
+ char *f_dylib = strdup(filename);
+ strcpy(strrchr(f_dylib, '.'), ".dylib");
+ char path[FL_PATH_MAX];
+ sprintf(path, "/sw/lib/%s", f_dylib);
+ ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
+ if (!ptr) {
+ sprintf(path, "/opt/sw/lib/%s", f_dylib);
+ ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
+ }
+ if (!ptr) {
+ sprintf(path, "/opt/X11/lib/%s", f_dylib);
+ ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
+ }
+ free(f_dylib);
+ }
+# endif // __APPLE_CC__
+#endif // HAVE_DLSYM
+ return ptr;
}
int Fl_Posix_System_Driver::file_type(const char *filename)