Commit 2a8475b5bdaf23ec53924798317432f55bb92ff8

Tom Rini 2011-06-29T19:45:53

configure.ac, Makefile.am: Allow setting of OpenCL location Add two new configure flags, --with-opencl-libdir and --with-opencl-inc to specify where OpenCL headers and libraries exist. This now adds a test for the OpenCL header file and makes not finding the library or headers a fatal error. Signed-off-by: Tom Rini <trini@kernel.crashing.org>

diff --git a/Makefile.am b/Makefile.am
index 82c58ca..2f23b6b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,7 +9,8 @@ EXTRA_DIST	= example-cfg.json
 
 SUBDIRS		= compat
 
-INCLUDES	= $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES)
+INCLUDES	= $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) \
+		  @OPENCL_INCLUDES@
 
 bin_PROGRAMS	= minerd
 
diff --git a/configure.ac b/configure.ac
index 99f05eb..a1003ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,8 +39,31 @@ case $target in
     ;;
 esac
 
+dnl Figure out where OpenCL is, either passed or system-wide
+AC_ARG_WITH([opencl-libdir],
+	[AC_HELP_STRING([--with-opencl-libdir],[specify OpenCL library])],
+	[with_opencl_lib=$withval],
+	[with_opencl_lib="auto"])
+if test "x$with_opencl_lib" = xauto; then
+	AC_CHECK_LIB([OpenCL], [OpenCL], [OPENCL_LIBS="-lOpenCL"], AC_MSG_ERROR([OpenCL library could not be found]))
+else
+	OPENCL_LIBS="$with_opencl_lib/libOpenCL.so"
+fi
+OPENCL_INCLUDES=""
+AC_ARG_WITH([opencl-inc],
+	[AC_HELP_STRING([--with-opencl-inc],[specify OpenCL include paths])],
+	[with_opencl_inc=$withval],
+	[with_opencl_inc="auto"])
+if test "x$with_opencl_inc" = xauto; then
+	AC_CHECK_HEADERS(CL/cl.h, [found="yes"])
+	AC_CHECK_HEADERS(OpenCL/opencl.h, [found="yes"])
+	if test "x$found" = x; then
+		AC_MSG_ERROR([OpenCL headers could not be found])
+	fi
+else
+	OPENCL_INCLUDES="-I$with_opencl_inc"
+fi
 
-AC_CHECK_LIB(OpenCL, clSetKernelArg, OPENCL_LIBS=-lOpenCL)
 AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
 AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIBS=-lpthread)
 
@@ -97,6 +120,7 @@ LIBCURL_CHECK_CONFIG(, 7.10.1, ,
   [AC_MSG_ERROR([Missing required libcurl >= 7.10.1])])
 
 AC_SUBST(OPENCL_LIBS)
+AC_SUBST(OPENCL_INCLUDES)
 AC_SUBST(JANSSON_LIBS)
 AC_SUBST(PTHREAD_FLAGS)
 AC_SUBST(PTHREAD_LIBS)