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 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
395 case "$mesa_driver" in
400 SRC_DIRS="glx/x11 $SRC_DIRS"
410 AC_SUBST([DRIVER_DIRS])
411 AC_SUBST([WINDOW_SYSTEM])
414 dnl User supplied program configuration
416 if test -d "$srcdir/progs/demos"; then
422 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
423 [optional comma delimited demo directories to build
424 @<:@default=auto if source available@:>@])],
425 [with_demos="$withval"],
426 [with_demos="$default_demos"])
427 if test "x$with_demos" = x; then
431 dnl If $with_demos is yes, directories will be added as libs available
433 case "$with_demos" in
436 # If the driver isn't osmesa, we have libGL and can build xdemos
437 if test "$mesa_driver" != osmesa; then
438 PROGRAM_DIRS="xdemos"
442 # verify the requested demos directories exist
443 demos=`IFS=,; echo $with_demos`
444 for demo in $demos; do
445 test -d "$srcdir/progs/$demo" || \
446 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
448 PROGRAM_DIRS="$demos"
453 dnl Find out if X is available. The variable have_x is set if libX11 is
454 dnl found to mimic AC_PATH_XTRA.
456 if test -n "$PKG_CONFIG"; then
457 AC_MSG_CHECKING([pkg-config files for X11 are available])
458 PKG_CHECK_EXISTS([x11],[
464 AC_MSG_RESULT([$x11_pkgconfig])
468 dnl Use the autoconf macro if no pkg-config files
469 if test "$x11_pkgconfig" = no; then
473 dnl Try to tell the user that the --x-* options are only used when
474 dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
475 m4_divert_once([HELP_BEGIN],
476 [These options are only used when the X libraries cannot be found by the
477 pkg-config utility.])
479 dnl We need X for xlib and dri, so bomb now if it's not found
480 case "$mesa_driver" in
482 if test "$no_x" = yes; then
483 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
488 dnl XCB - this is only used for GLX right now
490 [AS_HELP_STRING([--enable-xcb],
491 [use XCB for GLX @<:@default=disabled@:>@])],
492 [enable_xcb="$enableval"],
494 if test "x$enable_xcb" = xyes; then
495 DEFINES="$DEFINES -DUSE_XCB"
501 dnl libGL configuration per driver
503 case "$mesa_driver" in
505 if test "$x11_pkgconfig" = yes; then
506 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
507 GL_PC_REQ_PRIV="x11 xext"
508 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
509 GL_LIB_DEPS="$XLIBGL_LIBS"
511 # should check these...
512 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
513 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
514 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
515 GL_PC_CFLAGS="$X11_INCLUDES"
517 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
518 GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread $OS_LIBS"
520 # if static, move the external libraries to the programs
521 # and empty the libraries for libGL
522 if test "$enable_static" = yes; then
523 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
528 # DRI must be shared, I think
529 if test "$enable_static" = yes; then
530 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
534 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
535 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
536 GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
537 DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
539 # find the DRI deps for libGL
540 if test "$x11_pkgconfig" = yes; then
541 # add xcb modules if necessary
542 dri_modules="x11 xext xxf86vm xdamage xfixes"
543 if test "$enable_xcb" = yes; then
544 dri_modules="$dri_modules x11-xcb xcb-glx"
547 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
548 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
549 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
550 GL_LIB_DEPS="$DRIGL_LIBS"
552 # should check these...
553 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
554 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
555 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
556 GL_PC_CFLAGS="$X11_INCLUDES"
558 # XCB can only be used from pkg-config
559 if test "$enable_xcb" = yes; then
560 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
561 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
562 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
563 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
567 # need DRM libs, -lpthread, etc.
568 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
569 GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS $OS_LIBS"
572 # No libGL for osmesa
573 GL_LIB_DEPS="$OS_LIBS"
576 AC_SUBST([GL_LIB_DEPS])
577 AC_SUBST([GL_PC_REQ_PRIV])
578 AC_SUBST([GL_PC_LIB_PRIV])
579 AC_SUBST([GL_PC_CFLAGS])
580 AC_SUBST([DRI_PC_REQ_PRIV])
585 if test "$mesa_driver" = xlib; then
586 DEFINES="$DEFINES -DUSE_XSHM"
592 AC_ARG_ENABLE([glx-tls],
593 [AS_HELP_STRING([--enable-glx-tls],
594 [enable TLS support in GLX @<:@default=disabled@:>@])],
595 [GLX_USE_TLS="$enableval"],
597 dnl Directory for DRI drivers
598 AC_ARG_WITH([dri-driverdir],
599 [AS_HELP_STRING([--with-dri-driverdir=DIR],
600 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
601 [DRI_DRIVER_INSTALL_DIR="$withval"],
602 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
603 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
604 dnl Direct rendering or just indirect rendering
605 AC_ARG_ENABLE([driglx-direct],
606 [AS_HELP_STRING([--disable-driglx-direct],
607 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
608 [driglx_direct="$enableval"],
609 [driglx_direct="yes"])
610 dnl Which drivers to build - default is chosen by platform
611 AC_ARG_WITH([dri-drivers],
612 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
613 [comma delimited DRI drivers list, e.g.
614 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
615 [with_dri_drivers="$withval"],
616 [with_dri_drivers=yes])
617 if test "x$with_dri_drivers" = x; then
621 dnl If $with_dri_drivers is yes, directories will be added through
624 case "$with_dri_drivers" in
630 # verify the requested driver directories exist
631 dri_drivers=`IFS=', '; echo $with_dri_drivers`
632 for driver in $dri_drivers; do
633 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
634 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
636 DRI_DIRS="$dri_drivers"
640 dnl Just default to no EGL for now
642 AC_SUBST([USING_EGL])
644 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
645 if test "$mesa_driver" = dri; then
647 if test "x$GLX_USE_TLS" = xyes; then
648 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
651 if test "x$USING_EGL" = x1; then
655 # Platform specific settings and drivers to build
658 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
659 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
660 if test "x$driglx_direct" = xyes; then
661 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
666 # ffb, gamma, and sis are missing because they have not be
667 # converted to use the new interface. i810 are missing
668 # because there is no x86-64 system where they could *ever*
670 if test "x$DRI_DIRS" = "xyes"; then
671 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
672 savage tdfx unichrome swrast"
676 # Build only the drivers for cards that exist on PowerPC.
677 # At some point MGA will be added, but not yet.
678 if test "x$DRI_DIRS" = "xyes"; then
679 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
683 # Build only the drivers for cards that exist on sparc`
684 if test "x$DRI_DIRS" = "xyes"; then
685 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
690 freebsd* | dragonfly*)
691 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
692 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
693 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
694 if test "x$driglx_direct" = xyes; then
695 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
697 if test "x$GXX" = xyes; then
698 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
701 # ffb and gamma are missing because they have not been converted
702 # to use the new interface.
703 if test "x$DRI_DIRS" = "xyes"; then
704 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
705 unichrome savage sis swrast"
709 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
710 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
711 if test "x$driglx_direct" = xyes; then
712 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
718 if test "x$DRI_DIRS" = "xyes"; then
719 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
720 savage sis tdfx trident unichrome ffb swrast"
723 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
729 [AS_HELP_STRING([--with-expat=DIR],
730 [expat install directory])],[
731 EXPAT_INCLUDES="-I$withval/include"
732 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
733 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
734 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
736 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
737 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
738 [AC_MSG_ERROR([Expat required for DRI.])])
740 # put all the necessary libs together
741 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
744 AC_SUBST([EXPAT_INCLUDES])
745 AC_SUBST([DRI_LIB_DEPS])
748 dnl OSMesa configuration
750 if test "$mesa_driver" = xlib; then
751 default_gl_osmesa=yes
755 AC_ARG_ENABLE([gl-osmesa],
756 [AS_HELP_STRING([--enable-gl-osmesa],
757 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
758 [gl_osmesa="$enableval"],
759 [gl_osmesa="$default_gl_osmesa"])
760 if test "x$gl_osmesa" = xyes; then
761 if test "$mesa_driver" = osmesa; then
762 AC_MSG_ERROR([libGL is not available for OSMesa driver])
764 DRIVER_DIRS="$DRIVER_DIRS osmesa"
768 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
769 AC_ARG_WITH([osmesa-bits],
770 [AS_HELP_STRING([--with-osmesa-bits=BITS],
771 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
772 [osmesa_bits="$withval"],
774 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
775 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
778 case "x$osmesa_bits" in
783 OSMESA_LIB="OSMesa$osmesa_bits"
784 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
787 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
790 AC_SUBST([OSMESA_LIB])
792 case "$mesa_driver" in
794 # only link libraries with osmesa if shared
795 if test "$enable_static" = no; then
796 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
801 OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS"
804 # Link OSMesa to libGL otherwise
806 # only link libraries with osmesa if shared
807 if test "$enable_static" = no; then
808 OSMESA_MESA_DEPS='-l$(GL_LIB)'
815 if test "$enable_static" = no; then
816 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
818 OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV $OS_LIBS"
819 AC_SUBST([OSMESA_LIB_DEPS])
820 AC_SUBST([OSMESA_MESA_DEPS])
821 AC_SUBST([OSMESA_PC_REQ])
822 AC_SUBST([OSMESA_PC_LIB_PRIV])
825 dnl GLU configuration
828 [AS_HELP_STRING([--disable-glu],
829 [enable OpenGL Utility library @<:@default=enabled@:>@])],
830 [enable_glu="$enableval"],
832 if test "x$enable_glu" = xyes; then
833 SRC_DIRS="$SRC_DIRS glu"
835 case "$mesa_driver" in
837 # If GLU is available and we have libOSMesa (not 16 or 32),
838 # we can build the osdemos
839 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
840 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
843 # Link libGLU to libOSMesa instead of libGL
846 if test "$enable_static" = no; then
847 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
853 # If static, empty GLU_LIB_DEPS and add libs for programs to link
855 GLU_PC_LIB_PRIV="-lm"
856 if test "$enable_static" = no; then
858 GLU_MESA_DEPS='-l$(GL_LIB)'
862 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
867 if test "$enable_static" = no; then
868 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
870 GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
871 AC_SUBST([GLU_LIB_DEPS])
872 AC_SUBST([GLU_MESA_DEPS])
873 AC_SUBST([GLU_PC_REQ])
874 AC_SUBST([GLU_PC_REQ_PRIV])
875 AC_SUBST([GLU_PC_LIB_PRIV])
876 AC_SUBST([GLU_PC_CFLAGS])
879 dnl GLw configuration
882 [AS_HELP_STRING([--disable-glw],
883 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
884 [enable_glw="$enableval"],
886 dnl Don't build GLw on osmesa
887 if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
888 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
891 AC_ARG_ENABLE([motif],
892 [AS_HELP_STRING([--enable-motif],
893 [use Motif widgets in GLw @<:@default=disabled@:>@])],
894 [enable_motif="$enableval"],
897 if test "x$enable_glw" = xyes; then
898 SRC_DIRS="$SRC_DIRS glw"
899 if test "$x11_pkgconfig" = yes; then
900 PKG_CHECK_MODULES([GLW],[x11 xt])
901 GLW_PC_REQ_PRIV="x11 xt"
902 GLW_LIB_DEPS="$GLW_LIBS"
904 # should check these...
905 GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
906 GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
907 GLW_PC_CFLAGS="$X11_INCLUDES"
910 GLW_SOURCES="GLwDrawA.c"
912 if test "x$enable_motif" = xyes; then
913 GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
914 AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
915 if test "x$MOTIF_CONFIG" != xno; then
916 MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
917 MOTIF_LIBS=`$MOTIF_CONFIG --libs`
919 AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
920 [AC_MSG_ERROR([Can't locate Motif headers])])
921 AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
922 [AC_MSG_ERROR([Can't locate Motif Xm library])])
924 # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
925 GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
926 GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
927 GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
930 # If static, empty GLW_LIB_DEPS and add libs for programs to link
931 GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV $OS_LIBS"
932 if test "$enable_static" = no; then
933 GLW_MESA_DEPS='-l$(GL_LIB)'
934 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
936 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
941 AC_SUBST([GLW_LIB_DEPS])
942 AC_SUBST([GLW_MESA_DEPS])
943 AC_SUBST([GLW_SOURCES])
944 AC_SUBST([MOTIF_CFLAGS])
945 AC_SUBST([GLW_PC_REQ_PRIV])
946 AC_SUBST([GLW_PC_LIB_PRIV])
947 AC_SUBST([GLW_PC_CFLAGS])
950 dnl GLUT configuration
952 if test -f "$srcdir/include/GL/glut.h"; then
957 AC_ARG_ENABLE([glut],
958 [AS_HELP_STRING([--disable-glut],
959 [enable GLUT library @<:@default=enabled if source available@:>@])],
960 [enable_glut="$enableval"],
961 [enable_glut="$default_glut"])
963 dnl Can't build glut if GLU not available
964 if test "x$enable_glu$enable_glut" = xnoyes; then
965 AC_MSG_WARN([Disabling glut since GLU is disabled])
968 dnl Don't build glut on osmesa
969 if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
970 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
974 if test "x$enable_glut" = xyes; then
975 SRC_DIRS="$SRC_DIRS glut/glx"
977 if test "x$GCC" = xyes; then
978 GLUT_CFLAGS="-fexceptions"
980 if test "$x11_pkgconfig" = yes; then
981 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
982 GLUT_PC_REQ_PRIV="x11 xmu xi"
983 GLUT_LIB_DEPS="$GLUT_LIBS"
985 # should check these...
986 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
987 GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
988 GLUT_PC_CFLAGS="$X11_INCLUDES"
990 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
991 GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm $OS_LIBS"
993 # If glut is available, we can build most programs
994 if test "$with_demos" = yes; then
995 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
998 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
999 if test "$enable_static" = no; then
1000 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
1002 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
1007 AC_SUBST([GLUT_LIB_DEPS])
1008 AC_SUBST([GLUT_MESA_DEPS])
1009 AC_SUBST([GLUT_CFLAGS])
1010 AC_SUBST([GLUT_PC_REQ_PRIV])
1011 AC_SUBST([GLUT_PC_LIB_PRIV])
1012 AC_SUBST([GLUT_PC_CFLAGS])
1015 dnl Program library dependencies
1016 dnl Only libm is added here if necessary as the libraries should
1017 dnl be pulled in by the linker
1019 if test "x$APP_LIB_DEPS" = x; then
1022 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
1029 AC_SUBST([APP_LIB_DEPS])
1030 AC_SUBST([PROGRAM_DIRS])
1033 dnl Restore LDFLAGS and CPPFLAGS
1034 LDFLAGS="$_SAVE_LDFLAGS"
1035 CPPFLAGS="$_SAVE_CPPFLAGS"
1037 dnl Substitute the config
1038 AC_CONFIG_FILES([configs/autoconf])
1040 dnl Replace the configs/current symlink
1041 AC_CONFIG_COMMANDS([configs],[
1042 if test -f configs/current || test -L configs/current; then
1043 rm -f configs/current
1045 ln -s autoconf configs/current
1051 dnl Output some configuration info for the user
1054 echo " prefix: $prefix"
1055 echo " exec_prefix: $exec_prefix"
1056 echo " libdir: $libdir"
1057 echo " includedir: $includedir"
1061 echo " Driver: $mesa_driver"
1062 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1063 echo " OSMesa: lib$OSMESA_LIB"
1067 if test "$mesa_driver" = dri; then
1068 # cleanup the drivers var
1069 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1070 if test "x$DRI_DIRS" = x; then
1071 echo " DRI drivers: no"
1073 echo " DRI drivers: $dri_dirs"
1075 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
1077 echo " Use XCB: $enable_xcb"
1081 echo " Shared libs: $enable_shared"
1082 echo " Static libs: $enable_static"
1083 echo " GLU: $enable_glu"
1084 echo " GLw: $enable_glw (Motif: $enable_motif)"
1085 echo " glut: $enable_glut"
1088 # cleanup the programs var for display
1089 program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1090 if test "x$program_dirs" = x; then
1093 echo " Demos: $program_dirs"
1096 dnl Compiler options
1097 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1098 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1099 $SED 's/^ *//;s/ */ /;s/ *$//'`
1100 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1101 $SED 's/^ *//;s/ */ /;s/ *$//'`
1102 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1104 echo " CFLAGS: $cflags"
1105 echo " CXXFLAGS: $cxxflags"
1106 echo " Macros: $defines"
1109 echo " Run '${MAKE-make}' to build Mesa"