Skip to content

Commit

Permalink
Mac OS X: Serach public frameworks first, then system frameworks.
Browse files Browse the repository at this point in the history
  • Loading branch information
svenpanne committed May 12, 2016
1 parent e3f9bd2 commit a4a3924
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.7.0.10
--------
* Mac OS X: Search public frameworks first, then system frameworks.

2.7.0.9
--------
* The GLUT package compiles without any additional library/framework now.
Expand Down
2 changes: 1 addition & 1 deletion GLUT.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: GLUT
version: 2.7.0.9
version: 2.7.0.10
synopsis: A binding for the OpenGL Utility Toolkit
description:
A Haskell binding for the OpenGL Utility Toolkit, a window system independent
Expand Down
19 changes: 12 additions & 7 deletions cbits/HsGLUT.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ hs_GLUT_getProcAddress(const char *name)
#include <stdlib.h>
#include <dlfcn.h>

#ifdef __APPLE__
#define FILENAME "/System/Library/Frameworks/GLUT.framework/GLUT"
#else
#define FILENAME "libglut.so"
#endif

void*
hs_GLUT_getProcAddress(const char *name)
{
Expand All @@ -62,7 +56,18 @@ hs_GLUT_getProcAddress(const char *name)

if (firstTime) {
firstTime = 0;
handle = dlopen(FILENAME, RTLD_LAZY | RTLD_GLOBAL);

#ifdef __APPLE__
/* Try public framework path first. */
handle = dlopen("/Library/Frameworks/GLUT.framework/GLUT", RTLD_LAZY | RTLD_GLOBAL);

/* If the public path failed, try the system framework path. */
if (!handle) {
handle = dlopen("/System/Library/Frameworks/GLUT.framework/GLUT", RTLD_LAZY | RTLD_GLOBAL);
}
#else
handle = dlopen("libglut.so", RTLD_LAZY | RTLD_GLOBAL);
#endif
}

return handle ? dlsym(handle, name) : NULL;
Expand Down

0 comments on commit a4a3924

Please sign in to comment.