nouveau/vieux: switch to libdrm_nouveau-2.0
[profile/ivi/mesa.git] / configure.ac
1 dnl Process this file with autoconf to create configure.
2
3 AC_PREREQ([2.60])
4
5 dnl Versioning - scrape the version from configs/default
6 m4_define([mesa_version],
7     [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n' | tr -d '\r'])])
8 m4_ifval(mesa_version,,
9     [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])])
10
11 dnl Tell the user about autoconf.html in the --help output
12 m4_divert_once([HELP_END], [
13 See docs/autoconf.html for more details on the options for Mesa.])
14
15 AC_INIT([Mesa],[mesa_version],
16     [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
17 AC_CONFIG_AUX_DIR([bin])
18 AC_CANONICAL_HOST
19 AM_INIT_AUTOMAKE([foreign])
20
21 dnl http://people.gnome.org/~walters/docs/build-api.txt
22 dnl We don't support srcdir != builddir.
23 echo \#buildapi-variable-no-builddir >/dev/null
24
25 # Support silent build rules, requires at least automake-1.11. Disable
26 # by either passing --disable-silent-rules to configure or passing V=1
27 # to make
28 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
29
30 LT_PREREQ([2.2])
31 LT_INIT([disable-static])
32
33 dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
34 USER_CFLAGS="$CFLAGS"
35 USER_CXXFLAGS="$CXXFLAGS"
36
37 dnl Versions for external dependencies
38 LIBDRM_REQUIRED=2.4.24
39 LIBDRM_RADEON_REQUIRED=2.4.31
40 LIBDRM_INTEL_REQUIRED=2.4.32
41 LIBDRM_NVVIEUX_REQUIRED=2.4.33
42 LIBDRM_NOUVEAU_REQUIRED=0.6
43 DRI2PROTO_REQUIRED=2.6
44 GLPROTO_REQUIRED=1.4.14
45 LIBDRM_XORG_REQUIRED=2.4.24
46 LIBKMS_XORG_REQUIRED=1.0.0
47
48 dnl Check for progs
49 AC_PROG_CPP
50 AC_PROG_CC
51 AC_PROG_CXX
52 AC_CHECK_PROGS([MAKE], [gmake make])
53 AC_CHECK_PROGS([PYTHON2], [python2 python])
54 AC_PROG_SED
55 AC_PROG_MKDIR_P
56 AC_PATH_PROG([MKDEP], [makedepend])
57
58 if test "x$MKDEP" = "x"; then
59     AC_MSG_ERROR([makedepend is required to build Mesa])
60 fi
61
62 AC_PROG_YACC
63 AC_PATH_PROG([YACC_INST], $YACC)
64 if test ! -f "$srcdir/src/glsl/glcpp/glcpp-parse.y"; then
65     if test -z "$YACC_INST"; then
66         AC_MSG_ERROR([yacc not found - unable to compile glcpp-parse.y])
67     fi
68 fi
69 AC_PROG_LEX
70
71 AC_PATH_PROG([PERL], [perl])
72
73 dnl Our fallback install-sh is a symlink to minstall. Use the existing
74 dnl configuration in that case.
75 AC_PROG_INSTALL
76 test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)'
77
78 dnl We need a POSIX shell for parts of the build. Assume we have one
79 dnl in most cases.
80 case "$host_os" in
81 solaris*)
82     # Solaris /bin/sh is too old/non-POSIX compliant
83     AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
84     SHELL="$POSIX_SHELL"
85     ;;
86 esac
87
88 dnl clang is mostly GCC-compatible, but its version is much lower,
89 dnl so we have to check for it.
90 AC_MSG_CHECKING([if compiling with clang])
91
92 AC_COMPILE_IFELSE(
93 [AC_LANG_PROGRAM([], [[
94 #ifndef __clang__
95        not clang
96 #endif
97 ]])],
98 [acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
99
100 AC_MSG_RESULT([$acv_mesa_CLANG])
101
102 dnl If we're using GCC, make sure that it is at least version 3.3.0.  Older
103 dnl versions are explictly not supported.
104 if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
105     AC_MSG_CHECKING([whether gcc version is sufficient])
106     major=0
107     minor=0
108
109     GCC_VERSION=`$CC -dumpversion`
110     if test $? -eq 0; then
111         major=`echo $GCC_VERSION | cut -d. -f1`
112         minor=`echo $GCC_VERSION | cut -d. -f2`
113     fi
114
115     if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then
116         AC_MSG_RESULT([no])
117         AC_MSG_ERROR([If using GCC, version 3.3.0 or later is required.])
118     else
119         AC_MSG_RESULT([yes])
120     fi
121 fi
122
123
124 MKDEP_OPTIONS=-fdepend
125 dnl Ask gcc where it's keeping its secret headers
126 if test "x$GCC" = xyes; then
127     for dir in include include-fixed; do
128         GCC_INCLUDES=`$CC -print-file-name=$dir`
129         if test "x$GCC_INCLUDES" != x && \
130            test "$GCC_INCLUDES" != "$dir" && \
131            test -d "$GCC_INCLUDES"; then
132             MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
133         fi
134     done
135 fi
136 AC_SUBST([MKDEP_OPTIONS])
137
138 dnl Make sure the pkg-config macros are defined
139 m4_ifndef([PKG_PROG_PKG_CONFIG],
140     [m4_fatal([Could not locate the pkg-config autoconf macros.
141   These are usually located in /usr/share/aclocal/pkg.m4. If your macros
142   are in a different location, try setting the environment variable
143   ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
144 PKG_PROG_PKG_CONFIG()
145
146 dnl LIB_DIR - library basename
147 LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
148 AC_SUBST([LIB_DIR])
149
150 dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
151 _SAVE_LDFLAGS="$LDFLAGS"
152 AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
153 AC_SUBST([EXTRA_LIB_PATH])
154
155 dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
156 _SAVE_CPPFLAGS="$CPPFLAGS"
157 AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
158 AC_SUBST([X11_INCLUDES])
159
160 dnl Compiler macros
161 DEFINES=""
162 AC_SUBST([DEFINES])
163 case "$host_os" in
164 linux*|*-gnu*|gnu*)
165     DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
166     ;;
167 solaris*)
168     DEFINES="$DEFINES -DPTHREADS -DSVR4"
169     ;;
170 cygwin*)
171     DEFINES="$DEFINES -DPTHREADS"
172     ;;
173 esac
174
175 dnl Add flags for gcc and g++
176 if test "x$GCC" = xyes; then
177     CFLAGS="$CFLAGS -Wall -std=c99"
178
179     # Enable -Werror=implicit-function-declaration and
180     # -Werror=missing-prototypes, if available, or otherwise, just
181     # -Wmissing-prototypes.  This is particularly useful to avoid
182     # generating a loadable driver module that has undefined symbols.
183     save_CFLAGS="$CFLAGS"
184     AC_MSG_CHECKING([whether $CC supports -Werror=missing-prototypes])
185     CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
186     CFLAGS="$CFLAGS -Werror=missing-prototypes"
187     AC_LINK_IFELSE([AC_LANG_PROGRAM()],
188                    AC_MSG_RESULT([yes]),
189                    [CFLAGS="$save_CFLAGS -Wmissing-prototypes";
190                     AC_MSG_RESULT([no])]);
191
192     # Enable -fvisibility=hidden if using a gcc that supports it
193     save_CFLAGS="$CFLAGS"
194     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
195     VISIBILITY_CFLAGS="-fvisibility=hidden"
196     CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
197     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
198                    [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
199
200     # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
201     CFLAGS=$save_CFLAGS
202
203     # Work around aliasing bugs - developers should comment this out
204     CFLAGS="$CFLAGS -fno-strict-aliasing"
205
206     # gcc's builtin memcmp is slower than glibc's
207     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
208     CFLAGS="$CFLAGS -fno-builtin-memcmp"
209 fi
210 if test "x$GXX" = xyes; then
211     CXXFLAGS="$CXXFLAGS -Wall"
212
213     # Enable -fvisibility=hidden if using a gcc that supports it
214     save_CXXFLAGS="$CXXFLAGS"
215     AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
216     VISIBILITY_CXXFLAGS="-fvisibility=hidden"
217     CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
218     AC_LANG_PUSH([C++])
219     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
220                    [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
221     AC_LANG_POP([C++])
222
223     # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
224     CXXFLAGS=$save_CXXFLAGS
225
226     # Work around aliasing bugs - developers should comment this out
227     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
228
229     # gcc's builtin memcmp is slower than glibc's
230     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
231     CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp"
232 fi
233
234 dnl even if the compiler appears to support it, using visibility attributes isn't
235 dnl going to do anything useful currently on cygwin apart from emit lots of warnings
236 case "$host_os" in
237 cygwin*)
238     VISIBILITY_CFLAGS=""
239     VISIBILITY_CXXFLAGS=""
240     ;;
241 esac
242
243 AC_SUBST([VISIBILITY_CFLAGS])
244 AC_SUBST([VISIBILITY_CXXFLAGS])
245
246 dnl These should be unnecessary, but let the user set them if they want
247 AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
248     Default is to use CFLAGS.])
249 AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
250     compiler. Default is to use CFLAGS.])
251 AC_SUBST([OPT_FLAGS])
252 AC_SUBST([ARCH_FLAGS])
253
254 dnl
255 dnl Hacks to enable 32 or 64 bit build
256 dnl
257 AC_ARG_ENABLE([32-bit],
258     [AS_HELP_STRING([--enable-32-bit],
259         [build 32-bit libraries @<:@default=auto@:>@])],
260     [enable_32bit="$enableval"],
261     [enable_32bit=auto]
262 )
263 if test "x$enable_32bit" = xyes; then
264     if test "x$GCC" = xyes; then
265         CFLAGS="$CFLAGS -m32"
266         ARCH_FLAGS="$ARCH_FLAGS -m32"
267     fi
268     if test "x$GXX" = xyes; then
269         CXXFLAGS="$CXXFLAGS -m32"
270     fi
271 fi
272 AC_ARG_ENABLE([64-bit],
273     [AS_HELP_STRING([--enable-64-bit],
274         [build 64-bit libraries @<:@default=auto@:>@])],
275     [enable_64bit="$enableval"],
276     [enable_64bit=auto]
277 )
278 if test "x$enable_64bit" = xyes; then
279     if test "x$GCC" = xyes; then
280         CFLAGS="$CFLAGS -m64"
281     fi
282     if test "x$GXX" = xyes; then
283         CXXFLAGS="$CXXFLAGS -m64"
284     fi
285 fi
286
287 dnl Can't have static and shared libraries, default to static if user
288 dnl explicitly requested. If both disabled, set to static since shared
289 dnl was explicitly requested.
290 case "x$enable_static$enable_shared" in
291 xyesyes )
292     AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
293     enable_shared=no
294     ;;
295 xnono )
296     AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
297     enable_static=yes
298     ;;
299 esac
300
301 dnl
302 dnl mklib options
303 dnl
304 AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
305 if test "$enable_static" = yes; then
306     MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
307 fi
308 AC_SUBST([MKLIB_OPTIONS])
309
310 dnl
311 dnl other compiler options
312 dnl
313 AC_ARG_ENABLE([debug],
314     [AS_HELP_STRING([--enable-debug],
315         [use debug compiler flags and macros @<:@default=disabled@:>@])],
316     [enable_debug="$enableval"],
317     [enable_debug=no]
318 )
319 if test "x$enable_debug" = xyes; then
320     DEFINES="$DEFINES -DDEBUG"
321     if test "x$GCC" = xyes; then
322         CFLAGS="$CFLAGS -g"
323     fi
324     if test "x$GXX" = xyes; then
325         CXXFLAGS="$CXXFLAGS -g"
326     fi
327 fi
328
329 dnl
330 dnl library names
331 dnl
332 LIB_PREFIX_GLOB='lib'
333 LIB_VERSION_SEPARATOR='.'
334 if test "$enable_static" = yes; then
335     LIB_EXTENSION='a'
336 else
337     case "$host_os" in
338     darwin* )
339         LIB_EXTENSION='dylib' ;;
340     cygwin* )
341         dnl prefix can be 'cyg' or 'lib'
342         LIB_PREFIX_GLOB='???'
343         LIB_VERSION_SEPARATOR='-'
344         LIB_EXTENSION='dll' ;;
345     aix* )
346         LIB_EXTENSION='a' ;;
347     * )
348         LIB_EXTENSION='so' ;;
349     esac
350 fi
351
352 dnl
353 dnl Mangled Mesa support
354 dnl
355 AC_ARG_ENABLE([mangling],
356   [AS_HELP_STRING([--enable-mangling],
357     [enable mangled symbols and library name @<:@default=disabled@:>@])],
358   [enable_mangling="${enableval}"],
359   [enable_mangling=no]
360 )
361 GL_LIB="GL"
362 GLU_LIB="GLU"
363 OSMESA_LIB="OSMesa"
364 if test "x${enable_mangling}" = "xyes" ; then
365   DEFINES="${DEFINES} -DUSE_MGL_NAMESPACE"
366   GL_LIB="MangledGL"
367   GLU_LIB="MangledGLU"
368   OSMESA_LIB="MangledOSMesa"
369 fi
370 AC_SUBST([GL_LIB])
371 AC_SUBST([GLU_LIB])
372 AC_SUBST([OSMESA_LIB])
373 AM_CONDITIONAL(HAVE_MANGLED_GL, test $GL_LIB = MangledGL)
374
375 dnl
376 dnl potentially-infringing-but-nobody-knows-for-sure stuff
377 dnl
378 AC_ARG_ENABLE([texture-float],
379     [AS_HELP_STRING([--enable-texture-float],
380         [enable floating-point textures and renderbuffers @<:@default=disabled@:>@])],
381     [enable_texture_float="$enableval"],
382     [enable_texture_float=no]
383 )
384 if test "x$enable_texture_float" = xyes; then
385     AC_MSG_WARN([Floating-point textures enabled.])
386     AC_MSG_WARN([Please consult docs/patents.txt with your lawyer before building Mesa.])
387     DEFINES="$DEFINES -DTEXTURE_FLOAT_ENABLED"
388 fi
389
390 GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
391 GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
392 OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
393 EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
394 GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION}
395 GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION}
396 VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION}
397 GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION}
398
399 GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
400 GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
401 OSMESA_LIB_GLOB=${LIB_PREFIX_GLOB}'$(OSMESA_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
402 EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
403 EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
404 GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
405 GLESv2_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv2_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
406 VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
407 GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
408
409 AC_SUBST([GL_LIB_NAME])
410 AC_SUBST([GLU_LIB_NAME])
411 AC_SUBST([OSMESA_LIB_NAME])
412 AC_SUBST([EGL_LIB_NAME])
413 AC_SUBST([GLESv1_CM_LIB_NAME])
414 AC_SUBST([GLESv2_LIB_NAME])
415 AC_SUBST([VG_LIB_NAME])
416 AC_SUBST([GLAPI_LIB_NAME])
417
418 AC_SUBST([GL_LIB_GLOB])
419 AC_SUBST([GLU_LIB_GLOB])
420 AC_SUBST([OSMESA_LIB_GLOB])
421 AC_SUBST([EGL_LIB_GLOB])
422 AC_SUBST([GLESv1_CM_LIB_GLOB])
423 AC_SUBST([GLESv2_LIB_GLOB])
424 AC_SUBST([VG_LIB_GLOB])
425 AC_SUBST([GLAPI_LIB_GLOB])
426
427 dnl
428 dnl Arch/platform-specific settings
429 dnl
430 AC_ARG_ENABLE([asm],
431     [AS_HELP_STRING([--disable-asm],
432         [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
433     [enable_asm="$enableval"],
434     [enable_asm=yes]
435 )
436 asm_arch=""
437 ASM_FLAGS=""
438 MESA_ASM_SOURCES=""
439 GLAPI_ASM_SOURCES=""
440 AC_MSG_CHECKING([whether to enable assembly])
441 test "x$enable_asm" = xno && AC_MSG_RESULT([no])
442 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
443 if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
444     case "$host_cpu" in
445     i?86 | x86_64)
446         enable_asm=no
447         AC_MSG_RESULT([no, cross compiling])
448         ;;
449     esac
450 fi
451 # check for supported arches
452 if test "x$enable_asm" = xyes; then
453     case "$host_cpu" in
454     i?86)
455         case "$host_os" in
456         linux* | *freebsd* | dragonfly* | *netbsd*)
457             test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
458             ;;
459         esac
460         ;;
461     x86_64)
462         case "$host_os" in
463         linux* | *freebsd* | dragonfly* | *netbsd*)
464             test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
465             ;;
466         esac
467         ;;
468     powerpc)
469         case "$host_os" in
470         linux*)
471             asm_arch=ppc
472             ;;
473         esac
474         ;;
475     sparc*)
476         case "$host_os" in
477         linux*)
478             asm_arch=sparc
479             ;;
480         esac
481         ;;
482     esac
483
484     case "$asm_arch" in
485     x86)
486         ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
487         MESA_ASM_SOURCES='$(X86_SOURCES)'
488         GLAPI_ASM_SOURCES='$(X86_API)'
489         AC_MSG_RESULT([yes, x86])
490         ;;
491     x86_64)
492         ASM_FLAGS="-DUSE_X86_64_ASM"
493         MESA_ASM_SOURCES='$(X86-64_SOURCES)'
494         GLAPI_ASM_SOURCES='$(X86-64_API)'
495         AC_MSG_RESULT([yes, x86_64])
496         ;;
497     sparc)
498         ASM_FLAGS="-DUSE_SPARC_ASM"
499         MESA_ASM_SOURCES='$(SPARC_SOURCES)'
500         GLAPI_ASM_SOURCES='$(SPARC_API)'
501         AC_MSG_RESULT([yes, sparc])
502         ;;
503     *)
504         AC_MSG_RESULT([no, platform not supported])
505         ;;
506     esac
507 fi
508 AC_SUBST([ASM_FLAGS])
509 AC_SUBST([MESA_ASM_SOURCES])
510 AC_SUBST([GLAPI_ASM_SOURCES])
511
512 dnl PIC code macro
513 MESA_PIC_FLAGS
514
515 dnl Check to see if dlopen is in default libraries (like Solaris, which
516 dnl has it in libc), or if libdl is needed to get it.
517 AC_CHECK_FUNC([dlopen], [],
518     [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
519 AC_SUBST([DLOPEN_LIBS])
520
521 dnl See if posix_memalign is available
522 AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
523
524 dnl SELinux awareness.
525 AC_ARG_ENABLE([selinux],
526     [AS_HELP_STRING([--enable-selinux],
527         [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
528     [MESA_SELINUX="$enableval"],
529     [MESA_SELINUX=no])
530 if test "x$enable_selinux" = "xyes"; then
531     AC_CHECK_HEADER([selinux/selinux.h],[],
532                     [AC_MSG_ERROR([SELinux headers not found])])
533     AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
534                  [AC_MSG_ERROR([SELinux library not found])])
535     SELINUX_LIBS="-lselinux"
536     DEFINES="$DEFINES -DMESA_SELINUX"
537 fi
538
539 dnl Options for APIs
540 AC_ARG_ENABLE([opengl],
541     [AS_HELP_STRING([--disable-opengl],
542         [disable support for standard OpenGL API @<:@default=no@:>@])],
543     [enable_opengl="$enableval"],
544     [enable_opengl=yes])
545 AC_ARG_ENABLE([gles1],
546     [AS_HELP_STRING([--enable-gles1],
547         [enable support for OpenGL ES 1.x API @<:@default=no@:>@])],
548     [enable_gles1="$enableval"],
549     [enable_gles1=no])
550 AC_ARG_ENABLE([gles2],
551     [AS_HELP_STRING([--enable-gles2],
552         [enable support for OpenGL ES 2.x API @<:@default=no@:>@])],
553     [enable_gles2="$enableval"],
554     [enable_gles2=no])
555 AC_ARG_ENABLE([openvg],
556     [AS_HELP_STRING([--enable-openvg],
557         [enable support for OpenVG API @<:@default=no@:>@])],
558     [enable_openvg="$enableval"],
559     [enable_openvg=no])
560
561 AC_ARG_ENABLE([dri],
562     [AS_HELP_STRING([--enable-dri],
563         [enable DRI modules @<:@default=auto@:>@])],
564     [enable_dri="$enableval"],
565     [enable_dri=auto])
566 AC_ARG_ENABLE([glx],
567     [AS_HELP_STRING([--enable-glx],
568         [enable GLX library @<:@default=auto@:>@])],
569     [enable_glx="$enableval"],
570     [enable_glx=auto])
571 AC_ARG_ENABLE([osmesa],
572     [AS_HELP_STRING([--enable-osmesa],
573         [enable OSMesa library @<:@default=auto@:>@])],
574     [enable_osmesa="$enableval"],
575     [enable_osmesa=auto])
576 AC_ARG_ENABLE([egl],
577     [AS_HELP_STRING([--disable-egl],
578         [disable EGL library @<:@default=enabled@:>@])],
579     [enable_egl="$enableval"],
580     [enable_egl=yes])
581
582 AC_ARG_ENABLE([xorg],
583     [AS_HELP_STRING([--enable-xorg],
584         [enable support for X.Org DDX API @<:@default=no@:>@])],
585     [enable_xorg="$enableval"],
586     [enable_xorg=no])
587 AC_ARG_ENABLE([xa],
588     [AS_HELP_STRING([--enable-xa],
589         [enable build of the XA X Acceleration API @<:@default=no@:>@])],
590     [enable_xa="$enableval"],
591     [enable_xa=no])
592 AC_ARG_ENABLE([d3d1x],
593     [AS_HELP_STRING([--enable-d3d1x],
594         [enable support for Direct3D 10 & 11 low-level API @<:@default=no@:>@])],
595     [enable_d3d1x="$enableval"],
596     [enable_d3d1x=no])
597 AC_ARG_ENABLE([gbm],
598    [AS_HELP_STRING([--enable-gbm],
599          [enable gbm library @<:@default=auto@:>@])],
600    [enable_gbm="$enableval"],
601    [enable_gbm=auto])
602
603 AC_ARG_ENABLE([xvmc],
604    [AS_HELP_STRING([--enable-xvmc],
605          [enable xvmc library @<:@default=auto@:>@])],
606    [enable_xvmc="$enableval"],
607    [enable_xvmc=auto])
608 AC_ARG_ENABLE([vdpau],
609    [AS_HELP_STRING([--enable-vdpau],
610          [enable vdpau library @<:@default=auto@:>@])],
611    [enable_vdpau="$enableval"],
612    [enable_vdpau=auto])
613 AC_ARG_ENABLE([va],
614    [AS_HELP_STRING([--enable-va],
615          [enable va library @<:@default=auto@:>@])],
616    [enable_va="$enableval"],
617    [enable_va=auto])
618
619 AC_ARG_ENABLE([xlib_glx],
620     [AS_HELP_STRING([--enable-xlib-glx],
621         [make GLX library Xlib-based instead of DRI-based @<:@default=disable@:>@])],
622     [enable_xlib_glx="$enableval"],
623     [enable_xlib_glx=auto])
624 AC_ARG_ENABLE([gallium_egl],
625     [AS_HELP_STRING([--enable-gallium-egl],
626         [enable optional EGL state tracker (not required
627          for EGL support in Gallium with OpenGL and OpenGL ES)
628          @<:@default=disable@:>@])],
629     [enable_gallium_egl="$enableval"],
630     [enable_gallium_egl=no])
631 AC_ARG_ENABLE([gallium_gbm],
632     [AS_HELP_STRING([--enable-gallium-gbm],
633         [enable optional gbm state tracker (not required for
634          gbm support in Gallium)
635          @<:@default=auto@:>@])],
636     [enable_gallium_gbm="$enableval"],
637     [enable_gallium_gbm=auto])
638
639 # Option for Gallium drivers
640 GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
641
642 AC_ARG_WITH([gallium-drivers],
643     [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
644         [comma delimited Gallium drivers list, e.g.
645         "i915,nouveau,r300,r600,svga,swrast"
646         @<:@default=r300,r600,swrast@:>@])],
647     [with_gallium_drivers="$withval"],
648     [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
649
650 # Doing '--without-gallium-drivers' will set this variable to 'no'.  Clear it
651 # here so that the script doesn't choke on an unknown driver name later.
652 case "$with_gallium_drivers" in
653     yes) with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT" ;;
654     no) with_gallium_drivers='' ;;
655 esac
656
657 if test "x$enable_opengl" = xno -a \
658         "x$enable_gles1" = xno -a \
659         "x$enable_gles2" = xno -a \
660         "x$enable_openvg" = xno -a \
661         "x$enable_xorg" = xno -a \
662         "x$enable_xa" = xno -a \
663         "x$enable_d3d1x" = xno -a \
664         "x$enable_xvmc" = xno -a \
665         "x$enable_vdpau" = xno -a \
666         "x$enable_va" = xno; then
667     AC_MSG_ERROR([at least one API should be enabled])
668 fi
669
670 API_DEFINES=""
671 if test "x$enable_opengl" = xno; then
672     API_DEFINES="$API_DEFINES -DFEATURE_GL=0"
673 else
674     API_DEFINES="$API_DEFINES -DFEATURE_GL=1"
675 fi
676 if test "x$enable_gles1" = xyes; then
677     API_DEFINES="$API_DEFINES -DFEATURE_ES1=1"
678 fi
679 if test "x$enable_gles2" = xyes; then
680     API_DEFINES="$API_DEFINES -DFEATURE_ES2=1"
681 fi
682 AC_SUBST([API_DEFINES])
683
684 AC_ARG_ENABLE([shared-glapi],
685     [AS_HELP_STRING([--enable-shared-glapi],
686         [EXPERIMENTAL.  Enable shared glapi for OpenGL @<:@default=no@:>@])],
687     [enable_shared_glapi="$enableval"],
688     [enable_shared_glapi=no])
689
690 SHARED_GLAPI="0"
691 if test "x$enable_shared_glapi" = xyes; then
692     SHARED_GLAPI="1"
693     # libGL will use libglapi for function lookups (IN_DRI_DRIVER means to use
694     # the remap table)
695     DEFINES="$DEFINES -DIN_DRI_DRIVER"
696     SRC_DIRS="$SRC_DIRS mapi/shared-glapi"
697 fi
698 AC_SUBST([SHARED_GLAPI])
699 AM_CONDITIONAL(HAVE_SHARED_GLAPI, test $SHARED_GLAPI = 1)
700
701 dnl
702 dnl Driver configuration. Options are xlib, dri and osmesa right now.
703 dnl More later: fbdev, ...
704 dnl
705 default_driver="xlib"
706
707 case "$host_os" in
708 linux*)
709     case "$host_cpu" in
710     i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
711     esac
712     ;;
713 *freebsd* | dragonfly* | *netbsd*)
714     case "$host_cpu" in
715     i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
716     esac
717     ;;
718 esac
719
720 if test "x$enable_opengl" = xno; then
721     default_driver="no"
722 fi
723
724 AC_ARG_WITH([driver],
725     [AS_HELP_STRING([--with-driver=DRIVER], [DEPRECATED])],
726     [mesa_driver="$withval"],
727     [mesa_driver=auto])
728 dnl Check for valid option
729 case "x$mesa_driver" in
730 xxlib|xdri|xosmesa|xno)
731     if test "x$enable_dri" != xauto -o \
732             "x$enable_glx" != xauto -o \
733             "x$enable_osmesa" != xauto -o \
734             "x$enable_xlib_glx" != xauto; then
735         AC_MSG_ERROR([--with-driver=$mesa_driver is deprecated])
736     fi
737     ;;
738 xauto)
739     mesa_driver="$default_driver"
740     ;;
741 *)
742     AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
743     ;;
744 esac
745
746 # map $mesa_driver to APIs
747 if test "x$enable_dri" = xauto; then
748     case "x$mesa_driver" in
749     xdri) enable_dri=yes ;;
750     *)    enable_dri=no ;;
751     esac
752 fi
753
754 if test "x$enable_glx" = xauto; then
755     case "x$mesa_driver" in
756     xdri|xxlib) enable_glx=yes ;;
757     *)          enable_glx=no ;;
758     esac
759 fi
760
761 if test "x$enable_osmesa" = xauto; then
762     case "x$mesa_driver" in
763     xxlib|xosmesa) enable_osmesa=yes ;;
764     *)             enable_osmesa=no ;;
765     esac
766 fi
767
768 if test "x$enable_xlib_glx" = xauto; then
769     case "x$mesa_driver" in
770     xxlib) enable_xlib_glx=yes ;;
771     *)     enable_xlib_glx=no ;;
772     esac
773 fi
774
775 if test "x$enable_glx" = xno; then
776     enable_xlib_glx=no
777 fi
778
779 AM_CONDITIONAL(HAVE_DRI, test x"$enable_dri" = xyes)
780
781 dnl
782 dnl Driver specific build directories
783 dnl
784
785 dnl this variable will be prepended to SRC_DIRS and is not exported
786 CORE_DIRS=""
787
788 SRC_DIRS="gtest"
789 GLU_DIRS="sgi"
790 GALLIUM_DIRS="auxiliary drivers state_trackers"
791 GALLIUM_TARGET_DIRS=""
792 GALLIUM_WINSYS_DIRS="sw"
793 GALLIUM_DRIVERS_DIRS="galahad trace rbug noop identity"
794 GALLIUM_STATE_TRACKERS_DIRS=""
795
796 # build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled
797 case "x$enable_shared_glapi$enable_gles1$enable_gles2" in
798 x*yes*)
799     CORE_DIRS="$CORE_DIRS mapi/shared-glapi"
800     ;;
801 esac
802
803 # build glapi if OpenGL is enabled
804 if test "x$enable_opengl" = xyes; then
805     CORE_DIRS="$CORE_DIRS mapi/glapi"
806 fi
807
808 # build es1api if OpenGL ES 1.x is enabled
809 if test "x$enable_gles1" = xyes; then
810     CORE_DIRS="$CORE_DIRS mapi/es1api"
811 fi
812
813 # build es2api if OpenGL ES 2.x is enabled
814 if test "x$enable_gles2" = xyes; then
815     CORE_DIRS="$CORE_DIRS mapi/es2api"
816 fi
817
818 # build glsl and mesa if OpenGL or OpenGL ES is enabled
819 case "x$enable_opengl$enable_gles1$enable_gles2" in
820 x*yes*)
821     CORE_DIRS="$CORE_DIRS glsl mesa"
822     ;;
823 esac
824
825 case "x$enable_glx$enable_xlib_glx" in
826 xyesyes)
827     DRIVER_DIRS="$DRIVER_DIRS x11"
828     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
829     GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib"
830     GALLIUM_STATE_TRACKERS_DIRS="glx $GALLIUM_STATE_TRACKERS_DIRS"
831     HAVE_WINSYS_XLIB="yes"
832     ;;
833 xyesno)
834     # DRI-based GLX
835     SRC_DIRS="$SRC_DIRS glx"
836     ;;
837 esac
838
839 if test "x$enable_dri" = xyes; then
840     DRIVER_DIRS="$DRIVER_DIRS dri"
841
842     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/dri"
843     GALLIUM_STATE_TRACKERS_DIRS="dri $GALLIUM_STATE_TRACKERS_DIRS"
844     HAVE_ST_DRI="yes"
845 fi
846
847 if test "x$enable_osmesa" = xyes; then
848     # the empty space matters for osmesa... (see src/mesa/Makefile)
849     if test -n "$DRIVER_DIRS"; then
850         DRIVER_DIRS="$DRIVER_DIRS osmesa"
851     else
852         DRIVER_DIRS="osmesa"
853     fi
854 fi
855
856 AC_SUBST([SRC_DIRS])
857 AC_SUBST([GLU_DIRS])
858 AC_SUBST([DRIVER_DIRS])
859 AC_SUBST([GALLIUM_DIRS])
860 AC_SUBST([GALLIUM_TARGET_DIRS])
861 AC_SUBST([GALLIUM_WINSYS_DIRS])
862 AC_SUBST([GALLIUM_DRIVERS_DIRS])
863 AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
864 AC_SUBST([MESA_LLVM])
865
866 # Check for libdrm
867 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
868                   [have_libdrm=yes], [have_libdrm=no])
869
870 if test "x$enable_dri" = xyes; then
871     # DRI must be shared, I think
872     if test "$enable_static" = yes; then
873         AC_MSG_ERROR([Can't use static libraries for DRI drivers])
874     fi
875
876     # not a hard requirement as swrast does not depend on it
877     if test "x$have_libdrm" = xyes; then
878         DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
879     fi
880 fi
881
882 dnl
883 dnl Find out if X is available. The variable have_x is set if libX11 is
884 dnl found to mimic AC_PATH_XTRA.
885 dnl
886 if test -n "$PKG_CONFIG"; then
887     AC_MSG_CHECKING([pkg-config files for X11 are available])
888     PKG_CHECK_EXISTS([x11],[
889         x11_pkgconfig=yes
890         have_x=yes
891         ],[
892         x11_pkgconfig=no
893     ])
894     AC_MSG_RESULT([$x11_pkgconfig])
895 else
896     x11_pkgconfig=no
897 fi
898 dnl Use the autoconf macro if no pkg-config files
899 if test "$x11_pkgconfig" = yes; then
900     PKG_CHECK_MODULES([X11], [x11])
901 else
902     AC_PATH_XTRA
903     test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS"
904     test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11"
905     AC_SUBST([X11_CFLAGS])
906     AC_SUBST([X11_LIBS])
907 fi
908
909 dnl Try to tell the user that the --x-* options are only used when
910 dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
911 m4_divert_once([HELP_BEGIN],
912 [These options are only used when the X libraries cannot be found by the
913 pkg-config utility.])
914
915 dnl We need X for xlib and dri, so bomb now if it's not found
916 if test "x$enable_glx" = xyes -a "x$no_x" = xyes; then
917     AC_MSG_ERROR([X11 development libraries needed for GLX])
918 fi
919
920 if test "x$enable_glx" = xyes; then
921     DEFINES="$DEFINES -DUSE_XCB"
922 fi
923
924 dnl Direct rendering or just indirect rendering
925 case "$host_os" in
926 gnu*)
927     dnl Disable by default on GNU/Hurd
928     driglx_direct_default="no"
929     ;;
930 cygwin*)
931     dnl Disable by default on cygwin
932     driglx_direct_default="no"
933     ;;
934 *)
935     driglx_direct_default="yes"
936     ;;
937 esac
938 AC_ARG_ENABLE([driglx-direct],
939     [AS_HELP_STRING([--disable-driglx-direct],
940         [enable direct rendering in GLX and EGL for DRI \
941             @<:@default=auto@:>@])],
942     [driglx_direct="$enableval"],
943     [driglx_direct="$driglx_direct_default"])
944
945 dnl
946 dnl libGL configuration per driver
947 dnl
948 case "x$enable_glx$enable_xlib_glx" in
949 xyesyes)
950     # Xlib-based GLX
951     if test "$x11_pkgconfig" = yes; then
952         PKG_CHECK_MODULES([XLIBGL], [x11 xext])
953         GL_PC_REQ_PRIV="x11 xext"
954         X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
955         GL_LIB_DEPS="$XLIBGL_LIBS"
956     else
957         # should check these...
958         X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
959         GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
960         GL_PC_LIB_PRIV="$GL_LIB_DEPS"
961         GL_PC_CFLAGS="$X11_INCLUDES"
962     fi
963     GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $DLOPEN_LIBS"
964     GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread"
965     ;;
966 xyesno)
967     # DRI-based GLX
968     PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
969     GL_PC_REQ_PRIV="glproto >= $GLPROTO_REQUIRED"
970     if test x"$driglx_direct" = xyes; then
971         if test "x$have_libdrm" != xyes; then
972             AC_MSG_ERROR([Direct rendering requires libdrm >= $LIBDRM_REQUIRED])
973         fi
974         PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
975         GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
976     fi
977
978     # find the DRI deps for libGL
979     if test "$x11_pkgconfig" = yes; then
980         dri_modules="x11 xext xdamage xfixes x11-xcb xcb-glx"
981
982         # add xf86vidmode if available
983         PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no)
984         if test "$HAVE_XF86VIDMODE" = yes ; then
985             dri_modules="$dri_modules xxf86vm"
986         fi
987
988         PKG_CHECK_MODULES([DRIGL], [$dri_modules])
989         GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
990         X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
991         GL_LIB_DEPS="$DRIGL_LIBS"
992     else
993         # should check these...
994         X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
995         if test "x$HAVE_XF86VIDMODE" == xyes; then
996            GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
997         else
998            GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXdamage -lXfixes"
999         fi
1000         GL_PC_LIB_PRIV="$GL_LIB_DEPS"
1001         GL_PC_CFLAGS="$X11_INCLUDES"
1002
1003         # XCB can only be used from pkg-config
1004         PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
1005         GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
1006         X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
1007         GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
1008     fi
1009
1010     # Check to see if the xcb-glx library is new enough to support
1011     # GLX_ARB_create_context.  This bit of hackery is necessary until XCB 1.8
1012     # is released.
1013     save_CPPFLAGS="$CPPFLAGS"
1014     save_LDFLAGS="$LDFLAGS"
1015     CPPFLAGS="$CPPFLAGS $X11_INCLUDES"
1016     LDFLAGS="$LDFLAGS $GL_LIB_DEPS"
1017     AC_CHECK_LIB(xcb-glx, xcb_glx_create_context_attribs_arb_checked,
1018         [HAVE_XCB_GLX_CREATE_CONTEXT=yes],
1019         [HAVE_XCB_GLX_CREATE_CONTEXT=no])
1020     CPPFLAGS="$save_CPPFLAGS"
1021     LDFLAGS="$save_LDFLAGS"
1022
1023     if test x$HAVE_XCB_GLX_CREATE_CONTEXT = xyes; then
1024         X11_INCLUDES="$X11_INCLUDES -DHAVE_XCB_GLX_CREATE_CONTEXT"
1025     fi
1026
1027     # need DRM libs, -lpthread, etc.
1028     GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
1029     GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
1030     ;;
1031 esac
1032
1033 # This is outside the case (above) so that it is invoked even for non-GLX
1034 # builds.
1035 AM_CONDITIONAL(HAVE_XCB_GLX_CREATE_CONTEXT,
1036     test x$HAVE_XCB_GLX_CREATE_CONTEXT = xyes)
1037 AM_CONDITIONAL(HAVE_XF86VIDMODE, test "x$HAVE_XF86VIDMODE" = xyes)
1038
1039 GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
1040 GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
1041 GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
1042 GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
1043
1044 AC_SUBST([GL_LIB_DEPS])
1045 AC_SUBST([GL_PC_REQ_PRIV])
1046 AC_SUBST([GL_PC_LIB_PRIV])
1047 AC_SUBST([GL_PC_CFLAGS])
1048 AC_SUBST([DRI_PC_REQ_PRIV])
1049 AC_SUBST([GLESv1_CM_LIB_DEPS])
1050 AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
1051 AC_SUBST([GLESv2_LIB_DEPS])
1052 AC_SUBST([GLESv2_PC_LIB_PRIV])
1053
1054 GLAPI_LIB_DEPS="-lpthread $SELINUX_LIBS"
1055 AC_SUBST([GLAPI_LIB_DEPS])
1056
1057
1058 dnl Setup default DRI CFLAGS
1059 DRI_CFLAGS='$(CFLAGS)'
1060 DRI_CXXFLAGS='$(CXXFLAGS)'
1061 DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a'
1062 MESA_MODULES='$(TOP)/src/mesa/libmesa.a'
1063
1064 if test "x$enable_dri" = xyes && test "x$driglx_direct" = xyes ; then
1065     DRICORE_GLSL_LIBS='$(TOP)/$(LIB_DIR)/libglsl.so'
1066     DRICORE_LIBS='$(TOP)/$(LIB_DIR)/libdricore.so'
1067     DRICORE_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -lglsl'
1068     DRI_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -ldricore -lglsl'
1069     DRI_CFLAGS='$(CFLAGS_NOVISIBILITY) -DUSE_DRICORE'
1070     DRI_CXXFLAGS='$(CXXFLAGS_NOVISIBILITY) -DUSE_DRICORE'
1071     MESA_MODULES='$(DRICORE_LIBS) $(DRICORE_GLSL_LIBS)'
1072 fi
1073 AC_SUBST([DRICORE_LIBS])
1074 AC_SUBST([DRICORE_GLSL_LIBS])
1075 AC_SUBST([DRICORE_LIB_DEPS])
1076 AC_SUBST([DRI_CXXFLAGS])
1077 AC_SUBST([DRI_CFLAGS])
1078 AC_SUBST([MESA_MODULES])
1079
1080 AC_SUBST([HAVE_XF86VIDMODE])
1081
1082 dnl
1083 dnl More GLX setup
1084 dnl
1085 case "x$enable_glx$enable_xlib_glx" in
1086 xyesyes)
1087     DEFINES="$DEFINES -DUSE_XSHM"
1088     ;;
1089 xyesno)
1090     DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
1091     if test "x$driglx_direct" = xyes; then
1092         DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
1093     fi
1094     ;;
1095 esac
1096
1097 dnl
1098 dnl TLS detection
1099 dnl
1100
1101 AC_ARG_ENABLE([glx-tls],
1102     [AS_HELP_STRING([--enable-glx-tls],
1103         [enable TLS support in GLX @<:@default=disabled@:>@])],
1104     [GLX_USE_TLS="$enableval"],
1105     [GLX_USE_TLS=no])
1106 AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
1107
1108 AS_IF([test "x$GLX_USE_TLS" = xyes],
1109       [DEFINES="${DEFINES} -DGLX_USE_TLS -DPTHREADS"])
1110
1111 dnl
1112 dnl More DRI setup
1113 dnl
1114 dnl Directory for DRI drivers
1115 AC_ARG_WITH([dri-driverdir],
1116     [AS_HELP_STRING([--with-dri-driverdir=DIR],
1117         [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
1118     [DRI_DRIVER_INSTALL_DIR="$withval"],
1119     [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
1120 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
1121 dnl Extra search path for DRI drivers
1122 AC_ARG_WITH([dri-searchpath],
1123     [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
1124         [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
1125     [DRI_DRIVER_SEARCH_DIR="$withval"],
1126     [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
1127 AC_SUBST([DRI_DRIVER_SEARCH_DIR])
1128 dnl Which drivers to build - default is chosen by platform
1129 AC_ARG_WITH([dri-drivers],
1130     [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
1131         [comma delimited DRI drivers list, e.g.
1132         "swrast,i965,radeon" @<:@default=auto@:>@])],
1133     [with_dri_drivers="$withval"],
1134     [with_dri_drivers=yes])
1135 if test "x$with_dri_drivers" = x; then
1136     with_dri_drivers=no
1137 fi
1138
1139 dnl If $with_dri_drivers is yes, directories will be added through
1140 dnl platform checks
1141 DRI_DIRS=""
1142 case "$with_dri_drivers" in
1143 no) ;;
1144 yes)
1145     # classic DRI drivers require FEATURE_GL to build
1146     if test "x$enable_opengl" = xyes; then
1147         DRI_DIRS="yes"
1148     fi
1149     ;;
1150 *)
1151     # verify the requested driver directories exist
1152     dri_drivers=`IFS=', '; echo $with_dri_drivers`
1153     for driver in $dri_drivers; do
1154         test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
1155             AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
1156     done
1157     DRI_DIRS="$dri_drivers"
1158     if test -n "$DRI_DIRS" -a "x$enable_opengl" != xyes; then
1159         AC_MSG_ERROR([--with-dri-drivers requires OpenGL])
1160     fi
1161     ;;
1162 esac
1163
1164 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
1165 if test "x$enable_dri" = xyes; then
1166     # Platform specific settings and drivers to build
1167     case "$host_os" in
1168     linux*)
1169         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
1170         DEFINES="$DEFINES -DHAVE_ALIAS"
1171
1172         case "$host_cpu" in
1173         x86_64)
1174             if test "x$DRI_DIRS" = "xyes"; then
1175                 DRI_DIRS="i915 i965 nouveau r200 radeon swrast"
1176             fi
1177             ;;
1178         powerpc*)
1179             # Build only the drivers for cards that exist on PowerPC.
1180             if test "x$DRI_DIRS" = "xyes"; then
1181                 DRI_DIRS="r200 radeon swrast"
1182             fi
1183             ;;
1184         sparc*)
1185             # Build only the drivers for cards that exist on sparc
1186             if test "x$DRI_DIRS" = "xyes"; then
1187                 DRI_DIRS="r200 radeon swrast"
1188             fi
1189             ;;
1190         esac
1191         ;;
1192     freebsd* | dragonfly* | *netbsd*)
1193         DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
1194         DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
1195
1196         if test "x$DRI_DIRS" = "xyes"; then
1197             DRI_DIRS="i915 i965 nouveau r200 radeon swrast"
1198         fi
1199         ;;
1200     gnu*)
1201         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
1202         DEFINES="$DEFINES -DHAVE_ALIAS"
1203         ;;
1204     solaris*)
1205         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
1206         ;;
1207     cygwin*)
1208         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
1209         if test "x$DRI_DIRS" = "xyes"; then
1210             DRI_DIRS="swrast"
1211         fi
1212         ;;
1213     esac
1214
1215     # default drivers
1216     if test "x$DRI_DIRS" = "xyes"; then
1217         DRI_DIRS="i915 i965 nouveau r200 radeon swrast"
1218     fi
1219
1220     DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`
1221
1222     # Check for expat
1223     if test "x$enable_dri" = xyes; then
1224         EXPAT_INCLUDES=""
1225         EXPAT_LIB=-lexpat
1226         AC_ARG_WITH([expat],
1227             [AS_HELP_STRING([--with-expat=DIR],
1228                 [expat install directory])],[
1229             EXPAT_INCLUDES="-I$withval/include"
1230             CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
1231             LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
1232             EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
1233             ])
1234         AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
1235         save_LIBS="$LIBS"
1236         AC_CHECK_LIB([expat],[XML_ParserCreate],[],
1237             [AC_MSG_ERROR([Expat required for DRI.])])
1238         LIBS="$save_LIBS"
1239     fi
1240
1241     # if we are building any dri driver other than swrast ...
1242     if test -n "$DRI_DIRS" -a x"$DRI_DIRS" != xswrast; then
1243         # ... libdrm is required
1244         if test "x$have_libdrm" != xyes; then
1245             AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
1246         fi
1247         # ... and build dricommon
1248         HAVE_COMMON_DRI=yes
1249     fi
1250
1251     # put all the necessary libs together
1252     DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
1253 fi
1254 AC_SUBST([DRI_DIRS])
1255 AC_SUBST([EXPAT_INCLUDES])
1256 AC_SUBST([DRI_LIB_DEPS])
1257
1258 case $DRI_DIRS in
1259 *i915*|*i965*)
1260     PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
1261
1262     for d in $(echo $DRI_DIRS | sed 's/,/ /g'); do
1263         case $d in
1264         i915)
1265             HAVE_I915_DRI=yes;
1266             ;;
1267         i965)
1268             HAVE_I965_DRI=yes;
1269             ;;
1270         esac
1271     done
1272
1273     ;;
1274 esac
1275
1276 case $DRI_DIRS in
1277 *nouveau*)
1278     PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NVVIEUX_REQUIRED])
1279     HAVE_NOUVEAU_DRI=yes;
1280     ;;
1281 esac
1282
1283 case $DRI_DIRS in
1284 *radeon*|*r200*)
1285     PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
1286
1287     for d in $(echo $DRI_DIRS | sed 's/,/ /g'); do
1288         case $d in
1289         radeon)
1290             HAVE_RADEON_DRI=yes;
1291             ;;
1292         r200)
1293             HAVE_R200_DRI=yes;
1294             ;;
1295         esac
1296     done
1297
1298     ;;
1299 esac
1300
1301 case $DRI_DIRS in
1302 *swrast*)
1303     HAVE_SWRAST_DRI=yes;
1304     ;;
1305 esac
1306
1307 AM_CONDITIONAL(HAVE_I915_DRI, test x$HAVE_I915_DRI = xyes)
1308 AM_CONDITIONAL(HAVE_I965_DRI, test x$HAVE_I965_DRI = xyes)
1309 AM_CONDITIONAL(HAVE_NOUVEAU_DRI, test x$HAVE_NOUVEAU_DRI = xyes)
1310 AM_CONDITIONAL(HAVE_R200_DRI, test x$HAVE_R200_DRI = xyes)
1311 AM_CONDITIONAL(HAVE_RADEON_DRI, test x$HAVE_RADEON_DRI = xyes)
1312 AM_CONDITIONAL(HAVE_SWRAST_DRI, test x$HAVE_SWRAST_DRI = xyes)
1313 AM_CONDITIONAL(HAVE_COMMON_DRI, test x$HAVE_COMMON_DRI = xyes)
1314
1315 dnl
1316 dnl OSMesa configuration
1317 dnl
1318
1319 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
1320 AC_ARG_WITH([osmesa-bits],
1321     [AS_HELP_STRING([--with-osmesa-bits=BITS],
1322         [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
1323     [osmesa_bits="$withval"],
1324     [osmesa_bits=8])
1325 if test "x$osmesa_bits" != x8; then
1326     if test "x$enable_dri" = xyes -o "x$enable_glx" = xyes; then
1327         AC_MSG_WARN([Ignoring OSMesa channel bits because of non-OSMesa driver])
1328         osmesa_bits=8
1329     fi
1330 fi
1331 case "x$osmesa_bits" in
1332 x8)
1333     OSMESA_LIB="${OSMESA_LIB}"
1334     ;;
1335 x16|x32)
1336     OSMESA_LIB="${OSMESA_LIB}$osmesa_bits"
1337     DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
1338     ;;
1339 *)
1340     AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
1341     ;;
1342 esac
1343
1344 if test "x$enable_osmesa" = xyes; then
1345     # only link libraries with osmesa if shared
1346     if test "$enable_static" = no; then
1347         OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
1348     else
1349         OSMESA_LIB_DEPS=""
1350     fi
1351     OSMESA_MESA_DEPS=""
1352     OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
1353 fi
1354 AC_SUBST([OSMESA_LIB_DEPS])
1355 AC_SUBST([OSMESA_MESA_DEPS])
1356 AC_SUBST([OSMESA_PC_REQ])
1357 AC_SUBST([OSMESA_PC_LIB_PRIV])
1358
1359 dnl
1360 dnl gbm configuration
1361 dnl
1362 if test "x$enable_gbm" = xauto; then
1363     case "$with_egl_platforms" in
1364         *drm*)
1365             enable_gbm=yes ;;
1366          *)
1367             enable_gbm=no ;;
1368     esac
1369 fi
1370 if test "x$enable_gbm" = xyes; then
1371     SRC_DIRS="$SRC_DIRS gbm"
1372
1373     PKG_CHECK_MODULES([LIBUDEV], [libudev], [],
1374                       AC_MSG_ERROR([gbm needs udev]))
1375
1376     if test "x$enable_dri" = xyes; then
1377         GBM_BACKEND_DIRS="$GBM_BACKEND_DIRS dri"
1378         if test "$SHARED_GLAPI" -eq 0; then
1379             AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
1380         fi
1381     fi
1382 fi
1383 GBM_PC_REQ_PRIV="libudev"
1384 GBM_PC_LIB_PRIV="$DLOPEN_LIBS"
1385 AC_SUBST([GBM_PC_REQ_PRIV])
1386 AC_SUBST([GBM_PC_LIB_PRIV])
1387
1388 dnl
1389 dnl EGL configuration
1390 dnl
1391 EGL_CLIENT_APIS=""
1392
1393 if test "x$enable_egl" = xyes; then
1394     SRC_DIRS="$SRC_DIRS egl"
1395     EGL_LIB_DEPS="$DLOPEN_LIBS $SELINUX_LIBS -lpthread"
1396
1397     AC_CHECK_FUNC(mincore, [DEFINES="$DEFINES -DHAVE_MINCORE"])
1398
1399     if test "$enable_static" != yes; then
1400         # build egl_glx when libGL is built
1401         if test "x$enable_glx" = xyes; then
1402             HAVE_EGL_DRIVER_GLX=1
1403         fi
1404
1405         PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
1406                           [have_libudev=yes],[have_libudev=no])
1407         if test "$have_libudev" = yes; then
1408             DEFINES="$DEFINES -DHAVE_LIBUDEV"
1409         fi
1410         if test "x$enable_dri" = xyes; then
1411             # build egl_dri2 when xcb-dri2 is available
1412             PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
1413                           [have_xcb_dri2=yes],[have_xcb_dri2=no])
1414             if test "$have_xcb_dri2" = yes; then
1415                 HAVE_EGL_DRIVER_DRI2=1
1416                 # workaround a bug in xcb-dri2 generated by xcb-proto 1.6
1417                 save_LIBS="$LIBS"
1418                 AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
1419                           [DEFINES="$DEFINES -DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN"])
1420                 LIBS="$save_LIBS"
1421             fi
1422         fi
1423
1424     fi
1425 fi
1426 AC_SUBST([EGL_LIB_DEPS])
1427
1428 dnl
1429 dnl EGL Gallium configuration
1430 dnl
1431 if test "x$enable_gallium_egl" = xyes; then
1432     if test "x$with_gallium_drivers" = x; then
1433         AC_MSG_ERROR([cannot enable egl_gallium without Gallium])
1434     fi
1435     if test "x$enable_egl" = xno; then
1436         AC_MSG_ERROR([cannot enable egl_gallium without EGL])
1437     fi
1438     if test "x$have_libdrm" != xyes; then
1439         AC_MSG_ERROR([egl_gallium requires libdrm >= $LIBDRM_REQUIRED])
1440     fi
1441
1442     GALLIUM_STATE_TRACKERS_DIRS="egl $GALLIUM_STATE_TRACKERS_DIRS"
1443     GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-static"
1444     HAVE_ST_EGL="yes"
1445 fi
1446
1447 dnl
1448 dnl gbm Gallium configuration
1449 dnl
1450 if test "x$enable_gallium_gbm" = xauto; then
1451     case "$enable_gbm$HAVE_ST_EGL$enable_dri$with_egl_platforms" in
1452         yesyesyes*drm*)
1453             enable_gallium_gbm=yes ;;
1454          *)
1455             enable_gallium_gbm=no ;;
1456     esac
1457 fi
1458 if test "x$enable_gallium_gbm" = xyes; then
1459     if test "x$with_gallium_drivers" = x; then
1460         AC_MSG_ERROR([cannot enable gbm_gallium without Gallium])
1461     fi
1462     if test "x$enable_gbm" = xno; then
1463         AC_MSG_ERROR([cannot enable gbm_gallium without gbm])
1464     fi
1465     # gbm_gallium abuses DRI_LIB_DEPS to link.  Make sure it is set.
1466     if test "x$enable_dri" = xno; then
1467         AC_MSG_ERROR([gbm_gallium requires --enable-dri to build])
1468     fi
1469
1470     GALLIUM_STATE_TRACKERS_DIRS="gbm $GALLIUM_STATE_TRACKERS_DIRS"
1471     GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS gbm"
1472     HAVE_ST_GBM="yes"
1473 fi
1474
1475 dnl
1476 dnl X.Org DDX configuration
1477 dnl
1478 if test "x$enable_xorg" = xyes; then
1479     PKG_CHECK_MODULES([XORG], [xorg-server >= 1.6.0])
1480     PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
1481     PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
1482     PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
1483         HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
1484         HAVE_XEXTPROTO_71="no")
1485     GALLIUM_STATE_TRACKERS_DIRS="xorg $GALLIUM_STATE_TRACKERS_DIRS"
1486     HAVE_ST_XORG=yes
1487 fi
1488
1489 dnl
1490 dnl XA configuration
1491 dnl
1492 if test "x$enable_xa" = xyes; then
1493 AC_PROG_AWK
1494 AC_PROG_GREP
1495 AC_CHECK_PROG(NM, nm, "nm")
1496 if test "x$AWK" = x || test "x$GREP" = x || test "x$NM" = x; then
1497 AC_MSG_WARN([Missing one of nm, grep or awk. Disabling xa.])
1498 enable_xa=no
1499 fi
1500 fi
1501 if test "x$enable_xa" = xyes; then
1502     GALLIUM_STATE_TRACKERS_DIRS="xa $GALLIUM_STATE_TRACKERS_DIRS"
1503     HAVE_ST_XA=yes
1504     AC_SUBST(AWK)
1505     AC_SUBST(GREP)
1506     AC_SUBST(NM)
1507 fi
1508
1509 dnl
1510 dnl OpenVG configuration
1511 dnl
1512 VG_LIB_DEPS=""
1513
1514 if test "x$enable_openvg" = xyes; then
1515     if test "x$enable_egl" = xno; then
1516         AC_MSG_ERROR([cannot enable OpenVG without EGL])
1517     fi
1518     if test "x$with_gallium_drivers" = x; then
1519         AC_MSG_ERROR([cannot enable OpenVG without Gallium])
1520     fi
1521     if test "x$enable_gallium_egl" = xno; then
1522         AC_MSG_ERROR([cannot enable OpenVG without egl_gallium])
1523     fi
1524
1525     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
1526     VG_LIB_DEPS="$VG_LIB_DEPS $SELINUX_LIBS -lpthread"
1527     CORE_DIRS="$CORE_DIRS mapi/vgapi"
1528     GALLIUM_STATE_TRACKERS_DIRS="vega $GALLIUM_STATE_TRACKERS_DIRS"
1529     HAVE_ST_VEGA=yes
1530 fi
1531
1532 dnl
1533 dnl D3D1X configuration
1534 dnl
1535
1536 if test "x$enable_d3d1x" = xyes; then
1537     if test "x$with_gallium_drivers" = x; then
1538         AC_MSG_ERROR([cannot enable D3D1X without Gallium])
1539     fi
1540
1541     GALLIUM_STATE_TRACKERS_DIRS="d3d1x $GALLIUM_STATE_TRACKERS_DIRS"
1542     HAVE_ST_D3D1X=yes
1543 fi
1544
1545 dnl
1546 dnl Gallium G3DVL configuration
1547 dnl
1548 AC_ARG_ENABLE([gallium-g3dvl],
1549     [AS_HELP_STRING([--enable-gallium-g3dvl],
1550         [build gallium g3dvl @<:@default=disabled@:>@])],
1551     [enable_gallium_g3dvl="$enableval"],
1552     [enable_gallium_g3dvl=no])
1553 if test "x$enable_gallium_g3dvl" = xyes; then
1554     if test "x$with_gallium_drivers" = x; then
1555         AC_MSG_ERROR([cannot enable G3DVL without Gallium])
1556     fi
1557
1558     if test "x$enable_xvmc" = xauto; then
1559         PKG_CHECK_EXISTS([xvmc], [enable_xvmc=yes], [enable_xvmc=no])
1560     fi
1561
1562     if test "x$enable_vdpau" = xauto; then
1563         PKG_CHECK_EXISTS([vdpau], [enable_vdpau=yes], [enable_vdpau=no])
1564     fi
1565
1566     if test "x$enable_va" = xauto; then
1567         #don't enable vaapi state tracker even if package exists
1568         #PKG_CHECK_EXISTS([libva], [enable_vdpau=yes], [enable_vdpau=no])
1569         enable_va=no
1570     fi
1571 fi
1572
1573 if test "x$enable_xvmc" = xyes; then
1574     PKG_CHECK_MODULES([XVMC], [xvmc >= 1.0.6 x11-xcb xcb-dri2 >= 1.8])
1575     GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xvmc"
1576     HAVE_ST_XVMC="yes"
1577 fi
1578
1579 if test "x$enable_vdpau" = xyes; then
1580     PKG_CHECK_MODULES([VDPAU], [vdpau >= 0.4.1 x11-xcb xcb-dri2 >= 1.8])
1581     GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vdpau"
1582     HAVE_ST_VDPAU="yes"
1583 fi
1584
1585 if test "x$enable_va" = xyes; then
1586     PKG_CHECK_MODULES([LIBVA], [libva = 0.31.1 x11-xcb xcb-dri2 >= 1.8])
1587     AC_MSG_WARN([vaapi state tracker currently unmaintained])
1588     GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS va"
1589     HAVE_ST_VA="yes"
1590 fi
1591
1592 dnl
1593 dnl GLU configuration
1594 dnl
1595 AC_ARG_ENABLE([glu],
1596     [AS_HELP_STRING([--disable-glu],
1597         [enable OpenGL Utility library @<:@default=enabled@:>@])],
1598     [enable_glu="$enableval"],
1599     [enable_glu=yes])
1600
1601 if test "x$enable_glu" = xyes; then
1602     if test "x$enable_glx" = xno -a "x$enable_osmesa" = xno; then
1603         AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver])
1604         enable_glu=no
1605     fi
1606 fi
1607
1608 if test "x$enable_glu" = xyes; then
1609     SRC_DIRS="$SRC_DIRS glu"
1610
1611     if test "x$enable_glx" = xno; then
1612         # Link libGLU to libOSMesa instead of libGL
1613         GLU_LIB_DEPS=""
1614         GLU_PC_REQ="osmesa"
1615         if test "$enable_static" = no; then
1616             GLU_MESA_DEPS='-l$(OSMESA_LIB)'
1617         else
1618             GLU_MESA_DEPS=""
1619         fi
1620     else
1621         # If static, empty GLU_LIB_DEPS and add libs for programs to link
1622         GLU_PC_REQ="gl"
1623         GLU_PC_LIB_PRIV="-lm"
1624         if test "$enable_static" = no; then
1625             GLU_LIB_DEPS="-lm"
1626             GLU_MESA_DEPS='-l$(GL_LIB)'
1627         else
1628             GLU_LIB_DEPS=""
1629             GLU_MESA_DEPS=""
1630         fi
1631     fi
1632 fi
1633 if test "$enable_static" = no; then
1634     GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
1635 fi
1636 GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
1637 AC_SUBST([GLU_LIB_DEPS])
1638 AC_SUBST([GLU_MESA_DEPS])
1639 AC_SUBST([GLU_PC_REQ])
1640 AC_SUBST([GLU_PC_REQ_PRIV])
1641 AC_SUBST([GLU_PC_LIB_PRIV])
1642 AC_SUBST([GLU_PC_CFLAGS])
1643
1644 AC_SUBST([PROGRAM_DIRS])
1645
1646 dnl
1647 dnl Gallium configuration
1648 dnl
1649 if test "x$with_gallium_drivers" != x; then
1650     SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
1651 fi
1652
1653 AC_SUBST([LLVM_BINDIR])
1654 AC_SUBST([LLVM_CFLAGS])
1655 AC_SUBST([LLVM_CXXFLAGS])
1656 AC_SUBST([LLVM_LIBS])
1657 AC_SUBST([LLVM_LDFLAGS])
1658 AC_SUBST([LLVM_INCLUDEDIR])
1659 AC_SUBST([LLVM_VERSION])
1660
1661 case "x$enable_opengl$enable_gles1$enable_gles2" in
1662 x*yes*)
1663     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)'
1664     ;;
1665 esac
1666
1667 AC_SUBST([VG_LIB_DEPS])
1668 AC_SUBST([EGL_CLIENT_APIS])
1669
1670 AC_ARG_WITH([egl-platforms],
1671     [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
1672         [comma delimited native platforms libEGL supports, e.g.
1673         "x11,drm" @<:@default=auto@:>@])],
1674     [with_egl_platforms="$withval"],
1675     [if test "x$enable_egl" = xyes; then
1676         with_egl_platforms="x11"
1677     else
1678         with_egl_platforms=""
1679     fi])
1680
1681 EGL_PLATFORMS=""
1682
1683 if test "x$with_egl_platforms" != "x" -a "x$enable_egl" != xyes; then
1684     AC_MSG_ERROR([cannot build egl state tracker without EGL library])
1685 fi
1686
1687 # verify the requested driver directories exist
1688 egl_platforms=`IFS=', '; echo $with_egl_platforms`
1689 for plat in $egl_platforms; do
1690         test -d "$srcdir/src/gallium/state_trackers/egl/$plat" || \
1691             AC_MSG_ERROR([EGL platform '$plat' does not exist])
1692         if test "$plat" = "fbdev"; then
1693                 GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/fbdev"
1694         fi
1695         if test "$plat" = "null"; then
1696                 GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/null"
1697         fi
1698         if test "$plat" = "wayland"; then
1699                 PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server],, \
1700                                   [AC_MSG_ERROR([cannot find libwayland-client])])
1701                 GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/wayland"
1702
1703                 m4_ifdef([WAYLAND_SCANNER_RULES],
1704                          [WAYLAND_SCANNER_RULES(['$(top_srcdir)/src/egl/wayland/wayland-drm/protocol'])])
1705         fi
1706         if test "$plat" = "drm" && test "x$enable_gbm" = "xno"; then
1707                 AC_MSG_ERROR([EGL platform drm needs gbm])
1708         fi
1709         case "$plat$have_libudev" in
1710                 waylandno|drmno)
1711                     AC_MSG_ERROR([cannot build $plat platfrom without udev]) ;;
1712         esac
1713 done
1714
1715 # libEGL wants to default to the first platform specified in
1716 # ./configure.  parse that here.
1717 if test "x$egl_platforms" != "x"; then
1718     FIRST_PLATFORM_CAPS=`echo $egl_platforms | sed 's| .*||' | tr 'a-z' 'A-Z'`
1719     EGL_NATIVE_PLATFORM="_EGL_PLATFORM_$FIRST_PLATFORM_CAPS"
1720 else
1721     EGL_NATIVE_PLATFORM="_EGL_INVALID_PLATFORM"
1722 fi
1723
1724 EGL_PLATFORMS="$egl_platforms"
1725
1726 AM_CONDITIONAL(HAVE_EGL_PLATFORM_X11, echo "$egl_platforms" | grep 'x11' >/dev/null 2>&1)
1727 AM_CONDITIONAL(HAVE_EGL_PLATFORM_WAYLAND, echo "$egl_platforms" | grep 'wayland' >/dev/null 2>&1)
1728 AM_CONDITIONAL(HAVE_EGL_PLATFORM_DRM, echo "$egl_platforms" | grep 'drm' >/dev/null 2>&1)
1729 AM_CONDITIONAL(HAVE_EGL_PLATFORM_FBDEV, echo "$egl_platforms" | grep 'fbdev' >/dev/null 2>&1)
1730 AM_CONDITIONAL(HAVE_EGL_PLATFORM_NULL, echo "$egl_platforms" | grep 'null' >/dev/null 2>&1)
1731
1732 AM_CONDITIONAL(HAVE_EGL_DRIVER_DRI2, test "x$HAVE_EGL_DRIVER_DRI2" != "x")
1733 AM_CONDITIONAL(HAVE_EGL_DRIVER_GLX, test "x$HAVE_EGL_DRIVER_GLX" != "x")
1734
1735 AC_SUBST([EGL_NATIVE_PLATFORM])
1736 AC_SUBST([EGL_PLATFORMS])
1737 AC_SUBST([EGL_CFLAGS])
1738
1739 AC_ARG_WITH([egl-driver-dir],
1740     [AS_HELP_STRING([--with-egl-driver-dir=DIR],
1741                     [directory for EGL drivers [[default=${libdir}/egl]]])],
1742     [EGL_DRIVER_INSTALL_DIR="$withval"],
1743     [EGL_DRIVER_INSTALL_DIR='${libdir}/egl'])
1744 AC_SUBST([EGL_DRIVER_INSTALL_DIR])
1745
1746 AC_ARG_WITH([xorg-driver-dir],
1747     [AS_HELP_STRING([--with-xorg-driver-dir=DIR],
1748                     [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])],
1749     [XORG_DRIVER_INSTALL_DIR="$withval"],
1750     [XORG_DRIVER_INSTALL_DIR="${libdir}/xorg/modules/drivers"])
1751 AC_SUBST([XORG_DRIVER_INSTALL_DIR])
1752
1753 AC_ARG_WITH([max-width],
1754     [AS_HELP_STRING([--with-max-width=N],
1755                     [Maximum framebuffer width (4096)])],
1756     [DEFINES="${DEFINES} -DMAX_WIDTH=${withval}";
1757      AS_IF([test "${withval}" -gt "4096"],
1758            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
1759 )
1760 AC_ARG_WITH([max-height],
1761     [AS_HELP_STRING([--with-max-height=N],
1762                     [Maximum framebuffer height (4096)])],
1763     [DEFINES="${DEFINES} -DMAX_HEIGHT=${withval}";
1764      AS_IF([test "${withval}" -gt "4096"],
1765            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
1766 )
1767
1768 dnl
1769 dnl Gallium LLVM
1770 dnl
1771 AC_ARG_ENABLE([gallium-llvm],
1772     [AS_HELP_STRING([--enable-gallium-llvm],
1773         [build gallium LLVM support @<:@default=enabled on x86/x86_64@:>@])],
1774     [enable_gallium_llvm="$enableval"],
1775     [enable_gallium_llvm=auto])
1776
1777 AC_ARG_WITH([llvm-shared-libs],
1778     [AS_HELP_STRING([--with-llvm-shared-libs],
1779         [link with LLVM shared libraries @<:@default=disabled@:>@])],
1780     [with_llvm_shared_libs=yes],
1781     [with_llvm_shared_libs=no])
1782
1783 if test "x$with_gallium_drivers" = x; then
1784     enable_gallium_llvm=no
1785 fi
1786 if test "x$enable_gallium_llvm" = xauto; then
1787     case "$host_cpu" in
1788     i*86|x86_64) enable_gallium_llvm=yes;;
1789     esac
1790 fi
1791 if test "x$enable_gallium_llvm" = xyes; then
1792     AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
1793
1794     if test "x$LLVM_CONFIG" != xno; then
1795         LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'`
1796         LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed -e 's/-DNDEBUG\>//g' -e 's/-pedantic//g'`
1797         if test "x$with_llvm_shared_libs" = xyes; then
1798             dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
1799             LLVM_LIBS="-lLLVM-`$LLVM_CONFIG --version`"
1800         else
1801             LLVM_LIBS="`$LLVM_CONFIG --libs engine bitwriter`"
1802         fi
1803         LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
1804         LLVM_BINDIR=`$LLVM_CONFIG --bindir`
1805         LLVM_CXXFLAGS=`$LLVM_CONFIG --cxxflags`
1806         LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir`
1807         DEFINES="$DEFINES -D__STDC_CONSTANT_MACROS"
1808         MESA_LLVM=1
1809     else
1810         MESA_LLVM=0
1811     fi
1812 else
1813     MESA_LLVM=0
1814 fi
1815
1816 dnl Directory for XVMC libs
1817 AC_ARG_WITH([xvmc-libdir],
1818     [AS_HELP_STRING([--with-xvmc-libdir=DIR],
1819         [directory for the XVMC libraries @<:@default=${libdir}@:>@])],
1820     [XVMC_LIB_INSTALL_DIR="$withval"],
1821     [XVMC_LIB_INSTALL_DIR='${libdir}'])
1822 AC_SUBST([XVMC_LIB_INSTALL_DIR])
1823
1824 dnl Directory for VDPAU libs
1825 AC_ARG_WITH([vdpau-libdir],
1826     [AS_HELP_STRING([--with-vdpau-libdir=DIR],
1827         [directory for the VDPAU libraries @<:@default=${libdir}/vdpau@:>@])],
1828     [VDPAU_LIB_INSTALL_DIR="$withval"],
1829     [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau'])
1830 AC_SUBST([VDPAU_LIB_INSTALL_DIR])
1831
1832 dnl Directory for VA libs
1833 AC_ARG_WITH([va-libdir],
1834     [AS_HELP_STRING([--with-va-libdir=DIR],
1835         [directory for the VA libraries @<:@default=${libdir}/va@:>@])],
1836     [VA_LIB_INSTALL_DIR="$withval"],
1837     [VA_LIB_INSTALL_DIR='${libdir}/va'])
1838 AC_SUBST([VA_LIB_INSTALL_DIR])
1839
1840 dnl
1841 dnl Gallium helper functions
1842 dnl
1843 gallium_check_st() {
1844     if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes ||
1845          test "x$HAVE_ST_XA" = xyes || test "x$HAVE_ST_XVMC" = xyes ||
1846          test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then
1847          if test "x$have_libdrm" != xyes; then
1848             AC_MSG_ERROR([DRI or Xorg DDX requires libdrm >= $LIBDRM_REQUIRED])
1849          fi
1850          GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1"
1851     fi
1852     if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then
1853          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2"
1854     fi
1855     if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then
1856          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
1857     fi
1858     if test "x$HAVE_ST_XA" = xyes && test "x$4" != x; then
1859          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4"
1860     fi
1861     if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then
1862          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5"
1863     fi
1864     if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then
1865          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6"
1866     fi
1867     if test "x$HAVE_ST_VA" = xyes && test "x$7" != x; then
1868          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7"
1869     fi
1870 }
1871
1872 gallium_require_llvm() {
1873     if test "x$MESA_LLVM" = x0; then
1874         case "$host_cpu" in
1875         i*86|x86_64) AC_MSG_ERROR([LLVM is required to build $1 on x86 and x86_64]);;
1876         esac
1877     fi
1878 }
1879
1880 dnl Gallium drivers
1881 dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block
1882 if test "x$with_gallium_drivers" != x; then
1883     gallium_drivers=`IFS=', '; echo $with_gallium_drivers`
1884     for driver in $gallium_drivers; do
1885         case "x$driver" in
1886         xsvga)
1887             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga softpipe"
1888             gallium_check_st "svga/drm" "dri-vmwgfx" "" "xa-vmwgfx"
1889             ;;
1890         xi915)
1891             PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
1892             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 softpipe"
1893             if test "x$MESA_LLVM" = x1; then
1894                 GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
1895             fi
1896             GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
1897             gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
1898             ;;
1899         xr300)
1900             PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
1901             gallium_require_llvm "Gallium R300"
1902             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
1903             gallium_check_st "radeon/drm" "dri-r300" "xorg-r300" "" "xvmc-r300" "vdpau-r300" "va-r300"
1904             ;;
1905         xr600)
1906             PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
1907             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
1908             gallium_check_st "radeon/drm" "dri-r600" "xorg-r600" "" "xvmc-r600" "vdpau-r600" "va-r600"
1909             ;;
1910         xradeonsi)
1911             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS radeonsi"
1912             if test "x$LLVM_VERSION" != "x3.1"; then
1913                 AC_MSG_ERROR([LLVM 3.1 is required to build the radeonsi driver.])
1914             fi
1915             NEED_RADEON_GALLIUM=yes;
1916             gallium_check_st "radeon/drm" "dri-radeonsi" "xorg-radeonsi"
1917             ;;
1918         xnouveau)
1919             PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED])
1920             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0"
1921             gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "" "xvmc-nouveau" "vdpau-nouveau"
1922             ;;
1923         xswrast)
1924             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
1925             if test "x$MESA_LLVM" = x1; then
1926                 GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
1927             fi
1928
1929             if test "x$HAVE_ST_DRI" = xyes; then
1930                 GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
1931             fi
1932             if test "x$HAVE_ST_VDPAU" = xyes; then
1933                 GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe"
1934             fi
1935             if test "x$HAVE_ST_XVMC" = xyes; then
1936                 GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xvmc-softpipe"
1937             fi
1938             if test "x$HAVE_ST_VA" = xyes; then
1939                 GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS va-softpipe"
1940             fi
1941             if test "x$HAVE_ST_VDPAU" = xyes ||
1942                test "x$HAVE_ST_XVMC" = xyes ||
1943                test "x$HAVE_ST_VA" = xyes; then
1944                if test "x$HAVE_WINSYS_XLIB" != xyes; then
1945                   GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
1946                fi
1947             fi
1948             ;;
1949         *)
1950             AC_MSG_ERROR([Unknown Gallium driver: $driver])
1951             ;;
1952         esac
1953     done
1954 fi
1955
1956 dnl Tell Automake which drivers to build
1957 for driver in $GALLIUM_DRIVERS_DIRS; do
1958     case "x$driver" in
1959         xgalahad)
1960             HAVE_GALAHAD_GALLIUM=yes;
1961             ;;
1962         xidentity)
1963             HAVE_IDENTITY_GALLIUM=yes;
1964             ;;
1965         xnoop)
1966             HAVE_NOOP_GALLIUM=yes;
1967             ;;
1968         *)
1969             GALLIUM_MAKE_DIRS="$GALLIUM_MAKE_DIRS $driver"
1970             ;;
1971     esac
1972 done
1973
1974 AM_CONDITIONAL(HAVE_GALAHAD_GALLIUM, test x$HAVE_GALAHAD_GALLIUM = xyes)
1975 AM_CONDITIONAL(HAVE_IDENTITY_GALLIUM, test x$HAVE_IDENTITY_GALLIUM = xyes)
1976 AM_CONDITIONAL(HAVE_NOOP_GALLIUM, test x$HAVE_NOOP_GALLIUM = xyes)
1977 AM_CONDITIONAL(NEED_RADEON_GALLIUM, test x$NEED_RADEON_GALLIUM = xyes)
1978 AC_SUBST([GALLIUM_MAKE_DIRS])
1979
1980 dnl prepend CORE_DIRS to SRC_DIRS
1981 SRC_DIRS="$CORE_DIRS $SRC_DIRS"
1982
1983 dnl Restore LDFLAGS and CPPFLAGS
1984 LDFLAGS="$_SAVE_LDFLAGS"
1985 CPPFLAGS="$_SAVE_CPPFLAGS"
1986
1987 dnl Add user CFLAGS and CXXFLAGS
1988 CFLAGS="$CFLAGS $USER_CFLAGS"
1989 CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
1990
1991 dnl Substitute the config
1992 AC_CONFIG_FILES([configs/autoconf
1993                 src/gallium/drivers/Makefile
1994                 src/gallium/drivers/r300/Makefile
1995                 src/gbm/Makefile
1996                 src/gbm/main/gbm.pc
1997                 src/egl/drivers/Makefile
1998                 src/egl/drivers/dri2/Makefile
1999                 src/egl/drivers/glx/Makefile
2000                 src/egl/main/Makefile
2001                 src/egl/main/egl.pc
2002                 src/egl/wayland/Makefile
2003                 src/egl/wayland/wayland-egl/Makefile
2004                 src/egl/wayland/wayland-egl/wayland-egl.pc
2005                 src/egl/wayland/wayland-drm/Makefile
2006                 src/glx/Makefile
2007                 src/mapi/shared-glapi/Makefile
2008                 src/gtest/Makefile
2009                 src/mesa/drivers/dri/dri.pc
2010                 src/mesa/drivers/dri/Makefile
2011                 src/mesa/drivers/dri/common/Makefile
2012                 src/mesa/drivers/dri/i915/Makefile
2013                 src/mesa/drivers/dri/i965/Makefile
2014                 src/mesa/drivers/dri/nouveau/Makefile
2015                 src/mesa/drivers/dri/r200/Makefile
2016                 src/mesa/drivers/dri/radeon/Makefile
2017                 src/mesa/drivers/dri/swrast/Makefile
2018                 tests/Makefile
2019                 tests/glx/Makefile])
2020
2021 dnl Replace the configs/current symlink
2022 AC_CONFIG_COMMANDS([configs],[
2023 if test -f configs/current || test -L configs/current; then
2024     rm -f configs/current
2025 fi
2026 ln -s autoconf configs/current
2027 ])
2028
2029 dnl Sort the dirs alphabetically
2030 GALLIUM_TARGET_DIRS=`echo $GALLIUM_TARGET_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
2031 GALLIUM_WINSYS_DIRS=`echo $GALLIUM_WINSYS_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
2032 GALLIUM_DRIVERS_DIRS=`echo $GALLIUM_DRIVERS_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
2033 GALLIUM_MAKE_DIRS=`echo $GALLIUM_MAKE_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
2034 GALLIUM_STATE_TRACKERS_DIRS=`echo $GALLIUM_STATE_TRACKERS_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
2035
2036 AC_OUTPUT
2037
2038 dnl
2039 dnl Output some configuration info for the user
2040 dnl
2041 echo ""
2042 echo "        prefix:          $prefix"
2043 echo "        exec_prefix:     $exec_prefix"
2044 echo "        libdir:          $libdir"
2045 echo "        includedir:      $includedir"
2046
2047 dnl API info
2048 echo ""
2049 echo "        OpenGL:          $enable_opengl (ES1: $enable_gles1 ES2: $enable_gles2)"
2050 echo "        OpenVG:          $enable_openvg"
2051
2052 dnl Driver info
2053 echo ""
2054 if test "x$enable_osmesa" != xno; then
2055         echo "        OSMesa:          lib$OSMESA_LIB"
2056 else
2057         echo "        OSMesa:          no"
2058 fi
2059
2060 if test "x$enable_dri" != xno; then
2061         # cleanup the drivers var
2062         dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
2063         if test "x$DRI_DIRS" = x; then
2064             echo "        DRI drivers:     no"
2065         else
2066             echo "        DRI drivers:     $dri_dirs"
2067         fi
2068         echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
2069 fi
2070
2071 case "x$enable_glx$enable_xlib_glx" in
2072 xyesyes)
2073     echo "        GLX:             Xlib-based"
2074     ;;
2075 xyesno)
2076     echo "        GLX:             DRI-based"
2077     ;;
2078 *)
2079     echo "        GLX:             $enable_glx"
2080     ;;
2081 esac
2082
2083 echo ""
2084 echo "        GLU:             $enable_glu"
2085
2086 dnl EGL
2087 echo ""
2088 echo "        EGL:             $enable_egl"
2089 if test "$enable_egl" = yes; then
2090     echo "        EGL platforms:   $EGL_PLATFORMS"
2091
2092     egl_drivers=""
2093     if test "x$HAVE_EGL_DRIVER_GLX" != "x"; then
2094         egl_drivers="$egl_drivers builtin:egl_glx"
2095     fi
2096     if test "x$HAVE_EGL_DRIVER_DRI2" != "x"; then
2097         egl_drivers="$egl_drivers builtin:egl_dri2"
2098     fi
2099
2100     if test "x$HAVE_ST_EGL" = xyes; then
2101         echo "        EGL drivers:    ${egl_drivers} egl_gallium"
2102         echo "        EGL Gallium STs:$EGL_CLIENT_APIS"
2103     else
2104         echo "        EGL drivers:    $egl_drivers"
2105     fi
2106 fi
2107
2108 echo ""
2109 if test "x$MESA_LLVM" = x1; then
2110     echo "        llvm:            yes"
2111     echo "        llvm-config:     $LLVM_CONFIG"
2112     echo "        llvm-version:    $LLVM_VERSION"
2113 else
2114     echo "        llvm:            no"
2115 fi
2116
2117 echo ""
2118 if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
2119     echo "        Gallium:         yes"
2120     echo "        Gallium dirs:    $GALLIUM_DIRS"
2121     echo "        Target dirs:     $GALLIUM_TARGET_DIRS"
2122     echo "        Winsys dirs:     $GALLIUM_WINSYS_DIRS"
2123     echo "        Driver dirs:     $GALLIUM_DRIVERS_DIRS"
2124     echo "        Trackers dirs:   $GALLIUM_STATE_TRACKERS_DIRS"
2125 else
2126     echo "        Gallium:         no"
2127 fi
2128
2129
2130 dnl Libraries
2131 echo ""
2132 echo "        Shared libs:     $enable_shared"
2133 echo "        Static libs:     $enable_static"
2134
2135 dnl Compiler options
2136 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
2137 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
2138     $SED 's/^ *//;s/  */ /;s/ *$//'`
2139 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
2140     $SED 's/^ *//;s/  */ /;s/ *$//'`
2141 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/  */ /;s/ *$//'`
2142 echo ""
2143 echo "        CFLAGS:          $cflags"
2144 echo "        CXXFLAGS:        $cxxflags"
2145 echo "        Macros:          $defines"
2146 echo ""
2147 echo "        PYTHON2:         $PYTHON2"
2148
2149 echo ""
2150 echo "        Run '${MAKE-make}' to build Mesa"
2151 echo ""