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