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