OSDN Git Service

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