Merge commit 'origin/master' into drm-gem
[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'])])
8 m4_ifval(mesa_version,[],[
9 m4_errprint([Error: Failed to get the Mesa version from the output of
10 running `make -f bin/version.mk version'
11 ])
12 m4_exit([1])
13 ])
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.3.1
22 DRI2PROTO_REQUIRED=1.1
23
24 dnl Check for progs
25 AC_PROG_CPP
26 AC_PROG_CC
27 AC_PROG_CXX
28 AC_CHECK_PROGS([MAKE], [gmake make])
29 AC_PATH_PROG([MKDEP], [makedepend])
30 AC_PATH_PROG([SED], [sed])
31
32 dnl Platform-specific program settings
33 EXTRA_CONFIG_LINES=""
34 AC_SUBST([EXTRA_CONFIG_LINES])
35 case "$host_os" in
36 solaris*)
37 # Solaris /bin/sh is too old/non-POSIX compliant
38 AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
39 EXTRA_CONFIG_LINES="SHELL=$POSIX_SHELL"
40 ;;
41 esac
42
43
44 MKDEP_OPTIONS=-fdepend
45 dnl Ask gcc where it's keeping its secret headers
46 if test "x$GCC" = xyes; then
47 GCC_INCLUDES=`$CC -print-file-name=include`
48 if test "x$GCC_INCLUDES" != x; then
49 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
50 fi
51 fi
52 AC_SUBST([MKDEP_OPTIONS])
53
54 dnl Make sure the pkg-config macros are defined
55 m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
56 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
57 These are usually located in /usr/share/aclocal/pkg.m4. If your
58 macros are in a different location, try setting the environment
59 variable ACLOCAL="aclocal -I/other/macro/dir" before running
60 autoreconf.
61 ])
62 m4_exit([1])
63 ])
64 PKG_PROG_PKG_CONFIG()
65
66 dnl LIB_DIR - library basename
67 LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
68 AC_SUBST([LIB_DIR])
69
70 dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
71 _SAVE_LDFLAGS="$LDFLAGS"
72 AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
73 AC_SUBST([EXTRA_LIB_PATH])
74
75 dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
76 _SAVE_CPPFLAGS="$CPPFLAGS"
77 AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
78 AC_SUBST([X11_INCLUDES])
79
80 dnl Compiler macros
81 DEFINES=""
82 AC_SUBST([DEFINES])
83 case "$host_os" in
84 linux*)
85 if test "x$GCC" = xyes; then
86 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
87 fi
88 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
89 ;;
90 solaris*)
91 DEFINES="$DEFINES -DPTHREADS -DSVR4"
92 ;;
93 esac
94
95 dnl Add flags for gcc and g++
96 if test "x$GCC" = xyes; then
97 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
98
99 # Work around aliasing bugs - developers should comment this out
100 CFLAGS="$CFLAGS -fno-strict-aliasing"
101 fi
102 if test "x$GXX" = xyes; then
103 CXXFLAGS="$CXXFLAGS -Wall"
104
105 # Work around aliasing bugs - developers should comment this out
106 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
107 fi
108
109 dnl These should be unnecessary, but let the user set them if they want
110 AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
111 Default is to use CFLAGS.])
112 AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
113 compiler. Default is to use CFLAGS.])
114 AC_SUBST([OPT_FLAGS])
115 AC_SUBST([ARCH_FLAGS])
116
117 dnl
118 dnl Hacks to enable 32 or 64 bit build
119 dnl
120 AC_ARG_ENABLE([32-bit],
121 [AS_HELP_STRING([--enable-32-bit],
122 [build 32-bit libraries @<:@default=auto@:>@])],
123 [enable_32bit="$enableval"],
124 [enable_32bit=auto]
125 )
126 if test "x$enable_32bit" = xyes; then
127 if test "x$GCC" = xyes; then
128 CFLAGS="$CFLAGS -m32"
129 fi
130 if test "x$GXX" = xyes; then
131 CXXFLAGS="$CXXFLAGS -m32"
132 fi
133 fi
134 AC_ARG_ENABLE([64-bit],
135 [AS_HELP_STRING([--enable-64-bit],
136 [build 64-bit libraries @<:@default=auto@:>@])],
137 [enable_64bit="$enableval"],
138 [enable_64bit=auto]
139 )
140 if test "x$enable_64bit" = xyes; then
141 if test "x$GCC" = xyes; then
142 CFLAGS="$CFLAGS -m64"
143 fi
144 if test "x$GXX" = xyes; then
145 CXXFLAGS="$CXXFLAGS -m64"
146 fi
147 fi
148
149 dnl
150 dnl shared/static libraries, mimic libtool options
151 dnl
152 AC_ARG_ENABLE([static],
153 [AS_HELP_STRING([--enable-static],
154 [build static libraries @<:@default=disabled@:>@])],
155 [enable_static="$enableval"],
156 [enable_static=no]
157 )
158 case "x$enable_static" in
159 xyes|xno ) ;;
160 x ) enable_static=no ;;
161 * )
162 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
163 ;;
164 esac
165 AC_ARG_ENABLE([shared],
166 [AS_HELP_STRING([--disable-shared],
167 [build shared libraries @<:@default=enabled@:>@])],
168 [enable_shared="$enableval"],
169 [enable_shared=yes]
170 )
171 case "x$enable_shared" in
172 xyes|xno ) ;;
173 x ) enable_shared=yes ;;
174 * )
175 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
176 ;;
177 esac
178
179 dnl Can't have static and shared libraries, default to static if user
180 dnl explicitly requested. If both disabled, set to static since shared
181 dnl was explicitly requirested.
182 case "x$enable_static$enable_shared" in
183 xyesyes )
184 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
185 enable_shared=no
186 ;;
187 xnono )
188 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
189 enable_static=yes
190 ;;
191 esac
192
193 dnl
194 dnl mklib options
195 dnl
196 AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
197 if test "$enable_static" = yes; then
198 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
199 fi
200 AC_SUBST([MKLIB_OPTIONS])
201
202 dnl
203 dnl other compiler options
204 dnl
205 AC_ARG_ENABLE([debug],
206 [AS_HELP_STRING([--enable-debug],
207 [use debug compiler flags and macros @<:@default=disabled@:>@])],
208 [enable_debug="$enableval"],
209 [enable_debug=no]
210 )
211 if test "x$enable_debug" = xyes; then
212 DEFINES="$DEFINES -DDEBUG"
213 if test "x$GCC" = xyes; then
214 CFLAGS="$CFLAGS -g"
215 fi
216 if test "x$GXX" = xyes; then
217 CXXFLAGS="$CXXFLAGS -g"
218 fi
219 fi
220
221 dnl
222 dnl library names
223 dnl
224 if test "$enable_static" = yes; then
225 GL_LIB_NAME='lib$(GL_LIB).a'
226 GLU_LIB_NAME='lib$(GLU_LIB).a'
227 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
228 GLW_LIB_NAME='lib$(GLW_LIB).a'
229 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
230 else
231 GL_LIB_NAME='lib$(GL_LIB).so'
232 GLU_LIB_NAME='lib$(GLU_LIB).so'
233 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
234 GLW_LIB_NAME='lib$(GLW_LIB).so'
235 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
236 fi
237 AC_SUBST([GL_LIB_NAME])
238 AC_SUBST([GLU_LIB_NAME])
239 AC_SUBST([GLUT_LIB_NAME])
240 AC_SUBST([GLW_LIB_NAME])
241 AC_SUBST([OSMESA_LIB_NAME])
242
243 dnl
244 dnl Arch/platform-specific settings
245 dnl
246 AC_ARG_ENABLE([asm],
247 [AS_HELP_STRING([--disable-asm],
248 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
249 [enable_asm="$enableval"],
250 [enable_asm=yes]
251 )
252 asm_arch=""
253 ASM_FLAGS=""
254 ASM_SOURCES=""
255 ASM_API=""
256 AC_MSG_CHECKING([whether to enable assembly])
257 test "x$enable_asm" = xno && AC_MSG_RESULT([no])
258 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
259 if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
260 case "$host_cpu" in
261 i?86 | x86_64)
262 enable_asm=no
263 AC_MSG_RESULT([no, cross compiling])
264 ;;
265 esac
266 fi
267 # check for supported arches
268 if test "x$enable_asm" = xyes; then
269 case "$host_cpu" in
270 i?86)
271 case "$host_os" in
272 linux* | freebsd* | dragonfly*)
273 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
274 ;;
275 esac
276 ;;
277 x86_64)
278 case "$host_os" in
279 linux* | freebsd* | dragonfly*)
280 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
281 ;;
282 esac
283 ;;
284 powerpc)
285 case "$host_os" in
286 linux*)
287 asm_arch=ppc
288 ;;
289 esac
290 ;;
291 esac
292
293 case "$asm_arch" in
294 x86)
295 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
296 ASM_SOURCES='$(X86_SOURCES)'
297 ASM_API='$(X86_API)'
298 AC_MSG_RESULT([yes, x86])
299 ;;
300 x86_64)
301 ASM_FLAGS="-DUSE_X86_64_ASM"
302 ASM_SOURCES='$(X86-64_SOURCES)'
303 ASM_API='$(X86-64_API)'
304 AC_MSG_RESULT([yes, x86_64])
305 ;;
306 ppc)
307 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
308 ASM_SOURCES='$(PPC_SOURCES)'
309 AC_MSG_RESULT([yes, ppc])
310 ;;
311 *)
312 AC_MSG_RESULT([no, platform not supported])
313 ;;
314 esac
315 fi
316 AC_SUBST([ASM_FLAGS])
317 AC_SUBST([ASM_SOURCES])
318 AC_SUBST([ASM_API])
319
320 dnl PIC code macro
321 MESA_PIC_FLAGS
322
323 dnl Check to see if dlopen is in default libraries (like Solaris, which
324 dnl has it in libc), or if libdl is needed to get it.
325 AC_CHECK_FUNC([dlopen], [],
326 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
327
328 dnl SELinux awareness.
329 AC_ARG_ENABLE([selinux],
330 [AS_HELP_STRING([--enable-selinux],
331 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
332 [MESA_SELINUX="$enableval"],
333 [MESA_SELINUX=no])
334 if test "x$enable_selinux" = "xyes"; then
335 AC_CHECK_HEADER([selinux/selinux.h],[],
336 [AC_MSG_ERROR([SELinux headers not found])])
337 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
338 [AC_MSG_ERROR([SELinux library not found])])
339 SELINUX_LIBS="-lselinux"
340 DEFINES="$DEFINES -DMESA_SELINUX"
341 fi
342
343 dnl OS-specific libraries
344 OS_LIBS=""
345 case "$host_os" in
346 solaris*)
347 OS_LIBS="-lc"
348 if test "x$GXX" != xyes; then
349 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
350 fi
351 ;;
352 esac
353
354 dnl
355 dnl Driver configuration. Options are xlib, dri and osmesa right now.
356 dnl More later: directfb, fbdev, ...
357 dnl
358 default_driver="xlib"
359
360 case "$host_os" in
361 linux*)
362 case "$host_cpu" in
363 i*86|x86_64|powerpc*) default_driver="dri";;
364 esac
365 ;;
366 freebsd* | dragonfly*)
367 case "$host_cpu" in
368 i*86|x86_64) default_driver="dri";;
369 esac
370 ;;
371 esac
372
373 AC_ARG_WITH([driver],
374 [AS_HELP_STRING([--with-driver=DRIVER],
375 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
376 [mesa_driver="$withval"],
377 [mesa_driver="$default_driver"])
378 dnl Check for valid option
379 case "x$mesa_driver" in
380 xxlib|xdri|xosmesa)
381 ;;
382 *)
383 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
384 ;;
385 esac
386
387 dnl
388 dnl Driver specific build directories
389 dnl
390 SRC_DIRS="mesa"
391 GLU_DIRS="sgi"
392 WINDOW_SYSTEM=""
393 case "$mesa_driver" in
394 xlib)
395 DRIVER_DIRS="x11"
396 ;;
397 dri)
398 SRC_DIRS="glx/x11 $SRC_DIRS"
399 DRIVER_DIRS="dri"
400 WINDOW_SYSTEM="dri"
401 ;;
402 osmesa)
403 DRIVER_DIRS="osmesa"
404 ;;
405 esac
406 AC_SUBST([SRC_DIRS])
407 AC_SUBST([GLU_DIRS])
408 AC_SUBST([DRIVER_DIRS])
409 AC_SUBST([WINDOW_SYSTEM])
410
411 dnl
412 dnl User supplied program configuration
413 dnl
414 if test -d "$srcdir/progs/demos"; then
415 default_demos=yes
416 else
417 default_demos=no
418 fi
419 AC_ARG_WITH([demos],
420 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
421 [optional comma delimited demo directories to build
422 @<:@default=auto if source available@:>@])],
423 [with_demos="$withval"],
424 [with_demos="$default_demos"])
425 if test "x$with_demos" = x; then
426 with_demos=no
427 fi
428
429 dnl If $with_demos is yes, directories will be added as libs available
430 PROGRAM_DIRS=""
431 case "$with_demos" in
432 no) ;;
433 yes)
434 # If the driver isn't osmesa, we have libGL and can build xdemos
435 if test "$mesa_driver" != osmesa; then
436 PROGRAM_DIRS="xdemos"
437 fi
438 ;;
439 *)
440 # verify the requested demos directories exist
441 demos=`IFS=,; echo $with_demos`
442 for demo in $demos; do
443 test -d "$srcdir/progs/$demo" || \
444 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
445 done
446 PROGRAM_DIRS="$demos"
447 ;;
448 esac
449
450 dnl
451 dnl Find out if X is available. The variable have_x is set if libX11 is
452 dnl to mimic AC_PATH_XTRA.
453 dnl
454 if test -n "$PKG_CONFIG"; then
455 AC_MSG_CHECKING([pkg-config files for X11 are available])
456 PKG_CHECK_EXISTS([x11],[
457 x11_pkgconfig=yes
458 have_x=yes
459 ],[
460 x11_pkgconfig=no
461 ])
462 AC_MSG_RESULT([$x11_pkgconfig])
463 else
464 x11_pkgconfig=no
465 fi
466 dnl Use the autoconf macro if no pkg-config files
467 if test "$x11_pkgconfig" = no; then
468 AC_PATH_XTRA
469 fi
470
471 dnl We need X for xlib and dri, so bomb now if it's not found
472 case "$mesa_driver" in
473 xlib|dri)
474 if test "$no_x" = yes; then
475 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
476 fi
477 ;;
478 esac
479
480 dnl XCB - this is only used for GLX right now
481 AC_ARG_ENABLE([xcb],
482 [AS_HELP_STRING([--enable-xcb],
483 [use XCB for GLX @<:@default=disabled@:>@])],
484 [enable_xcb="$enableval"],
485 [enable_xcb=no])
486 if test "x$enable_xcb" = xyes; then
487 DEFINES="$DEFINES -DUSE_XCB"
488 else
489 enable_xcb=no
490 fi
491
492 dnl
493 dnl libGL configuration per driver
494 dnl
495 case "$mesa_driver" in
496 xlib)
497 if test "$x11_pkgconfig" = yes; then
498 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
499 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
500 GL_LIB_DEPS="$XLIBGL_LIBS"
501 else
502 # should check these...
503 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
504 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
505 fi
506 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
507
508 # if static, move the external libraries to the programs
509 # and empty the libraries for libGL
510 if test "$enable_static" = yes; then
511 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
512 GL_LIB_DEPS=""
513 fi
514 ;;
515 dri)
516 # DRI must be shared, I think
517 if test "$enable_static" = yes; then
518 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
519 fi
520
521 # Check for libdrm
522 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
523 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
524
525 # find the DRI deps for libGL
526 if test "$x11_pkgconfig" = yes; then
527 # add xcb modules if necessary
528 dri_modules="x11 xext xxf86vm xdamage xfixes"
529 if test "$enable_xcb" = yes; then
530 dri_modules="$dri_modules x11-xcb xcb-glx"
531 fi
532
533 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
534 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
535 GL_LIB_DEPS="$DRIGL_LIBS"
536 else
537 # should check these...
538 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
539 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
540
541 # XCB can only be used from pkg-config
542 if test "$enable_xcb" = yes; then
543 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
544 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
545 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
546 fi
547 fi
548
549 # need DRM libs, -lpthread, etc.
550 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
551 ;;
552 osmesa)
553 # No libGL for osmesa
554 GL_LIB_DEPS="$OS_LIBS"
555 ;;
556 esac
557 AC_SUBST([GL_LIB_DEPS])
558
559 dnl
560 dnl More X11 setup
561 dnl
562 if test "$mesa_driver" = xlib; then
563 DEFINES="$DEFINES -DUSE_XSHM"
564 fi
565
566 dnl
567 dnl More DRI setup
568 dnl
569 AC_ARG_ENABLE([glx-tls],
570 [AS_HELP_STRING([--enable-glx-tls],
571 [enable TLS support in GLX @<:@default=disabled@:>@])],
572 [GLX_USE_TLS="$enableval"],
573 [GLX_USE_TLS=no])
574 dnl Directory for DRI drivers
575 AC_ARG_WITH([dri-driverdir],
576 [AS_HELP_STRING([--with-dri-driverdir=DIR],
577 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
578 [DRI_DRIVER_INSTALL_DIR="$withval"],
579 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
580 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
581 dnl Direct rendering or just indirect rendering
582 AC_ARG_ENABLE([driglx-direct],
583 [AS_HELP_STRING([--disable-driglx-direct],
584 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
585 [driglx_direct="$enableval"],
586 [driglx_direct="yes"])
587 dnl ttm support
588 AC_ARG_ENABLE([ttm-api],
589 [AS_HELP_STRING([--enable-ttm-api],
590 [enable TTM API users @<:@default=disabled@:>@])],
591 [ttmapi="$enableval"],
592 [ttmapi="no"])
593
594 if test "x$ttmapi" = "xyes"; then
595 save_CFLAGS=$CFLAGS
596 CFLAGS=$LIBDRM_CFLAGS
597 AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
598 CFLAGS=$save_CFLAGS
599 fi
600
601 dnl Which drivers to build - default is chosen by platform
602 AC_ARG_WITH([dri-drivers],
603 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
604 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
605 [with_dri_drivers="$withval"],
606 [with_dri_drivers=yes])
607 if test "x$with_dri_drivers" = x; then
608 with_dri_drivers=no
609 fi
610
611 dnl If $with_dri_drivers is yes, directories will be added through
612 dnl platform checks
613 DRI_DIRS=""
614 case "$with_dri_drivers" in
615 no|yes) ;;
616 *)
617 # verify the requested driver directories exist
618 dri_drivers=`IFS=,; echo $with_dri_drivers`
619 for driver in $dri_drivers; do
620 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
621 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
622 done
623 DRI_DIRS="$dri_drivers"
624 ;;
625 esac
626
627 dnl Just default to no EGL for now
628 USING_EGL=0
629 AC_SUBST([USING_EGL])
630
631 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
632 if test "$mesa_driver" = dri; then
633 # Use TLS in GLX?
634 if test "x$GLX_USE_TLS" = xyes; then
635 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
636 fi
637
638 if test "x$ttmapi" = xyes; then
639 DEFINES="$DEFINES -DTTM_API"
640 fi
641
642 if test "x$USING_EGL" = x1; then
643 PROGRAM_DIRS="egl"
644 fi
645
646 # Platform specific settings and drivers to build
647 case "$host_os" in
648 linux*)
649 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
650 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
651 if test "x$driglx_direct" = xyes; then
652 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
653 fi
654
655 case "$host_cpu" in
656 x86_64)
657 # ffb, gamma, and sis are missing because they have not be
658 # converted to use the new interface. i810 are missing
659 # because there is no x86-64 system where they could *ever*
660 # be used.
661 if test "x$DRI_DIRS" = x; then
662 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
663 savage tdfx unichrome swrast"
664 fi
665 ;;
666 powerpc*)
667 # Build only the drivers for cards that exist on PowerPC.
668 # At some point MGA will be added, but not yet.
669 if test "x$DRI_DIRS" = x; then
670 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
671 fi
672 ;;
673 sparc*)
674 # Build only the drivers for cards that exist on sparc`
675 if test "x$DRI_DIRS" = x; then
676 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
677 fi
678 ;;
679 esac
680 ;;
681 freebsd* | dragonfly*)
682 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
683 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
684 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
685 if test "x$driglx_direct" = xyes; then
686 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
687 fi
688 if test "x$GXX" = xyes; then
689 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
690 fi
691
692 # ffb and gamma are missing because they have not been converted
693 # to use the new interface.
694 if test "x$DRI_DIRS" = x; then
695 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
696 unichrome savage sis swrast"
697 fi
698 ;;
699 solaris*)
700 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
701 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
702 if test "x$driglx_direct" = xyes; then
703 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
704 fi
705 ;;
706 esac
707
708 # default drivers
709 if test "x$DRI_DIRS" = x; then
710 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
711 savage sis tdfx trident unichrome ffb swrast"
712 fi
713
714 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
715
716 # Check for expat
717 EXPAT_INCLUDES=""
718 EXPAT_LIB=-lexpat
719 AC_ARG_WITH([expat],
720 [AS_HELP_STRING([--with-expat=DIR],
721 [expat install directory])],[
722 EXPAT_INCLUDES="-I$withval/include"
723 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
724 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
725 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
726 ])
727 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
728 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
729 [AC_MSG_ERROR([Expat required for DRI.])])
730
731 # put all the necessary libs together
732 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
733 fi
734 AC_SUBST([DRI_DIRS])
735 AC_SUBST([EXPAT_INCLUDES])
736 AC_SUBST([DRI_LIB_DEPS])
737
738 dnl
739 dnl OSMesa configuration
740 dnl
741 if test "$mesa_driver" = xlib; then
742 default_gl_osmesa=yes
743 else
744 default_gl_osmesa=no
745 fi
746 AC_ARG_ENABLE([gl-osmesa],
747 [AS_HELP_STRING([--enable-gl-osmesa],
748 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
749 [gl_osmesa="$enableval"],
750 [gl_osmesa="$default_gl_osmesa"])
751 if test "x$gl_osmesa" = xyes; then
752 if test "$mesa_driver" = osmesa; then
753 AC_MSG_ERROR([libGL is not available for OSMesa driver])
754 else
755 DRIVER_DIRS="$DRIVER_DIRS osmesa"
756 fi
757 fi
758
759 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
760 AC_ARG_WITH([osmesa-bits],
761 [AS_HELP_STRING([--with-osmesa-bits=BITS],
762 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
763 [osmesa_bits="$withval"],
764 [osmesa_bits=8])
765 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
766 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
767 osmesa_bits=8
768 fi
769 case "x$osmesa_bits" in
770 x8)
771 OSMESA_LIB=OSMesa
772 ;;
773 x16|x32)
774 OSMESA_LIB="OSMesa$osmesa_bits"
775 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
776 ;;
777 *)
778 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
779 ;;
780 esac
781 AC_SUBST([OSMESA_LIB])
782
783 case "$mesa_driver" in
784 osmesa)
785 # only link libraries with osmesa if shared
786 if test "$enable_static" = no; then
787 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
788 else
789 OSMESA_LIB_DEPS=""
790 fi
791 OSMESA_MESA_DEPS=""
792 ;;
793 *)
794 # Link OSMesa to libGL otherwise
795 OSMESA_LIB_DEPS=""
796 # only link libraries with osmesa if shared
797 if test "$enable_static" = no; then
798 OSMESA_MESA_DEPS='-l$(GL_LIB)'
799 else
800 OSMESA_MESA_DEPS=""
801 fi
802 ;;
803 esac
804 if test "$enable_static" = no; then
805 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
806 fi
807 AC_SUBST([OSMESA_LIB_DEPS])
808 AC_SUBST([OSMESA_MESA_DEPS])
809
810 dnl
811 dnl GLU configuration
812 dnl
813 AC_ARG_ENABLE([glu],
814 [AS_HELP_STRING([--disable-glu],
815 [enable OpenGL Utility library @<:@default=enabled@:>@])],
816 [enable_glu="$enableval"],
817 [enable_glu=yes])
818 if test "x$enable_glu" = xyes; then
819 SRC_DIRS="$SRC_DIRS glu"
820
821 case "$mesa_driver" in
822 osmesa)
823 # If GLU is available and we have libOSMesa (not 16 or 32),
824 # we can build the osdemos
825 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
826 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
827 fi
828
829 # Link libGLU to libOSMesa instead of libGL
830 GLU_LIB_DEPS=""
831 if test "$enable_static" = no; then
832 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
833 else
834 GLU_MESA_DEPS=""
835 fi
836 ;;
837 *)
838 # If static, empty GLU_LIB_DEPS and add libs for programs to link
839 if test "$enable_static" = no; then
840 GLU_LIB_DEPS="-lm"
841 GLU_MESA_DEPS='-l$(GL_LIB)'
842 else
843 GLU_LIB_DEPS=""
844 GLU_MESA_DEPS=""
845 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
846 fi
847 ;;
848 esac
849 fi
850 if test "$enable_static" = no; then
851 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
852 fi
853 AC_SUBST([GLU_LIB_DEPS])
854 AC_SUBST([GLU_MESA_DEPS])
855
856 dnl
857 dnl GLw configuration
858 dnl
859 AC_ARG_ENABLE([glw],
860 [AS_HELP_STRING([--disable-glw],
861 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
862 [enable_glw="$enableval"],
863 [enable_glw=yes])
864 dnl Don't build GLw on osmesa
865 if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
866 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
867 enable_glw=no
868 fi
869 if test "x$enable_glw" = xyes; then
870 SRC_DIRS="$SRC_DIRS glw"
871 if test "$x11_pkgconfig" = yes; then
872 PKG_CHECK_MODULES([GLW],[x11 xt])
873 GLW_LIB_DEPS="$GLW_LIBS"
874 else
875 # should check these...
876 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
877 fi
878
879 # If static, empty GLW_LIB_DEPS and add libs for programs to link
880 if test "$enable_static" = no; then
881 GLW_MESA_DEPS='-l$(GL_LIB)'
882 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
883 else
884 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
885 GLW_LIB_DEPS=""
886 GLW_MESA_DEPS=""
887 fi
888 fi
889 AC_SUBST([GLW_LIB_DEPS])
890 AC_SUBST([GLW_MESA_DEPS])
891
892 dnl
893 dnl GLUT configuration
894 dnl
895 if test -f "$srcdir/include/GL/glut.h"; then
896 default_glut=yes
897 else
898 default_glut=no
899 fi
900 AC_ARG_ENABLE([glut],
901 [AS_HELP_STRING([--disable-glut],
902 [enable GLUT library @<:@default=enabled if source available@:>@])],
903 [enable_glut="$enableval"],
904 [enable_glut="$default_glut"])
905
906 dnl Can't build glut if GLU not available
907 if test "x$enable_glu$enable_glut" = xnoyes; then
908 AC_MSG_WARN([Disabling glut since GLU is disabled])
909 enable_glut=no
910 fi
911 dnl Don't build glut on osmesa
912 if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
913 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
914 enable_glut=no
915 fi
916
917 if test "x$enable_glut" = xyes; then
918 SRC_DIRS="$SRC_DIRS glut/glx"
919 GLUT_CFLAGS=""
920 if test "x$GCC" = xyes; then
921 GLUT_CFLAGS="-fexceptions"
922 fi
923 if test "$x11_pkgconfig" = yes; then
924 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
925 GLUT_LIB_DEPS="$GLUT_LIBS"
926 else
927 # should check these...
928 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
929 fi
930 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
931
932 # If glut is available, we can build most programs
933 if test "$with_demos" = yes; then
934 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
935 fi
936
937 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
938 if test "$enable_static" = no; then
939 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
940 else
941 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
942 GLUT_LIB_DEPS=""
943 GLUT_MESA_DEPS=""
944 fi
945 fi
946 AC_SUBST([GLUT_LIB_DEPS])
947 AC_SUBST([GLUT_MESA_DEPS])
948 AC_SUBST([GLUT_CFLAGS])
949
950 dnl
951 dnl Program library dependencies
952 dnl Only libm is added here if necessary as the libraries should
953 dnl be pulled in by the linker
954 dnl
955 if test "x$APP_LIB_DEPS" = x; then
956 case "$host_os" in
957 solaris*)
958 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
959 ;;
960 *)
961 APP_LIB_DEPS="-lm"
962 ;;
963 esac
964 fi
965 AC_SUBST([APP_LIB_DEPS])
966 AC_SUBST([PROGRAM_DIRS])
967
968
969 dnl Restore LDFLAGS and CPPFLAGS
970 LDFLAGS="$_SAVE_LDFLAGS"
971 CPPFLAGS="$_SAVE_CPPFLAGS"
972
973 dnl Substitute the config
974 AC_CONFIG_FILES([configs/autoconf])
975
976 dnl Replace the configs/current symlink
977 AC_CONFIG_COMMANDS([configs],[
978 if test -f configs/current || test -L configs/current; then
979 rm -f configs/current
980 fi
981 ln -s autoconf configs/current
982 ])
983
984 AC_OUTPUT
985
986 dnl
987 dnl Output some configuration info for the user
988 dnl
989 echo ""
990 echo " prefix: $prefix"
991 echo " exec_prefix: $exec_prefix"
992 echo " libdir: $libdir"
993
994 dnl Driver info
995 echo ""
996 echo " Driver: $mesa_driver"
997 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
998 echo " OSMesa: lib$OSMESA_LIB"
999 else
1000 echo " OSMesa: no"
1001 fi
1002 if test "$mesa_driver" = dri; then
1003 # cleanup the drivers var
1004 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1005 echo " DRI drivers: $dri_dirs"
1006 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
1007 echo " TTM API support: $ttmapi"
1008 fi
1009
1010 dnl Libraries
1011 echo ""
1012 echo " Shared libs: $enable_shared"
1013 echo " Static libs: $enable_static"
1014 echo " GLU: $enable_glu"
1015 echo " GLw: $enable_glw"
1016 echo " glut: $enable_glut"
1017
1018 dnl Programs
1019 # cleanup the programs var for display
1020 program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1021 if test "x$program_dirs" = x; then
1022 echo " Demos: no"
1023 else
1024 echo " Demos: $program_dirs"
1025 fi
1026
1027 dnl Compiler options
1028 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1029 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1030 $SED 's/^ *//;s/ */ /;s/ *$//'`
1031 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1032 $SED 's/^ *//;s/ */ /;s/ *$//'`
1033 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1034 echo ""
1035 echo " CFLAGS: $cflags"
1036 echo " CXXFLAGS: $cxxflags"
1037 echo " Macros: $defines"
1038
1039 echo ""
1040 echo " Run '${MAKE-make}' to build Mesa"
1041 echo ""