configure.ac 73.9 KB
Newer Older
1
dnl Process this file with autoconf to create configure.
2

3
AC_PREREQ([2.60])
4

5 6 7 8
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.])

9 10
m4_define(MESA_VERSION, m4_normalize(m4_include(VERSION)))
AC_INIT([Mesa], [MESA_VERSION],
11
    [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
12
AC_CONFIG_AUX_DIR([bin])
13
AC_CONFIG_MACRO_DIR([m4])
14
AC_CANONICAL_SYSTEM
15
AM_INIT_AUTOMAKE([foreign])
16

17 18 19
# 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
20 21
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
22

23 24
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

25 26 27 28
dnl Set internal versions
OSMESA_VERSION=8
AC_SUBST([OSMESA_VERSION])

29
dnl Versions for external dependencies
30
LIBDRM_REQUIRED=2.4.38
31
LIBDRM_RADEON_REQUIRED=2.4.50
32
LIBDRM_INTEL_REQUIRED=2.4.52
33
LIBDRM_NVVIEUX_REQUIRED=2.4.33
34
LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
35
LIBDRM_FREEDRENO_REQUIRED=2.4.51
36
DRI2PROTO_REQUIRED=2.6
Keith Packard's avatar
Keith Packard committed
37 38 39
DRI3PROTO_REQUIRED=1.0
PRESENTPROTO_REQUIRED=1.0
LIBUDEV_REQUIRED=151
40
GLPROTO_REQUIRED=1.4.14
41 42 43 44 45 46 47
LIBOMXIL_BELLAGIO_REQUIRED=0.0
VDPAU_REQUIRED=0.4.1
WAYLAND_REQUIRED=1.2.0
XCBDRI2_REQUIRED=1.8
XCBGLX_REQUIRED=1.8.1
XSHMFENCE_REQUIRED=1.1
XVMC_REQUIRED=1.0.6
48

49 50 51 52
dnl Check for progs
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CXX
53
AM_PROG_CC_C_O
54
AM_PROG_AS
55
AC_CHECK_PROGS([MAKE], [gmake make])
56
AC_CHECK_PROGS([PYTHON2], [python2 python])
57
AX_PYTHON_MODULE([libxml2], [needed])
58
AC_PROG_SED
59
AC_PROG_MKDIR_P
60

61 62 63
LT_PREREQ([2.2])
LT_INIT([disable-static])

Matt Turner's avatar
Matt Turner committed
64
AX_PROG_BISON([],
65
              AS_IF([test ! -f "$srcdir/src/glsl/glcpp/glcpp-parse.c"],
Matt Turner's avatar
Matt Turner committed
66
                    [AC_MSG_ERROR([bison not found - unable to compile glcpp-parse.y])]))
Matt Turner's avatar
Matt Turner committed
67
AX_PROG_FLEX([],
68
             AS_IF([test ! -f "$srcdir/src/glsl/glcpp/glcpp-lex.c"],
Matt Turner's avatar
Matt Turner committed
69
                   [AC_MSG_ERROR([flex not found - unable to compile glcpp-lex.l])]))
70

71 72
AC_PATH_PROG([PERL], [perl])

73 74
AC_CHECK_PROG(INDENT, indent, indent, cat)
if test "x$INDENT" != "xcat"; then
75
    AC_SUBST(INDENT_FLAGS, '-i4 -nut -br -brs -npcs -ce -TGLubyte -TGLbyte -TBool')
76 77
fi

78 79
AC_PROG_INSTALL

80 81
dnl We need a POSIX shell for parts of the build. Assume we have one
dnl in most cases.
82 83 84 85
case "$host_os" in
solaris*)
    # Solaris /bin/sh is too old/non-POSIX compliant
    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
86
    SHELL="$POSIX_SHELL"
87 88 89
    ;;
esac

90 91 92 93 94 95 96 97 98 99
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
]])],
100
[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
101

102
AC_MSG_RESULT([$acv_mesa_CLANG])
103

Ian Romanick's avatar
Ian Romanick committed
104 105
dnl If we're using GCC, make sure that it is at least version 3.3.0.  Older
dnl versions are explictly not supported.
106
GEN_ASM_OFFSETS=no
107
if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
Ian Romanick's avatar
Ian Romanick committed
108 109 110 111 112 113
    AC_MSG_CHECKING([whether gcc version is sufficient])
    major=0
    minor=0

    GCC_VERSION=`$CC -dumpversion`
    if test $? -eq 0; then
114 115
        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
116 117
    fi

118
    if test $GCC_VERSION_MAJOR -lt 3 -o $GCC_VERSION_MAJOR -eq 3 -a $GCC_VERSION_MINOR -lt 3 ; then
Ian Romanick's avatar
Ian Romanick committed
119 120 121 122 123
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([If using GCC, version 3.3.0 or later is required.])
    else
        AC_MSG_RESULT([yes])
    fi
124 125 126 127

    if test "x$cross_compiling" = xyes; then
        GEN_ASM_OFFSETS=yes
    fi
Ian Romanick's avatar
Ian Romanick committed
128
fi
129 130 131

dnl Check for compiler builtins
AX_GCC_BUILTIN([__builtin_bswap32])
132
AX_GCC_BUILTIN([__builtin_bswap64])
133

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

136
dnl Make sure the pkg-config macros are defined
137 138 139 140 141
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.])])
142 143 144 145
PKG_PROG_PKG_CONFIG()

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

148
dnl Cache LDFLAGS and CPPFLAGS so we can add to them and restore later
149 150 151 152 153
_SAVE_LDFLAGS="$LDFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"

dnl Compiler macros
DEFINES=""
154
AC_SUBST([DEFINES])
155
case "$host_os" in
Samuel Thibault's avatar
Samuel Thibault committed
156
linux*|*-gnu*|gnu*)
157
    DEFINES="$DEFINES -D_GNU_SOURCE -DHAVE_PTHREAD"
158
    ;;
159
solaris*)
160
    DEFINES="$DEFINES -DHAVE_PTHREAD -DSVR4"
161
    ;;
162
cygwin*)
163
    DEFINES="$DEFINES -DHAVE_PTHREAD"
164
    ;;
165 166 167 168
esac

dnl Add flags for gcc and g++
if test "x$GCC" = xyes; then
169 170 171 172 173 174 175 176
    case "$host_os" in
    cygwin*)
        CFLAGS="$CFLAGS -Wall -std=gnu99"
        ;;
    *)
        CFLAGS="$CFLAGS -Wall -std=c99"
        ;;
    esac
177 178 179 180 181 182 183 184 185 186 187 188 189

    # 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])]);
190 191 192

    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CFLAGS="$CFLAGS"
193
    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
194 195
    VISIBILITY_CFLAGS="-fvisibility=hidden"
    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
196
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
197 198 199 200
		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);

    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
    CFLAGS=$save_CFLAGS
201 202 203

    # Work around aliasing bugs - developers should comment this out
    CFLAGS="$CFLAGS -fno-strict-aliasing"
204 205 206 207

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

212 213 214
    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CXXFLAGS="$CXXFLAGS"
    AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
215 216
    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
    CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
217
    AC_LANG_PUSH([C++])
218
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
219
		   [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
220
    AC_LANG_POP([C++])
221 222 223

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

225 226
    # Work around aliasing bugs - developers should comment this out
    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
227 228 229 230

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

233 234 235 236 237 238 239 240 241
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

242 243 244
AC_SUBST([VISIBILITY_CFLAGS])
AC_SUBST([VISIBILITY_CXXFLAGS])

245 246 247 248 249 250
dnl
dnl Optional flags, check for compiler support
dnl
AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])

251 252 253
dnl
dnl Hacks to enable 32 or 64 bit build
dnl
254
AC_ARG_ENABLE([32-bit],
255 256
    [AS_HELP_STRING([--enable-32-bit],
        [build 32-bit libraries @<:@default=auto@:>@])],
257 258
    [enable_32bit="$enableval"],
    [enable_32bit=auto]
259 260 261 262
)
if test "x$enable_32bit" = xyes; then
    if test "x$GCC" = xyes; then
        CFLAGS="$CFLAGS -m32"
263
        CCASFLAGS="$CCASFLAGS -m32"
264 265 266 267 268
    fi
    if test "x$GXX" = xyes; then
        CXXFLAGS="$CXXFLAGS -m32"
    fi
fi
269
AC_ARG_ENABLE([64-bit],
270 271
    [AS_HELP_STRING([--enable-64-bit],
        [build 64-bit libraries @<:@default=auto@:>@])],
272 273
    [enable_64bit="$enableval"],
    [enable_64bit=auto]
274 275 276 277 278 279 280 281 282 283
)
if test "x$enable_64bit" = xyes; then
    if test "x$GCC" = xyes; then
        CFLAGS="$CFLAGS -m64"
    fi
    if test "x$GXX" = xyes; then
        CXXFLAGS="$CXXFLAGS -m64"
    fi
fi

284 285
dnl Can't have static and shared libraries, default to static if user
dnl explicitly requested. If both disabled, set to static since shared
286
dnl was explicitly requested.
287 288
case "x$enable_static$enable_shared" in
xyesyes )
289
    AC_MSG_WARN([Cannot build static and shared libraries, disabling shared])
290 291 292
    enable_shared=no
    ;;
xnono )
293
    AC_MSG_WARN([Cannot disable both static and shared libraries, enabling static])
294 295 296 297
    enable_static=yes
    ;;
esac

298 299
AM_CONDITIONAL(BUILD_SHARED, test "x$enable_shared" = xyes)

300 301 302
dnl
dnl other compiler options
dnl
303
AC_ARG_ENABLE([debug],
304 305
    [AS_HELP_STRING([--enable-debug],
        [use debug compiler flags and macros @<:@default=disabled@:>@])],
306 307
    [enable_debug="$enableval"],
    [enable_debug=no]
308 309 310 311
)
if test "x$enable_debug" = xyes; then
    DEFINES="$DEFINES -DDEBUG"
    if test "x$GCC" = xyes; then
312
        CFLAGS="$CFLAGS -g -O0"
313 314
    fi
    if test "x$GXX" = xyes; then
315
        CXXFLAGS="$CXXFLAGS -g -O0"
316 317
    fi
fi
318

319 320 321 322 323 324 325 326 327 328 329 330
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)

331 332 333
dnl
dnl library names
dnl
334
if test "$enable_static" = yes; then
335
    LIB_EXT='a'
336
else
337 338
    case "$host_os" in
    darwin* )
339
        LIB_EXT='dylib' ;;
Jon Turney's avatar
Jon Turney committed
340
    cygwin* )
341
        LIB_EXT='dll' ;;
342
    aix* )
343
        LIB_EXT='a' ;;
344
    * )
345
        LIB_EXT='so' ;;
346
    esac
347
fi
348 349 350

AC_SUBST([LIB_EXT])

351 352 353 354 355 356 357 358 359 360 361 362
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])
363

364 365 366 367 368 369 370 371 372 373 374
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"
375 376
  GL_LIB="Mangled${GL_LIB}"
  OSMESA_LIB="Mangled${OSMESA_LIB}"
377 378 379 380
fi
AC_SUBST([GL_LIB])
AC_SUBST([OSMESA_LIB])

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

396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
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
if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
    case "$host_cpu" in
411
    i?86 | x86_64 | amd64)
412 413 414 415 416 417 418 419 420 421
        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
422
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
423 424
            test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
            ;;
425 426 427
        gnu*)
            asm_arch=x86
            ;;
428 429
        esac
        ;;
430
    x86_64|amd64)
431
        case "$host_os" in
432
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
433 434 435 436
            test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
            ;;
        esac
        ;;
437 438 439 440 441 442 443
    sparc*)
        case "$host_os" in
        linux*)
            asm_arch=sparc
            ;;
        esac
        ;;
444 445 446 447
    esac

    case "$asm_arch" in
    x86)
448
        DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
449 450
        AC_MSG_RESULT([yes, x86])
        ;;
451
    x86_64|amd64)
452
        DEFINES="$DEFINES -DUSE_X86_64_ASM"
453 454
        AC_MSG_RESULT([yes, x86_64])
        ;;
455
    sparc)
456
        DEFINES="$DEFINES -DUSE_SPARC_ASM"
457 458
        AC_MSG_RESULT([yes, sparc])
        ;;
459 460 461 462 463 464 465 466
    *)
        AC_MSG_RESULT([no, platform not supported])
        ;;
    esac
fi

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.
467 468 469
AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
    [AC_CHECK_LIB([dl], [dlopen],
       [DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])])
470
AC_SUBST([DLOPEN_LIBS])
471

472
case "$host_os" in
473
darwin*|mingw*)
474 475 476 477 478 479 480 481
    ;;
*)
    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
                   [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
                                 [AC_MSG_ERROR([Couldn't find clock_gettime])])])
    AC_SUBST([CLOCK_LIB])
    ;;
esac
482

483 484 485
dnl See if posix_memalign is available
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])

486 487
dnl Check for pthreads
AX_PTHREAD
488 489 490 491
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"
492

493 494 495 496 497 498 499
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
500 501 502 503 504 505
    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"])
506 507
    DEFINES="$DEFINES -DMESA_SELINUX"
fi
508
AC_SUBST([SELINUX_CFLAGS])
509
AC_SUBST([SELINUX_LIBS])
510

511
dnl Options for APIs
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
AC_ARG_ENABLE([opengl],
    [AS_HELP_STRING([--disable-opengl],
        [disable support for standard OpenGL API @<:@default=no@:>@])],
    [enable_opengl="$enableval"],
    [enable_opengl=yes])
AC_ARG_ENABLE([gles1],
    [AS_HELP_STRING([--enable-gles1],
        [enable support for OpenGL ES 1.x API @<:@default=no@:>@])],
    [enable_gles1="$enableval"],
    [enable_gles1=no])
AC_ARG_ENABLE([gles2],
    [AS_HELP_STRING([--enable-gles2],
        [enable support for OpenGL ES 2.x API @<:@default=no@:>@])],
    [enable_gles2="$enableval"],
    [enable_gles2=no])
AC_ARG_ENABLE([openvg],
    [AS_HELP_STRING([--enable-openvg],
        [enable support for OpenVG API @<:@default=no@:>@])],
    [enable_openvg="$enableval"],
    [enable_openvg=no])
532 533 534

AC_ARG_ENABLE([dri],
    [AS_HELP_STRING([--enable-dri],
535
        [enable DRI modules @<:@default=enabled@:>@])],
536
    [enable_dri="$enableval"],
537
    [enable_dri=yes])
538 539 540 541 542
AC_ARG_ENABLE([dri3],
    [AS_HELP_STRING([--enable-dri3],
        [enable DRI3 @<:@default=enabled@:>@])],
    [enable_dri3="$enableval"],
    [enable_dri3=yes])
543 544
AC_ARG_ENABLE([glx],
    [AS_HELP_STRING([--enable-glx],
545
        [enable GLX library @<:@default=enabled@:>@])],
546
    [enable_glx="$enableval"],
547
    [enable_glx=yes])
548 549
AC_ARG_ENABLE([osmesa],
    [AS_HELP_STRING([--enable-osmesa],
550
        [enable OSMesa library @<:@default=disabled@:>@])],
551
    [enable_osmesa="$enableval"],
552
    [enable_osmesa=no])
553 554 555 556 557
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])
558 559 560 561 562 563
AC_ARG_ENABLE([egl],
    [AS_HELP_STRING([--disable-egl],
        [disable EGL library @<:@default=enabled@:>@])],
    [enable_egl="$enableval"],
    [enable_egl=yes])

564 565 566 567 568
AC_ARG_ENABLE([xa],
    [AS_HELP_STRING([--enable-xa],
        [enable build of the XA X Acceleration API @<:@default=no@:>@])],
    [enable_xa="$enableval"],
    [enable_xa=no])
569 570 571 572 573
AC_ARG_ENABLE([gbm],
   [AS_HELP_STRING([--enable-gbm],
         [enable gbm library @<:@default=auto@:>@])],
   [enable_gbm="$enableval"],
   [enable_gbm=auto])
574

575 576 577 578
AC_ARG_ENABLE([xvmc],
   [AS_HELP_STRING([--enable-xvmc],
         [enable xvmc library @<:@default=auto@:>@])],
   [enable_xvmc="$enableval"],
579
   [enable_xvmc=no])
580 581 582 583 584
AC_ARG_ENABLE([vdpau],
   [AS_HELP_STRING([--enable-vdpau],
         [enable vdpau library @<:@default=auto@:>@])],
   [enable_vdpau="$enableval"],
   [enable_vdpau=auto])
585 586 587 588 589
AC_ARG_ENABLE([omx],
   [AS_HELP_STRING([--enable-omx],
         [enable OpenMAX library @<:@default=no@:>@])],
   [enable_omx="$enableval"],
   [enable_omx=no])
590 591
AC_ARG_ENABLE([opencl],
   [AS_HELP_STRING([--enable-opencl],
592
         [enable OpenCL library NOTE: Enabling this option will also enable
593
          --enable-llvm-shared-libs
594
          @<:@default=no@:>@])],
595
   [],
596
   [enable_opencl=no])
597 598 599 600 601 602
AC_ARG_ENABLE([opencl_icd],
   [AS_HELP_STRING([--enable-opencl-icd],
          [Build an OpenCL ICD library to be loaded by an ICD implementation
           @<:@default=no@:>@])],
    [enable_opencl_icd="$enableval"],
    [enable_opencl_icd=no])
603
AC_ARG_ENABLE([xlib-glx],
604
    [AS_HELP_STRING([--enable-xlib-glx],
605
        [make GLX library Xlib-based instead of DRI-based @<:@default=disabled@:>@])],
606
    [enable_xlib_glx="$enableval"],
607
    [enable_xlib_glx=no])
608
AC_ARG_ENABLE([gallium-egl],
609 610 611 612 613 614
    [AS_HELP_STRING([--enable-gallium-egl],
        [enable optional EGL state tracker (not required
         for EGL support in Gallium with OpenGL and OpenGL ES)
         @<:@default=disable@:>@])],
    [enable_gallium_egl="$enableval"],
    [enable_gallium_egl=no])
615
AC_ARG_ENABLE([gallium-gbm],
616 617 618
    [AS_HELP_STRING([--enable-gallium-gbm],
        [enable optional gbm state tracker (not required for
         gbm support in Gallium)
619
         @<:@default=auto@:>@])],
620
    [enable_gallium_gbm="$enableval"],
621
    [enable_gallium_gbm=auto])
622

623
AC_ARG_ENABLE([r600-llvm-compiler],
624 625
    [AS_HELP_STRING([--enable-r600-llvm-compiler],
        [Enable experimental LLVM backend for graphics shaders @<:@default=disable@:>@])],
626 627 628
    [enable_r600_llvm="$enableval"],
    [enable_r600_llvm=no])

629
AC_ARG_ENABLE([gallium-tests],
630 631 632 633 634
    [AS_HELP_STRING([--enable-gallium-tests],
        [Enable optional Gallium tests) @<:@default=disable@:>@])],
    [enable_gallium_tests="$enableval"],
    [enable_gallium_tests=no])

635
# Option for Gallium drivers
636 637

# Keep this in sync with the --with-gallium-drivers help string default value
638
GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
639 640 641 642

AC_ARG_WITH([gallium-drivers],
    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
        [comma delimited Gallium drivers list, e.g.
643
        "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast"
644
        @<:@default=r300,r600,svga,swrast@:>@])],
645 646
    [with_gallium_drivers="$withval"],
    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
647

648 649 650 651 652 653 654
# 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

655 656 657
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xno -a \
        "x$enable_gles2" = xno -a \
658
        "x$enable_openvg" = xno -a \
659
        "x$enable_xa" = xno -a \
660 661
        "x$enable_xvmc" = xno -a \
        "x$enable_vdpau" = xno -a \
662
        "x$enable_omx" = xno -a \
663
        "x$enable_opencl" = xno; then
664 665 666
    AC_MSG_ERROR([at least one API should be enabled])
fi

667 668 669 670 671 672 673 674 675 676 677
# 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

678 679 680 681 682 683 684
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)

685 686 687
if test "x$enable_glx" = xno; then
    AC_MSG_WARN([GLX disabled, disabling Xlib-GLX])
    enable_xlib_glx=no
688 689
fi

690 691
if test "x$enable_dri$enable_xlib_glx" = xyesyes; then
    AC_MSG_ERROR([DRI and Xlib-GLX cannot be built together])
692 693
fi

694 695 696 697 698 699 700 701 702 703
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

704
# Disable GLX if DRI and Xlib-GLX are not enabled
705
if test "x$enable_glx" = xyes -a \
706
        "x$enable_dri" = xno -a \
707
        "x$enable_xlib_glx" = xno; then
708
    AC_MSG_WARN([Neither DRI nor Xlib-GLX enabled, disabling GLX])
709
    enable_glx=no
710
fi
711

Matt Turner's avatar
Matt Turner committed
712
AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xyes -a \
713
                                  "x$enable_dri" = xyes)
714
AM_CONDITIONAL(HAVE_DRI, test "x$enable_dri" = xyes)
715
AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes)
Matt Turner's avatar
Matt Turner committed
716

717 718 719 720
AC_ARG_ENABLE([shared-glapi],
    [AS_HELP_STRING([--enable-shared-glapi],
        [Enable shared glapi for OpenGL @<:@default=yes@:>@])],
    [enable_shared_glapi="$enableval"],
721
    [enable_shared_glapi=yes])
722

723 724 725 726 727 728 729 730
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
731

732 733 734 735 736 737
# 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

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

740 741
dnl
dnl Driver specific build directories
742
dnl
743
GALLIUM_TARGET_DIRS=""
744
GALLIUM_WINSYS_DIRS="sw"
745
GALLIUM_DRIVERS_DIRS="galahad trace rbug noop identity"
746 747
GALLIUM_STATE_TRACKERS_DIRS=""

748 749
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
750
    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
751
    GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib"
752
    GALLIUM_STATE_TRACKERS_DIRS="glx $GALLIUM_STATE_TRACKERS_DIRS"
753
    NEED_WINSYS_XLIB="yes"
754
    ;;
755 756 757
esac

if test "x$enable_dri" = xyes; then
758
    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/dri"
759
    GALLIUM_STATE_TRACKERS_DIRS="dri $GALLIUM_STATE_TRACKERS_DIRS"
760 761
fi

762 763 764 765 766 767 768
if test "x$enable_gallium_osmesa" = xyes; then
    if test -z "$with_gallium_drivers"; then
        AC_MSG_ERROR([Cannot enable gallium_osmesa without Gallium])
    fi
    if test "x$enable_osmesa" = xyes; then
        AC_MSG_ERROR([Cannot enable both classic and Gallium OSMesa implementations])
    fi
769 770
    GALLIUM_STATE_TRACKERS_DIRS="osmesa $GALLIUM_STATE_TRACKERS_DIRS"
    GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS osmesa"
771 772
fi

773
AC_SUBST([MESA_LLVM])
774

Chia-I Wu's avatar
Chia-I Wu committed
775 776 777
# Check for libdrm
PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
                  [have_libdrm=yes], [have_libdrm=no])
778 779 780
if test "x$have_libdrm" = xyes; then
	DEFINES="$DEFINES -DHAVE_LIBDRM"
fi
Chia-I Wu's avatar
Chia-I Wu committed
781

782 783 784
PKG_CHECK_MODULES([LIBUDEV], [libudev >= $LIBUDEV_REQUIRED],
                  have_libudev=yes, have_libudev=no)

Chia-I Wu's avatar
Chia-I Wu committed
785 786 787
if test "x$enable_dri" = xyes; then
    # DRI must be shared, I think
    if test "$enable_static" = yes; then
788
        AC_MSG_ERROR([Cannot use static libraries for DRI drivers])
Chia-I Wu's avatar
Chia-I Wu committed
789 790
    fi

791 792 793
    # 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
794 795 796
    fi
fi

797
dnl Direct rendering or just indirect rendering
798 799 800 801 802
case "$host_os" in
gnu*)
    dnl Disable by default on GNU/Hurd
    driglx_direct_default="no"
    ;;
803 804 805 806
cygwin*)
    dnl Disable by default on cygwin
    driglx_direct_default="no"
    ;;
807 808 809 810
*)
    driglx_direct_default="yes"
    ;;
esac
811 812
AC_ARG_ENABLE([driglx-direct],
    [AS_HELP_STRING([--disable-driglx-direct],
813
        [disable direct rendering in GLX and EGL for DRI \
814
            @<:@default=auto@:>@])],
815
    [driglx_direct="$enableval"],
816
    [driglx_direct="$driglx_direct_default"])
817

818
dnl
819
dnl libGL configuration per driver
820
dnl
821 822 823
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
    # Xlib-based GLX
824 825 826 827
    PKG_CHECK_MODULES([XLIBGL], [x11 xext])
    GL_PC_REQ_PRIV="x11 xext"
    X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
    GL_LIB_DEPS="$XLIBGL_LIBS"
828 829
    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"
830
    ;;
831 832
xyesno)
    # DRI-based GLX
833
    PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
834
    if test x"$driglx_direct" = xyes; then
Chia-I Wu's avatar
Chia-I Wu committed
835 836 837
        if test "x$have_libdrm" != xyes; then
            AC_MSG_ERROR([Direct rendering requires libdrm >= $LIBDRM_REQUIRED])
        fi
838
        PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
839
        GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV libdrm >= $LIBDRM_REQUIRED"
840 841 842 843 844 845 846
        if test x"$enable_dri3" = xyes; then
            if test x"$have_libudev" != xyes; then
              AC_MSG_ERROR([DRI3 requires libudev >= $LIBUDEV_REQUIRED])
            fi
            PKG_CHECK_MODULES([DRI3PROTO], [dri3proto >= $DRI3PROTO_REQUIRED])
            PKG_CHECK_MODULES([PRESENTPROTO], [presentproto >= $PRESENTPROTO_REQUIRED])
        fi
847
    fi
848

849
    # find the DRI deps for libGL
850
    dri_modules="x11 xext xdamage xfixes x11-xcb xcb-glx >= $XCBGLX_REQUIRED xcb-dri2 >= $XCBDRI2_REQUIRED"
851 852

    if test x"$enable_dri3" = xyes; then
853
        dri_modules="$dri_modules xcb-dri3 xcb-present xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
854
    fi
855

856 857 858 859
    # 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"
860 861
    fi

862 863
    PKG_CHECK_MODULES([DRIGL], [$dri_modules])
    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
864 865 866
    X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
    GL_LIB_DEPS="$DRIGL_LIBS"

867 868 869
    # 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"
870
    ;;
871
esac
872

873 874 875 876
if test "$have_libudev" = yes; then
    DEFINES="$DEFINES -DHAVE_LIBUDEV"
fi

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

881 882 883 884
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"
885

886
AC_SUBST([X11_INCLUDES])
887
AC_SUBST([GL_LIB_DEPS])
888 889 890 891
AC_SUBST([GL_PC_REQ_PRIV])
AC_SUBST([GL_PC_LIB_PRIV])
AC_SUBST([GL_PC_CFLAGS])
AC_SUBST([DRI_PC_REQ_PRIV])
892
AC_SUBST([GLESv1_CM_LIB_DEPS])
893
AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
894
AC_SUBST([GLESv2_LIB_DEPS])
895 896
AC_SUBST([GLESv2_PC_LIB_PRIV])

897 898
AC_SUBST([HAVE_XF86VIDMODE])

899
dnl
Chia-I Wu's avatar
Chia-I Wu committed
900
dnl More GLX setup
901
dnl
Chia-I Wu's avatar
Chia-I Wu committed
902 903
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
904
    DEFINES="$DEFINES -DUSE_XSHM"
Chia-I Wu's avatar
Chia-I Wu committed
905 906 907 908 909 910 911 912
    ;;
xyesno)
    DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
    if test "x$driglx_direct" = xyes; then
        DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
    fi
    ;;
esac
913

914
dnl
915
dnl TLS detection
916
dnl
917

918
AC_ARG_ENABLE([glx-tls],
919
    [AS_HELP_STRING([--enable-glx-tls],
920
        [enable TLS support in GLX @<:@default=disabled@:>@])],
921 922
    [GLX_USE_TLS="$enableval"],
    [GLX_USE_TLS=no])
923 924
AC_SUBST(GLX_TLS, ${GLX_USE_TLS})

925
AS_IF([test "x$GLX_USE_TLS" = xyes -a "x$ax_pthread_ok" = xyes],
926
      [DEFINES="${DEFINES} -DGLX_USE_TLS -DHAVE_PTHREAD"])
Thomas Fogal's avatar
Thomas Fogal committed
927

928 929 930
dnl
dnl More DRI setup
dnl
931
dnl Directory for DRI drivers
932
AC_ARG_WITH([dri-driverdir],
933
    [AS_HELP_STRING([--with-dri-driverdir=DIR],
934
        [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
935
    [DRI_DRIVER_INSTALL_DIR="$withval"],
936
    [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
937
AC_SUBST([DRI_DRIVER_INSTALL_DIR])
938 939 940 941 942 943 944
dnl Extra search path for DRI drivers
AC_ARG_WITH([dri-searchpath],
    [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
        [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
    [DRI_DRIVER_SEARCH_DIR="$withval"],
    [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
AC_SUBST([DRI_DRIVER_SEARCH_DIR])
945
dnl Which drivers to build - default is chosen by platform
946
AC_ARG_WITH([dri-drivers],
947
    [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
948
        [comma delimited classic DRI drivers list, e.g.
949
        "swrast,i965,radeon" @<:@default=auto@:>@])],
950
    [with_dri_drivers="$withval"],
951
    [with_dri_drivers=auto])
952

953 954
if test "x$with_dri_drivers" = xauto; then
    if test "x$enable_opengl" = xyes -a "x$enable_dri" = xyes; then
955
        with_dri_drivers="yes"
956 957
    else
        with_dri_drivers="no"
958
    fi
959
fi
960 961 962
if test "x$with_dri_drivers" = xno; then
    with_dri_drivers=''
fi
963

964 965
dnl If $with_dri_drivers is yes, drivers will be added through
dnl platform checks. Set DEFINES and LIB_DEPS
966
if test "x$enable_dri" = xyes; then
967 968 969
    # Platform specific settings and drivers to build
    case "$host_os" in
    linux*)
970
        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1"
Chia-I Wu's avatar
Chia-I Wu committed
971
        DEFINES="$DEFINES -DHAVE_ALIAS"
972 973 974
        if test "x$enable_dri3" = xyes; then
            DEFINES="$DEFINES -DHAVE_DRI3"
        fi
975

976 977 978 979
        if test "x$have_libudev" != xyes; then
            AC_MSG_ERROR([libudev-dev required for building DRI])
        fi

980
        case "$host_cpu" in
981 982
        powerpc* | sparc*)
            # Build only the drivers for cards that exist on PowerPC/sparc
983 984
            if test "x$with_dri_drivers" = "xyes"; then
                with_dri_drivers="r200 radeon swrast"
985 986
            fi
            ;;
987 988
        esac
        ;;
989
    *freebsd* | dragonfly* | *netbsd* | openbsd*)
990
        DEFINES="$DEFINES -DHAVE_PTHREAD -DUSE_EXTERNAL_DXTN_LIB=1"
991
        DEFINES="$DEFINES -DHAVE_ALIAS"
992
        ;;
Samuel Thibault's avatar
Samuel Thibault committed
993
    gnu*)
994
        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1"
Chia-I Wu's avatar
Chia-I Wu committed
995
        DEFINES="$DEFINES -DHAVE_ALIAS"
Samuel Thibault's avatar
Samuel Thibault committed
996
	;;
997
    solaris*)
998
        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1"
999
        ;;
1000
    cygwin*)
1001
        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1"
1002 1003
        if test "x$with_dri_drivers" = "xyes"; then
            with_dri_drivers="swrast"
1004 1005
        fi
        ;;
1006
    esac
1007 1008

    # default drivers
1009 1010
    if test "x$with_dri_drivers" = "xyes"; then
        with_dri_drivers="i915 i965 nouveau r200 radeon swrast"
1011 1012
    fi

1013
    # Check for expat
1014 1015 1016 1017 1018 1019 1020 1021
    PKG_CHECK_EXISTS([EXPAT], [have_expat=yes], [have_expat=no])
    if test "x$have_expat" = "xyes"; then
       PKG_CHECK_MODULES([EXPAT], [expat], [],
                         AC_MSG_ERROR([Expat required for DRI.]))
    else
       # expat version 2.0 and earlier do not provide expat.pc
       EXPAT_LIBS=-lexpat
    fi
1022

1023
    # If we are building any DRI driver other than swrast.
1024 1025
    if test -n "$with_dri_drivers"; then
        if test "x$with_dri_drivers" != xswrast; then
1026 1027 1028 1029 1030 1031 1032
            # ... libdrm is required
            if test "x$have_libdrm" != xyes; then
                AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
            fi
            DRICOMMON_NEED_LIBDRM=yes
        else
            DRICOMMON_NEED_LIBDRM=no
1033 1034 1035
        fi
    fi

1036
    # put all the necessary libs together
1037 1038
    DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIBS -lm $PTHREAD_LIBS $DLOPEN_LIBS"
    GALLIUM_DRI_LIB_DEPS="$GALLIUM_DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIBS -lm $CLOCK_LIB $PTHREAD_LIBS $DLOPEN_LIBS"
1039

1040
fi
1041

1042 1043 1044
AC_SUBST([DRI_LIB_DEPS])
AC_SUBST([GALLIUM_DRI_LIB_DEPS])

1045 1046 1047
DRI_DIRS=''
dnl Duplicates in DRI_DIRS are removed by sorting it at the end of this block
if test -n "$with_dri_drivers"; then
1048 1049 1050 1051 1052 1053
    if test "x$enable_opengl" != xyes; then
        AC_MSG_ERROR([--with-dri-drivers requires OpenGL])
    fi

    dri_drivers=`IFS=', '; echo $with_dri_drivers`
    for driver in $dri_drivers; do
Eric Anholt's avatar
Eric Anholt committed
1054
        DRI_DIRS="$DRI_DIRS $driver"
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
        case "x$driver" in
        xi915)
            HAVE_I915_DRI=yes;
            PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
            ;;
        xi965)
            HAVE_I965_DRI=yes;
            PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
            ;;
        xnouveau)
            HAVE_NOUVEAU_DRI=yes;
            PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NVVIEUX_REQUIRED])
            ;;
        xradeon)
            HAVE_RADEON_DRI=yes;
            PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
            ;;
        xr200)
            HAVE_R200_DRI=yes;
            PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
            ;;
        xswrast)
            HAVE_SWRAST_DRI=yes;
            ;;
        *)
            AC_MSG_ERROR([classic DRI driver '$driver' does not exist])
            ;;
        esac
    done
1084
    DRI_DIRS=`echo $DRI_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
1085 1086
fi

1087
AM_CONDITIONAL(NEED_MEGADRIVER, test -n "$DRI_DIRS")
1088 1089
AM_CONDITIONAL(NEED_LIBMESA, test "x$enable_xlib_glx" = xyes -o \
                                  "x$enable_osmesa" = xyes -o \
1090
                                  -n "$DRI_DIRS")
1091

1092 1093 1094
dnl
dnl OSMesa configuration
dnl
1095

1096
dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
1097
AC_ARG_WITH([osmesa-bits],
1098 1099
    [AS_HELP_STRING([--with-osmesa-bits=BITS],
        [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
1100 1101
    [osmesa_bits="$withval"],
    [osmesa_bits=8])
1102 1103 1104 1105 1106
if test "x$osmesa_bits" != x8; then
    if test "x$enable_dri" = xyes -o "x$enable_glx" = xyes; then
        AC_MSG_WARN([Ignoring OSMesa channel bits because of non-OSMesa driver])
        osmesa_bits=8
    fi
1107 1108 1109
fi
case "x$osmesa_bits" in
x8)
1110
    OSMESA_LIB="${OSMESA_LIB}"
1111 1112
    ;;
x16|x32)
1113
    OSMESA_LIB="${OSMESA_LIB}$osmesa_bits"
1114 1115 1116 1117 1118 1119 1120
    DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
    ;;
*)
    AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
    ;;
esac

1121
if test "x$enable_osmesa" = xyes -o "x$enable_gallium_osmesa" = xyes; then
1122
    # only link libraries with osmesa if shared
1123
    if test "$enable_static" = no; then
1124
        OSMESA_LIB_DEPS="-lm $PTHREAD_LIBS $SELINUX_LIBS $DLOPEN_LIBS"
1125 1126 1127
    else
        OSMESA_LIB_DEPS=""
    fi
1128
    OSMESA_MESA_DEPS=""
1129
    OSMESA_PC_LIB_PRIV="-lm $PTHREAD_LIBS $SELINUX_LIBS $DLOPEN_LIBS"
1130
fi
1131

1132
AC_SUBST([OSMESA_LIB_DEPS])
1133 1134
AC_SUBST([OSMESA_MESA_DEPS])
AC_SUBST([OSMESA_PC_REQ])
1135
AC_SUBST([OSMESA_PC_LIB_PRIV])
1136

1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
dnl
dnl gbm configuration
dnl
if test "x$enable_gbm" = xauto; then
    case "$with_egl_platforms" in
        *drm*)
            enable_gbm=yes ;;
         *)
            enable_gbm=no ;;
    esac
fi
if test "x$enable_gbm" = xyes; then
1149
    if test x"$have_libudev" != xyes; then
1150
        AC_MSG_ERROR([gbm requires udev >= $LIBUDEV_REQUIRED])
1151
    fi
1152 1153 1154

    if test "x$enable_dri" = xyes; then
        GBM_BACKEND_DIRS="$GBM_BACKEND_DIRS dri"
1155
        if test "x$enable_shared_glapi" = xno; then
1156 1157 1158
            AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
        fi
    fi
1159
fi
Matt Turner's avatar
Matt Turner committed
1160
AM_CONDITIONAL(HAVE_GBM, test "x$enable_gbm" = xyes)
1161
GBM_PC_REQ_PRIV="libudev >= $LIBUDEV_REQUIRED"
1162 1163 1164 1165
GBM_PC_LIB_PRIV="$DLOPEN_LIBS"
AC_SUBST([GBM_PC_REQ_PRIV])
AC_SUBST([GBM_PC_LIB_PRIV])

1166 1167 1168
dnl
dnl EGL configuration
dnl
1169 1170
EGL_CLIENT_APIS=""

1171
if test "x$enable_egl" = xyes; then
1172
    EGL_LIB_DEPS="$DLOPEN_LIBS $SELINUX_LIBS $PTHREAD_LIBS"
1173

1174 1175
    AC_CHECK_FUNC(mincore, [DEFINES="$DEFINES -DHAVE_MINCORE"])

1176
    if test "$enable_static" != yes; then
1177
        if test "x$enable_dri" = xyes; then
1178
	    HAVE_EGL_DRIVER_DRI2=1
1179
	fi
1180

1181
    fi
1182
fi
Matt Turner's avatar
Matt Turner committed
1183
AM_CONDITIONAL(HAVE_EGL, test "x$enable_egl" = xyes)
1184 1185
AC_SUBST([EGL_LIB_DEPS])

1186 1187 1188 1189
dnl
dnl EGL Gallium configuration
dnl
if test "x$enable_gallium_egl" = xyes; then
1190
    if test -z "$with_gallium_drivers"; then
1191 1192 1193 1194 1195
        AC_MSG_ERROR([cannot enable egl_gallium without Gallium])
    fi
    if test "x$enable_egl" = xno; then
        AC_MSG_ERROR([cannot enable egl_gallium without EGL])
    fi
Chia-I Wu's avatar
Chia-I Wu committed
1196 1197 1198
    if test "x$have_libdrm" != xyes; then
        AC_MSG_ERROR([egl_gallium requires libdrm >= $LIBDRM_REQUIRED])
    fi
1199 1200

    GALLIUM_STATE_TRACKERS_DIRS="egl $GALLIUM_STATE_TRACKERS_DIRS"
1201
    GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-static"
1202
fi
1203
AM_CONDITIONAL(HAVE_GALLIUM_EGL, test "x$enable_gallium_egl" = xyes)
1204

1205 1206 1207
dnl
dnl gbm Gallium configuration
dnl
1208
if test "x$enable_gallium_gbm" = xauto; then
1209
    case "$enable_gbm$enable_gallium_egl$enable_dri$with_egl_platforms" in
1210
        yesyesyes*drm*)
1211 1212 1213 1214 1215
            enable_gallium_gbm=yes ;;
         *)
            enable_gallium_gbm=no ;;
    esac
fi
1216
if test "x$enable_gallium_gbm" = xyes; then
1217
    if test -z "$with_gallium_drivers"; then
1218 1219 1220 1221 1222
        AC_MSG_ERROR([cannot enable gbm_gallium without Gallium])
    fi
    if test "x$enable_gbm" = xno; then
        AC_MSG_ERROR([cannot enable gbm_gallium without gbm])
    fi
1223 1224 1225 1226
    # gbm_gallium abuses DRI_LIB_DEPS to link.  Make sure it is set.
    if test "x$enable_dri" = xno; then
        AC_MSG_ERROR([gbm_gallium requires --enable-dri to build])
    fi
1227 1228 1229

    GALLIUM_STATE_TRACKERS_DIRS="gbm $GALLIUM_STATE_TRACKERS_DIRS"
    GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS gbm"
1230
    enable_gallium_loader=yes
1231
fi
1232
AM_CONDITIONAL(HAVE_GALLIUM_GBM, test "x$enable_gallium_gbm" = xyes)
1233

1234 1235 1236 1237
dnl
dnl XA configuration
dnl
if test "x$enable_xa" = xyes; then
1238 1239 1240 1241 1242 1243 1244 1245
    if test "x$with_gallium_drivers" = xswrast; then
       AC_MSG_ERROR([
          Building xa requires at least one non swrast gallium driver.
          If you are looking to use libxatracker.so with vmware's virtual gpu,
          make sure to include svga in the gallium drivers list, apart from
          enabling XA.
          Example: ./configure --enable-xa --with-gallium-drivers=svga...])
    fi
1246
    GALLIUM_STATE_TRACKERS_DIRS="xa $GALLIUM_STATE_TRACKERS_DIRS"
1247
    enable_gallium_loader=yes
1248
fi
1249
AM_CONDITIONAL(HAVE_ST_XA, test "x$enable_xa" = xyes)
1250

1251 1252 1253 1254 1255 1256 1257 1258 1259
dnl
dnl OpenVG configuration
dnl
VG_LIB_DEPS=""

if test "x$enable_openvg" = xyes; then
    if test "x$enable_egl" = xno; then
        AC_MSG_ERROR([cannot enable OpenVG without EGL])
    fi
1260
    if test -z "$with_gallium_drivers"; then
1261 1262
        AC_MSG_ERROR([cannot enable OpenVG without Gallium])
    fi
1263 1264 1265
    if test "x$enable_gallium_egl" = xno; then
        AC_MSG_ERROR([cannot enable OpenVG without egl_gallium])
    fi
1266 1267

    EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
1268
    VG_LIB_DEPS="$VG_LIB_DEPS $SELINUX_LIBS $PTHREAD_LIBS"
1269
    GALLIUM_STATE_TRACKERS_DIRS="vega $GALLIUM_STATE_TRACKERS_DIRS"
1270
    VG_PC_LIB_PRIV="-lm $CLOCK_LIB $PTHREAD_LIBS $DLOPEN_LIBS"
Matt Turner's avatar
Matt Turner committed
1271
    AC_SUBST([VG_PC_LIB_PRIV])
1272
fi
1273
AM_CONDITIONAL(HAVE_OPENVG, test "x$enable_openvg" = xyes)
1274

1275 1276 1277
dnl
dnl Gallium G3DVL configuration
dnl
1278
if test -n "$with_gallium_drivers"; then
1279
    if test "x$enable_xvmc" = xauto; then
1280
	PKG_CHECK_EXISTS([xvmc], [enable_xvmc=yes], [enable_xvmc=no])
1281 1282 1283
    fi

    if test "x$enable_vdpau" = xauto; then
1284
	PKG_CHECK_EXISTS([vdpau], [enable_vdpau=yes], [enable_vdpau=no])
1285
    fi
1286 1287 1288 1289

    if test "x$enable_omx" = xauto; then
	PKG_CHECK_EXISTS([libomxil-bellagio], [enable_omx=yes], [enable_omx=no])
    fi
1290 1291 1292
fi

if test "x$enable_xvmc" = xyes; then
1293
    PKG_CHECK_MODULES([XVMC], [xvmc >= $XVMC_REQUIRED x11-xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
1294
    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xvmc"
1295
fi
1296
AM_CONDITIONAL(HAVE_ST_XVMC, test "x$enable_xvmc" = xyes)
1297 1298

if test "x$enable_vdpau" = xyes; then
1299
    PKG_CHECK_MODULES([VDPAU], [vdpau >= $VDPAU_REQUIRED x11-xcb xcb-dri2 >= $XCBDRI2_REQUIRED],
1300
                      [VDPAU_LIBS="`$PKG_CONFIG --libs x11-xcb xcb-dri2`"])
1301 1302
    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vdpau"
fi
1303
AM_CONDITIONAL(HAVE_ST_VDPAU, test "x$enable_vdpau" = xyes)
1304

1305
if test "x$enable_omx" = xyes; then
1306
    PKG_CHECK_MODULES([OMX], [libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED x11-xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
1307 1308 1309 1310
    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS omx"
fi
AM_CONDITIONAL(HAVE_ST_OMX, test "x$enable_omx" = xyes)

1311 1312 1313 1314
dnl
dnl OpenCL configuration
dnl

1315 1316
AC_ARG_WITH([libclc-path],
   [AS_HELP_STRING([--with-libclc-path],
1317
         [DEPRECATED: See http://dri.freedesktop.org/wiki/GalliumCompute#How_to_Install])],
1318
   [LIBCLC_PATH="$withval"],
1319
   [LIBCLC_PATH=''])
1320

1321
if test -n "$LIBCLC_PATH"; then
1322 1323 1324 1325 1326 1327
   AC_MSG_ERROR([The --with-libclc-path option has been deprecated.
                  Please review the updated build instructions for clover:
		  http://dri.freedesktop.org/wiki/GalliumCompute])
fi


1328 1329 1330 1331
AC_ARG_WITH([clang-libdir],
   [AS_HELP_STRING([--with-clang-libdir],
         [Path to Clang libraries @<:@default=llvm-config --libdir@:>@])],
   [CLANG_LIBDIR="$withval"],
1332
   [CLANG_LIBDIR=''])
1333

1334
PKG_CHECK_EXISTS([libclc], [have_libclc=yes], [have_libclc=no])
1335

1336
if test "x$enable_opencl" = xyes; then
1337
    if test -z "$with_gallium_drivers"; then
1338 1339
        AC_MSG_ERROR([cannot enable OpenCL without Gallium])
    fi
1340

1341 1342
    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 7; then
        AC_MSG_ERROR([gcc >= 4.7 is required to build clover])
1343 1344
    fi