mesa/drm/ttm: allow build against non-TTM aware libdrm
[mesa.git] / configure.ac
1 dnl Process this file with autoconf to create configure.
2
3 AC_PREREQ([2.59])
4
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'
11 ])
12 m4_exit([1])
13 ])
14
15 AC_INIT([Mesa],[mesa_version],
16 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
17 AC_CONFIG_AUX_DIR([bin])
18 AC_CANONICAL_HOST
19
20 dnl Versions for external dependencies
21 LIBDRM_REQUIRED=2.3.1
22 DRI2PROTO_REQUIRED=1.1
23
24 dnl Check for progs
25 AC_PROG_CPP
26 AC_PROG_CC
27 AC_PROG_CXX
28 AC_CHECK_PROGS([MAKE], [gmake make])
29 AC_PATH_PROG([MKDEP], [makedepend])
30 AC_PATH_PROG([SED], [sed])
31
32 MKDEP_OPTIONS=-fdepend
33 dnl Ask gcc where it's keeping its secret headers
34 if test "x$GCC" = xyes; then
35 GCC_INCLUDES=`$CC -print-file-name=include`
36 if test "x$GCC_INCLUDES" != x; then
37 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
38 fi
39 fi
40 AC_SUBST([MKDEP_OPTIONS])
41
42 dnl Check to see if dlopen is in default libraries (like Solaris, which
43 dnl has it in libc), or if libdl is needed to get it.
44 AC_CHECK_FUNC([dlopen], [],
45 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
46
47 dnl Make sure the pkg-config macros are defined
48 m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
49 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
50 These are usually located in /usr/share/aclocal/pkg.m4. If your
51 macros are in a different location, try setting the environment
52 variable ACLOCAL="aclocal -I/other/macro/dir" before running
53 autoreconf.
54 ])
55 m4_exit([1])
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
211 dnl
212 dnl library names
213 dnl
214 if test "$enable_static" = yes; then
215 GL_LIB_NAME='lib$(GL_LIB).a'
216 GLU_LIB_NAME='lib$(GLU_LIB).a'
217 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
218 GLW_LIB_NAME='lib$(GLW_LIB).a'
219 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
220 else
221 GL_LIB_NAME='lib$(GL_LIB).so'
222 GLU_LIB_NAME='lib$(GLU_LIB).so'
223 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
224 GLW_LIB_NAME='lib$(GLW_LIB).so'
225 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
226 fi
227 AC_SUBST([GL_LIB_NAME])
228 AC_SUBST([GLU_LIB_NAME])
229 AC_SUBST([GLUT_LIB_NAME])
230 AC_SUBST([GLW_LIB_NAME])
231 AC_SUBST([OSMESA_LIB_NAME])
232
233 dnl
234 dnl Driver configuration. Options are xlib, dri and osmesa right now.
235 dnl More later: directfb, fbdev, ...
236 dnl
237 default_driver="xlib"
238
239 case "$host_os" in
240 linux*)
241 case "$host_cpu" in
242 i*86|x86_64|powerpc*) default_driver="dri";;
243 esac
244 ;;
245 freebsd* | dragonfly*)
246 case "$host_cpu" in
247 i*86|x86_64) default_driver="dri";;
248 esac
249 ;;
250 esac
251
252 AC_ARG_WITH([driver],
253 [AS_HELP_STRING([--with-driver=DRIVER],
254 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
255 [mesa_driver="$withval"],
256 [mesa_driver="$default_driver"])
257 dnl Check for valid option
258 case "x$mesa_driver" in
259 xxlib|xdri|xosmesa)
260 ;;
261 *)
262 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
263 ;;
264 esac
265
266 dnl
267 dnl Driver specific build directories
268 dnl
269 SRC_DIRS="mesa"
270 GLU_DIRS="sgi"
271 WINDOW_SYSTEM=""
272 case "$mesa_driver" in
273 xlib)
274 DRIVER_DIRS="x11"
275 ;;
276 dri)
277 SRC_DIRS="glx/x11 $SRC_DIRS"
278 DRIVER_DIRS="dri"
279 WINDOW_SYSTEM="dri"
280 ;;
281 osmesa)
282 DRIVER_DIRS="osmesa"
283 ;;
284 esac
285 AC_SUBST([SRC_DIRS])
286 AC_SUBST([GLU_DIRS])
287 AC_SUBST([DRIVER_DIRS])
288 AC_SUBST([WINDOW_SYSTEM])
289
290 dnl
291 dnl User supplied program configuration
292 dnl
293 if test -d "$srcdir/progs/demos"; then
294 default_demos=yes
295 else
296 default_demos=no
297 fi
298 AC_ARG_WITH([demos],
299 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
300 [optional comma delimited demo directories to build
301 @<:@default=auto if source available@:>@])],
302 [with_demos="$withval"],
303 [with_demos="$default_demos"])
304 if test "x$with_demos" = x; then
305 with_demos=no
306 fi
307
308 dnl If $with_demos is yes, directories will be added as libs available
309 PROGRAM_DIRS=""
310 case "$with_demos" in
311 no) ;;
312 yes)
313 # If the driver isn't osmesa, we have libGL and can build xdemos
314 if test "$mesa_driver" != osmesa; then
315 PROGRAM_DIRS="xdemos"
316 fi
317 ;;
318 *)
319 # verify the requested demos directories exist
320 demos=`IFS=,; echo $with_demos`
321 for demo in $demos; do
322 test -d "$srcdir/progs/$demo" || \
323 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
324 done
325 PROGRAM_DIRS="$demos"
326 ;;
327 esac
328
329 dnl
330 dnl Find out if X is available. The variable have_x is set if libX11 is
331 dnl to mimic AC_PATH_XTRA.
332 dnl
333 if test -n "$PKG_CONFIG"; then
334 AC_MSG_CHECKING([pkg-config files for X11 are available])
335 PKG_CHECK_EXISTS([x11],[
336 x11_pkgconfig=yes
337 have_x=yes
338 ],[
339 x11_pkgconfig=no
340 ])
341 AC_MSG_RESULT([$x11_pkgconfig])
342 else
343 x11_pkgconfig=no
344 fi
345 dnl Use the autoconf macro if no pkg-config files
346 if test "$x11_pkgconfig" = no; then
347 AC_PATH_XTRA
348 fi
349
350 dnl We need X for xlib and dri, so bomb now if it's not found
351 case "$mesa_driver" in
352 xlib|dri)
353 if test "$no_x" = yes; then
354 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
355 fi
356 ;;
357 esac
358
359 dnl XCB - this is only used for GLX right now
360 AC_ARG_ENABLE([xcb],
361 [AS_HELP_STRING([--enable-xcb],
362 [use XCB for GLX @<:@default=disabled@:>@])],
363 [enable_xcb="$enableval"],
364 [enable_xcb=no])
365 if test "x$enable_xcb" = xyes; then
366 DEFINES="$DEFINES -DUSE_XCB"
367 else
368 enable_xcb=no
369 fi
370
371 # SELinux awareness.
372 AC_ARG_ENABLE([selinux],
373 [AS_HELP_STRING([--enable-selinux],
374 [Build SELinux-aware Mesa (default: disabled)])],
375 [MESA_SELINUX="$enableval"],
376 [MESA_SELINUX=no])
377 if test "x$enable_selinux" = "xyes"; then
378 AC_CHECK_HEADER([selinux/selinux.h],[],
379 [AC_MSG_ERROR([SELinux headers not found])])
380 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
381 [AC_MSG_ERROR([SELinux library not found])])
382 SELINUX_LIBS="-lselinux"
383 DEFINES="$DEFINES -DMESA_SELINUX"
384 fi
385
386 dnl
387 dnl libGL configuration per driver
388 dnl
389 case "$mesa_driver" in
390 xlib)
391 if test "$x11_pkgconfig" = yes; then
392 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
393 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
394 GL_LIB_DEPS="$XLIBGL_LIBS"
395 else
396 # should check these...
397 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
398 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
399 fi
400 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
401
402 # if static, move the external libraries to the programs
403 # and empty the libraries for libGL
404 if test "$enable_static" = yes; then
405 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
406 GL_LIB_DEPS=""
407 fi
408 ;;
409 dri)
410 # DRI must be shared, I think
411 if test "$enable_static" = yes; then
412 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
413 fi
414
415 # Check for libdrm
416 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
417 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
418
419 # find the DRI deps for libGL
420 if test "$x11_pkgconfig" = yes; then
421 # add xcb modules if necessary
422 dri_modules="x11 xext xxf86vm xdamage xfixes"
423 if test "$enable_xcb" = yes; then
424 dri_modules="$dri_modules x11-xcb xcb-glx"
425 fi
426
427 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
428 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
429 GL_LIB_DEPS="$DRIGL_LIBS"
430 else
431 # should check these...
432 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
433 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
434
435 # XCB can only be used from pkg-config
436 if test "$enable_xcb" = yes; then
437 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
438 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
439 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
440 fi
441 fi
442
443 # need DRM libs, -lpthread, etc.
444 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
445 ;;
446 osmesa)
447 # No libGL for osmesa
448 GL_LIB_DEPS=""
449 ;;
450 esac
451 AC_SUBST([GL_LIB_DEPS])
452
453 dnl
454 dnl More X11 setup
455 dnl
456 if test "$mesa_driver" = xlib; then
457 DEFINES="$DEFINES -DUSE_XSHM"
458 fi
459
460 dnl
461 dnl More DRI setup
462 dnl
463 AC_ARG_ENABLE([glx-tls],
464 [AS_HELP_STRING([--enable-glx-tls],
465 [enable TLS support in GLX @<:@default=disabled@:>@])],
466 [GLX_USE_TLS="$enableval"],
467 [GLX_USE_TLS=no])
468 dnl Directory for DRI drivers
469 AC_ARG_WITH([dri-driverdir],
470 [AS_HELP_STRING([--with-dri-driverdir=DIR],
471 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
472 [DRI_DRIVER_INSTALL_DIR="$withval"],
473 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
474 AC_SUBST([DRI_DRIVER_INSTALL_DIR])
475 dnl Direct rendering or just indirect rendering
476 AC_ARG_ENABLE([driglx-direct],
477 [AS_HELP_STRING([--disable-driglx-direct],
478 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
479 [driglx_direct="$enableval"],
480 [driglx_direct="yes"])
481 dnl ttm support
482 AC_ARG_ENABLE([ttm-api],
483 [AS_HELP_STRING([--enable-ttm-api],
484 [enable TTM API users])],
485 [ttmapi="$enableval"],
486 [ttmapi="no"])
487
488 if test "x$ttmapi" = "xyes"; then
489 save_CFLAGS=$CFLAGS
490 CFLAGS=$LIBDRM_CFLAGS
491 AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
492 CFLAGS=$save_CFLAGS
493 fi
494
495 dnl Which drivers to build - default is chosen by platform
496 AC_ARG_WITH([dri-drivers],
497 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
498 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
499 [with_dri_drivers="$withval"],
500 [with_dri_drivers=yes])
501 if test "x$with_dri_drivers" = x; then
502 with_dri_drivers=no
503 fi
504
505 dnl If $with_dri_drivers is yes, directories will be added through
506 dnl platform checks
507 DRI_DIRS=""
508 case "$with_dri_drivers" in
509 no|yes) ;;
510 *)
511 # verify the requested driver directories exist
512 dri_drivers=`IFS=,; echo $with_dri_drivers`
513 for driver in $dri_drivers; do
514 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
515 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
516 done
517 DRI_DIRS="$dri_drivers"
518 ;;
519 esac
520
521 dnl Just default to no EGL for now
522 USING_EGL=0
523 AC_SUBST([USING_EGL])
524
525 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
526 if test "$mesa_driver" = dri; then
527 # Use TLS in GLX?
528 if test "x$GLX_USE_TLS" = xyes; then
529 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
530 fi
531
532 if test "x$ttmapi" = xyes; then
533 DEFINES="$DEFINES -DTTM_API"
534 fi
535
536 if test "x$USING_EGL" = x1; then
537 PROGRAM_DIRS="egl"
538 fi
539
540 # Platform specific settings and drivers to build
541 case "$host_os" in
542 linux*)
543 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
544 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
545 if test "x$driglx_direct" = xyes; then
546 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
547 fi
548
549 case "$host_cpu" in
550 x86_64)
551 # ffb, gamma, and sis are missing because they have not be
552 # converted to use the new interface. i810 are missing
553 # because there is no x86-64 system where they could *ever*
554 # be used.
555 if test "x$DRI_DIRS" = x; then
556 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
557 savage tdfx unichrome swrast"
558 fi
559 ;;
560 powerpc*)
561 # Build only the drivers for cards that exist on PowerPC.
562 # At some point MGA will be added, but not yet.
563 if test "x$DRI_DIRS" = x; then
564 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
565 fi
566 ;;
567 esac
568 ;;
569 freebsd* | dragonfly*)
570 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
571 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
572 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
573 if test "x$driglx_direct" = xyes; then
574 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
575 fi
576 if test "x$GXX" = xyes; then
577 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
578 fi
579
580 # ffb and gamma are missing because they have not been converted
581 # to use the new interface.
582 if test "x$DRI_DIRS" = x; then
583 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
584 unichrome savage sis swrast"
585 fi
586 ;;
587 esac
588
589 # default drivers
590 if test "x$DRI_DIRS" = x; then
591 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
592 savage sis tdfx trident unichrome ffb swrast"
593 fi
594
595 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
596
597 # Check for expat
598 EXPAT_INCLUDES=""
599 EXPAT_LIB=-lexpat
600 AC_ARG_WITH([expat],
601 [AS_HELP_STRING([--with-expat=DIR],
602 [expat install directory])],[
603 EXPAT_INCLUDES="-I$withval/include"
604 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
605 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
606 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
607 ])
608 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
609 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
610 [AC_MSG_ERROR([Expat required for DRI.])])
611
612 # put all the necessary libs together
613 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
614 fi
615 AC_SUBST([DRI_DIRS])
616 AC_SUBST([EXPAT_INCLUDES])
617 AC_SUBST([DRI_LIB_DEPS])
618
619 dnl
620 dnl OSMesa configuration
621 dnl
622 if test "$mesa_driver" = xlib; then
623 default_gl_osmesa=yes
624 else
625 default_gl_osmesa=no
626 fi
627 AC_ARG_ENABLE([gl-osmesa],
628 [AS_HELP_STRING([--enable-gl-osmesa],
629 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
630 [gl_osmesa="$enableval"],
631 [gl_osmesa="$default_gl_osmesa"])
632 if test "x$gl_osmesa" = xyes; then
633 if test "$mesa_driver" = osmesa; then
634 AC_MSG_ERROR([libGL is not available for OSMesa driver])
635 else
636 DRIVER_DIRS="$DRIVER_DIRS osmesa"
637 fi
638 fi
639
640 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
641 AC_ARG_WITH([osmesa-bits],
642 [AS_HELP_STRING([--with-osmesa-bits=BITS],
643 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
644 [osmesa_bits="$withval"],
645 [osmesa_bits=8])
646 if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
647 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
648 osmesa_bits=8
649 fi
650 case "x$osmesa_bits" in
651 x8)
652 OSMESA_LIB=OSMesa
653 ;;
654 x16|x32)
655 OSMESA_LIB="OSMesa$osmesa_bits"
656 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
657 ;;
658 *)
659 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
660 ;;
661 esac
662 AC_SUBST([OSMESA_LIB])
663
664 case "$mesa_driver" in
665 osmesa)
666 # only link librararies with osmesa if shared
667 if test "$enable_static" = no; then
668 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
669 else
670 OSMESA_LIB_DEPS=""
671 fi
672 OSMESA_MESA_DEPS=""
673 ;;
674 *)
675 # Link OSMesa to libGL otherwise
676 OSMESA_LIB_DEPS=""
677 # only link librararies with osmesa if shared
678 if test "$enable_static" = no; then
679 OSMESA_MESA_DEPS='-l$(GL_LIB)'
680 else
681 OSMESA_MESA_DEPS=""
682 fi
683 ;;
684 esac
685 AC_SUBST([OSMESA_LIB_DEPS])
686 AC_SUBST([OSMESA_MESA_DEPS])
687
688 dnl
689 dnl GLU configuration
690 dnl
691 AC_ARG_ENABLE([glu],
692 [AS_HELP_STRING([--disable-glu],
693 [enable OpenGL Utility library @<:@default=enabled@:>@])],
694 [enable_glu="$enableval"],
695 [enable_glu=yes])
696 if test "x$enable_glu" = xyes; then
697 SRC_DIRS="$SRC_DIRS glu"
698
699 case "$mesa_driver" in
700 osmesa)
701 # If GLU is available and we have libOSMesa (not 16 or 32),
702 # we can build the osdemos
703 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
704 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
705 fi
706
707 # Link libGLU to libOSMesa instead of libGL
708 GLU_LIB_DEPS=""
709 if test "$enable_static" = no; then
710 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
711 else
712 GLU_MESA_DEPS=""
713 fi
714 ;;
715 *)
716 # If static, empty GLU_LIB_DEPS and add libs for programs to link
717 if test "$enable_static" = no; then
718 GLU_LIB_DEPS="-lm"
719 GLU_MESA_DEPS='-l$(GL_LIB)'
720 else
721 GLU_LIB_DEPS=""
722 GLU_MESA_DEPS=""
723 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
724 fi
725 ;;
726 esac
727 fi
728 AC_SUBST([GLU_LIB_DEPS])
729 AC_SUBST([GLU_MESA_DEPS])
730
731 dnl
732 dnl GLw configuration
733 dnl
734 AC_ARG_ENABLE([glw],
735 [AS_HELP_STRING([--disable-glw],
736 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
737 [enable_glw="$enableval"],
738 [enable_glw=yes])
739 dnl Don't build GLw on osmesa
740 if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
741 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
742 enable_glw=no
743 fi
744 if test "x$enable_glw" = xyes; then
745 SRC_DIRS="$SRC_DIRS glw"
746 if test "$x11_pkgconfig" = yes; then
747 PKG_CHECK_MODULES([GLW],[x11 xt])
748 GLW_LIB_DEPS="$GLW_LIBS"
749 else
750 # should check these...
751 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
752 fi
753
754 # If static, empty GLW_LIB_DEPS and add libs for programs to link
755 if test "$enable_static" = no; then
756 GLW_MESA_DEPS='-l$(GL_LIB)'
757 else
758 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
759 GLW_LIB_DEPS=""
760 GLW_MESA_DEPS=""
761 fi
762 fi
763 AC_SUBST([GLW_LIB_DEPS])
764 AC_SUBST([GLW_MESA_DEPS])
765
766 dnl
767 dnl GLUT configuration
768 dnl
769 if test -f "$srcdir/include/GL/glut.h"; then
770 default_glut=yes
771 else
772 default_glut=no
773 fi
774 AC_ARG_ENABLE([glut],
775 [AS_HELP_STRING([--disable-glut],
776 [enable GLUT library @<:@default=enabled if source available@:>@])],
777 [enable_glut="$enableval"],
778 [enable_glut="$default_glut"])
779
780 dnl Can't build glut if GLU not available
781 if test "x$enable_glu$enable_glut" = xnoyes; then
782 AC_MSG_WARN([Disabling glut since GLU is disabled])
783 enable_glut=no
784 fi
785 dnl Don't build glut on osmesa
786 if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
787 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
788 enable_glut=no
789 fi
790
791 if test "x$enable_glut" = xyes; then
792 SRC_DIRS="$SRC_DIRS glut/glx"
793 GLUT_CFLAGS=""
794 if test "x$GCC" = xyes; then
795 GLUT_CFLAGS="-fexceptions"
796 fi
797 if test "$x11_pkgconfig" = yes; then
798 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
799 GLUT_LIB_DEPS="$GLUT_LIBS"
800 else
801 # should check these...
802 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
803 fi
804 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
805
806 # If glut is available, we can build most programs
807 if test "$with_demos" = yes; then
808 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
809 fi
810
811 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
812 if test "$enable_static" = no; then
813 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
814 else
815 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
816 GLUT_LIB_DEPS=""
817 GLUT_MESA_DEPS=""
818 fi
819 fi
820 AC_SUBST([GLUT_LIB_DEPS])
821 AC_SUBST([GLUT_MESA_DEPS])
822 AC_SUBST([GLUT_CFLAGS])
823
824 dnl
825 dnl Program library dependencies
826 dnl Only libm is added here if necessary as the libraries should
827 dnl be pulled in by the linker
828 dnl
829 if test "x$APP_LIB_DEPS" = x; then
830 APP_LIB_DEPS="-lm"
831 fi
832 AC_SUBST([APP_LIB_DEPS])
833 AC_SUBST([PROGRAM_DIRS])
834
835 dnl
836 dnl Arch/platform-specific settings
837 dnl
838 AC_ARG_ENABLE([asm],
839 [AS_HELP_STRING([--disable-asm],
840 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
841 [enable_asm="$enableval"],
842 [enable_asm=yes]
843 )
844 asm_arch=""
845 ASM_FLAGS=""
846 ASM_SOURCES=""
847 ASM_API=""
848 AC_MSG_CHECKING([whether to enable assembly])
849 test "x$enable_asm" = xno && AC_MSG_RESULT([no])
850 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
851 if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
852 case "$host_cpu" in
853 i?86 | x86_64)
854 enable_asm=no
855 AC_MSG_RESULT([no, cross compiling])
856 ;;
857 esac
858 fi
859 # check for supported arches
860 if test "x$enable_asm" = xyes; then
861 case "$host_cpu" in
862 i?86)
863 case "$host_os" in
864 linux* | freebsd* | dragonfly*)
865 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
866 ;;
867 esac
868 ;;
869 x86_64)
870 case "$host_os" in
871 linux* | freebsd* | dragonfly*)
872 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
873 ;;
874 esac
875 ;;
876 powerpc)
877 case "$host_os" in
878 linux*)
879 asm_arch=ppc
880 ;;
881 esac
882 ;;
883 esac
884
885 case "$asm_arch" in
886 x86)
887 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
888 ASM_SOURCES='$(X86_SOURCES)'
889 ASM_API='$(X86_API)'
890 AC_MSG_RESULT([yes, x86])
891 ;;
892 x86_64)
893 ASM_FLAGS="-DUSE_X86_64_ASM"
894 ASM_SOURCES='$(X86-64_SOURCES)'
895 ASM_API='$(X86-64_API)'
896 AC_MSG_RESULT([yes, x86_64])
897 ;;
898 ppc)
899 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
900 ASM_SOURCES='$(PPC_SOURCES)'
901 AC_MSG_RESULT([yes, ppc])
902 ;;
903 *)
904 AC_MSG_RESULT([no, platform not supported])
905 ;;
906 esac
907 fi
908 AC_SUBST([ASM_FLAGS])
909 AC_SUBST([ASM_SOURCES])
910 AC_SUBST([ASM_API])
911
912 dnl PIC code macro
913 MESA_PIC_FLAGS
914
915
916 dnl Restore LDFLAGS and CPPFLAGS
917 LDFLAGS="$_SAVE_LDFLAGS"
918 CPPFLAGS="$_SAVE_CPPFLAGS"
919
920 dnl Substitute the config
921 AC_CONFIG_FILES([configs/autoconf])
922
923 dnl Replace the configs/current symlink
924 AC_CONFIG_COMMANDS([configs],[
925 if test -f configs/current || test -L configs/current; then
926 rm -f configs/current
927 fi
928 ln -s autoconf configs/current
929 ])
930
931 AC_OUTPUT
932
933 dnl
934 dnl Output some configuration info for the user
935 dnl
936 echo ""
937 echo " prefix: $prefix"
938 echo " exec_prefix: $exec_prefix"
939 echo " libdir: $libdir"
940
941 dnl Driver info
942 echo ""
943 echo " Driver: $mesa_driver"
944 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
945 echo " OSMesa: lib$OSMESA_LIB"
946 else
947 echo " OSMesa: no"
948 fi
949 if test "$mesa_driver" = dri; then
950 # cleanup the drivers var
951 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
952 echo " DRI drivers: $dri_dirs"
953 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
954 echo " TTM API support: $ttmapi"
955 fi
956
957 dnl Libraries
958 echo ""
959 echo " Shared libs: $enable_shared"
960 echo " Static libs: $enable_static"
961 echo " GLU: $enable_glu"
962 echo " GLw: $enable_glw"
963 echo " glut: $enable_glut"
964
965 dnl Programs
966 # cleanup the programs var for display
967 program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
968 if test "x$program_dirs" = x; then
969 echo " Demos: no"
970 else
971 echo " Demos: $program_dirs"
972 fi
973
974 dnl Compiler options
975 # cleanup the CFLAGS/CXXFLAGS/DEFINES vars
976 cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
977 $SED 's/^ *//;s/ */ /;s/ *$//'`
978 cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
979 $SED 's/^ *//;s/ */ /;s/ *$//'`
980 defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
981 echo ""
982 echo " CFLAGS: $cflags"
983 echo " CXXFLAGS: $cxxflags"
984 echo " Macros: $defines"
985
986 echo ""
987 echo " Run '${MAKE-make}' to build Mesa"
988 echo ""