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 if test "x$GCC" = xyes; then
88 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
90 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS"
93 DEFINES="$DEFINES -DPTHREADS -DSVR4"
97 dnl Add flags for gcc and g++
98 if test "x$GCC" = xyes; then
99 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
101 # Work around aliasing bugs - developers should comment this out
102 CFLAGS="$CFLAGS -fno-strict-aliasing"
104 if test "x$GXX" = xyes; then
105 CXXFLAGS="$CXXFLAGS -Wall"
107 # Work around aliasing bugs - developers should comment this out
108 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
111 dnl These should be unnecessary, but let the user set them if they want
112 AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
113 Default is to use CFLAGS.])
114 AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
115 compiler. Default is to use CFLAGS.])
116 AC_SUBST([OPT_FLAGS])
117 AC_SUBST([ARCH_FLAGS])
120 dnl Hacks to enable 32 or 64 bit build
122 AC_ARG_ENABLE([32-bit],
123 [AS_HELP_STRING([--enable-32-bit],
124 [build 32-bit libraries @<:@default=auto@:>@])],
125 [enable_32bit="$enableval"],
128 if test "x$enable_32bit" = xyes; then
129 if test "x$GCC" = xyes; then
130 CFLAGS="$CFLAGS -m32"
132 if test "x$GXX" = xyes; then
133 CXXFLAGS="$CXXFLAGS -m32"
136 AC_ARG_ENABLE([64-bit],
137 [AS_HELP_STRING([--enable-64-bit],
138 [build 64-bit libraries @<:@default=auto@:>@])],
139 [enable_64bit="$enableval"],
142 if test "x$enable_64bit" = xyes; then
143 if test "x$GCC" = xyes; then
144 CFLAGS="$CFLAGS -m64"
146 if test "x$GXX" = xyes; then
147 CXXFLAGS="$CXXFLAGS -m64"
152 dnl shared/static libraries, mimic libtool options
154 AC_ARG_ENABLE([static],
155 [AS_HELP_STRING([--enable-static],
156 [build static libraries @<:@default=disabled@:>@])],
157 [enable_static="$enableval"],
160 case "x$enable_static" in
162 x ) enable_static=no ;;
164 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
167 AC_ARG_ENABLE([shared],
168 [AS_HELP_STRING([--disable-shared],
169 [build shared libraries @<:@default=enabled@:>@])],
170 [enable_shared="$enableval"],
173 case "x$enable_shared" in
175 x ) enable_shared=yes ;;
177 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
181 dnl Can't have static and shared libraries, default to static if user
182 dnl explicitly requested. If both disabled, set to static since shared
183 dnl was explicitly requirested.
184 case "x$enable_static$enable_shared" in
186 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
190 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
198 AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
199 if test "$enable_static" = yes; then
200 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
202 AC_SUBST([MKLIB_OPTIONS])
205 dnl other compiler options
207 AC_ARG_ENABLE([debug],
208 [AS_HELP_STRING([--enable-debug],
209 [use debug compiler flags and macros @<:@default=disabled@:>@])],
210 [enable_debug="$enableval"],
213 if test "x$enable_debug" = xyes; then
214 DEFINES="$DEFINES -DDEBUG"
215 if test "x$GCC" = xyes; then
218 if test "x$GXX" = xyes; then
219 CXXFLAGS="$CXXFLAGS -g"
226 if test "$enable_static" = yes; then
227 GL_LIB_NAME='lib$(GL_LIB).a'
228 GLU_LIB_NAME='lib$(GLU_LIB).a'
229 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
230 GLW_LIB_NAME='lib$(GLW_LIB).a'
231 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
233 GL_LIB_NAME='lib$(GL_LIB).so'
234 GLU_LIB_NAME='lib$(GLU_LIB).so'
235 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
236 GLW_LIB_NAME='lib$(GLW_LIB).so'
237 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
239 AC_SUBST([GL_LIB_NAME])
240 AC_SUBST([GLU_LIB_NAME])
241 AC_SUBST([GLUT_LIB_NAME])
242 AC_SUBST([GLW_LIB_NAME])
243 AC_SUBST([OSMESA_LIB_NAME])
246 dnl Arch/platform-specific settings
249 [AS_HELP_STRING([--disable-asm],
250 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
251 [enable_asm="$enableval"],
258 AC_MSG_CHECKING([whether to enable assembly])
259 test "x$enable_asm" = xno && AC_MSG_RESULT([no])
260 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
261 if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
265 AC_MSG_RESULT([no, cross compiling])
269 # check for supported arches
270 if test "x$enable_asm" = xyes; then
274 linux* | *freebsd* | dragonfly*)
275 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
281 linux* | *freebsd* | dragonfly*)
282 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
297 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
298 ASM_SOURCES='$(X86_SOURCES)'
300 AC_MSG_RESULT([yes, x86])
303 ASM_FLAGS="-DUSE_X86_64_ASM"
304 ASM_SOURCES='$(X86-64_SOURCES)'
305 ASM_API='$(X86-64_API)'
306 AC_MSG_RESULT([yes, x86_64])
309 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
310 ASM_SOURCES='$(PPC_SOURCES)'
311 AC_MSG_RESULT([yes, ppc])
314 AC_MSG_RESULT([no, platform not supported])
318 AC_SUBST([ASM_FLAGS])
319 AC_SUBST([ASM_SOURCES])
325 dnl Check to see if dlopen is in default libraries (like Solaris, which
326 dnl has it in libc), or if libdl is needed to get it.
327 AC_CHECK_FUNC([dlopen], [],
328 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
330 dnl See if posix_memalign is available
331 AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
333 dnl SELinux awareness.
334 AC_ARG_ENABLE([selinux],
335 [AS_HELP_STRING([--enable-selinux],
336 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
337 [MESA_SELINUX="$enableval"],
339 if test "x$enable_selinux" = "xyes"; then
340 AC_CHECK_HEADER([selinux/selinux.h],[],
341 [AC_MSG_ERROR([SELinux headers not found])])
342 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
343 [AC_MSG_ERROR([SELinux library not found])])
344 SELINUX_LIBS="-lselinux"
345 DEFINES="$DEFINES -DMESA_SELINUX"
348 dnl OS-specific libraries
353 if test "x$GXX" != xyes; then
354 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
360 dnl Driver configuration. Options are xlib, dri and osmesa right now.
361 dnl More later: directfb, fbdev, ...
363 default_driver="xlib"
368 i*86|x86_64|powerpc*) default_driver="dri";;
371 *freebsd* | dragonfly*)
373 i*86|x86_64) default_driver="dri";;
378 AC_ARG_WITH([driver],
379 [AS_HELP_STRING([--with-driver=DRIVER],
380 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
381 [mesa_driver="$withval"],
382 [mesa_driver="$default_driver"])
383 dnl Check for valid option
384 case "x$mesa_driver" in
388 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
393 dnl Driver specific build directories
398 case "$mesa_driver" in
403 SRC_DIRS="glx/x11 $SRC_DIRS"
413 AC_SUBST([DRIVER_DIRS])
414 AC_SUBST([WINDOW_SYSTEM])
417 dnl User supplied program configuration
419 if test -d "$srcdir/progs/demos"; then
425 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
426 [optional comma delimited demo directories to build
427 @<:@default=auto if source available@:>@])],
428 [with_demos="$withval"],
429 [with_demos="$default_demos"])
430 if test "x$with_demos" = x; then
434 dnl If $with_demos is yes, directories will be added as libs available
436 case "$with_demos" in
439 # If the driver isn't osmesa, we have libGL and can build xdemos
440 if test "$mesa_driver" != osmesa; then
441 PROGRAM_DIRS="xdemos"
445 # verify the requested demos directories exist
446 demos=`IFS=,; echo $with_demos`
447 for demo in $demos; do
448 test -d "$srcdir/progs/$demo" || \
449 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
451 PROGRAM_DIRS="$demos"
456 dnl Find out if X is available. The variable have_x is set if libX11 is
457 dnl found to mimic AC_PATH_XTRA.
459 if test -n "$PKG_CONFIG"; then
460 AC_MSG_CHECKING([pkg-config files for X11 are available])
461 PKG_CHECK_EXISTS([x11],[
467 AC_MSG_RESULT([$x11_pkgconfig])
471 dnl Use the autoconf macro if no pkg-config files
472 if test "$x11_pkgconfig" = no; then
476 dnl Try to tell the user that the --x-* options are only used when
477 dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
478 m4_divert_once([HELP_BEGIN],
479 [These options are only used when the X libraries cannot be found by the
480 pkg-config utility.])
482 dnl We need X for xlib and dri, so bomb now if it's not found
483 case "$mesa_driver" in
485 if test "$no_x" = yes; then
486 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
491 dnl XCB - this is only used for GLX right now
493 [AS_HELP_STRING([--enable-xcb],
494 [use XCB for GLX @<:@default=disabled@:>@])],
495 [enable_xcb="$enableval"],
497 if test "x$enable_xcb" = xyes; then
498 DEFINES="$DEFINES -DUSE_XCB"
504 dnl libGL configuration per driver
506 case "$mesa_driver" in
508 if test "$x11_pkgconfig" = yes; then
509 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
510 GL_PC_REQ_PRIV="x11 xext"
511 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
512 GL_LIB_DEPS="$XLIBGL_LIBS"
514 # should check these...
515 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
516 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
517 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
518 GL_PC_CFLAGS="$X11_INCLUDES"
520 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
521 GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread $OS_LIBS"
523 # if static, move the external libraries to the programs
524 # and empty the libraries for libGL
525 if test "$enable_static" = yes; then
526 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
531 # DRI must be shared, I think
532 if test "$enable_static" = yes; then
533 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
537 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
538 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
539 GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
540 DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
542 # find the DRI deps for libGL
543 if test "$x11_pkgconfig" = yes; then
544 # add xcb modules if necessary
545 dri_modules="x11 xext xxf86vm xdamage xfixes"
546 if test "$enable_xcb" = yes; then
547 dri_modules="$dri_modules x11-xcb xcb-glx"
550 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
551 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
552 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
553 GL_LIB_DEPS="$DRIGL_LIBS"
555 # should check these...
556 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
557 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
558 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
559 GL_PC_CFLAGS="$X11_INCLUDES"
561 # XCB can only be used from pkg-config
562 if test "$enable_xcb" = yes; then
563 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
564 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
565 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
566 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
570 # need DRM libs, -lpthread, etc.
571 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
572 GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS $OS_LIBS"
575 # No libGL for osmesa
576 GL_LIB_DEPS="$OS_LIBS"
579 AC_SUBST([GL_LIB_DEPS])
580 AC_SUBST([GL_PC_REQ_PRIV])
581 AC_SUBST([GL_PC_LIB_PRIV])
582 AC_SUBST([GL_PC_CFLAGS])
583 AC_SUBST([DRI_PC_REQ_PRIV])
588 if test "$mesa_driver" = xlib; then
589 DEFINES="$DEFINES -DUSE_XSHM"
595 AC_ARG_ENABLE([glx-tls],
596 [AS_HELP_STRING([--enable-glx-tls],
597 [enable TLS support in GLX @<:@default=disabled@:>@])],
598 [GLX_USE_TLS="$enableval"],
600 dnl Directory for DRI drivers
601 AC_ARG_WITH([dri-driverdir],
602 [AS_HELP_STRING([--with-dri-driverdir=DIR],
603 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
604 [DRI_DRIVER_INSTALL_DIR="$withval"],
605 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
606 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
607 dnl Direct rendering or just indirect rendering
608 AC_ARG_ENABLE([driglx-direct],
609 [AS_HELP_STRING([--disable-driglx-direct],
610 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
611 [driglx_direct="$enableval"],
612 [driglx_direct="yes"])
613 dnl Which drivers to build - default is chosen by platform
614 AC_ARG_WITH([dri-drivers],
615 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
616 [comma delimited DRI drivers list, e.g.
617 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
618 [with_dri_drivers="$withval"],
619 [with_dri_drivers=yes])
620 if test "x$with_dri_drivers" = x; then
624 dnl If $with_dri_drivers is yes, directories will be added through
627 case "$with_dri_drivers" in
633 # verify the requested driver directories exist
634 dri_drivers=`IFS=', '; echo $with_dri_drivers`
635 for driver in $dri_drivers; do
636 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
637 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
639 DRI_DIRS="$dri_drivers"
643 dnl Just default to no EGL for now
645 AC_SUBST([USING_EGL])
647 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
648 if test "$mesa_driver" = dri; then
650 if test "x$GLX_USE_TLS" = xyes; then
651 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
654 if test "x$USING_EGL" = x1; then
658 # Platform specific settings and drivers to build
661 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
662 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
663 if test "x$driglx_direct" = xyes; then
664 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
669 # ffb, gamma, and sis are missing because they have not be
670 # converted to use the new interface. i810 are missing
671 # because there is no x86-64 system where they could *ever*
673 if test "x$DRI_DIRS" = "xyes"; then
674 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
675 savage tdfx unichrome swrast"
679 # Build only the drivers for cards that exist on PowerPC.
680 # At some point MGA will be added, but not yet.
681 if test "x$DRI_DIRS" = "xyes"; then
682 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
686 # Build only the drivers for cards that exist on sparc`
687 if test "x$DRI_DIRS" = "xyes"; then
688 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
693 freebsd* | dragonfly*)
694 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
695 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
696 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
697 if test "x$driglx_direct" = xyes; then
698 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
700 if test "x$GXX" = xyes; then
701 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
704 # ffb and gamma are missing because they have not been converted
705 # to use the new interface.
706 if test "x$DRI_DIRS" = "xyes"; then
707 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
708 unichrome savage sis swrast"
712 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
713 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
714 if test "x$driglx_direct" = xyes; then
715 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
721 if test "x$DRI_DIRS" = "xyes"; then
722 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
723 savage sis tdfx trident unichrome ffb swrast"
726 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
732 [AS_HELP_STRING([--with-expat=DIR],
733 [expat install directory])],[
734 EXPAT_INCLUDES="-I$withval/include"
735 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
736 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
737 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
739 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
740 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
741 [AC_MSG_ERROR([Expat required for DRI.])])
743 # put all the necessary libs together
744 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
747 AC_SUBST([EXPAT_INCLUDES])
748 AC_SUBST([DRI_LIB_DEPS])
751 dnl OSMesa configuration
753 if test "$mesa_driver" = xlib; then
754 default_gl_osmesa=yes
758 AC_ARG_ENABLE([gl-osmesa],
759 [AS_HELP_STRING([--enable-gl-osmesa],
760 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
761 [gl_osmesa="$enableval"],
762 [gl_osmesa="$default_gl_osmesa"])
763 if test "x$gl_osmesa" = xyes; then
764 if test "$mesa_driver" = osmesa; then
765 AC_MSG_ERROR([libGL is not available for OSMesa driver])
767 DRIVER_DIRS="$DRIVER_DIRS osmesa"
771 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
772 AC_ARG_WITH([osmesa-bits],
773 [AS_HELP_STRING([--with-osmesa-bits=BITS],
774 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
775 [osmesa_bits="$withval"],
777 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
778 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
781 case "x$osmesa_bits" in
786 OSMESA_LIB="OSMesa$osmesa_bits"
787 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
790 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
793 AC_SUBST([OSMESA_LIB])
795 case "$mesa_driver" in
797 # only link libraries with osmesa if shared
798 if test "$enable_static" = no; then
799 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
804 OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS"
807 # Link OSMesa to libGL otherwise
809 # only link libraries with osmesa if shared
810 if test "$enable_static" = no; then
811 OSMESA_MESA_DEPS='-l$(GL_LIB)'
818 if test "$enable_static" = no; then
819 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
821 OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV $OS_LIBS"
822 AC_SUBST([OSMESA_LIB_DEPS])
823 AC_SUBST([OSMESA_MESA_DEPS])
824 AC_SUBST([OSMESA_PC_REQ])
825 AC_SUBST([OSMESA_PC_LIB_PRIV])
828 dnl GLU configuration
831 [AS_HELP_STRING([--disable-glu],
832 [enable OpenGL Utility library @<:@default=enabled@:>@])],
833 [enable_glu="$enableval"],
835 if test "x$enable_glu" = xyes; then
836 SRC_DIRS="$SRC_DIRS glu"
838 case "$mesa_driver" in
840 # If GLU is available and we have libOSMesa (not 16 or 32),
841 # we can build the osdemos
842 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
843 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
846 # Link libGLU to libOSMesa instead of libGL
849 if test "$enable_static" = no; then
850 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
856 # If static, empty GLU_LIB_DEPS and add libs for programs to link
858 GLU_PC_LIB_PRIV="-lm"
859 if test "$enable_static" = no; then
861 GLU_MESA_DEPS='-l$(GL_LIB)'
865 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
870 if test "$enable_static" = no; then
871 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
873 GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
874 AC_SUBST([GLU_LIB_DEPS])
875 AC_SUBST([GLU_MESA_DEPS])
876 AC_SUBST([GLU_PC_REQ])
877 AC_SUBST([GLU_PC_REQ_PRIV])
878 AC_SUBST([GLU_PC_LIB_PRIV])
879 AC_SUBST([GLU_PC_CFLAGS])
882 dnl GLw configuration
885 [AS_HELP_STRING([--disable-glw],
886 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
887 [enable_glw="$enableval"],
889 dnl Don't build GLw on osmesa
890 if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
891 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
894 AC_ARG_ENABLE([motif],
895 [AS_HELP_STRING([--enable-motif],
896 [use Motif widgets in GLw @<:@default=disabled@:>@])],
897 [enable_motif="$enableval"],
900 if test "x$enable_glw" = xyes; then
901 SRC_DIRS="$SRC_DIRS glw"
902 if test "$x11_pkgconfig" = yes; then
903 PKG_CHECK_MODULES([GLW],[x11 xt])
904 GLW_PC_REQ_PRIV="x11 xt"
905 GLW_LIB_DEPS="$GLW_LIBS"
907 # should check these...
908 GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
909 GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
910 GLW_PC_CFLAGS="$X11_INCLUDES"
913 GLW_SOURCES="GLwDrawA.c"
915 if test "x$enable_motif" = xyes; then
916 GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
917 AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
918 if test "x$MOTIF_CONFIG" != xno; then
919 MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
920 MOTIF_LIBS=`$MOTIF_CONFIG --libs`
922 AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
923 [AC_MSG_ERROR([Can't locate Motif headers])])
924 AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
925 [AC_MSG_ERROR([Can't locate Motif Xm library])])
927 # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
928 GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
929 GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
930 GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
933 # If static, empty GLW_LIB_DEPS and add libs for programs to link
934 GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV $OS_LIBS"
935 if test "$enable_static" = no; then
936 GLW_MESA_DEPS='-l$(GL_LIB)'
937 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
939 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
944 AC_SUBST([GLW_LIB_DEPS])
945 AC_SUBST([GLW_MESA_DEPS])
946 AC_SUBST([GLW_SOURCES])
947 AC_SUBST([MOTIF_CFLAGS])
948 AC_SUBST([GLW_PC_REQ_PRIV])
949 AC_SUBST([GLW_PC_LIB_PRIV])
950 AC_SUBST([GLW_PC_CFLAGS])
953 dnl GLUT configuration
955 if test -f "$srcdir/include/GL/glut.h"; then
960 AC_ARG_ENABLE([glut],
961 [AS_HELP_STRING([--disable-glut],
962 [enable GLUT library @<:@default=enabled if source available@:>@])],
963 [enable_glut="$enableval"],
964 [enable_glut="$default_glut"])
966 dnl Can't build glut if GLU not available
967 if test "x$enable_glu$enable_glut" = xnoyes; then
968 AC_MSG_WARN([Disabling glut since GLU is disabled])
971 dnl Don't build glut on osmesa
972 if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
973 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
977 if test "x$enable_glut" = xyes; then
978 SRC_DIRS="$SRC_DIRS glut/glx"
980 if test "x$GCC" = xyes; then
981 GLUT_CFLAGS="-fexceptions"
983 if test "$x11_pkgconfig" = yes; then
984 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
985 GLUT_PC_REQ_PRIV="x11 xmu xi"
986 GLUT_LIB_DEPS="$GLUT_LIBS"
988 # should check these...
989 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
990 GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
991 GLUT_PC_CFLAGS="$X11_INCLUDES"
993 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
994 GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm $OS_LIBS"
996 # If glut is available, we can build most programs
997 if test "$with_demos" = yes; then
998 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
1001 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
1002 if test "$enable_static" = no; then
1003 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
1005 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
1010 AC_SUBST([GLUT_LIB_DEPS])
1011 AC_SUBST([GLUT_MESA_DEPS])
1012 AC_SUBST([GLUT_CFLAGS])
1013 AC_SUBST([GLUT_PC_REQ_PRIV])
1014 AC_SUBST([GLUT_PC_LIB_PRIV])
1015 AC_SUBST([GLUT_PC_CFLAGS])
1018 dnl Program library dependencies
1019 dnl Only libm is added here if necessary as the libraries should
1020 dnl be pulled in by the linker
1022 if test "x$APP_LIB_DEPS" = x; then
1025 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
1032 AC_SUBST([APP_LIB_DEPS])
1033 AC_SUBST([PROGRAM_DIRS])
1036 dnl Restore LDFLAGS and CPPFLAGS
1037 LDFLAGS="$_SAVE_LDFLAGS"
1038 CPPFLAGS="$_SAVE_CPPFLAGS"
1040 dnl Substitute the config
1041 AC_CONFIG_FILES([configs/autoconf])
1043 dnl Replace the configs/current symlink
1044 AC_CONFIG_COMMANDS([configs],[
1045 if test -f configs/current || test -L configs/current; then
1046 rm -f configs/current
1048 ln -s autoconf configs/current
1054 dnl Output some configuration info for the user
1057 echo " prefix: $prefix"
1058 echo " exec_prefix: $exec_prefix"
1059 echo " libdir: $libdir"
1060 echo " includedir: $includedir"
1064 echo " Driver: $mesa_driver"
1065 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1066 echo " OSMesa: lib$OSMESA_LIB"
1070 if test "$mesa_driver" = dri; then
1071 # cleanup the drivers var
1072 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1073 if test "x$DRI_DIRS" = x; then
1074 echo " DRI drivers: no"
1076 echo " DRI drivers: $dri_dirs"
1078 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
1080 echo " Use XCB: $enable_xcb"
1084 echo " Shared libs: $enable_shared"
1085 echo " Static libs: $enable_static"
1086 echo " GLU: $enable_glu"
1087 echo " GLw: $enable_glw (Motif: $enable_motif)"
1088 echo " glut: $enable_glut"
1091 # cleanup the programs var for display
1092 program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1093 if test "x$program_dirs" = x; then
1096 echo " Demos: $program_dirs"
1099 dnl Compiler options
1100 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1101 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1102 $SED 's/^ *//;s/ */ /;s/ *$//'`
1103 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1104 $SED 's/^ *//;s/ */ /;s/ *$//'`
1105 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1107 echo " CFLAGS: $cflags"
1108 echo " CXXFLAGS: $cxxflags"
1109 echo " Macros: $defines"
1112 echo " Run '${MAKE-make}' to build Mesa"