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