configure.ac 90.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
dnl Copyright © 2011-2014 Intel Corporation
dnl Copyright © 2011-2014 Emil Velikov <emil.l.velikov@gmail.com>
dnl Copyright © 2007-2010 Dan Nicholson
dnl Copyright © 2010-2014 Marek Olšák <maraeo@gmail.com>
dnl Copyright © 2010-2014 Christian König
dnl Copyright © 2012-2014 Tom Stellard <tstellar@gmail.com>
dnl Copyright © 2009-2012 Jakob Bornecrantz
dnl Copyright © 2009-2014 Jon TURNEY
dnl Copyright © 2011-2012 Benjamin Franzke
dnl Copyright © 2008-2014 David Airlie
dnl Copyright © 2009-2013 Brian Paul
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice (including the next
dnl paragraph) shall be included in all copies or substantial portions of the
dnl Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl
32
dnl Process this file with autoconf to create configure.
33

34
AC_PREREQ([2.60])
35

36 37 38 39
dnl Tell the user about autoconf.html in the --help output
m4_divert_once([HELP_END], [
See docs/autoconf.html for more details on the options for Mesa.])

40 41
m4_define(MESA_VERSION, m4_normalize(m4_include(VERSION)))
AC_INIT([Mesa], [MESA_VERSION],
42
    [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
43
AC_CONFIG_AUX_DIR([bin])
44
AC_CONFIG_MACRO_DIR([m4])
45
AC_CANONICAL_SYSTEM
46
AM_INIT_AUTOMAKE([foreign tar-ustar dist-xz subdir-objects])
47

48 49 50 51 52 53 54
dnl We only support native Windows builds (MinGW/MSVC) through SCons.
case "$host_os" in
mingw*)
    AC_MSG_ERROR([MinGW build not supported through autoconf/automake, use SCons instead])
    ;;
esac

55 56 57
# Support silent build rules, requires at least automake-1.11. Disable
# by either passing --disable-silent-rules to configure or passing V=1
# to make
58 59
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
60

61 62
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

Johannes Obermayr's avatar
Johannes Obermayr committed
63 64 65
dnl Set internal versions
OSMESA_VERSION=8
AC_SUBST([OSMESA_VERSION])
66 67
OPENCL_VERSION=1
AC_SUBST([OPENCL_VERSION])
Johannes Obermayr's avatar
Johannes Obermayr committed
68

69 70 71 72 73 74
# The idea is that libdrm is distributed as one cohesive package, even
# though it is composed of multiple libraries. However some drivers
# may have different version requirements than others. This list
# codifies which drivers need which version of libdrm. Any libdrm
# version dependencies in non-driver-specific code should be reflected
# in the first entry.
75
LIBDRM_REQUIRED=2.4.66
76
LIBDRM_RADEON_REQUIRED=2.4.56
77
LIBDRM_AMDGPU_REQUIRED=2.4.63
78
LIBDRM_INTEL_REQUIRED=2.4.75
79 80
LIBDRM_NVVIEUX_REQUIRED=2.4.66
LIBDRM_NOUVEAU_REQUIRED=2.4.66
Rob Clark's avatar
Rob Clark committed
81
LIBDRM_FREEDRENO_REQUIRED=2.4.74
82
LIBDRM_VC4_REQUIRED=2.4.69
83
LIBDRM_ETNAVIV_REQUIRED=2.4.74
84 85

dnl Versions for external dependencies
86
DRI2PROTO_REQUIRED=2.6
Keith Packard's avatar
Keith Packard committed
87 88
DRI3PROTO_REQUIRED=1.0
PRESENTPROTO_REQUIRED=1.0
89
GLPROTO_REQUIRED=1.4.14
90
LIBOMXIL_BELLAGIO_REQUIRED=0.0
91
LIBVA_REQUIRED=0.38.0
92
VDPAU_REQUIRED=1.1
93
WAYLAND_REQUIRED=1.11
94
XCB_REQUIRED=1.9.3
95 96 97 98
XCBDRI2_REQUIRED=1.8
XCBGLX_REQUIRED=1.8.1
XSHMFENCE_REQUIRED=1.1
XVMC_REQUIRED=1.0.6
99
PYTHON_MAKO_REQUIRED=0.8.0
100
LIBSENSORS_REQUIRED=4.0.0
101

102 103 104 105 106 107 108 109
dnl LLVM versions
LLVM_REQUIRED_GALLIUM=3.3.0
LLVM_REQUIRED_OPENCL=3.6.0
LLVM_REQUIRED_R600=3.6.0
LLVM_REQUIRED_RADEONSI=3.6.0
LLVM_REQUIRED_RADV=3.9.0
LLVM_REQUIRED_SWR=3.6.0

110 111 112 113
dnl Check for progs
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CXX
114
AM_PROG_CC_C_O
115
AM_PROG_AS
116
AX_CHECK_GNU_MAKE
117
AC_CHECK_PROGS([PYTHON2], [python2.7 python2 python])
Matt Turner's avatar
Matt Turner committed
118
AC_PROG_SED
119
AC_PROG_MKDIR_P
120

121 122
AC_SYS_LARGEFILE

123 124 125
LT_PREREQ([2.2])
LT_INIT([disable-static])

Jonathan Gray's avatar
Jonathan Gray committed
126
AC_CHECK_PROG(RM, rm, [rm -f])
127
AC_CHECK_PROG(XXD, xxd, [xxd])
Jonathan Gray's avatar
Jonathan Gray committed
128

Matt Turner's avatar
Matt Turner committed
129
AX_PROG_BISON([],
130
              AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-parse.c"],
Matt Turner's avatar
Matt Turner committed
131
                    [AC_MSG_ERROR([bison not found - unable to compile glcpp-parse.y])]))
Matt Turner's avatar
Matt Turner committed
132
AX_PROG_FLEX([],
133
             AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-lex.c"],
Matt Turner's avatar
Matt Turner committed
134
                   [AC_MSG_ERROR([flex not found - unable to compile glcpp-lex.l])]))
135

136 137
AC_CHECK_PROG(INDENT, indent, indent, cat)
if test "x$INDENT" != "xcat"; then
138 139 140 141 142 143 144
    # Only GNU indent is supported
    INDENT_VERSION=`indent --version | grep GNU`
    if test $? -eq 0; then
       AC_SUBST(INDENT_FLAGS, '-i4 -nut -br -brs -npcs -ce -TGLubyte -TGLbyte -TBool')
    else
       INDENT="cat"
    fi
145 146
fi

147
AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED)
148 149 150 151 152 153 154 155 156 157 158

if test -z "$PYTHON2"; then
    if test ! -f "$srcdir/src/util/format_srgb.c"; then
        AC_MSG_ERROR([Python not found - unable to generate sources])
    fi
else
    if test "x$acv_mako_found" = xno; then
        if test ! -f "$srcdir/src/mesa/main/format_unpack.c"; then
            AC_MSG_ERROR([Python mako module v$PYTHON_MAKO_REQUIRED or higher not found])
        fi
    fi
159
fi
160

161 162
AC_PROG_INSTALL

163 164
dnl We need a POSIX shell for parts of the build. Assume we have one
dnl in most cases.
165 166 167 168
case "$host_os" in
solaris*)
    # Solaris /bin/sh is too old/non-POSIX compliant
    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
169
    SHELL="$POSIX_SHELL"
170 171 172
    ;;
esac

173 174 175 176 177 178 179 180 181 182
dnl clang is mostly GCC-compatible, but its version is much lower,
dnl so we have to check for it.
AC_MSG_CHECKING([if compiling with clang])

AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
       not clang
#endif
]])],
183
[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
184

185
AC_MSG_RESULT([$acv_mesa_CLANG])
186

187
dnl If we're using GCC, make sure that it is at least version 4.2.0.  Older
Ian Romanick's avatar
Ian Romanick committed
188
dnl versions are explictly not supported.
189
GEN_ASM_OFFSETS=no
190
USE_GNU99=no
191
if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
Ian Romanick's avatar
Ian Romanick committed
192 193 194 195 196 197
    AC_MSG_CHECKING([whether gcc version is sufficient])
    major=0
    minor=0

    GCC_VERSION=`$CC -dumpversion`
    if test $? -eq 0; then
Tom Stellard's avatar
Tom Stellard committed
198 199
        GCC_VERSION_MAJOR=`echo $GCC_VERSION | cut -d. -f1`
        GCC_VERSION_MINOR=`echo $GCC_VERSION | cut -d. -f2`
Ian Romanick's avatar
Ian Romanick committed
200 201
    fi

202
    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 2 ; then
Ian Romanick's avatar
Ian Romanick committed
203
        AC_MSG_RESULT([no])
204
        AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
Ian Romanick's avatar
Ian Romanick committed
205 206 207
    else
        AC_MSG_RESULT([yes])
    fi
208

209 210 211
    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 6 ; then
        USE_GNU99=yes
    fi
212 213 214
    if test "x$cross_compiling" = xyes; then
        GEN_ASM_OFFSETS=yes
    fi
Ian Romanick's avatar
Ian Romanick committed
215
fi
216

217 218 219 220 221 222 223
dnl We don't support building Mesa with Sun C compiler
dnl https://bugs.freedesktop.org/show_bug.cgi?id=93189
AC_CHECK_DECL([__SUNPRO_C], [SUNCC=yes], [SUNCC=no])
if test "x$SUNCC" = xyes; then
    AC_MSG_ERROR([Building with Sun C compiler is not supported, use GCC instead.])
fi

224 225
dnl Check for compiler builtins
AX_GCC_BUILTIN([__builtin_bswap32])
Tom Stellard's avatar
Tom Stellard committed
226
AX_GCC_BUILTIN([__builtin_bswap64])
227 228 229 230 231 232 233 234 235
AX_GCC_BUILTIN([__builtin_clz])
AX_GCC_BUILTIN([__builtin_clzll])
AX_GCC_BUILTIN([__builtin_ctz])
AX_GCC_BUILTIN([__builtin_expect])
AX_GCC_BUILTIN([__builtin_ffs])
AX_GCC_BUILTIN([__builtin_ffsll])
AX_GCC_BUILTIN([__builtin_popcount])
AX_GCC_BUILTIN([__builtin_popcountll])
AX_GCC_BUILTIN([__builtin_unreachable])
236

237
AX_GCC_FUNC_ATTRIBUTE([const])
238 239
AX_GCC_FUNC_ATTRIBUTE([flatten])
AX_GCC_FUNC_ATTRIBUTE([format])
240
AX_GCC_FUNC_ATTRIBUTE([malloc])
241
AX_GCC_FUNC_ATTRIBUTE([packed])
242
AX_GCC_FUNC_ATTRIBUTE([pure])
243
AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
244
AX_GCC_FUNC_ATTRIBUTE([unused])
245
AX_GCC_FUNC_ATTRIBUTE([visibility])
246
AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
247
AX_GCC_FUNC_ATTRIBUTE([weak])
248
AX_GCC_FUNC_ATTRIBUTE([alias])
249

250
AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes)
Ian Romanick's avatar
Ian Romanick committed
251

252
dnl Make sure the pkg-config macros are defined
253 254 255 256 257
m4_ifndef([PKG_PROG_PKG_CONFIG],
    [m4_fatal([Could not locate the pkg-config autoconf macros.
  These are usually located in /usr/share/aclocal/pkg.m4. If your macros
  are in a different location, try setting the environment variable
  ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
258 259 260 261
PKG_PROG_PKG_CONFIG()

dnl LIB_DIR - library basename
LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
262
AC_SUBST([LIB_DIR])
263

Matt Turner's avatar
Matt Turner committed
264
dnl Cache LDFLAGS and CPPFLAGS so we can add to them and restore later
265 266 267 268
_SAVE_LDFLAGS="$LDFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"

dnl Compiler macros
269
DEFINES="-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
270
AC_SUBST([DEFINES])
271
android=no
272
case "$host_os" in
273 274 275
*-android)
    android=yes
    ;;
276
linux*|*-gnu*|gnu*|cygwin*)
277
    DEFINES="$DEFINES -D_GNU_SOURCE"
278
    ;;
279
solaris*)
280
    DEFINES="$DEFINES -DSVR4"
281
    ;;
282 283
esac

284 285
AM_CONDITIONAL(HAVE_ANDROID, test "x$android" = xyes)

286 287
dnl Add flags for gcc and g++
if test "x$GCC" = xyes; then
288 289 290 291 292 293 294
    CFLAGS="$CFLAGS -Wall"

    if test "x$USE_GNU99" = xyes; then
	CFLAGS="$CFLAGS -std=gnu99"
    else
	CFLAGS="$CFLAGS -std=c99"
    fi
295 296 297 298 299 300 301 302 303 304 305 306 307

    # Enable -Werror=implicit-function-declaration and
    # -Werror=missing-prototypes, if available, or otherwise, just
    # -Wmissing-prototypes.  This is particularly useful to avoid
    # generating a loadable driver module that has undefined symbols.
    save_CFLAGS="$CFLAGS"
    AC_MSG_CHECKING([whether $CC supports -Werror=missing-prototypes])
    CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
    CFLAGS="$CFLAGS -Werror=missing-prototypes"
    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
		   AC_MSG_RESULT([yes]),
		   [CFLAGS="$save_CFLAGS -Wmissing-prototypes";
		    AC_MSG_RESULT([no])]);
308 309 310

    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CFLAGS="$CFLAGS"
311
    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
312 313
    VISIBILITY_CFLAGS="-fvisibility=hidden"
    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
314
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
315 316 317 318
		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);

    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
    CFLAGS=$save_CFLAGS
319

320 321
    # We don't want floating-point math functions to set errno or trap
    CFLAGS="$CFLAGS -fno-math-errno -fno-trapping-math"
322

323 324
    # Flags to help ensure that certain portions of the code -- and only those
    # portions -- can be built with MSVC:
325
    # - src/util, src/gallium/auxiliary, rc/gallium/drivers/llvmpipe, and
326 327 328
    # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which
    #   supports most of C99)
    # - the rest has no compiler compiler restrictions
329 330 331 332 333 334 335 336 337 338 339 340 341
    MSVC2013_COMPAT_CFLAGS="-Werror=pointer-arith"
    MSVC2013_COMPAT_CXXFLAGS="-Werror=pointer-arith"

    # Enable -Werror=vla if compiler supports it
    save_CFLAGS="$CFLAGS"
    AC_MSG_CHECKING([whether $CC supports -Werror=vla])
    CFLAGS="$CFLAGS -Werror=vla"
    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
		   [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=vla";
		    MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=vla";
		    AC_MSG_RESULT([yes])],
		    AC_MSG_RESULT([no]));
    CFLAGS="$save_CFLAGS"
342 343 344
fi
if test "x$GXX" = xyes; then
    CXXFLAGS="$CXXFLAGS -Wall"
345

346 347 348
    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CXXFLAGS="$CXXFLAGS"
    AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
349 350
    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
    CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
351
    AC_LANG_PUSH([C++])
352
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
353
		   [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
354
    AC_LANG_POP([C++])
355 356 357

    # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
    CXXFLAGS=$save_CXXFLAGS
358

359 360
    # We don't want floating-point math functions to set errno or trap
    CXXFLAGS="$CXXFLAGS -fno-math-errno -fno-trapping-math"
361 362
fi

363 364 365
AC_SUBST([MSVC2013_COMPAT_CFLAGS])
AC_SUBST([MSVC2013_COMPAT_CXXFLAGS])

366 367 368 369 370 371 372 373 374
dnl even if the compiler appears to support it, using visibility attributes isn't
dnl going to do anything useful currently on cygwin apart from emit lots of warnings
case "$host_os" in
cygwin*)
    VISIBILITY_CFLAGS=""
    VISIBILITY_CXXFLAGS=""
    ;;
esac

375 376 377
AC_SUBST([VISIBILITY_CFLAGS])
AC_SUBST([VISIBILITY_CXXFLAGS])

378 379 380
dnl
dnl Optional flags, check for compiler support
dnl
381 382 383 384 385 386 387 388
SSE41_CFLAGS="-msse4.1"
dnl Code compiled by GCC with -msse* assumes a 16 byte aligned
dnl stack, but on x86-32 such alignment is not guaranteed.
case "$target_cpu" in
i?86)
    SSE41_CFLAGS="$SSE41_CFLAGS -mstackrealign"
    ;;
esac
389
save_CFLAGS="$CFLAGS"
390
CFLAGS="$SSE41_CFLAGS $CFLAGS"
391 392
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <smmintrin.h>
393
int param;
394
int main () {
395
    __m128i a = _mm_set1_epi32 (param), b = _mm_set1_epi32 (param + 1), c;
396
    c = _mm_max_epu32(a, b);
397
    return _mm_cvtsi128_si32(c);
398 399
}]])], SSE41_SUPPORTED=1)
CFLAGS="$save_CFLAGS"
400 401 402
if test "x$SSE41_SUPPORTED" = x1; then
    DEFINES="$DEFINES -DUSE_SSE41"
fi
403
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
404
AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS)
405

406 407 408 409 410 411 412 413 414 415 416
dnl Check for new-style atomic builtins
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
int main() {
    int n;
    return __atomic_load_n(&n, __ATOMIC_ACQUIRE);
}]])], GCC_ATOMIC_BUILTINS_SUPPORTED=1)
if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then
    DEFINES="$DEFINES -DUSE_GCC_ATOMIC_BUILTINS"
fi
AM_CONDITIONAL([GCC_ATOMIC_BUILTINS_SUPPORTED], [test x$GCC_ATOMIC_BUILTINS_SUPPORTED = x1])

417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
dnl Check for Endianness
AC_C_BIGENDIAN(
   little_endian=no,
   little_endian=yes,
   little_endian=no,
   little_endian=no
)

dnl Check for POWER8 Architecture
PWR8_CFLAGS="-mpower8-vector"
have_pwr8_intrinsics=no
AC_MSG_CHECKING(whether gcc supports -mpower8-vector)
save_CFLAGS=$CFLAGS
CFLAGS="$PWR8_CFLAGS $CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
#error "Need GCC >= 4.8 for sane POWER8 support"
#endif
#include <altivec.h>
int main () {
    vector unsigned char r;
    vector unsigned int v = vec_splat_u32 (1);
    r = __builtin_vec_vgbbd ((vector unsigned char) v);
    return 0;
}]])], have_pwr8_intrinsics=yes)
CFLAGS=$save_CFLAGS

AC_ARG_ENABLE(pwr8,
   [AC_HELP_STRING([--disable-pwr8-inst],
                   [disable POWER8-specific instructions])],
   [enable_pwr8=$enableval], [enable_pwr8=auto])

if test "x$enable_pwr8" = xno ; then
   have_pwr8_intrinsics=disabled
fi

if test $have_pwr8_intrinsics = yes && test $little_endian = yes ; then
   DEFINES="$DEFINES -D_ARCH_PWR8"
   CXXFLAGS="$CXXFLAGS $PWR8_CFLAGS"
   CFLAGS="$CFLAGS $PWR8_CFLAGS"
else
   PWR8_CFLAGS=
fi

AC_MSG_RESULT($have_pwr8_intrinsics)
if test "x$enable_pwr8" = xyes && test $have_pwr8_intrinsics = no ; then
   AC_MSG_ERROR([POWER8 compiler support not detected])
fi

if test $have_pwr8_intrinsics = yes && test $little_endian = no ; then
   AC_MSG_WARN([POWER8 optimization is enabled only on POWER8 Little-Endian])
fi

AC_SUBST([PWR8_CFLAGS], $PWR8_CFLAGS)

472 473
dnl Can't have static and shared libraries, default to static if user
dnl explicitly requested. If both disabled, set to static since shared
474
dnl was explicitly requested.
475
case "x$enable_static$enable_shared" in
476
xyesyes)
477
    AC_MSG_ERROR([Cannot enable both static and shared. Building using --enable-shared is strongly recommended])
478
    ;;
479
xnono)
480
    AC_MSG_ERROR([Cannot disable both static and shared. Building using --enable-shared is strongly recommended])
481 482 483
    ;;
esac

484 485
AM_CONDITIONAL(BUILD_SHARED, test "x$enable_shared" = xyes)

486 487 488
dnl
dnl other compiler options
dnl
489
AC_ARG_ENABLE([debug],
490 491
    [AS_HELP_STRING([--enable-debug],
        [use debug compiler flags and macros @<:@default=disabled@:>@])],
492 493
    [enable_debug="$enableval"],
    [enable_debug=no]
494
)
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512

AC_ARG_ENABLE([profile],
    [AS_HELP_STRING([--enable-profile],
        [enable profiling of code @<:@default=disabled@:>@])],
    [enable_profile="$enableval"],
    [enable_profile=no]
)

if test "x$enable_profile" = xyes; then
    DEFINES="$DEFINES -DPROFILE"
    if test "x$GCC" = xyes; then
        CFLAGS="$CFLAGS -fno-omit-frame-pointer"
    fi
    if test "x$GXX" = xyes; then
        CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer"
    fi
fi

513 514
if test "x$enable_debug" = xyes; then
    DEFINES="$DEFINES -DDEBUG"
515 516 517
    if test "x$enable_profile" = xyes; then
        AC_MSG_WARN([Debug and Profile are enabled at the same time])
    fi
518
    if test "x$GCC" = xyes; then
519 520 521 522 523 524
        if ! echo "$CFLAGS" | grep -q -e '-g'; then
            CFLAGS="$CFLAGS -g"
        fi
        if ! echo "$CFLAGS" | grep -q -e '-O'; then
            CFLAGS="$CFLAGS -O0"
        fi
525 526
    fi
    if test "x$GXX" = xyes; then
527 528 529 530 531 532
        if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
            CXXFLAGS="$CXXFLAGS -g"
        fi
        if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
            CXXFLAGS="$CXXFLAGS -O0"
        fi
533
    fi
534 535
else
   DEFINES="$DEFINES -DNDEBUG"
536
fi
537

Jon Turney's avatar
Jon Turney committed
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
dnl
dnl Check if linker supports -Bsymbolic
dnl
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
AC_MSG_CHECKING([if ld supports -Bsymbolic])
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([int main() { return 0;}])],
    [AC_MSG_RESULT([yes])
        BSYMBOLIC="-Wl,-Bsymbolic";],
    [AC_MSG_RESULT([no])
        BSYMBOLIC="";])
LDFLAGS=$save_LDFLAGS

AC_SUBST([BSYMBOLIC])

554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
dnl
dnl Check if linker supports garbage collection
dnl
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--gc-sections"
AC_MSG_CHECKING([whether ld supports --gc-sections])
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([static char UnusedFunc() { return 5; } int main() { return 0;}])],
    [AC_MSG_RESULT([yes])
        GC_SECTIONS="-Wl,--gc-sections";],
    [AC_MSG_RESULT([no])
        GC_SECTIONS="";])
LDFLAGS=$save_LDFLAGS

AC_SUBST([GC_SECTIONS])

570 571 572 573 574
dnl
dnl OpenBSD does not have DT_NEEDED entries for libc by design
dnl so when these flags are passed to ld via libtool the checks will fail
dnl
case "$host_os" in
575
openbsd* | darwin* )
576 577 578 579 580 581 582
    LD_NO_UNDEFINED="" ;;
*)
    LD_NO_UNDEFINED="-Wl,--no-undefined" ;;
esac

AC_SUBST([LD_NO_UNDEFINED])

Jon Turney's avatar
Jon Turney committed
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
dnl
dnl Check if linker supports version scripts
dnl
AC_MSG_CHECKING([if the linker supports version-scripts])
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
cat > conftest.map <<EOF
VERSION_1 {
     global:
         main;

     local:
         *;
};
EOF
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([int main() { return 0;}])],
    [have_ld_version_script=yes;AC_MSG_RESULT(yes)],
    [have_ld_version_script=no; AC_MSG_RESULT(no)])
LDFLAGS=$save_LDFLAGS
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")

605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
dnl
dnl Check if linker supports dynamic list files
dnl
AC_MSG_CHECKING([if the linker supports --dynamic-list])
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--dynamic-list=conftest.dyn"
cat > conftest.dyn <<EOF
{
	radeon_drm_winsys_create;
};
EOF
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([int main() { return 0;}])],
    [have_ld_dynamic_list=yes;AC_MSG_RESULT(yes)],
    [have_ld_dynamic_list=no; AC_MSG_RESULT(no)])
LDFLAGS=$save_LDFLAGS
AM_CONDITIONAL(HAVE_LD_DYNAMIC_LIST, test "$have_ld_dynamic_list" = "yes")

623 624 625 626 627 628 629 630 631 632 633 634
dnl
dnl compatibility symlinks
dnl
case "$host_os" in
linux* )
    HAVE_COMPAT_SYMLINKS=yes ;;
* )
    HAVE_COMPAT_SYMLINKS=no ;;
esac

AM_CONDITIONAL(HAVE_COMPAT_SYMLINKS, test "x$HAVE_COMPAT_SYMLINKS" = xyes)

635 636 637
dnl
dnl library names
dnl
638 639 640 641 642 643 644 645 646
dnl Unfortunately we need to do a few things that libtool can't help us with,
dnl so we need some knowledge of shared library filenames:
dnl
dnl LIB_EXT is the extension used when creating symlinks for alternate
dnl filenames for a shared library which will be dynamically loaded
dnl
dnl IMP_LIB_EXT is the extension used when checking for the presence of a
dnl the file for a shared library we wish to link with
dnl
647 648
case "$host_os" in
darwin* )
649 650 651
    LIB_EXT='dylib'
    IMP_LIB_EXT=$LIB_EXT
    ;;
652
cygwin* )
653 654 655
    LIB_EXT='dll'
    IMP_LIB_EXT='dll.a'
    ;;
656
aix* )
657 658 659
    LIB_EXT='a'
    IMP_LIB_EXT=$LIB_EXT
    ;;
660
* )
661 662 663
    LIB_EXT='so'
    IMP_LIB_EXT=$LIB_EXT
    ;;
664
esac
665 666 667

AC_SUBST([LIB_EXT])

668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
dnl
dnl potentially-infringing-but-nobody-knows-for-sure stuff
dnl
AC_ARG_ENABLE([texture-float],
    [AS_HELP_STRING([--enable-texture-float],
        [enable floating-point textures and renderbuffers @<:@default=disabled@:>@])],
    [enable_texture_float="$enableval"],
    [enable_texture_float=no]
)
if test "x$enable_texture_float" = xyes; then
    AC_MSG_WARN([Floating-point textures enabled.])
    AC_MSG_WARN([Please consult docs/patents.txt with your lawyer before building Mesa.])
    DEFINES="$DEFINES -DTEXTURE_FLOAT_ENABLED"
fi

683 684 685 686 687 688 689 690 691 692 693 694 695
dnl
dnl Arch/platform-specific settings
dnl
AC_ARG_ENABLE([asm],
    [AS_HELP_STRING([--disable-asm],
        [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
    [enable_asm="$enableval"],
    [enable_asm=yes]
)
asm_arch=""
AC_MSG_CHECKING([whether to enable assembly])
test "x$enable_asm" = xno && AC_MSG_RESULT([no])
# disable if cross compiling on x86/x86_64 since we must run gen_matypes
696
if test "x$enable_asm" = xyes -a "x$cross_compiling" = xyes; then
697
    case "$host_cpu" in
698
    i?86 | x86_64 | amd64)
699 700 701 702
        if test "x$host_cpu" != "x$target_cpu"; then
            enable_asm=no
            AC_MSG_RESULT([no, cross compiling])
        fi
703 704 705 706 707 708 709 710
        ;;
    esac
fi
# check for supported arches
if test "x$enable_asm" = xyes; then
    case "$host_cpu" in
    i?86)
        case "$host_os" in
711
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | gnu*)
712 713
            asm_arch=x86
            ;;
714 715
        esac
        ;;
716
    x86_64|amd64)
717
        case "$host_os" in
Jonathan Gray's avatar
Jonathan Gray committed
718
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
719
            asm_arch=x86_64
720 721 722
            ;;
        esac
        ;;
723 724 725 726 727 728 729
    sparc*)
        case "$host_os" in
        linux*)
            asm_arch=sparc
            ;;
        esac
        ;;
730 731 732 733
    esac

    case "$asm_arch" in
    x86)
734
        DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
735 736
        AC_MSG_RESULT([yes, x86])
        ;;
737
    x86_64|amd64)
738
        DEFINES="$DEFINES -DUSE_X86_64_ASM"
739 740
        AC_MSG_RESULT([yes, x86_64])
        ;;
741
    sparc)
742
        DEFINES="$DEFINES -DUSE_SPARC_ASM"
743 744
        AC_MSG_RESULT([yes, sparc])
        ;;
745 746 747 748 749 750
    *)
        AC_MSG_RESULT([no, platform not supported])
        ;;
    esac
fi

751
AC_HEADER_MAJOR
752
AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
753
AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
754
AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
755
AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
756

757 758
dnl Check to see if dlopen is in default libraries (like Solaris, which
dnl has it in libc), or if libdl is needed to get it.
759 760 761
AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
    [AC_CHECK_LIB([dl], [dlopen],
       [DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])])
Chia-I Wu's avatar
Chia-I Wu committed
762
AC_SUBST([DLOPEN_LIBS])
763

764
dnl Check if that library also has dladdr
765 766 767 768
save_LIBS="$LIBS"
LIBS="$LIBS $DLOPEN_LIBS"
AC_CHECK_FUNCS([dladdr])
LIBS="$save_LIBS"
769

770
case "$host_os" in
771
darwin*)
772 773 774 775
    ;;
*)
    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
                   [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
776
                                 [AC_MSG_ERROR([Could not find clock_gettime])])])
777 778 779
    AC_SUBST([CLOCK_LIB])
    ;;
esac
780

781 782 783
dnl See if posix_memalign is available
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])

784
dnl Check for pthreads
785 786 787 788
AX_PTHREAD
if test "x$ax_pthread_ok" = xno; then
    AC_MSG_ERROR([Building mesa on this platform requires pthreads])
fi
789 790
dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS
dnl to -pthread, which causes problems if we need -lpthread to appear in
791 792 793 794 795
dnl pkgconfig files.  Since Android doesn't have a pthread lib, this check
dnl is not valid for that platform.
if test "x$android" = xno; then
    test -z "$PTHREAD_LIBS" && PTHREAD_LIBS="-lpthread"
fi
796

797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
dnl pthread-stubs is mandatory on targets where it exists
case "$host_os" in
cygwin* )
    pthread_stubs_possible="no"
    ;;
* )
    pthread_stubs_possible="yes"
    ;;
esac

if test "x$pthread_stubs_possible" = xyes; then
    PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs)
    AC_SUBST(PTHREADSTUBS_CFLAGS)
    AC_SUBST(PTHREADSTUBS_LIBS)
fi
812

813 814 815 816 817 818 819
dnl SELinux awareness.
AC_ARG_ENABLE([selinux],
    [AS_HELP_STRING([--enable-selinux],
        [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
    [MESA_SELINUX="$enableval"],
    [MESA_SELINUX=no])
if test "x$enable_selinux" = "xyes"; then
820 821 822 823 824 825
    PKG_CHECK_MODULES([SELINUX], [libselinux], [],
        [AC_CHECK_HEADER([selinux/selinux.h],[],
                         [AC_MSG_ERROR([SELinux headers not found])])
         AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
                      [AC_MSG_ERROR([SELinux library not found])])
         SELINUX_LIBS="-lselinux"])
826 827
    DEFINES="$DEFINES -DMESA_SELINUX"
fi
828
AC_SUBST([SELINUX_CFLAGS])
829
AC_SUBST([SELINUX_LIBS])
830

831 832 833
dnl
dnl LLVM
dnl
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854
AC_ARG_ENABLE([llvm-shared-libs],
    [AS_HELP_STRING([--enable-llvm-shared-libs],
        [link with LLVM shared libraries @<:@default=enabled@:>@])],
    [enable_llvm_shared_libs="$enableval"],
    [enable_llvm_shared_libs=yes])

AC_ARG_WITH([llvm-prefix],
    [AS_HELP_STRING([--with-llvm-prefix],
        [Prefix for LLVM installations in non-standard locations])],
    [llvm_prefix="$withval"],
    [llvm_prefix=''])

PKG_CHECK_MODULES([LIBELF], [libelf], [have_libelf=yes], [have_libelf=no])
if test "x$have_libelf" = xno; then
   LIBELF_LIBS=''
   LIBELF_CFLAGS=''
   AC_CHECK_LIB([elf], [elf_memory], [have_libelf=yes;LIBELF_LIBS=-lelf], [have_libelf=no])
   AC_SUBST([LIBELF_LIBS])
   AC_SUBST([LIBELF_CFLAGS])
fi

855 856 857 858 859 860 861 862
if test -z "$LLVM_CONFIG"; then
    if test -n "$llvm_prefix"; then
        AC_PATH_TOOL([LLVM_CONFIG], [llvm-config], [no], ["$llvm_prefix/bin"])
    else
        AC_PATH_TOOL([LLVM_CONFIG], [llvm-config], [no])
    fi
fi

863 864 865 866
llvm_add_component() {
    new_llvm_component=$1
    driver_name=$2

867 868 869 870 871
    if $LLVM_CONFIG --components | grep -iqw $new_llvm_component ; then
        LLVM_COMPONENTS="${LLVM_COMPONENTS} ${new_llvm_component}"
    else
        AC_MSG_ERROR([LLVM component '$new_llvm_component' not enabled in your LLVM build. Required by $driver_name.])
    fi
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
}

llvm_add_default_components() {
    driver_name=$1

    # Required default components
    llvm_add_component "bitwriter" $driver_name
    llvm_add_component "engine" $driver_name
    llvm_add_component "mcdisassembler" $driver_name
    llvm_add_component "mcjit" $driver_name

    # Optional default components
    if $LLVM_CONFIG --components | grep -iqw inteljitevents ; then
        LLVM_COMPONENTS="$LLVM_COMPONENTS inteljitevents"
    fi
}

llvm_add_target() {
    new_llvm_target=$1
    driver_name=$2

    if $LLVM_CONFIG --targets-built | grep -iqw $new_llvm_target ; then
        llvm_add_component $new_llvm_target $driver_name
    else
        AC_MSG_ERROR([LLVM target '$new_llvm_target' not enabled in your LLVM build. Required by $driver_name.])
    fi
}

900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926
# Call this inside ` ` to get the return value.
# $1 is the llvm-config command with arguments.
strip_unwanted_llvm_flags() {
    # Use \> (marks the end of the word)
    echo `$1` | sed \
        -e 's/-march=\S*//g' \
        -e 's/-mtune=\S*//g' \
        -e 's/-mcpu=\S*//g' \
        -e 's/-DNDEBUG\>//g' \
        -e 's/-D_GNU_SOURCE\>//g' \
        -e 's/-pedantic\>//g' \
        -e 's/-Wcovered-switch-default\>//g' \
        -e 's/-O.\>//g' \
        -e 's/-g\>//g' \
        -e 's/-Wall\>//g' \
        -e 's/-Wcast-qual\>//g' \
        -e 's/-Woverloaded-virtual\>//g' \
        -e 's/-fcolor-diagnostics\>//g' \
        -e 's/-fdata-sections\>//g' \
        -e 's/-ffunction-sections\>//g' \
        -e 's/-fno-exceptions\>//g' \
        -e 's/-fomit-frame-pointer\>//g' \
        -e 's/-fvisibility-inlines-hidden\>//g' \
        -e 's/-fPIC\>//g' \
        -e 's/-fstack-protector-strong\>//g'
}

927 928 929 930 931 932 933
llvm_set_environment_variables() {
    if test "x$LLVM_CONFIG" != xno; then
        LLVM_VERSION=`$LLVM_CONFIG --version | egrep -o '^[[0-9.]]+'`
        LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"`
        LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir`
        LLVM_LIBDIR=`$LLVM_CONFIG --libdir`

934
        # We need to respect LLVM_CPPFLAGS when compiling LLVM headers.
935
        save_CFLAGS="$CFLAGS"
936
        CFLAGS="$CFLAGS $LLVM_CPPFLAGS"
937

938 939 940 941
        AC_COMPUTE_INT([LLVM_VERSION_MAJOR], [LLVM_VERSION_MAJOR],
            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
        AC_COMPUTE_INT([LLVM_VERSION_MINOR], [LLVM_VERSION_MINOR],
            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
942 943
        AC_COMPUTE_INT([LLVM_VERSION_PATCH], [LLVM_VERSION_PATCH],
            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
944

945 946
        CFLAGS="$save_CFLAGS"

947
        # Only needed for LLVM < 3.6.0
948 949 950 951
        if test -z "$LLVM_VERSION_PATCH"; then
            LLVM_VERSION_PATCH=0
        fi

952
        LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}"
953

954
        FOUND_LLVM=yes
955
    else
956
        FOUND_LLVM=no
957 958 959 960
        LLVM_VERSION_INT=0
    fi
}

961
require_llvm() {
962 963
    if test "x$enable_llvm" != "xyes"; then
        AC_MSG_ERROR([--enable-llvm is required when building $1])
964 965 966
    fi
}

967 968
llvm_require_version() {
    require_llvm $2
969 970 971 972 973 974 975 976 977

    llvm_target_version_major=`echo $1 | cut -d. -f1 | egrep -o '^[[0-9]]+'`
    llvm_target_version_minor=`echo $1 | cut -d. -f2 | egrep -o '^[[0-9]]+'`
    llvm_target_version_patch=`echo $1 | cut -d. -f3 | egrep -o '^[[0-9]]+'`

    if test "$LLVM_VERSION_MAJOR" -gt "$llvm_target_version_major"; then
        # major > required major
        #  --> OK
        return
978
    fi
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999

    if test "$LLVM_VERSION_MAJOR" -eq "$llvm_target_version_major"; then
        if test "$LLVM_VERSION_MINOR" -gt "$llvm_target_version_minor"; then
            # major = required major and
            # minor > required minor
            #  --> OK
            return
        else
            if test "$LLVM_VERSION_MINOR" -eq "$llvm_target_version_minor"; then
                if test "$LLVM_VERSION_PATCH" -ge "$llvm_target_version_patch"; then
                    # major = required major and
                    # minor = required minor and
                    # patch >= required patch
                    #  --> OK
                    return
                fi
            fi
        fi
    fi

    AC_MSG_ERROR([LLVM $1 or newer is required for $2])
1000 1001 1002 1003 1004 1005 1006 1007 1008
}

radeon_llvm_check() {
    if test ${LLVM_VERSION_INT} -lt 307; then
        amdgpu_llvm_target_name='r600'
    else
        amdgpu_llvm_target_name='amdgpu'
    fi

1009
    llvm_require_version $*
1010

1011
    llvm_add_target $amdgpu_llvm_target_name $2
1012

1013 1014 1015
    llvm_add_default_components $2
    llvm_add_component "bitreader" $2
    llvm_add_component "ipo" $2
1016 1017 1018 1019 1020 1021 1022

    NEED_RADEON_LLVM=yes
    if test "x$have_libelf" != xyes; then
       AC_MSG_ERROR([$1 requires libelf when using llvm])
    fi
}

1023 1024 1025 1026 1027 1028 1029 1030
llvm_set_environment_variables

AC_SUBST([LLVM_CFLAGS])
AC_SUBST([LLVM_CXXFLAGS])
AC_SUBST([LLVM_LIBS])
AC_SUBST([LLVM_LDFLAGS])
AC_SUBST([LLVM_INCLUDEDIR])

1031
dnl Options for APIs
1032 1033
AC_ARG_ENABLE([opengl],
    [AS_HELP_STRING([--disable-opengl],
1034
        [disable support for standard OpenGL API @<:@default=enabled@:>@])],
1035 1036 1037
    [enable_opengl="$enableval"],
    [enable_opengl=yes])
AC_ARG_ENABLE([gles1],
1038 1039
    [AS_HELP_STRING([--disable-gles1],
        [disable support for OpenGL ES 1.x API @<:@default=enabled@:>@])],
1040
    [enable_gles1="$enableval"],
1041
    [enable_gles1=yes])
1042
AC_ARG_ENABLE([gles2],
1043 1044
    [AS_HELP_STRING([--disable-gles2],
        [disable support for OpenGL ES 2.x API @<:@default=enabled@:>@])],
1045
    [enable_gles2="$enableval"],
1046
    [enable_gles2=yes])
1047 1048 1049

AC_ARG_ENABLE([dri],
    [AS_HELP_STRING([--enable-dri],
1050
        [enable DRI modules @<:@default=enabled@:>@])],
1051
    [enable_dri="$enableval"],
1052
    [enable_dri=yes])
1053

1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
AC_ARG_ENABLE([gallium-extra-hud],
    [AS_HELP_STRING([--enable-gallium-extra-hud],
        [enable HUD block/NIC I/O HUD stats support @<:@default=disabled@:>@])],
    [enable_gallium_extra_hud="$enableval"],
    [enable_gallium_extra_hud=no])
AM_CONDITIONAL(HAVE_GALLIUM_EXTRA_HUD, test "x$enable_gallium_extra_hud" = xyes)
if test "x$enable_gallium_extra_hud" = xyes ; then
    DEFINES="${DEFINES} -DHAVE_GALLIUM_EXTRA_HUD=1"
fi

#TODO: no pkgconfig .pc available for libsensors.
#PKG_CHECK_MODULES([LIBSENSORS], [libsensors >= $LIBSENSORS_REQUIRED], [enable_lmsensors=yes], [enable_lmsensors=no])
AC_ARG_ENABLE([lmsensors],
    [AS_HELP_STRING([--enable-lmsensors],
        [enable HUD lmsensor support @<:@default=disabled@:>@])],
    [enable_lmsensors="$enableval"],
    [enable_lmsensors=no])
AM_CONDITIONAL(HAVE_LIBSENSORS, test "x$enable_lmsensors" = xyes)
if test "x$enable_lmsensors" = xyes ; then
    DEFINES="${DEFINES} -DHAVE_LIBSENSORS=1"
1074
    LIBSENSORS_LIBS="-lsensors"
1075
else
1076
    LIBSENSORS_LIBS=""
1077
fi
1078
AC_SUBST(LIBSENSORS_LIBS)
1079

1080 1081 1082 1083 1084 1085 1086 1087
case "$host_os" in
linux*)
    dri3_default=yes
    ;;
*)
    dri3_default=no
    ;;
esac
1088 1089 1090 1091 1092

if test "x$enable_dri" = xno; then
    dri3_default=no
fi

1093 1094
AC_ARG_ENABLE([dri3],
    [AS_HELP_STRING([--enable-dri3],
1095
        [enable DRI3 @<:@default=auto@:>@])],
1096
    [enable_dri3="$enableval"],
1097
    [enable_dri3="$dri3_default"])
1098
AC_ARG_ENABLE([glx],
1099 1100
    [AS_HELP_STRING([--enable-glx@<:@=dri|xlib|gallium-xlib@:>@],
        [enable the GLX library and choose an implementation @<:@default=auto@:>@])],
1101
    [enable_glx="$enableval"],
1102
    [enable_glx=yes])
1103 1104
AC_ARG_ENABLE([osmesa],
    [AS_HELP_STRING([--enable-osmesa],
1105
        [enable OSMesa library @<:@default=disabled@:>@])],
1106
    [enable_osmesa="$enableval"],
1107
    [enable_osmesa=no])
1108 1109 1110 1111 1112
AC_ARG_ENABLE([gallium-osmesa],
    [AS_HELP_STRING([--enable-gallium-osmesa],
        [enable Gallium implementation of the OSMesa library @<:@default=disabled@:>@])],
    [enable_gallium_osmesa="$enableval"],
    [enable_gallium_osmesa=no])
1113 1114 1115 1116 1117 1118
AC_ARG_ENABLE([egl],
    [AS_HELP_STRING([--disable-egl],
        [disable EGL library @<:@default=enabled@:>@])],
    [enable_egl="$enableval"],
    [enable_egl=yes])

Thomas Hellstrom's avatar
Thomas Hellstrom committed
1119 1120
AC_ARG_ENABLE([xa],
    [AS_HELP_STRING([--enable-xa],
1121
        [enable build of the XA X Acceleration API @<:@default=disabled@:>@])],
Thomas Hellstrom's avatar
Thomas Hellstrom committed
1122 1123
    [enable_xa="$enableval"],
    [enable_xa=no])
1124 1125
AC_ARG_ENABLE([gbm],
   [AS_HELP_STRING([--enable-gbm],
1126
         [enable gbm library @<:@default=yes except cygwin@:>@])],
1127
   [enable_gbm="$enableval"],
1128 1129 1130 1131 1132 1133 1134 1135
   [case "$host_os" in
       cygwin*)
          enable_gbm=no
          ;;
       *)
          enable_gbm=yes
          ;;
    esac])
1136 1137 1138 1139 1140
AC_ARG_ENABLE([nine],
    [AS_HELP_STRING([--enable-nine],
        [enable build of the nine Direct3D9 API @<:@default=no@:>@])],
    [enable_nine="$enableval"],
    [enable_nine=no])
1141

1142 1143 1144 1145
AC_ARG_ENABLE([xvmc],
   [AS_HELP_STRING([--enable-xvmc],
         [enable xvmc library @<:@default=auto@:>@])],
   [enable_xvmc="$enableval"],
1146
   [enable_xvmc=auto])
1147 1148 1149 1150 1151
AC_ARG_ENABLE([vdpau],
   [AS_HELP_STRING([--enable-vdpau],
         [enable vdpau library @<:@default=auto@:>@])],
   [enable_vdpau="$enableval"],
   [enable_vdpau=auto])
1152 1153
AC_ARG_ENABLE([omx],
   [AS_HELP_STRING([--enable-omx],
1154
         [enable OpenMAX library @<:@default=disabled@:>@])],
1155 1156
   [enable_omx="$enableval"],
   [enable_omx=no])
1157 1158 1159 1160 1161
AC_ARG_ENABLE([va],
   [AS_HELP_STRING([--enable-va],
         [enable va library @<:@default=auto@:>@])],
   [enable_va="$enableval"],
   [enable_va=auto])
1162 1163
AC_ARG_ENABLE([opencl],
   [AS_HELP_STRING([--enable-opencl],
1164
         [enable OpenCL library @<:@default=disabled@:>@])],
1165
   [enable_opencl="$enableval"],
1166
   [enable_opencl=no])
1167 1168 1169
AC_ARG_ENABLE([opencl_icd],
   [AS_HELP_STRING([--enable-opencl-icd],
          [Build an OpenCL ICD library to be loaded by an ICD implementation
1170
           @<:@default=disabled@:>@])],
1171 1172
    [enable_opencl_icd="$enableval"],
    [enable_opencl_icd=no])
1173

1174
AC_ARG_ENABLE([gallium-tests],
1175
    [AS_HELP_STRING([--enable-gallium-tests],
1176
        [Enable optional Gallium tests) @<:@default=disabled@:>@])],
1177 1178 1179
    [enable_gallium_tests="$enableval"],
    [enable_gallium_tests=no])

1180
# Option for Gallium drivers
1181 1182

# Keep this in sync with the --with-gallium-drivers help string default value
1183
GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
1184 1185 1186 1187

AC_ARG_WITH([gallium-drivers],
    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
        [comma delimited Gallium drivers list, e.g.
1188
        "i915,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,swr,vc4,virgl,etnaviv,imx"
1189
        @<:@default=r300,r600,svga,swrast@:>@])],
1190 1191
    [with_gallium_drivers="$withval"],
    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
1192

1193 1194 1195 1196 1197 1198 1199
# Doing '--without-gallium-drivers' will set this variable to 'no'.  Clear it
# here so that the script doesn't choke on an unknown driver name later.
case "$with_gallium_drivers" in
    yes) with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT" ;;
    no) with_gallium_drivers='' ;;
esac

1200 1201 1202
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xno -a \
        "x$enable_gles2" = xno -a \
1203
        "x$enable_nine" = xno -a \
Thomas Hellstrom's avatar
Thomas Hellstrom committed
1204
        "x$enable_xa" = xno -a \
1205 1206
        "x$enable_xvmc" = xno -a \
        "x$enable_vdpau" = xno -a \
1207
        "x$enable_omx" = xno -a \
1208
        "x$enable_va" = xno -a \
1209
        "x$enable_opencl" = xno; then
1210 1211 1212
    AC_MSG_ERROR([at least one API should be enabled])
fi

1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
# Building OpenGL ES1 and/or ES2 without OpenGL is not supported on mesa 9.0.x
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xyes; then
    AC_MSG_ERROR([Building OpenGL ES1 without OpenGL is not supported])
fi

if test "x$enable_opengl" = xno -a \
        "x$enable_gles2" = xyes; then
    AC_MSG_ERROR([Building OpenGL ES2 without OpenGL is not supported])
fi

Matt Turner's avatar
Matt Turner committed
1224 1225 1226 1227 1228 1229 1230
AM_CONDITIONAL(HAVE_OPENGL, test "x$enable_opengl" = xyes)
AM_CONDITIONAL(HAVE_OPENGL_ES1, test "x$enable_gles1" = xyes)
AM_CONDITIONAL(HAVE_OPENGL_ES2, test "x$enable_gles2" = xyes)
AM_CONDITIONAL(NEED_OPENGL_COMMON, test "x$enable_opengl" = xyes -o \
                                        "x$enable_gles1" = xyes -o \
                                        "x$enable_gles2" = xyes)