diff --git a/CHANGELOG.md b/CHANGELOG.md index b83ad90..c832413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/GLUT.cabal b/GLUT.cabal index f280025..f370d6c 100644 --- a/GLUT.cabal +++ b/GLUT.cabal @@ -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 diff --git a/cbits/HsGLUT.c b/cbits/HsGLUT.c index 95d0e0f..198b188 100644 --- a/cbits/HsGLUT.c +++ b/cbits/HsGLUT.c @@ -48,12 +48,6 @@ hs_GLUT_getProcAddress(const char *name) #include #include -#ifdef __APPLE__ -#define FILENAME "/System/Library/Frameworks/GLUT.framework/GLUT" -#else -#define FILENAME "libglut.so" -#endif - void* hs_GLUT_getProcAddress(const char *name) { @@ -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;