1 dnl Process this file with autoconf to create configure.
6 dnl Make version number available to autoconf and configure
7 m4_define(mesa_major, 7)
8 m4_define(mesa_minor, 1)
9 m4_define(mesa_tiny, 0)
10 m4_define(mesa_version, [mesa_major().mesa_minor().mesa_tiny()])
12 AC_INIT(Mesa, mesa_version(), mesa3d@sourceforge.net)
13 AC_CONFIG_AUX_DIR(bin)
16 dnl Substitute the version number into shell variables
17 MESA_MAJOR=mesa_major()
18 MESA_MINOR=mesa_minor()
28 AC_PATH_PROG(MAKE, make)
29 AC_PATH_PROG(MKDEP, makedepend)
30 AC_PATH_PROG(SED, sed)
33 dnl LIB_DIR - library basename
34 LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
37 dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
38 _SAVE_LDFLAGS="$LDFLAGS"
39 AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
40 AC_SUBST(EXTRA_LIB_PATH)
42 dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
43 _SAVE_CPPFLAGS="$CPPFLAGS"
44 AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
45 AC_SUBST(X11_INCLUDES)
50 if test "x$GCC" = xyes; then
51 DEFINES="-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
55 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
59 dnl Add flags for gcc and g++
60 if test "x$GCC" = xyes; then
61 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
63 if test "x$GXX" = xyes; then
64 CXXFLAGS="$CXXFLAGS -Wall"
67 dnl These should be unnecessary, but let the user set them if they want
68 AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
69 Default is to use CFLAGS.])
70 AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
71 compiler. Default is to use CFLAGS.])
76 dnl shared/static libraries, mimic libtool options
79 [AS_HELP_STRING([--enable-static],
80 [build static libraries @<:@default=disabled@:>@])],
81 enable_static="$enableval",
84 case "x$enable_static" in
86 x ) enable_static=no ;;
88 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
92 [AS_HELP_STRING([--disable-shared],
93 [build shared libraries @<:@default=enabled@:>@])],
94 enable_shared="$enableval",
97 case "x$enable_shared" in
99 x ) enable_shared=yes ;;
101 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
105 dnl Can't have static and shared libraries, default to static if user
106 dnl explicitly requested. If both disabled, set to static since shared
107 dnl was explicitly requirested.
108 case "x$enable_static$enable_shared" in
110 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
114 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
122 AC_ARG_VAR(MKLIB_OPTIONS,[Options for the Mesa library script, mklib])
123 if test "$enable_static" = yes; then
124 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
126 AC_SUBST(MKLIB_OPTIONS)
132 if test "$enable_static" = yes; then
133 GL_LIB_NAME='lib$(GL_LIB).a'
134 GLU_LIB_NAME='lib$(GLU_LIB).a'
135 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
136 GLW_LIB_NAME='lib$(GLW_LIB).a'
137 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
139 GL_LIB_NAME='lib$(GL_LIB).so'
140 GLU_LIB_NAME='lib$(GLU_LIB).so'
141 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
142 GLW_LIB_NAME='lib$(GLW_LIB).so'
143 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
145 AC_SUBST(GL_LIB_NAME)
146 AC_SUBST(GLU_LIB_NAME)
147 AC_SUBST(GLUT_LIB_NAME)
148 AC_SUBST(GLW_LIB_NAME)
149 AC_SUBST(OSMESA_LIB_NAME)
152 dnl Driver configuration. Options are x11 (Xlib), dri and osmesa right now.
153 dnl More later: directfb, fbdev, ...
156 [AS_HELP_STRING([--with-driver=DRIVER],
157 [driver for Mesa: x11,dri,osmesa @<:@default=x11@:>@])],
158 mesa_driver="$withval",
160 dnl Check for valid option
161 case "x$mesa_driver" in
165 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
170 dnl Driver specific build directories
175 case "$mesa_driver" in
180 SRC_DIRS="glx/x11 $SRC_DIRS"
190 AC_SUBST(DRIVER_DIRS)
191 AC_SUBST(WINDOW_SYSTEM)
194 dnl User supplied program configuration
196 if test -d "$srcdir/progs/demos"; then
202 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
203 [optional comma delimited demo directories to build
204 @<:@default=yes if source available@:>@])],
205 with_demos="$withval",
206 with_demos="$default_demos")
207 if test "x$with_demos" = x; then
211 dnl If $with_demos is yes, directories will be added as libs available
213 case "$with_demos" in
216 # verify the requested demos directories exist
217 demos=`IFS=,; echo $with_demos`
218 for demo in $demos; do
219 test -d "$srcdir/progs/$demo" || \
220 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
222 PROGRAM_DIRS="$demos"
227 dnl Find out if X is available. The variables have_x or no_x will be
228 dnl set and used later in the driver setups
230 if test -n "$PKG_CONFIG"; then
231 AC_MSG_CHECKING([pkg-config files for X11 are available])
232 if $PKG_CONFIG --exists x11; then
244 dnl Use the autoconf macro if no pkg-config files
245 if test "$x11_pkgconfig" = no; then
249 dnl We need X for xlib and dri, so bomb now if it's not found
250 case "$mesa_driver" in
252 if test "$no_x" = yes; then
253 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
259 dnl libGL configuration per driver
261 case "$mesa_driver" in
263 if test "$x11_pkgconfig" = yes; then
264 PKG_CHECK_MODULES(X11GL, x11 xext)
265 X11_INCLUDES="$X11_INCLUDES $X11GL_CFLAGS"
266 GL_LIB_DEPS="$X11GL_LIBS"
268 # should check these...
269 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
270 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
272 GL_LIB_DEPS="$GL_LIB_DEPS -lm -lpthread"
274 # if static, move the external libraries to the programs
275 # and empty the libraries for libGL
276 if test "$enable_static" = yes; then
277 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
282 # DRI must be shared, I think
283 if test "$enable_static" = yes; then
284 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
288 PKG_CHECK_MODULES(LIBDRM, libdrm)
290 # find the DRI deps for libGL
291 if test "$x11_pkgconfig" = yes; then
292 PKG_CHECK_MODULES(DRIGL, x11 xext xxf86vm xdamage xfixes)
293 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
294 GL_LIB_DEPS="$DRIGL_LIBS"
296 # should check these...
297 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
298 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
301 # need DRM libs, -lpthread, etc.
302 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread -ldl"
305 # No libGL for osmesa
309 AC_SUBST(GL_LIB_DEPS)
314 if test "$mesa_driver" = x11; then
315 DEFINES="$DEFINES -DUSE_XSHM"
321 AC_ARG_ENABLE(glx-tls,
322 [AS_HELP_STRING([--enable-glx-tls],
323 [enable TLS support in GLX @<:@default=disabled@:>@])],
324 GLX_USE_TLS="$enableval",
326 dnl Directory for DRI drivers
327 AC_ARG_WITH(dri-driverdir,
328 [AS_HELP_STRING([--with-dri-driverdir=DIR],
329 [directory for the DRI drivers @<:@/usr/X11R6/lib/modules/dri@:>@])],
330 DRI_DRIVER_INSTALL_DIR="$withval",
331 DRI_DRIVER_INSTALL_DIR='/usr/X11R6/lib/modules/dri')
332 AC_SUBST(DRI_DRIVER_INSTALL_DIR)
333 dnl Direct rendering or just indirect rendering
334 AC_ARG_ENABLE(driglx-direct,
335 [AS_HELP_STRING([--disable-driglx-direct],
336 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
337 driglx_direct="$enableval",
340 dnl Which drivers to build - default is chosen by platform
341 AC_ARG_WITH(dri-drivers,
342 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
343 [comma delimited DRI drivers to build @<:@default=auto by platform@:>@])],
344 with_dri_drivers="$withval",
345 with_dri_drivers=yes)
346 if test "x$with_dri_drivers" = x; then
350 dnl If $with_dri_drivers is yes, directories will be added through
353 case "$with_dri_drivers" in
356 # verify the requested driver directories exist
357 dri_drivers=`IFS=,; echo $with_dri_drivers`
358 for driver in $dri_drivers; do
359 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
360 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
362 DRI_DIRS="$dri_drivers"
366 dnl Just default to no EGL for now
370 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
371 if test "$mesa_driver" = dri; then
373 if test "x$GLX_USE_TLS" = xyes; then
374 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
377 if test "x$USING_EGL" = x1; then
382 if test "x$DRI_DIRS" = x; then
383 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
384 savage sis tdfx trident unichrome ffb"
387 # Platform specific settings and drivers to build
390 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
391 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
392 if test "x$driglx_direct" = xyes; then
393 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
398 # ffb, gamma, and sis are missing because they have not be
399 # converted to use the new interface. i810 are missing
400 # because there is no x86-64 system where they could *ever*
402 if test "x$DRI_DIRS" = x; then
403 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
404 savage tdfx unichrome"
408 # Build only the drivers for cards that exist on PowerPC.
409 # At some point MGA will be added, but not yet.
410 if test "x$DRI_DIRS" = x; then
411 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
417 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
418 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
419 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
420 if test "x$driglx_direct" = xyes; then
421 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
423 if test "x$GXX" = xyes; then
424 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
427 # ffb and gamma are missing because they have not been converted
428 # to use the new interface.
429 if test "x$DRI_DIRS" = x; then
430 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
431 unichrome savage sis"
435 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
440 AC_ARG_WITH(expat, AS_HELP_STRING([--with-expat=DIR],
441 [expat install directory]),[
442 EXPAT_INCLUDES="-I$withval/include"
443 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
444 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
445 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
447 AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR([Expat required for DRI.]))
448 AC_CHECK_LIB(expat, XML_ParserCreate,,
449 AC_MSG_ERROR([Expat required for DRI.]))
451 # put all the necessary libs together
452 DRI_LIB_DEPS="$LIBDRM_LIBS $EXPAT_LIB -lm -lpthread -ldl"
455 AC_SUBST(EXPAT_INCLUDES)
456 AC_SUBST(DRI_LIB_DEPS)
459 dnl OSMesa configuration
461 if test "$mesa_driver" = x11; then
462 default_x11_osmesa=yes
464 default_x11_osmesa=no
466 AC_ARG_ENABLE(x11-osmesa,
467 [AS_HELP_STRING([--disable-x11-osmesa],
468 [enable OSMesa on X11 libGL @<:@default=enabled for x11 driver@:>@])],
469 x11_osmesa="$enableval",
470 x11_osmesa="$default_x11_osmesa")
471 if test "x$x11_osmesa" = xyes; then
472 if test "$mesa_driver" = x11; then
473 DRIVER_DIRS="$DRIVER_DIRS osmesa"
475 AC_MSG_ERROR([Can only enable OSMesa on libGL for X11])
479 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
480 AC_ARG_WITH(osmesa-bits,
481 [AS_HELP_STRING([--with-osmesa-bits=BITS],
482 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
483 osmesa_bits="$withval",
485 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
486 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
489 case "x$osmesa_bits" in
494 OSMESA_LIB="OSMesa$osmesa_bits"
495 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
498 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
503 case "$mesa_driver" in
505 # only link librararies with osmesa if shared
506 if test "$enable_static" = no; then
507 OSMESA_LIB_DEPS="-lm -lpthread"
514 # Link OSMesa to libGL otherwise
516 # only link librararies with osmesa if shared
517 if test "$enable_static" = no; then
518 OSMESA_MESA_DEPS='-l$(GL_LIB)'
524 AC_SUBST(OSMESA_LIB_DEPS)
525 AC_SUBST(OSMESA_MESA_DEPS)
528 dnl GLU configuration
531 [AS_HELP_STRING([--disable-glu],
532 [enable OpenGL Utility library @<:@default=enabled@:>@])],
533 enable_glu="$enableval",
535 if test "x$enable_glu" = xyes; then
536 SRC_DIRS="$SRC_DIRS glu"
538 case "$mesa_driver" in
540 # If GLU is available and we have libOSMesa (not 16 or 32),
541 # we can build the osdemos
542 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
543 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
546 # Link libGLU to libOSMesa instead of libGL
548 if test "$enable_static" = no; then
549 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
555 # If GLU is available, we can build the xdemos
556 if test "$with_demos" = yes; then
557 PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
560 # If static, empty GLU_LIB_DEPS and add libs for programs to link
561 if test "$enable_static" = no; then
563 GLU_MESA_DEPS='-l$(GL_LIB)'
567 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
572 AC_SUBST(GLU_LIB_DEPS)
573 AC_SUBST(GLU_MESA_DEPS)
576 dnl GLw configuration
579 [AS_HELP_STRING([--disable-glw],
580 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
581 enable_glw="$enableval",
583 dnl Don't build GLw on osmesa
584 if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
585 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
588 if test "x$enable_glw" = xyes; then
589 SRC_DIRS="$SRC_DIRS glw"
590 if test "$x11_pkgconfig" = yes; then
591 PKG_CHECK_MODULES(GLW, x11 xt)
592 GLW_LIB_DEPS="$GLW_LIBS"
594 # should check these...
595 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
598 # If static, empty GLW_LIB_DEPS and add libs for programs to link
599 if test "$enable_static" = no; then
600 GLW_MESA_DEPS='-l$(GL_LIB)'
602 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
607 AC_SUBST(GLW_LIB_DEPS)
608 AC_SUBST(GLW_MESA_DEPS)
611 dnl GLUT configuration
613 if test -f "$srcdir/include/GL/glut.h"; then
619 [AS_HELP_STRING([--disable-glut],
620 [enable GLUT library @<:@default=enabled if source available@:>@])],
621 enable_glut="$enableval",
622 enable_glut="$default_glut")
624 dnl Can't build glut if GLU not available
625 if test "x$enable_glu$enable_glut" = xnoyes; then
626 AC_MSG_WARN([Disabling glut since GLU is disabled])
629 dnl Don't build glut on osmesa
630 if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
631 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
635 if test "x$enable_glut" = xyes; then
636 SRC_DIRS="$SRC_DIRS glut/glx"
638 if test "x$GCC" = xyes; then
639 GLUT_CFLAGS="-fexceptions"
641 if test "$x11_pkgconfig" = yes; then
642 PKG_CHECK_MODULES(GLUT, x11 xmu xi)
643 GLUT_LIB_DEPS="$GLUT_LIBS"
645 # should check these...
646 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
648 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
650 # If glut is available, we can build most programs
651 if test "$with_demos" = yes; then
652 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
655 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
656 if test "$enable_static" = no; then
657 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
659 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
664 AC_SUBST(GLUT_LIB_DEPS)
665 AC_SUBST(GLUT_MESA_DEPS)
666 AC_SUBST(GLUT_CFLAGS)
669 dnl Program library dependencies
670 dnl Only libm is added here if necessary as the libraries should
671 dnl be pulled in by the linker
673 if test "x$APP_LIB_DEPS" = x; then
676 AC_SUBST(APP_LIB_DEPS)
677 AC_SUBST(PROGRAM_DIRS)
679 dnl Arch/platform-specific settings
686 AC_SUBST(ASM_SOURCES)
693 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
694 ASM_SOURCES='$(X86_SOURCES)'
698 ASM_FLAGS="-DUSE_X86_64_ASM"
699 ASM_SOURCES='$(X86-64_SOURCES)'
700 ASM_API='$(X86-64_API)'
703 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
704 ASM_SOURCES='$(PPC_SOURCES)'
713 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
714 ASM_SOURCES='$(X86_SOURCES)'
718 ASM_FLAGS="-DUSE_X86_64_ASM"
719 ASM_SOURCES='$(X86-64_SOURCES)'
720 ASM_API='$(X86-64_API)'
726 dnl Restore LDFLAGS and CPPFLAGS
727 LDFLAGS="$_SAVE_LDFLAGS"
728 CPPFLAGS="$_SAVE_CPPFLAGS"
730 dnl Substitute the config
731 AC_OUTPUT([configs/autoconf])
734 dnl Output some configuration info for the user
737 echo " prefix: $prefix"
738 echo " exec_prefix: $exec_prefix"
739 echo " libdir: $libdir"
743 echo " Driver: $mesa_driver"
744 case "$mesa_driver" in
746 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
747 echo " OSMesa: lib$OSMESA_LIB"
753 # cleanup the drivers var
754 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
755 echo " DRI drivers: $dri_dirs"
756 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
762 echo " Shared libs: $enable_shared"
763 echo " Static libs: $enable_static"
764 echo " GLU: $enable_glu"
765 echo " GLw: $enable_glw"
766 echo " glut: $enable_glut"
769 # cleanup the programs var for display
770 program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
771 if test "x$program_dirs" = x; then
774 echo " Demos: $program_dirs"
778 echo " Run 'make autoconf' to build Mesa"