Fix #20146:
[blender.git] / source / blender / imbuf / intern / gen_dynlibtiff.py
index 4dba5b13aa0e188d09d16dde3ae4529d8ec428f6..a81ef981357498d423b96102c274e2c2c7d82169 100755 (executable)
@@ -117,25 +117,71 @@ void libtiff_loadlibtiff(void)
        if (libtiff != NULL)  return;
 
        /* Try to find libtiff in a couple of standard places */
+#ifdef __APPLE__
+       /* OSX has version specific library */
+       //standard install location
+       libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.3.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.4.dylib");
+       if (libtiff != NULL)  return;
+       //inside the blender app package contents/resources
+       libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.3.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.4.dylib");
+       if (libtiff != NULL)  return;
+       //inside the blender app package contents/frameworks
+       libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.3.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.4.dylib");
+       if (libtiff != NULL)  return;
+       //along side the blender app package
+       libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.3.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.4.dylib");
+       if (libtiff != NULL)  return;
+       //inside the blender app package contents/MacOS
+       libtiff = PIL_dynlib_open("@executable_path/libtiff.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/libtiff.3.dylib");
+       if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("@executable_path/libtiff.4.dylib");
+       if (libtiff != NULL)  return;
+#else
        libtiff = PIL_dynlib_open("libtiff.so");
        if (libtiff != NULL)  return;
        libtiff = PIL_dynlib_open("libtiff.so.3");
        if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("libtiff.so.4");
+       if (libtiff != NULL)  return;
        libtiff = PIL_dynlib_open("libtiff.dll");
        if (libtiff != NULL)  return;
        libtiff = PIL_dynlib_open("/usr/lib/libtiff.so");
        if (libtiff != NULL)  return;
        libtiff = PIL_dynlib_open("/usr/lib/libtiff.so.3");
        if (libtiff != NULL)  return;
-       /* OSX has version specific library */
+       libtiff = PIL_dynlib_open("/usr/lib/libtiff.so.4");
+       if (libtiff != NULL)  return;
 #ifdef __x86_64__
+       libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so");
+       if (libtiff != NULL)  return;
        libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so.3");
        if (libtiff != NULL)  return;
+       libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so.4");
+       if (libtiff != NULL)  return;
 #endif
        libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.so");
        if (libtiff != NULL)  return;
        /* For solaris */
        libtiff = PIL_dynlib_open("/usr/openwin/lib/libtiff.so");
+#endif
 
 }
 
@@ -145,8 +191,11 @@ void *libtiff_findsymbol(char *name)
        assert(libtiff != NULL);
        symbol = PIL_dynlib_find_symbol(libtiff, name);
        if (symbol == NULL) {
-               printf("libtiff_findsymbol: error %s\\n",
-                       PIL_dynlib_get_error_as_string(libtiff));
+               char *err = PIL_dynlib_get_error_as_string(libtiff);
+
+               if (err) printf("libtiff_findsymbol: error %s\\n",err);
+               else printf("libtiff_findsymbol: error Unknown.\\n");
+
                libtiff = NULL;
                G.have_libtiff = (0);
                return NULL;