• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl Copyright © 2011-2014 Intel Corporation
2dnl Copyright © 2011-2014 Emil Velikov <emil.l.velikov@gmail.com>
3dnl Copyright © 2007-2010 Dan Nicholson
4dnl Copyright © 2010-2014 Marek Olšák <maraeo@gmail.com>
5dnl Copyright © 2010-2014 Christian König
6dnl Copyright © 2012-2014 Tom Stellard <tstellar@gmail.com>
7dnl Copyright © 2009-2012 Jakob Bornecrantz
8dnl Copyright © 2009-2014 Jon TURNEY
9dnl Copyright © 2011-2012 Benjamin Franzke
10dnl Copyright © 2008-2014 David Airlie
11dnl Copyright © 2009-2013 Brian Paul
12dnl
13dnl Permission is hereby granted, free of charge, to any person obtaining a
14dnl copy of this software and associated documentation files (the "Software"),
15dnl to deal in the Software without restriction, including without limitation
16dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
17dnl and/or sell copies of the Software, and to permit persons to whom the
18dnl Software is furnished to do so, subject to the following conditions:
19dnl
20dnl The above copyright notice and this permission notice (including the next
21dnl paragraph) shall be included in all copies or substantial portions of the
22dnl Software.
23dnl
24dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30dnl DEALINGS IN THE SOFTWARE.
31dnl
32dnl Process this file with autoconf to create configure.
33
34AC_PREREQ([2.60])
35
36dnl Tell the user about autoconf.html in the --help output
37m4_divert_once([HELP_END], [
38See docs/autoconf.html for more details on the options for Mesa.])
39
40m4_define(MESA_VERSION, m4_normalize(m4_include(VERSION)))
41AC_INIT([Mesa], [MESA_VERSION],
42    [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
43AC_CONFIG_AUX_DIR([bin])
44AC_CONFIG_MACRO_DIR([m4])
45AC_CANONICAL_SYSTEM
46AM_INIT_AUTOMAKE([foreign tar-ustar dist-xz subdir-objects])
47
48dnl We only support native Windows builds (MinGW/MSVC) through SCons.
49case "$host_os" in
50mingw*)
51    AC_MSG_ERROR([MinGW build not supported through autoconf/automake, use SCons instead])
52    ;;
53esac
54
55# Support silent build rules, requires at least automake-1.11. Disable
56# by either passing --disable-silent-rules to configure or passing V=1
57# to make
58m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
59    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
60
61m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
62
63dnl Set internal versions
64OSMESA_VERSION=8
65AC_SUBST([OSMESA_VERSION])
66OPENCL_VERSION=1
67AC_SUBST([OPENCL_VERSION])
68
69# The idea is that libdrm is distributed as one cohesive package, even
70# though it is composed of multiple libraries. However some drivers
71# may have different version requirements than others. This list
72# codifies which drivers need which version of libdrm. Any libdrm
73# version dependencies in non-driver-specific code should be reflected
74# in the first entry.
75LIBDRM_REQUIRED=2.4.75
76LIBDRM_RADEON_REQUIRED=2.4.71
77LIBDRM_AMDGPU_REQUIRED=2.4.89
78LIBDRM_INTEL_REQUIRED=2.4.75
79LIBDRM_NVVIEUX_REQUIRED=2.4.66
80LIBDRM_NOUVEAU_REQUIRED=2.4.66
81LIBDRM_FREEDRENO_REQUIRED=2.4.89
82LIBDRM_ETNAVIV_REQUIRED=2.4.82
83
84dnl Versions for external dependencies
85DRI2PROTO_REQUIRED=2.8
86GLPROTO_REQUIRED=1.4.14
87LIBOMXIL_BELLAGIO_REQUIRED=0.0
88LIBVA_REQUIRED=0.38.0
89VDPAU_REQUIRED=1.1
90WAYLAND_REQUIRED=1.11
91WAYLAND_PROTOCOLS_REQUIRED=1.8
92XCB_REQUIRED=1.9.3
93XCBDRI2_REQUIRED=1.8
94XCBGLX_REQUIRED=1.8.1
95XDAMAGE_REQUIRED=1.1
96XSHMFENCE_REQUIRED=1.1
97XVMC_REQUIRED=1.0.6
98PYTHON_MAKO_REQUIRED=0.8.0
99LIBSENSORS_REQUIRED=4.0.0
100ZLIB_REQUIRED=1.2.3
101
102dnl LLVM versions
103LLVM_REQUIRED_GALLIUM=3.3.0
104LLVM_REQUIRED_OPENCL=3.9.0
105LLVM_REQUIRED_R600=3.9.0
106LLVM_REQUIRED_RADEONSI=3.9.0
107LLVM_REQUIRED_RADV=3.9.0
108LLVM_REQUIRED_SWR=3.9.0
109
110dnl Check for progs
111AC_PROG_CPP
112AC_PROG_CC
113AC_PROG_CXX
114dnl add this here, so the help for this environmnet variable is close to
115dnl other CC/CXX flags related help
116AC_ARG_VAR([CXX11_CXXFLAGS], [Compiler flag to enable C++11 support (only needed if not
117                              enabled by default and different  from -std=c++11)])
118AM_PROG_CC_C_O
119AM_PROG_AS
120AX_CHECK_GNU_MAKE
121AC_CHECK_PROGS([PYTHON2], [python2.7 python2 python])
122AC_PROG_SED
123AC_PROG_MKDIR_P
124
125AC_SYS_LARGEFILE
126
127
128LT_PREREQ([2.2])
129LT_INIT([disable-static])
130
131AC_CHECK_PROG(RM, rm, [rm -f])
132
133AX_PROG_BISON([],
134              AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-parse.c"],
135                    [AC_MSG_ERROR([bison not found - unable to compile glcpp-parse.y])]))
136AX_PROG_FLEX([],
137             AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-lex.c"],
138                   [AC_MSG_ERROR([flex not found - unable to compile glcpp-lex.l])]))
139
140AC_CHECK_PROG(INDENT, indent, indent, cat)
141if test "x$INDENT" != "xcat"; then
142    # Only GNU indent is supported
143    INDENT_VERSION=`indent --version | grep GNU`
144    if test $? -eq 0; then
145       AC_SUBST(INDENT_FLAGS, '-i4 -nut -br -brs -npcs -ce -TGLubyte -TGLbyte -TBool')
146    else
147       INDENT="cat"
148    fi
149fi
150
151AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED)
152
153if test -z "$PYTHON2"; then
154    if test ! -f "$srcdir/src/util/format_srgb.c"; then
155        AC_MSG_ERROR([Python not found - unable to generate sources])
156    fi
157else
158    if test "x$acv_mako_found" = xno; then
159        if test ! -f "$srcdir/src/mesa/main/format_unpack.c"; then
160            AC_MSG_ERROR([Python mako module v$PYTHON_MAKO_REQUIRED or higher not found])
161        fi
162    fi
163fi
164
165AC_PROG_INSTALL
166
167dnl We need a POSIX shell for parts of the build. Assume we have one
168dnl in most cases.
169case "$host_os" in
170solaris*)
171    # Solaris /bin/sh is too old/non-POSIX compliant
172    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
173    SHELL="$POSIX_SHELL"
174    ;;
175esac
176
177dnl clang is mostly GCC-compatible, but its version is much lower,
178dnl so we have to check for it.
179AC_MSG_CHECKING([if compiling with clang])
180
181AC_COMPILE_IFELSE(
182[AC_LANG_PROGRAM([], [[
183#ifndef __clang__
184       not clang
185#endif
186]])],
187[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
188
189AC_MSG_RESULT([$acv_mesa_CLANG])
190
191dnl If we're using GCC, make sure that it is at least version 4.2.0.  Older
192dnl versions are explictly not supported.
193GEN_ASM_OFFSETS=no
194USE_GNU99=no
195if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
196    AC_MSG_CHECKING([whether gcc version is sufficient])
197    major=0
198    minor=0
199
200    GCC_VERSION=`$CC -dumpversion`
201    if test $? -eq 0; then
202        GCC_VERSION_MAJOR=`echo $GCC_VERSION | cut -d. -f1`
203        GCC_VERSION_MINOR=`echo $GCC_VERSION | cut -d. -f2`
204    fi
205
206    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 2 ; then
207        AC_MSG_RESULT([no])
208        AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
209    else
210        AC_MSG_RESULT([yes])
211    fi
212
213    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 6 ; then
214        USE_GNU99=yes
215    fi
216    if test "x$cross_compiling" = xyes; then
217        GEN_ASM_OFFSETS=yes
218    fi
219fi
220
221dnl We don't support building Mesa with Sun C compiler
222dnl https://bugs.freedesktop.org/show_bug.cgi?id=93189
223AC_CHECK_DECL([__SUNPRO_C], [SUNCC=yes], [SUNCC=no])
224if test "x$SUNCC" = xyes; then
225    AC_MSG_ERROR([Building with Sun C compiler is not supported, use GCC instead.])
226fi
227
228dnl Check for compiler builtins
229AX_GCC_BUILTIN([__builtin_bswap32])
230AX_GCC_BUILTIN([__builtin_bswap64])
231AX_GCC_BUILTIN([__builtin_clz])
232AX_GCC_BUILTIN([__builtin_clzll])
233AX_GCC_BUILTIN([__builtin_ctz])
234AX_GCC_BUILTIN([__builtin_expect])
235AX_GCC_BUILTIN([__builtin_ffs])
236AX_GCC_BUILTIN([__builtin_ffsll])
237AX_GCC_BUILTIN([__builtin_popcount])
238AX_GCC_BUILTIN([__builtin_popcountll])
239AX_GCC_BUILTIN([__builtin_unreachable])
240
241AX_GCC_FUNC_ATTRIBUTE([const])
242AX_GCC_FUNC_ATTRIBUTE([flatten])
243AX_GCC_FUNC_ATTRIBUTE([format])
244AX_GCC_FUNC_ATTRIBUTE([malloc])
245AX_GCC_FUNC_ATTRIBUTE([packed])
246AX_GCC_FUNC_ATTRIBUTE([pure])
247AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
248AX_GCC_FUNC_ATTRIBUTE([unused])
249AX_GCC_FUNC_ATTRIBUTE([visibility])
250AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
251AX_GCC_FUNC_ATTRIBUTE([weak])
252AX_GCC_FUNC_ATTRIBUTE([alias])
253AX_GCC_FUNC_ATTRIBUTE([noreturn])
254
255AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes)
256
257dnl Make sure the pkg-config macros are defined
258m4_ifndef([PKG_PROG_PKG_CONFIG],
259    [m4_fatal([Could not locate the pkg-config autoconf macros.
260  These are usually located in /usr/share/aclocal/pkg.m4. If your macros
261  are in a different location, try setting the environment variable
262  ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
263PKG_PROG_PKG_CONFIG()
264
265dnl LIB_DIR - library basename
266LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
267AC_SUBST([LIB_DIR])
268
269dnl Cache LDFLAGS and CPPFLAGS so we can add to them and restore later
270_SAVE_LDFLAGS="$LDFLAGS"
271_SAVE_CPPFLAGS="$CPPFLAGS"
272
273dnl Compiler macros
274DEFINES="-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
275AC_SUBST([DEFINES])
276android=no
277case "$host_os" in
278*-android*)
279    android=yes
280    ;;
281linux*|*-gnu*|gnu*|cygwin*)
282    DEFINES="$DEFINES -D_GNU_SOURCE"
283    ;;
284solaris*)
285    DEFINES="$DEFINES -DSVR4"
286    ;;
287esac
288
289AM_CONDITIONAL(HAVE_ANDROID, test "x$android" = xyes)
290
291dnl
292dnl Check compiler flags
293dnl
294AX_CHECK_COMPILE_FLAG([-Wall],                                 [CFLAGS="$CFLAGS -Wall"])
295AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration], [CFLAGS="$CFLAGS -Werror=implicit-function-declaration"])
296AX_CHECK_COMPILE_FLAG([-Werror=missing-prototypes],            [CFLAGS="$CFLAGS -Werror=missing-prototypes"])
297AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],                  [CFLAGS="$CFLAGS -Wmissing-prototypes"])
298AX_CHECK_COMPILE_FLAG([-fno-math-errno],                       [CFLAGS="$CFLAGS -fno-math-errno"])
299AX_CHECK_COMPILE_FLAG([-fno-trapping-math],                    [CFLAGS="$CFLAGS -fno-trapping-math"])
300AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],                   [VISIBILITY_CFLAGS="-fvisibility=hidden"])
301
302dnl
303dnl Check C++ compiler flags
304dnl
305AC_LANG_PUSH([C++])
306AX_CHECK_COMPILE_FLAG([-Wall],                                 [CXXFLAGS="$CXXFLAGS -Wall"])
307AX_CHECK_COMPILE_FLAG([-fno-math-errno],                       [CXXFLAGS="$CXXFLAGS -fno-math-errno"])
308AX_CHECK_COMPILE_FLAG([-fno-trapping-math],                    [CXXFLAGS="$CXXFLAGS -fno-trapping-math"])
309AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],                   [VISIBILITY_CXXFLAGS="-fvisibility=hidden"])
310AC_LANG_POP([C++])
311
312# Flags to help ensure that certain portions of the code -- and only those
313# portions -- can be built with MSVC:
314# - src/util, src/gallium/auxiliary, rc/gallium/drivers/llvmpipe, and
315# - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which
316#   supports most of C99)
317# - the rest has no compiler compiler restrictions
318AX_CHECK_COMPILE_FLAG([-Werror=pointer-arith],                 [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=pointer-arith"])
319AX_CHECK_COMPILE_FLAG([-Werror=vla],                           [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=vla"])
320AC_LANG_PUSH([C++])
321AX_CHECK_COMPILE_FLAG([-Werror=pointer-arith],                 [MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=pointer-arith"])
322AX_CHECK_COMPILE_FLAG([-Werror=vla],                           [MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=vla"])
323AC_LANG_POP([C++])
324
325AC_SUBST([MSVC2013_COMPAT_CFLAGS])
326AC_SUBST([MSVC2013_COMPAT_CXXFLAGS])
327
328if test "x$GCC" = xyes; then
329    if test "x$USE_GNU99" = xyes; then
330        CFLAGS="$CFLAGS -std=gnu99"
331    else
332        CFLAGS="$CFLAGS -std=c99"
333    fi
334fi
335
336dnl
337dnl Check whether C++11 is supported, if the environment variable
338dnl CXX11_CXXFLAGS is set it takes precedence.
339dnl
340
341AC_LANG_PUSH([C++])
342
343check_cxx11_available() {
344    output_support=$1
345    AC_COMPILE_IFELSE(
346        [AC_LANG_PROGRAM([
347             #if !(__cplusplus >= 201103L)
348             #error
349             #endif
350             #include <tuple>
351        ])
352    ], [
353         AC_MSG_RESULT(yes)
354         cxx11_support=yes
355    ], AC_MSG_RESULT(no))
356    eval "$output_support=\$cxx11_support"
357}
358
359HAVE_CXX11=no
360save_CXXFLAGS="$CXXFLAGS"
361
362dnl If the user provides a flag to enable c++11, then we test only this
363if test "x$CXX11_CXXFLAGS" != "x"; then
364   CXXFLAGS="$CXXFLAGS $CXX11_CXXFLAGS"
365   AC_MSG_CHECKING(whether c++11 is enabled by via $CXX11_CXXFLAGS)
366   check_cxx11_available HAVE_CXX11
367else
368   dnl test whether c++11 is enabled by default
369   AC_MSG_CHECKING(whether c++11 is enabled by default)
370   check_cxx11_available HAVE_CXX11
371
372   dnl C++11 not enabled by default, test whether -std=c++11 does the job
373   if test "x$HAVE_CXX11" != "xyes"; then
374       CXX11_CXXFLAGS=-std=c++11
375       CXXFLAGS="$CXXFLAGS $CXX11_CXXFLAGS"
376       AC_MSG_CHECKING(whether c++11 is enabled by via $CXX11_CXXFLAGS)
377       check_cxx11_available HAVE_CXX11
378   fi
379fi
380
381CXXFLAGS="$save_CXXFLAGS"
382AM_CONDITIONAL(HAVE_STD_CXX11, test "x$HAVE_CXX11" = "xyes")
383AC_SUBST(CXX11_CXXFLAGS)
384AC_LANG_POP([C++])
385
386dnl even if the compiler appears to support it, using visibility attributes isn't
387dnl going to do anything useful currently on cygwin apart from emit lots of warnings
388case "$host_os" in
389cygwin*)
390    VISIBILITY_CFLAGS=""
391    VISIBILITY_CXXFLAGS=""
392    ;;
393esac
394
395AC_SUBST([VISIBILITY_CFLAGS])
396AC_SUBST([VISIBILITY_CXXFLAGS])
397
398dnl For some reason, the test for -Wno-foo always succeeds with gcc, even if the
399dnl option is not supported. Hence, check for -Wfoo instead.
400AX_CHECK_COMPILE_FLAG([-Woverride-init],                    [WNO_OVERRIDE_INIT="$WNO_OVERRIDE_INIT -Wno-override-init"])         # gcc
401AX_CHECK_COMPILE_FLAG([-Winitializer-overrides],            [WNO_OVERRIDE_INIT="$WNO_OVERRIDE_INIT -Wno-initializer-overrides"]) # clang
402AC_SUBST([WNO_OVERRIDE_INIT])
403
404dnl
405dnl Optional flags, check for compiler support
406dnl
407SSE41_CFLAGS="-msse4.1"
408dnl Code compiled by GCC with -msse* assumes a 16 byte aligned
409dnl stack, but on x86-32 such alignment is not guaranteed.
410case "$target_cpu" in
411i?86)
412    SSE41_CFLAGS="$SSE41_CFLAGS -mstackrealign"
413    ;;
414esac
415save_CFLAGS="$CFLAGS"
416CFLAGS="$SSE41_CFLAGS $CFLAGS"
417AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
418#include <smmintrin.h>
419int param;
420int main () {
421    __m128i a = _mm_set1_epi32 (param), b = _mm_set1_epi32 (param + 1), c;
422    c = _mm_max_epu32(a, b);
423    return _mm_cvtsi128_si32(c);
424}]])], SSE41_SUPPORTED=1)
425CFLAGS="$save_CFLAGS"
426if test "x$SSE41_SUPPORTED" = x1; then
427    DEFINES="$DEFINES -DUSE_SSE41"
428fi
429AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
430AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS)
431
432dnl Check for new-style atomic builtins
433AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
434int main() {
435    int n;
436    return __atomic_load_n(&n, __ATOMIC_ACQUIRE);
437}]])], GCC_ATOMIC_BUILTINS_SUPPORTED=1)
438if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then
439    DEFINES="$DEFINES -DUSE_GCC_ATOMIC_BUILTINS"
440    dnl On some platforms, new-style atomics need a helper library
441    AC_MSG_CHECKING(whether -latomic is needed)
442    AC_LINK_IFELSE([AC_LANG_SOURCE([[
443    #include <stdint.h>
444    uint64_t v;
445    int main() {
446        return (int)__atomic_load_n(&v, __ATOMIC_ACQUIRE);
447    }]])], GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=no, GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=yes)
448    AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC)
449    if test "x$GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC" = xyes; then
450        LIBATOMIC_LIBS="-latomic"
451    fi
452fi
453AM_CONDITIONAL([GCC_ATOMIC_BUILTINS_SUPPORTED], [test x$GCC_ATOMIC_BUILTINS_SUPPORTED = x1])
454AC_SUBST([LIBATOMIC_LIBS])
455
456dnl Check if host supports 64-bit atomics
457dnl note that lack of support usually results in link (not compile) error
458AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported)
459AC_LINK_IFELSE([AC_LANG_SOURCE([[
460#include <stdint.h>
461uint64_t v;
462int main() {
463    return __sync_add_and_fetch(&v, (uint64_t)1);
464}]])], GCC_64BIT_ATOMICS_SUPPORTED=yes, GCC_64BIT_ATOMICS_SUPPORTED=no)
465if test "x$GCC_64BIT_ATOMICS_SUPPORTED" != xyes; then
466    DEFINES="$DEFINES -DMISSING_64BIT_ATOMICS"
467fi
468AC_MSG_RESULT($GCC_64BIT_ATOMICS_SUPPORTED)
469
470dnl Check for Endianness
471AC_C_BIGENDIAN(
472   little_endian=no,
473   little_endian=yes,
474   little_endian=no,
475   little_endian=no
476)
477
478dnl Check for POWER8 Architecture
479PWR8_CFLAGS="-mpower8-vector"
480have_pwr8_intrinsics=no
481AC_MSG_CHECKING(whether gcc supports -mpower8-vector)
482save_CFLAGS=$CFLAGS
483CFLAGS="$PWR8_CFLAGS $CFLAGS"
484AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
485#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
486#error "Need GCC >= 4.8 for sane POWER8 support"
487#endif
488#include <altivec.h>
489int main () {
490    vector unsigned char r;
491    vector unsigned int v = vec_splat_u32 (1);
492    r = __builtin_vec_vgbbd ((vector unsigned char) v);
493    return 0;
494}]])], have_pwr8_intrinsics=yes)
495CFLAGS=$save_CFLAGS
496
497AC_ARG_ENABLE(pwr8,
498   [AS_HELP_STRING([--disable-pwr8],
499                   [disable POWER8-specific instructions])],
500   [enable_pwr8=$enableval], [enable_pwr8=auto])
501
502if test "x$enable_pwr8" = xno ; then
503   have_pwr8_intrinsics=disabled
504fi
505
506if test $have_pwr8_intrinsics = yes && test $little_endian = yes ; then
507   DEFINES="$DEFINES -D_ARCH_PWR8"
508   CXXFLAGS="$CXXFLAGS $PWR8_CFLAGS"
509   CFLAGS="$CFLAGS $PWR8_CFLAGS"
510else
511   PWR8_CFLAGS=
512fi
513
514AC_MSG_RESULT($have_pwr8_intrinsics)
515if test "x$enable_pwr8" = xyes && test $have_pwr8_intrinsics = no ; then
516   AC_MSG_ERROR([POWER8 compiler support not detected])
517fi
518
519if test $have_pwr8_intrinsics = yes && test $little_endian = no ; then
520   AC_MSG_WARN([POWER8 optimization is enabled only on POWER8 Little-Endian])
521fi
522
523AC_SUBST([PWR8_CFLAGS], $PWR8_CFLAGS)
524
525dnl Can't have static and shared libraries, default to static if user
526dnl explicitly requested. If both disabled, set to static since shared
527dnl was explicitly requested.
528case "x$enable_static$enable_shared" in
529xyesyes)
530    AC_MSG_ERROR([Cannot enable both static and shared. Building using --enable-shared is strongly recommended])
531    ;;
532xnono)
533    AC_MSG_ERROR([Cannot disable both static and shared. Building using --enable-shared is strongly recommended])
534    ;;
535esac
536
537AM_CONDITIONAL(BUILD_SHARED, test "x$enable_shared" = xyes)
538
539dnl
540dnl other compiler options
541dnl
542AC_ARG_ENABLE([debug],
543    [AS_HELP_STRING([--enable-debug],
544        [use debug compiler flags and macros @<:@default=disabled@:>@])],
545    [enable_debug="$enableval"],
546    [enable_debug=no]
547)
548
549AC_ARG_ENABLE([profile],
550    [AS_HELP_STRING([--enable-profile],
551        [enable profiling of code @<:@default=disabled@:>@])],
552    [enable_profile="$enableval"],
553    [enable_profile=no]
554)
555
556AC_ARG_ENABLE([sanitize],
557    [AS_HELP_STRING([--enable-sanitize@<:@=address|undefined@:>@],
558        [enable code sanitizer @<:@default=disabled@:>@])],
559    [enable_sanitize="$enableval"],
560    [enable_sanitize=no])
561
562if test "x$enable_profile" = xyes; then
563    DEFINES="$DEFINES -DPROFILE"
564    if test "x$GCC" = xyes; then
565        CFLAGS="$CFLAGS -fno-omit-frame-pointer"
566    fi
567    if test "x$GXX" = xyes; then
568        CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer"
569    fi
570fi
571
572if test "x$enable_debug" = xyes; then
573    DEFINES="$DEFINES -DDEBUG"
574    if test "x$enable_profile" = xyes; then
575        AC_MSG_WARN([Debug and Profile are enabled at the same time])
576    fi
577    if test "x$GCC" = xyes; then
578        if ! echo "$CFLAGS" | grep -q -e '-g'; then
579            CFLAGS="$CFLAGS -g"
580        fi
581        if ! echo "$CFLAGS" | grep -q -e '-O'; then
582            CFLAGS="$CFLAGS -O0"
583        fi
584    fi
585    if test "x$GXX" = xyes; then
586        if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
587            CXXFLAGS="$CXXFLAGS -g"
588        fi
589        if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
590            CXXFLAGS="$CXXFLAGS -O0"
591        fi
592    fi
593else
594   DEFINES="$DEFINES -DNDEBUG"
595fi
596
597if test "x$enable_sanitize" != xno; then
598    if test "x$enable_profile" = xyes; then
599        AC_MSG_WARN([Sanitize and Profile are enabled at the same time])
600    fi
601
602    CFLAGS="$CFLAGS -fsanitize=$enable_sanitize"
603    CXXFLAGS="$CXXFLAGS -fsanitize=$enable_sanitize"
604    LDFLAGS="$LDFLAGS -fsanitize=$enable_sanitize"
605
606    AC_LINK_IFELSE(
607        [AC_LANG_SOURCE([int main(){return 0;}])],
608        [],
609        [AC_MSG_FAILURE([sanitize flags '$enable_sanitize' not supported])])
610fi
611
612dnl
613dnl Check if linker supports -Bsymbolic
614dnl
615save_LDFLAGS=$LDFLAGS
616LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
617AC_MSG_CHECKING([if ld supports -Bsymbolic])
618AC_LINK_IFELSE(
619    [AC_LANG_SOURCE([int main() { return 0;}])],
620    [AC_MSG_RESULT([yes])
621        BSYMBOLIC="-Wl,-Bsymbolic";],
622    [AC_MSG_RESULT([no])
623        BSYMBOLIC="";])
624LDFLAGS=$save_LDFLAGS
625
626AC_SUBST([BSYMBOLIC])
627
628dnl
629dnl Check if linker supports garbage collection
630dnl
631save_LDFLAGS=$LDFLAGS
632LDFLAGS="$LDFLAGS -Wl,--gc-sections"
633AC_MSG_CHECKING([whether ld supports --gc-sections])
634AC_LINK_IFELSE(
635    [AC_LANG_SOURCE([static char UnusedFunc() { return 5; } int main() { return 0;}])],
636    [AC_MSG_RESULT([yes])
637        GC_SECTIONS="-Wl,--gc-sections";],
638    [AC_MSG_RESULT([no])
639        GC_SECTIONS="";])
640LDFLAGS=$save_LDFLAGS
641
642AC_SUBST([GC_SECTIONS])
643
644dnl
645dnl OpenBSD does not have DT_NEEDED entries for libc by design
646dnl so when these flags are passed to ld via libtool the checks will fail
647dnl
648case "$host_os" in
649openbsd* | darwin* )
650    LD_NO_UNDEFINED="" ;;
651*)
652    if test "x$enable_sanitize" = xno; then
653        LD_NO_UNDEFINED="-Wl,--no-undefined"
654    else
655        LD_NO_UNDEFINED=""
656    fi
657    ;;
658esac
659
660AC_SUBST([LD_NO_UNDEFINED])
661
662dnl
663dnl Check if linker supports version scripts
664dnl
665AC_MSG_CHECKING([if the linker supports version-scripts])
666save_LDFLAGS=$LDFLAGS
667LDFLAGS="$LDFLAGS -Wl,--version-script=$srcdir/build-support/conftest.map"
668AC_LINK_IFELSE(
669    [AC_LANG_SOURCE([int main() { return 0;}])],
670    [have_ld_version_script=yes;AC_MSG_RESULT(yes)],
671    [have_ld_version_script=no; AC_MSG_RESULT(no)])
672LDFLAGS=$save_LDFLAGS
673AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
674
675dnl
676dnl Check if linker supports dynamic list files
677dnl
678AC_MSG_CHECKING([if the linker supports --dynamic-list])
679save_LDFLAGS=$LDFLAGS
680LDFLAGS="$LDFLAGS -Wl,--dynamic-list=$srcdir/build-support/conftest.dyn"
681AC_LINK_IFELSE(
682    [AC_LANG_SOURCE([int main() { return 0;}])],
683    [have_ld_dynamic_list=yes;AC_MSG_RESULT(yes)],
684    [have_ld_dynamic_list=no; AC_MSG_RESULT(no)])
685LDFLAGS=$save_LDFLAGS
686AM_CONDITIONAL(HAVE_LD_DYNAMIC_LIST, test "$have_ld_dynamic_list" = "yes")
687
688dnl
689dnl OSX linker does not support build-id
690dnl
691case "$host_os" in
692darwin*)
693    LD_BUILD_ID=""
694    ;;
695*)
696    LD_BUILD_ID="-Wl,--build-id=sha1"
697    ;;
698esac
699AC_SUBST([LD_BUILD_ID])
700
701dnl
702dnl compatibility symlinks
703dnl
704case "$host_os" in
705linux* )
706    HAVE_COMPAT_SYMLINKS=yes ;;
707* )
708    HAVE_COMPAT_SYMLINKS=no ;;
709esac
710
711AM_CONDITIONAL(HAVE_COMPAT_SYMLINKS, test "x$HAVE_COMPAT_SYMLINKS" = xyes)
712
713dnl
714dnl library names
715dnl
716dnl Unfortunately we need to do a few things that libtool can't help us with,
717dnl so we need some knowledge of shared library filenames:
718dnl
719dnl LIB_EXT is the extension used when creating symlinks for alternate
720dnl filenames for a shared library which will be dynamically loaded
721dnl
722dnl IMP_LIB_EXT is the extension used when checking for the presence of a
723dnl the file for a shared library we wish to link with
724dnl
725case "$host_os" in
726darwin* )
727    LIB_EXT='dylib'
728    IMP_LIB_EXT=$LIB_EXT
729    ;;
730cygwin* )
731    LIB_EXT='dll'
732    IMP_LIB_EXT='dll.a'
733    ;;
734aix* )
735    LIB_EXT='a'
736    IMP_LIB_EXT=$LIB_EXT
737    ;;
738* )
739    LIB_EXT='so'
740    IMP_LIB_EXT=$LIB_EXT
741    ;;
742esac
743
744AC_SUBST([LIB_EXT])
745
746dnl
747dnl potentially-infringing-but-nobody-knows-for-sure stuff
748dnl
749AC_ARG_ENABLE([texture-float],
750    [AS_HELP_STRING([--enable-texture-float],
751        [enable floating-point textures and renderbuffers @<:@default=disabled@:>@])],
752    [enable_texture_float="$enableval"],
753    [enable_texture_float=no]
754)
755if test "x$enable_texture_float" = xyes; then
756    AC_MSG_WARN([Floating-point textures enabled.])
757    AC_MSG_WARN([Please consult docs/patents.txt with your lawyer before building Mesa.])
758    DEFINES="$DEFINES -DTEXTURE_FLOAT_ENABLED"
759fi
760
761dnl
762dnl Arch/platform-specific settings
763dnl
764AC_ARG_ENABLE([asm],
765    [AS_HELP_STRING([--disable-asm],
766        [disable assembly usage @<:@default=enabled on supported platforms@:>@])],
767    [enable_asm="$enableval"],
768    [enable_asm=yes]
769)
770asm_arch=""
771AC_MSG_CHECKING([whether to enable assembly])
772test "x$enable_asm" = xno && AC_MSG_RESULT([no])
773# disable if cross compiling on x86/x86_64 since we must run gen_matypes
774if test "x$enable_asm" = xyes -a "x$cross_compiling" = xyes; then
775    case "$host_cpu" in
776    i?86 | x86_64 | amd64)
777        if test "x$host_cpu" != "x$target_cpu"; then
778            enable_asm=no
779            AC_MSG_RESULT([no, cross compiling])
780        fi
781        ;;
782    esac
783fi
784# check for supported arches
785if test "x$enable_asm" = xyes; then
786    case "$host_cpu" in
787    i?86)
788        case "$host_os" in
789        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | gnu*)
790            asm_arch=x86
791            ;;
792        esac
793        ;;
794    x86_64|amd64)
795        case "$host_os" in
796        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
797            asm_arch=x86_64
798            ;;
799        esac
800        ;;
801    sparc*)
802        case "$host_os" in
803        linux*)
804            asm_arch=sparc
805            ;;
806        esac
807        ;;
808    powerpc64le)
809        case "$host_os" in
810        linux*)
811            asm_arch=ppc64le
812            ;;
813        esac
814        ;;
815    aarch64)
816        case "$host_os" in
817        linux*)
818            asm_arch=aarch64
819            ;;
820        esac
821        ;;
822    arm)
823        case "$host_os" in
824        linux*)
825            asm_arch=arm
826            ;;
827        esac
828        ;;
829    esac
830
831    case "$asm_arch" in
832    x86)
833        DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
834        AC_MSG_RESULT([yes, x86])
835        ;;
836    x86_64|amd64)
837        DEFINES="$DEFINES -DUSE_X86_64_ASM"
838        AC_MSG_RESULT([yes, x86_64])
839        ;;
840    sparc)
841        DEFINES="$DEFINES -DUSE_SPARC_ASM"
842        AC_MSG_RESULT([yes, sparc])
843        ;;
844    ppc64le)
845        DEFINES="$DEFINES -DUSE_PPC64LE_ASM"
846        AC_MSG_RESULT([yes, ppc64le])
847        ;;
848    aarch64)
849        DEFINES="$DEFINES -DUSE_AARCH64_ASM"
850        AC_MSG_RESULT([yes, aarch64])
851        ;;
852    arm)
853        DEFINES="$DEFINES -DUSE_ARM_ASM"
854        AC_MSG_RESULT([yes, arm])
855        ;;
856    *)
857        AC_MSG_RESULT([no, platform not supported])
858        ;;
859    esac
860fi
861
862AC_HEADER_MAJOR
863AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
864AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
865AC_CHECK_HEADERS([endian.h])
866AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
867AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
868AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"])
869AC_CHECK_FUNC([memfd_create], [DEFINES="$DEFINES -DHAVE_MEMFD_CREATE"])
870
871AC_MSG_CHECKING([whether strtod has locale support])
872AC_LINK_IFELSE([AC_LANG_SOURCE([[
873    #define _GNU_SOURCE
874    #include <stdlib.h>
875    #include <locale.h>
876    #ifdef HAVE_XLOCALE_H
877    #include <xlocale.h>
878    #endif
879    int main() {
880       locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
881       const char *s = "1.0";
882       char *end;
883       double d = strtod_l(s, end, loc);
884       float f = strtof_l(s, end, loc);
885       freelocale(loc);
886       return 0;
887    }]])],
888  [DEFINES="$DEFINES -DHAVE_STRTOD_L"];
889   AC_MSG_RESULT([yes]),
890   AC_MSG_RESULT([no]))
891
892dnl Check to see if dlopen is in default libraries (like Solaris, which
893dnl has it in libc), or if libdl is needed to get it.
894AC_CHECK_FUNC([dlopen], [],
895    [AC_CHECK_LIB([dl], [dlopen],
896       [DLOPEN_LIBS="-ldl"])])
897AC_SUBST([DLOPEN_LIBS])
898
899dnl Check if that library also has dladdr
900save_LIBS="$LIBS"
901LIBS="$LIBS $DLOPEN_LIBS"
902AC_CHECK_FUNCS([dladdr])
903LIBS="$save_LIBS"
904
905AC_CHECK_FUNC([dl_iterate_phdr], [DEFINES="$DEFINES -DHAVE_DL_ITERATE_PHDR"])
906
907case "$host_os" in
908darwin*)
909    ;;
910*)
911    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
912                   [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
913                                 [AC_MSG_ERROR([Could not find clock_gettime])])])
914    AC_SUBST([CLOCK_LIB])
915    ;;
916esac
917
918dnl See if posix_memalign is available
919AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
920
921dnl Check for zlib
922PKG_CHECK_MODULES([ZLIB], [zlib >= $ZLIB_REQUIRED])
923DEFINES="$DEFINES -DHAVE_ZLIB"
924
925dnl Check for pthreads
926AX_PTHREAD
927if test "x$ax_pthread_ok" = xno; then
928    AC_MSG_ERROR([Building mesa on this platform requires pthreads])
929fi
930dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS
931dnl to -pthread, which causes problems if we need -lpthread to appear in
932dnl pkgconfig files.  Since Android doesn't have a pthread lib, this check
933dnl is not valid for that platform.
934if test "x$android" = xno; then
935    test -z "$PTHREAD_LIBS" && PTHREAD_LIBS="-lpthread"
936fi
937dnl According to the manual when using pthreads, one should add -pthread to
938dnl both compile and link-time arguments.
939dnl In practise that should be sufficient for all platforms, since any
940dnl platforms build with GCC and Clang support the flag.
941PTHREAD_LIBS="$PTHREAD_LIBS -pthread"
942
943dnl pthread-stubs is mandatory on some BSD platforms, due to the nature of the
944dnl project. Even then there's a notable issue as described in the project README
945case "$host_os" in
946linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu* | openbsd*)
947    pthread_stubs_possible="no"
948    ;;
949* )
950    pthread_stubs_possible="yes"
951    ;;
952esac
953
954if test "x$pthread_stubs_possible" = xyes; then
955    PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs >= 0.4)
956fi
957
958dnl Check for futex for fast inline simple_mtx_t.
959AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"])
960
961dnl SELinux awareness.
962AC_ARG_ENABLE([selinux],
963    [AS_HELP_STRING([--enable-selinux],
964        [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
965    [MESA_SELINUX="$enableval"],
966    [MESA_SELINUX=no])
967if test "x$enable_selinux" = "xyes"; then
968    PKG_CHECK_MODULES([SELINUX], [libselinux], [],
969        [AC_CHECK_HEADER([selinux/selinux.h],[],
970                         [AC_MSG_ERROR([SELinux headers not found])])
971         AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
972                      [AC_MSG_ERROR([SELinux library not found])])
973         SELINUX_LIBS="-lselinux"])
974    DEFINES="$DEFINES -DMESA_SELINUX"
975fi
976AC_SUBST([SELINUX_CFLAGS])
977AC_SUBST([SELINUX_LIBS])
978
979dnl
980dnl LLVM
981dnl
982AC_ARG_ENABLE([llvm-shared-libs],
983    [AS_HELP_STRING([--enable-llvm-shared-libs],
984        [link with LLVM shared libraries @<:@default=enabled@:>@])],
985    [enable_llvm_shared_libs="$enableval"],
986    [enable_llvm_shared_libs=yes])
987
988AC_ARG_WITH([llvm-prefix],
989    [AS_HELP_STRING([--with-llvm-prefix],
990        [Prefix for LLVM installations in non-standard locations])],
991    [llvm_prefix="$withval"],
992    [llvm_prefix=''])
993
994PKG_CHECK_MODULES([LIBELF], [libelf], [have_libelf=yes], [have_libelf=no])
995if test "x$have_libelf" = xno; then
996   LIBELF_LIBS=''
997   LIBELF_CFLAGS=''
998   AC_CHECK_LIB([elf], [elf_memory], [have_libelf=yes;LIBELF_LIBS=-lelf], [have_libelf=no])
999   AC_SUBST([LIBELF_LIBS])
1000   AC_SUBST([LIBELF_CFLAGS])
1001fi
1002
1003if test -z "$LLVM_CONFIG"; then
1004    if test -n "$llvm_prefix"; then
1005        AC_PATH_TOOL([LLVM_CONFIG], [llvm-config], [no], ["$llvm_prefix/bin"])
1006    else
1007        AC_PATH_TOOL([LLVM_CONFIG], [llvm-config], [no])
1008    fi
1009fi
1010
1011llvm_add_component() {
1012    new_llvm_component=$1
1013    driver_name=$2
1014
1015    if $LLVM_CONFIG --components | grep -iqw $new_llvm_component ; then
1016        LLVM_COMPONENTS="${LLVM_COMPONENTS} ${new_llvm_component}"
1017    else
1018        AC_MSG_ERROR([LLVM component '$new_llvm_component' not enabled in your LLVM build. Required by $driver_name.])
1019    fi
1020}
1021
1022llvm_add_optional_component() {
1023    new_llvm_component=$1
1024    driver_name=$2
1025
1026    if $LLVM_CONFIG --components | grep -iqw $new_llvm_component ; then
1027        LLVM_COMPONENTS="${LLVM_COMPONENTS} ${new_llvm_component}"
1028    fi
1029}
1030
1031llvm_add_default_components() {
1032    driver_name=$1
1033
1034    # Required default components
1035    llvm_add_component "bitwriter" $driver_name
1036    llvm_add_component "engine" $driver_name
1037    llvm_add_component "mcdisassembler" $driver_name
1038    llvm_add_component "mcjit" $driver_name
1039
1040    # Optional default components
1041    llvm_add_optional_component "inteljitevents" $driver_name
1042}
1043
1044llvm_add_target() {
1045    new_llvm_target=$1
1046    driver_name=$2
1047
1048    if $LLVM_CONFIG --targets-built | grep -iqw $new_llvm_target ; then
1049        llvm_add_component $new_llvm_target $driver_name
1050    else
1051        AC_MSG_ERROR([LLVM target '$new_llvm_target' not enabled in your LLVM build. Required by $driver_name.])
1052    fi
1053}
1054
1055# Call this inside ` ` to get the return value.
1056# $1 is the llvm-config command with arguments.
1057strip_unwanted_llvm_flags() {
1058    echo " `$1` " | sed -E \
1059        -e 's/[[[:space:]]]+-m[[^[:space:]]]*//g' \
1060        -e 's/[[[:space:]]]+-DNDEBUG[[[:space:]]]/ /g' \
1061        -e 's/[[[:space:]]]+-D_GNU_SOURCE[[[:space:]]]/ /g' \
1062        -e 's/[[[:space:]]]+-pedantic[[[:space:]]]/ /g' \
1063        -e 's/[[[:space:]]]+-W[[^[:space:]]]*//g' \
1064        -e 's/[[[:space:]]]+-O[[^[:space:]]]*//g' \
1065        -e 's/[[[:space:]]]+-g[[^[:space:]]]*//g' \
1066        -e 's/-fno-rtti[[[:space:]]]/-Fno-rtti /g' \
1067        -e 's/[[[:space:]]]+-f[[^[:space:]]]*//g' \
1068        -e 's/-Fno-rtti[[[:space:]]]/-fno-rtti /g' \
1069        -e 's/^[[[:space:]]]//' \
1070        -e 's/[[[:space:]]]$//'
1071}
1072
1073llvm_set_environment_variables() {
1074    if test "x$LLVM_CONFIG" != xno; then
1075        LLVM_VERSION=`$LLVM_CONFIG --version | egrep -o '^[[0-9.]]+'`
1076        LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"`
1077        LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir`
1078        LLVM_LIBDIR=`$LLVM_CONFIG --libdir`
1079
1080        # We need to respect LLVM_CPPFLAGS when compiling LLVM headers.
1081        save_CFLAGS="$CFLAGS"
1082        CFLAGS="$CFLAGS $LLVM_CPPFLAGS"
1083
1084        AC_COMPUTE_INT([LLVM_VERSION_MAJOR], [LLVM_VERSION_MAJOR],
1085            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
1086        AC_COMPUTE_INT([LLVM_VERSION_MINOR], [LLVM_VERSION_MINOR],
1087            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
1088        AC_COMPUTE_INT([LLVM_VERSION_PATCH], [LLVM_VERSION_PATCH],
1089            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
1090
1091        CFLAGS="$save_CFLAGS"
1092
1093        # Only needed for LLVM < 3.6.0
1094        if test -z "$LLVM_VERSION_PATCH"; then
1095            LLVM_VERSION_PATCH=0
1096        fi
1097
1098        LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}"
1099
1100        FOUND_LLVM=yes
1101    else
1102        FOUND_LLVM=no
1103        LLVM_VERSION_INT=0
1104    fi
1105}
1106
1107require_llvm() {
1108    if test "x$enable_llvm" != "xyes"; then
1109        AC_MSG_ERROR([--enable-llvm is required when building $1])
1110    fi
1111}
1112
1113llvm_require_version() {
1114    require_llvm $2
1115
1116    llvm_target_version_major=`echo $1 | cut -d. -f1 | egrep -o '^[[0-9]]+'`
1117    llvm_target_version_minor=`echo $1 | cut -d. -f2 | egrep -o '^[[0-9]]+'`
1118    llvm_target_version_patch=`echo $1 | cut -d. -f3 | egrep -o '^[[0-9]]+'`
1119
1120    if test "$LLVM_VERSION_MAJOR" -gt "$llvm_target_version_major"; then
1121        # major > required major
1122        #  --> OK
1123        return
1124    fi
1125
1126    if test "$LLVM_VERSION_MAJOR" -eq "$llvm_target_version_major"; then
1127        if test "$LLVM_VERSION_MINOR" -gt "$llvm_target_version_minor"; then
1128            # major = required major and
1129            # minor > required minor
1130            #  --> OK
1131            return
1132        else
1133            if test "$LLVM_VERSION_MINOR" -eq "$llvm_target_version_minor"; then
1134                if test "$LLVM_VERSION_PATCH" -ge "$llvm_target_version_patch"; then
1135                    # major = required major and
1136                    # minor = required minor and
1137                    # patch >= required patch
1138                    #  --> OK
1139                    return
1140                fi
1141            fi
1142        fi
1143    fi
1144
1145    AC_MSG_ERROR([LLVM $1 or newer is required for $2])
1146}
1147
1148radeon_llvm_check() {
1149    if test ${LLVM_VERSION_INT} -lt 307; then
1150        amdgpu_llvm_target_name='r600'
1151    else
1152        amdgpu_llvm_target_name='amdgpu'
1153    fi
1154
1155    llvm_require_version $*
1156
1157    llvm_add_target $amdgpu_llvm_target_name $2
1158
1159    llvm_add_default_components $2
1160    llvm_add_component "bitreader" $2
1161    llvm_add_component "ipo" $2
1162
1163    if test "x$have_libelf" != xyes; then
1164       AC_MSG_ERROR([$2 requires libelf when using llvm])
1165    fi
1166}
1167
1168llvm_set_environment_variables
1169
1170AC_SUBST([LLVM_CFLAGS])
1171AC_SUBST([LLVM_CXXFLAGS])
1172AC_SUBST([LLVM_LIBS])
1173AC_SUBST([LLVM_LDFLAGS])
1174AC_SUBST([LLVM_INCLUDEDIR])
1175
1176dnl
1177dnl libunwind
1178dnl
1179PKG_CHECK_EXISTS(libunwind, [HAVE_LIBUNWIND=yes], [HAVE_LIBUNWIND=no])
1180AC_ARG_ENABLE([libunwind],
1181    [AS_HELP_STRING([--enable-libunwind],
1182            [Use libunwind for backtracing (default: auto)])],
1183        [LIBUNWIND="$enableval"],
1184        [LIBUNWIND="$HAVE_LIBUNWIND"])
1185
1186if test "x$LIBUNWIND" = "xyes"; then
1187    PKG_CHECK_MODULES(LIBUNWIND, libunwind)
1188    AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
1189fi
1190
1191
1192dnl Options for APIs
1193AC_ARG_ENABLE([opengl],
1194    [AS_HELP_STRING([--disable-opengl],
1195        [disable support for standard OpenGL API @<:@default=enabled@:>@])],
1196    [enable_opengl="$enableval"],
1197    [enable_opengl=yes])
1198AC_ARG_ENABLE([gles1],
1199    [AS_HELP_STRING([--disable-gles1],
1200        [disable support for OpenGL ES 1.x API @<:@default=enabled@:>@])],
1201    [enable_gles1="$enableval"],
1202    [enable_gles1=yes])
1203AC_ARG_ENABLE([gles2],
1204    [AS_HELP_STRING([--disable-gles2],
1205        [disable support for OpenGL ES 2.x API @<:@default=enabled@:>@])],
1206    [enable_gles2="$enableval"],
1207    [enable_gles2=yes])
1208
1209AC_ARG_ENABLE([dri],
1210    [AS_HELP_STRING([--enable-dri],
1211        [enable DRI modules @<:@default=enabled@:>@])],
1212    [enable_dri="$enableval"],
1213    [enable_dri=yes])
1214
1215AC_ARG_ENABLE([gallium-extra-hud],
1216    [AS_HELP_STRING([--enable-gallium-extra-hud],
1217        [enable HUD block/NIC I/O HUD stats support @<:@default=disabled@:>@])],
1218    [enable_gallium_extra_hud="$enableval"],
1219    [enable_gallium_extra_hud=no])
1220AM_CONDITIONAL(HAVE_GALLIUM_EXTRA_HUD, test "x$enable_gallium_extra_hud" = xyes)
1221if test "x$enable_gallium_extra_hud" = xyes ; then
1222    DEFINES="${DEFINES} -DHAVE_GALLIUM_EXTRA_HUD=1"
1223fi
1224
1225#TODO: no pkgconfig .pc available for libsensors.
1226#PKG_CHECK_MODULES([LIBSENSORS], [libsensors >= $LIBSENSORS_REQUIRED], [enable_lmsensors=yes], [enable_lmsensors=no])
1227AC_ARG_ENABLE([lmsensors],
1228    [AS_HELP_STRING([--enable-lmsensors],
1229        [enable HUD lmsensor support @<:@default=disabled@:>@])],
1230    [enable_lmsensors="$enableval"],
1231    [enable_lmsensors=no])
1232AM_CONDITIONAL(HAVE_LIBSENSORS, test "x$enable_lmsensors" = xyes)
1233if test "x$enable_lmsensors" = xyes ; then
1234    DEFINES="${DEFINES} -DHAVE_LIBSENSORS=1"
1235    LIBSENSORS_LIBS="-lsensors"
1236else
1237    LIBSENSORS_LIBS=""
1238fi
1239AC_SUBST(LIBSENSORS_LIBS)
1240
1241case "$host_os" in
1242linux*)
1243    dri3_default=yes
1244    ;;
1245*)
1246    dri3_default=no
1247    ;;
1248esac
1249
1250if test "x$enable_dri" = xno; then
1251    dri3_default=no
1252fi
1253
1254AC_ARG_ENABLE([dri3],
1255    [AS_HELP_STRING([--enable-dri3],
1256        [enable DRI3 @<:@default=auto@:>@])],
1257    [enable_dri3="$enableval"],
1258    [enable_dri3="$dri3_default"])
1259AC_ARG_ENABLE([glx],
1260    [AS_HELP_STRING([--enable-glx@<:@=dri|xlib|gallium-xlib@:>@],
1261        [enable the GLX library and choose an implementation @<:@default=auto@:>@])],
1262    [enable_glx="$enableval"],
1263    [enable_glx=yes])
1264AC_ARG_ENABLE([osmesa],
1265    [AS_HELP_STRING([--enable-osmesa],
1266        [enable OSMesa library @<:@default=disabled@:>@])],
1267    [enable_osmesa="$enableval"],
1268    [enable_osmesa=no])
1269AC_ARG_ENABLE([gallium-osmesa],
1270    [AS_HELP_STRING([--enable-gallium-osmesa],
1271        [enable Gallium implementation of the OSMesa library @<:@default=disabled@:>@])],
1272    [enable_gallium_osmesa="$enableval"],
1273    [enable_gallium_osmesa=no])
1274AC_ARG_ENABLE([egl],
1275    [AS_HELP_STRING([--disable-egl],
1276        [disable EGL library @<:@default=enabled@:>@])],
1277    [enable_egl="$enableval"],
1278    [enable_egl=yes])
1279
1280AC_ARG_ENABLE([xa],
1281    [AS_HELP_STRING([--enable-xa],
1282        [enable build of the XA X Acceleration API @<:@default=disabled@:>@])],
1283    [enable_xa="$enableval"],
1284    [enable_xa=no])
1285AC_ARG_ENABLE([gbm],
1286   [AS_HELP_STRING([--enable-gbm],
1287         [enable gbm library @<:@default=yes except cygwin and macOS@:>@])],
1288   [enable_gbm="$enableval"],
1289   [case "$host_os" in
1290       cygwin* | darwin*)
1291          enable_gbm=no
1292          ;;
1293       *)
1294          enable_gbm=yes
1295          ;;
1296    esac])
1297AC_ARG_ENABLE([nine],
1298    [AS_HELP_STRING([--enable-nine],
1299        [enable build of the nine Direct3D9 API @<:@default=no@:>@])],
1300    [enable_nine="$enableval"],
1301    [enable_nine=no])
1302
1303AC_ARG_ENABLE([xvmc],
1304   [AS_HELP_STRING([--enable-xvmc],
1305         [enable xvmc library @<:@default=auto@:>@])],
1306   [enable_xvmc="$enableval"],
1307   [enable_xvmc=auto])
1308AC_ARG_ENABLE([vdpau],
1309   [AS_HELP_STRING([--enable-vdpau],
1310         [enable vdpau library @<:@default=auto@:>@])],
1311   [enable_vdpau="$enableval"],
1312   [enable_vdpau=auto])
1313AC_ARG_ENABLE([omx],
1314   [AS_HELP_STRING([--enable-omx],
1315         [DEPRECATED: Use --enable-omx-bellagio instead @<:@default=auto@:>@])],
1316   [AC_MSG_ERROR([--enable-omx is deprecated. Use --enable-omx-bellagio instead.])],
1317   [])
1318AC_ARG_ENABLE([omx-bellagio],
1319   [AS_HELP_STRING([--enable-omx-bellagio],
1320         [enable OpenMAX Bellagio library @<:@default=disabled@:>@])],
1321   [enable_omx_bellagio="$enableval"],
1322   [enable_omx_bellagio=no])
1323AC_ARG_ENABLE([va],
1324   [AS_HELP_STRING([--enable-va],
1325         [enable va library @<:@default=auto@:>@])],
1326   [enable_va="$enableval"],
1327   [enable_va=auto])
1328AC_ARG_ENABLE([opencl],
1329   [AS_HELP_STRING([--enable-opencl],
1330         [enable OpenCL library @<:@default=disabled@:>@])],
1331   [enable_opencl="$enableval"],
1332   [enable_opencl=no])
1333AC_ARG_ENABLE([opencl_icd],
1334   [AS_HELP_STRING([--enable-opencl-icd],
1335          [Build an OpenCL ICD library to be loaded by an ICD implementation
1336           @<:@default=enabled@:>@])],
1337    [enable_opencl_icd="$enableval"],
1338    [enable_opencl_icd=yes])
1339
1340AC_ARG_ENABLE([gallium-tests],
1341    [AS_HELP_STRING([--enable-gallium-tests],
1342        [Enable optional Gallium tests) @<:@default=disabled@:>@])],
1343    [enable_gallium_tests="$enableval"],
1344    [enable_gallium_tests=no])
1345
1346# Option for Gallium drivers
1347
1348# Keep this in sync with the --with-gallium-drivers help string default value
1349GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
1350
1351AC_ARG_WITH([gallium-drivers],
1352    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
1353        [comma delimited Gallium drivers list, e.g.
1354        "i915,nouveau,r300,r600,radeonsi,freedreno,pl111,svga,swrast,swr,vc4,vc5,virgl,etnaviv,imx"
1355        @<:@default=r300,r600,svga,swrast@:>@])],
1356    [with_gallium_drivers="$withval"],
1357    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
1358
1359# Doing '--without-gallium-drivers' will set this variable to 'no'.  Clear it
1360# here so that the script doesn't choke on an unknown driver name later.
1361case "$with_gallium_drivers" in
1362    yes) with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT" ;;
1363    no) with_gallium_drivers='' ;;
1364esac
1365
1366if test "x$enable_opengl" = xno -a \
1367        "x$enable_gles1" = xno -a \
1368        "x$enable_gles2" = xno -a \
1369        "x$enable_nine" = xno -a \
1370        "x$enable_xa" = xno -a \
1371        "x$enable_xvmc" = xno -a \
1372        "x$enable_vdpau" = xno -a \
1373        "x$enable_omx_bellagio" = xno -a \
1374        "x$enable_va" = xno -a \
1375        "x$enable_opencl" = xno; then
1376    AC_MSG_ERROR([at least one API should be enabled])
1377fi
1378
1379# Building OpenGL ES1 and/or ES2 without OpenGL is not supported on mesa 9.0.x
1380if test "x$enable_opengl" = xno -a \
1381        "x$enable_gles1" = xyes; then
1382    AC_MSG_ERROR([Building OpenGL ES1 without OpenGL is not supported])
1383fi
1384
1385if test "x$enable_opengl" = xno -a \
1386        "x$enable_gles2" = xyes; then
1387    AC_MSG_ERROR([Building OpenGL ES2 without OpenGL is not supported])
1388fi
1389
1390AM_CONDITIONAL(HAVE_OPENGL, test "x$enable_opengl" = xyes)
1391AM_CONDITIONAL(HAVE_OPENGL_ES1, test "x$enable_gles1" = xyes)
1392AM_CONDITIONAL(HAVE_OPENGL_ES2, test "x$enable_gles2" = xyes)
1393AM_CONDITIONAL(NEED_OPENGL_COMMON, test "x$enable_opengl" = xyes -o \
1394                                        "x$enable_gles1" = xyes -o \
1395                                        "x$enable_gles2" = xyes)
1396AM_CONDITIONAL(NEED_KHRPLATFORM, test "x$enable_egl" = xyes -o \
1397                                      "x$enable_gles1" = xyes -o \
1398                                      "x$enable_gles2" = xyes)
1399
1400# Validate GLX options
1401if test "x$enable_glx" = xyes; then
1402    if test "x$enable_dri" = xyes; then
1403        enable_glx=dri
1404    elif test -n "$with_gallium_drivers"; then
1405        enable_glx=gallium-xlib
1406    else
1407        enable_glx=xlib
1408    fi
1409fi
1410case "x$enable_glx" in
1411xdri | xxlib | xgallium-xlib)
1412    # GLX requires OpenGL
1413    if test "x$enable_opengl" = xno; then
1414        AC_MSG_ERROR([GLX cannot be built without OpenGL])
1415    fi
1416
1417    # Check individual dependencies
1418    case "x$enable_glx" in
1419    xdri)
1420        if test "x$enable_dri" = xno; then
1421            AC_MSG_ERROR([DRI-based GLX requires DRI to be enabled])
1422        fi
1423        ;;
1424    xxlib)
1425        if test "x$enable_dri" = xyes; then
1426            AC_MSG_ERROR([Xlib-based GLX cannot be built with DRI enabled])
1427        fi
1428        ;;
1429    xgallium-xlib )
1430        if test "x$enable_dri" = xyes; then
1431            AC_MSG_ERROR([Xlib-based (Gallium) GLX cannot be built with DRI enabled])
1432        fi
1433        if test -z "$with_gallium_drivers"; then
1434            AC_MSG_ERROR([Xlib-based (Gallium) GLX cannot be built without Gallium enabled])
1435        fi
1436        ;;
1437    esac
1438    ;;
1439xno)
1440    ;;
1441*)
1442    AC_MSG_ERROR([Illegal value for --enable-glx: $enable_glx])
1443    ;;
1444esac
1445
1446AM_CONDITIONAL(HAVE_GLX, test "x$enable_glx" != xno)
1447AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xdri)
1448AM_CONDITIONAL(HAVE_XLIB_GLX, test "x$enable_glx" = xxlib)
1449AM_CONDITIONAL(HAVE_GALLIUM_XLIB_GLX, test "x$enable_glx" = xgallium-xlib)
1450
1451DEFAULT_GL_LIB_NAME=GL
1452
1453dnl
1454dnl Libglvnd configuration
1455dnl
1456AC_ARG_ENABLE([libglvnd],
1457    [AS_HELP_STRING([--enable-libglvnd],
1458        [Build GLX and EGL for libglvnd @<:@default=disabled@:>@])],
1459    [enable_libglvnd="$enableval"],
1460    [enable_libglvnd=no])
1461AM_CONDITIONAL(USE_LIBGLVND, test "x$enable_libglvnd" = xyes)
1462
1463if test "x$enable_libglvnd" = xyes ; then
1464    case "x$enable_glx" in
1465    xxlib | xgallium-xlib )
1466        AC_MSG_ERROR([cannot build libgvnd when Xlib-GLX or Gallium-Xlib-GLX is enabled])
1467        ;;
1468    esac
1469
1470    PKG_CHECK_MODULES([GLVND], libglvnd >= 0.2.0)
1471    LIBGLVND_DATADIR=`$PKG_CONFIG --variable=datadir libglvnd`
1472    AC_SUBST([LIBGLVND_DATADIR])
1473
1474    DEFINES="${DEFINES} -DUSE_LIBGLVND=1"
1475    DEFAULT_GL_LIB_NAME=GLX_mesa
1476
1477    if test "x$enable_glx" = xno -a "x$enable_egl" = xno; then
1478        AC_MSG_ERROR([cannot build libglvnd without GLX or EGL])
1479    fi
1480fi
1481
1482AC_ARG_WITH([gl-lib-name],
1483  [AS_HELP_STRING([--with-gl-lib-name@<:@=NAME@:>@],
1484    [specify GL library name @<:@default=GL@:>@])],
1485  [GL_LIB=$withval],
1486  [GL_LIB="$DEFAULT_GL_LIB_NAME"])
1487AC_ARG_WITH([osmesa-lib-name],
1488  [AS_HELP_STRING([--with-osmesa-lib-name@<:@=NAME@:>@],
1489    [specify OSMesa library name @<:@default=OSMesa@:>@])],
1490  [OSMESA_LIB=$withval],
1491  [OSMESA_LIB=OSMesa])
1492AS_IF([test "x$GL_LIB" = xyes], [GL_LIB="$DEFAULT_GL_LIB_NAME"])
1493AS_IF([test "x$OSMESA_LIB" = xyes], [OSMESA_LIB=OSMesa])
1494
1495dnl
1496dnl Mangled Mesa support
1497dnl
1498AC_ARG_ENABLE([mangling],
1499  [AS_HELP_STRING([--enable-mangling],
1500    [enable mangled symbols and library name @<:@default=disabled@:>@])],
1501  [enable_mangling="${enableval}"],
1502  [enable_mangling=no]
1503)
1504if test "x${enable_mangling}" = "xyes" ; then
1505  DEFINES="${DEFINES} -DUSE_MGL_NAMESPACE"
1506  GL_LIB="Mangled${GL_LIB}"
1507  OSMESA_LIB="Mangled${OSMESA_LIB}"
1508fi
1509AC_SUBST([GL_LIB])
1510AC_SUBST([OSMESA_LIB])
1511
1512# Check for libdrm
1513PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
1514                  [have_libdrm=yes], [have_libdrm=no])
1515if test "x$have_libdrm" = xyes; then
1516    DEFINES="$DEFINES -DHAVE_LIBDRM"
1517fi
1518
1519require_libdrm() {
1520    if test "x$have_libdrm" != xyes; then
1521       AC_MSG_ERROR([$1 requires libdrm >= $LIBDRM_REQUIRED])
1522    fi
1523}
1524
1525
1526# Select which platform-dependent DRI code gets built
1527case "$host_os" in
1528darwin*)
1529    dri_platform='apple' ;;
1530cygwin*)
1531    dri_platform='windows' ;;
1532gnu*)
1533    dri_platform='none' ;;
1534*)
1535    dri_platform='drm' ;;
1536esac
1537
1538if test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes; then
1539    have_drisw_kms='yes'
1540fi
1541
1542AM_CONDITIONAL(HAVE_DRICOMMON, test "x$enable_dri" = xyes )
1543AM_CONDITIONAL(HAVE_DRISW, test "x$enable_dri" = xyes )
1544AM_CONDITIONAL(HAVE_DRISW_KMS, test "x$have_drisw_kms" = xyes )
1545AM_CONDITIONAL(HAVE_DRI2, test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes )
1546AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes )
1547AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xapple )
1548AM_CONDITIONAL(HAVE_LMSENSORS, test "x$enable_lmsensors" = xyes )
1549AM_CONDITIONAL(HAVE_GALLIUM_EXTRA_HUD, test "x$enable_gallium_extra_hud" = xyes )
1550AM_CONDITIONAL(HAVE_WINDOWSDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xwindows )
1551
1552AC_ARG_ENABLE([shared-glapi],
1553    [AS_HELP_STRING([--enable-shared-glapi],
1554        [Enable shared glapi for OpenGL @<:@default=enabled@:>@])],
1555    [enable_shared_glapi="$enableval"],
1556    [enable_shared_glapi=yes])
1557
1558case "x$enable_opengl$enable_gles1$enable_gles2" in
1559x*yes*yes*)
1560    if test "x$enable_shared_glapi" = xno; then
1561        AC_MSG_ERROR([shared GLAPI required when building two or more of
1562                      the following APIs - opengl, gles1 gles2])
1563    fi
1564    ;;
1565esac
1566
1567AM_CONDITIONAL(HAVE_SHARED_GLAPI, test "x$enable_shared_glapi" = xyes)
1568
1569# Build the pipe-drivers as separate libraries/modules.
1570# Do not touch this unless you know what you are doing.
1571# XXX: Expose via configure option ?
1572enable_shared_pipe_drivers=no
1573
1574dnl
1575dnl Driver specific build directories
1576dnl
1577
1578if test "x$enable_gallium_osmesa" = xyes; then
1579    if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
1580        AC_MSG_ERROR([gallium_osmesa requires the gallium swrast driver])
1581    fi
1582    if test "x$enable_osmesa" = xyes; then
1583        AC_MSG_ERROR([Cannot enable both classic and Gallium OSMesa implementations])
1584    fi
1585fi
1586
1587require_dri_shared_libs_and_glapi() {
1588    if test "x$enable_static" = xyes; then
1589        AC_MSG_ERROR([$1 cannot be build as static library])
1590    fi
1591
1592    if test "x$enable_dri" != xyes; then
1593        # There is only a single backend which won't be build/used otherwise.
1594        # XXX: Revisit this as the egl/haiku is a thing.
1595        AC_MSG_ERROR([$1 requires --enable-dri])
1596    fi
1597
1598    if test "x$enable_shared_glapi" != xyes; then
1599        AC_MSG_ERROR([$1 requires --enable-shared-glapi])
1600    fi
1601}
1602
1603if test "x$enable_dri" = xyes; then
1604    require_dri_shared_libs_and_glapi "DRI"
1605
1606    # not a hard requirement as swrast does not depend on it
1607    if test "x$have_libdrm" = xyes; then
1608        DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
1609    fi
1610fi
1611
1612AC_ARG_ENABLE([driglx-direct],
1613    [AS_HELP_STRING([--disable-driglx-direct],
1614        [disable direct rendering in GLX and EGL for DRI \
1615            @<:@default=enabled@:>@])],
1616    [driglx_direct="$enableval"],
1617    [driglx_direct="yes"])
1618
1619dnl
1620dnl libGL configuration per driver
1621dnl
1622if test "x$enable_glx" != xno; then
1623    PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
1624fi
1625case "x$enable_glx" in
1626xxlib | xgallium-xlib)
1627    # Xlib-based GLX
1628    dri_modules="x11 xext xcb"
1629    PKG_CHECK_MODULES([XLIBGL], [$dri_modules])
1630    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
1631    X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
1632    GL_LIB_DEPS="$XLIBGL_LIBS"
1633    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
1634    GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm $PTHREAD_LIBS"
1635    ;;
1636xdri)
1637    # DRI-based GLX
1638
1639    # find the DRI deps for libGL
1640    dri_modules="x11 xext xdamage >= $XDAMAGE_REQUIRED xfixes x11-xcb xcb xcb-glx >= $XCBGLX_REQUIRED"
1641
1642    if test x"$driglx_direct" = xyes; then
1643        if test x"$dri_platform" = xdrm ; then
1644            DEFINES="$DEFINES -DGLX_USE_DRM"
1645            require_libdrm "Direct rendering"
1646
1647            PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
1648            GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV libdrm >= $LIBDRM_REQUIRED"
1649
1650            if test x"$enable_dri" = xyes; then
1651               dri_modules="$dri_modules xcb-dri2 >= $XCBDRI2_REQUIRED"
1652            fi
1653        fi
1654        if test x"$dri_platform" = xapple ; then
1655            DEFINES="$DEFINES -DGLX_USE_APPLEGL"
1656        fi
1657        if test x"$dri_platform" = xwindows ; then
1658            DEFINES="$DEFINES -DGLX_USE_WINDOWSGL"
1659        fi
1660    fi
1661
1662    # add xf86vidmode if available
1663    PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no)
1664    if test "$HAVE_XF86VIDMODE" = yes ; then
1665        dri_modules="$dri_modules xxf86vm"
1666    fi
1667
1668    PKG_CHECK_MODULES([DRIGL], [$dri_modules])
1669    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
1670    X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
1671    GL_LIB_DEPS="$DRIGL_LIBS"
1672
1673    # need DRM libs, $PTHREAD_LIBS, etc.
1674    GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
1675    GL_PC_LIB_PRIV="-lm $PTHREAD_LIBS $DLOPEN_LIBS"
1676    ;;
1677esac
1678
1679# This is outside the case (above) so that it is invoked even for non-GLX
1680# builds.
1681AM_CONDITIONAL(HAVE_XF86VIDMODE, test "x$HAVE_XF86VIDMODE" = xyes)
1682
1683GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
1684GLESv1_CM_PC_LIB_PRIV="-lm $PTHREAD_LIBS $DLOPEN_LIBS"
1685GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
1686GLESv2_PC_LIB_PRIV="-lm $PTHREAD_LIBS $DLOPEN_LIBS"
1687
1688AC_SUBST([X11_INCLUDES])
1689AC_SUBST([GL_LIB_DEPS])
1690AC_SUBST([GL_PC_REQ_PRIV])
1691AC_SUBST([GL_PC_LIB_PRIV])
1692AC_SUBST([GL_PC_CFLAGS])
1693AC_SUBST([DRI_PC_REQ_PRIV])
1694AC_SUBST([GLESv1_CM_LIB_DEPS])
1695AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
1696AC_SUBST([GLESv2_LIB_DEPS])
1697AC_SUBST([GLESv2_PC_LIB_PRIV])
1698
1699AC_SUBST([HAVE_XF86VIDMODE])
1700
1701dnl
1702dnl More GLX setup
1703dnl
1704case "x$enable_glx" in
1705xxlib | xgallium-xlib)
1706    DEFINES="$DEFINES -DUSE_XSHM"
1707    ;;
1708xdri)
1709    DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
1710    if test "x$driglx_direct" = xyes; then
1711        DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
1712    fi
1713    ;;
1714esac
1715
1716dnl
1717dnl TLS detection
1718dnl
1719
1720AC_ARG_ENABLE([glx-tls],
1721    [AS_HELP_STRING([--enable-glx-tls],
1722        [enable TLS support in GLX @<:@default=enabled@:>@])],
1723    [GLX_USE_TLS="$enableval"],
1724    [GLX_USE_TLS=yes])
1725AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
1726
1727if test "x$GLX_USE_TLS" = xyes; then
1728    DEFINES="$DEFINES -DGLX_USE_TLS"
1729fi
1730
1731dnl Read-only text section on x86 hardened platforms
1732AC_ARG_ENABLE([glx-read-only-text],
1733    [AS_HELP_STRING([--enable-glx-read-only-text],
1734        [Disable writable .text section on x86 (decreases performance) @<:@default=disabled@:>@])],
1735    [enable_glx_read_only_text="$enableval"],
1736    [enable_glx_read_only_text=no])
1737if test "x$enable_glx_read_only_text" = xyes; then
1738    DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
1739fi
1740
1741dnl
1742dnl DEPRECATED: EGL Platforms configuration
1743dnl
1744AC_ARG_WITH([egl-platforms],
1745    [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
1746        [DEPRECATED: use --with-platforms instead@<:@default=auto@:>@])],
1747    [with_egl_platforms="$withval"],
1748    [with_egl_platforms=auto])
1749
1750if test "x$with_egl_platforms" = xauto; then
1751    with_egl_platforms="x11,surfaceless"
1752    if test "x$enable_gbm" = xyes; then
1753        with_egl_platforms="$with_egl_platforms,drm"
1754    fi
1755else
1756    AC_MSG_WARN([--with-egl-platforms is deprecated. Use --with-platforms instead.])
1757fi
1758
1759dnl
1760dnl Platforms configuration
1761dnl
1762AC_ARG_WITH([platforms],
1763    [AS_HELP_STRING([--with-platforms@<:@=DIRS...@:>@],
1764        [comma delimited native platforms libEGL/Vulkan/other supports, e.g.
1765        "x11,drm,wayland,surfaceless..." @<:@default=auto@:>@])],
1766    [with_platforms="$withval"],
1767    [with_platforms=auto])
1768
1769# Reuse the autodetection rather than duplicating it.
1770if test "x$with_platforms" = xauto; then
1771    with_platforms=$with_egl_platforms
1772fi
1773
1774PKG_CHECK_MODULES([WAYLAND_SCANNER], [wayland-scanner],
1775        WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`,
1776        WAYLAND_SCANNER='')
1777if test "x$WAYLAND_SCANNER" = x; then
1778    AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner], [:])
1779fi
1780
1781PKG_CHECK_EXISTS([wayland-protocols >= $WAYLAND_PROTOCOLS_REQUIRED], [have_wayland_protocols=yes], [have_wayland_protocols=no])
1782if test "x$have_wayland_protocols" = xyes; then
1783    ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir wayland-protocols`
1784fi
1785AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)
1786
1787# Do per platform setups and checks
1788platforms=`IFS=', '; echo $with_platforms`
1789for plat in $platforms; do
1790    case "$plat" in
1791    wayland)
1792
1793        PKG_CHECK_MODULES([WAYLAND_CLIENT], [wayland-client >= $WAYLAND_REQUIRED])
1794        PKG_CHECK_MODULES([WAYLAND_SERVER], [wayland-server >= $WAYLAND_REQUIRED])
1795
1796        if test "x$WAYLAND_SCANNER" = "x:"; then
1797                AC_MSG_ERROR([wayland-scanner is needed to compile the wayland platform])
1798        fi
1799        if test "x$have_wayland_protocols" = xno; then
1800                AC_MSG_ERROR([wayland-protocols >= $WAYLAND_PROTOCOLS_REQUIRED is needed to compile the wayland platform])
1801        fi
1802        DEFINES="$DEFINES -DHAVE_WAYLAND_PLATFORM -DWL_HIDE_DEPRECATED"
1803        ;;
1804
1805    x11)
1806        PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED xcb-xfixes])
1807        DEFINES="$DEFINES -DHAVE_X11_PLATFORM"
1808        ;;
1809
1810    drm)
1811        test "x$enable_gbm" = "xno" &&
1812                AC_MSG_ERROR([EGL platform drm needs gbm])
1813        DEFINES="$DEFINES -DHAVE_DRM_PLATFORM"
1814        ;;
1815
1816    surfaceless)
1817        DEFINES="$DEFINES -DHAVE_SURFACELESS_PLATFORM"
1818        ;;
1819
1820    android)
1821        PKG_CHECK_MODULES([ANDROID], [cutils hardware sync])
1822        DEFINES="$DEFINES -DHAVE_ANDROID_PLATFORM"
1823        ;;
1824
1825    *)
1826        AC_MSG_ERROR([platform '$plat' does not exist])
1827        ;;
1828    esac
1829
1830    case "$plat" in
1831    wayland|drm|surfaceless)
1832        require_libdrm "Platform $plat"
1833        ;;
1834    esac
1835done
1836
1837if test "x$enable_glx" != xno; then
1838    if ! echo "$platforms" | grep -q 'x11'; then
1839        AC_MSG_ERROR([Building GLX without the x11 platform is not supported])
1840    fi
1841fi
1842
1843if test x"$enable_dri3" = xyes; then
1844    DEFINES="$DEFINES -DHAVE_DRI3"
1845
1846    dri3_modules="x11-xcb xcb >= $XCB_REQUIRED xcb-dri3 xcb-xfixes xcb-present xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
1847    PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules])
1848fi
1849
1850AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11')
1851AM_CONDITIONAL(HAVE_PLATFORM_WAYLAND, echo "$platforms" | grep -q 'wayland')
1852AM_CONDITIONAL(HAVE_PLATFORM_DRM, echo "$platforms" | grep -q 'drm')
1853AM_CONDITIONAL(HAVE_PLATFORM_SURFACELESS, echo "$platforms" | grep -q 'surfaceless')
1854AM_CONDITIONAL(HAVE_PLATFORM_ANDROID, echo "$platforms" | grep -q 'android')
1855
1856dnl
1857dnl More DRI setup
1858dnl
1859dnl Directory for DRI drivers
1860AC_ARG_WITH([dri-driverdir],
1861    [AS_HELP_STRING([--with-dri-driverdir=DIR],
1862        [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
1863    [DRI_DRIVER_INSTALL_DIR="$withval"],
1864    [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
1865AC_SUBST([DRI_DRIVER_INSTALL_DIR])
1866dnl Extra search path for DRI drivers
1867AC_ARG_WITH([dri-searchpath],
1868    [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
1869        [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
1870    [DRI_DRIVER_SEARCH_DIR="$withval"],
1871    [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
1872AC_SUBST([DRI_DRIVER_SEARCH_DIR])
1873dnl Which drivers to build - default is chosen by platform
1874AC_ARG_WITH([dri-drivers],
1875    [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
1876        [comma delimited classic DRI drivers list, e.g.
1877        "i915,i965,nouveau,radeon,r200,swrast" @<:@default=auto@:>@])],
1878    [with_dri_drivers="$withval"],
1879    [with_dri_drivers=auto])
1880
1881if test "x$with_dri_drivers" = xauto; then
1882    if test "x$enable_opengl" = xyes -a "x$enable_dri" = xyes; then
1883        with_dri_drivers="yes"
1884    else
1885        with_dri_drivers="no"
1886    fi
1887fi
1888if test "x$with_dri_drivers" = xno; then
1889    with_dri_drivers=''
1890fi
1891
1892# Check for expat
1893PKG_CHECK_MODULES([EXPAT], [expat],,
1894    [PKG_CHECK_MODULES([EXPAT], [expat21])]
1895)
1896
1897dnl If $with_dri_drivers is yes, drivers will be added through
1898dnl platform checks. Set DEFINES and LIB_DEPS
1899if test "x$enable_dri" = xyes; then
1900    # Platform specific settings and drivers to build
1901    case "$host_os" in
1902    linux*)
1903        case "$host_cpu" in
1904        powerpc* | sparc*)
1905            # Build only the drivers for cards that exist on PowerPC/sparc
1906            if test "x$with_dri_drivers" = "xyes"; then
1907                with_dri_drivers="r200 radeon swrast"
1908            fi
1909            ;;
1910        esac
1911        ;;
1912    cygwin*)
1913        if test "x$with_dri_drivers" = "xyes"; then
1914            with_dri_drivers="swrast"
1915        fi
1916        ;;
1917    darwin*)
1918        DEFINES="$DEFINES -DBUILDING_MESA"
1919        if test "x$with_dri_drivers" = "xyes"; then
1920            with_dri_drivers="swrast"
1921        fi
1922        ;;
1923    esac
1924
1925    # default drivers
1926    if test "x$with_dri_drivers" = "xyes"; then
1927        with_dri_drivers="i915 i965 nouveau r200 radeon swrast"
1928    fi
1929
1930    # put all the necessary libs together
1931    DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
1932fi
1933
1934AC_SUBST([DRI_LIB_DEPS])
1935
1936DRI_DIRS=''
1937dnl Duplicates in DRI_DIRS are removed by sorting it at the end of this block
1938if test -n "$with_dri_drivers"; then
1939    if test "x$enable_opengl" != xyes; then
1940        AC_MSG_ERROR([--with-dri-drivers requires OpenGL])
1941    fi
1942
1943    dri_drivers=`IFS=', '; echo $with_dri_drivers`
1944    for driver in $dri_drivers; do
1945        DRI_DIRS="$DRI_DIRS $driver"
1946        case "x$driver" in
1947        xi915)
1948            require_libdrm "i915"
1949            HAVE_I915_DRI=yes
1950            PKG_CHECK_MODULES([I915], [libdrm >= $LIBDRM_INTEL_REQUIRED libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
1951            ;;
1952        xi965)
1953            require_libdrm "i965"
1954            HAVE_I965_DRI=yes
1955            ;;
1956        xnouveau)
1957            require_libdrm "nouveau"
1958            HAVE_NOUVEAU_DRI=yes
1959            PKG_CHECK_MODULES([NVVIEUX], [libdrm >= $LIBDRM_NVVIEUX_REQUIRED libdrm_nouveau >= $LIBDRM_NVVIEUX_REQUIRED])
1960            ;;
1961        xradeon)
1962            require_libdrm "radeon"
1963            HAVE_RADEON_DRI=yes;
1964            PKG_CHECK_MODULES([RADEON], [libdrm >= $LIBDRM_RADEON_REQUIRED libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
1965            ;;
1966        xr200)
1967            require_libdrm "r200"
1968            HAVE_R200_DRI=yes
1969            PKG_CHECK_MODULES([RADEON], [libdrm >= $LIBDRM_RADEON_REQUIRED libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
1970            ;;
1971        xswrast)
1972            HAVE_SWRAST_DRI=yes
1973            ;;
1974        *)
1975            AC_MSG_ERROR([classic DRI driver '$driver' does not exist])
1976            ;;
1977        esac
1978    done
1979    DRI_DIRS=`echo $DRI_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
1980fi
1981
1982
1983dnl
1984dnl Gallium LLVM
1985dnl Deprecated: kept for backwards compatibility
1986dnl
1987AC_ARG_ENABLE([gallium-llvm],
1988    [AS_HELP_STRING([--enable-gallium-llvm],
1989        [DEPRECATED: use --enable-llvm instead])],
1990    [enable_gallium_llvm="$enableval"],
1991    [enable_gallium_llvm=auto])
1992
1993if test "x$enable_gallium_llvm" != xauto; then
1994   AC_MSG_WARN([The --enable-gallium-llvm option has been deprecated. Use --enable-llvm instead.])
1995   enable_llvm=$enable_gallium_llvm
1996fi
1997
1998dnl
1999dnl LLVM
2000dnl
2001AC_ARG_ENABLE([llvm],
2002    [AS_HELP_STRING([--enable-llvm],
2003        [build with LLVM support @<:@default=enabled on x86/x86_64@:>@])],
2004    [enable_llvm="$enableval"],
2005    [enable_llvm=auto])
2006
2007if test "x$enable_llvm" = xauto -a "x$FOUND_LLVM" = xyes; then
2008    if test "x$FOUND_LLVM" = xyes; then
2009        case "$host_cpu" in
2010        i*86|x86_64|amd64) enable_llvm=yes;;
2011        *) enable_llvm=no;;
2012        esac
2013    else
2014        enable_llvm=no
2015    fi
2016fi
2017
2018if test "x$enable_llvm" = xyes -a "x$FOUND_LLVM" = xno; then
2019    AC_MSG_ERROR([--enable-llvm selected but llvm-config is not found])
2020fi
2021
2022#
2023# Vulkan driver configuration
2024#
2025
2026AC_ARG_WITH([vulkan-drivers],
2027    [AS_HELP_STRING([--with-vulkan-drivers@<:@=DIRS...@:>@],
2028        [comma delimited Vulkan drivers list, e.g.
2029        "intel,radeon"
2030        @<:@default=no@:>@])],
2031    [with_vulkan_drivers="$withval"],
2032    [with_vulkan_drivers="no"])
2033
2034# Doing '--without-vulkan-drivers' will set this variable to 'no'.  Clear it
2035# here so that the script doesn't choke on an unknown driver name later.
2036case "x$with_vulkan_drivers" in
2037    xyes) with_vulkan_drivers="$VULKAN_DRIVERS_DEFAULT" ;;
2038    xno) with_vulkan_drivers='' ;;
2039esac
2040
2041AC_ARG_WITH([vulkan-icddir],
2042    [AS_HELP_STRING([--with-vulkan-icddir=DIR],
2043        [directory for the Vulkan driver icd files @<:@${datarootdir}/vulkan/icd.d@:>@])],
2044    [VULKAN_ICD_INSTALL_DIR="$withval"],
2045    [VULKAN_ICD_INSTALL_DIR='${datarootdir}/vulkan/icd.d'])
2046AC_SUBST([VULKAN_ICD_INSTALL_DIR])
2047
2048require_x11_dri3() {
2049    if echo "$platforms" | grep -q 'x11'; then
2050        if test "x$enable_dri3" != xyes; then
2051            AC_MSG_ERROR([$1 Vulkan driver requires DRI3 when built with X11])
2052        fi
2053    fi
2054}
2055
2056if test -n "$with_vulkan_drivers"; then
2057    if test "x$ac_cv_func_dl_iterate_phdr" = xno; then
2058        AC_MSG_ERROR([Vulkan drivers require the dl_iterate_phdr function])
2059    fi
2060
2061    VULKAN_DRIVERS=`IFS=', '; echo $with_vulkan_drivers`
2062    for driver in $VULKAN_DRIVERS; do
2063        case "x$driver" in
2064        xintel)
2065            require_libdrm "ANV"
2066            require_x11_dri3 "ANV"
2067            HAVE_INTEL_VULKAN=yes
2068            ;;
2069        xradeon)
2070            require_libdrm "radv"
2071            PKG_CHECK_MODULES([AMDGPU], [libdrm >= $LIBDRM_AMDGPU_REQUIRED libdrm_amdgpu >= $LIBDRM_AMDGPU_REQUIRED])
2072            radeon_llvm_check $LLVM_REQUIRED_RADV "radv"
2073            require_x11_dri3 "radv"
2074            HAVE_RADEON_VULKAN=yes
2075            ;;
2076        *)
2077            AC_MSG_ERROR([Vulkan driver '$driver' does not exist])
2078            ;;
2079        esac
2080    done
2081    VULKAN_DRIVERS=`echo $VULKAN_DRIVERS|tr " " "\n"|sort -u|tr "\n" " "`
2082fi
2083
2084
2085DEFINES="$DEFINES -DENABLE_SHADER_CACHE"
2086AM_CONDITIONAL(NEED_MEGADRIVER, test -n "$DRI_DIRS")
2087AM_CONDITIONAL(NEED_LIBMESA, test "x$enable_glx" = xxlib -o \
2088                                  "x$enable_osmesa" = xyes -o \
2089                                  -n "$DRI_DIRS")
2090
2091dnl
2092dnl OSMesa configuration
2093dnl
2094
2095dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
2096AC_ARG_WITH([osmesa-bits],
2097    [AS_HELP_STRING([--with-osmesa-bits=BITS],
2098        [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
2099    [osmesa_bits="$withval"],
2100    [osmesa_bits=8])
2101if test "x$osmesa_bits" != x8; then
2102    if test "x$enable_dri" = xyes -o "x$enable_glx" != xno; then
2103        AC_MSG_WARN([Ignoring OSMesa channel bits because of non-OSMesa driver])
2104        osmesa_bits=8
2105    fi
2106fi
2107case "x$osmesa_bits" in
2108x8)
2109    OSMESA_LIB="${OSMESA_LIB}"
2110    ;;
2111x16|x32)
2112    OSMESA_LIB="${OSMESA_LIB}$osmesa_bits"
2113    DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
2114    ;;
2115*)
2116    AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
2117    ;;
2118esac
2119
2120if test "x$enable_osmesa" = xyes -o "x$enable_gallium_osmesa" = xyes; then
2121    # only link libraries with osmesa if shared
2122    if test "$enable_static" = no; then
2123        OSMESA_LIB_DEPS="-lm $PTHREAD_LIBS $SELINUX_LIBS $DLOPEN_LIBS"
2124    else
2125        OSMESA_LIB_DEPS=""
2126    fi
2127    OSMESA_PC_LIB_PRIV="-lm $PTHREAD_LIBS $SELINUX_LIBS $DLOPEN_LIBS"
2128fi
2129
2130AC_SUBST([OSMESA_LIB_DEPS])
2131AC_SUBST([OSMESA_PC_REQ])
2132AC_SUBST([OSMESA_PC_LIB_PRIV])
2133
2134dnl
2135dnl gbm configuration
2136dnl
2137if test "x$enable_gbm" = xyes; then
2138    require_dri_shared_libs_and_glapi "gbm"
2139fi
2140AM_CONDITIONAL(HAVE_GBM, test "x$enable_gbm" = xyes)
2141# FINISHME: GBM has a number of dependencies which we should add below
2142GBM_PC_REQ_PRIV=""
2143GBM_PC_LIB_PRIV="$DLOPEN_LIBS"
2144AC_SUBST([GBM_PC_REQ_PRIV])
2145AC_SUBST([GBM_PC_LIB_PRIV])
2146
2147dnl
2148dnl EGL configuration
2149dnl
2150
2151if test "x$enable_egl" = xyes; then
2152    EGL_LIB_DEPS="$DLOPEN_LIBS $SELINUX_LIBS $PTHREAD_LIBS"
2153
2154    AC_CHECK_FUNC(mincore, [DEFINES="$DEFINES -DHAVE_MINCORE"])
2155
2156    require_dri_shared_libs_and_glapi "egl"
2157fi
2158AM_CONDITIONAL(HAVE_EGL, test "x$enable_egl" = xyes)
2159AC_SUBST([EGL_LIB_DEPS])
2160
2161gallium_st="mesa"
2162
2163dnl
2164dnl XA configuration
2165dnl
2166if test "x$enable_xa" = xyes; then
2167    if test "x$with_gallium_drivers" = xswrast; then
2168       AC_MSG_ERROR([
2169          Building xa requires at least one non swrast gallium driver.
2170          If you are looking to use libxatracker.so with the VMware driver,
2171          make sure to include svga in the gallium drivers list, apart from
2172          enabling XA.
2173          Example: ./configure --enable-xa --with-gallium-drivers=svga...])
2174    fi
2175    gallium_st="$gallium_st xa"
2176fi
2177AM_CONDITIONAL(HAVE_ST_XA, test "x$enable_xa" = xyes)
2178
2179if echo $platforms | grep -q "x11"; then
2180    have_xvmc_platform=yes
2181else
2182    have_xvmc_platform=no
2183fi
2184
2185if echo $platforms | grep -q "x11"; then
2186    have_vdpau_platform=yes
2187else
2188    have_vdpau_platform=no
2189fi
2190
2191if echo $platforms | grep -q "x11\|drm"; then
2192    have_omx_platform=yes
2193else
2194    have_omx_platform=no
2195fi
2196
2197if echo $platforms | grep -q "x11\|drm\|wayland"; then
2198    have_va_platform=yes
2199else
2200    have_va_platform=no
2201fi
2202
2203dnl
2204dnl Gallium G3DVL configuration
2205dnl
2206if test -n "$with_gallium_drivers" -a "x$with_gallium_drivers" != xswrast; then
2207    if test "x$enable_xvmc" = xauto -a "x$have_xvmc_platform" = xyes; then
2208        PKG_CHECK_EXISTS([xvmc >= $XVMC_REQUIRED], [enable_xvmc=yes], [enable_xvmc=no])
2209    fi
2210
2211    if test "x$enable_vdpau" = xauto -a "x$have_vdpau_platform" = xyes; then
2212        PKG_CHECK_EXISTS([vdpau >= $VDPAU_REQUIRED], [enable_vdpau=yes], [enable_vdpau=no])
2213    fi
2214
2215    if test "x$enable_omx_bellagio" = xauto -a "x$have_omx_platform" = xyes; then
2216        PKG_CHECK_EXISTS([libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED], [enable_omx_bellagio=yes], [enable_omx_bellagio=no])
2217    fi
2218
2219    if test "x$enable_va" = xauto -a "x$have_va_platform" = xyes; then
2220        PKG_CHECK_EXISTS([libva >= $LIBVA_REQUIRED], [enable_va=yes], [enable_va=no])
2221    fi
2222fi
2223
2224if test "x$enable_dri" = xyes -o \
2225        "x$enable_xvmc" = xyes -o \
2226        "x$enable_vdpau" = xyes -o \
2227        "x$enable_omx_bellagio" = xyes -o \
2228        "x$enable_va" = xyes; then
2229    need_gallium_vl=yes
2230fi
2231AM_CONDITIONAL(NEED_GALLIUM_VL, test "x$need_gallium_vl" = xyes)
2232
2233if test "x$enable_xvmc" = xyes -o \
2234        "x$enable_vdpau" = xyes -o \
2235        "x$enable_omx_bellagio" = xyes -o \
2236        "x$enable_va" = xyes; then
2237    if echo $platforms | grep -q "x11"; then
2238        PKG_CHECK_MODULES([VL], [x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
2239    fi
2240    need_gallium_vl_winsys=yes
2241fi
2242AM_CONDITIONAL(NEED_GALLIUM_VL_WINSYS, test "x$need_gallium_vl_winsys" = xyes)
2243
2244if test "x$enable_xvmc" = xyes; then
2245    if test "x$have_xvmc_platform" != xyes; then
2246        AC_MSG_ERROR([XVMC requires the x11 platforms])
2247    fi
2248    PKG_CHECK_MODULES([XVMC], [xvmc >= $XVMC_REQUIRED])
2249    gallium_st="$gallium_st xvmc"
2250fi
2251AM_CONDITIONAL(HAVE_ST_XVMC, test "x$enable_xvmc" = xyes)
2252
2253if test "x$enable_vdpau" = xyes; then
2254    if test "x$have_vdpau_platform" != xyes; then
2255        AC_MSG_ERROR([VDPAU requires the x11 platforms])
2256    fi
2257    PKG_CHECK_MODULES([VDPAU], [vdpau >= $VDPAU_REQUIRED])
2258    gallium_st="$gallium_st vdpau"
2259    DEFINES="$DEFINES -DHAVE_ST_VDPAU"
2260fi
2261AM_CONDITIONAL(HAVE_ST_VDPAU, test "x$enable_vdpau" = xyes)
2262
2263if test "x$enable_omx_bellagio" = xyes; then
2264    if test "x$have_omx_platform" != xyes; then
2265        AC_MSG_ERROR([OMX requires at least one of the x11 or drm platforms])
2266    fi
2267    PKG_CHECK_MODULES([OMX_BELLAGIO], [libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED])
2268    gallium_st="$gallium_st omx_bellagio"
2269fi
2270AM_CONDITIONAL(HAVE_ST_OMX_BELLAGIO, test "x$enable_omx_bellagio" = xyes)
2271
2272if test "x$enable_va" = xyes; then
2273    if test "x$have_va_platform" != xyes; then
2274        AC_MSG_ERROR([VA requires at least one of the x11 drm or wayland platforms])
2275    fi
2276    PKG_CHECK_MODULES([VA], [libva >= $LIBVA_REQUIRED])
2277    gallium_st="$gallium_st va"
2278fi
2279AM_CONDITIONAL(HAVE_ST_VA, test "x$enable_va" = xyes)
2280
2281dnl
2282dnl Nine Direct3D9 configuration
2283dnl
2284if test "x$enable_nine" = xyes; then
2285    if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
2286        AC_MSG_ERROR([nine requires the gallium swrast driver])
2287    fi
2288    if test "x$with_gallium_drivers" = xswrast; then
2289        AC_MSG_ERROR([nine requires at least one non-swrast gallium driver])
2290    fi
2291    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 6; then
2292        AC_MSG_ERROR([gcc >= 4.6 is required to build nine])
2293    fi
2294
2295    if test "x$enable_dri3" = xno; then
2296        AC_MSG_WARN([using nine together with wine requires DRI3 enabled system])
2297    fi
2298
2299    gallium_st="$gallium_st nine"
2300fi
2301AM_CONDITIONAL(HAVE_ST_NINE, test "x$enable_nine" = xyes)
2302
2303dnl
2304dnl OpenCL configuration
2305dnl
2306
2307AC_ARG_WITH([clang-libdir],
2308   [AS_HELP_STRING([--with-clang-libdir],
2309         [Path to Clang libraries @<:@default=llvm-config --libdir@:>@])],
2310   [CLANG_LIBDIR="$withval"],
2311   [CLANG_LIBDIR=''])
2312
2313PKG_CHECK_EXISTS([libclc], [have_libclc=yes], [have_libclc=no])
2314
2315if test "x$enable_opencl" = xyes; then
2316    if test -z "$with_gallium_drivers"; then
2317        AC_MSG_ERROR([cannot enable OpenCL without Gallium])
2318    fi
2319
2320    if test "x$HAVE_CXX11" != "xyes"; then
2321       AC_MSG_ERROR([clover requires c++11 support])
2322    fi
2323
2324    if test "x$have_libclc" = xno; then
2325        AC_MSG_ERROR([pkg-config cannot find libclc.pc which is required to build clover.
2326                    Make sure the directory containing libclc.pc is specified in your
2327                    PKG_CONFIG_PATH environment variable.
2328                    By default libclc.pc is installed to /usr/local/share/pkgconfig/])
2329    else
2330        LIBCLC_INCLUDEDIR=`$PKG_CONFIG --variable=includedir libclc`
2331        LIBCLC_LIBEXECDIR=`$PKG_CONFIG --variable=libexecdir libclc`
2332        AC_SUBST([LIBCLC_INCLUDEDIR])
2333        AC_SUBST([LIBCLC_LIBEXECDIR])
2334    fi
2335
2336    gallium_st="$gallium_st clover"
2337
2338    if test "x$enable_opencl_icd" = xyes; then
2339        OPENCL_LIBNAME="MesaOpenCL"
2340    else
2341        OPENCL_LIBNAME="OpenCL"
2342    fi
2343
2344    if test "x$have_libelf" != xyes; then
2345       AC_MSG_ERROR([Clover requires libelf])
2346    fi
2347
2348    if test "x${ac_cv_cxx_compiler_gnu}" = xyes; then
2349        altivec_enabled=no
2350        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2351        #if !defined(__VEC__) || !defined(__ALTIVEC__)
2352        #error "AltiVec not enabled"
2353        #endif
2354        ])], altivec_enabled=yes)
2355
2356        if test "$altivec_enabled" = yes; then
2357            CLOVER_STD_OVERRIDE="-std=gnu++11"
2358        fi
2359        AC_SUBST([CLOVER_STD_OVERRIDE])
2360    fi
2361
2362    llvm_require_version $LLVM_REQUIRED_OPENCL "opencl"
2363
2364    llvm_add_default_components "opencl"
2365    llvm_add_component "all-targets" "opencl"
2366    llvm_add_component "coverage" "opencl"
2367    llvm_add_component "linker" "opencl"
2368    llvm_add_component "instrumentation" "opencl"
2369    llvm_add_component "ipo" "opencl"
2370    llvm_add_component "irreader" "opencl"
2371    llvm_add_component "lto" "opencl"
2372    llvm_add_component "option" "opencl"
2373    llvm_add_component "objcarcopts" "opencl"
2374    llvm_add_component "profiledata" "opencl"
2375    llvm_add_optional_component "coroutines" "opencl"
2376
2377    dnl Check for Clang internal headers
2378    if test -z "$CLANG_LIBDIR"; then
2379        CLANG_LIBDIR=${LLVM_LIBDIR}
2380    fi
2381    CLANG_RESOURCE_DIR=$CLANG_LIBDIR/clang/${LLVM_VERSION}
2382    AS_IF([test ! -f "$CLANG_RESOURCE_DIR/include/stddef.h"],
2383        [AC_MSG_ERROR([Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries.])])
2384fi
2385AM_CONDITIONAL(HAVE_CLOVER, test "x$enable_opencl" = xyes)
2386AM_CONDITIONAL(HAVE_CLOVER_ICD, test "x$enable_opencl_icd" = xyes)
2387AC_SUBST([OPENCL_LIBNAME])
2388AC_SUBST([CLANG_RESOURCE_DIR])
2389
2390dnl
2391dnl Gallium configuration
2392dnl
2393AM_CONDITIONAL(HAVE_GALLIUM, test -n "$with_gallium_drivers")
2394
2395# libEGL wants to default to the first platform specified in
2396# ./configure.  parse that here.
2397if test "x$platforms" != "x"; then
2398    FIRST_PLATFORM_CAPS=`echo $platforms | sed 's| .*||' | tr '[[a-z]]' '[[A-Z]]'`
2399    EGL_NATIVE_PLATFORM="_EGL_PLATFORM_$FIRST_PLATFORM_CAPS"
2400else
2401    EGL_NATIVE_PLATFORM="_EGL_INVALID_PLATFORM"
2402fi
2403
2404AC_SUBST([EGL_NATIVE_PLATFORM])
2405AC_SUBST([EGL_CFLAGS])
2406
2407# If we don't have the X11 platform, set this define so we don't try to include
2408# the X11 headers.
2409if ! echo "$platforms" | grep -q 'x11'; then
2410    DEFINES="$DEFINES -DMESA_EGL_NO_X11_HEADERS"
2411    GL_PC_CFLAGS="$GL_PC_CFLAGS -DMESA_EGL_NO_X11_HEADERS"
2412fi
2413
2414dnl Directory for XVMC libs
2415AC_ARG_WITH([xvmc-libdir],
2416    [AS_HELP_STRING([--with-xvmc-libdir=DIR],
2417        [directory for the XVMC libraries @<:@default=${libdir}@:>@])],
2418    [XVMC_LIB_INSTALL_DIR="$withval"],
2419    [XVMC_LIB_INSTALL_DIR='${libdir}'])
2420AC_SUBST([XVMC_LIB_INSTALL_DIR])
2421
2422dnl
2423dnl Gallium Tests
2424dnl
2425AM_CONDITIONAL(HAVE_GALLIUM_TESTS, test "x$enable_gallium_tests" = xyes)
2426
2427dnl Directory for VDPAU libs
2428AC_ARG_WITH([vdpau-libdir],
2429    [AS_HELP_STRING([--with-vdpau-libdir=DIR],
2430        [directory for the VDPAU libraries @<:@default=${libdir}/vdpau@:>@])],
2431    [VDPAU_LIB_INSTALL_DIR="$withval"],
2432    [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau'])
2433AC_SUBST([VDPAU_LIB_INSTALL_DIR])
2434
2435dnl Directory for OMX_BELLAGIO libs
2436
2437AC_ARG_WITH([omx-bellagio-libdir],
2438    [AS_HELP_STRING([--with-omx-bellagio-libdir=DIR],
2439        [directory for the OMX_BELLAGIO libraries])],
2440    [OMX_BELLAGIO_LIB_INSTALL_DIR="$withval"],
2441    [OMX_BELLAGIO_LIB_INSTALL_DIR=`$PKG_CONFIG --exists libomxil-bellagio && \
2442                                   $PKG_CONFIG --define-variable=libdir=\$libdir --variable=pluginsdir libomxil-bellagio`])
2443AC_SUBST([OMX_BELLAGIO_LIB_INSTALL_DIR])
2444
2445dnl Directory for VA libs
2446
2447AC_ARG_WITH([va-libdir],
2448    [AS_HELP_STRING([--with-va-libdir=DIR],
2449        [directory for the VA libraries @<:@${libdir}/dri@:>@])],
2450    [VA_LIB_INSTALL_DIR="$withval"],
2451    [VA_LIB_INSTALL_DIR="${libdir}/dri"])
2452AC_SUBST([VA_LIB_INSTALL_DIR])
2453
2454AC_ARG_WITH([d3d-libdir],
2455    [AS_HELP_STRING([--with-d3d-libdir=DIR],
2456        [directory for the D3D modules @<:@${libdir}/d3d@:>@])],
2457    [D3D_DRIVER_INSTALL_DIR="$withval"],
2458    [D3D_DRIVER_INSTALL_DIR="${libdir}/d3d"])
2459AC_SUBST([D3D_DRIVER_INSTALL_DIR])
2460
2461dnl Architectures to build SWR library for
2462
2463AC_ARG_WITH([swr-archs],
2464    [AS_HELP_STRING([--with-swr-archs@<:@=DIRS...@:>@],
2465        [comma delimited swr architectures list, e.g.
2466        "avx,avx2,knl,skx" @<:@default="avx,avx2"@:>@])],
2467    [with_swr_archs="$withval"],
2468    [with_swr_archs="avx,avx2"])
2469
2470dnl
2471dnl r300 doesn't strictly require LLVM, but for performance reasons we
2472dnl highly recommend LLVM usage. So require it at least on x86 and x86_64
2473dnl architectures.
2474dnl
2475r300_require_llvm() {
2476    case "$host" in *gnux32) return;; esac
2477    case "$host_cpu" in
2478    i*86|x86_64|amd64) require_llvm $1
2479        ;;
2480    esac
2481}
2482
2483dnl
2484dnl DRM is needed by X, Wayland, and offscreen rendering.
2485dnl Surfaceless is an alternative for the last one.
2486dnl
2487require_basic_egl() {
2488    case "$with_platforms" in
2489        *drm*|*surfaceless*|*android*)
2490            ;;
2491        *)
2492            AC_MSG_ERROR([$1 requires one of these:
2493                  1) --with-platforms=drm (X, Wayland, offscreen rendering based on DRM)
2494                  2) --with-platforms=surfaceless (offscreen only)
2495                  3) --with-platforms=android (Android only)
2496                  Recommended options: drm,x11])
2497            ;;
2498    esac
2499}
2500
2501swr_require_cxx_feature_flags() {
2502    feature_name="$1"
2503    preprocessor_test="$2"
2504    option_list="$3"
2505    output_var="$4"
2506
2507    AC_MSG_CHECKING([whether $CXX supports $feature_name])
2508    AC_LANG_PUSH([C++])
2509    save_CXXFLAGS="$CXXFLAGS"
2510    save_IFS="$IFS"
2511    IFS=","
2512    found=0
2513    for opts in $option_list
2514    do
2515        unset IFS
2516        CXXFLAGS="$opts $save_CXXFLAGS"
2517        AC_COMPILE_IFELSE(
2518            [AC_LANG_PROGRAM(
2519                [   #if !($preprocessor_test)
2520                    #error
2521                    #endif
2522                ])],
2523            [found=1; break],
2524            [])
2525        IFS=","
2526    done
2527    IFS="$save_IFS"
2528    CXXFLAGS="$save_CXXFLAGS"
2529    AC_LANG_POP([C++])
2530    if test $found -eq 1; then
2531        AC_MSG_RESULT([$opts])
2532        eval "$output_var=\$opts"
2533        return 0
2534    fi
2535    AC_MSG_RESULT([no])
2536    AC_MSG_ERROR([swr requires $feature_name support])
2537    return 1
2538}
2539
2540dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block
2541if test -n "$with_gallium_drivers"; then
2542    gallium_drivers=`IFS=', '; echo $with_gallium_drivers`
2543    for driver in $gallium_drivers; do
2544        case "x$driver" in
2545        xsvga)
2546            HAVE_GALLIUM_SVGA=yes
2547            require_libdrm "svga"
2548            ;;
2549        xi915)
2550            HAVE_GALLIUM_I915=yes
2551            PKG_CHECK_MODULES([I915], [libdrm >= $LIBDRM_INTEL_REQUIRED libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
2552            require_libdrm "Gallium i915"
2553            ;;
2554        xr300)
2555            HAVE_GALLIUM_R300=yes
2556            PKG_CHECK_MODULES([RADEON], [libdrm >= $LIBDRM_RADEON_REQUIRED libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
2557            require_libdrm "r300"
2558            r300_require_llvm "r300"
2559            ;;
2560        xr600)
2561            HAVE_GALLIUM_R600=yes
2562            PKG_CHECK_MODULES([RADEON], [libdrm >= $LIBDRM_RADEON_REQUIRED libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
2563            require_libdrm "r600"
2564            if test "x$enable_llvm" = xyes; then
2565                radeon_llvm_check $LLVM_REQUIRED_R600 "r600"
2566
2567                llvm_add_component "asmparser" "r600"
2568                llvm_add_component "bitreader" "r600"
2569            fi
2570            ;;
2571        xradeonsi)
2572            HAVE_GALLIUM_RADEONSI=yes
2573            PKG_CHECK_MODULES([RADEON], [libdrm >= $LIBDRM_RADEON_REQUIRED libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
2574            PKG_CHECK_MODULES([AMDGPU], [libdrm >= $LIBDRM_AMDGPU_REQUIRED libdrm_amdgpu >= $LIBDRM_AMDGPU_REQUIRED])
2575
2576            # Blacklist libdrm_amdgpu 2.4.90 because it causes a crash in older
2577            # radeonsi with pretty much any app.
2578            libdrm_version=`pkg-config libdrm_amdgpu --modversion`
2579            if test "x$libdrm_version" = x2.4.90; then
2580                AC_MSG_ERROR([radeonsi can't use libdrm 2.4.90 due to a compatibility issue. Use a newer or older version.])
2581            fi
2582
2583            require_libdrm "radeonsi"
2584            radeon_llvm_check $LLVM_REQUIRED_RADEONSI "radeonsi"
2585            if test "x$enable_egl" = xyes; then
2586                require_basic_egl "radeonsi"
2587            fi
2588            ;;
2589        xnouveau)
2590            HAVE_GALLIUM_NOUVEAU=yes
2591            PKG_CHECK_MODULES([NOUVEAU], [libdrm >= $LIBDRM_NOUVEAU_REQUIRED libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED])
2592            require_libdrm "nouveau"
2593            ;;
2594        xfreedreno)
2595            HAVE_GALLIUM_FREEDRENO=yes
2596            PKG_CHECK_MODULES([FREEDRENO], [libdrm >= $LIBDRM_FREEDRENO_REQUIRED libdrm_freedreno >= $LIBDRM_FREEDRENO_REQUIRED])
2597            require_libdrm "freedreno"
2598            ;;
2599        xetnaviv)
2600            HAVE_GALLIUM_ETNAVIV=yes
2601            PKG_CHECK_MODULES([ETNAVIV], [libdrm >= $LIBDRM_ETNAVIV_REQUIRED libdrm_etnaviv >= $LIBDRM_ETNAVIV_REQUIRED])
2602            require_libdrm "etnaviv"
2603            ;;
2604       ximx)
2605            HAVE_GALLIUM_IMX=yes
2606            ;;
2607        xswrast)
2608            HAVE_GALLIUM_SOFTPIPE=yes
2609            if test "x$enable_llvm" = xyes; then
2610                HAVE_GALLIUM_LLVMPIPE=yes
2611            fi
2612            ;;
2613        xswr)
2614            llvm_require_version $LLVM_REQUIRED_SWR "swr"
2615
2616            if test "x$HAVE_CXX11" != "xyes"; then
2617                AC_MSG_ERROR([swr requires c++11 support])
2618            fi
2619
2620            swr_require_cxx_feature_flags "AVX" "defined(__AVX__)" \
2621                ",-target-cpu=sandybridge,-mavx,-march=core-avx,-tp=sandybridge" \
2622                SWR_AVX_CXXFLAGS
2623            AC_SUBST([SWR_AVX_CXXFLAGS])
2624
2625            swr_archs=`IFS=', '; echo $with_swr_archs`
2626            for arch in $swr_archs; do
2627                case "x$arch" in
2628                xavx)
2629                    HAVE_SWR_AVX=yes
2630                    ;;
2631                xavx2)
2632                    swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
2633                        ",-target-cpu=haswell,-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2,-tp=haswell" \
2634                        SWR_AVX2_CXXFLAGS
2635                    AC_SUBST([SWR_AVX2_CXXFLAGS])
2636                    HAVE_SWR_AVX2=yes
2637                    ;;
2638                xknl)
2639                    swr_require_cxx_feature_flags "KNL" "defined(__AVX512F__) && defined(__AVX512ER__)" \
2640                        ",-target-cpu=mic-knl,-march=knl,-xMIC-AVX512" \
2641                        SWR_KNL_CXXFLAGS
2642                    AC_SUBST([SWR_KNL_CXXFLAGS])
2643                    HAVE_SWR_KNL=yes
2644                    ;;
2645                xskx)
2646                    swr_require_cxx_feature_flags "SKX" "defined(__AVX512F__) && defined(__AVX512BW__)" \
2647                        ",-target-cpu=x86-skylake,-march=skylake-avx512,-xCORE-AVX512" \
2648                        SWR_SKX_CXXFLAGS
2649                    AC_SUBST([SWR_SKX_CXXFLAGS])
2650                    HAVE_SWR_SKX=yes
2651                    ;;
2652                *)
2653                    AC_MSG_ERROR([unknown SWR build architecture '$arch'])
2654                    ;;
2655                esac
2656            done
2657
2658            if test "x$HAVE_SWR_AVX" != xyes -a \
2659                    "x$HAVE_SWR_AVX2" != xyes -a \
2660                    "x$HAVE_SWR_KNL" != xyes -a \
2661                    "x$HAVE_SWR_SKX" != xyes; then
2662               AC_MSG_ERROR([swr enabled but no swr architectures selected])
2663            fi
2664
2665            # test if more than one swr arch configured
2666            if test `echo $swr_archs | wc -w` -eq 1; then
2667                HAVE_SWR_BUILTIN=yes
2668            fi
2669
2670            HAVE_GALLIUM_SWR=yes
2671            ;;
2672        xvc4)
2673            HAVE_GALLIUM_VC4=yes
2674            require_libdrm "vc4"
2675
2676            PKG_CHECK_MODULES([SIMPENROSE], [simpenrose],
2677                              [USE_VC4_SIMULATOR=yes;
2678                               DEFINES="$DEFINES -DUSE_VC4_SIMULATOR"],
2679                              [USE_VC4_SIMULATOR=no])
2680            ;;
2681        xvc5)
2682            HAVE_GALLIUM_VC5=yes
2683
2684            PKG_CHECK_MODULES([VC5_SIMULATOR], [v3dv3],
2685                              [USE_VC5_SIMULATOR=yes;
2686                               DEFINES="$DEFINES -DUSE_VC5_SIMULATOR"],
2687                              [AC_MSG_ERROR([vc5 requires the simulator])])
2688            ;;
2689        xpl111)
2690            HAVE_GALLIUM_PL111=yes
2691            ;;
2692        xvirgl)
2693            HAVE_GALLIUM_VIRGL=yes
2694            require_libdrm "virgl"
2695            if test "x$enable_egl" = xyes; then
2696                require_basic_egl "virgl"
2697            fi
2698            ;;
2699        *)
2700            AC_MSG_ERROR([Unknown Gallium driver: $driver])
2701            ;;
2702        esac
2703    done
2704fi
2705
2706# XXX: Keep in sync with LLVM_REQUIRED_SWR
2707AM_CONDITIONAL(SWR_INVALID_LLVM_VERSION, test "x$LLVM_VERSION" != x3.9.0 -a \
2708                                              "x$LLVM_VERSION" != x3.9.1)
2709
2710if test "x$enable_llvm" = "xyes" -a "$with_gallium_drivers"; then
2711    llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
2712    llvm_add_default_components "gallium"
2713fi
2714
2715AM_CONDITIONAL(HAVE_SWR_AVX, test "x$HAVE_SWR_AVX" = xyes)
2716AM_CONDITIONAL(HAVE_SWR_AVX2, test "x$HAVE_SWR_AVX2" = xyes)
2717AM_CONDITIONAL(HAVE_SWR_KNL, test "x$HAVE_SWR_KNL" = xyes)
2718AM_CONDITIONAL(HAVE_SWR_SKX, test "x$HAVE_SWR_SKX" = xyes)
2719AM_CONDITIONAL(HAVE_SWR_BUILTIN, test "x$HAVE_SWR_BUILTIN" = xyes)
2720
2721dnl We need to validate some needed dependencies for renderonly drivers.
2722
2723if test "x$HAVE_GALLIUM_ETNAVIV" != xyes -a "x$HAVE_GALLIUM_IMX" = xyes  ; then
2724    AC_MSG_ERROR([Building with imx requires etnaviv])
2725fi
2726
2727if test "x$HAVE_GALLIUM_VC4" != xyes -a "x$HAVE_GALLIUM_PL111" = xyes  ; then
2728    AC_MSG_ERROR([Building with pl111 requires vc4])
2729fi
2730
2731
2732detect_old_buggy_llvm() {
2733    dnl llvm-config may not give the right answer when llvm is a built as a
2734    dnl single shared library, so we must work the library name out for
2735    dnl ourselves.
2736    dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
2737    dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
2738    LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
2739    AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], [llvm_have_one_so=yes])
2740
2741    if test "x$llvm_have_one_so" = xyes; then
2742        dnl LLVM was built using auto*, so there is only one shared object.
2743        LLVM_LIBS="-l$LLVM_SO_NAME"
2744    else
2745        dnl If LLVM was built with CMake, there will be one shared object per
2746        dnl component.
2747        AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.$IMP_LIB_EXT"],
2748               [AC_MSG_ERROR([Could not find llvm shared libraries:
2749                Please make sure you have built llvm with the --enable-shared option
2750                and that your llvm libraries are installed in $LLVM_LIBDIR
2751                If you have installed your llvm libraries to a different directory you
2752                can use the --with-llvm-prefix= configure flag to specify this directory.
2753                NOTE: Mesa is attempting to use llvm shared libraries by default.
2754                If you do not want to build with llvm shared libraries and instead want to
2755                use llvm static libraries then add --disable-llvm-shared-libs to your configure
2756                invocation and rebuild.])])
2757
2758        dnl We don't need to update LLVM_LIBS in this case because the LLVM
2759        dnl install uses a shared object for each component and we have
2760        dnl already added all of these objects to LLVM_LIBS.
2761    fi
2762}
2763
2764dnl
2765dnl Set defines and buildtime variables only when using LLVM.
2766dnl
2767if test "x$enable_llvm" = xyes; then
2768    DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
2769
2770    LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
2771    LLVM_CFLAGS=$LLVM_CPPFLAGS   # CPPFLAGS seem to be sufficient
2772    LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"`
2773
2774    dnl Set LLVM_LIBS - This is done after the driver configuration so
2775    dnl that drivers can add additional components to LLVM_COMPONENTS.
2776    dnl Previously, gallium drivers were updating LLVM_LIBS directly
2777    dnl by calling llvm-config --libs ${DRIVER_LLVM_COMPONENTS}, but
2778    dnl this was causing the same libraries to be appear multiple times
2779    dnl in LLVM_LIBS.
2780
2781    if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 9; then
2782        if test "x$enable_llvm_shared_libs" = xyes; then
2783            LLVM_LIBS="`$LLVM_CONFIG --link-shared --libs ${LLVM_COMPONENTS}`"
2784        else
2785            dnl Invoking llvm-config with both -libs and --system-libs produces the
2786            dnl two separate lines - each for the set of libraries.
2787		dnl Call the program twice, effectively folding them into a single line.
2788            LLVM_LIBS="`$LLVM_CONFIG --link-static --libs ${LLVM_COMPONENTS}`"
2789            dnl We need to link to llvm system libs when using static libs
2790            LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --link-static --system-libs`"
2791        fi
2792    else
2793        LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
2794        if test "x$enable_llvm_shared_libs" = xyes; then
2795            detect_old_buggy_llvm
2796        else
2797            AC_MSG_WARN([Building mesa with statically linked LLVM may cause compilation issues])
2798            dnl We need to link to llvm system libs when using static libs
2799            dnl However, only llvm 3.5+ provides --system-libs
2800            if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then
2801                LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`"
2802            fi
2803        fi
2804    fi
2805
2806    dnl The gallium-xlib GLX and gallium OSMesa targets directly embed the
2807    dnl swr/llvmpipe driver into the final binary.  Adding LLVM_LIBS results in
2808    dnl the LLVM library propagated in the Libs.private of the respective .pc
2809    dnl file which ensures complete dependency information when statically
2810    dnl linking.
2811    if test "x$enable_glx" == xgallium-xlib; then
2812        GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $LLVM_LIBS"
2813    fi
2814    if test "x$enable_gallium_osmesa" = xyes; then
2815        OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV $LLVM_LIBS"
2816    fi
2817fi
2818
2819AM_CONDITIONAL(HAVE_GALLIUM_SVGA, test "x$HAVE_GALLIUM_SVGA" = xyes)
2820AM_CONDITIONAL(HAVE_GALLIUM_I915, test "x$HAVE_GALLIUM_I915" = xyes)
2821AM_CONDITIONAL(HAVE_GALLIUM_PL111, test "x$HAVE_GALLIUM_PL111" = xyes)
2822AM_CONDITIONAL(HAVE_GALLIUM_R300, test "x$HAVE_GALLIUM_R300" = xyes)
2823AM_CONDITIONAL(HAVE_GALLIUM_R600, test "x$HAVE_GALLIUM_R600" = xyes)
2824AM_CONDITIONAL(HAVE_GALLIUM_RADEONSI, test "x$HAVE_GALLIUM_RADEONSI" = xyes)
2825AM_CONDITIONAL(HAVE_GALLIUM_RADEON_COMMON, test "x$HAVE_GALLIUM_RADEONSI" = xyes)
2826AM_CONDITIONAL(HAVE_GALLIUM_NOUVEAU, test "x$HAVE_GALLIUM_NOUVEAU" = xyes)
2827AM_CONDITIONAL(HAVE_GALLIUM_FREEDRENO, test "x$HAVE_GALLIUM_FREEDRENO" = xyes)
2828AM_CONDITIONAL(HAVE_GALLIUM_ETNAVIV, test "x$HAVE_GALLIUM_ETNAVIV" = xyes)
2829AM_CONDITIONAL(HAVE_GALLIUM_IMX, test "x$HAVE_GALLIUM_IMX" = xyes)
2830AM_CONDITIONAL(HAVE_GALLIUM_SOFTPIPE, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes)
2831AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test "x$HAVE_GALLIUM_LLVMPIPE" = xyes)
2832AM_CONDITIONAL(HAVE_GALLIUM_SWR, test "x$HAVE_GALLIUM_SWR" = xyes)
2833AM_CONDITIONAL(HAVE_GALLIUM_SWRAST, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes -o \
2834                                         "x$HAVE_GALLIUM_LLVMPIPE" = xyes -o \
2835                                         "x$HAVE_GALLIUM_SWR" = xyes)
2836AM_CONDITIONAL(HAVE_GALLIUM_VC4, test "x$HAVE_GALLIUM_VC4" = xyes)
2837AM_CONDITIONAL(HAVE_GALLIUM_VC5, test "x$HAVE_GALLIUM_VC5" = xyes)
2838AM_CONDITIONAL(HAVE_GALLIUM_VIRGL, test "x$HAVE_GALLIUM_VIRGL" = xyes)
2839
2840AM_CONDITIONAL(HAVE_GALLIUM_STATIC_TARGETS, test "x$enable_shared_pipe_drivers" = xno)
2841
2842if test "x$enable_dri" = xyes; then
2843    GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES -DHAVE_PIPE_LOADER_DRI"
2844fi
2845
2846if test "x$have_drisw_kms" = xyes; then
2847    GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES -DHAVE_PIPE_LOADER_KMS"
2848fi
2849AC_SUBST([GALLIUM_PIPE_LOADER_DEFINES])
2850
2851AM_CONDITIONAL(HAVE_I915_DRI, test x$HAVE_I915_DRI = xyes)
2852AM_CONDITIONAL(HAVE_I965_DRI, test x$HAVE_I965_DRI = xyes)
2853AM_CONDITIONAL(HAVE_NOUVEAU_DRI, test x$HAVE_NOUVEAU_DRI = xyes)
2854AM_CONDITIONAL(HAVE_R200_DRI, test x$HAVE_R200_DRI = xyes)
2855AM_CONDITIONAL(HAVE_RADEON_DRI, test x$HAVE_RADEON_DRI = xyes)
2856AM_CONDITIONAL(HAVE_SWRAST_DRI, test x$HAVE_SWRAST_DRI = xyes)
2857
2858AM_CONDITIONAL(HAVE_RADEON_VULKAN, test "x$HAVE_RADEON_VULKAN" = xyes)
2859AM_CONDITIONAL(HAVE_INTEL_VULKAN, test "x$HAVE_INTEL_VULKAN" = xyes)
2860
2861AM_CONDITIONAL(HAVE_AMD_DRIVERS, test "x$HAVE_GALLIUM_RADEONSI" = xyes -o \
2862                                      "x$HAVE_RADEON_VULKAN" = xyes)
2863
2864AM_CONDITIONAL(HAVE_BROADCOM_DRIVERS, test "x$HAVE_GALLIUM_VC4" = xyes -o \
2865                                      "x$HAVE_GALLIUM_VC5" = xyes)
2866
2867AM_CONDITIONAL(HAVE_INTEL_DRIVERS, test "x$HAVE_INTEL_VULKAN" = xyes -o \
2868                                        "x$HAVE_I965_DRI" = xyes)
2869
2870AM_CONDITIONAL(NEED_RADEON_DRM_WINSYS, test "x$HAVE_GALLIUM_R300" = xyes -o \
2871                                            "x$HAVE_GALLIUM_R600" = xyes -o \
2872                                            "x$HAVE_GALLIUM_RADEONSI" = xyes)
2873AM_CONDITIONAL(NEED_WINSYS_XLIB, test "x$enable_glx" = xgallium-xlib)
2874AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
2875AM_CONDITIONAL(HAVE_GALLIUM_LLVM, test "x$enable_llvm" = xyes)
2876AM_CONDITIONAL(USE_VC4_SIMULATOR, test x$USE_VC4_SIMULATOR = xyes)
2877AM_CONDITIONAL(USE_VC5_SIMULATOR, test x$USE_VC5_SIMULATOR = xyes)
2878
2879AM_CONDITIONAL(HAVE_LIBDRM, test "x$have_libdrm" = xyes)
2880AM_CONDITIONAL(HAVE_OSMESA, test "x$enable_osmesa" = xyes)
2881AM_CONDITIONAL(HAVE_GALLIUM_OSMESA, test "x$enable_gallium_osmesa" = xyes)
2882AM_CONDITIONAL(HAVE_COMMON_OSMESA, test "x$enable_osmesa" = xyes -o \
2883                                        "x$enable_gallium_osmesa" = xyes)
2884
2885AM_CONDITIONAL(HAVE_X86_ASM, test "x$asm_arch" = xx86 -o "x$asm_arch" = xx86_64)
2886AM_CONDITIONAL(HAVE_X86_64_ASM, test "x$asm_arch" = xx86_64)
2887AM_CONDITIONAL(HAVE_SPARC_ASM, test "x$asm_arch" = xsparc)
2888AM_CONDITIONAL(HAVE_PPC64LE_ASM, test "x$asm_arch" = xppc64le)
2889AM_CONDITIONAL(HAVE_AARCH64_ASM, test "x$asm_arch" = xaarch64)
2890AM_CONDITIONAL(HAVE_ARM_ASM, test "x$asm_arch" = xarm)
2891
2892AC_SUBST([NINE_MAJOR], 1)
2893AC_SUBST([NINE_MINOR], 0)
2894AC_SUBST([NINE_PATCH], 0)
2895AC_SUBST([NINE_VERSION], "$NINE_MAJOR.$NINE_MINOR.$NINE_PATCH")
2896
2897AC_SUBST([VDPAU_MAJOR], 1)
2898AC_SUBST([VDPAU_MINOR], 0)
2899
2900if test "x$enable_va" = xyes; then
2901    VA_MAJOR=`$PKG_CONFIG --modversion libva | $SED -n 's/\([[^\.]]*\)\..*$/\1/p'`
2902    VA_MINOR=`$PKG_CONFIG --modversion libva | $SED -n 's/.*\.\(.*\)\..*$/\1/p'`
2903fi
2904AC_SUBST([VA_MAJOR], $VA_MAJOR)
2905AC_SUBST([VA_MINOR], $VA_MINOR)
2906
2907AM_CONDITIONAL(HAVE_VULKAN_COMMON, test "x$VULKAN_DRIVERS" != "x")
2908
2909AC_SUBST([XVMC_MAJOR], 1)
2910AC_SUBST([XVMC_MINOR], 0)
2911
2912AC_SUBST([XA_MAJOR], 2)
2913AC_SUBST([XA_MINOR], 3)
2914AC_SUBST([XA_PATCH], 0)
2915AC_SUBST([XA_VERSION], "$XA_MAJOR.$XA_MINOR.$XA_PATCH")
2916
2917AC_ARG_ENABLE(valgrind,
2918              [AS_HELP_STRING([--enable-valgrind],
2919                             [Build mesa with valgrind support (default: auto)])],
2920                             [VALGRIND=$enableval], [VALGRIND=auto])
2921if test "x$VALGRIND" != xno; then
2922    PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no])
2923fi
2924AC_MSG_CHECKING([whether to enable Valgrind support])
2925if test "x$VALGRIND" = xauto; then
2926    VALGRIND="$have_valgrind"
2927fi
2928
2929if test "x$VALGRIND" = "xyes"; then
2930    if ! test "x$have_valgrind" = xyes; then
2931        AC_MSG_ERROR([Valgrind support required but not present])
2932    fi
2933    AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
2934fi
2935
2936AC_MSG_RESULT([$VALGRIND])
2937
2938dnl Restore LDFLAGS and CPPFLAGS
2939LDFLAGS="$_SAVE_LDFLAGS"
2940CPPFLAGS="$_SAVE_CPPFLAGS"
2941
2942dnl Suppress clang's warnings about unused CFLAGS and CXXFLAGS
2943if test "x$acv_mesa_CLANG" = xyes; then
2944    CFLAGS="$CFLAGS -Qunused-arguments"
2945    CXXFLAGS="$CXXFLAGS -Qunused-arguments"
2946fi
2947
2948dnl Add user CFLAGS and CXXFLAGS
2949CFLAGS="$CFLAGS $USER_CFLAGS"
2950CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
2951
2952dnl Substitute the config
2953AC_CONFIG_FILES([Makefile
2954                 src/Makefile
2955                 src/amd/Makefile
2956                 src/amd/vulkan/Makefile
2957                 src/broadcom/Makefile
2958                 src/compiler/Makefile
2959                 src/egl/Makefile
2960                 src/egl/main/egl.pc
2961                 src/egl/wayland/wayland-drm/Makefile
2962                 src/egl/wayland/wayland-egl/Makefile
2963                 src/egl/wayland/wayland-egl/wayland-egl.pc
2964                 src/gallium/Makefile
2965                 src/gallium/auxiliary/Makefile
2966                 src/gallium/auxiliary/pipe-loader/Makefile
2967                 src/gallium/drivers/freedreno/Makefile
2968                 src/gallium/drivers/ddebug/Makefile
2969                 src/gallium/drivers/i915/Makefile
2970                 src/gallium/drivers/llvmpipe/Makefile
2971                 src/gallium/drivers/noop/Makefile
2972                 src/gallium/drivers/nouveau/Makefile
2973                 src/gallium/drivers/pl111/Makefile
2974                 src/gallium/drivers/r300/Makefile
2975                 src/gallium/drivers/r600/Makefile
2976                 src/gallium/drivers/radeon/Makefile
2977                 src/gallium/drivers/radeonsi/Makefile
2978                 src/gallium/drivers/rbug/Makefile
2979                 src/gallium/drivers/softpipe/Makefile
2980                 src/gallium/drivers/svga/Makefile
2981                 src/gallium/drivers/swr/Makefile
2982                 src/gallium/drivers/trace/Makefile
2983                 src/gallium/drivers/etnaviv/Makefile
2984                 src/gallium/drivers/imx/Makefile
2985                 src/gallium/drivers/vc4/Makefile
2986                 src/gallium/drivers/vc5/Makefile
2987                 src/gallium/drivers/virgl/Makefile
2988                 src/gallium/state_trackers/clover/Makefile
2989                 src/gallium/state_trackers/dri/Makefile
2990                 src/gallium/state_trackers/glx/xlib/Makefile
2991                 src/gallium/state_trackers/nine/Makefile
2992                 src/gallium/state_trackers/omx_bellagio/Makefile
2993                 src/gallium/state_trackers/osmesa/Makefile
2994                 src/gallium/state_trackers/va/Makefile
2995                 src/gallium/state_trackers/vdpau/Makefile
2996                 src/gallium/state_trackers/xa/Makefile
2997                 src/gallium/state_trackers/xa/xa_tracker.h
2998                 src/gallium/state_trackers/xvmc/Makefile
2999                 src/gallium/targets/d3dadapter9/Makefile
3000                 src/gallium/targets/d3dadapter9/d3d.pc
3001                 src/gallium/targets/dri/Makefile
3002                 src/gallium/targets/libgl-xlib/Makefile
3003                 src/gallium/targets/omx-bellagio/Makefile
3004                 src/gallium/targets/opencl/Makefile
3005                 src/gallium/targets/opencl/mesa.icd
3006                 src/gallium/targets/osmesa/Makefile
3007                 src/gallium/targets/osmesa/osmesa.pc
3008                 src/gallium/targets/pipe-loader/Makefile
3009                 src/gallium/targets/va/Makefile
3010                 src/gallium/targets/vdpau/Makefile
3011                 src/gallium/targets/xa/Makefile
3012                 src/gallium/targets/xa/xatracker.pc
3013                 src/gallium/targets/xvmc/Makefile
3014                 src/gallium/tests/trivial/Makefile
3015                 src/gallium/tests/unit/Makefile
3016                 src/gallium/winsys/etnaviv/drm/Makefile
3017                 src/gallium/winsys/imx/drm/Makefile
3018                 src/gallium/winsys/freedreno/drm/Makefile
3019                 src/gallium/winsys/i915/drm/Makefile
3020                 src/gallium/winsys/nouveau/drm/Makefile
3021                 src/gallium/winsys/pl111/drm/Makefile
3022                 src/gallium/winsys/radeon/drm/Makefile
3023                 src/gallium/winsys/amdgpu/drm/Makefile
3024                 src/gallium/winsys/svga/drm/Makefile
3025                 src/gallium/winsys/sw/dri/Makefile
3026                 src/gallium/winsys/sw/kms-dri/Makefile
3027                 src/gallium/winsys/sw/null/Makefile
3028                 src/gallium/winsys/sw/wrapper/Makefile
3029                 src/gallium/winsys/sw/xlib/Makefile
3030                 src/gallium/winsys/vc4/drm/Makefile
3031                 src/gallium/winsys/vc5/drm/Makefile
3032                 src/gallium/winsys/virgl/drm/Makefile
3033                 src/gallium/winsys/virgl/vtest/Makefile
3034                 src/gbm/Makefile
3035                 src/gbm/main/gbm.pc
3036                 src/glx/Makefile
3037                 src/glx/apple/Makefile
3038                 src/glx/tests/Makefile
3039                 src/glx/windows/Makefile
3040                 src/glx/windows/windowsdriproto.pc
3041                 src/gtest/Makefile
3042                 src/intel/Makefile
3043                 src/loader/Makefile
3044                 src/mapi/Makefile
3045                 src/mapi/es1api/glesv1_cm.pc
3046                 src/mapi/es2api/glesv2.pc
3047                 src/mapi/glapi/gen/Makefile
3048                 src/mesa/Makefile
3049                 src/mesa/gl.pc
3050                 src/mesa/drivers/dri/dri.pc
3051                 src/mesa/drivers/dri/common/Makefile
3052                 src/mesa/drivers/dri/i915/Makefile
3053                 src/mesa/drivers/dri/i965/Makefile
3054                 src/mesa/drivers/dri/Makefile
3055                 src/mesa/drivers/dri/nouveau/Makefile
3056                 src/mesa/drivers/dri/r200/Makefile
3057                 src/mesa/drivers/dri/radeon/Makefile
3058                 src/mesa/drivers/dri/swrast/Makefile
3059                 src/mesa/drivers/osmesa/Makefile
3060                 src/mesa/drivers/osmesa/osmesa.pc
3061                 src/mesa/drivers/x11/Makefile
3062                 src/mesa/main/tests/Makefile
3063                 src/mesa/state_tracker/tests/Makefile
3064                 src/util/Makefile
3065                 src/util/tests/hash_table/Makefile
3066                 src/util/tests/string_buffer/Makefile
3067                 src/util/xmlpool/Makefile
3068                 src/vulkan/Makefile])
3069
3070AC_OUTPUT
3071
3072# Fix up dependencies in *.Plo files, where we changed the extension of a
3073# source file
3074$SED -i -e 's/brw_blorp.cpp/brw_blorp.c/' src/mesa/drivers/dri/i965/.deps/brw_blorp.Plo
3075
3076rm -f src/compiler/spirv/spirv_info.lo
3077echo "# dummy" > src/compiler/spirv/.deps/spirv_info.Plo
3078
3079dnl
3080dnl Output some configuration info for the user
3081dnl
3082echo ""
3083echo "        prefix:          $prefix"
3084echo "        exec_prefix:     $exec_prefix"
3085echo "        libdir:          $libdir"
3086echo "        includedir:      $includedir"
3087
3088dnl API info
3089echo ""
3090echo "        OpenGL:          $enable_opengl (ES1: $enable_gles1 ES2: $enable_gles2)"
3091
3092dnl Driver info
3093echo ""
3094case "x$enable_osmesa$enable_gallium_osmesa" in
3095xnoyes)
3096        echo "        OSMesa:          lib$OSMESA_LIB (Gallium)"
3097        ;;
3098xyesno)
3099        echo "        OSMesa:          lib$OSMESA_LIB"
3100        ;;
3101xnono)
3102        echo "        OSMesa:          no"
3103        ;;
3104esac
3105
3106echo ""
3107if test "x$enable_dri" != xno; then
3108        echo "        DRI platform:    $dri_platform"
3109        if test -z "$DRI_DIRS"; then
3110            echo "        DRI drivers:     no"
3111        else
3112            echo "        DRI drivers:     $DRI_DIRS"
3113        fi
3114        echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
3115fi
3116
3117case "x$enable_glx" in
3118xdri)
3119    echo "        GLX:             DRI-based"
3120    ;;
3121xxlib)
3122    echo "        GLX:             Xlib-based"
3123    ;;
3124xgallium-xlib)
3125    echo "        GLX:             Xlib-based (Gallium)"
3126    ;;
3127*)
3128    echo "        GLX:             $enable_glx"
3129    ;;
3130esac
3131
3132dnl EGL
3133echo ""
3134echo "        EGL:             $enable_egl"
3135if test "$enable_egl" = yes; then
3136
3137    egl_drivers=""
3138    if test "x$enable_dri" != "xno"; then
3139        egl_drivers="$egl_drivers builtin:egl_dri2"
3140    fi
3141    if test "x$enable_dri3" != "xno"; then
3142        egl_drivers="$egl_drivers builtin:egl_dri3"
3143    fi
3144
3145    echo "        EGL drivers:    $egl_drivers"
3146fi
3147if test "x$enable_gbm" = xyes; then
3148    echo "        GBM:             yes"
3149else
3150    echo "        GBM:             no"
3151fi
3152
3153    echo "        EGL/Vulkan/VL platforms:   $platforms"
3154
3155# Vulkan
3156echo ""
3157if test "x$VULKAN_DRIVERS" != x; then
3158    echo "        Vulkan drivers:  $VULKAN_DRIVERS"
3159    echo "        Vulkan ICD dir:  $VULKAN_ICD_INSTALL_DIR"
3160else
3161    echo "        Vulkan drivers:  no"
3162fi
3163
3164echo ""
3165if test "x$enable_llvm" = xyes; then
3166    echo "        llvm:            yes"
3167    echo "        llvm-config:     $LLVM_CONFIG"
3168    echo "        llvm-version:    $LLVM_VERSION"
3169else
3170    echo "        llvm:            no"
3171fi
3172
3173echo ""
3174if test -n "$with_gallium_drivers"; then
3175    echo "        Gallium drivers: $gallium_drivers"
3176    echo "        Gallium st:      $gallium_st"
3177else
3178    echo "        Gallium:         no"
3179fi
3180
3181echo ""
3182if test "x$enable_gallium_extra_hud" != xyes; then
3183    echo "        HUD extra stats: no"
3184else
3185    echo "        HUD extra stats: yes"
3186fi
3187
3188if test "x$enable_lmsensors" != xyes; then
3189    echo "        HUD lmsensors:   no"
3190else
3191    echo "        HUD lmsensors:   yes"
3192fi
3193
3194echo ""
3195if test "x$HAVE_GALLIUM_SWR" != x; then
3196    if test "x$HAVE_SWR_BUILTIN" = xyes; then
3197        echo "        SWR archs:       $swr_archs (builtin)"
3198    else
3199        echo "        SWR archs:       $swr_archs"
3200    fi
3201fi
3202
3203dnl Libraries
3204echo ""
3205echo "        Shared libs:     $enable_shared"
3206echo "        Static libs:     $enable_static"
3207echo "        Shared-glapi:    $enable_shared_glapi"
3208
3209dnl Compiler options
3210# cleanup the CFLAGS/CXXFLAGS/LDFLAGS/DEFINES vars
3211cflags=`echo $CFLAGS | \
3212    $SED 's/^ *//;s/  */ /;s/ *$//'`
3213cxxflags=`echo $CXXFLAGS | \
3214    $SED 's/^ *//;s/  */ /;s/ *$//'`
3215ldflags=`echo $LDFLAGS | $SED 's/^ *//;s/  */ /;s/ *$//'`
3216defines=`echo $DEFINES | $SED 's/^ *//;s/  */ /;s/ *$//'`
3217echo ""
3218echo "        CFLAGS:          $cflags"
3219echo "        CXXFLAGS:        $cxxflags"
3220echo "        CXX11_CXXFLAGS:  $CXX11_CXXFLAGS"
3221echo "        LDFLAGS:         $ldflags"
3222echo "        Macros:          $defines"
3223echo ""
3224if test "x$enable_llvm" = xyes; then
3225    echo "        LLVM_CFLAGS:     $LLVM_CFLAGS"
3226    echo "        LLVM_CXXFLAGS:   $LLVM_CXXFLAGS"
3227    echo "        LLVM_CPPFLAGS:   $LLVM_CPPFLAGS"
3228    echo "        LLVM_LDFLAGS:    $LLVM_LDFLAGS"
3229    echo ""
3230fi
3231echo "        PYTHON2:         $PYTHON2"
3232
3233echo ""
3234echo "        Run '${MAKE-make}' to build Mesa"
3235echo ""
3236