configure.ac 90.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
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
Carl Worth's avatar
Carl Worth committed
12
dnl Copyright © 2003-2007 Keith Packard, Daniel Stone
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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
33
dnl Process this file with autoconf to create configure.
34

35
AC_PREREQ([2.60])
36

37 38 39 40
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.])

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

49 50 51 52 53 54 55
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

56 57 58
# 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
59 60
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
61

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

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

70
dnl Versions for external dependencies
71
LIBDRM_REQUIRED=2.4.66
72
LIBDRM_RADEON_REQUIRED=2.4.56
73
LIBDRM_AMDGPU_REQUIRED=2.4.63
74
LIBDRM_INTEL_REQUIRED=2.4.61
75 76
LIBDRM_NVVIEUX_REQUIRED=2.4.66
LIBDRM_NOUVEAU_REQUIRED=2.4.66
Rob Clark's avatar
Rob Clark committed
77
LIBDRM_FREEDRENO_REQUIRED=2.4.67
78
DRI2PROTO_REQUIRED=2.6
Keith Packard's avatar
Keith Packard committed
79 80 81
DRI3PROTO_REQUIRED=1.0
PRESENTPROTO_REQUIRED=1.0
LIBUDEV_REQUIRED=151
82
GLPROTO_REQUIRED=1.4.14
83
LIBOMXIL_BELLAGIO_REQUIRED=0.0
84
LIBVA_REQUIRED=0.38.0
85
VDPAU_REQUIRED=1.1
86
WAYLAND_REQUIRED=1.2.0
87
XCB_REQUIRED=1.9.3
88 89 90 91
XCBDRI2_REQUIRED=1.8
XCBGLX_REQUIRED=1.8.1
XSHMFENCE_REQUIRED=1.1
XVMC_REQUIRED=1.0.6
92
PYTHON_MAKO_REQUIRED=0.3.4
93

94 95 96 97
dnl Check for progs
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CXX
98
AM_PROG_CC_C_O
99
AM_PROG_AS
100
AX_CHECK_GNU_MAKE
101
AC_CHECK_PROGS([PYTHON2], [python2.7 python2 python])
102
AC_CHECK_PROGS([PYTHON3], [python3.5 python3.4 python3])
Matt Turner's avatar
Matt Turner committed
103
AC_PROG_SED
104
AC_PROG_MKDIR_P
105

106 107
AC_SYS_LARGEFILE

108 109 110
LT_PREREQ([2.2])
LT_INIT([disable-static])

111 112
AC_CHECK_PROG(RM, rm, [rm -f])

Matt Turner's avatar
Matt Turner committed
113
AX_PROG_BISON([],
114
              AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-parse.c"],
Matt Turner's avatar
Matt Turner committed
115
                    [AC_MSG_ERROR([bison not found - unable to compile glcpp-parse.y])]))
Matt Turner's avatar
Matt Turner committed
116
AX_PROG_FLEX([],
117
             AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-lex.c"],
Matt Turner's avatar
Matt Turner committed
118
                   [AC_MSG_ERROR([flex not found - unable to compile glcpp-lex.l])]))
119

120 121
AC_CHECK_PROG(INDENT, indent, indent, cat)
if test "x$INDENT" != "xcat"; then
122 123 124 125 126 127 128
    # 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
129 130
fi

131
AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED)
132 133 134 135 136 137 138 139 140 141 142

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
143
fi
144

145 146 147 148 149 150
if test -z "$PYTHON3"; then
    if test ! -f "$srcdir/src/intel/genxml/gen9_pack.h"; then
        AC_MSG_ERROR([Python3 not found - unable to generate sources])
    fi
fi

151 152
AC_PROG_INSTALL

153 154
dnl We need a POSIX shell for parts of the build. Assume we have one
dnl in most cases.
155 156 157 158
case "$host_os" in
solaris*)
    # Solaris /bin/sh is too old/non-POSIX compliant
    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
159
    SHELL="$POSIX_SHELL"
160 161 162
    ;;
esac

163 164 165 166 167 168 169 170 171 172
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
]])],
173
[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
174

175
AC_MSG_RESULT([$acv_mesa_CLANG])
176

177
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
178
dnl versions are explictly not supported.
179
GEN_ASM_OFFSETS=no
180
USE_GNU99=no
181
if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
Ian Romanick's avatar
Ian Romanick committed
182 183 184 185 186 187
    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
188 189
        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
190 191
    fi

192
    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
193
        AC_MSG_RESULT([no])
194
        AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
Ian Romanick's avatar
Ian Romanick committed
195 196 197
    else
        AC_MSG_RESULT([yes])
    fi
198

199 200 201
    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 6 ; then
        USE_GNU99=yes
    fi
202 203 204
    if test "x$cross_compiling" = xyes; then
        GEN_ASM_OFFSETS=yes
    fi
Ian Romanick's avatar
Ian Romanick committed
205
fi
206

207 208 209 210 211 212 213
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

214 215
dnl Check for compiler builtins
AX_GCC_BUILTIN([__builtin_bswap32])
Tom Stellard's avatar
Tom Stellard committed
216
AX_GCC_BUILTIN([__builtin_bswap64])
217 218 219 220 221 222 223 224 225
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])
226

227
AX_GCC_FUNC_ATTRIBUTE([const])
228 229
AX_GCC_FUNC_ATTRIBUTE([flatten])
AX_GCC_FUNC_ATTRIBUTE([format])
230
AX_GCC_FUNC_ATTRIBUTE([malloc])
231
AX_GCC_FUNC_ATTRIBUTE([packed])
232
AX_GCC_FUNC_ATTRIBUTE([pure])
233
AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
234
AX_GCC_FUNC_ATTRIBUTE([unused])
235
AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
236
AX_GCC_FUNC_ATTRIBUTE([weak])
237

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

240
dnl Make sure the pkg-config macros are defined
241 242 243 244 245
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.])])
246 247 248 249
PKG_PROG_PKG_CONFIG()

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

Matt Turner's avatar
Matt Turner committed
252
dnl Cache LDFLAGS and CPPFLAGS so we can add to them and restore later
253 254 255 256
_SAVE_LDFLAGS="$LDFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"

dnl Compiler macros
257
DEFINES="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
258
AC_SUBST([DEFINES])
259
android=no
260
case "$host_os" in
261 262 263
*-android)
    android=yes
    ;;
Samuel Thibault's avatar
Samuel Thibault committed
264
linux*|*-gnu*|gnu*)
265
    DEFINES="$DEFINES -D_GNU_SOURCE"
266
    ;;
267
solaris*)
268
    DEFINES="$DEFINES -DSVR4"
269
    ;;
270
cygwin*)
271
    DEFINES="$DEFINES -D_XOPEN_SOURCE=700"
272
    ;;
273 274
esac

275 276
AM_CONDITIONAL(HAVE_ANDROID, test "x$android" = xyes)

277 278
dnl Add flags for gcc and g++
if test "x$GCC" = xyes; then
279 280 281 282 283 284 285
    CFLAGS="$CFLAGS -Wall"

    if test "x$USE_GNU99" = xyes; then
	CFLAGS="$CFLAGS -std=gnu99"
    else
	CFLAGS="$CFLAGS -std=c99"
    fi
286 287 288 289 290 291 292 293 294 295 296 297 298

    # 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])]);
299 300 301

    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CFLAGS="$CFLAGS"
302
    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
303 304
    VISIBILITY_CFLAGS="-fvisibility=hidden"
    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
305
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
306 307 308 309
		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);

    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
    CFLAGS=$save_CFLAGS
310 311 312

    # Work around aliasing bugs - developers should comment this out
    CFLAGS="$CFLAGS -fno-strict-aliasing"
313

314 315
    # We don't want floating-point math functions to set errno or trap
    CFLAGS="$CFLAGS -fno-math-errno -fno-trapping-math"
316

317 318 319
    # gcc's builtin memcmp is slower than glibc's
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
    CFLAGS="$CFLAGS -fno-builtin-memcmp"
320 321 322

    # Flags to help ensure that certain portions of the code -- and only those
    # portions -- can be built with MSVC:
323
    # - src/util, src/gallium/auxiliary, rc/gallium/drivers/llvmpipe, and
324 325 326
    # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which
    #   supports most of C99)
    # - the rest has no compiler compiler restrictions
327 328 329 330 331 332 333 334 335 336 337 338 339
    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"
340 341 342
fi
if test "x$GXX" = xyes; then
    CXXFLAGS="$CXXFLAGS -Wall"
343

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

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

357 358
    # Work around aliasing bugs - developers should comment this out
    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
359 360 361 362

    # gcc's builtin memcmp is slower than glibc's
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
    CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp"
363 364
fi

365 366 367
AC_SUBST([MSVC2013_COMPAT_CFLAGS])
AC_SUBST([MSVC2013_COMPAT_CXXFLAGS])

368 369 370 371 372 373 374 375 376
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

377 378 379
AC_SUBST([VISIBILITY_CFLAGS])
AC_SUBST([VISIBILITY_CXXFLAGS])

380 381 382
dnl
dnl Optional flags, check for compiler support
dnl
383 384 385 386 387 388 389 390
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
391
save_CFLAGS="$CFLAGS"
392
CFLAGS="$SSE41_CFLAGS $CFLAGS"
393 394
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <smmintrin.h>
395
int param;
396
int main () {
397
    __m128i a = _mm_set1_epi32 (param), b = _mm_set1_epi32 (param + 1), c;
398
    c = _mm_max_epu32(a, b);
399
    return _mm_cvtsi128_si32(c);
400 401
}]])], SSE41_SUPPORTED=1)
CFLAGS="$save_CFLAGS"
402 403 404
if test "x$SSE41_SUPPORTED" = x1; then
    DEFINES="$DEFINES -DUSE_SSE41"
fi
405
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
406
AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS)
407

408 409 410 411 412 413 414 415 416 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
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)

463 464
dnl Can't have static and shared libraries, default to static if user
dnl explicitly requested. If both disabled, set to static since shared
465
dnl was explicitly requested.
466
case "x$enable_static$enable_shared" in
467 468 469
xyesyes)
    AC_MSG_WARN([Cannot build static and shared libraries, disabling shared])
    enable_shared=no
470
    ;;
471 472
xnono)
    AC_MSG_WARN([Cannot disable both static and shared libraries, enabling shared])
473
    enable_shared=yes
474 475 476
    ;;
esac

477 478
AM_CONDITIONAL(BUILD_SHARED, test "x$enable_shared" = xyes)

479 480 481
dnl
dnl other compiler options
dnl
482
AC_ARG_ENABLE([debug],
483 484
    [AS_HELP_STRING([--enable-debug],
        [use debug compiler flags and macros @<:@default=disabled@:>@])],
485 486
    [enable_debug="$enableval"],
    [enable_debug=no]
487
)
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505

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

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

Jon Turney's avatar
Jon Turney committed
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
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])

547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
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])

563 564 565 566 567
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
568
openbsd* | darwin* )
569 570 571 572 573 574 575
    LD_NO_UNDEFINED="" ;;
*)
    LD_NO_UNDEFINED="-Wl,--no-undefined" ;;
esac

AC_SUBST([LD_NO_UNDEFINED])

Jon Turney's avatar
Jon Turney committed
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
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")

598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
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")

616 617 618 619 620 621 622 623 624 625 626 627
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)

628 629 630
dnl
dnl library names
dnl
631 632 633 634 635 636 637 638 639
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
640 641
case "$host_os" in
darwin* )
642 643 644
    LIB_EXT='dylib'
    IMP_LIB_EXT=$LIB_EXT
    ;;
645
cygwin* )
646 647 648
    LIB_EXT='dll'
    IMP_LIB_EXT='dll.a'
    ;;
649
aix* )
650 651 652
    LIB_EXT='a'
    IMP_LIB_EXT=$LIB_EXT
    ;;
653
* )
654 655 656
    LIB_EXT='so'
    IMP_LIB_EXT=$LIB_EXT
    ;;
657
esac
658 659 660

AC_SUBST([LIB_EXT])

661 662 663 664 665 666 667 668 669 670 671 672
AC_ARG_WITH([gl-lib-name],
  [AS_HELP_STRING([--with-gl-lib-name@<:@=NAME@:>@],
    [specify GL library name @<:@default=GL@:>@])],
  [GL_LIB=$withval],
  [GL_LIB=GL])
AC_ARG_WITH([osmesa-lib-name],
  [AS_HELP_STRING([--with-osmesa-lib-name@<:@=NAME@:>@],
    [specify OSMesa library name @<:@default=OSMesa@:>@])],
  [OSMESA_LIB=$withval],
  [OSMESA_LIB=OSMesa])
AS_IF([test "x$GL_LIB" = xyes], [GL_LIB=GL])
AS_IF([test "x$OSMESA_LIB" = xyes], [OSMESA_LIB=OSMesa])
673

674 675 676 677 678 679 680 681 682 683 684
dnl
dnl Mangled Mesa support
dnl
AC_ARG_ENABLE([mangling],
  [AS_HELP_STRING([--enable-mangling],
    [enable mangled symbols and library name @<:@default=disabled@:>@])],
  [enable_mangling="${enableval}"],
  [enable_mangling=no]
)
if test "x${enable_mangling}" = "xyes" ; then
  DEFINES="${DEFINES} -DUSE_MGL_NAMESPACE"
685 686
  GL_LIB="Mangled${GL_LIB}"
  OSMESA_LIB="Mangled${OSMESA_LIB}"
687 688 689 690
fi
AC_SUBST([GL_LIB])
AC_SUBST([OSMESA_LIB])

691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
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

706 707 708 709 710 711 712 713 714 715 716 717 718
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
719
if test "x$enable_asm" = xyes -a "x$cross_compiling" = xyes; then
720
    case "$host_cpu" in
721
    i?86 | x86_64 | amd64)
722 723 724 725
        if test "x$host_cpu" != "x$target_cpu"; then
            enable_asm=no
            AC_MSG_RESULT([no, cross compiling])
        fi
726 727 728 729 730 731 732 733
        ;;
    esac
fi
# check for supported arches
if test "x$enable_asm" = xyes; then
    case "$host_cpu" in
    i?86)
        case "$host_os" in
734
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | gnu*)
735 736
            asm_arch=x86
            ;;
737 738
        esac
        ;;
739
    x86_64|amd64)
740
        case "$host_os" in
Jonathan Gray's avatar
Jonathan Gray committed
741
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
742
            asm_arch=x86_64
743 744 745
            ;;
        esac
        ;;
746 747 748 749 750 751 752
    sparc*)
        case "$host_os" in
        linux*)
            asm_arch=sparc
            ;;
        esac
        ;;
753 754 755 756
    esac

    case "$asm_arch" in
    x86)
757
        DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
758 759
        AC_MSG_RESULT([yes, x86])
        ;;
760
    x86_64|amd64)
761
        DEFINES="$DEFINES -DUSE_X86_64_ASM"
762 763
        AC_MSG_RESULT([yes, x86_64])
        ;;
764
    sparc)
765
        DEFINES="$DEFINES -DUSE_SPARC_ASM"
766 767
        AC_MSG_RESULT([yes, sparc])
        ;;
768 769 770 771 772 773
    *)
        AC_MSG_RESULT([no, platform not supported])
        ;;
    esac
fi

774
AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
775
AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
776
AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
777
AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
778

779 780
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.
781 782 783
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
784
AC_SUBST([DLOPEN_LIBS])
785

786
dnl Check if that library also has dladdr
787 788 789 790
save_LIBS="$LIBS"
LIBS="$LIBS $DLOPEN_LIBS"
AC_CHECK_FUNCS([dladdr])
LIBS="$save_LIBS"
791

792
case "$host_os" in
793
darwin*)
794 795 796 797
    ;;
*)
    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
                   [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
798
                                 [AC_MSG_ERROR([Could not find clock_gettime])])])
799 800 801
    AC_SUBST([CLOCK_LIB])
    ;;
esac
802

803 804 805
dnl See if posix_memalign is available
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])

806
dnl Check for pthreads
807 808 809 810
AX_PTHREAD
if test "x$ax_pthread_ok" = xno; then
    AC_MSG_ERROR([Building mesa on this platform requires pthreads])
fi
811 812 813 814
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
dnl pkgconfig files.
test -z "$PTHREAD_LIBS" && PTHREAD_LIBS="-lpthread"
815

816 817 818 819
PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs)
AC_SUBST(PTHREADSTUBS_CFLAGS)
AC_SUBST(PTHREADSTUBS_LIBS)

820 821 822 823 824 825 826
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
827 828 829 830 831 832
    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"])
833 834
    DEFINES="$DEFINES -DMESA_SELINUX"
fi
835
AC_SUBST([SELINUX_CFLAGS])
836
AC_SUBST([SELINUX_LIBS])
837

838
dnl Options for APIs
839 840
AC_ARG_ENABLE([opengl],
    [AS_HELP_STRING([--disable-opengl],
841
        [disable support for standard OpenGL API @<:@default=enabled@:>@])],
842 843 844
    [enable_opengl="$enableval"],
    [enable_opengl=yes])
AC_ARG_ENABLE([gles1],
845 846
    [AS_HELP_STRING([--disable-gles1],
        [disable support for OpenGL ES 1.x API @<:@default=enabled@:>@])],
847
    [enable_gles1="$enableval"],
848
    [enable_gles1=yes])
849
AC_ARG_ENABLE([gles2],
850 851
    [AS_HELP_STRING([--disable-gles2],
        [disable support for OpenGL ES 2.x API @<:@default=enabled@:>@])],
852
    [enable_gles2="$enableval"],
853
    [enable_gles2=yes])
854 855 856

AC_ARG_ENABLE([dri],
    [AS_HELP_STRING([--enable-dri],
857
        [enable DRI modules @<:@default=enabled@:>@])],
858
    [enable_dri="$enableval"],
859
    [enable_dri=yes])
860 861 862 863 864 865 866 867 868

case "$host_os" in
linux*)
    dri3_default=yes
    ;;
*)
    dri3_default=no
    ;;
esac
869 870 871 872 873

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

874 875
AC_ARG_ENABLE([dri3],
    [AS_HELP_STRING([--enable-dri3],
876
        [enable DRI3 @<:@default=auto@:>@])],
877
    [enable_dri3="$enableval"],
878
    [enable_dri3="$dri3_default"])
879
AC_ARG_ENABLE([glx],
880 881
    [AS_HELP_STRING([--enable-glx@<:@=dri|xlib|gallium-xlib@:>@],
        [enable the GLX library and choose an implementation @<:@default=auto@:>@])],
882
    [enable_glx="$enableval"],
883
    [enable_glx=yes])
884 885
AC_ARG_ENABLE([osmesa],
    [AS_HELP_STRING([--enable-osmesa],
886
        [enable OSMesa library @<:@default=disabled@:>@])],
887
    [enable_osmesa="$enableval"],
888
    [enable_osmesa=no])
889 890 891 892 893
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])
894 895 896 897 898 899
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
900 901
AC_ARG_ENABLE([xa],
    [AS_HELP_STRING([--enable-xa],
902
        [enable build of the XA X Acceleration API @<:@default=disabled@:>@])],
Thomas Hellstrom's avatar
Thomas Hellstrom committed
903 904
    [enable_xa="$enableval"],
    [enable_xa=no])
905 906 907 908 909
AC_ARG_ENABLE([gbm],
   [AS_HELP_STRING([--enable-gbm],
         [enable gbm library @<:@default=auto@:>@])],
   [enable_gbm="$enableval"],
   [enable_gbm=auto])
910 911 912 913 914
AC_ARG_ENABLE([nine],
    [AS_HELP_STRING([--enable-nine],
        [enable build of the nine Direct3D9 API @<:@default=no@:>@])],
    [enable_nine="$enableval"],
    [enable_nine=no])
915

916 917 918 919
AC_ARG_ENABLE([xvmc],
   [AS_HELP_STRING([--enable-xvmc],
         [enable xvmc library @<:@default=auto@:>@])],
   [enable_xvmc="$enableval"],
920
   [enable_xvmc=auto])
921 922 923 924 925
AC_ARG_ENABLE([vdpau],
   [AS_HELP_STRING([--enable-vdpau],
         [enable vdpau library @<:@default=auto@:>@])],
   [enable_vdpau="$enableval"],
   [enable_vdpau=auto])
926 927
AC_ARG_ENABLE([omx],
   [AS_HELP_STRING([--enable-omx],
928
         [enable OpenMAX library @<:@default=disabled@:>@])],
929 930
   [enable_omx="$enableval"],
   [enable_omx=no])
931 932 933 934 935
AC_ARG_ENABLE([va],
   [AS_HELP_STRING([--enable-va],
         [enable va library @<:@default=auto@:>@])],
   [enable_va="$enableval"],
   [enable_va=auto])
936 937
AC_ARG_ENABLE([opencl],
   [AS_HELP_STRING([--enable-opencl],
938
         [enable OpenCL library @<:@default=disabled@:>@])],
939
   [enable_opencl="$enableval"],
940
   [enable_opencl=no])
941 942 943
AC_ARG_ENABLE([opencl_icd],
   [AS_HELP_STRING([--enable-opencl-icd],
          [Build an OpenCL ICD library to be loaded by an ICD implementation
944
           @<:@default=disabled@:>@])],
945 946
    [enable_opencl_icd="$enableval"],
    [enable_opencl_icd=no])
947

948
AC_ARG_ENABLE([gallium-tests],
949
    [AS_HELP_STRING([--enable-gallium-tests],
950
        [Enable optional Gallium tests) @<:@default=disabled@:>@])],
951 952 953
    [enable_gallium_tests="$enableval"],
    [enable_gallium_tests=no])

954
# Option for Gallium drivers
955 956

# Keep this in sync with the --with-gallium-drivers help string default value
957
GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
958 959 960 961

AC_ARG_WITH([gallium-drivers],
    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
        [comma delimited Gallium drivers list, e.g.
962
        "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4,virgl"
963
        @<:@default=r300,r600,svga,swrast@:>@])],
964 965
    [with_gallium_drivers="$withval"],
    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
966

967 968 969 970 971 972 973
# 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

974 975 976
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xno -a \
        "x$enable_gles2" = xno -a \
977
        "x$enable_nine" = xno -a \
Thomas Hellstrom's avatar
Thomas Hellstrom committed
978
        "x$enable_xa" = xno -a \
979 980
        "x$enable_xvmc" = xno -a \
        "x$enable_vdpau" = xno -a \
981
        "x$enable_omx" = xno -a \
982
        "x$enable_va" = xno -a \
983
        "x$enable_opencl" = xno; then
984 985 986
    AC_MSG_ERROR([at least one API should be enabled])
fi

987 988 989 990 991 992 993 994 995 996 997
# 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
998 999 1000 1001 1002 1003 1004
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)

1005 1006 1007 1008 1009 1010 1011 1012 1013
# Validate GLX options
if test "x$enable_glx" = xyes; then
    if test "x$enable_dri" = xyes; then
        enable_glx=dri
    elif test -n "$with_gallium_drivers"; then
        enable_glx=gallium-xlib
    else
        enable_glx=xlib
    fi
1014
fi
1015 1016 1017 1018 1019 1020
case "x$enable_glx" in
xdri | xxlib | xgallium-xlib)
    # GLX requires OpenGL
    if test "x$enable_opengl" = xno; then
        AC_MSG_ERROR([GLX cannot be built without OpenGL])
    fi
1021

1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
    # Check individual dependencies
    case "x$enable_glx" in
    xdri)
        if test "x$enable_dri" = xno; then
            AC_MSG_ERROR([DRI-based GLX requires DRI to be enabled])
        fi
        ;;
    xxlib)
        if test "x$enable_dri" = xyes; then
            AC_MSG_ERROR([Xlib-based GLX cannot be built with DRI enabled])
        fi
        ;;
    xgallium-xlib )
        if test "x$enable_dri" = xyes; then
            AC_MSG_ERROR([Xlib-based (Gallium) GLX cannot be built with DRI enabled])
        fi
        if test -z "$with_gallium_drivers"; then
            AC_MSG_ERROR([Xlib-based (Gallium) GLX cannot be built without Gallium enabled])
        fi
        ;;
    esac
    ;;
xno)
    ;;
*)
    AC_MSG_ERROR([Illegal value for --enable-glx: $enable_glx])
    ;;
esac
1050

1051 1052 1053
AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xdri)
AM_CONDITIONAL(HAVE_XLIB_GLX, test "x$enable_glx" = xxlib)
AM_CONDITIONAL(HAVE_GALLIUM_XLIB_GLX, test "x$enable_glx" = xgallium-xlib)
1054

1055 1056 1057 1058 1059 1060 1061
# Check for libdrm
PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
                  [have_libdrm=yes], [have_libdrm=no])
if test "x$have_libdrm" = xyes; then
	DEFINES="$DEFINES -DHAVE_LIBDRM"
fi

1062 1063 1064 1065
# Select which platform-dependent DRI code gets built
case "$host_os" in
darwin*)
    dri_platform='apple' ;;
1066
gnu*|cygwin*)
1067 1068 1069 1070 1071
    dri_platform='none' ;;
*)
    dri_platform='drm' ;;
esac

1072 1073 1074 1075
if test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes; then
    have_drisw_kms='yes'
fi

1076 1077
AM_CONDITIONAL(HAVE_DRICOMMON, test "x$enable_dri" = xyes )
AM_CONDITIONAL(HAVE_DRISW, test "x$enable_dri" = xyes )
1078
AM_CONDITIONAL(HAVE_DRISW_KMS, test "x$have_drisw_kms" = xyes )
1079 1080
AM_CONDITIONAL(HAVE_DRI2, test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes )
AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes )
1081
AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xapple )
Matt Turner's avatar
Matt Turner committed
1082

1083 1084
AC_ARG_ENABLE([shared-glapi],
    [AS_HELP_STRING([--enable-shared-glapi],
1085
        [Enable shared glapi for OpenGL @<:@default=enabled@:>@])],
1086
    [enable_shared_glapi="$enableval"],
1087
    [enable_shared_glapi=yes])
1088

1089 1090 1091 1092 1093 1094 1095 1096
case "x$enable_opengl$enable_gles1$enable_gles2" in
x*yes*yes*)
    if test "x$enable_shared_glapi" = xno; then
        AC_MSG_ERROR([shared GLAPI required when building two or more of
                      the following APIs - opengl, gles1 gles2])
    fi
    ;;
esac
1097 1098 1099

AM_CONDITIONAL(HAVE_SHARED_GLAPI, test "x$enable_shared_glapi" = xyes)

1100 1101 1102 1103 1104
# Build the pipe-drivers as separate libraries/modules.
# Do not touch this unless you know what you are doing.
# XXX: Expose via configure option ?
enable_shared_pipe_drivers=no

1105 1106
dnl
dnl Driver specific build directories
1107
dnl
1108

1109
if test "x$enable_gallium_osmesa" = xyes; then
1110 1111
    if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
        AC_MSG_ERROR([gallium_osmesa requires the gallium swrast driver])
1112 1113 1114 1115
    fi
    if test "x$enable_osmesa" = xyes; then
        AC_MSG_ERROR([Cannot enable both classic and Gallium OSMesa implementations])
    fi
1116 1117
fi

1118
AC_SUBST([MESA_LLVM])
1119

Carl Worth's avatar
Carl Worth committed
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241
# SHA1 hashing
AC_ARG_WITH([sha1],
        [AS_HELP_STRING([--with-sha1=libc|libmd|libnettle|libgcrypt|libcrypto|libsha1|CommonCrypto|CryptoAPI],
        [choose SHA1 implementation])])
case "x$with_sha1" in
x | xlibc | xlibmd | xlibnettle | xlibgcrypt | xlibcrypto | xlibsha1 | xCommonCrypto | xCryptoAPI)
  ;;
*)
        AC_MSG_ERROR([Illegal value for --with-sha1: $with_sha1])
esac

AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
	with_sha1=libc
fi
if test "x$with_sha1" = xlibc && test "x$HAVE_SHA1_IN_LIBC" != xyes; then
	AC_MSG_ERROR([sha1 in libc requested but not found])
fi
if test "x$with_sha1" = xlibc; then
	AC_DEFINE([HAVE_SHA1_IN_LIBC], [1],
		[Use libc SHA1 functions])
	SHA1_LIBS=""
fi
AC_CHECK_FUNC([CC_SHA1_Init], [HAVE_SHA1_IN_COMMONCRYPTO=yes])
if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_COMMONCRYPTO" = xyes; then
	with_sha1=CommonCrypto
fi
if test "x$with_sha1" = xCommonCrypto && test "x$HAVE_SHA1_IN_COMMONCRYPTO" != xyes; then
	AC_MSG_ERROR([CommonCrypto requested but not found])
fi
if test "x$with_sha1" = xCommonCrypto; then
	AC_DEFINE([HAVE_SHA1_IN_COMMONCRYPTO], [1],
		[Use CommonCrypto SHA1 functions])
	SHA1_LIBS=""
fi
dnl stdcall functions cannot be tested with AC_CHECK_LIB
AC_CHECK_HEADER([wincrypt.h], [HAVE_SHA1_IN_CRYPTOAPI=yes], [], [#include <windows.h>])
if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_CRYPTOAPI" = xyes; then
	with_sha1=CryptoAPI
fi
if test "x$with_sha1" = xCryptoAPI && test "x$HAVE_SHA1_IN_CRYPTOAPI" != xyes; then
	AC_MSG_ERROR([CryptoAPI requested but not found])
fi
if test "x$with_sha1" = xCryptoAPI; then
	AC_DEFINE([HAVE_SHA1_IN_CRYPTOAPI], [1],
		[Use CryptoAPI SHA1 functions])
	SHA1_LIBS=""
fi
AC_CHECK_LIB([md], [SHA1Init], [HAVE_LIBMD=yes])
if test "x$with_sha1" = x && test "x$HAVE_LIBMD" = xyes; then
	with_sha1=libmd
fi
if test "x$with_sha1" = xlibmd && test "x$HAVE_LIBMD" != xyes; then
	AC_MSG_ERROR([libmd requested but not found])
fi
if test "x$with_sha1" = xlibmd; then
	AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
	          [Use libmd SHA1 functions])
	SHA1_LIBS=-lmd
fi
PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
   with_sha1=libsha1
fi
if test "x$with_sha1" = xlibsha1 && test "x$HAVE_LIBSHA1" != xyes; then
	AC_MSG_ERROR([libsha1 requested but not found])
fi
if test "x$with_sha1" = xlibsha1; then
	AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1],
	          [Use libsha1 for SHA1])
	SHA1_LIBS=-lsha1
fi
AC_CHECK_LIB([nettle], [nettle_sha1_init], [HAVE_LIBNETTLE=yes])
if test "x$with_sha1" = x && test "x$HAVE_LIBNETTLE" = xyes; then
	with_sha1=libnettle
fi
if test "x$with_sha1" = xlibnettle && test "x$HAVE_LIBNETTLE" != xyes; then
	AC_MSG_ERROR([libnettle requested but not found])
fi
if test "x$with_sha1" = xlibnettle; then
	AC_DEFINE([HAVE_SHA1_IN_LIBNETTLE], [1],
	          [Use libnettle SHA1 functions])
	SHA1_LIBS=-lnettle
fi
AC_CHECK_LIB([gcrypt], [gcry_md_open], [HAVE_LIBGCRYPT=yes])
if test "x$with_sha1" = x && test "x$HAVE_LIBGCRYPT" = xyes; then
	with_sha1=libgcrypt
fi
if test "x$with_sha1" = xlibgcrypt && test "x$HAVE_LIBGCRYPT" != xyes; then
	AC_MSG_ERROR([libgcrypt requested but not found])
fi
if test "x$with_sha1" = xlibgcrypt; then
	AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
	          [Use libgcrypt SHA1 functions])
	SHA1_LIBS=-lgcrypt
fi
# We don't need all of the OpenSSL libraries, just libcrypto
AC_CHECK_LIB([crypto], [SHA1_Init], [HAVE_LIBCRYPTO=yes])
PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
                  [HAVE_OPENSSL_PKC=no])
if test "x$HAVE_LIBCRYPTO" = xyes || test "x$HAVE_OPENSSL_PKC" = xyes; then
	if test "x$with_sha1" = x; then
		with_sha1=libcrypto
	fi
else
	if test "x$with_sha1" = xlibcrypto; then
		AC_MSG_ERROR([OpenSSL libcrypto requested but not found])
	fi
fi
if test "x$with_sha1" = xlibcrypto; then
	if test "x$HAVE_LIBCRYPTO" = xyes; then
		SHA1_LIBS=-lcrypto
	else
		SHA1_LIBS="$OPENSSL_LIBS"
		SHA1_CFLAGS="$OPENSSL_CFLAGS"
	fi
fi
AC_MSG_CHECKING([for SHA1 implementation])
AC_MSG_RESULT([$with_sha1])
AC_SUBST(SHA1_LIBS)
AC_SUBST(SHA1_CFLAGS)

1242 1243 1244 1245 1246
# Enable a define for SHA1
if test "x$with_sha1" != "x"; then
	DEFINES="$DEFINES -DHAVE_SHA1"
fi

1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
# Allow user to configure out the shader-cache feature
AC_ARG_ENABLE([shader-cache],
    AS_HELP_STRING([--disable-shader-cache], [Disable binary shader cache]),
    [enable_shader_cache="$enableval"],
    [if test "x$with_sha1" != "x"; then
        enable_shader_cache=yes
     else
        enable_shader_cache=no
     fi])
if test "x$with_sha1" = "x"; then
    if test "x$enable_shader_cache" = "xyes"; then
        AC_MSG_ERROR([Cannot enable shader cache (no SHA-1 implementation found)])
    fi
fi
AM_CONDITIONAL([ENABLE_SHADER_CACHE], [test x$enable_shader_cache = xyes])

1263 1264
case "$host_os" in
linux*)
1265
    need_pci_id=yes ;;
1266
*)
1267
    need_pci_id=no ;;
1268 1269
esac

1270 1271 1272
PKG_CHECK_MODULES([LIBUDEV], [libudev >= $LIBUDEV_REQUIRED],
                  have_libudev=yes, have_libudev=no)

1273 1274 1275 1276 1277 1278 1279
AC_ARG_ENABLE([sysfs],
    [AS_HELP_STRING([--enable-sysfs],
        [enable /sys PCI identification @<:@default=disabled@:>@])],
    [have_sysfs="$enableval"],
    [have_sysfs=no]
)

Chia-I Wu's avatar
Chia-I Wu committed
1280
if test "x$enable_dri" = xyes; then
1281 1282 1283 1284
    if test "$enable_static" = yes; then
        AC_MSG_ERROR([Cannot use static libraries for DRI drivers])
    fi

1285 1286 1287
    # not a hard requirement as swrast does not depend on it
    if test "x$have_libdrm" = xyes; then
        DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
Chia-I Wu's avatar
Chia-I Wu committed
1288 1289 1290
    fi
fi

1291 1292
AC_ARG_ENABLE([driglx-direct],
    [AS_HELP_STRING([--disable-driglx-direct],
1293
        [disable direct rendering in GLX and EGL for DRI \
1294
            @<:@default=auto@:>@])],
1295
    [driglx_direct="$enableval"],
1296
    [driglx_direct="yes"])
1297

1298
dnl
1299
dnl libGL configuration per driver
1300
dnl
1301 1302
case "x$enable_glx" in
xxlib | xgallium-xlib)
1303
    # Xlib-based GLX
1304 1305 1306
    dri_modules="x11 xext xcb"
    PKG_CHECK_MODULES([XLIBGL], [$dri_modules])
    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
1307 1308
    X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
    GL_LIB_DEPS="$XLIBGL_LIBS"
1309 1310
    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
    GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm $PTHREAD_LIBS"
1311
    ;;
1312
xdri)
1313
    # DRI-based GLX
Jesse Barnes's avatar
Jesse Barnes committed
1314
    PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
1315

1316
    # find the DRI deps for libGL
1317
    dri_modules="x11 xext xdamage xfixes x11-xcb xcb xcb-glx >= $XCBGLX_REQUIRED"
1318

1319 1320
    if test x"$driglx_direct" = xyes; then
        if test x"$dri_platform" = xdrm ; then
1321
            DEFINES="$DEFINES -DGLX_USE_DRM"
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337
            if test "x$have_libdrm" != xyes; then
               AC_MSG_ERROR([Direct rendering requires libdrm >= $LIBDRM_REQUIRED])
            fi

            PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
            GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV libdrm >= $LIBDRM_REQUIRED"
            if test x"$enable_dri3" = xyes; then
               PKG_CHECK_MODULES([DRI3PROTO], [dri3proto >= $DRI3PROTO_REQUIRED])
               PKG_CHECK_MODULES([PRESENTPROTO], [presentproto >= $PRESENTPROTO_REQUIRED])
            fi

            if test x"$enable_dri" = xyes; then
               dri_modules="$dri_modules xcb-dri2 >= $XCBDRI2_REQUIRED"
            fi

            if test x"$enable_dri3" = xyes; then
1338
               PKG_CHECK_EXISTS([xcb >= $XCB_REQUIRED], [], AC_MSG_ERROR([DRI3 requires xcb >= $XCB_REQUIRED]))
1339
               dri3_modules="xcb xcb-dri3 xcb-present xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
Boyan Ding's avatar
Boyan Ding committed
1340
               PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules])
1341
            fi
Jon Turney's avatar
Jon Turney committed
1342 1343 1344 1345
        fi
        if test x"$dri_platform" = xapple ; then
            DEFINES="$DEFINES -DGLX_USE_APPLEGL"
        fi
1346
    fi
1347

1348 1349 1350 1351
    # add xf86vidmode if available
    PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no)
    if test "$HAVE_XF86VIDMODE" = yes ; then
        dri_modules="$dri_modules xxf86vm"
1352 1353
    fi

1354 1355
    PKG_CHECK_MODULES([DRIGL], [$dri_modules])
    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
1356 1357 1358
    X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
    GL_LIB_DEPS="$DRIGL_LIBS"

1359 1360 1361
    # need DRM libs, $PTHREAD_LIBS, etc.
    GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
    GL_PC_LIB_PRIV="-lm $PTHREAD_LIBS $DLOPEN_LIBS"
1362
    ;;
1363
esac
1364

1365
have_pci_id=no
1366 1367
if test "$have_libudev" = yes; then
    DEFINES="$DEFINES -DHAVE_LIBUDEV"
1368 1369 1370 1371 1372 1373
    have_pci_id=yes
fi

if test "$have_sysfs" = yes; then
    DEFINES="$DEFINES -DHAVE_SYSFS"
    have_pci_id=yes
1374 1375
fi

1376 1377
# This is outside the case (above) so that it is invoked even for non-GLX
# builds.
Eric Anholt's avatar
Eric Anholt committed
1378
AM_CONDITIONAL(HAVE_XF86VIDMODE, test "x$HAVE_XF86VIDMODE" = xyes)
1379

1380 1381 1382 1383
GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
GLESv1_CM_PC_LIB_PRIV="-lm $PTHREAD_LIBS $DLOPEN_LIBS"
GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
GLESv2_PC_LIB_PRIV="-lm $PTHREAD_LIBS $DLOPEN_LIBS"
1384

1385
AC_SUBST([X11_INCLUDES])
1386
AC_SUBST([GL_LIB_DEPS])
1387 1388 1389 1390
AC_SUBST([GL_PC_REQ_PRIV])
AC_SUBST([GL_PC_LIB_PRIV])
AC_SUBST([GL_PC_CFLAGS])
AC_SUBST([DRI_PC_REQ_PRIV])
1391
AC_SUBST([GLESv1_CM_LIB_DEPS])
1392
AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
1393
AC_SUBST([GLESv2_LIB_DEPS])
1394 1395
AC_SUBST([GLESv2_PC_LIB_PRIV])

1396 1397
AC_SUBST([HAVE_XF86VIDMODE])

1398
dnl
Chia-I Wu's avatar
Chia-I Wu committed
1399
dnl More GLX setup
1400
dnl
1401 1402
case "x$enable_glx" in
xxlib | xgallium-xlib)
1403
    DEFINES="$DEFINES -DUSE_XSHM"
Chia-I Wu's avatar
Chia-I Wu committed
1404
    ;;
1405
xdri)
Chia-I Wu's avatar
Chia-I Wu committed
1406 1407 1408 1409 1410 1411
    DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
    if test "x$driglx_direct" = xyes; then
        DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
    fi
    ;;
esac
1412