Update copyright notices
[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 OPENCL_VERSION="2.0"
22 AC_SUBST([OPENCL_VERSION])
23
24 # Checks for programs.
25 AC_PROG_CC_C89
26 AC_PROG_INSTALL
27 AC_PROG_LN_S
28 AM_PROG_CC_C_O
29
30 AC_PATH_PROG([ASCIIDOC], [asciidoc], [])
31 AC_PATH_PROG([A2X], [a2x], [])
32 AC_PATH_PROG([XMLTO], [xmlto], [])
33 AM_CONDITIONAL([GEN_DOC], [\
34         test x"$ASCIIDOC" != x && \
35         test x"$A2X" != x && \
36         test x"$XMLTO" != x ])
37
38 # Checks for libraries.
39 AC_CHECK_LIB([dl], [dlopen])
40
41 # Checks for header files.
42 AC_CHECK_HEADERS([stdlib.h string.h])
43 cl_h=no
44 case $host_os in
45   darwin* )
46     AC_CHECK_HEADER([OpenCL/opencl.h],[cl_h=yes])
47     ;;
48   * )
49     AC_CHECK_HEADER([CL/opencl.h],[cl_h=yes])
50     ;;
51 esac
52 if test $cl_h = yes; then
53   AC_MSG_CHECKING([whether OpenCL headers 2.0 are available])
54   AC_PREPROC_IFELSE([
55     AC_LANG_PROGRAM([[
56 #if defined(__APPLE__) || defined(__MACOSX)
57 #  include <OpenCL/opencl.h>
58 #else
59 #  include <CL/opencl.h>
60 #endif
61 #ifndef CL_VERSION_2_0
62 #  error Cannot find CL_VERSION_2_0 symbol
63 #endif
64       ]], [[
65       ]])],[
66     AC_MSG_RESULT([yes])
67   ],[
68     AC_MSG_RESULT([no])
69     cl_h=no
70   ])
71 fi
72
73 # Checks for typedefs, structures, and compiler characteristics.
74 AC_C_INLINE
75 AC_TYPE_SIZE_T
76 AC_C_CONST
77
78 NO_DEPRECATED_DECLARATIONS_FLAGS=
79 AX_CHECK_COMPILER_FLAGS([-Wno-deprecated-declarations],
80   [NO_DEPRECATED_DECLARATIONS_FLAGS="-Wno-deprecated-declarations"])
81 AC_SUBST([NO_DEPRECATED_DECLARATIONS_FLAGS])
82
83 # Checks for library functions.
84 AC_FUNC_MALLOC
85 AC_FUNC_REALLOC
86 AC_CHECK_FUNCS([strstr])
87
88 # --enable-pthread-once
89 AC_ARG_ENABLE([pthread-once],
90   [AS_HELP_STRING([--enable-pthread-once],
91                [use pthread_once() to ensure correct initialisation without polling])],
92   [pthread_once=$enableval],
93   [pthread_once=no])
94
95 if test "$pthread_once" = yes ; then
96   AX_PTHREAD([
97     AC_DEFINE([USE_PTHREAD], [1],
98               [pthreads are available])
99   ], [
100     AC_MSG_ERROR([No pthread detected on this platform!])
101   ])
102 fi
103
104 # --enable-official-khronos-headers
105 AC_ARG_ENABLE([official-khronos-headers],
106   [AS_HELP_STRING([--enable-official-khronos-headers],
107                [use official Khronos OpenCL headers provided in the sources instead of OpenCL headers installed on the system])],
108   [khronos_headers=$enableval],
109   [khronos_headers=may])
110
111 AS_CASE([$cl_h,$khronos_headers],
112   [no,no], [AC_MSG_ERROR([No 2.0 OpenCL headers available and --disable-official-khronos-headers used])],
113   [no,*], [khronos_headers=yes],
114   [yes,yes], [AC_MSG_WARN([Using internal copy of OpenCL headers as requested, even if they are available on the system])],
115   [yes,*], [khronos_headers=no],
116   [AC_MSG_ERROR([Internal error. Please, report this bug])])
117
118 if test $khronos_headers = no; then
119   AC_MSG_NOTICE([using system OpenCL headers])
120 else
121   AC_MSG_NOTICE([using internal copy of OpenCL headers])
122   AM_CPPFLAGS="$AM_CPPFLAGS -I\${abs_top_srcdir}/khronos-headers"
123   AC_SUBST([AM_CPPFLAGS])
124 fi
125
126 # --disable-debug
127 AC_ARG_ENABLE([debug],
128   [AS_HELP_STRING([--disable-debug],
129                [remove debug and additionnal checks (default is included)])],
130   [use_debug=$enableval],
131   [use_debug=yes])
132 if  test "x$use_debug" != xno ; then
133   AC_DEFINE([DEBUG_OCL_ICD], [1],
134             [Add DEBUG additionnal code])
135 fi
136
137 # --enable-update-database
138 AC_ARG_ENABLE([update-database],
139   [AS_HELP_STRING([--enable-update-database],
140                [update the YAML database from the currently installed ICD Loader and OpenCL headers (root access required)])],
141   [update_database=$enableval],
142   [update_database=no])
143 AM_CONDITIONAL([UPDATE_DATABASE], [test x"$update_database" != xno])
144
145 # always use versionned symbols (check required for MacOSX)
146 AM_CONDITIONAL([USE_MAP], [true])
147
148 AC_CONFIG_FILES([
149   Makefile
150   doc/Makefile
151   tests/Makefile
152
153   OpenCL.pc
154   ocl-icd.pc
155   tests/atlocal
156 ])
157 AC_OUTPUT