mirror of https://github.com/BOINC/boinc.git
Fix opencl check
This commit is contained in:
parent
4af1360faa
commit
336825cd02
15
configure.ac
15
configure.ac
|
@ -217,13 +217,6 @@ if test x$enable_server = xyes ; then
|
|||
configured_to_build="${configured_to_build} server"
|
||||
fi
|
||||
if test x$enable_apps = xyes ; then
|
||||
AX_CHECK_CL
|
||||
if test "X$no_cl" = "Xyes"; then
|
||||
AC_MSG_WARN([OpenCL is missing, OpenClApp example is disable])
|
||||
enable_openclapp=no
|
||||
else
|
||||
enable_openclapp=yes
|
||||
fi
|
||||
configured_to_build="${configured_to_build} apps"
|
||||
fi
|
||||
if test x$enable_unit_tests = xyes ; then
|
||||
|
@ -562,6 +555,12 @@ dnl check for X11
|
|||
AC_PATH_X
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl Check for CL library opencl
|
||||
AX_CHECK_CL
|
||||
if test "x$with_opencl" = "xno"; then
|
||||
AC_MSG_WARN([OpenCL is missing, OpenClApp example is disabled])
|
||||
fi
|
||||
|
||||
dnl check for GL library
|
||||
AX_CHECK_GL
|
||||
AX_CHECK_GLU
|
||||
|
@ -1076,11 +1075,11 @@ AM_CONDITIONAL(ENABLE_MANAGER, [ test "x${ac_cv_have_wxwidgets}" = xyes -a "${en
|
|||
AM_CONDITIONAL(ENABLE_LIBRARIES, [test "${enable_libraries}" = yes])
|
||||
AM_CONDITIONAL(ENABLE_BOINCZIP, [test "${enable_boinczip}" = yes])
|
||||
AM_CONDITIONAL(ENABLE_APPS, [test "${enable_apps}" = yes])
|
||||
AM_CONDITIONAL(ENABLE_OPENCLAPP, [test "${enable_openclapp}" = yes])
|
||||
AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "${enable_unit_tests}" = yes])
|
||||
AM_CONDITIONAL(ENABLE_BOINCCRYPT, [test "x${enable_server}" = xyes || test "x${enable_client}" = xyes ])
|
||||
AM_CONDITIONAL(INSTALL_HEADERS, [test "${enable_install_headers}" = yes])
|
||||
AM_CONDITIONAL(HAVE_CUDA_LIB, [test "${enable_client}" = yes -a -f ./coprocs/CUDA/posix/${boinc_platform}/libcudart.so])
|
||||
AM_CONDITIONAL(BUILD_OPENCL, [test "x$with_opencl" = "xyes"])
|
||||
|
||||
dnl ======================================================================
|
||||
dnl some more vodoo required for building portable client-binary (client, clientgui)
|
||||
|
|
|
@ -1,120 +1,65 @@
|
|||
# -*- mode: autoconf -*-
|
||||
#
|
||||
# AX_CHECK_CL
|
||||
#
|
||||
# Check for an OpenCL implementation. If CL is found, the required compiler
|
||||
# and linker flags are included in the output variables "CL_CFLAGS" and
|
||||
# "CL_LIBS", respectively. If no usable CL implementation is found, "no_cl"
|
||||
# is set to "yes".
|
||||
#
|
||||
# If the header "CL/cl.h" is found, "HAVE_CL_CL_H" is defined. If the header
|
||||
# "OpenCL/cl.h" is found, HAVE_OPENCL_CL_H is defined. These preprocessor
|
||||
# definitions may not be mutually exclusive.
|
||||
#
|
||||
# Based on AX_CHECK_GL, version: 2.4 author: Braden McDaniel
|
||||
# <braden@endoframe.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
# As a special exception, the you may copy, distribute and modify the
|
||||
# configure scripts that are the output of Autoconf when processing
|
||||
# the Macro. You need not follow the terms of the GNU General Public
|
||||
# License when using or distributing such scripts.
|
||||
#
|
||||
|
||||
# OpenCL support
|
||||
AC_DEFUN([AX_CHECK_CL],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
AC_REQUIRE([AC_PATH_X])dnl
|
||||
AC_REQUIRE([AC_PROG_SED])dnl
|
||||
AC_REQUIRE([ACX_PTHREAD])dnl
|
||||
[AC_ARG_WITH([opencl],
|
||||
[AS_HELP_STRING([--with-opencl],
|
||||
[build OpenClApp with OpenCL @<:@default=check@:>@])],
|
||||
[],
|
||||
[with_opencl=check])
|
||||
|
||||
AC_LANG_PUSH([C])
|
||||
AX_LANG_COMPILER_MS
|
||||
AS_IF([test X$ax_compiler_ms = Xno],
|
||||
[CL_CFLAGS="${PTHREAD_CFLAGS}"; CL_LIBS="${PTHREAD_LIBS} -lm"])
|
||||
|
||||
#
|
||||
# Use x_includes and x_libraries if they have been set (presumably by
|
||||
# AC_PATH_X).
|
||||
#
|
||||
AS_IF([test X$no_x != Xyes],
|
||||
[AS_IF([test -n "$x_includes"],
|
||||
[CL_CFLAGS="-I$x_includes $CL_CFLAGS"])]
|
||||
AS_IF([test -n "$x_libraries"],
|
||||
[CL_LIBS="-L$x_libraries -lX11 $CL_LIBS"]))
|
||||
|
||||
ax_save_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CL_CFLAGS $CPPFLAGS"
|
||||
AC_CHECK_HEADERS([CL/cl.h OpenCL/cl.h])
|
||||
CPPFLAGS=$ax_save_CPPFLAGS
|
||||
|
||||
AC_CHECK_HEADERS([windows.h])
|
||||
|
||||
m4_define([AX_CHECK_CL_PROGRAM],
|
||||
[AC_LANG_PROGRAM([[
|
||||
# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# ifdef HAVE_CL_CL_H
|
||||
# include <CL/cl.h>
|
||||
# elif defined(HAVE_OPENCL_CL_H)
|
||||
# include <OpenCL/cl.h>
|
||||
# else
|
||||
# error no cl.h
|
||||
# endif]],
|
||||
[[clFinish(0)]])])
|
||||
|
||||
AC_CACHE_CHECK([for OpenCL library], [ax_cv_check_cl_libcl],
|
||||
[ax_cv_check_cl_libcl=no
|
||||
case $host_cpu in
|
||||
x86_64) ax_check_cl_libdir=lib64 ;;
|
||||
*) ax_check_cl_libdir=lib ;;
|
||||
esac
|
||||
ax_save_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CL_CFLAGS $CPPFLAGS"
|
||||
ax_save_LIBS=$LIBS
|
||||
LIBS=""
|
||||
ax_check_libs="-lOpenCL -lCL"
|
||||
for ax_lib in $ax_check_libs; do
|
||||
AS_IF([test X$ax_compiler_ms = Xyes],
|
||||
[ax_try_lib=`echo $ax_lib | $SED -e 's/^-l//' -e 's/$/.lib/'`],
|
||||
[ax_try_lib=$ax_lib])
|
||||
LIBS="$ax_try_lib $CL_LIBS $ax_save_LIBS"
|
||||
AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
|
||||
[ax_cv_check_cl_libcl=$ax_try_lib; break],
|
||||
[ax_check_cl_nvidia_flags="-L/usr/$ax_check_cl_libdir/nvidia" LIBS="$ax_try_lib $ax_check_cl_nvidia_flags $CL_LIBS $ax_save_LIBS"
|
||||
AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
|
||||
[ax_cv_check_cl_libcl="$ax_try_lib $ax_check_cl_nvidia_flags"; break],
|
||||
[ax_check_cl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libCL.dylib:/System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libCL.dylib' LIBS="$ax_try_lib $ax_check_cl_dylib_flag $CL_LIBS $ax_save_LIBS"
|
||||
AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
|
||||
[ax_cv_check_cl_libcl="$ax_try_lib $ax_check_cl_dylib_flag"; break])])])
|
||||
done
|
||||
|
||||
AS_IF([test "X$ax_cv_check_cl_libcl" = Xno -a X$no_x = Xyes],
|
||||
[LIBS='-framework OpenCL'
|
||||
AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
|
||||
[ax_cv_check_cl_libcl=$LIBS])])
|
||||
|
||||
LIBS=$ax_save_LIBS
|
||||
CPPFLAGS=$ax_save_CPPFLAGS])
|
||||
|
||||
AS_IF([test "X$ax_cv_check_cl_libcl" = Xno],
|
||||
[no_cl=yes; CL_CFLAGS=""; CL_LIBS=""],
|
||||
[CL_LIBS="$ax_cv_check_cl_libcl $CL_LIBS"])
|
||||
AC_LANG_POP([C])
|
||||
|
||||
AC_SUBST([CL_CFLAGS])
|
||||
AC_SUBST([CL_LIBS])
|
||||
# detect/verify we have a working OpenCL header and library
|
||||
AS_IF([test "x$with_opencl" != xno],
|
||||
[
|
||||
# check for usable OpenCL header
|
||||
# note C++ binding uses opencl.h, not just cl.h
|
||||
AC_MSG_NOTICE([checking for usable OpenCL opencl.h header])
|
||||
AC_CHECK_HEADER([OpenCL/opencl.h],
|
||||
[OPENCL_HEADER='"OpenCL/opencl.h"'],
|
||||
[AC_CHECK_HEADER([CL/opencl.h],
|
||||
[OPENCL_HEADER='"CL/opencl.h"'],
|
||||
[if test "x$with_opencl" != xcheck; then
|
||||
AC_MSG_FAILURE([OpenCL support was requested, but no usable OpenCL header was found])
|
||||
fi
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
AS_IF([test "x$OPENCL_HEADER" != x],
|
||||
[
|
||||
# we have a header, check for usable OpenCL library
|
||||
# we cannot use AC_CHECK_LIB because we want to check
|
||||
# using the OS X OpenCL framework, and AC_CHECK_LIB does not
|
||||
# know how to use the framework linker syntax.
|
||||
# (we also do not want the OpenCL libs to be added to the
|
||||
# LIBS variable, and AC_CHECK_LIB does that if it succeeds)
|
||||
AC_MSG_CHECKING([for usable OpenCL library])
|
||||
savedLIBS=$LIBS
|
||||
OPENCL_LIBS="-framework OpenCL"
|
||||
LIBS="$OPENCL_LIBS $savedLIBS"
|
||||
AC_LINK_IFELSE( [AC_LANG_PROGRAM([@%:@include $OPENCL_HEADER],[clGetPlatformIDs(0,0,0);])],
|
||||
[AC_MSG_RESULT($OPENCL_LIBS)],
|
||||
[OPENCL_LIBS="-lOpenCL"
|
||||
LIBS="$OPENCL_LIBS $savedLIBS"
|
||||
AC_LINK_IFELSE( [AC_LANG_PROGRAM([@%:@include $OPENCL_HEADER],[clGetPlatformIDs(0,0,0);])],
|
||||
[AC_MSG_RESULT($OPENCL_LIBS)],
|
||||
[AC_MSG_RESULT([no])
|
||||
if test "x$with_opencl" != xcheck; then
|
||||
AC_MSG_FAILURE([OpenCL support was requested, but no usable OpenCL library was found])
|
||||
fi
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
LIBS=$savedLIBS
|
||||
]
|
||||
)
|
||||
AS_IF([test "x$OPENCL_HEADER" != "x" -a "x$OPENCL_LIBS" != "x"],
|
||||
[with_opencl=yes
|
||||
MPI_SUBDIRS="$MPI_SUBDIRS opencl"
|
||||
AC_SUBST([OPENCL_LIBS])
|
||||
],
|
||||
[AC_MSG_NOTICE([no usable OpenCL installation found])
|
||||
with_opencl=no
|
||||
])
|
||||
])
|
||||
])dnl
|
||||
|
|
|
@ -7,7 +7,7 @@ include $(top_srcdir)/Makefile.incl
|
|||
SUBDIRS = condor example_app multi_thread sleeper vboxmonitor vboxwrapper worker wrapper
|
||||
|
||||
## build openclapp if you have opencl on your device
|
||||
if ENABLE_OPENCLAPP
|
||||
if BUILD_OPENCL
|
||||
SUBDIRS += openclapp
|
||||
endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue