From 8914e0a116d9a1ae14dbae798ef5692436d2d963 Mon Sep 17 00:00:00 2001
From: Maneesh Gupta <maneesh.gupta@amd.com>
Date: Fri, 6 Feb 2015 14:23:37 +0530
Subject: [PATCH 3/3] Update configure since OpenCL compilation does not need
 cl.h anymore

---
 configure | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 0c209c5..eaf09fc 100755
--- a/configure
+++ b/configure
@@ -266,7 +266,7 @@ External library support:
   --enable-decklink        enable Blackmagick DeckLink I/O support [no]
   --enable-nvenc           enable NVIDIA NVENC support [no]
   --enable-openal          enable OpenAL 1.1 capture support [no]
-  --enable-opencl          enable OpenCL code
+  --disable-opencl         disable OpenCL code [autodetect]
   --enable-opengl          enable OpenGL rendering [no]
   --enable-openssl         enable openssl, needed for https support
                            if gnutls is not used [no]
@@ -4961,12 +4961,6 @@ enabled openal            && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lO
                                die "ERROR: openal not found"; } &&
                              { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
                                die "ERROR: openal must be installed and version must be 1.1 or compatible"; }
-enabled opencl            && { check_lib2 OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
-                               check_lib2 CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
-                               die "ERROR: opencl not found"; } &&
-                             { check_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
-                               check_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
-                               die "ERROR: opencl must be installed and version must be 1.2 or compatible"; }
 enabled opengl            && { check_lib GL/glx.h glXGetProcAddress "-lGL" ||
                                check_lib2 windows.h wglGetProcAddress "-lopengl32 -lgdi32" ||
                                check_lib2 OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" ||
@@ -4984,6 +4978,18 @@ if enabled gnutls; then
     { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
 fi
 
+# OpenCL auto-detection. FIXME: List of whitelisted platforms for which OpenCL is enabled by default
+if ! disabled opencl; then
+    if [ $target_os == mingw32 ] || [ $target_os == linux ] || [ $target_os == darwin ] ||
+       { [ $target_os == cygwin ] && check_code ld "windows.h" "LoadLibraryW(0);"; }; then
+        enable opencl
+    elif enabled opencl ; then
+        warn "OpenCL support using CLEW may not work on target os"
+    else
+        disable opencl
+    fi
+fi
+
 # libdc1394 check
 if enabled libdc1394; then
     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
-- 
1.9.5.msysgit.0

