OSDN Git Service

i965: emit one vb packet per vbo
[android-x86/external-mesa.git] / configure.ac
1 dnl Process this file with autoconf to create configure.
2
3 AC_PREREQ([2.59])
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
20 dnl Versions for external dependencies
21 LIBDRM_REQUIRED=2.4.23
22 LIBDRM_RADEON_REQUIRED=2.4.23
23 LIBDRM_INTEL_REQUIRED=2.4.23
24 DRI2PROTO_REQUIRED=2.1
25 GLPROTO_REQUIRED=1.4.11
26 LIBDRM_XORG_REQUIRED=2.4.23
27 LIBKMS_XORG_REQUIRED=1.0.0
28
29 dnl Check for progs
30 AC_PROG_CPP
31 AC_PROG_CC
32 AC_PROG_CXX
33 AC_CHECK_PROGS([MAKE], [gmake make])
34 AC_CHECK_PROGS([PYTHON2], [python2 python])
35 AC_PATH_PROG([MKDEP], [makedepend])
36 AC_PATH_PROG([SED], [sed])
37
38 if test "x$MKDEP" = "x"; then
39     AC_MSG_ERROR([makedepend is required to build Mesa])
40 fi
41
42 dnl Our fallback install-sh is a symlink to minstall. Use the existing
43 dnl configuration in that case.
44 AC_PROG_INSTALL
45 test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)'
46
47 dnl We need a POSIX shell for parts of the build. Assume we have one
48 dnl in most cases.
49 case "$host_os" in
50 solaris*)
51     # Solaris /bin/sh is too old/non-POSIX compliant
52     AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
53     SHELL="$POSIX_SHELL"
54     ;;
55 esac
56
57 dnl clang is mostly GCC-compatible, but its version is much lower,
58 dnl so we have to check for it.
59 AC_MSG_CHECKING([if compiling with clang])
60
61 AC_COMPILE_IFELSE(
62 [AC_LANG_PROGRAM([], [[
63 #ifndef __clang__
64        not clang
65 #endif
66 ]])],
67 [CLANG=yes], [CLANG=no])
68
69 AC_MSG_RESULT([$CLANG])
70
71 dnl If we're using GCC, make sure that it is at least version 3.3.0.  Older
72 dnl versions are explictly not supported.
73 if test "x$GCC" = xyes -a "x$CLANG" = xno; then
74     AC_MSG_CHECKING([whether gcc version is sufficient])
75     major=0
76     minor=0
77
78     GCC_VERSION=`$CC -dumpversion`
79     if test $? -eq 0; then
80         major=`echo $GCC_VERSION | cut -d. -f1`
81         minor=`echo $GCC_VERSION | cut -d. -f1`
82     fi
83
84     if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then
85         AC_MSG_RESULT([no])
86         AC_MSG_ERROR([If using GCC, version 3.3.0 or later is required.])
87     else
88         AC_MSG_RESULT([yes])
89     fi
90 fi
91
92
93 MKDEP_OPTIONS=-fdepend
94 dnl Ask gcc where it's keeping its secret headers
95 if test "x$GCC" = xyes; then
96     for dir in include include-fixed; do
97         GCC_INCLUDES=`$CC -print-file-name=$dir`
98         if test "x$GCC_INCLUDES" != x && \
99            test "$GCC_INCLUDES" != "$dir" && \
100            test -d "$GCC_INCLUDES"; then
101             MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
102         fi
103     done
104 fi
105 AC_SUBST([MKDEP_OPTIONS])
106
107 dnl Make sure the pkg-config macros are defined
108 m4_ifndef([PKG_PROG_PKG_CONFIG],
109     [m4_fatal([Could not locate the pkg-config autoconf macros.
110   These are usually located in /usr/share/aclocal/pkg.m4. If your macros
111   are in a different location, try setting the environment variable
112   ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
113 PKG_PROG_PKG_CONFIG()
114
115 dnl LIB_DIR - library basename
116 LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
117 AC_SUBST([LIB_DIR])
118
119 dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
120 _SAVE_LDFLAGS="$LDFLAGS"
121 AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
122 AC_SUBST([EXTRA_LIB_PATH])
123
124 dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
125 _SAVE_CPPFLAGS="$CPPFLAGS"
126 AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
127 AC_SUBST([X11_INCLUDES])
128
129 dnl Compiler macros
130 DEFINES=""
131 AC_SUBST([DEFINES])
132 case "$host_os" in
133 linux*|*-gnu*|gnu*)
134     DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
135     ;;
136 solaris*)
137     DEFINES="$DEFINES -DPTHREADS -DSVR4"
138     ;;
139 cygwin*)
140     DEFINES="$DEFINES -DPTHREADS"
141     ;;
142 esac
143
144 dnl Add flags for gcc and g++
145 if test "x$GCC" = xyes; then
146     CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99"
147     if test "x$CLANG" = "xno"; then
148        CFLAGS="$CFLAGS -ffast-math"
149     fi
150
151     # Enable -fvisibility=hidden if using a gcc that supports it
152     save_CFLAGS="$CFLAGS"
153     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
154     VISIBILITY_CFLAGS="-fvisibility=hidden"
155     CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
156     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
157                    [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
158
159     # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
160     CFLAGS=$save_CFLAGS
161
162     # Work around aliasing bugs - developers should comment this out
163     CFLAGS="$CFLAGS -fno-strict-aliasing"
164 fi
165 if test "x$GXX" = xyes; then
166     CXXFLAGS="$CXXFLAGS -Wall"
167
168     # Enable -fvisibility=hidden if using a gcc that supports it
169     save_CXXFLAGS="$CXXFLAGS"
170     AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
171     VISIBILITY_CXXFLAGS="-fvisibility=hidden"
172     CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
173     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
174                    [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
175
176     # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
177     CXXFLAGS=$save_CXXFLAGS
178
179     # Work around aliasing bugs - developers should comment this out
180     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
181 fi
182
183 AC_SUBST([VISIBILITY_CFLAGS])
184 AC_SUBST([VISIBILITY_CXXFLAGS])
185
186 dnl These should be unnecessary, but let the user set them if they want
187 AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
188     Default is to use CFLAGS.])
189 AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
190     compiler. Default is to use CFLAGS.])
191 AC_SUBST([OPT_FLAGS])
192 AC_SUBST([ARCH_FLAGS])
193
194 dnl
195 dnl Hacks to enable 32 or 64 bit build
196 dnl
197 AC_ARG_ENABLE([32-bit],
198     [AS_HELP_STRING([--enable-32-bit],
199         [build 32-bit libraries @<:@default=auto@:>@])],
200     [enable_32bit="$enableval"],
201     [enable_32bit=auto]
202 )
203 if test "x$enable_32bit" = xyes; then
204     if test "x$GCC" = xyes; then
205         CFLAGS="$CFLAGS -m32"
206         ARCH_FLAGS="$ARCH_FLAGS -m32"
207     fi
208     if test "x$GXX" = xyes; then
209         CXXFLAGS="$CXXFLAGS -m32"
210     fi
211 fi
212 AC_ARG_ENABLE([64-bit],
213     [AS_HELP_STRING([--enable-64-bit],
214         [build 64-bit libraries @<:@default=auto@:>@])],
215     [enable_64bit="$enableval"],
216     [enable_64bit=auto]
217 )
218 if test "x$enable_64bit" = xyes; then
219     if test "x$GCC" = xyes; then
220         CFLAGS="$CFLAGS -m64"
221     fi
222     if test "x$GXX" = xyes; then
223         CXXFLAGS="$CXXFLAGS -m64"
224     fi
225 fi
226
227 dnl
228 dnl shared/static libraries, mimic libtool options
229 dnl
230 AC_ARG_ENABLE([static],
231     [AS_HELP_STRING([--enable-static],
232         [build static libraries @<:@default=disabled@:>@])],
233     [enable_static="$enableval"],
234     [enable_static=no]
235 )
236 case "x$enable_static" in
237 xyes|xno ) ;;
238 x ) enable_static=no ;;
239 * )
240     AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
241     ;;
242 esac
243 AC_ARG_ENABLE([shared],
244     [AS_HELP_STRING([--disable-shared],
245         [build shared libraries @<:@default=enabled@:>@])],
246     [enable_shared="$enableval"],
247     [enable_shared=yes]
248 )
249 case "x$enable_shared" in
250 xyes|xno ) ;;
251 x ) enable_shared=yes ;;
252 * )
253     AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
254     ;;
255 esac
256
257 dnl Can't have static and shared libraries, default to static if user
258 dnl explicitly requested. If both disabled, set to static since shared
259 dnl was explicitly requirested.
260 case "x$enable_static$enable_shared" in
261 xyesyes )
262     AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
263     enable_shared=no
264     ;;
265 xnono )
266     AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
267     enable_static=yes
268     ;;
269 esac
270
271 dnl
272 dnl mklib options
273 dnl
274 AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
275 if test "$enable_static" = yes; then
276     MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
277 fi
278 AC_SUBST([MKLIB_OPTIONS])
279
280 dnl
281 dnl other compiler options
282 dnl
283 AC_ARG_ENABLE([debug],
284     [AS_HELP_STRING([--enable-debug],
285         [use debug compiler flags and macros @<:@default=disabled@:>@])],
286     [enable_debug="$enableval"],
287     [enable_debug=no]
288 )
289 if test "x$enable_debug" = xyes; then
290     DEFINES="$DEFINES -DDEBUG"
291     if test "x$GCC" = xyes; then
292         CFLAGS="$CFLAGS -g"
293     fi
294     if test "x$GXX" = xyes; then
295         CXXFLAGS="$CXXFLAGS -g"
296     fi
297 fi
298
299 dnl
300 dnl library names
301 dnl
302 LIB_PREFIX_GLOB='lib'
303 LIB_VERSION_SEPARATOR='.'
304 if test "$enable_static" = yes; then
305     LIB_EXTENSION='a'
306 else
307     case "$host_os" in
308     darwin* )
309         LIB_EXTENSION='dylib' ;;
310     cygwin* )
311         dnl prefix can be 'cyg' or 'lib'
312         LIB_PREFIX_GLOB='???'
313         LIB_VERSION_SEPARATOR='-'
314         LIB_EXTENSION='dll' ;;
315     aix* )
316         LIB_EXTENSION='a' ;;
317     * )
318         LIB_EXTENSION='so' ;;
319     esac
320 fi
321
322 GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
323 GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
324 GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
325 GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
326 OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
327 EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
328 GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION}
329 GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION}
330 VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION}
331 GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION}
332 WAYLAND_EGL_LIB_NAME='lib$(WAYLAND_EGL_LIB).'${LIB_EXTENSION}
333
334 GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
335 GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
336 GLUT_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLUT_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
337 GLW_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLW_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
338 OSMESA_LIB_GLOB=${LIB_PREFIX_GLOB}'$(OSMESA_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
339 EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
340 EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
341 GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
342 GLESv2_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv2_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
343 VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
344 GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
345 WAYLAND_EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(WAYLAND_EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
346
347 AC_SUBST([GL_LIB_NAME])
348 AC_SUBST([GLU_LIB_NAME])
349 AC_SUBST([GLUT_LIB_NAME])
350 AC_SUBST([GLW_LIB_NAME])
351 AC_SUBST([OSMESA_LIB_NAME])
352 AC_SUBST([EGL_LIB_NAME])
353 AC_SUBST([GLESv1_CM_LIB_NAME])
354 AC_SUBST([GLESv2_LIB_NAME])
355 AC_SUBST([VG_LIB_NAME])
356 AC_SUBST([GLAPI_LIB_NAME])
357 AC_SUBST([WAYLAND_EGL_LIB_NAME])
358
359 AC_SUBST([GL_LIB_GLOB])
360 AC_SUBST([GLU_LIB_GLOB])
361 AC_SUBST([GLUT_LIB_GLOB])
362 AC_SUBST([GLW_LIB_GLOB])
363 AC_SUBST([OSMESA_LIB_GLOB])
364 AC_SUBST([EGL_LIB_GLOB])
365 AC_SUBST([GLESv1_CM_LIB_GLOB])
366 AC_SUBST([GLESv2_LIB_GLOB])
367 AC_SUBST([VG_LIB_GLOB])
368 AC_SUBST([GLAPI_LIB_GLOB])
369 AC_SUBST([WAYLAND_EGL_LIB_GLOB])
370
371 dnl
372 dnl Arch/platform-specific settings
373 dnl
374 AC_ARG_ENABLE([asm],
375     [AS_HELP_STRING([--disable-asm],
376         [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
377     [enable_asm="$enableval"],
378     [enable_asm=yes]
379 )
380 asm_arch=""
381 ASM_FLAGS=""
382 MESA_ASM_SOURCES=""
383 GLAPI_ASM_SOURCES=""
384 AC_MSG_CHECKING([whether to enable assembly])
385 test "x$enable_asm" = xno && AC_MSG_RESULT([no])
386 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
387 if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
388     case "$host_cpu" in
389     i?86 | x86_64)
390         enable_asm=no
391         AC_MSG_RESULT([no, cross compiling])
392         ;;
393     esac
394 fi
395 # check for supported arches
396 if test "x$enable_asm" = xyes; then
397     case "$host_cpu" in
398     i?86)
399         case "$host_os" in
400         linux* | *freebsd* | dragonfly* | *netbsd*)
401             test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
402             ;;
403         esac
404         ;;
405     x86_64)
406         case "$host_os" in
407         linux* | *freebsd* | dragonfly* | *netbsd*)
408             test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
409             ;;
410         esac
411         ;;
412     powerpc)
413         case "$host_os" in
414         linux*)
415             asm_arch=ppc
416             ;;
417         esac
418         ;;
419     sparc*)
420         case "$host_os" in
421         linux*)
422             asm_arch=sparc
423             ;;
424         esac
425         ;;
426     esac
427
428     case "$asm_arch" in
429     x86)
430         ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
431         MESA_ASM_SOURCES='$(X86_SOURCES)'
432         GLAPI_ASM_SOURCES='$(X86_API)'
433         AC_MSG_RESULT([yes, x86])
434         ;;
435     x86_64)
436         ASM_FLAGS="-DUSE_X86_64_ASM"
437         MESA_ASM_SOURCES='$(X86-64_SOURCES)'
438         GLAPI_ASM_SOURCES='$(X86-64_API)'
439         AC_MSG_RESULT([yes, x86_64])
440         ;;
441     ppc)
442         ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
443         MESA_ASM_SOURCES='$(PPC_SOURCES)'
444         AC_MSG_RESULT([yes, ppc])
445         ;;
446     sparc)
447         ASM_FLAGS="-DUSE_SPARC_ASM"
448         MESA_ASM_SOURCES='$(SPARC_SOURCES)'
449         GLAPI_ASM_SOURCES='$(SPARC_API)'
450         AC_MSG_RESULT([yes, sparc])
451         ;;
452     *)
453         AC_MSG_RESULT([no, platform not supported])
454         ;;
455     esac
456 fi
457 AC_SUBST([ASM_FLAGS])
458 AC_SUBST([MESA_ASM_SOURCES])
459 AC_SUBST([GLAPI_ASM_SOURCES])
460
461 dnl PIC code macro
462 MESA_PIC_FLAGS
463
464 dnl Check to see if dlopen is in default libraries (like Solaris, which
465 dnl has it in libc), or if libdl is needed to get it.
466 AC_CHECK_FUNC([dlopen], [],
467     [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
468 AC_SUBST([DLOPEN_LIBS])
469
470 dnl See if posix_memalign is available
471 AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
472
473 dnl SELinux awareness.
474 AC_ARG_ENABLE([selinux],
475     [AS_HELP_STRING([--enable-selinux],
476         [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
477     [MESA_SELINUX="$enableval"],
478     [MESA_SELINUX=no])
479 if test "x$enable_selinux" = "xyes"; then
480     AC_CHECK_HEADER([selinux/selinux.h],[],
481                     [AC_MSG_ERROR([SELinux headers not found])])
482     AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
483                  [AC_MSG_ERROR([SELinux library not found])])
484     SELINUX_LIBS="-lselinux"
485     DEFINES="$DEFINES -DMESA_SELINUX"
486 fi
487
488 dnl Determine which APIs to support
489 AC_ARG_ENABLE([opengl],
490     [AS_HELP_STRING([--disable-opengl],
491         [disable support for standard OpenGL API @<:@default=no@:>@])],
492     [enable_opengl="$enableval"],
493     [enable_opengl=yes])
494 AC_ARG_ENABLE([gles1],
495     [AS_HELP_STRING([--enable-gles1],
496         [enable support for OpenGL ES 1.x API @<:@default=no@:>@])],
497     [enable_gles1="$enableval"],
498     [enable_gles1=no])
499 AC_ARG_ENABLE([gles2],
500     [AS_HELP_STRING([--enable-gles2],
501         [enable support for OpenGL ES 2.x API @<:@default=no@:>@])],
502     [enable_gles2="$enableval"],
503     [enable_gles2=no])
504 AC_ARG_ENABLE([gles-overlay],
505     [AS_HELP_STRING([--enable-gles-overlay],
506         [DEPRECATED.  Same as --enable-gles1 and --enable-gles2])],
507     [enable_gles1="$enableval"; enable_gles2="$enableval"],
508     [])
509
510 AC_ARG_ENABLE([openvg],
511     [AS_HELP_STRING([--enable-openvg],
512         [enable support for OpenVG API @<:@default=no@:>@])],
513     [enable_openvg="$enableval"],
514     [enable_openvg=no])
515
516 dnl smooth the transition; should be removed eventually
517 if test "x$enable_openvg" = xno; then
518     case "x$with_state_trackers" in
519     x*vega*)
520         AC_MSG_WARN([vega state tracker is enabled without --enable-openvg])
521         enable_openvg=yes
522         ;;
523     esac
524 fi
525
526 if test "x$enable_opengl" = xno -a \
527         "x$enable_gles1" = xno -a \
528         "x$enable_gles2" = xno -a \
529         "x$enable_openvg" = xno; then
530     AC_MSG_ERROR([at least one API should be enabled])
531 fi
532
533 API_DEFINES=""
534 if test "x$enable_opengl" = xno; then
535     API_DEFINES="$API_DEFINES -DFEATURE_GL=0"
536 else
537     API_DEFINES="$API_DEFINES -DFEATURE_GL=1"
538 fi
539 if test "x$enable_gles1" = xyes; then
540     API_DEFINES="$API_DEFINES -DFEATURE_ES1=1"
541 fi
542 if test "x$enable_gles2" = xyes; then
543     API_DEFINES="$API_DEFINES -DFEATURE_ES2=1"
544 fi
545 AC_SUBST([API_DEFINES])
546
547 AC_ARG_ENABLE([shared-glapi],
548     [AS_HELP_STRING([--enable-shared-glapi],
549         [EXPERIMENTAL.  Enable shared glapi for OpenGL @<:@default=no@:>@])],
550     [enable_shared_glapi="$enableval"],
551     [enable_shared_glapi=no])
552
553 SHARED_GLAPI="0"
554 if test "x$enable_shared_glapi" = xyes; then
555     SHARED_GLAPI="1"
556 fi
557 AC_SUBST([SHARED_GLAPI])
558
559 dnl
560 dnl Driver configuration. Options are xlib, dri and osmesa right now.
561 dnl More later: fbdev, ...
562 dnl
563 default_driver="xlib"
564
565 case "$host_os" in
566 linux*)
567     case "$host_cpu" in
568     i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
569     esac
570     ;;
571 *freebsd* | dragonfly* | *netbsd*)
572     case "$host_cpu" in
573     i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
574     esac
575     ;;
576 esac
577
578 if test "x$enable_opengl" = xno; then
579     default_driver="no"
580 fi
581
582 AC_ARG_WITH([driver],
583     [AS_HELP_STRING([--with-driver=DRIVER],
584         [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
585     [mesa_driver="$withval"],
586     [mesa_driver="$default_driver"])
587 dnl Check for valid option
588 case "x$mesa_driver" in
589 xxlib|xdri|xosmesa)
590     if test "x$enable_opengl" = xno; then
591         AC_MSG_ERROR([Driver '$mesa_driver' requires OpenGL enabled])
592     fi
593     ;;
594 xno)
595     ;;
596 *)
597     AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
598     ;;
599 esac
600
601 dnl
602 dnl Driver specific build directories
603 dnl
604
605 dnl this variable will be prepended to SRC_DIRS and is not exported
606 CORE_DIRS=""
607
608 SRC_DIRS=""
609 GLU_DIRS="sgi"
610 GALLIUM_DIRS="auxiliary drivers state_trackers"
611 GALLIUM_TARGET_DIRS=""
612 GALLIUM_WINSYS_DIRS="sw"
613 GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity"
614 GALLIUM_STATE_TRACKERS_DIRS=""
615
616 # build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled
617 case "x$enable_shared_glapi$enable_gles1$enable_gles2" in
618 x*yes*)
619     CORE_DIRS="$CORE_DIRS mapi/shared-glapi"
620     ;;
621 esac
622
623 # build glapi if OpenGL is enabled
624 if test "x$enable_opengl" = xyes; then
625     CORE_DIRS="$CORE_DIRS mapi/glapi"
626 fi
627
628 # build es1api if OpenGL ES 1.x is enabled
629 if test "x$enable_gles1" = xyes; then
630     CORE_DIRS="$CORE_DIRS mapi/es1api"
631 fi
632
633 # build es2api if OpenGL ES 2.x is enabled
634 if test "x$enable_gles2" = xyes; then
635     CORE_DIRS="$CORE_DIRS mapi/es2api"
636 fi
637
638 # build vgapi if OpenVG is enabled
639 if test "x$enable_openvg" = xyes; then
640     CORE_DIRS="$CORE_DIRS mapi/vgapi"
641 fi
642
643 # build glsl and mesa if OpenGL or OpenGL ES is enabled
644 case "x$enable_opengl$enable_gles1$enable_gles2" in
645 x*yes*)
646     CORE_DIRS="$CORE_DIRS glsl mesa"
647     ;;
648 esac
649
650 case "$mesa_driver" in
651 xlib)
652     DRIVER_DIRS="x11"
653     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
654     GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib"
655     ;;
656 dri)
657     SRC_DIRS="$SRC_DIRS glx"
658     DRIVER_DIRS="dri"
659     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri"
660     ;;
661 osmesa)
662     DRIVER_DIRS="osmesa"
663     ;;
664 no)
665     DRIVER_DRIS=""
666     ;;
667 esac
668 AC_SUBST([SRC_DIRS])
669 AC_SUBST([GLU_DIRS])
670 AC_SUBST([DRIVER_DIRS])
671 AC_SUBST([GALLIUM_DIRS])
672 AC_SUBST([GALLIUM_TARGET_DIRS])
673 AC_SUBST([GALLIUM_WINSYS_DIRS])
674 AC_SUBST([GALLIUM_DRIVERS_DIRS])
675 AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
676 AC_SUBST([MESA_LLVM])
677
678 dnl
679 dnl Find out if X is available. The variable have_x is set if libX11 is
680 dnl found to mimic AC_PATH_XTRA.
681 dnl
682 if test -n "$PKG_CONFIG"; then
683     AC_MSG_CHECKING([pkg-config files for X11 are available])
684     PKG_CHECK_EXISTS([x11],[
685         x11_pkgconfig=yes
686         have_x=yes
687         ],[
688         x11_pkgconfig=no
689     ])
690     AC_MSG_RESULT([$x11_pkgconfig])
691 else
692     x11_pkgconfig=no
693 fi
694 dnl Use the autoconf macro if no pkg-config files
695 if test "$x11_pkgconfig" = yes; then
696     PKG_CHECK_MODULES([X11], [x11])
697 else
698     AC_PATH_XTRA
699     test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS"
700     test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11"
701     AC_SUBST([X11_CFLAGS])
702     AC_SUBST([X11_LIBS])
703 fi
704
705 dnl Try to tell the user that the --x-* options are only used when
706 dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
707 m4_divert_once([HELP_BEGIN],
708 [These options are only used when the X libraries cannot be found by the
709 pkg-config utility.])
710
711 dnl We need X for xlib and dri, so bomb now if it's not found
712 case "$mesa_driver" in
713 xlib|dri)
714     if test "$no_x" = yes; then
715         AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
716     fi
717     ;;
718 esac
719
720 dnl XCB - this is only used for GLX right now
721 AC_ARG_ENABLE([xcb],
722     [AS_HELP_STRING([--enable-xcb],
723         [use XCB for GLX @<:@default=disabled@:>@])],
724     [enable_xcb="$enableval"],
725     [enable_xcb=no])
726 if test "x$enable_xcb" = xyes; then
727     DEFINES="$DEFINES -DUSE_XCB"
728 else
729     enable_xcb=no
730 fi
731
732 dnl
733 dnl libGL configuration per driver
734 dnl
735 case "$mesa_driver" in
736 xlib)
737     if test "$x11_pkgconfig" = yes; then
738         PKG_CHECK_MODULES([XLIBGL], [x11 xext])
739         GL_PC_REQ_PRIV="x11 xext"
740         X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
741         GL_LIB_DEPS="$XLIBGL_LIBS"
742     else
743         # should check these...
744         X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
745         GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
746         GL_PC_LIB_PRIV="$GL_LIB_DEPS"
747         GL_PC_CFLAGS="$X11_INCLUDES"
748     fi
749     GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
750     GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread"
751
752     # if static, move the external libraries to the programs
753     # and empty the libraries for libGL
754     if test "$enable_static" = yes; then
755         APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
756         GL_LIB_DEPS=""
757     fi
758     ;;
759 dri|no) # these checks are still desired when there is no mesa_driver
760     # DRI must be shared, I think
761     if test "$enable_static" = yes; then
762         AC_MSG_ERROR([Can't use static libraries for DRI drivers])
763     fi
764
765     # Check for libdrm
766     PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
767     PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
768     PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
769     GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED glproto >= $GLPROTO_REQUIRED"
770     DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
771
772     # find the DRI deps for libGL
773     if test "$x11_pkgconfig" = yes; then
774         dri_modules="x11 xext xdamage xfixes"
775
776         # add xf86vidmode if available
777         PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no)
778         if test "$HAVE_XF86VIDMODE" = yes ; then
779             dri_modules="$dri_modules xxf86vm"
780         fi
781
782         # add xcb modules if necessary
783         if test "$enable_xcb" = yes; then
784             dri_modules="$dri_modules x11-xcb xcb-glx"
785         fi
786
787         PKG_CHECK_MODULES([DRIGL], [$dri_modules])
788         GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
789         X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
790         GL_LIB_DEPS="$DRIGL_LIBS"
791     else
792         # should check these...
793         X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
794         GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
795         GL_PC_LIB_PRIV="$GL_LIB_DEPS"
796         GL_PC_CFLAGS="$X11_INCLUDES"
797
798         # XCB can only be used from pkg-config
799         if test "$enable_xcb" = yes; then
800             PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
801             GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
802             X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
803             GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
804         fi
805     fi
806
807     # need DRM libs, -lpthread, etc.
808     GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
809     GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
810     GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
811     GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
812     GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
813     GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
814     ;;
815 osmesa)
816     # No libGL for osmesa
817     GL_LIB_DEPS=""
818     ;;
819 esac
820 AC_SUBST([GL_LIB_DEPS])
821 AC_SUBST([GL_PC_REQ_PRIV])
822 AC_SUBST([GL_PC_LIB_PRIV])
823 AC_SUBST([GL_PC_CFLAGS])
824 AC_SUBST([DRI_PC_REQ_PRIV])
825 AC_SUBST([GLESv1_CM_LIB_DEPS])
826 AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
827 AC_SUBST([GLESv2_LIB_DEPS])
828 AC_SUBST([GLESv2_PC_LIB_PRIV])
829
830 GLAPI_LIB_DEPS="-lpthread"
831 AC_SUBST([GLAPI_LIB_DEPS])
832
833
834 dnl Setup default DRI CFLAGS
835 DRI_CFLAGS='$(CFLAGS)'
836 DRI_CXXFLAGS='$(CXXFLAGS)'
837 DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a'
838 MESA_MODULES='$(TOP)/src/mesa/libmesa.a'
839
840 AC_ARG_ENABLE([shared-dricore],
841     [AS_HELP_STRING([--enable-shared-dricore],
842         [link DRI modules with shared core DRI routines @<:@default=disabled@:>@])],
843     [enable_dricore="$enableval"],
844     [enable_dricore=no])
845 if test "$mesa_driver" = dri ; then
846    if test "$enable_dricore" = yes ; then
847       if test "$GCC$GXX" != yesyes ; then
848          AC_MSG_WARN([Shared dricore requires GCC-compatible rpath handling.  Disabling shared dricore])
849          enable_dricore=no
850       else
851          DRICORE_GLSL_LIBS='$(TOP)/$(LIB_DIR)/libglsl.so'
852          DRICORE_LIBS='$(TOP)/$(LIB_DIR)/libdricore.so'
853          DRICORE_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -lglsl'
854          DRI_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -ldricore -lglsl'
855          DRI_CFLAGS='$(CFLAGS_NOVISIBILITY) -DUSE_DRICORE'
856          DRI_CXXFLAGS='$(CXXFLAGS_NOVISIBILITY) -DUSE_DRICORE'
857          MESA_MODULES='$(DRICORE_LIBS) $(DRICORE_GLSL_LIBS)'
858       fi
859    fi
860 fi
861 AC_SUBST([DRICORE_LIBS])
862 AC_SUBST([DRICORE_GLSL_LIBS])
863 AC_SUBST([DRICORE_LIB_DEPS])
864 AC_SUBST([DRI_CXXFLAGS])
865 AC_SUBST([DRI_CFLAGS])
866 AC_SUBST([MESA_MODULES])
867
868 AC_SUBST([HAVE_XF86VIDMODE])
869
870 PKG_CHECK_MODULES([LIBDRM_RADEON],
871                   [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED],
872                   HAVE_LIBDRM_RADEON=yes,
873                   HAVE_LIBDRM_RADEON=no)
874
875 dnl
876 dnl More X11 setup
877 dnl
878 if test "$mesa_driver" = xlib; then
879     DEFINES="$DEFINES -DUSE_XSHM"
880 fi
881
882 dnl
883 dnl TLS detection
884 dnl
885
886 AC_ARG_ENABLE([glx-tls],
887     [AS_HELP_STRING([--enable-glx-tls],
888         [enable TLS support in GLX @<:@default=disabled@:>@])],
889     [GLX_USE_TLS="$enableval"],
890     [GLX_USE_TLS=no])
891 AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
892
893 dnl
894 dnl More DRI setup
895 dnl
896 dnl Directory for DRI drivers
897 AC_ARG_WITH([dri-driverdir],
898     [AS_HELP_STRING([--with-dri-driverdir=DIR],
899         [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
900     [DRI_DRIVER_INSTALL_DIR="$withval"],
901     [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
902 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
903 dnl Extra search path for DRI drivers
904 AC_ARG_WITH([dri-searchpath],
905     [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
906         [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
907     [DRI_DRIVER_SEARCH_DIR="$withval"],
908     [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
909 AC_SUBST([DRI_DRIVER_SEARCH_DIR])
910 dnl Direct rendering or just indirect rendering
911 AC_ARG_ENABLE([driglx-direct],
912     [AS_HELP_STRING([--disable-driglx-direct],
913         [enable direct rendering in GLX and EGL for DRI @<:@default=enabled@:>@])],
914     [driglx_direct="$enableval"],
915     [driglx_direct="yes"])
916 dnl Which drivers to build - default is chosen by platform
917 AC_ARG_WITH([dri-drivers],
918     [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
919         [comma delimited DRI drivers list, e.g.
920         "swrast,i965,radeon" @<:@default=auto@:>@])],
921     [with_dri_drivers="$withval"],
922     [with_dri_drivers=yes])
923 if test "x$with_dri_drivers" = x; then
924     with_dri_drivers=no
925 fi
926
927 dnl If $with_dri_drivers is yes, directories will be added through
928 dnl platform checks
929 DRI_DIRS=""
930 case "$with_dri_drivers" in
931 no) ;;
932 yes)
933     DRI_DIRS="yes"
934     ;;
935 *)
936     # verify the requested driver directories exist
937     dri_drivers=`IFS=', '; echo $with_dri_drivers`
938     for driver in $dri_drivers; do
939         test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
940             AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
941     done
942     DRI_DIRS="$dri_drivers"
943     ;;
944 esac
945
946 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
947 if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
948     # Use TLS in GLX?
949     if test "x$GLX_USE_TLS" = xyes; then
950         DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
951     fi
952
953     # Platform specific settings and drivers to build
954     case "$host_os" in
955     linux*)
956         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
957         if test "x$driglx_direct" = xyes; then
958             DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
959         fi
960         DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
961
962         case "$host_cpu" in
963         x86_64)
964             # sis is missing because they have not be converted to use
965             # the new interface.  i810 are missing because there is no
966             # x86-64 system where they could *ever* be used.
967             if test "x$DRI_DIRS" = "xyes"; then
968                 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \
969                     savage tdfx unichrome swrast"
970             fi
971             ;;
972         powerpc*)
973             # Build only the drivers for cards that exist on PowerPC.
974             # At some point MGA will be added, but not yet.
975             if test "x$DRI_DIRS" = "xyes"; then
976                 DRI_DIRS="mach64 r128 r200 r300 r600 radeon tdfx swrast"
977             fi
978             ;;
979         sparc*)
980             # Build only the drivers for cards that exist on sparc`
981             if test "x$DRI_DIRS" = "xyes"; then
982                 DRI_DIRS="mach64 r128 r200 r300 r600 radeon swrast"
983             fi
984             ;;
985         esac
986         ;;
987     freebsd* | dragonfly* | *netbsd*)
988         DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
989         DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
990         DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
991         if test "x$driglx_direct" = xyes; then
992             DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
993         fi
994
995         if test "x$DRI_DIRS" = "xyes"; then
996             DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \
997                 unichrome savage sis swrast"
998         fi
999         ;;
1000     gnu*)
1001         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
1002         DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
1003         ;;
1004     solaris*)
1005         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
1006         DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
1007         if test "x$driglx_direct" = xyes; then
1008             DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
1009         fi
1010         ;;
1011     esac
1012
1013     # default drivers
1014     if test "x$DRI_DIRS" = "xyes"; then
1015         DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
1016             savage sis tdfx unichrome swrast"
1017     fi
1018
1019     DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`
1020
1021     # Check for expat
1022     if test "$mesa_driver" = dri; then
1023         EXPAT_INCLUDES=""
1024         EXPAT_LIB=-lexpat
1025         AC_ARG_WITH([expat],
1026             [AS_HELP_STRING([--with-expat=DIR],
1027                 [expat install directory])],[
1028             EXPAT_INCLUDES="-I$withval/include"
1029             CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
1030             LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
1031             EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
1032             ])
1033         AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
1034         AC_CHECK_LIB([expat],[XML_ParserCreate],[],
1035             [AC_MSG_ERROR([Expat required for DRI.])])
1036     fi
1037
1038     # put all the necessary libs together, including possibly libdricore
1039     DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
1040 fi
1041 AC_SUBST([DRI_DIRS])
1042 AC_SUBST([EXPAT_INCLUDES])
1043 AC_SUBST([DRI_LIB_DEPS])
1044
1045 case $DRI_DIRS in
1046 *i915*|*i965*)
1047     PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
1048     ;;
1049 esac
1050
1051 case $DRI_DIRS in
1052 *radeon*|*r200*|*r300*|*r600*)
1053     if test "x$HAVE_LIBDRM_RADEON" = xyes; then
1054         RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
1055         RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS
1056     fi
1057     ;;
1058 esac
1059 AC_SUBST([RADEON_CFLAGS])
1060 AC_SUBST([RADEON_LDFLAGS])
1061
1062
1063 dnl
1064 dnl OSMesa configuration
1065 dnl
1066 if test "$mesa_driver" = xlib; then
1067     default_gl_osmesa=yes
1068 else
1069     default_gl_osmesa=no
1070 fi
1071 AC_ARG_ENABLE([gl-osmesa],
1072     [AS_HELP_STRING([--enable-gl-osmesa],
1073         [enable OSMesa with libGL @<:@default=enabled for xlib driver@:>@])],
1074     [gl_osmesa="$enableval"],
1075     [gl_osmesa="$default_gl_osmesa"])
1076 if test "x$gl_osmesa" = xyes; then
1077     if test "x$enable_opengl" = xno; then
1078         AC_MSG_ERROR([OpenGL is not available for OSMesa driver])
1079     fi
1080     if test "$mesa_driver" = osmesa; then
1081         AC_MSG_ERROR([libGL is not available for OSMesa driver])
1082     else
1083         DRIVER_DIRS="$DRIVER_DIRS osmesa"
1084     fi
1085 fi
1086
1087 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
1088 AC_ARG_WITH([osmesa-bits],
1089     [AS_HELP_STRING([--with-osmesa-bits=BITS],
1090         [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
1091     [osmesa_bits="$withval"],
1092     [osmesa_bits=8])
1093 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
1094     AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
1095     osmesa_bits=8
1096 fi
1097 case "x$osmesa_bits" in
1098 x8)
1099     OSMESA_LIB=OSMesa
1100     ;;
1101 x16|x32)
1102     OSMESA_LIB="OSMesa$osmesa_bits"
1103     DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
1104     ;;
1105 *)
1106     AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
1107     ;;
1108 esac
1109 AC_SUBST([OSMESA_LIB])
1110
1111 case "$DRIVER_DIRS" in
1112 *osmesa*)
1113     # only link libraries with osmesa if shared
1114     if test "$enable_static" = no; then
1115         OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
1116     else
1117         OSMESA_LIB_DEPS=""
1118     fi
1119     OSMESA_MESA_DEPS=""
1120     OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
1121     ;;
1122 esac
1123 AC_SUBST([OSMESA_LIB_DEPS])
1124 AC_SUBST([OSMESA_MESA_DEPS])
1125 AC_SUBST([OSMESA_PC_REQ])
1126 AC_SUBST([OSMESA_PC_LIB_PRIV])
1127
1128 dnl
1129 dnl EGL configuration
1130 dnl
1131 AC_ARG_ENABLE([egl],
1132     [AS_HELP_STRING([--disable-egl],
1133         [disable EGL library @<:@default=enabled@:>@])],
1134     [enable_egl="$enableval"],
1135     [enable_egl=yes])
1136 if test "x$enable_egl" = xno; then
1137     if test "x$mesa_driver" = xno; then
1138         AC_MSG_ERROR([cannot disable EGL when there is no mesa driver])
1139     fi
1140     if test "x$enable_openvg" = xyes; then
1141         AC_MSG_ERROR([cannot enable OpenVG without EGL])
1142     fi
1143 fi
1144 if test "x$enable_egl" = xyes; then
1145     SRC_DIRS="$SRC_DIRS egl"
1146     EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread"
1147     EGL_DRIVERS_DIRS=""
1148     if test "$enable_static" != yes; then
1149         # build egl_glx when libGL is built
1150         if test "$mesa_driver" = xlib -o "$mesa_driver" = dri; then
1151             EGL_DRIVERS_DIRS="glx"
1152         fi
1153
1154         if test "$mesa_driver" = dri; then
1155             # build egl_dri2 when xcb-dri2 is available
1156             PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
1157                           [have_xcb_dri2=yes],[have_xcb_dri2=no])
1158             PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
1159                           [have_libudev=yes],[have_libudev=no])
1160             
1161             if test "$have_xcb_dri2" = yes; then
1162                 EGL_DRIVER_DRI2=dri2
1163                 DEFINES="$DEFINES -DHAVE_XCB_DRI2"
1164                 if test "$have_libudev" = yes; then
1165                     DEFINES="$DEFINES -DHAVE_LIBUDEV"
1166                 fi
1167             fi
1168         fi
1169
1170         EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS $EGL_DRIVER_DRI2"
1171     fi
1172 fi
1173 AC_SUBST([EGL_LIB_DEPS])
1174 AC_SUBST([EGL_DRIVERS_DIRS])
1175
1176 dnl
1177 dnl GLU configuration
1178 dnl
1179 AC_ARG_ENABLE([glu],
1180     [AS_HELP_STRING([--disable-glu],
1181         [enable OpenGL Utility library @<:@default=enabled@:>@])],
1182     [enable_glu="$enableval"],
1183     [enable_glu=yes])
1184
1185 if test "x$enable_glu" = xyes -a "x$mesa_driver" = xno; then
1186     AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver])
1187     enable_glu=no
1188 fi
1189
1190 if test "x$enable_glu" = xyes; then
1191     SRC_DIRS="$SRC_DIRS glu"
1192
1193     case "$mesa_driver" in
1194     osmesa)
1195         # Link libGLU to libOSMesa instead of libGL
1196         GLU_LIB_DEPS=""
1197         GLU_PC_REQ="osmesa"
1198         if test "$enable_static" = no; then
1199             GLU_MESA_DEPS='-l$(OSMESA_LIB)'
1200         else
1201             GLU_MESA_DEPS=""
1202         fi
1203         ;;
1204     *)
1205         # If static, empty GLU_LIB_DEPS and add libs for programs to link
1206         GLU_PC_REQ="gl"
1207         GLU_PC_LIB_PRIV="-lm"
1208         if test "$enable_static" = no; then
1209             GLU_LIB_DEPS="-lm"
1210             GLU_MESA_DEPS='-l$(GL_LIB)'
1211         else
1212             GLU_LIB_DEPS=""
1213             GLU_MESA_DEPS=""
1214             APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
1215         fi
1216         ;;
1217     esac
1218 fi
1219 if test "$enable_static" = no; then
1220     GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
1221 fi
1222 GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
1223 AC_SUBST([GLU_LIB_DEPS])
1224 AC_SUBST([GLU_MESA_DEPS])
1225 AC_SUBST([GLU_PC_REQ])
1226 AC_SUBST([GLU_PC_REQ_PRIV])
1227 AC_SUBST([GLU_PC_LIB_PRIV])
1228 AC_SUBST([GLU_PC_CFLAGS])
1229
1230 dnl
1231 dnl GLw configuration
1232 dnl
1233 AC_ARG_ENABLE([glw],
1234     [AS_HELP_STRING([--disable-glw],
1235         [enable Xt/Motif widget library @<:@default=enabled@:>@])],
1236     [enable_glw="$enableval"],
1237     [enable_glw=yes])
1238 dnl Don't build GLw on osmesa
1239 if test "x$enable_glw" = xyes; then
1240     case "$mesa_driver" in
1241     osmesa|no)
1242         AC_MSG_NOTICE([Disabling GLw since there is no OpenGL driver])
1243         enable_glw=no
1244         ;;
1245     esac
1246 fi
1247 AC_ARG_ENABLE([motif],
1248     [AS_HELP_STRING([--enable-motif],
1249         [use Motif widgets in GLw @<:@default=disabled@:>@])],
1250     [enable_motif="$enableval"],
1251     [enable_motif=no])
1252
1253 if test "x$enable_glw" = xyes; then
1254     SRC_DIRS="$SRC_DIRS glw"
1255     if test "$x11_pkgconfig" = yes; then
1256         PKG_CHECK_MODULES([GLW],[x11 xt])
1257         GLW_PC_REQ_PRIV="x11 xt"
1258         GLW_LIB_DEPS="$GLW_LIBS"
1259     else
1260         # should check these...
1261         GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
1262         GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
1263         GLW_PC_CFLAGS="$X11_INCLUDES"
1264     fi
1265
1266     GLW_SOURCES="GLwDrawA.c"
1267     MOTIF_CFLAGS=
1268     if test "x$enable_motif" = xyes; then
1269         GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
1270         AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
1271         if test "x$MOTIF_CONFIG" != xno; then
1272             MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
1273             MOTIF_LIBS=`$MOTIF_CONFIG --libs`
1274         else
1275             AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
1276                 [AC_MSG_ERROR([Can't locate Motif headers])])
1277             AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
1278                 [AC_MSG_ERROR([Can't locate Motif Xm library])])
1279         fi
1280         # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
1281         GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
1282         GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
1283         GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
1284     fi
1285
1286     # If static, empty GLW_LIB_DEPS and add libs for programs to link
1287     GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV"
1288     if test "$enable_static" = no; then
1289         GLW_MESA_DEPS='-l$(GL_LIB)'
1290         GLW_LIB_DEPS="$GLW_LIB_DEPS"
1291     else
1292         APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
1293         GLW_LIB_DEPS=""
1294         GLW_MESA_DEPS=""
1295     fi
1296 fi
1297 AC_SUBST([GLW_LIB_DEPS])
1298 AC_SUBST([GLW_MESA_DEPS])
1299 AC_SUBST([GLW_SOURCES])
1300 AC_SUBST([MOTIF_CFLAGS])
1301 AC_SUBST([GLW_PC_REQ_PRIV])
1302 AC_SUBST([GLW_PC_LIB_PRIV])
1303 AC_SUBST([GLW_PC_CFLAGS])
1304
1305 dnl
1306 dnl GLUT configuration
1307 dnl
1308 if test -f "$srcdir/include/GL/glut.h"; then
1309     default_glut=yes
1310 else
1311     default_glut=no
1312 fi
1313 AC_ARG_ENABLE([glut],
1314     [AS_HELP_STRING([--disable-glut],
1315         [enable GLUT library @<:@default=enabled if source available@:>@])],
1316     [enable_glut="$enableval"],
1317     [enable_glut="$default_glut"])
1318
1319 dnl Don't build glut on osmesa
1320 if test "x$enable_glut" = xyes; then
1321     case "$mesa_driver" in
1322     osmesa|no)
1323         AC_MSG_NOTICE([Disabling glut since there is no OpenGL driver])
1324         enable_glut=no
1325         ;;
1326     esac
1327 fi
1328 dnl Can't build glut if GLU not available
1329 if test "x$enable_glu$enable_glut" = xnoyes; then
1330     AC_MSG_WARN([Disabling glut since GLU is disabled])
1331     enable_glut=no
1332 fi
1333
1334 if test "x$enable_glut" = xyes; then
1335     SRC_DIRS="$SRC_DIRS glut/glx"
1336     if test "$x11_pkgconfig" = yes; then
1337         PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
1338         GLUT_PC_REQ_PRIV="x11 xmu xi"
1339         GLUT_LIB_DEPS="$GLUT_LIBS"
1340     else
1341         # should check these...
1342         GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
1343         GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
1344         GLUT_PC_CFLAGS="$X11_INCLUDES"
1345     fi
1346     if test "x$GCC" = xyes; then
1347         GLUT_CFLAGS="$GLUT_CFLAGS -fexceptions"
1348     fi
1349     GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
1350     GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm"
1351
1352     # If static, empty GLUT_LIB_DEPS and add libs for programs to link
1353     if test "$enable_static" = no; then
1354         GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
1355     else
1356         APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
1357         GLUT_LIB_DEPS=""
1358         GLUT_MESA_DEPS=""
1359     fi
1360 fi
1361 AC_SUBST([GLUT_LIB_DEPS])
1362 AC_SUBST([GLUT_MESA_DEPS])
1363 AC_SUBST([GLUT_CFLAGS])
1364 AC_SUBST([GLUT_PC_REQ_PRIV])
1365 AC_SUBST([GLUT_PC_LIB_PRIV])
1366 AC_SUBST([GLUT_PC_CFLAGS])
1367
1368 dnl
1369 dnl Program library dependencies
1370 dnl    Only libm is added here if necessary as the libraries should
1371 dnl    be pulled in by the linker
1372 dnl
1373 if test "x$APP_LIB_DEPS" = x; then
1374     case "$host_os" in
1375     solaris*)
1376         APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
1377         ;;
1378     cygwin*)
1379         APP_LIB_DEPS="-lX11"
1380         ;;
1381     *)
1382         APP_LIB_DEPS="-lm"
1383         ;;
1384     esac
1385 fi
1386 AC_SUBST([APP_LIB_DEPS])
1387 AC_SUBST([PROGRAM_DIRS])
1388
1389 dnl
1390 dnl Gallium configuration
1391 dnl
1392 AC_ARG_ENABLE([gallium],
1393     [AS_HELP_STRING([--disable-gallium],
1394         [build gallium @<:@default=enabled@:>@])],
1395     [enable_gallium="$enableval"],
1396     [enable_gallium=yes])
1397 if test "x$enable_gallium" = xno -a "x$enable_openvg" = xyes; then
1398     AC_MSG_ERROR([cannot enable OpenVG without Gallium])
1399 fi
1400 if test "x$enable_gallium" = xyes; then
1401     SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
1402     AC_CHECK_HEADER([udis86.h], [HAS_UDIS86="yes"],
1403                 [HAS_UDIS86="no"])
1404     AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
1405 fi
1406
1407 AC_SUBST([LLVM_CFLAGS])
1408 AC_SUBST([LLVM_LIBS])
1409 AC_SUBST([LLVM_LDFLAGS])
1410 AC_SUBST([LLVM_VERSION])
1411
1412 dnl
1413 dnl Gallium state trackers configuration
1414 dnl
1415
1416 AC_ARG_ENABLE([gallium-egl],
1417     [AS_HELP_STRING([--enable-gallium-egl],
1418         [enable gallium EGL state tracker @<:@default=auto@:>@])],
1419     [enable_gallium_egl="$enableval"],
1420     [enable_gallium_egl=auto])
1421 if test "x$enable_gallium_egl" = xauto; then
1422     case "$mesa_driver" in
1423     dri|no)
1424         enable_gallium_egl=$enable_egl
1425         ;;
1426     *)
1427         enable_gallium_egl=$enable_openvg
1428         ;;
1429     esac
1430 fi
1431 case "x$enable_egl$enable_gallium_egl" in
1432 xnoyes)
1433     AC_MSG_ERROR([cannot build Gallium EGL state tracker without EGL])
1434 esac
1435
1436 AC_ARG_WITH([state-trackers],
1437     [AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@],
1438         [comma delimited state_trackers list, e.g.
1439         "egl,glx" @<:@default=auto@:>@])],
1440     [with_state_trackers="$withval"],
1441     [with_state_trackers=yes])
1442
1443 case "$with_state_trackers" in
1444 no)
1445     GALLIUM_STATE_TRACKERS_DIRS=""
1446     ;;
1447 yes)
1448     # look at what else is built
1449     case "$mesa_driver" in
1450     xlib)
1451         GALLIUM_STATE_TRACKERS_DIRS=glx
1452         ;;
1453     dri)
1454         GALLIUM_STATE_TRACKERS_DIRS="dri"
1455         HAVE_ST_DRI="yes"
1456         # Have only tested st/xorg on 1.6.0 servers
1457         PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED],
1458             HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
1459             HAVE_ST_XORG="no")
1460         ;;
1461     esac
1462
1463     if test "x$enable_egl" = xyes; then
1464         if test "$enable_openvg" = yes; then
1465             GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vega"
1466             st_egl="yes"
1467         fi
1468
1469         if test "$enable_gallium_egl" = yes; then
1470             GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
1471             HAVE_ST_EGL="yes"
1472         fi
1473     fi
1474     ;;
1475 *)
1476     # verify the requested state tracker exist
1477     state_trackers=""
1478     _state_trackers=`IFS=', '; echo $with_state_trackers`
1479     for tracker in $_state_trackers; do
1480         case "$tracker" in
1481         dri)
1482             if test "x$mesa_driver" != xdri; then
1483                 AC_MSG_ERROR([cannot build dri state tracker without mesa driver set to dri])
1484             fi
1485             HAVE_ST_DRI="yes"
1486             ;;
1487         egl)
1488             if test "x$enable_egl" != xyes; then
1489                 AC_MSG_ERROR([cannot build egl state tracker without EGL library])
1490             fi
1491             HAVE_ST_EGL="yes"
1492             ;;
1493         xorg)
1494             PKG_CHECK_MODULES([XORG], [xorg-server >= 1.6.0])
1495             PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
1496             PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
1497             HAVE_ST_XORG="yes"
1498             ;;
1499         vega)
1500             if test "x$enable_openvg" != xyes; then
1501                 AC_MSG_ERROR([cannot build vega state tracker without --enable-openvg])
1502             fi
1503             have_st_vega="yes"
1504             ;;
1505         esac
1506
1507         if test -n "$tracker"; then
1508             test -d "$srcdir/src/gallium/state_trackers/$tracker" || \
1509                 AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
1510             if test -n "$state_trackers"; then
1511                 state_trackers="$state_trackers $tracker"
1512             else
1513                 state_trackers="$tracker"
1514             fi
1515         fi
1516     done
1517     GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
1518
1519     # append --enable-openvg/--enable-gallium-egl to --with-state-trackers
1520     if test "x$have_st_vega" != xyes -a "x$enable_openvg" = xyes; then
1521         AC_MSG_ERROR([--with-state-trackers specified but vega is missing])
1522     fi
1523     if test "x$HAVE_ST_EGL" != xyes -a "x$enable_gallium_egl" = xyes; then
1524         AC_MSG_ERROR([--with-state-trackers specified but egl is missing])
1525     fi
1526     ;;
1527 esac
1528
1529
1530 EGL_CLIENT_APIS=""
1531 VG_LIB_DEPS=""
1532
1533 case "x$enable_opengl$enable_gles1$enable_gles2" in
1534 x*yes*)
1535     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)'
1536     ;;
1537 esac
1538 if test "x$enable_openvg" = xyes; then
1539     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
1540     VG_LIB_DEPS="$VG_LIB_DEPS -lpthread"
1541 fi
1542
1543 AC_SUBST([VG_LIB_DEPS])
1544 AC_SUBST([EGL_CLIENT_APIS])
1545
1546 if test "x$HAVE_ST_EGL" = xyes; then
1547         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl"
1548 fi
1549
1550 if test "x$HAVE_ST_XORG" = xyes; then
1551     PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
1552         HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
1553         HAVE_XEXTPROTO_71="no")
1554 fi
1555
1556 AC_ARG_WITH([egl-platforms],
1557     [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
1558         [comma delimited native platforms libEGL supports, e.g.
1559         "x11,drm" @<:@default=auto@:>@])],
1560     [with_egl_platforms="$withval"],
1561     [with_egl_platforms=yes])
1562 AC_ARG_WITH([egl-displays],
1563     [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@],
1564         [DEPRECATED.  Use --with-egl-platforms instead])],
1565     [with_egl_platforms="$withval"])
1566
1567 EGL_PLATFORMS=""
1568 WAYLAND_EGL_LIB_DEPS=""
1569
1570 case "$with_egl_platforms" in
1571 yes)
1572     if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then
1573         EGL_PLATFORMS="x11"
1574         if test "$mesa_driver" = dri; then
1575             EGL_PLATFORMS="$EGL_PLATFORMS drm"
1576         fi
1577     fi
1578     ;;
1579 *)
1580     if test "x$enable_egl" != xyes; then
1581         AC_MSG_ERROR([cannot build egl state tracker without EGL library])
1582     fi
1583     # verify the requested driver directories exist
1584     egl_platforms=`IFS=', '; echo $with_egl_platforms`
1585     for plat in $egl_platforms; do
1586         test -d "$srcdir/src/gallium/state_trackers/egl/$plat" || \
1587             AC_MSG_ERROR([EGL platform '$plat' doesn't exist])
1588         if test "$plat" = "fbdev"; then
1589                 GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/fbdev"
1590         fi
1591         if test "$plat" = "wayland"; then
1592                 PKG_CHECK_MODULES([WAYLAND], [wayland-client],, \
1593                                   [AC_MSG_ERROR([cannot find libwayland-client])])
1594                 WAYLAND_EGL_LIB_DEPS="$WAYLAND_LIBS $LIBDRM_LIBS"
1595         fi
1596     done
1597     EGL_PLATFORMS="$egl_platforms"
1598     ;;
1599 esac
1600 AC_SUBST([EGL_PLATFORMS])
1601
1602 AC_SUBST([WAYLAND_EGL_LIB_DEPS])
1603 WAYLAND_EGL_PC_REQ_PRIV="wayland-client libdrm"
1604 WAYLAND_EGL_PC_LIB_PRIV=
1605 WAYLAND_EGL_PC_CFLAGS=
1606
1607 AC_SUBST([WAYLAND_EGL_PC_REQ_PRIV])
1608 AC_SUBST([WAYLAND_EGL_PC_LIB_PRIV])
1609 AC_SUBST([WAYLAND_EGL_PC_CFLAGS])
1610
1611
1612 AC_ARG_WITH([egl-driver-dir],
1613     [AS_HELP_STRING([--with-egl-driver-dir=DIR],
1614                     [directory for EGL drivers [[default=${libdir}/egl]]])],
1615     [EGL_DRIVER_INSTALL_DIR="$withval"],
1616     [EGL_DRIVER_INSTALL_DIR='${libdir}/egl'])
1617 AC_SUBST([EGL_DRIVER_INSTALL_DIR])
1618
1619 AC_ARG_WITH([xorg-driver-dir],
1620     [AS_HELP_STRING([--with-xorg-driver-dir=DIR],
1621                     [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])],
1622     [XORG_DRIVER_INSTALL_DIR="$withval"],
1623     [XORG_DRIVER_INSTALL_DIR="${libdir}/xorg/modules/drivers"])
1624 AC_SUBST([XORG_DRIVER_INSTALL_DIR])
1625
1626 AC_ARG_WITH([max-width],
1627     [AS_HELP_STRING([--with-max-width=N],
1628                     [Maximum framebuffer width (4096)])],
1629     [DEFINES="${DEFINES} -DMAX_WIDTH=${withval}";
1630      AS_IF([test "${withval}" -gt "4096"],
1631            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
1632 )
1633 AC_ARG_WITH([max-height],
1634     [AS_HELP_STRING([--with-max-height=N],
1635                     [Maximum framebuffer height (4096)])],
1636     [DEFINES="${DEFINES} -DMAX_HEIGHT=${withval}";
1637      AS_IF([test "${withval}" -gt "4096"],
1638            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
1639 )
1640
1641 dnl
1642 dnl Gallium LLVM
1643 dnl
1644 AC_ARG_ENABLE([gallium-llvm],
1645     [AS_HELP_STRING([--enable-gallium-llvm],
1646         [build gallium LLVM support @<:@default=disabled@:>@])],
1647     [enable_gallium_llvm="$enableval"],
1648     [enable_gallium_llvm=auto])
1649 if test "x$enable_gallium_llvm" = xyes; then
1650     if test "x$LLVM_CONFIG" != xno; then
1651         LLVM_VERSION=`$LLVM_CONFIG --version`
1652         LLVM_CFLAGS=`$LLVM_CONFIG --cppflags`
1653         LLVM_LIBS="`$LLVM_CONFIG --libs jit interpreter nativecodegen bitwriter` -lstdc++"
1654
1655         if test "x$HAS_UDIS86" != xno; then
1656             LLVM_LIBS="$LLVM_LIBS -ludis86"
1657             DEFINES="$DEFINES -DHAVE_UDIS86"
1658         fi
1659         LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
1660         GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
1661         DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS"
1662         MESA_LLVM=1
1663     else
1664         MESA_LLVM=0
1665     fi
1666 else
1667     MESA_LLVM=0
1668 fi
1669
1670 dnl
1671 dnl Gallium helper functions
1672 dnl
1673 gallium_check_st() {
1674     if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes; then
1675          GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1"
1676     fi
1677     if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then
1678          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2"
1679     fi
1680     if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then
1681          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
1682     fi
1683 }
1684
1685
1686 dnl
1687 dnl Gallium SVGA configuration
1688 dnl
1689 AC_ARG_ENABLE([gallium-svga],
1690     [AS_HELP_STRING([--enable-gallium-svga],
1691         [build gallium SVGA @<:@default=disabled@:>@])],
1692     [enable_gallium_svga="$enableval"],
1693     [enable_gallium_svga=auto])
1694 if test "x$enable_gallium_svga" = xyes; then
1695     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
1696     gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx"
1697 elif test "x$enable_gallium_svga" = xauto; then
1698     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
1699 fi
1700
1701 dnl
1702 dnl Gallium i915 configuration
1703 dnl
1704 AC_ARG_ENABLE([gallium-i915],
1705     [AS_HELP_STRING([--enable-gallium-i915],
1706         [build gallium i915 @<:@default=disabled@:>@])],
1707     [enable_gallium_i915="$enableval"],
1708     [enable_gallium_i915=auto])
1709 if test "x$enable_gallium_i915" = xyes; then
1710     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
1711     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
1712     gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
1713 elif test "x$enable_gallium_i915" = xauto; then
1714     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
1715     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
1716 fi
1717
1718 dnl
1719 dnl Gallium i965 configuration
1720 dnl
1721 AC_ARG_ENABLE([gallium-i965],
1722     [AS_HELP_STRING([--enable-gallium-i965],
1723         [build gallium i965 @<:@default=disabled@:>@])],
1724     [enable_gallium_i965="$enableval"],
1725     [enable_gallium_i965=auto])
1726 if test "x$enable_gallium_i965" = xyes; then
1727     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965"
1728     gallium_check_st "i965/drm" "dri-i965" "xorg-i965"
1729 elif test "x$enable_gallium_i965" = xauto; then
1730     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965"
1731 fi
1732
1733 dnl
1734 dnl Gallium Radeon r300g configuration
1735 dnl
1736 AC_ARG_ENABLE([gallium-radeon],
1737     [AS_HELP_STRING([--enable-gallium-radeon],
1738         [build gallium radeon @<:@default=disabled@:>@])],
1739     [enable_gallium_radeon="$enableval"],
1740     [enable_gallium_radeon=auto])
1741 if test "x$enable_gallium_radeon" = xauto; then
1742     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
1743     gallium_check_st "radeon/drm" "dri-r300"
1744 fi
1745 if test "x$enable_gallium_radeon" = xyes; then
1746     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
1747     gallium_check_st "radeon/drm" "dri-r300" "xorg-radeon"
1748 fi
1749
1750 dnl
1751 dnl Gallium Radeon r600g configuration
1752 dnl
1753 AC_ARG_ENABLE([gallium-r600],
1754     [AS_HELP_STRING([--enable-gallium-r600],
1755         [build gallium radeon @<:@default=disabled@:>@])],
1756     [enable_gallium_r600="$enableval"],
1757     [enable_gallium_r600=auto])
1758 if test "x$enable_gallium_r600" = xyes; then
1759     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
1760     gallium_check_st "r600/drm" "dri-r600"
1761 fi
1762
1763 dnl
1764 dnl Gallium Nouveau configuration
1765 dnl
1766 AC_ARG_ENABLE([gallium-nouveau],
1767     [AS_HELP_STRING([--enable-gallium-nouveau],
1768         [build gallium nouveau @<:@default=disabled@:>@])],
1769     [enable_gallium_nouveau="$enableval"],
1770     [enable_gallium_nouveau=no])
1771 if test "x$enable_gallium_nouveau" = xyes; then
1772     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0"
1773     gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau"
1774 fi
1775
1776 dnl
1777 dnl Gallium swrast configuration
1778 dnl
1779 AC_ARG_ENABLE([gallium-swrast],
1780     [AS_HELP_STRING([--enable-gallium-swrast],
1781         [build gallium swrast @<:@default=auto@:>@])],
1782     [enable_gallium_swrast="$enableval"],
1783     [enable_gallium_swrast=auto])
1784 if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then
1785     if test "x$HAVE_ST_DRI" = xyes; then
1786         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
1787     fi
1788 fi
1789
1790 dnl prepend CORE_DIRS to SRC_DIRS
1791 SRC_DIRS="$CORE_DIRS $SRC_DIRS"
1792
1793 dnl Restore LDFLAGS and CPPFLAGS
1794 LDFLAGS="$_SAVE_LDFLAGS"
1795 CPPFLAGS="$_SAVE_CPPFLAGS"
1796
1797 dnl Substitute the config
1798 AC_CONFIG_FILES([configs/autoconf])
1799
1800 dnl Replace the configs/current symlink
1801 AC_CONFIG_COMMANDS([configs],[
1802 if test -f configs/current || test -L configs/current; then
1803     rm -f configs/current
1804 fi
1805 ln -s autoconf configs/current
1806 ])
1807
1808 AC_OUTPUT
1809
1810 dnl
1811 dnl Output some configuration info for the user
1812 dnl
1813 echo ""
1814 echo "        prefix:          $prefix"
1815 echo "        exec_prefix:     $exec_prefix"
1816 echo "        libdir:          $libdir"
1817 echo "        includedir:      $includedir"
1818
1819 dnl API info
1820 echo ""
1821 echo "        OpenGL:          $enable_opengl (ES1: $enable_gles1 ES2: $enable_gles2)"
1822 echo "        OpenVG:          $enable_openvg"
1823
1824 dnl Driver info
1825 echo ""
1826 echo "        Driver:          $mesa_driver"
1827 if test "$mesa_driver" != no; then
1828     if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1829         echo "        OSMesa:          lib$OSMESA_LIB"
1830     else
1831         echo "        OSMesa:          no"
1832     fi
1833     if test "$mesa_driver" = dri; then
1834         # cleanup the drivers var
1835         dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
1836         if test "x$DRI_DIRS" = x; then
1837             echo "        DRI drivers:     no"
1838         else
1839             echo "        DRI drivers:     $dri_dirs"
1840         fi
1841         echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
1842         echo "        Use XCB:         $enable_xcb"
1843         echo "        Shared dricore:  $enable_dricore"
1844     fi
1845 fi
1846 echo ""
1847 echo "        GLU:             $enable_glu"
1848 echo "        GLw:             $enable_glw (Motif: $enable_motif)"
1849 echo "        glut:            $enable_glut"
1850
1851 dnl EGL
1852 echo ""
1853 echo "        EGL:             $enable_egl"
1854 if test "$enable_egl" = yes; then
1855     echo "        EGL platforms:   $EGL_PLATFORMS"
1856
1857     egl_drivers=""
1858     for d in $EGL_DRIVERS_DIRS; do
1859         egl_drivers="$egl_drivers builtin:egl_$d"
1860     done
1861
1862     if test "$enable_gallium" = yes -a "$HAVE_ST_EGL" = yes; then
1863         echo "        EGL drivers:    ${egl_drivers} egl_gallium"
1864         echo "        EGL Gallium STs:$EGL_CLIENT_APIS"
1865     else
1866         echo "        EGL drivers:    $egl_drivers"
1867     fi
1868 fi
1869
1870 echo ""
1871 if test "x$MESA_LLVM" = x1; then
1872     echo "        llvm:            yes"
1873     echo "        llvm-config:     $LLVM_CONFIG"
1874     echo "        llvm-version:    $LLVM_VERSION"
1875 else
1876     echo "        llvm:            no"
1877 fi
1878
1879 echo ""
1880 if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
1881     echo "        Gallium:         yes"
1882     echo "        Gallium dirs:    $GALLIUM_DIRS"
1883     echo "        Target dirs:     $GALLIUM_TARGET_DIRS"
1884     echo "        Winsys dirs:     $GALLIUM_WINSYS_DIRS"
1885     echo "        Driver dirs:     $GALLIUM_DRIVERS_DIRS"
1886     echo "        Trackers dirs:   $GALLIUM_STATE_TRACKERS_DIRS"
1887 else
1888     echo "        Gallium:         no"
1889 fi
1890
1891 dnl Libraries
1892 echo ""
1893 echo "        Shared libs:     $enable_shared"
1894 echo "        Static libs:     $enable_static"
1895
1896 dnl Compiler options
1897 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1898 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1899     $SED 's/^ *//;s/  */ /;s/ *$//'`
1900 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1901     $SED 's/^ *//;s/  */ /;s/ *$//'`
1902 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/  */ /;s/ *$//'`
1903 echo ""
1904 echo "        CFLAGS:          $cflags"
1905 echo "        CXXFLAGS:        $cxxflags"
1906 echo "        Macros:          $defines"
1907 echo ""
1908 echo "        PYTHON2:         $PYTHON2"
1909
1910 echo ""
1911 echo "        Run '${MAKE-make}' to build Mesa"
1912 echo ""