/
vexcl.m4
160 lines (134 loc) · 4.91 KB
/
vexcl.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# SYNOPSIS
#
# Test for VEXCL
#
# AX_PATH_VEXCL( <Minimum Required Version>, <package-required=yes/no> )
#
# DESCRIPTION
#
# Provides a --with-vexcl=DIR option. Searches --with-vexcl,
# $VEXCL_DIR, and the usual places for VEXCL headers and libraries.
#
# On success, sets VEXCL_CPPFLAGS, VEXCL_LIBS, and #defines HAVE_VEXCL.
# Also defines automake conditional VEXCL_ENABLED. Assumes package
# is optional unless overridden with $2=yes.
#
# LAST MODIFICATION
#
# $Id: vexcl.m4 -1 $
#
# COPYLEFT
#
# Copyright (c) 2013 Roy H. Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2012 Paul T. Bauman <pbauman@ices.utexas.edu>
# Copyright (c) 2010 Karl W. Schulz <karl@ices.utexas.edu>
# Copyright (c) 2009 Rhys Ulerich <rhys.ulerich@gmail.com>
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2008 Caolan McNamara <caolan@skynet.ie>
# Copyright (c) 2008 Alexandre Duret-Lutz <adl@gnu.org>
# Copyright (c) 2008 Matthew Mueller <donut@azstarnet.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([AX_PATH_VEXCL],
[
AC_ARG_VAR(VEXCL_DIR,[root directory of VEXCL installation])
AC_ARG_WITH(vexcl,
[AS_HELP_STRING([--with-vexcl[=DIR]],[root directory of VEXCL installation (default = VEXCL_DIR)])],
[with_vexcl=$withval
if test "${with_vexcl}" != yes; then
VEXCL_PREFIX=$withval
elif test "x${VEXCL_DIR}" != "x"; then
VEXCL_PREFIX=${VEXCL_DIR}
else
VEXCL_PREFIX=/usr
fi
],[
with_vexcl=$withval
if test "x${VEXCL_DIR}" != "x"; then
VEXCL_PREFIX=${VEXCL_DIR}
fi
])
# package requirement; if not specified, the default is to assume that
# the package is optional
is_package_required=ifelse([$2], ,no, $2 )
HAVE_VEXCL=0
VEXCL_INCLUDE="$VEXCL_PREFIX"
if test "${with_vexcl}" != no ; then
# If we can see the vexcl headers, then we know where to get them
# and we'll need C++11 to compile them
if test -e "${VEXCL_PREFIX}/vexcl/vexcl.hpp" ; then
VEXCL_CPPFLAGS="-I${VEXCL_PREFIX}"
AX_CXX_COMPILE_STDCXX_11(noext)
elif test -e "${VEXCL_PREFIX}/include/vexcl/vexcl.hpp" ; then
VEXCL_INCLUDE="${VEXCL_PREFIX}/include"
VEXCL_CPPFLAGS="-I${VEXCL_PREFIX}/include"
AX_CXX_COMPILE_STDCXX_11(noext)
else
AC_MSG_NOTICE([${VEXCL_PREFIX}/vexcl/vexcl.hpp not found])
AC_MSG_NOTICE([${VEXCL_PREFIX}/include/vexcl/vexcl.hpp not found])
fi
# Make sure we have OpenCL support
AX_CHECK_CL([C++])
found_boost=yes
BOOST_REQUIRE([1.47],[found_boost=no]) # Chrono introduced in 1.47
BOOST_CHRONO
if test "x$boost_cv_lib_chrono" != xyes; then
found_boost=no
fi
BOOST_DATE_TIME
if test "x$boost_cv_lib_date_time" != xyes; then
found_boost=no
fi
BOOST_FILESYSTEM
if test "x$boost_cv_lib_filesystem" != xyes; then
found_boost=no
fi
BOOST_SYSTEM
if test "x$boost_cv_lib_system" != xyes; then
found_boost=no
fi
BOOST_THREADS
if test "x$boost_cv_lib_threads" != xyes; then
found_boost=no
fi
# Make sure we have OpenCL support
AX_CHECK_CL([C++])
AC_LANG_PUSH([C++])
ac_VEXCL_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CXXFLAGS $CPPFLAGS $VEXCL_CPPFLAGS $BOOST_CPPFLAGS $CL_CFLAGS $CL_CPPFLAGS"
AC_CHECK_HEADER([vexcl/vexcl.hpp],[found_header=yes],[found_header=no])
CPPFLAGS="$ac_VEXCL_save_CPPFLAGS"
AC_LANG_POP([C++])
#-----------------------
# Minimum version check skipped - there's no versioning
# information in vexcl headers as of 0.7.0
#----------------------
succeeded=yes
if test x$found_header = xyes -a x"$no_cl" != xyes; then
VEXCL_CPPFLAGS="$VEXCL_CPPFLAGS $BOOST_CPPFLAGS $CL_CFLAGS $CL_CPPFLAGS"
VEXCL_LDFLAGS="$BOOST_CHRONO_LDFLAGS $BOOST_DATE_TIME_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS $BOOST_SYSTEM_LDFLAGS $CL_LDFLAGS"
VEXCL_LIBS="$BOOST_CHRONO_LIBS $BOOST_DATE_TIME_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS $CL_LIBS"
HAVE_VEXCL=1
AC_DEFINE(HAVE_VEXCL,1,[Define if VEXCL is available])
AC_SUBST(VEXCL_CPPFLAGS)
AC_SUBST(VEXCL_LDFLAGS)
AC_SUBST(VEXCL_LIBS)
AC_SUBST(VEXCL_PREFIX)
AC_SUBST(VEXCL_INCLUDE)
else
succeeded=no
if test "$is_package_required" = yes; then
AC_MSG_ERROR([VEXCL not found. Try either --with-vexcl or setting VEXCL_DIR.])
else
AC_MSG_NOTICE([optional VEXCL library not found])
VEXCL_CPPFLAGS="" # VEXCL_CPPFLAGS empty on failure
VEXCL_LDFLAGS="" # VEXCL_LDFLAGS empty on failure
VEXCL_LIBS="" # VEXCL_LIBS empty on failure
fi
fi
AC_SUBST(HAVE_VEXCL)
fi
AM_CONDITIONAL(VEXCL_ENABLED,test x$HAVE_VEXCL = x1)
])