diff --git a/cffi_build.py.in b/cffi_build.py.in
index d650a6c8853355ce204d569bb4f9f4df62a76fae..5bd1ecbf6574487bd2f628115024ec4e7bf3275c 100644
--- a/cffi_build.py.in
+++ b/cffi_build.py.in
@@ -48,11 +48,22 @@ if {CL_ENABLE_GL}:
 
 ffi.set_source("pyopencl._cffi",
         """
-        #include <CL/cl.h>
+        #ifndef __APPLE__
+            #include <CL/cl.h>
 
-        #ifdef HAVE_GL
-        #include <GL/gl.h>
-        #include <CL/cl_gl.h>
+            #ifdef HAVE_GL
+            #include <GL/gl.h>
+            #include <CL/cl_gl.h>
+            #include <CL/cl_gl_ext.h>
+            #endif
+        #else
+            #include <OpenCL/opencl.h>
+
+            #ifdef HAVE_GL
+            #include <OpenGL/OpenGL.h>
+            #include <OpenCL/cl_gl.h>
+            #include <OpenCL/cl_gl_ext.h>
+            #endif
         #endif
 
         extern "C" {{