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