-
Notifications
You must be signed in to change notification settings - Fork 9
/
cit_opencl.m4
79 lines (67 loc) · 1.89 KB
/
cit_opencl.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- Autoconf -*-
## --------------------------- ##
## Autoconf macros for OPENCL. ##
## --------------------------- ##
# ----------------------------------------------------------------------
# CIT_OPENCL_CONFIG
# ----------------------------------------------------------------------
# Determine the directory containing <CL/cl.h>
AC_DEFUN([CIT_OPENCL_CONFIG], [
AC_ARG_VAR(OCL_INC, [Location of OpenCL include files])
AC_ARG_VAR(OCL_LIB, [Location of OpenCL library libOpenCL])
AC_LANG_PUSH([C])
AC_REQUIRE_CPP
CFLAGS_save="$CFLAGS"
LDFLAGS_save="$LDFLAGS"
LIBS_save="$LIBS"
dnl Check for OpenCL headers
if test "x$OCL_INC" != "x"; then
OCL_CFLAGS="-I$OCL_INC"
CFLAGS="$OCL_CFLAGS $CFLAGS"
fi
# tests for Apple Mac OsX OpenCL header file
case $host in
*apple*) HEADER_H="OpenCL/cl.h";;
*) HEADER_H="CL/cl.h";;
esac
AC_CHECK_HEADER([${HEADER_H}], [], [
AC_MSG_ERROR([OpenCL header not found; try setting OCL_INC.])
])
if test "x$OCL_LIB" != "x"; then
# tests for Apple Mac OsX which could add "-framework OpenCL"
case $host in
*apple*) OCL_LDFLAGS="$OCL_LIB";;
*) OCL_LDFLAGS="-L$OCL_LIB";;
esac
LDFLAGS="$OCL_LDFLAGS $LDFLAGS"
else
# adds default OpenCL library
case $host in
*apple*) OCL_LIBS="-framework OpenCL";;
*) OCL_LIBS="-lOpenCL";;
esac
fi
LIBS="$OCL_LIBS $LIBS"
AC_MSG_CHECKING([for clGetPlatformIDs in OpenCL])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
]],
[[clGetPlatformIDs(0, 0, 0);]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([OpenCL library not found; try setting OCL_LIB.])
])
CFLAGS="$CFLAGS_save"
LDFLAGS="$LDFLAGS_save"
LIBS="$LIBS_save"
AC_LANG_POP([C])
AC_SUBST([OCL_CFLAGS])
AC_SUBST([OCL_LDFLAGS])
AC_SUBST([OCL_LIBS])
])dnl CIT_OPENCL_COMPILER
dnl end of file