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