OSDN Git Service

fix build error
[android-x86/external-IA-Hardware-Composer.git] / configure.ac
1 #
2 # Copyright (c) 2016 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 AC_PREREQ([2.64])
17 AC_INIT([intel-hw-composer],
18         [0.01],
19         [https://github.com/android-ia/hwcomposer],
20         [intel-hw-composer])
21
22 AC_CONFIG_SRCDIR([Makefile.am])
23 AC_CONFIG_HEADERS([config.h])
24 AC_CONFIG_MACRO_DIR([m4])
25 AC_USE_SYSTEM_EXTENSIONS
26 AC_SYS_LARGEFILE
27 AC_GNU_SOURCE
28 AC_CANONICAL_HOST
29 AC_CANONICAL_TARGET
30
31 AM_INIT_AUTOMAKE([1.12 foreign subdir-objects dist-bzip2])
32 AM_PATH_PYTHON([3],, [:])
33
34 AC_PROG_CC
35 AC_PROG_CXX
36 AM_PROG_LEX
37 AC_PROG_YACC
38
39 # Initialize libtool
40 AC_DISABLE_STATIC
41 AC_PROG_LIBTOOL
42
43 AC_SUBST(ASSEMBLER_WARN_CFLAGS)
44
45 # For splash screen dummy compositor
46 AC_ARG_ENABLE(dummy-compositor,
47   AS_HELP_STRING([--enable-dummy-compositor],
48     [Enable the dummy compositor (EXPERIMENTAL)]),
49 [if test x$enableval = xyes; then
50   enable_dummy_compositor=yes
51   AC_DEFINE(ENABLE_DUMMY_COMPOSITOR, 1, [Enable Dummy_Compositor])
52 fi])
53
54 AM_CONDITIONAL([ENABLE_DUMMY_COMPOSITOR], [test "x$enable_dummy_compositor" = "xyes"])
55
56 # For vulkan
57 AC_ARG_ENABLE(vulkan,
58   AS_HELP_STRING([--enable-vulkan],
59     [Enable Vulkan backend (EXPERIMENTAL)]),
60 [if test x$enableval = xyes; then
61   enable_vulkan=yes
62   AC_DEFINE(ENABLE_VULKAN, 1, [Enable Vulkan backend])
63 fi])
64
65 AM_CONDITIONAL([ENABLE_VULKAN], [test "x$enable_vulkan" = "xyes"])
66
67 # For prebuilt-shader
68 AC_DEFINE(ENABLE_PREBUILT_SHADER_BIN_ARRAY, 0, [Enable built-in prebuilt shader array])
69
70 AC_ARG_WITH([prebuilt-shader-pci-id],
71   [AS_HELP_STRING([--with-prebuilt-shader-pci-id@<:@=PCI ID in hex@:>@],
72      [PCI-ID of target GPU is required for using built-in pre-built shaders, e.g.
73      "0x0412" @<:@default=no@:>@])],
74      [prebuilt_shader_pci_id="$withval"],
75      [prebuilt_shader_pci_id=no])
76
77 # check if shader-db exist
78 SHADERDB_PATH=common/compositor/gl/gl_shader_pre_built/shader-db
79
80 if test "x$prebuilt_shader_pci_id" != "xno"; then
81     SHADERDB_PATH=common/compositor/gl/gl_shader_pre_built/shader-db
82     AC_CHECK_FILES([$SHADERDB_PATH $SHADERDB_PATH/run
83                     $SHADERDB_PATH/intel_stub.so],
84                     shaderdb=yes, shaderdb=no)
85     if test "x$shaderdb" = "xyes"; then
86         PREBUILT_SHADER_FOR_PCI_ID="$withval"
87         AC_SUBST([PREBUILT_SHADER_FOR_PCI_ID])
88     else
89         prebuilt_shader_pci_id=no
90         AC_MSG_WARN([shader-db is not found at ($SHADERDB_PATH), ignoring prebuilt shaders])
91     fi
92 fi
93
94 AM_CONDITIONAL(ENABLE_PREBUILT_SHADER_BIN_ARRAY, test "x$prebuilt_shader_pci_id" != "xno")
95
96 # For linux
97 AC_ARG_ENABLE(linux-frontend,
98 AS_HELP_STRING([--enable-linux-frontend],
99 [Compile linux frontend (EXPERIMENTAL) @<:@default=no@:>@]),
100 [enable_linux_frontend="$enableval"],
101 [enable_linux_frontend=no])
102
103 AM_CONDITIONAL([ENABLE_LINUX_FRONTEND], [test "x$enable_linux_frontend" = "xyes"])
104
105 # For hotplug
106 AC_ARG_ENABLE(hotplug-support,
107   AS_HELP_STRING([--disable-hotplug-support],
108     [Disable Hot Plug Support.]),
109 [if test x$enableval = xyes; then
110   disable_hotplug_support=yes
111   AC_DEFINE(DISABLE_HOTPLUG_SUPPORT, 1, [Disable Hot Plug Support])
112 fi])
113
114 AM_CONDITIONAL(DISABLE_HOTPLUG_SUPPORT, test "x$disable_hotplug_support" = "xyes")
115
116 if test "x$disable_hotplug_support" = "xyes"; then
117     AC_MSG_RESULT([Hot Plug support is disabled.])
118   else
119     AC_MSG_RESULT([Hot Plug support is enabled.])
120 fi
121
122 # For json-c
123 AC_CONFIG_HEADER(tests/third_party/json-c/json_config.h)
124 AC_ARG_ENABLE(rdrand,
125   AS_HELP_STRING([--enable-rdrand],
126     [Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms.]),
127 [if test x$enableval = xyes; then
128   enable_rdrand=yes
129   AC_DEFINE(ENABLE_RDRAND, 1, [Enable RDRANR Hardware RNG Hash Seed])
130 fi])
131
132 if test "x$enable_rdrand" = "xyes"; then
133   AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed enabled on supported x86/x64 platforms])
134 else
135   AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed disabled. Use --enable-rdrand to enable])
136 fi
137
138 AM_PROG_CC_C_O
139 AC_PROG_CC_C99
140
141 AC_HEADER_STDC
142 AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h locale.h xlocale.h endian.h)
143 AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])])
144 AC_C_CONST
145 AC_TYPE_SIZE_T
146
147 AC_FUNC_VPRINTF
148 AC_FUNC_MEMCMP
149 AC_CHECK_FUNCS([realloc])
150 AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale uselocale)
151 AC_CHECK_DECLS([INFINITY], [], [], [[#include <math.h>]])
152 AC_CHECK_DECLS([nan], [], [], [[#include <math.h>]])
153 AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]])
154 AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]])
155 AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]])
156 AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]])
157
158 if test "$ac_cv_have_decl_isnan" = "yes" ; then
159   AC_TRY_LINK([#include <math.h>], [float f = 0.0; return isnan(f)], [], [LIBS="$LIBS -lm"])
160 fi
161
162 AC_LANG_PUSH([C])
163
164 AC_MSG_CHECKING([if .gnu.warning accepts long strings])
165 AC_LINK_IFELSE([AC_LANG_SOURCE([[
166 extern void json_object_get();
167 __asm__(".section .gnu.json_object_get,\n\t.ascii \"Please link against libjson-c instead of libjson\"\n\t.text");
168
169 int main(int c,char* v) {return 0;}
170 ]])], [
171   AC_DEFINE(HAS_GNU_WARNING_LONG, 1, [Define if .gnu.warning accepts long strings.])
172   AC_MSG_RESULT(yes)
173 ], [
174   AC_MSG_RESULT(no)
175 ])
176
177 AC_LANG_POP([C])
178
179 AC_ARG_ENABLE([Bsymbolic],
180                 [AS_HELP_STRING([--disable-Bsymbolic], [Avoid linking with -Bsymbolic-function])],
181                 [],
182                 [enable_Bsymbolic=check])
183
184 AS_IF([test "x$enable_Bsymbolic" = "xcheck"],
185         [
186         saved_LDFLAGS="${LDFLAGS}"
187         AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
188         LDFLAGS=-Wl,-Bsymbolic-functions
189         AC_TRY_LINK([], [int main (void) { return 0; }],
190                 [
191                         AC_MSG_RESULT([yes])
192                         enable_Bsymbolic=yes
193                 ],
194                 [
195                         AC_MSG_RESULT([no])
196                         enable_Bsymbolic=no
197                 ])
198         LDFLAGS="${saved_LDFLAGS}"
199 ])
200
201 AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions])
202 AC_SUBST(JSON_BSYMBOLIC_LDFLAGS)
203
204 AX_APPEND_COMPILE_FLAGS([-Wall -Wcast-qual -Wno-error=deprecated-declarations])
205 AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-string -Wno-unused-parameter])
206 AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE -D_REENTRANT])
207
208 AX_COMPILE_CHECK_SIZEOF(int)
209 AX_COMPILE_CHECK_SIZEOF(long)
210 AX_COMPILE_CHECK_SIZEOF(long long)
211 AX_COMPILE_CHECK_SIZEOF(size_t, [#include <stdint.h>])
212 # End of json-c
213 #######################################################################
214
215 PKG_CHECK_MODULES(DRM, [libdrm])
216 PKG_CHECK_MODULES(GBM, [gbm])
217 PKG_CHECK_MODULES(EGL, [egl])
218 PKG_CHECK_MODULES(GLES2, [glesv2])
219 PKG_CHECK_MODULES(LIBVA, [libva])
220 PKG_CHECK_MODULES(LIBVA_DRM, [libva-drm])
221
222 AC_ARG_ENABLE(git-hash,
223                 AS_HELP_STRING([--disable-git-hash],
224                         [Do not use git hash in version]),
225                         [git_hash=$enableval], [git_hash=yes])
226 AC_SUBST(GIT_HASH, [$git_hash])
227
228 AC_CONFIG_FILES([
229                 common/Makefile
230                 wsi/Makefile
231                 Makefile
232                 tests/third_party/json-c/Makefile
233                 tests/Makefile
234                 iahwc.pc
235                 ])
236 AC_OUTPUT
237
238 echo -e """\nEnabled options """
239
240 AC_MSG_RESULT([
241      Dummy compositor         $enable_dummy_compositor
242      Vulkan                   $enable_vulkan
243      Linux frontend           $enable_linux_frontend
244      Hotplug Support          $disable_hotplug_support
245      Prebuilt Shader Target   PCI-ID($prebuilt_shader_pci_id)
246 ])
247
248 # Test both compositors aren't enabled.
249 if [[ ! -z $enable_dummy_compositor ]] && [[ ! -z $enable_vulkan ]];
250 then
251     if test $enable_dummy_compositor = yes && test $enable_vulkan = yes; then
252         echo "Error:"
253         echo -e "\tOnly up to one compositor may be enabled at a time." 1>&2
254         exit 1
255     fi
256 fi