Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /trunk/config/ax_check_cl.m4
ViewVC logotype

Annotation of /trunk/config/ax_check_cl.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1219 - (view) (download)

1 : jhr 1219 # -*- mode: autoconf -*-
2 :     #
3 :     # AX_CHECK_CL
4 :     #
5 :     # Check for an OpenCL implementation. If CL is found, the required compiler
6 :     # and linker flags are included in the output variables "CL_CFLAGS" and
7 :     # "CL_LIBS", respectively. If no usable CL implementation is found, "no_cl"
8 :     # is set to "yes".
9 :     #
10 :     # If the header "CL/cl.h" is found, "HAVE_CL_CL_H" is defined. If the header
11 :     # "OpenCL/cl.h" is found, HAVE_OPENCL_CL_H is defined. These preprocessor
12 :     # definitions may not be mutually exclusive.
13 :     #
14 :     # Based on AX_CHECK_GL, version: 2.4 author: Braden McDaniel
15 :     # <braden@endoframe.com>
16 :     #
17 :     # Changed CL_CFLAGS to CL_CPPFLAGS (http://cs.uchicago.edu/~jhr)
18 :     #
19 :     # This program is free software; you can redistribute it and/or modify
20 :     # it under the terms of the GNU General Public License as published by
21 :     # the Free Software Foundation; either version 2, or (at your option)
22 :     # any later version.
23 :     #
24 :     # This program is distributed in the hope that it will be useful,
25 :     # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 :     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 :     # GNU General Public License for more details.
28 :     #
29 :     # You should have received a copy of the GNU General Public License
30 :     # along with this program; if not, write to the Free Software
31 :     # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 :     # 02110-1301, USA.
33 :     #
34 :     # As a special exception, the you may copy, distribute and modify the
35 :     # configure scripts that are the output of Autoconf when processing
36 :     # the Macro. You need not follow the terms of the GNU General Public
37 :     # License when using or distributing such scripts.
38 :     #
39 :     AC_DEFUN([AX_CHECK_CL],
40 :     [AC_REQUIRE([AC_CANONICAL_HOST])dnl
41 :     AC_REQUIRE([AC_PATH_X])dnl
42 :     AC_REQUIRE([AC_PROG_SED])dnl
43 :     AC_REQUIRE([ACX_PTHREAD])dnl
44 :    
45 :     AC_LANG_PUSH([C])
46 :     AX_LANG_COMPILER_MS
47 :     AS_IF([test X$ax_compiler_ms = Xno],
48 :     [CL_CPPFLAGS="${PTHREAD_CFLAGS}"; CL_LIBS="${PTHREAD_LIBS} -lm"])
49 :    
50 :     #
51 :     # Use x_includes and x_libraries if they have been set (presumably by
52 :     # AC_PATH_X).
53 :     #
54 :     AS_IF([test X$no_x != Xyes],
55 :     [AS_IF([test -n "$x_includes"],
56 :     [CL_CPPFLAGS="-I$x_includes $CL_CPPFLAGS"])]
57 :     AS_IF([test -n "$x_libraries"],
58 :     [CL_LIBS="-L$x_libraries -lX11 $CL_LIBS"]))
59 :    
60 :     ax_save_CPPFLAGS=$CPPFLAGS
61 :     CPPFLAGS="$CL_CPPFLAGS $CPPFLAGS"
62 :     AC_CHECK_HEADERS([CL/cl.h OpenCL/cl.h])
63 :     CPPFLAGS=$ax_save_CPPFLAGS
64 :    
65 :     AC_CHECK_HEADERS([windows.h])
66 :    
67 :     m4_define([AX_CHECK_CL_PROGRAM],
68 :     [AC_LANG_PROGRAM([[
69 :     # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
70 :     # include <windows.h>
71 :     # endif
72 :     # ifdef HAVE_CL_CL_H
73 :     # include <CL/cl.h>
74 :     # elif defined(HAVE_OPENCL_CL_H)
75 :     # include <OpenCL/cl.h>
76 :     # else
77 :     # error no cl.h
78 :     # endif]],
79 :     [[clFinish(0)]])])
80 :    
81 :     AC_CACHE_CHECK([for OpenCL library], [ax_cv_check_cl_libcl],
82 :     [ax_cv_check_cl_libcl=no
83 :     case $host_cpu in
84 :     x86_64) ax_check_cl_libdir=lib64 ;;
85 :     *) ax_check_cl_libdir=lib ;;
86 :     esac
87 :     ax_save_CPPFLAGS=$CPPFLAGS
88 :     CPPFLAGS="$CL_CPPFLAGS $CPPFLAGS"
89 :     ax_save_LIBS=$LIBS
90 :     LIBS=""
91 :     ax_check_libs="-lOpenCL -lCL"
92 :     for ax_lib in $ax_check_libs; do
93 :     AS_IF([test X$ax_compiler_ms = Xyes],
94 :     [ax_try_lib=`echo $ax_lib | $SED -e 's/^-l//' -e 's/$/.lib/'`],
95 :     [ax_try_lib=$ax_lib])
96 :     LIBS="$ax_try_lib $CL_LIBS $ax_save_LIBS"
97 :     AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
98 :     [ax_cv_check_cl_libcl=$ax_try_lib; break],
99 :     [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"
100 :     AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
101 :     [ax_cv_check_cl_libcl="$ax_try_lib $ax_check_cl_nvidia_flags"; break],
102 :     [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"
103 :     AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
104 :     [ax_cv_check_cl_libcl="$ax_try_lib $ax_check_cl_dylib_flag"; break])])])
105 :     done
106 :    
107 :     AS_IF([test "X$ax_cv_check_cl_libcl" = Xno -a X$no_x = Xyes],
108 :     [LIBS='-framework OpenCL'
109 :     AC_LINK_IFELSE([AX_CHECK_CL_PROGRAM],
110 :     [ax_cv_check_cl_libcl=$LIBS])])
111 :    
112 :     LIBS=$ax_save_LIBS
113 :     CPPFLAGS=$ax_save_CPPFLAGS])
114 :    
115 :     AS_IF([test "X$ax_cv_check_cl_libcl" = Xno],
116 :     [no_cl=yes; CL_CPPFLAGS=""; CL_LIBS=""],
117 :     [CL_LIBS="$ax_cv_check_cl_libcl $CL_LIBS"])
118 :     AC_LANG_POP([C])
119 :    
120 :     AC_SUBST([CL_CPPFLAGS])
121 :     AC_SUBST([CL_LIBS])
122 :     ])dnl

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0