- path = getenv ("GLAZE_LIBGL");
- if (path == NULL) {
- fprintf (stderr, "GLAZE_LIBGL unset. Please set to path of real libGL.so under glaze.\n");
- exit (1);
+ libgl_path = getenv ("GLAZE_LIBGL");
+
+ if (libgl_path == NULL) {
+
+#if GLAZE_BITS == 32
+ libgl_path = getenv ("GLAZE_LIBGL_32_AUTO");
+#elif GLAZE_BITS == 64
+ libgl_path = getenv ("GLAZE_LIBGL_64_AUTO");
+#endif
+
+ if (libgl_path == NULL) {
+ fprintf (stderr,
+ "Error: Failed to detect OpenGL library.\n"
+ "Please set GLAZE_LIBGL to path of real libGL.so\n");
+ exit (1);
+ }
+
+ setenv ("GLAZE_LIBGL", libgl_path, 1);