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