1 dnl Process this file with autoconf to create configure.
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'
15 dnl Tell the user about autoconf.html in the --help output
16 m4_divert_once([HELP_END], [
17 See docs/autoconf.html for more details on the options for Mesa.])
19 AC_INIT([Mesa],[mesa_version],
20 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
21 AC_CONFIG_AUX_DIR([bin])
24 dnl Versions for external dependencies
26 DRI2PROTO_REQUIRED=1.99.3
32 AC_CHECK_PROGS([MAKE], [gmake make])
33 AC_PATH_PROG([MKDEP], [makedepend])
34 AC_PATH_PROG([SED], [sed])
36 dnl We need a POSIX shell for parts of the build. Assume we have one
40 # Solaris /bin/sh is too old/non-POSIX compliant
41 AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
46 MKDEP_OPTIONS=-fdepend
47 dnl Ask gcc where it's keeping its secret headers
48 if test "x$GCC" = xyes; then
49 GCC_INCLUDES=`$CC -print-file-name=include`
50 if test "x$GCC_INCLUDES" != x; then
51 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
54 AC_SUBST([MKDEP_OPTIONS])
56 dnl Make sure the pkg-config macros are defined
57 m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
58 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
59 These are usually located in /usr/share/aclocal/pkg.m4. If your
60 macros are in a different location, try setting the environment
61 variable ACLOCAL="aclocal -I/other/macro/dir" before running
68 dnl LIB_DIR - library basename
69 LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
72 dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
73 _SAVE_LDFLAGS="$LDFLAGS"
74 AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
75 AC_SUBST([EXTRA_LIB_PATH])
77 dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
78 _SAVE_CPPFLAGS="$CPPFLAGS"
79 AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
80 AC_SUBST([X11_INCLUDES])
87 DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
90 DEFINES="$DEFINES -DPTHREADS -DSVR4"
94 dnl Add flags for gcc and g++
95 if test "x$GCC" = xyes; then
96 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
98 # Work around aliasing bugs - developers should comment this out
99 CFLAGS="$CFLAGS -fno-strict-aliasing"
101 if test "x$GXX" = xyes; then
102 CXXFLAGS="$CXXFLAGS -Wall"
104 # Work around aliasing bugs - developers should comment this out
105 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
108 dnl These should be unnecessary, but let the user set them if they want
109 AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
110 Default is to use CFLAGS.])
111 AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
112 compiler. Default is to use CFLAGS.])
113 AC_SUBST([OPT_FLAGS])
114 AC_SUBST([ARCH_FLAGS])
117 dnl Hacks to enable 32 or 64 bit build
119 AC_ARG_ENABLE([32-bit],
120 [AS_HELP_STRING([--enable-32-bit],
121 [build 32-bit libraries @<:@default=auto@:>@])],
122 [enable_32bit="$enableval"],
125 if test "x$enable_32bit" = xyes; then
126 if test "x$GCC" = xyes; then
127 CFLAGS="$CFLAGS -m32"
129 if test "x$GXX" = xyes; then
130 CXXFLAGS="$CXXFLAGS -m32"
133 AC_ARG_ENABLE([64-bit],
134 [AS_HELP_STRING([--enable-64-bit],
135 [build 64-bit libraries @<:@default=auto@:>@])],
136 [enable_64bit="$enableval"],
139 if test "x$enable_64bit" = xyes; then
140 if test "x$GCC" = xyes; then
141 CFLAGS="$CFLAGS -m64"
143 if test "x$GXX" = xyes; then
144 CXXFLAGS="$CXXFLAGS -m64"
149 dnl shared/static libraries, mimic libtool options
151 AC_ARG_ENABLE([static],
152 [AS_HELP_STRING([--enable-static],
153 [build static libraries @<:@default=disabled@:>@])],
154 [enable_static="$enableval"],
157 case "x$enable_static" in
159 x ) enable_static=no ;;
161 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
164 AC_ARG_ENABLE([shared],
165 [AS_HELP_STRING([--disable-shared],
166 [build shared libraries @<:@default=enabled@:>@])],
167 [enable_shared="$enableval"],
170 case "x$enable_shared" in
172 x ) enable_shared=yes ;;
174 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
178 dnl Can't have static and shared libraries, default to static if user
179 dnl explicitly requested. If both disabled, set to static since shared
180 dnl was explicitly requirested.
181 case "x$enable_static$enable_shared" in
183 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
187 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
195 AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
196 if test "$enable_static" = yes; then
197 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
199 AC_SUBST([MKLIB_OPTIONS])
202 dnl other compiler options
204 AC_ARG_ENABLE([debug],
205 [AS_HELP_STRING([--enable-debug],
206 [use debug compiler flags and macros @<:@default=disabled@:>@])],
207 [enable_debug="$enableval"],
210 if test "x$enable_debug" = xyes; then
211 DEFINES="$DEFINES -DDEBUG"
212 if test "x$GCC" = xyes; then
215 if test "x$GXX" = xyes; then
216 CXXFLAGS="$CXXFLAGS -g"
223 if test "$enable_static" = yes; then
224 GL_LIB_NAME='lib$(GL_LIB).a'
225 GLU_LIB_NAME='lib$(GLU_LIB).a'
226 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
227 GLW_LIB_NAME='lib$(GLW_LIB).a'
228 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
230 GL_LIB_NAME='lib$(GL_LIB).so'
231 GLU_LIB_NAME='lib$(GLU_LIB).so'
232 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
233 GLW_LIB_NAME='lib$(GLW_LIB).so'
234 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
236 AC_SUBST([GL_LIB_NAME])
237 AC_SUBST([GLU_LIB_NAME])
238 AC_SUBST([GLUT_LIB_NAME])
239 AC_SUBST([GLW_LIB_NAME])
240 AC_SUBST([OSMESA_LIB_NAME])
243 dnl Arch/platform-specific settings
246 [AS_HELP_STRING([--disable-asm],
247 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
248 [enable_asm="$enableval"],
255 AC_MSG_CHECKING([whether to enable assembly])
256 test "x$enable_asm" = xno && AC_MSG_RESULT([no])
257 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
258 if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
262 AC_MSG_RESULT([no, cross compiling])
266 # check for supported arches
267 if test "x$enable_asm" = xyes; then
271 linux* | *freebsd* | dragonfly*)
272 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
278 linux* | *freebsd* | dragonfly*)
279 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
294 dnl ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
295 ASM_SOURCES='$(X86_SOURCES)'
297 AC_MSG_RESULT([yes, x86])
300 ASM_FLAGS="-DUSE_X86_64_ASM"
301 ASM_SOURCES='$(X86-64_SOURCES)'
302 ASM_API='$(X86-64_API)'
303 AC_MSG_RESULT([yes, x86_64])
306 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
307 ASM_SOURCES='$(PPC_SOURCES)'
308 AC_MSG_RESULT([yes, ppc])
311 AC_MSG_RESULT([no, platform not supported])
315 AC_SUBST([ASM_FLAGS])
316 AC_SUBST([ASM_SOURCES])
322 dnl Check to see if dlopen is in default libraries (like Solaris, which
323 dnl has it in libc), or if libdl is needed to get it.
324 AC_CHECK_FUNC([dlopen], [],
325 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
327 dnl See if posix_memalign is available
328 AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
330 dnl SELinux awareness.
331 AC_ARG_ENABLE([selinux],
332 [AS_HELP_STRING([--enable-selinux],
333 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
334 [MESA_SELINUX="$enableval"],
336 if test "x$enable_selinux" = "xyes"; then
337 AC_CHECK_HEADER([selinux/selinux.h],[],
338 [AC_MSG_ERROR([SELinux headers not found])])
339 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
340 [AC_MSG_ERROR([SELinux library not found])])
341 SELINUX_LIBS="-lselinux"
342 DEFINES="$DEFINES -DMESA_SELINUX"
345 dnl OS-specific libraries
350 if test "x$GXX" != xyes; then
351 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
357 dnl Driver configuration. Options are xlib, dri and osmesa right now.
358 dnl More later: directfb, fbdev, ...
360 default_driver="xlib"
365 i*86|x86_64|powerpc*) default_driver="dri";;
368 *freebsd* | dragonfly*)
370 i*86|x86_64) default_driver="dri";;
375 AC_ARG_WITH([driver],
376 [AS_HELP_STRING([--with-driver=DRIVER],
377 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
378 [mesa_driver="$withval"],
379 [mesa_driver="$default_driver"])
380 dnl Check for valid option
381 case "x$mesa_driver" in
385 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
390 dnl Driver specific build directories
392 SRC_DIRS="mesa gallium egl gallium/winsys"
395 GALLIUM_WINSYS_DIRS=""
396 GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util"
397 GALLIUM_DRIVER_DIRS="softpipe failover"
398 case "$mesa_driver" in
403 SRC_DIRS="glx/x11 $SRC_DIRS"
406 GALLIUM_WINSYS_DIRS="drm $GALLIUM_WINSYS_DIRS"
407 GALLIUM_DRIVER_DIRS="$GALLIUM_DRIVER_DIRS i915simple i965simple nv04 nv10 nv20 nv30 nv40 nv50"
415 AC_SUBST([DRIVER_DIRS])
416 AC_SUBST([WINDOW_SYSTEM])
417 AC_SUBST([GALLIUM_WINSYS_DIRS])
418 AC_SUBST([GALLIUM_DRIVER_DIRS])
419 AC_SUBST([GALLIUM_AUXILIARY_DIRS])
422 dnl User supplied program configuration
424 if test -d "$srcdir/progs/demos"; then
430 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
431 [optional comma delimited demo directories to build
432 @<:@default=auto if source available@:>@])],
433 [with_demos="$withval"],
434 [with_demos="$default_demos"])
435 if test "x$with_demos" = x; then
439 dnl If $with_demos is yes, directories will be added as libs available
441 case "$with_demos" in
444 # If the driver isn't osmesa, we have libGL and can build xdemos
445 if test "$mesa_driver" != osmesa; then
446 PROGRAM_DIRS="xdemos"
450 # verify the requested demos directories exist
451 demos=`IFS=,; echo $with_demos`
452 for demo in $demos; do
453 test -d "$srcdir/progs/$demo" || \
454 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
456 PROGRAM_DIRS="$demos"
461 dnl Find out if X is available. The variable have_x is set if libX11 is
462 dnl found to mimic AC_PATH_XTRA.
464 if test -n "$PKG_CONFIG"; then
465 AC_MSG_CHECKING([pkg-config files for X11 are available])
466 PKG_CHECK_EXISTS([x11],[
472 AC_MSG_RESULT([$x11_pkgconfig])
476 dnl Use the autoconf macro if no pkg-config files
477 if test "$x11_pkgconfig" = no; then
481 dnl Try to tell the user that the --x-* options are only used when
482 dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
483 m4_divert_once([HELP_BEGIN],
484 [These options are only used when the X libraries cannot be found by the
485 pkg-config utility.])
487 dnl We need X for xlib and dri, so bomb now if it's not found
488 case "$mesa_driver" in
490 if test "$no_x" = yes; then
491 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
496 dnl XCB - this is only used for GLX right now
498 [AS_HELP_STRING([--enable-xcb],
499 [use XCB for GLX @<:@default=disabled@:>@])],
500 [enable_xcb="$enableval"],
502 if test "x$enable_xcb" = xyes; then
503 DEFINES="$DEFINES -DUSE_XCB"
509 dnl libGL configuration per driver
511 case "$mesa_driver" in
513 if test "$x11_pkgconfig" = yes; then
514 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
515 GL_PC_REQ_PRIV="x11 xext"
516 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
517 GL_LIB_DEPS="$XLIBGL_LIBS"
519 # should check these...
520 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
521 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
522 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
523 GL_PC_CFLAGS="$X11_INCLUDES"
525 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
526 GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread $OS_LIBS"
528 # if static, move the external libraries to the programs
529 # and empty the libraries for libGL
530 if test "$enable_static" = yes; then
531 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
536 # DRI must be shared, I think
537 if test "$enable_static" = yes; then
538 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
542 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
543 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
544 GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
545 DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
547 # find the DRI deps for libGL
548 if test "$x11_pkgconfig" = yes; then
549 # add xcb modules if necessary
550 dri_modules="x11 xext xxf86vm xdamage xfixes"
551 if test "$enable_xcb" = yes; then
552 dri_modules="$dri_modules x11-xcb xcb-glx"
555 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
556 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
557 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
558 GL_LIB_DEPS="$DRIGL_LIBS"
560 # should check these...
561 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
562 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
563 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
564 GL_PC_CFLAGS="$X11_INCLUDES"
566 # XCB can only be used from pkg-config
567 if test "$enable_xcb" = yes; then
568 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
569 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
570 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
571 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
575 # need DRM libs, -lpthread, etc.
576 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
577 GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS $OS_LIBS"
580 # No libGL for osmesa
581 GL_LIB_DEPS="$OS_LIBS"
584 AC_SUBST([GL_LIB_DEPS])
585 AC_SUBST([GL_PC_REQ_PRIV])
586 AC_SUBST([GL_PC_LIB_PRIV])
587 AC_SUBST([GL_PC_CFLAGS])
588 AC_SUBST([DRI_PC_REQ_PRIV])
593 if test "$mesa_driver" = xlib; then
594 DEFINES="$DEFINES -DUSE_XSHM"
600 AC_ARG_ENABLE([glx-tls],
601 [AS_HELP_STRING([--enable-glx-tls],
602 [enable TLS support in GLX @<:@default=disabled@:>@])],
603 [GLX_USE_TLS="$enableval"],
605 dnl Directory for DRI drivers
606 AC_ARG_WITH([dri-driverdir],
607 [AS_HELP_STRING([--with-dri-driverdir=DIR],
608 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
609 [DRI_DRIVER_INSTALL_DIR="$withval"],
610 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
611 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
612 dnl Direct rendering or just indirect rendering
613 AC_ARG_ENABLE([driglx-direct],
614 [AS_HELP_STRING([--disable-driglx-direct],
615 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
616 [driglx_direct="$enableval"],
617 [driglx_direct="yes"])
618 dnl Which drivers to build - default is chosen by platform
619 AC_ARG_WITH([dri-drivers],
620 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
621 [comma delimited DRI drivers list, e.g.
622 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
623 [with_dri_drivers="$withval"],
624 [with_dri_drivers=yes])
625 if test "x$with_dri_drivers" = x; then
629 dnl If $with_dri_drivers is yes, directories will be added through
632 case "$with_dri_drivers" in
638 # verify the requested driver directories exist
639 dri_drivers=`IFS=', '; echo $with_dri_drivers`
640 for driver in $dri_drivers; do
641 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
642 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
644 DRI_DIRS="$dri_drivers"
648 dnl Just default to no EGL for now
650 AC_SUBST([USING_EGL])
652 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
653 if test "$mesa_driver" = dri; then
655 if test "x$GLX_USE_TLS" = xyes; then
656 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
659 if test "x$USING_EGL" = x1; then
663 # Platform specific settings and drivers to build
666 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
667 if test "x$driglx_direct" = xyes; then
668 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
670 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
674 # ffb, gamma, and sis are missing because they have not be
675 # converted to use the new interface. i810 are missing
676 # because there is no x86-64 system where they could *ever*
678 if test "x$DRI_DIRS" = "xyes"; then
679 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
680 savage tdfx unichrome swrast"
684 # Build only the drivers for cards that exist on PowerPC.
685 # At some point MGA will be added, but not yet.
686 if test "x$DRI_DIRS" = "xyes"; then
687 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
691 # Build only the drivers for cards that exist on sparc`
692 if test "x$DRI_DIRS" = "xyes"; then
693 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
698 freebsd* | dragonfly*)
699 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
700 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
701 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
702 if test "x$driglx_direct" = xyes; then
703 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
705 if test "x$GXX" = xyes; then
706 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
709 # ffb and gamma are missing because they have not been converted
710 # to use the new interface.
711 if test "x$DRI_DIRS" = "xyes"; then
712 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
713 unichrome savage sis swrast"
717 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
718 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
719 if test "x$driglx_direct" = xyes; then
720 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
726 if test "x$DRI_DIRS" = "xyes"; then
727 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
728 savage sis tdfx trident unichrome ffb swrast"
731 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
737 [AS_HELP_STRING([--with-expat=DIR],
738 [expat install directory])],[
739 EXPAT_INCLUDES="-I$withval/include"
740 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
741 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
742 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
744 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
745 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
746 [AC_MSG_ERROR([Expat required for DRI.])])
748 # put all the necessary libs together
749 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
752 AC_SUBST([EXPAT_INCLUDES])
753 AC_SUBST([DRI_LIB_DEPS])
756 dnl OSMesa configuration
758 if test "$mesa_driver" = xlib; then
759 default_gl_osmesa=yes
763 AC_ARG_ENABLE([gl-osmesa],
764 [AS_HELP_STRING([--enable-gl-osmesa],
765 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
766 [gl_osmesa="$enableval"],
767 [gl_osmesa="$default_gl_osmesa"])
768 if test "x$gl_osmesa" = xyes; then
769 if test "$mesa_driver" = osmesa; then
770 AC_MSG_ERROR([libGL is not available for OSMesa driver])
772 DRIVER_DIRS="$DRIVER_DIRS osmesa"
776 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
777 AC_ARG_WITH([osmesa-bits],
778 [AS_HELP_STRING([--with-osmesa-bits=BITS],
779 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
780 [osmesa_bits="$withval"],
782 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
783 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
786 case "x$osmesa_bits" in
791 OSMESA_LIB="OSMesa$osmesa_bits"
792 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
795 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
798 AC_SUBST([OSMESA_LIB])
800 case "$mesa_driver" in
802 # only link libraries with osmesa if shared
803 if test "$enable_static" = no; then
804 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
809 OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS"
812 # Link OSMesa to libGL otherwise
814 # only link libraries with osmesa if shared
815 if test "$enable_static" = no; then
816 OSMESA_MESA_DEPS='-l$(GL_LIB)'
823 if test "$enable_static" = no; then
824 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
826 OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV $OS_LIBS"
827 AC_SUBST([OSMESA_LIB_DEPS])
828 AC_SUBST([OSMESA_MESA_DEPS])
829 AC_SUBST([OSMESA_PC_REQ])
830 AC_SUBST([OSMESA_PC_LIB_PRIV])
833 dnl GLU configuration
836 [AS_HELP_STRING([--disable-glu],
837 [enable OpenGL Utility library @<:@default=enabled@:>@])],
838 [enable_glu="$enableval"],
840 if test "x$enable_glu" = xyes; then
841 SRC_DIRS="$SRC_DIRS glu"
843 case "$mesa_driver" in
845 # If GLU is available and we have libOSMesa (not 16 or 32),
846 # we can build the osdemos
847 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
848 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
851 # Link libGLU to libOSMesa instead of libGL
854 if test "$enable_static" = no; then
855 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
861 # If static, empty GLU_LIB_DEPS and add libs for programs to link
863 GLU_PC_LIB_PRIV="-lm"
864 if test "$enable_static" = no; then
866 GLU_MESA_DEPS='-l$(GL_LIB)'
870 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
875 if test "$enable_static" = no; then
876 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
878 GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
879 AC_SUBST([GLU_LIB_DEPS])
880 AC_SUBST([GLU_MESA_DEPS])
881 AC_SUBST([GLU_PC_REQ])
882 AC_SUBST([GLU_PC_REQ_PRIV])
883 AC_SUBST([GLU_PC_LIB_PRIV])
884 AC_SUBST([GLU_PC_CFLAGS])
887 dnl GLw configuration
890 [AS_HELP_STRING([--disable-glw],
891 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
892 [enable_glw="$enableval"],
894 dnl Don't build GLw on osmesa
895 if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
896 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
899 AC_ARG_ENABLE([motif],
900 [AS_HELP_STRING([--enable-motif],
901 [use Motif widgets in GLw @<:@default=disabled@:>@])],
902 [enable_motif="$enableval"],
905 if test "x$enable_glw" = xyes; then
906 SRC_DIRS="$SRC_DIRS glw"
907 if test "$x11_pkgconfig" = yes; then
908 PKG_CHECK_MODULES([GLW],[x11 xt])
909 GLW_PC_REQ_PRIV="x11 xt"
910 GLW_LIB_DEPS="$GLW_LIBS"
912 # should check these...
913 GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
914 GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
915 GLW_PC_CFLAGS="$X11_INCLUDES"
918 GLW_SOURCES="GLwDrawA.c"
920 if test "x$enable_motif" = xyes; then
921 GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
922 AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
923 if test "x$MOTIF_CONFIG" != xno; then
924 MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
925 MOTIF_LIBS=`$MOTIF_CONFIG --libs`
927 AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
928 [AC_MSG_ERROR([Can't locate Motif headers])])
929 AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
930 [AC_MSG_ERROR([Can't locate Motif Xm library])])
932 # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
933 GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
934 GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
935 GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
938 # If static, empty GLW_LIB_DEPS and add libs for programs to link
939 GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV $OS_LIBS"
940 if test "$enable_static" = no; then
941 GLW_MESA_DEPS='-l$(GL_LIB)'
942 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
944 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
949 AC_SUBST([GLW_LIB_DEPS])
950 AC_SUBST([GLW_MESA_DEPS])
951 AC_SUBST([GLW_SOURCES])
952 AC_SUBST([MOTIF_CFLAGS])
953 AC_SUBST([GLW_PC_REQ_PRIV])
954 AC_SUBST([GLW_PC_LIB_PRIV])
955 AC_SUBST([GLW_PC_CFLAGS])
958 dnl GLUT configuration
960 if test -f "$srcdir/include/GL/glut.h"; then
965 AC_ARG_ENABLE([glut],
966 [AS_HELP_STRING([--disable-glut],
967 [enable GLUT library @<:@default=enabled if source available@:>@])],
968 [enable_glut="$enableval"],
969 [enable_glut="$default_glut"])
971 dnl Can't build glut if GLU not available
972 if test "x$enable_glu$enable_glut" = xnoyes; then
973 AC_MSG_WARN([Disabling glut since GLU is disabled])
976 dnl Don't build glut on osmesa
977 if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
978 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
982 if test "x$enable_glut" = xyes; then
983 SRC_DIRS="$SRC_DIRS glut/glx"
985 if test "x$GCC" = xyes; then
986 GLUT_CFLAGS="-fexceptions"
988 if test "$x11_pkgconfig" = yes; then
989 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
990 GLUT_PC_REQ_PRIV="x11 xmu xi"
991 GLUT_LIB_DEPS="$GLUT_LIBS"
993 # should check these...
994 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
995 GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
996 GLUT_PC_CFLAGS="$X11_INCLUDES"
998 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
999 GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm $OS_LIBS"
1001 # If glut is available, we can build most programs
1002 if test "$with_demos" = yes; then
1003 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
1006 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
1007 if test "$enable_static" = no; then
1008 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
1010 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
1015 AC_SUBST([GLUT_LIB_DEPS])
1016 AC_SUBST([GLUT_MESA_DEPS])
1017 AC_SUBST([GLUT_CFLAGS])
1018 AC_SUBST([GLUT_PC_REQ_PRIV])
1019 AC_SUBST([GLUT_PC_LIB_PRIV])
1020 AC_SUBST([GLUT_PC_CFLAGS])
1023 dnl Program library dependencies
1024 dnl Only libm is added here if necessary as the libraries should
1025 dnl be pulled in by the linker
1027 if test "x$APP_LIB_DEPS" = x; then
1030 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
1037 AC_SUBST([APP_LIB_DEPS])
1038 AC_SUBST([PROGRAM_DIRS])
1041 dnl Restore LDFLAGS and CPPFLAGS
1042 LDFLAGS="$_SAVE_LDFLAGS"
1043 CPPFLAGS="$_SAVE_CPPFLAGS"
1045 dnl Substitute the config
1046 AC_CONFIG_FILES([configs/autoconf])
1048 dnl Replace the configs/current symlink
1049 AC_CONFIG_COMMANDS([configs],[
1050 if test -f configs/current || test -L configs/current; then
1051 rm -f configs/current
1053 ln -s autoconf configs/current
1059 dnl Output some configuration info for the user
1062 echo " prefix: $prefix"
1063 echo " exec_prefix: $exec_prefix"
1064 echo " libdir: $libdir"
1065 echo " includedir: $includedir"
1069 echo " Driver: $mesa_driver"
1070 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1071 echo " OSMesa: lib$OSMESA_LIB"
1075 if test "$mesa_driver" = dri; then
1076 # cleanup the drivers var
1077 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1078 if test "x$DRI_DIRS" = x; then
1079 echo " DRI drivers: no"
1081 echo " DRI drivers: $dri_dirs"
1083 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
1085 echo " Use XCB: $enable_xcb"
1089 echo " Shared libs: $enable_shared"
1090 echo " Static libs: $enable_static"
1091 echo " GLU: $enable_glu"
1092 echo " GLw: $enable_glw (Motif: $enable_motif)"
1093 echo " glut: $enable_glut"
1096 # cleanup the programs var for display
1097 program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1098 if test "x$program_dirs" = x; then
1101 echo " Demos: $program_dirs"
1104 dnl Compiler options
1105 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1106 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1107 $SED 's/^ *//;s/ */ /;s/ *$//'`
1108 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1109 $SED 's/^ *//;s/ */ /;s/ *$//'`
1110 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1112 echo " CFLAGS: $cflags"
1113 echo " CXXFLAGS: $cxxflags"
1114 echo " Macros: $defines"
1117 echo " Run '${MAKE-make}' to build Mesa"