OSDN Git Service

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