OSDN Git Service

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