configure.ac 77.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])
47

48 49 50
# 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
51 52
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
53

54 55
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

Johannes Obermayr's avatar
Johannes Obermayr committed
56 57 58 59
dnl Set internal versions
OSMESA_VERSION=8
AC_SUBST([OSMESA_VERSION])

60
dnl Versions for external dependencies
61
LIBDRM_REQUIRED=2.4.38
62
LIBDRM_RADEON_REQUIRED=2.4.56
63
LIBDRM_INTEL_REQUIRED=2.4.52
64
LIBDRM_NVVIEUX_REQUIRED=2.4.33
65
LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
66
LIBDRM_FREEDRENO_REQUIRED=2.4.57
67
DRI2PROTO_REQUIRED=2.6
Keith Packard's avatar
Keith Packard committed
68 69 70
DRI3PROTO_REQUIRED=1.0
PRESENTPROTO_REQUIRED=1.0
LIBUDEV_REQUIRED=151
71
GLPROTO_REQUIRED=1.4.14
72
LIBOMXIL_BELLAGIO_REQUIRED=0.0
73
LIBVA_REQUIRED=0.35.0
74 75
VDPAU_REQUIRED=0.4.1
WAYLAND_REQUIRED=1.2.0
76
XCB_REQUIRED=1.9.3
77 78 79 80
XCBDRI2_REQUIRED=1.8
XCBGLX_REQUIRED=1.8.1
XSHMFENCE_REQUIRED=1.1
XVMC_REQUIRED=1.0.6
81

82 83 84 85
dnl Check for progs
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CXX
86
AM_PROG_CC_C_O
87
AM_PROG_AS
88
AX_CHECK_GNU_MAKE
89
AC_CHECK_PROGS([PYTHON2], [python2 python])
Matt Turner's avatar
Matt Turner committed
90
AC_PROG_SED
91
AC_PROG_MKDIR_P
92

93 94
AC_SYS_LARGEFILE

95 96 97
LT_PREREQ([2.2])
LT_INIT([disable-static])

Matt Turner's avatar
Matt Turner committed
98
AX_PROG_BISON([],
99
              AS_IF([test ! -f "$srcdir/src/glsl/glcpp/glcpp-parse.c"],
Matt Turner's avatar
Matt Turner committed
100
                    [AC_MSG_ERROR([bison not found - unable to compile glcpp-parse.y])]))
Matt Turner's avatar
Matt Turner committed
101
AX_PROG_FLEX([],
102
             AS_IF([test ! -f "$srcdir/src/glsl/glcpp/glcpp-lex.c"],
Matt Turner's avatar
Matt Turner committed
103
                   [AC_MSG_ERROR([flex not found - unable to compile glcpp-lex.l])]))
104

105 106
AC_CHECK_PROG(INDENT, indent, indent, cat)
if test "x$INDENT" != "xcat"; then
107 108 109 110 111 112 113
    # 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
114 115
fi

116
AX_CHECK_PYTHON_MAKO_MODULE(0.3.4)
117

118 119
AC_PROG_INSTALL

120 121
dnl We need a POSIX shell for parts of the build. Assume we have one
dnl in most cases.
122 123 124 125
case "$host_os" in
solaris*)
    # Solaris /bin/sh is too old/non-POSIX compliant
    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
126
    SHELL="$POSIX_SHELL"
127 128 129
    ;;
esac

nobled's avatar
nobled committed
130 131 132 133 134 135 136 137 138 139
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
]])],
140
[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
nobled's avatar
nobled committed
141

142
AC_MSG_RESULT([$acv_mesa_CLANG])
nobled's avatar
nobled committed
143

144
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
145
dnl versions are explictly not supported.
146
GEN_ASM_OFFSETS=no
147
if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
Ian Romanick's avatar
Ian Romanick committed
148 149 150 151 152 153
    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
154 155
        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
156 157
    fi

158
    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
159
        AC_MSG_RESULT([no])
160
        AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
Ian Romanick's avatar
Ian Romanick committed
161 162 163
    else
        AC_MSG_RESULT([yes])
    fi
164 165 166 167

    if test "x$cross_compiling" = xyes; then
        GEN_ASM_OFFSETS=yes
    fi
Ian Romanick's avatar
Ian Romanick committed
168
fi
169 170 171

dnl Check for compiler builtins
AX_GCC_BUILTIN([__builtin_bswap32])
Tom Stellard's avatar
Tom Stellard committed
172
AX_GCC_BUILTIN([__builtin_bswap64])
173 174 175 176 177 178 179 180 181
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])
182

183 184
AX_GCC_FUNC_ATTRIBUTE([flatten])
AX_GCC_FUNC_ATTRIBUTE([format])
185
AX_GCC_FUNC_ATTRIBUTE([malloc])
186 187
AX_GCC_FUNC_ATTRIBUTE([packed])

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

190
dnl Make sure the pkg-config macros are defined
191 192 193 194 195
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.])])
196 197 198 199
PKG_PROG_PKG_CONFIG()

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

Matt Turner's avatar
Matt Turner committed
202
dnl Cache LDFLAGS and CPPFLAGS so we can add to them and restore later
203 204 205 206
_SAVE_LDFLAGS="$LDFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"

dnl Compiler macros
207
DEFINES="-DUSE_EXTERNAL_DXTN_LIB=1"
208
AC_SUBST([DEFINES])
209
case "$host_os" in
Samuel Thibault's avatar
Samuel Thibault committed
210
linux*|*-gnu*|gnu*)
211
    DEFINES="$DEFINES -D_GNU_SOURCE"
212
    ;;
213
solaris*)
214
    DEFINES="$DEFINES -DSVR4"
215
    ;;
216
cygwin*)
217
    DEFINES="$DEFINES -D_XOPEN_SOURCE=700"
218
    ;;
219 220 221 222
esac

dnl Add flags for gcc and g++
if test "x$GCC" = xyes; then
223
    CFLAGS="$CFLAGS -Wall -std=c99"
224 225 226 227 228 229 230 231 232 233 234 235 236

    # 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])]);
237 238 239

    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CFLAGS="$CFLAGS"
240
    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
241 242
    VISIBILITY_CFLAGS="-fvisibility=hidden"
    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
243
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
244 245 246 247
		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);

    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
    CFLAGS=$save_CFLAGS
248 249 250

    # Work around aliasing bugs - developers should comment this out
    CFLAGS="$CFLAGS -fno-strict-aliasing"
251 252 253 254

    # gcc's builtin memcmp is slower than glibc's
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
    CFLAGS="$CFLAGS -fno-builtin-memcmp"
255 256 257
fi
if test "x$GXX" = xyes; then
    CXXFLAGS="$CXXFLAGS -Wall"
258

259 260 261
    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CXXFLAGS="$CXXFLAGS"
    AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
262 263
    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
    CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
264
    AC_LANG_PUSH([C++])
265
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
266
		   [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
267
    AC_LANG_POP([C++])
268 269 270

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

272 273
    # Work around aliasing bugs - developers should comment this out
    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
274 275 276 277

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

280 281 282 283 284 285 286 287 288
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

289 290 291
AC_SUBST([VISIBILITY_CFLAGS])
AC_SUBST([VISIBILITY_CXXFLAGS])

292 293 294
dnl
dnl Optional flags, check for compiler support
dnl
295 296 297 298 299 300 301 302
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
303
save_CFLAGS="$CFLAGS"
304
CFLAGS="$SSE41_CFLAGS $CFLAGS"
305 306 307 308 309 310 311 312
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <smmintrin.h>
int main () {
    __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
    c = _mm_max_epu32(a, b);
    return 0;
}]])], SSE41_SUPPORTED=1)
CFLAGS="$save_CFLAGS"
313 314 315
if test "x$SSE41_SUPPORTED" = x1; then
    DEFINES="$DEFINES -DUSE_SSE41"
fi
316
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
317
AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS)
318

319 320
dnl Can't have static and shared libraries, default to static if user
dnl explicitly requested. If both disabled, set to static since shared
321
dnl was explicitly requested.
322
case "x$enable_static$enable_shared" in
323 324 325
xyesyes)
    AC_MSG_WARN([Cannot build static and shared libraries, disabling shared])
    enable_shared=no
326
    ;;
327 328
xnono)
    AC_MSG_WARN([Cannot disable both static and shared libraries, enabling shared])
329
    enable_shared=yes
330 331 332
    ;;
esac

333 334
AM_CONDITIONAL(BUILD_SHARED, test "x$enable_shared" = xyes)

335 336 337
dnl
dnl other compiler options
dnl
338
AC_ARG_ENABLE([debug],
339 340
    [AS_HELP_STRING([--enable-debug],
        [use debug compiler flags and macros @<:@default=disabled@:>@])],
341 342
    [enable_debug="$enableval"],
    [enable_debug=no]
343 344 345 346
)
if test "x$enable_debug" = xyes; then
    DEFINES="$DEFINES -DDEBUG"
    if test "x$GCC" = xyes; then
347 348 349 350 351 352
        if ! echo "$CFLAGS" | grep -q -e '-g'; then
            CFLAGS="$CFLAGS -g"
        fi
        if ! echo "$CFLAGS" | grep -q -e '-O'; then
            CFLAGS="$CFLAGS -O0"
        fi
353 354
    fi
    if test "x$GXX" = xyes; then
355 356 357 358 359 360
        if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
            CXXFLAGS="$CXXFLAGS -g"
        fi
        if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
            CXXFLAGS="$CXXFLAGS -O0"
        fi
361 362
    fi
fi
363

Jon TURNEY's avatar
Jon TURNEY committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
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])

380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
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])

396 397 398 399 400
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
401
openbsd* | darwin* )
402 403 404 405 406 407 408
    LD_NO_UNDEFINED="" ;;
*)
    LD_NO_UNDEFINED="-Wl,--no-undefined" ;;
esac

AC_SUBST([LD_NO_UNDEFINED])

Jon TURNEY's avatar
Jon TURNEY committed
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
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")

431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
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")

449 450 451 452 453 454 455 456 457 458 459 460
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)

461 462 463
dnl
dnl library names
dnl
464 465 466 467 468 469 470 471 472 473
case "$host_os" in
darwin* )
    LIB_EXT='dylib' ;;
cygwin* )
    LIB_EXT='dll' ;;
aix* )
    LIB_EXT='a' ;;
* )
    LIB_EXT='so' ;;
esac
474 475 476

AC_SUBST([LIB_EXT])

477 478 479 480 481 482 483 484 485 486 487 488
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])
489

490 491 492 493 494 495 496 497 498 499 500
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"
501 502
  GL_LIB="Mangled${GL_LIB}"
  OSMESA_LIB="Mangled${OSMESA_LIB}"
503 504 505 506
fi
AC_SUBST([GL_LIB])
AC_SUBST([OSMESA_LIB])

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
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

522 523 524 525 526 527 528 529 530 531 532 533 534
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
535
if test "x$enable_asm" = xyes -a "x$cross_compiling" = xyes; then
536
    case "$host_cpu" in
537
    i?86 | x86_64 | amd64)
538 539 540 541 542 543 544 545 546 547
        enable_asm=no
        AC_MSG_RESULT([no, cross compiling])
        ;;
    esac
fi
# check for supported arches
if test "x$enable_asm" = xyes; then
    case "$host_cpu" in
    i?86)
        case "$host_os" in
548
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | gnu*)
549 550
            asm_arch=x86
            ;;
551 552
        esac
        ;;
553
    x86_64|amd64)
554
        case "$host_os" in
Jonathan Gray's avatar
Jonathan Gray committed
555
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
556
            asm_arch=x86_64
557 558 559
            ;;
        esac
        ;;
560 561 562 563 564 565 566
    sparc*)
        case "$host_os" in
        linux*)
            asm_arch=sparc
            ;;
        esac
        ;;
567 568 569 570
    esac

    case "$asm_arch" in
    x86)
571
        DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
572 573
        AC_MSG_RESULT([yes, x86])
        ;;
574
    x86_64|amd64)
575
        DEFINES="$DEFINES -DUSE_X86_64_ASM"
576 577
        AC_MSG_RESULT([yes, x86_64])
        ;;
578
    sparc)
579
        DEFINES="$DEFINES -DUSE_SPARC_ASM"
580 581
        AC_MSG_RESULT([yes, sparc])
        ;;
582 583 584 585 586 587
    *)
        AC_MSG_RESULT([no, platform not supported])
        ;;
    esac
fi

588 589 590
AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])

591 592
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.
593 594 595
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
596
AC_SUBST([DLOPEN_LIBS])
597

598
dnl Check if that library also has dladdr
599 600 601 602
save_LIBS="$LIBS"
LIBS="$LIBS $DLOPEN_LIBS"
AC_CHECK_FUNCS([dladdr])
LIBS="$save_LIBS"
603

604
case "$host_os" in
605
darwin*|mingw*)
606 607 608 609
    ;;
*)
    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
                   [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
610
                                 [AC_MSG_ERROR([Could not find clock_gettime])])])
611 612 613
    AC_SUBST([CLOCK_LIB])
    ;;
esac
614

615 616 617
dnl See if posix_memalign is available
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])

618
dnl Check for pthreads
619 620 621 622 623 624 625
case "$host_os" in
mingw*)
    ;;
*)
    AX_PTHREAD
    ;;
esac
626 627 628 629
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"
630

631 632 633 634 635 636 637
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
638 639 640 641 642 643
    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"])
644 645
    DEFINES="$DEFINES -DMESA_SELINUX"
fi
646
AC_SUBST([SELINUX_CFLAGS])
647
AC_SUBST([SELINUX_LIBS])
648

649
dnl Options for APIs
650 651
AC_ARG_ENABLE([opengl],
    [AS_HELP_STRING([--disable-opengl],
652
        [disable support for standard OpenGL API @<:@default=enabled@:>@])],
653 654 655 656
    [enable_opengl="$enableval"],
    [enable_opengl=yes])
AC_ARG_ENABLE([gles1],
    [AS_HELP_STRING([--enable-gles1],
657
        [enable support for OpenGL ES 1.x API @<:@default=disabled@:>@])],
658 659 660 661
    [enable_gles1="$enableval"],
    [enable_gles1=no])
AC_ARG_ENABLE([gles2],
    [AS_HELP_STRING([--enable-gles2],
662
        [enable support for OpenGL ES 2.x API @<:@default=disabled@:>@])],
663 664 665 666
    [enable_gles2="$enableval"],
    [enable_gles2=no])
AC_ARG_ENABLE([openvg],
    [AS_HELP_STRING([--enable-openvg],
667
        [enable support for OpenVG API @<:@default=disabled@:>@])],
668 669
    [enable_openvg="$enableval"],
    [enable_openvg=no])
670 671 672

AC_ARG_ENABLE([dri],
    [AS_HELP_STRING([--enable-dri],
673
        [enable DRI modules @<:@default=enabled@:>@])],
674
    [enable_dri="$enableval"],
675
    [enable_dri=yes])
676 677 678 679 680 681 682 683 684

case "$host_os" in
linux*)
    dri3_default=yes
    ;;
*)
    dri3_default=no
    ;;
esac
685 686
AC_ARG_ENABLE([dri3],
    [AS_HELP_STRING([--enable-dri3],
687
        [enable DRI3 @<:@default=auto@:>@])],
688
    [enable_dri3="$enableval"],
689
    [enable_dri3="$dri3_default"])
690 691
AC_ARG_ENABLE([glx],
    [AS_HELP_STRING([--enable-glx],
692
        [enable GLX library @<:@default=enabled@:>@])],
693
    [enable_glx="$enableval"],
694
    [enable_glx=yes])
695 696
AC_ARG_ENABLE([osmesa],
    [AS_HELP_STRING([--enable-osmesa],
697
        [enable OSMesa library @<:@default=disabled@:>@])],
698
    [enable_osmesa="$enableval"],
699
    [enable_osmesa=no])
700 701 702 703 704
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])
705 706 707 708 709 710
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
711 712
AC_ARG_ENABLE([xa],
    [AS_HELP_STRING([--enable-xa],
713
        [enable build of the XA X Acceleration API @<:@default=disabled@:>@])],
Thomas Hellstrom's avatar
Thomas Hellstrom committed
714 715
    [enable_xa="$enableval"],
    [enable_xa=no])
716 717 718 719 720
AC_ARG_ENABLE([gbm],
   [AS_HELP_STRING([--enable-gbm],
         [enable gbm library @<:@default=auto@:>@])],
   [enable_gbm="$enableval"],
   [enable_gbm=auto])
721 722 723 724 725
AC_ARG_ENABLE([nine],
    [AS_HELP_STRING([--enable-nine],
        [enable build of the nine Direct3D9 API @<:@default=no@:>@])],
    [enable_nine="$enableval"],
    [enable_nine=no])
726

727 728 729 730
AC_ARG_ENABLE([xvmc],
   [AS_HELP_STRING([--enable-xvmc],
         [enable xvmc library @<:@default=auto@:>@])],
   [enable_xvmc="$enableval"],
731
   [enable_xvmc=auto])
732 733 734 735 736
AC_ARG_ENABLE([vdpau],
   [AS_HELP_STRING([--enable-vdpau],
         [enable vdpau library @<:@default=auto@:>@])],
   [enable_vdpau="$enableval"],
   [enable_vdpau=auto])
737 738
AC_ARG_ENABLE([omx],
   [AS_HELP_STRING([--enable-omx],
739
         [enable OpenMAX library @<:@default=disabled@:>@])],
740 741
   [enable_omx="$enableval"],
   [enable_omx=no])
742 743 744 745 746
AC_ARG_ENABLE([va],
   [AS_HELP_STRING([--enable-va],
         [enable va library @<:@default=auto@:>@])],
   [enable_va="$enableval"],
   [enable_va=auto])
747 748
AC_ARG_ENABLE([opencl],
   [AS_HELP_STRING([--enable-opencl],
749
         [enable OpenCL library @<:@default=disabled@:>@])],
750
   [enable_opencl="$enableval"],
751
   [enable_opencl=no])
752 753 754
AC_ARG_ENABLE([opencl_icd],
   [AS_HELP_STRING([--enable-opencl-icd],
          [Build an OpenCL ICD library to be loaded by an ICD implementation
755
           @<:@default=disabled@:>@])],
756 757
    [enable_opencl_icd="$enableval"],
    [enable_opencl_icd=no])
758
AC_ARG_ENABLE([xlib-glx],
759
    [AS_HELP_STRING([--enable-xlib-glx],
760
        [make GLX library Xlib-based instead of DRI-based @<:@default=disabled@:>@])],
761
    [enable_xlib_glx="$enableval"],
762
    [enable_xlib_glx=no])
763

764
AC_ARG_ENABLE([r600-llvm-compiler],
765
    [AS_HELP_STRING([--enable-r600-llvm-compiler],
766
        [Enable experimental LLVM backend for graphics shaders @<:@default=disabled@:>@])],
767 768 769
    [enable_r600_llvm="$enableval"],
    [enable_r600_llvm=no])

770
AC_ARG_ENABLE([gallium-tests],
771
    [AS_HELP_STRING([--enable-gallium-tests],
772
        [Enable optional Gallium tests) @<:@default=disabled@:>@])],
773 774 775
    [enable_gallium_tests="$enableval"],
    [enable_gallium_tests=no])

776
# Option for Gallium drivers
777 778

# Keep this in sync with the --with-gallium-drivers help string default value
779
GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
780 781 782 783

AC_ARG_WITH([gallium-drivers],
    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
        [comma delimited Gallium drivers list, e.g.
784
        "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4"
785
        @<:@default=r300,r600,svga,swrast@:>@])],
786 787
    [with_gallium_drivers="$withval"],
    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
788

789 790 791 792 793 794 795
# 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

796 797 798
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xno -a \
        "x$enable_gles2" = xno -a \
799
        "x$enable_nine" = xno -a \
800
        "x$enable_openvg" = xno -a \
Thomas Hellstrom's avatar
Thomas Hellstrom committed
801
        "x$enable_xa" = xno -a \
802 803
        "x$enable_xvmc" = xno -a \
        "x$enable_vdpau" = xno -a \
804
        "x$enable_omx" = xno -a \
805
        "x$enable_va" = xno -a \
806
        "x$enable_opencl" = xno; then
807 808 809
    AC_MSG_ERROR([at least one API should be enabled])
fi

810 811 812 813 814 815 816 817 818 819 820
# 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
821 822 823 824 825 826 827
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)

828 829 830
if test "x$enable_glx" = xno; then
    AC_MSG_WARN([GLX disabled, disabling Xlib-GLX])
    enable_xlib_glx=no
831 832
fi

833 834
if test "x$enable_dri$enable_xlib_glx" = xyesyes; then
    AC_MSG_ERROR([DRI and Xlib-GLX cannot be built together])
835 836
fi

837 838 839 840 841 842 843 844 845 846
if test "x$enable_opengl$enable_xlib_glx" = xnoyes; then
    AC_MSG_ERROR([Xlib-GLX cannot be built without OpenGL])
fi

# Disable GLX if OpenGL is not enabled
if test "x$enable_glx$enable_opengl" = xyesno; then
    AC_MSG_WARN([OpenGL not enabled, disabling GLX])
    enable_glx=no
fi

847
# Disable GLX if DRI and Xlib-GLX are not enabled
848
if test "x$enable_glx" = xyes -a \
849
        "x$enable_dri" = xno -a \
850
        "x$enable_xlib_glx" = xno; then
851
    AC_MSG_WARN([Neither DRI nor Xlib-GLX enabled, disabling GLX])
852
    enable_glx=no
853
fi
854

Matt Turner's avatar
Matt Turner committed
855
AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xyes -a \
856
                                  "x$enable_dri" = xyes)
857 858 859 860 861 862 863 864 865 866 867 868 869

# Select which platform-dependent DRI code gets built
case "$host_os" in
darwin*)
    dri_platform='apple' ;;
gnu*|mingw*|cygwin*)
    dri_platform='none' ;;
*)
    dri_platform='drm' ;;
esac

AM_CONDITIONAL(HAVE_DRICOMMON, test "x$enable_dri" = xyes )
AM_CONDITIONAL(HAVE_DRISW, test "x$enable_dri" = xyes )
870 871 872
AM_CONDITIONAL(HAVE_DRI2, test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm )
AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes -a "x$dri_platform" = xdrm )
AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xapple )
Matt Turner's avatar
Matt Turner committed
873

874 875
AC_ARG_ENABLE([shared-glapi],
    [AS_HELP_STRING([--enable-shared-glapi],
876
        [Enable shared glapi for OpenGL @<:@default=enabled@:>@])],
877
    [enable_shared_glapi="$enableval"],
878
    [enable_shared_glapi=yes])
879

880 881 882 883 884 885 886 887
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
888

889 890 891 892 893 894
# Building Xlib-GLX requires shared glapi to be disabled.
if test "x$enable_xlib_glx" = xyes; then
    AC_MSG_NOTICE([Shared GLAPI should not used with Xlib-GLX, disabling])
    enable_shared_glapi=no
fi

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

897 898 899 900 901
# 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

902 903
dnl
dnl Driver specific build directories
904
dnl
905

906 907
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
908
    NEED_WINSYS_XLIB="yes"
909
    ;;
910 911 912
esac

if test "x$enable_dri" = xyes; then
913
    enable_gallium_loader="$enable_shared_pipe_drivers"
914 915
fi

916
if test "x$enable_gallium_osmesa" = xyes; then
917 918
    if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
        AC_MSG_ERROR([gallium_osmesa requires the gallium swrast driver])
919 920 921 922
    fi
    if test "x$enable_osmesa" = xyes; then
        AC_MSG_ERROR([Cannot enable both classic and Gallium OSMesa implementations])
    fi
923 924
fi

925
AC_SUBST([MESA_LLVM])
926

Chia-I Wu's avatar
Chia-I Wu committed
927 928 929
# Check for libdrm
PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
                  [have_libdrm=yes], [have_libdrm=no])
930 931 932
if test "x$have_libdrm" = xyes; then
	DEFINES="$DEFINES -DHAVE_LIBDRM"
fi
Chia-I Wu's avatar
Chia-I Wu committed
933

934 935
case "$host_os" in
linux*)
936
    need_pci_id=yes ;;
937
*)
938
    need_pci_id=no ;;
939 940
esac

941 942 943
PKG_CHECK_MODULES([LIBUDEV], [libudev >= $LIBUDEV_REQUIRED],
                  have_libudev=yes, have_libudev=no)

944 945 946 947 948 949 950
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
951
if test "x$enable_dri" = xyes; then
952 953 954 955
    if test "$enable_static" = yes; then
        AC_MSG_ERROR([Cannot use static libraries for DRI drivers])
    fi

956 957 958
    # 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
959 960 961
    fi
fi

962 963
AC_ARG_ENABLE([driglx-direct],
    [AS_HELP_STRING([--disable-driglx-direct],
964
        [disable direct rendering in GLX and EGL for DRI \
nobled's avatar
nobled committed
965
            @<:@default=auto@:>@])],
966
    [driglx_direct="$enableval"],
967
    [driglx_direct="yes"])
968

969
dnl
970
dnl libGL configuration per driver
971
dnl
972 973 974
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
    # Xlib-based GLX
975 976 977
    dri_modules="x11 xext xcb"
    PKG_CHECK_MODULES([XLIBGL], [$dri_modules])
    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
978 979
    X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
    GL_LIB_DEPS="$XLIBGL_LIBS"
980 981
    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"
982
    ;;
983 984
xyesno)
    # DRI-based GLX
Jesse Barnes's avatar
Jesse Barnes committed
985
    PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
986

987
    # find the DRI deps for libGL
988
    dri_modules="x11 xext xdamage xfixes x11-xcb xcb xcb-glx >= $XCBGLX_REQUIRED"
989

990 991
    if test x"$driglx_direct" = xyes; then
        if test x"$dri_platform" = xdrm ; then
992
            DEFINES="$DEFINES -DGLX_USE_DRM"
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
            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
1009
               PKG_CHECK_EXISTS([xcb >= $XCB_REQUIRED], [], AC_MSG_ERROR([DRI3 requires xcb >= $XCB_REQUIRED]))
1010 1011
               dri_modules="$dri_modules xcb-dri3 xcb-present xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
            fi
Jon TURNEY's avatar
Jon TURNEY committed
1012 1013 1014 1015
        fi
        if test x"$dri_platform" = xapple ; then
            DEFINES="$DEFINES -DGLX_USE_APPLEGL"
        fi
1016
    fi
1017

1018 1019 1020 1021
    # 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"
1022 1023
    fi

1024 1025
    PKG_CHECK_MODULES([DRIGL], [$dri_modules])
    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
1026 1027 1028
    X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
    GL_LIB_DEPS="$DRIGL_LIBS"

1029 1030 1031
    # 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"
1032
    ;;
1033
esac
1034

1035
have_pci_id=no
1036 1037
if test "$have_libudev" = yes; then
    DEFINES="$DEFINES -DHAVE_LIBUDEV"
1038 1039 1040 1041 1042 1043
    have_pci_id=yes
fi

if test "$have_sysfs" = yes; then
    DEFINES="$DEFINES -DHAVE_SYSFS"
    have_pci_id=yes
1044 1045
fi

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

1050 1051 1052 1053
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"
1054

1055
AC_SUBST([X11_INCLUDES])
1056
AC_SUBST([GL_LIB_DEPS])
1057 1058 1059 1060
AC_SUBST([GL_PC_REQ_PRIV])
AC_SUBST([GL_PC_LIB_PRIV])
AC_SUBST([GL_PC_CFLAGS])
AC_SUBST([DRI_PC_REQ_PRIV])
1061
AC_SUBST([GLESv1_CM_LIB_DEPS])
1062
AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
1063
AC_SUBST([GLESv2_LIB_DEPS])
1064 1065
AC_SUBST([GLESv2_PC_LIB_PRIV])

1066 1067
AC_SUBST([HAVE_XF86VIDMODE])

1068
dnl
Chia-I Wu's avatar
Chia-I Wu committed
1069
dnl More GLX setup
1070
dnl
Chia-I Wu's avatar
Chia-I Wu committed
1071 1072
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
1073
    DEFINES="$DEFINES -DUSE_XSHM"
Chia-I Wu's avatar
Chia-I Wu committed
1074 1075 1076 1077 1078 1079 1080 1081
    ;;
xyesno)
    DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
    if test "x$driglx_direct" = xyes; then
        DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
    fi
    ;;
esac
1082

1083
dnl
Tom Fogal's avatar
Tom Fogal committed
1084
dnl TLS detection
1085
dnl
Tom Fogal's avatar
Tom Fogal committed
1086

1087
AC_ARG_ENABLE([glx-tls],
1088
    [AS_HELP_STRING([--enable-glx-tls],
1089
        [enable TLS support in GLX @<:@default=disabled@:>@])],
1090 1091
    [GLX_USE_TLS="$enableval"],
    [GLX_USE_TLS=no])
Tom Fogal's avatar
Tom Fogal committed
1092 1093
AC_SUBST(GLX_TLS, ${GLX_USE_TLS})

1094
AS_IF([test "x$GLX_USE_TLS" = xyes -a "x$ax_pthread_ok" = xyes],
1095
      [DEFINES="${DEFINES} -DGLX_USE_TLS"])
Tom Fogal's avatar
Tom Fogal committed
1096

Tom Fogal's avatar
Tom Fogal committed
1097 1098 1099
dnl
dnl More DRI setup
dnl
1100
dnl Directory for DRI drivers
1101
AC_ARG_WITH([dri-driverdir],
1102
    [AS_HELP_STRING([--with-dri-driverdir=DIR],
1103
        [directory for the DRI drivers @<:@${libdir}/dri@:>@])],