Added NULL pointers handling, should not segfault anymore on NULL pointer.
[ocl-icd] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.67])
5 AC_INIT([OpenCL ICD Loader], [2.0.4], [ocl-icd-devel@lists.forge.imag.fr], [ocl-icd])
6 AC_CONFIG_SRCDIR([ocl_icd_loader.c])
7 AC_CONFIG_AUX_DIR([build-aux])
8 AC_CONFIG_HEADERS([config.h])
9 AC_CONFIG_MACRO_DIR([m4])
10 AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.9 tar-pax check-news color-tests parallel-tests])
11 AMX_SILENT_RULES([AM_DEFAULT_VERBOSITY=1])
12 # AM_PROG_AR must be called before LT_INIT...
13 AM_PROG_AR
14 LT_INIT([disable-static])
15 AC_CONFIG_TESTDIR([tests], [.])
16
17 OPENCL_VERSION="1.2"
18 AC_SUBST([OPENCL_VERSION])
19
20 # Checks for programs.
21 AC_PROG_CC_C89
22 AC_PROG_INSTALL
23 AC_PROG_LN_S
24 AM_PROG_CC_C_O
25
26 AC_PATH_PROG([ASCIIDOC], [asciidoc], [])
27 AC_PATH_PROG([A2X], [a2x], [])
28 AC_PATH_PROG([XMLTO], [xmlto], [])
29 AM_CONDITIONAL([GEN_DOC], [\
30         test x"$ASCIIDOC" != x && \
31         test x"$A2X" != x && \
32         test x"$XMLTO" != x ])
33
34 # Checks for libraries.
35 AC_CHECK_LIB([dl], [dlopen])
36
37 # Checks for header files.
38 AC_CHECK_HEADERS([stdlib.h string.h])
39 cl_h=no
40 case $host_os in
41   darwin* )
42     AC_CHECK_HEADER([OpenCL/opencl.h],[cl_h=yes])
43     ;;
44   * )
45     AC_CHECK_HEADER([CL/opencl.h],[cl_h=yes])
46     ;;
47 esac
48 if test $cl_h = no; then
49   AC_MSG_ERROR([OpenCL headers are required])
50 fi
51 AC_MSG_CHECKING([whether OpenCL headers 1.2 are available])
52 AC_PREPROC_IFELSE([
53   AC_LANG_PROGRAM([[
54 #if defined(__APPLE__) || defined(__MACOSX)
55 #  include <OpenCL/opencl.h>
56 #else
57 #  include <CL/opencl.h>
58 #endif
59 #ifndef CL_VERSION_1_2
60 #  error Cannot find CL_VERSION_1_2 symbol
61 #endif
62     ]], [[
63     ]])],[
64   AC_MSG_RESULT([yes])
65 ],[
66   AC_MSG_RESULT([no])
67   AC_MSG_FAILURE([OpenCL headers for OpenCL 1.2 are required])
68 ])
69
70 # Checks for typedefs, structures, and compiler characteristics.
71 AC_C_INLINE
72 AC_TYPE_SIZE_T
73 AC_C_CONST
74
75 NO_DEPRECATED_DECLARATIONS_FLAGS=
76 AX_CHECK_COMPILER_FLAGS([-Wno-deprecated-declarations],
77   [NO_DEPRECATED_DECLARATIONS_FLAGS="-Wno-deprecated-declarations"])
78 AC_SUBST([NO_DEPRECATED_DECLARATIONS_FLAGS])
79
80 # Checks for library functions.
81 AC_FUNC_MALLOC
82 AC_FUNC_REALLOC
83 AC_CHECK_FUNCS([strstr])
84
85 # --enable-pthread-once
86 AC_ARG_ENABLE([pthread-once],
87   [AS_HELP_STRING([--enable-pthread-once],
88                [use pthread_once() to ensure correct initialisation without polling])],
89   [pthread_once=$enableval],
90   [pthread_once=no])
91
92 if test "$pthread_once" = yes ; then
93   AX_PTHREAD([
94     AC_DEFINE([USE_PTHREAD], [1],
95               [pthreads are available])
96   ], [
97     AC_MSG_ERROR([No pthread detected on this platform!])
98   ])
99 fi
100
101 # --disable-debug
102 AC_ARG_ENABLE([debug],
103   [AS_HELP_STRING([--disable-debug],
104                [remove debug and additionnal checks (default is included)])],
105   [use_debug=$enableval],
106   [use_debug=yes])
107 if  test "x$use_debug" != xno ; then
108   AC_DEFINE([DEBUG_OCL_ICD], [1],
109             [Add DEBUG additionnal code])
110 fi
111
112 # --enable-update-database
113 AC_ARG_ENABLE([update-database],
114   [AS_HELP_STRING([--enable-update-database],
115                [update the YAML database from the currently installed ICD Loader and OpenCL headers (root access required)])],
116   [update_database=$enableval],
117   [update_database=no])
118 AM_CONDITIONAL([UPDATE_DATABASE], [test x"$update_database" != xno])
119
120 # always use versionned symbols (check required for MacOSX)
121 AM_CONDITIONAL([USE_MAP], [true])
122
123 AC_CONFIG_FILES([
124   Makefile
125   doc/Makefile
126   tests/Makefile
127
128   OpenCL.pc
129   ocl-icd.pc
130   tests/atlocal
131 ])
132 AC_OUTPUT