improve clGetExtensionFunctionAddress{,ForPlatform}
[ocl-icd] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3 #
4 # Copyright (c) 2012-2015, Brice Videau <brice.videau@imag.fr>
5 # Copyright (c) 2012-2015, Vincent Danjean <Vincent.Danjean@ens-lyon.org>
6
7
8 AC_PREREQ([2.67])
9 AC_INIT([OpenCL ICD Loader], [2.2.7], [ocl-icd-devel@lists.forge.imag.fr], [ocl-icd])
10 AC_CONFIG_SRCDIR([ocl_icd_loader.c])
11 AC_CONFIG_AUX_DIR([build-aux])
12 AC_CONFIG_HEADERS([config.h])
13 AC_CONFIG_MACRO_DIR([m4])
14 AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.9 tar-pax check-news color-tests parallel-tests])
15 AMX_SILENT_RULES([AM_DEFAULT_VERBOSITY=1])
16 # AM_PROG_AR must be called before LT_INIT...
17 AM_PROG_AR
18 LT_INIT([disable-static])
19 AC_CONFIG_TESTDIR([tests], [.])
20
21 m4_define([REQ_OPENCL_VERSION],[2_0])
22 OPENCL_VERSION="m4_translit(REQ_OPENCL_VERSION, [_], [.])"
23 AC_SUBST([OPENCL_VERSION])
24
25 # Checks for programs.
26 AC_PROG_CC_C89
27 AC_PROG_INSTALL
28 AC_PROG_LN_S
29 AM_PROG_CC_C_O
30
31 AC_PATH_PROG([ASCIIDOC], [asciidoc], [])
32 AC_PATH_PROG([A2X], [a2x], [])
33 AC_PATH_PROG([XMLTO], [xmlto], [])
34 AM_CONDITIONAL([GEN_DOC], [\
35         test x"$ASCIIDOC" != x && \
36         test x"$A2X" != x && \
37         test x"$XMLTO" != x ])
38
39 # Checks for libraries.
40 AC_CHECK_LIB([dl], [dlopen])
41
42 # Checks for header files.
43 AC_CHECK_HEADERS([stdlib.h string.h])
44 cl_h=no
45 case $host_os in
46   darwin* )
47     AC_CHECK_HEADER([OpenCL/opencl.h],[cl_h=yes])
48     ;;
49   * )
50     AC_CHECK_HEADER([CL/opencl.h],[cl_h=yes])
51     ;;
52 esac
53 if test $cl_h = yes; then
54   AC_MSG_CHECKING([whether OpenCL headers $OPENCL_VERSION are available])
55   AC_PREPROC_IFELSE([
56     AC_LANG_PROGRAM([[
57 #if defined(__APPLE__) || defined(__MACOSX)
58 #  include <OpenCL/opencl.h>
59 #else
60 #  include <CL/opencl.h>
61 #endif
62 #ifndef CL_VERSION_]REQ_OPENCL_VERSION[
63 #  error Cannot find CL_VERSION_]REQ_OPENCL_VERSION[ symbol
64 #endif
65       ]], [[
66       ]])],[
67     AC_MSG_RESULT([yes])
68   ],[
69     AC_MSG_RESULT([no])
70     cl_h=no
71   ])
72 fi
73
74 # Checks for typedefs, structures, and compiler characteristics.
75 AC_C_INLINE
76 AC_TYPE_SIZE_T
77 AC_C_CONST
78
79 NO_DEPRECATED_DECLARATIONS_FLAGS=
80 AX_CHECK_COMPILER_FLAGS([-Wno-deprecated-declarations],
81   [NO_DEPRECATED_DECLARATIONS_FLAGS="-Wno-deprecated-declarations"])
82 AC_SUBST([NO_DEPRECATED_DECLARATIONS_FLAGS])
83
84 # Checks for library functions.
85 AC_FUNC_MALLOC
86 AC_FUNC_REALLOC
87 AC_CHECK_FUNCS([strstr])
88
89 # --enable-pthread-once
90 AC_ARG_ENABLE([pthread-once],
91   [AS_HELP_STRING([--enable-pthread-once],
92                [use pthread_once() to ensure correct initialisation without polling])],
93   [pthread_once=$enableval],
94   [pthread_once=no])
95
96 if test "$pthread_once" = yes ; then
97   AX_PTHREAD([
98     AC_DEFINE([USE_PTHREAD], [1],
99               [pthreads are available])
100   ], [
101     AC_MSG_ERROR([No pthread detected on this platform!])
102   ])
103 fi
104
105 # --enable-official-khronos-headers
106 AC_ARG_ENABLE([official-khronos-headers],
107   [AS_HELP_STRING([--enable-official-khronos-headers],
108                [use official Khronos OpenCL headers provided in the sources instead of OpenCL headers installed on the system])],
109   [khronos_headers=$enableval],
110   [khronos_headers=may])
111
112 AS_CASE([$cl_h,$khronos_headers],
113   [no,no], [AC_MSG_ERROR([No $OPENCL_VERSION OpenCL headers available and --disable-official-khronos-headers used])],
114   [no,*], [khronos_headers=yes],
115   [yes,yes], [AC_MSG_WARN([Using internal copy of OpenCL headers as requested, even if they are available on the system])],
116   [yes,*], [khronos_headers=no],
117   [AC_MSG_ERROR([Internal error. Please, report this bug])])
118
119 if test $khronos_headers = no; then
120   AC_MSG_NOTICE([using system OpenCL headers])
121 else
122   AC_MSG_NOTICE([using internal copy of OpenCL headers])
123   AM_CPPFLAGS="$AM_CPPFLAGS -I\${abs_top_srcdir}/khronos-headers"
124   AC_SUBST([AM_CPPFLAGS])
125 fi
126
127 # --disable-debug
128 AC_ARG_ENABLE([debug],
129   [AS_HELP_STRING([--disable-debug],
130                [remove debug and additionnal checks (default is included)])],
131   [use_debug=$enableval],
132   [use_debug=yes])
133 if  test "x$use_debug" != xno ; then
134   AC_DEFINE([DEBUG_OCL_ICD], [1],
135             [Add DEBUG additionnal code])
136 fi
137
138 # --enable-update-database
139 AC_ARG_ENABLE([update-database],
140   [AS_HELP_STRING([--enable-update-database],
141                [update the YAML database from the currently installed ICD Loader and OpenCL headers (root access required)])],
142   [update_database=$enableval],
143   [update_database=no])
144 AM_CONDITIONAL([UPDATE_DATABASE], [test x"$update_database" != xno])
145
146 # always use versionned symbols (check required for MacOSX)
147 AM_CONDITIONAL([USE_MAP], [true])
148
149 AC_CONFIG_FILES([
150   Makefile
151   doc/Makefile
152   tests/Makefile
153
154   OpenCL.pc
155   ocl-icd.pc
156   tests/atlocal
157 ])
158 AC_OUTPUT