configure.ac revision 79aeafd3ca3680c28f6d47a21a501334844f4475
1dnl Process this file with autoconf to create configure.
2
3AC_PREREQ([2.59])
4
5dnl Versioning - scrape the version from configs/default
6m4_define([mesa_version],
7    [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])])
8m4_ifval(mesa_version,,
9    [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])])
10
11dnl Tell the user about autoconf.html in the --help output
12m4_divert_once([HELP_END], [
13See docs/autoconf.html for more details on the options for Mesa.])
14
15AC_INIT([Mesa],[mesa_version],
16    [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
17AC_CONFIG_AUX_DIR([bin])
18AC_CANONICAL_HOST
19
20dnl Versions for external dependencies
21LIBDRM_REQUIRED=2.4.15
22LIBDRM_RADEON_REQUIRED=2.4.17
23DRI2PROTO_REQUIRED=2.1
24GLPROTO_REQUIRED=1.4.11
25
26dnl Check for progs
27AC_PROG_CPP
28AC_PROG_CC
29AC_PROG_CXX
30AC_CHECK_PROGS([MAKE], [gmake make])
31AC_PATH_PROG([MKDEP], [makedepend])
32AC_PATH_PROG([SED], [sed])
33
34dnl Our fallback install-sh is a symlink to minstall. Use the existing
35dnl configuration in that case.
36AC_PROG_INSTALL
37test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)'
38
39dnl We need a POSIX shell for parts of the build. Assume we have one
40dnl in most cases.
41case "$host_os" in
42solaris*)
43    # Solaris /bin/sh is too old/non-POSIX compliant
44    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
45    SHELL="$POSIX_SHELL"
46    ;;
47esac
48
49MKDEP_OPTIONS=-fdepend
50dnl Ask gcc where it's keeping its secret headers
51if test "x$GCC" = xyes; then
52    for dir in include include-fixed; do
53        GCC_INCLUDES=`$CC -print-file-name=$dir`
54        if test "x$GCC_INCLUDES" != x && \
55           test "$GCC_INCLUDES" != "$dir" && \
56           test -d "$GCC_INCLUDES"; then
57            MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
58        fi
59    done
60fi
61AC_SUBST([MKDEP_OPTIONS])
62
63dnl Make sure the pkg-config macros are defined
64m4_ifndef([PKG_PROG_PKG_CONFIG],
65    [m4_fatal([Could not locate the pkg-config autoconf macros.
66  These are usually located in /usr/share/aclocal/pkg.m4. If your macros
67  are in a different location, try setting the environment variable
68  ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
69PKG_PROG_PKG_CONFIG()
70
71dnl LIB_DIR - library basename
72LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
73AC_SUBST([LIB_DIR])
74
75dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
76_SAVE_LDFLAGS="$LDFLAGS"
77AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
78AC_SUBST([EXTRA_LIB_PATH])
79
80dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
81_SAVE_CPPFLAGS="$CPPFLAGS"
82AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
83AC_SUBST([X11_INCLUDES])
84
85dnl Compiler macros
86DEFINES=""
87AC_SUBST([DEFINES])
88case "$host_os" in
89linux*|*-gnu*|gnu*)
90    DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
91    ;;
92solaris*)
93    DEFINES="$DEFINES -DPTHREADS -DSVR4"
94    ;;
95cygwin*)
96    DEFINES="$DEFINES -DPTHREADS"
97    ;;
98esac
99
100dnl Add flags for gcc and g++
101if test "x$GCC" = xyes; then
102    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
103
104    # Enable -fvisibility=hidden if using a gcc that supports it
105    save_CFLAGS="$CFLAGS"
106    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
107    CFLAGS="$CFLAGS -fvisibility=hidden"
108    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
109		   [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]);
110
111    # Work around aliasing bugs - developers should comment this out
112    CFLAGS="$CFLAGS -fno-strict-aliasing"
113fi
114if test "x$GXX" = xyes; then
115    CXXFLAGS="$CXXFLAGS -Wall"
116
117    # Work around aliasing bugs - developers should comment this out
118    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
119fi
120
121dnl These should be unnecessary, but let the user set them if they want
122AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
123    Default is to use CFLAGS.])
124AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
125    compiler. Default is to use CFLAGS.])
126AC_SUBST([OPT_FLAGS])
127AC_SUBST([ARCH_FLAGS])
128
129dnl
130dnl Hacks to enable 32 or 64 bit build
131dnl
132AC_ARG_ENABLE([32-bit],
133    [AS_HELP_STRING([--enable-32-bit],
134        [build 32-bit libraries @<:@default=auto@:>@])],
135    [enable_32bit="$enableval"],
136    [enable_32bit=auto]
137)
138if test "x$enable_32bit" = xyes; then
139    if test "x$GCC" = xyes; then
140        CFLAGS="$CFLAGS -m32"
141        ARCH_FLAGS="$ARCH_FLAGS -m32"
142    fi
143    if test "x$GXX" = xyes; then
144        CXXFLAGS="$CXXFLAGS -m32"
145    fi
146fi
147AC_ARG_ENABLE([64-bit],
148    [AS_HELP_STRING([--enable-64-bit],
149        [build 64-bit libraries @<:@default=auto@:>@])],
150    [enable_64bit="$enableval"],
151    [enable_64bit=auto]
152)
153if test "x$enable_64bit" = xyes; then
154    if test "x$GCC" = xyes; then
155        CFLAGS="$CFLAGS -m64"
156    fi
157    if test "x$GXX" = xyes; then
158        CXXFLAGS="$CXXFLAGS -m64"
159    fi
160fi
161
162dnl
163dnl shared/static libraries, mimic libtool options
164dnl
165AC_ARG_ENABLE([static],
166    [AS_HELP_STRING([--enable-static],
167        [build static libraries @<:@default=disabled@:>@])],
168    [enable_static="$enableval"],
169    [enable_static=no]
170)
171case "x$enable_static" in
172xyes|xno ) ;;
173x ) enable_static=no ;;
174* )
175    AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
176    ;;
177esac
178AC_ARG_ENABLE([shared],
179    [AS_HELP_STRING([--disable-shared],
180        [build shared libraries @<:@default=enabled@:>@])],
181    [enable_shared="$enableval"],
182    [enable_shared=yes]
183)
184case "x$enable_shared" in
185xyes|xno ) ;;
186x ) enable_shared=yes ;;
187* )
188    AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
189    ;;
190esac
191
192dnl Can't have static and shared libraries, default to static if user
193dnl explicitly requested. If both disabled, set to static since shared
194dnl was explicitly requirested.
195case "x$enable_static$enable_shared" in
196xyesyes )
197    AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
198    enable_shared=no
199    ;;
200xnono )
201    AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
202    enable_static=yes
203    ;;
204esac
205
206dnl
207dnl mklib options
208dnl
209AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
210if test "$enable_static" = yes; then
211    MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
212fi
213AC_SUBST([MKLIB_OPTIONS])
214
215dnl
216dnl other compiler options
217dnl
218AC_ARG_ENABLE([debug],
219    [AS_HELP_STRING([--enable-debug],
220        [use debug compiler flags and macros @<:@default=disabled@:>@])],
221    [enable_debug="$enableval"],
222    [enable_debug=no]
223)
224if test "x$enable_debug" = xyes; then
225    DEFINES="$DEFINES -DDEBUG"
226    if test "x$GCC" = xyes; then
227        CFLAGS="$CFLAGS -g"
228    fi
229    if test "x$GXX" = xyes; then
230        CXXFLAGS="$CXXFLAGS -g"
231    fi
232fi
233
234dnl
235dnl library names
236dnl
237if test "$enable_static" = yes; then
238    LIB_EXTENSION='a'
239else
240    case "$host_os" in
241    darwin* )
242        LIB_EXTENSION='dylib' ;;
243    cygwin* )
244        LIB_EXTENSION='dll' ;;
245    aix* )
246        LIB_EXTENSION='a' ;;
247    * )
248        LIB_EXTENSION='so' ;;
249    esac
250fi
251
252GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
253GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
254GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
255GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
256OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
257EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
258
259GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*'
260GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*'
261GLUT_LIB_GLOB='lib$(GLUT_LIB).*'${LIB_EXTENSION}'*'
262GLW_LIB_GLOB='lib$(GLW_LIB).*'${LIB_EXTENSION}'*'
263OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*'
264EGL_LIB_GLOB='lib$(EGL_LIB).*'${LIB_EXTENSION}'*'
265
266AC_SUBST([GL_LIB_NAME])
267AC_SUBST([GLU_LIB_NAME])
268AC_SUBST([GLUT_LIB_NAME])
269AC_SUBST([GLW_LIB_NAME])
270AC_SUBST([OSMESA_LIB_NAME])
271AC_SUBST([EGL_LIB_NAME])
272
273AC_SUBST([GL_LIB_GLOB])
274AC_SUBST([GLU_LIB_GLOB])
275AC_SUBST([GLUT_LIB_GLOB])
276AC_SUBST([GLW_LIB_GLOB])
277AC_SUBST([OSMESA_LIB_GLOB])
278AC_SUBST([EGL_LIB_GLOB])
279
280dnl
281dnl Arch/platform-specific settings
282dnl
283AC_ARG_ENABLE([asm],
284    [AS_HELP_STRING([--disable-asm],
285        [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
286    [enable_asm="$enableval"],
287    [enable_asm=yes]
288)
289asm_arch=""
290ASM_FLAGS=""
291MESA_ASM_SOURCES=""
292GLAPI_ASM_SOURCES=""
293AC_MSG_CHECKING([whether to enable assembly])
294test "x$enable_asm" = xno && AC_MSG_RESULT([no])
295# disable if cross compiling on x86/x86_64 since we must run gen_matypes
296if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
297    case "$host_cpu" in
298    i?86 | x86_64)
299        enable_asm=no
300        AC_MSG_RESULT([no, cross compiling])
301        ;;
302    esac
303fi
304# check for supported arches
305if test "x$enable_asm" = xyes; then
306    case "$host_cpu" in
307    i?86)
308        case "$host_os" in
309        linux* | *freebsd* | dragonfly*)
310            test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
311            ;;
312        esac
313        ;;
314    x86_64)
315        case "$host_os" in
316        linux* | *freebsd* | dragonfly*)
317            test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
318            ;;
319        esac
320        ;;
321    powerpc)
322        case "$host_os" in
323        linux*)
324            asm_arch=ppc
325            ;;
326        esac
327        ;;
328    sparc*)
329        case "$host_os" in
330        linux*)
331            asm_arch=sparc
332            ;;
333        esac
334        ;;
335    esac
336
337    case "$asm_arch" in
338    x86)
339        ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
340        MESA_ASM_SOURCES='$(X86_SOURCES)'
341        GLAPI_ASM_SOURCES='$(X86_API)'
342        AC_MSG_RESULT([yes, x86])
343        ;;
344    x86_64)
345        ASM_FLAGS="-DUSE_X86_64_ASM"
346        MESA_ASM_SOURCES='$(X86-64_SOURCES)'
347        GLAPI_ASM_SOURCES='$(X86-64_API)'
348        AC_MSG_RESULT([yes, x86_64])
349        ;;
350    ppc)
351        ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
352        MESA_ASM_SOURCES='$(PPC_SOURCES)'
353        AC_MSG_RESULT([yes, ppc])
354        ;;
355    sparc)
356        ASM_FLAGS="-DUSE_SPARC_ASM"
357        MESA_ASM_SOURCES='$(SPARC_SOURCES)'
358        GLAPI_ASM_SOURCES='$(SPARC_API)'
359        AC_MSG_RESULT([yes, sparc])
360        ;;
361    *)
362        AC_MSG_RESULT([no, platform not supported])
363        ;;
364    esac
365fi
366AC_SUBST([ASM_FLAGS])
367AC_SUBST([MESA_ASM_SOURCES])
368AC_SUBST([GLAPI_ASM_SOURCES])
369
370dnl PIC code macro
371MESA_PIC_FLAGS
372
373dnl Check to see if dlopen is in default libraries (like Solaris, which
374dnl has it in libc), or if libdl is needed to get it.
375AC_CHECK_FUNC([dlopen], [],
376    [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
377
378dnl See if posix_memalign is available
379AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
380
381dnl SELinux awareness.
382AC_ARG_ENABLE([selinux],
383    [AS_HELP_STRING([--enable-selinux],
384        [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
385    [MESA_SELINUX="$enableval"],
386    [MESA_SELINUX=no])
387if test "x$enable_selinux" = "xyes"; then
388    AC_CHECK_HEADER([selinux/selinux.h],[],
389                    [AC_MSG_ERROR([SELinux headers not found])])
390    AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
391                 [AC_MSG_ERROR([SELinux library not found])])
392    SELINUX_LIBS="-lselinux"
393    DEFINES="$DEFINES -DMESA_SELINUX"
394fi
395
396dnl
397dnl Driver configuration. Options are xlib, dri and osmesa right now.
398dnl More later: fbdev, ...
399dnl
400default_driver="xlib"
401
402case "$host_os" in
403linux*)
404    case "$host_cpu" in
405    i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
406    esac
407    ;;
408*freebsd* | dragonfly*)
409    case "$host_cpu" in
410    i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
411    esac
412    ;;
413esac
414
415AC_ARG_WITH([driver],
416    [AS_HELP_STRING([--with-driver=DRIVER],
417        [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
418    [mesa_driver="$withval"],
419    [mesa_driver="$default_driver"])
420dnl Check for valid option
421case "x$mesa_driver" in
422xxlib|xdri|xosmesa)
423    ;;
424*)
425    AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
426    ;;
427esac
428
429dnl
430dnl Driver specific build directories
431dnl
432
433dnl this variable will be prepended to SRC_DIRS and is not exported
434CORE_DIRS="glsl mesa"
435
436SRC_DIRS="glew"
437GLU_DIRS="sgi"
438WINDOW_SYSTEM=""
439GALLIUM_DIRS="auxiliary drivers state_trackers"
440GALLIUM_WINSYS_DIRS=""
441GALLIUM_WINSYS_DRM_DIRS=""
442GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
443GALLIUM_STATE_TRACKERS_DIRS=""
444
445case "$mesa_driver" in
446xlib)
447    DRIVER_DIRS="x11"
448    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib"
449    ;;
450dri)
451    SRC_DIRS="$SRC_DIRS glx"
452    DRIVER_DIRS="dri"
453    WINDOW_SYSTEM="dri"
454    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm"
455    ;;
456osmesa)
457    DRIVER_DIRS="osmesa"
458    ;;
459esac
460AC_SUBST([SRC_DIRS])
461AC_SUBST([GLU_DIRS])
462AC_SUBST([DRIVER_DIRS])
463AC_SUBST([WINDOW_SYSTEM])
464AC_SUBST([GALLIUM_DIRS])
465AC_SUBST([GALLIUM_WINSYS_DIRS])
466AC_SUBST([GALLIUM_WINSYS_DRM_DIRS])
467AC_SUBST([GALLIUM_DRIVERS_DIRS])
468AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
469
470dnl
471dnl User supplied program configuration
472dnl
473if test -d "$srcdir/progs/demos"; then
474    default_demos=yes
475else
476    default_demos=no
477fi
478AC_ARG_WITH([demos],
479    [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
480        [optional comma delimited demo directories to build
481        @<:@default=auto if source available@:>@])],
482    [with_demos="$withval"],
483    [with_demos="$default_demos"])
484if test "x$with_demos" = x; then
485    with_demos=no
486fi
487
488dnl If $with_demos is yes, directories will be added as libs available
489PROGRAM_DIRS=""
490case "$with_demos" in
491no) ;;
492yes)
493    # If the driver isn't osmesa, we have libGL and can build xdemos
494    if test "$mesa_driver" != osmesa; then
495        PROGRAM_DIRS="xdemos"
496    fi
497    ;;
498*)
499    # verify the requested demos directories exist
500    demos=`IFS=,; echo $with_demos`
501    for demo in $demos; do
502        test -d "$srcdir/progs/$demo" || \
503            AC_MSG_ERROR([Program directory '$demo' doesn't exist])
504    done
505    PROGRAM_DIRS="$demos"
506    ;;
507esac
508
509dnl
510dnl Find out if X is available. The variable have_x is set if libX11 is
511dnl found to mimic AC_PATH_XTRA.
512dnl
513if test -n "$PKG_CONFIG"; then
514    AC_MSG_CHECKING([pkg-config files for X11 are available])
515    PKG_CHECK_EXISTS([x11],[
516        x11_pkgconfig=yes
517        have_x=yes
518        ],[
519        x11_pkgconfig=no
520    ])
521    AC_MSG_RESULT([$x11_pkgconfig])
522else
523    x11_pkgconfig=no
524fi
525dnl Use the autoconf macro if no pkg-config files
526if test "$x11_pkgconfig" = no; then
527    AC_PATH_XTRA
528fi
529
530dnl Try to tell the user that the --x-* options are only used when
531dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
532m4_divert_once([HELP_BEGIN],
533[These options are only used when the X libraries cannot be found by the
534pkg-config utility.])
535
536dnl We need X for xlib and dri, so bomb now if it's not found
537case "$mesa_driver" in
538xlib|dri)
539    if test "$no_x" = yes; then
540        AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
541    fi
542    ;;
543esac
544
545dnl XCB - this is only used for GLX right now
546AC_ARG_ENABLE([xcb],
547    [AS_HELP_STRING([--enable-xcb],
548        [use XCB for GLX @<:@default=disabled@:>@])],
549    [enable_xcb="$enableval"],
550    [enable_xcb=no])
551if test "x$enable_xcb" = xyes; then
552    DEFINES="$DEFINES -DUSE_XCB"
553else
554    enable_xcb=no
555fi
556
557dnl
558dnl libGL configuration per driver
559dnl
560case "$mesa_driver" in
561xlib)
562    if test "$x11_pkgconfig" = yes; then
563        PKG_CHECK_MODULES([XLIBGL], [x11 xext])
564        GL_PC_REQ_PRIV="x11 xext"
565        X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
566        GL_LIB_DEPS="$XLIBGL_LIBS"
567    else
568        # should check these...
569        X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
570        GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
571        GL_PC_LIB_PRIV="$GL_LIB_DEPS"
572        GL_PC_CFLAGS="$X11_INCLUDES"
573    fi
574    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
575    GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread"
576
577    # if static, move the external libraries to the programs
578    # and empty the libraries for libGL
579    if test "$enable_static" = yes; then
580        APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
581        GL_LIB_DEPS=""
582    fi
583    ;;
584dri)
585    # DRI must be shared, I think
586    if test "$enable_static" = yes; then
587        AC_MSG_ERROR([Can't use static libraries for DRI drivers])
588    fi
589
590    # Check for libdrm
591    PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
592    PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
593    PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
594    GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED glproto >= $GLPROTO_REQUIRED"
595    DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
596
597    # find the DRI deps for libGL
598    if test "$x11_pkgconfig" = yes; then
599        # add xcb modules if necessary
600        dri_modules="x11 xext xxf86vm xdamage xfixes"
601        if test "$enable_xcb" = yes; then
602            dri_modules="$dri_modules x11-xcb xcb-glx"
603        fi
604
605        PKG_CHECK_MODULES([DRIGL], [$dri_modules])
606        GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
607        X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
608        GL_LIB_DEPS="$DRIGL_LIBS"
609    else
610        # should check these...
611        X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
612        GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
613        GL_PC_LIB_PRIV="$GL_LIB_DEPS"
614        GL_PC_CFLAGS="$X11_INCLUDES"
615
616        # XCB can only be used from pkg-config
617        if test "$enable_xcb" = yes; then
618            PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
619            GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
620            X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
621            GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
622        fi
623    fi
624
625    # need DRM libs, -lpthread, etc.
626    GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
627    GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
628    ;;
629osmesa)
630    # No libGL for osmesa
631    GL_LIB_DEPS=""
632    ;;
633esac
634AC_SUBST([GL_LIB_DEPS])
635AC_SUBST([GL_PC_REQ_PRIV])
636AC_SUBST([GL_PC_LIB_PRIV])
637AC_SUBST([GL_PC_CFLAGS])
638AC_SUBST([DRI_PC_REQ_PRIV])
639
640dnl
641dnl More X11 setup
642dnl
643if test "$mesa_driver" = xlib; then
644    DEFINES="$DEFINES -DUSE_XSHM"
645fi
646
647dnl
648dnl More DRI setup
649dnl
650AC_ARG_ENABLE([glx-tls],
651    [AS_HELP_STRING([--enable-glx-tls],
652        [enable TLS support in GLX @<:@default=disabled@:>@])],
653    [GLX_USE_TLS="$enableval"],
654    [GLX_USE_TLS=no])
655dnl Directory for DRI drivers
656AC_ARG_WITH([dri-driverdir],
657    [AS_HELP_STRING([--with-dri-driverdir=DIR],
658        [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
659    [DRI_DRIVER_INSTALL_DIR="$withval"],
660    [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
661AC_SUBST([DRI_DRIVER_INSTALL_DIR])
662dnl Extra search path for DRI drivers
663AC_ARG_WITH([dri-searchpath],
664    [AS_HELP_STRING([--with-dri-searchpath=DIRS...],
665        [semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
666    [DRI_DRIVER_SEARCH_DIR="$withval"],
667    [DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
668AC_SUBST([DRI_DRIVER_SEARCH_DIR])
669dnl Direct rendering or just indirect rendering
670AC_ARG_ENABLE([driglx-direct],
671    [AS_HELP_STRING([--disable-driglx-direct],
672        [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
673    [driglx_direct="$enableval"],
674    [driglx_direct="yes"])
675dnl Which drivers to build - default is chosen by platform
676AC_ARG_WITH([dri-drivers],
677    [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
678        [comma delimited DRI drivers list, e.g.
679        "swrast,i965,radeon" @<:@default=auto@:>@])],
680    [with_dri_drivers="$withval"],
681    [with_dri_drivers=yes])
682if test "x$with_dri_drivers" = x; then
683    with_dri_drivers=no
684fi
685
686dnl If $with_dri_drivers is yes, directories will be added through
687dnl platform checks
688DRI_DIRS=""
689case "$with_dri_drivers" in
690no) ;;
691yes)
692    DRI_DIRS="yes"
693    ;;
694*)
695    # verify the requested driver directories exist
696    dri_drivers=`IFS=', '; echo $with_dri_drivers`
697    for driver in $dri_drivers; do
698        test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
699            AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
700    done
701    DRI_DIRS="$dri_drivers"
702    ;;
703esac
704
705dnl Set DRI_DIRS, DEFINES and LIB_DEPS
706if test "$mesa_driver" = dri; then
707    # Use TLS in GLX?
708    if test "x$GLX_USE_TLS" = xyes; then
709        DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
710    fi
711
712    # Platform specific settings and drivers to build
713    case "$host_os" in
714    linux*)
715        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
716        if test "x$driglx_direct" = xyes; then
717            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
718        fi
719        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
720
721        case "$host_cpu" in
722        x86_64)
723            # sis is missing because they have not be converted to use
724            # the new interface.  i810 are missing because there is no
725            # x86-64 system where they could *ever* be used.
726            if test "x$DRI_DIRS" = "xyes"; then
727                DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \
728                    savage tdfx unichrome swrast"
729            fi
730            ;;
731        powerpc*)
732            # Build only the drivers for cards that exist on PowerPC.
733            # At some point MGA will be added, but not yet.
734            if test "x$DRI_DIRS" = "xyes"; then
735                DRI_DIRS="mach64 r128 r200 r300 r600 radeon tdfx swrast"
736            fi
737            ;;
738        sparc*)
739            # Build only the drivers for cards that exist on sparc`
740            if test "x$DRI_DIRS" = "xyes"; then
741                DRI_DIRS="mach64 r128 r200 r300 r600 radeon swrast"
742            fi
743            ;;
744        esac
745        ;;
746    freebsd* | dragonfly*)
747        DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
748        DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
749        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
750        if test "x$driglx_direct" = xyes; then
751            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
752        fi
753        if test "x$GXX" = xyes; then
754            CXXFLAGS="$CXXFLAGS -ansi -pedantic"
755        fi
756
757        if test "x$DRI_DIRS" = "xyes"; then
758            DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \
759                unichrome savage sis swrast"
760        fi
761        ;;
762    gnu*)
763        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
764        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
765	;;
766    solaris*)
767        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
768        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
769        if test "x$driglx_direct" = xyes; then
770            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
771        fi
772        ;;
773    esac
774
775    # default drivers
776    if test "x$DRI_DIRS" = "xyes"; then
777        DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
778            savage sis tdfx unichrome swrast"
779    fi
780
781    DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`
782
783    # Check for expat
784    EXPAT_INCLUDES=""
785    EXPAT_LIB=-lexpat
786    AC_ARG_WITH([expat],
787        [AS_HELP_STRING([--with-expat=DIR],
788            [expat install directory])],[
789        EXPAT_INCLUDES="-I$withval/include"
790        CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
791        LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
792        EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
793        ])
794    AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
795    AC_CHECK_LIB([expat],[XML_ParserCreate],[],
796        [AC_MSG_ERROR([Expat required for DRI.])])
797
798    # put all the necessary libs together
799    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
800fi
801AC_SUBST([DRI_DIRS])
802AC_SUBST([EXPAT_INCLUDES])
803AC_SUBST([DRI_LIB_DEPS])
804
805case $DRI_DIRS in
806*i915*|*i965*)
807    PKG_CHECK_MODULES([INTEL], [libdrm_intel])
808    ;;
809esac
810
811case $DRI_DIRS in
812*radeon*|*r200*|*r300*|*r600*)
813    PKG_CHECK_MODULES([LIBDRM_RADEON],
814		      [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED],
815		      HAVE_LIBDRM_RADEON=yes,
816		      HAVE_LIBDRM_RADEON=no)
817
818    if test "$HAVE_LIBDRM_RADEON" = yes; then
819	RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
820	RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS
821    fi
822    ;;
823esac
824AC_SUBST([RADEON_CFLAGS])
825AC_SUBST([RADEON_LDFLAGS])
826
827
828dnl
829dnl OSMesa configuration
830dnl
831if test "$mesa_driver" = xlib; then
832    default_gl_osmesa=yes
833else
834    default_gl_osmesa=no
835fi
836AC_ARG_ENABLE([gl-osmesa],
837    [AS_HELP_STRING([--enable-gl-osmesa],
838        [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
839    [gl_osmesa="$enableval"],
840    [gl_osmesa="$default_gl_osmesa"])
841if test "x$gl_osmesa" = xyes; then
842    if test "$mesa_driver" = osmesa; then
843        AC_MSG_ERROR([libGL is not available for OSMesa driver])
844    else
845        DRIVER_DIRS="$DRIVER_DIRS osmesa"
846    fi
847fi
848
849dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
850AC_ARG_WITH([osmesa-bits],
851    [AS_HELP_STRING([--with-osmesa-bits=BITS],
852        [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
853    [osmesa_bits="$withval"],
854    [osmesa_bits=8])
855if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
856    AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
857    osmesa_bits=8
858fi
859case "x$osmesa_bits" in
860x8)
861    OSMESA_LIB=OSMesa
862    ;;
863x16|x32)
864    OSMESA_LIB="OSMesa$osmesa_bits"
865    DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
866    ;;
867*)
868    AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
869    ;;
870esac
871AC_SUBST([OSMESA_LIB])
872
873case "$mesa_driver" in
874osmesa)
875    # only link libraries with osmesa if shared
876    if test "$enable_static" = no; then
877        OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
878    else
879        OSMESA_LIB_DEPS=""
880    fi
881    OSMESA_MESA_DEPS=""
882    OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
883    ;;
884*)
885    # Link OSMesa to libGL otherwise
886    OSMESA_LIB_DEPS=""
887    # only link libraries with osmesa if shared
888    if test "$enable_static" = no; then
889        OSMESA_MESA_DEPS='-l$(GL_LIB)'
890    else
891        OSMESA_MESA_DEPS=""
892    fi
893    OSMESA_PC_REQ="gl"
894    ;;
895esac
896OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV"
897AC_SUBST([OSMESA_LIB_DEPS])
898AC_SUBST([OSMESA_MESA_DEPS])
899AC_SUBST([OSMESA_PC_REQ])
900AC_SUBST([OSMESA_PC_LIB_PRIV])
901
902dnl
903dnl EGL configuration
904dnl
905AC_ARG_ENABLE([egl],
906    [AS_HELP_STRING([--disable-egl],
907        [disable EGL library @<:@default=enabled@:>@])],
908    [enable_egl="$enableval"],
909    [enable_egl=yes])
910if test "x$enable_egl" = xyes; then
911    SRC_DIRS="$SRC_DIRS egl"
912    EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread"
913    EGL_DRIVERS_DIRS=""
914    if test "$enable_static" != yes; then
915        # build egl_glx when libGL is built
916        if test "$mesa_driver" != osmesa; then
917            EGL_DRIVERS_DIRS="glx"
918        fi
919
920        # build egl_dri2 when xcb-dri2 is available
921        PKG_CHECK_MODULES([EGL_DRI2], [x11-xcb xcb-dri2 xcb-xfixes libdrm],
922			  [have_xcb_dri2=yes],[have_xcb_dri2=no])
923        if test "$have_xcb_dri2" = yes; then
924            EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS dri2"
925        fi
926    fi
927
928    if test "$with_demos" = yes; then
929        PROGRAM_DIRS="$PROGRAM_DIRS egl"
930    fi
931fi
932AC_SUBST([EGL_LIB_DEPS])
933AC_SUBST([EGL_DRIVERS_DIRS])
934
935dnl
936dnl GLU configuration
937dnl
938AC_ARG_ENABLE([glu],
939    [AS_HELP_STRING([--disable-glu],
940        [enable OpenGL Utility library @<:@default=enabled@:>@])],
941    [enable_glu="$enableval"],
942    [enable_glu=yes])
943if test "x$enable_glu" = xyes; then
944    SRC_DIRS="$SRC_DIRS glu"
945
946    case "$mesa_driver" in
947    osmesa)
948        # If GLU is available and we have libOSMesa (not 16 or 32),
949        # we can build the osdemos
950        if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
951            PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
952        fi
953
954        # Link libGLU to libOSMesa instead of libGL
955        GLU_LIB_DEPS=""
956        GLU_PC_REQ="osmesa"
957        if test "$enable_static" = no; then
958            GLU_MESA_DEPS='-l$(OSMESA_LIB)'
959        else
960            GLU_MESA_DEPS=""
961        fi
962        ;;
963    *)
964        # If static, empty GLU_LIB_DEPS and add libs for programs to link
965        GLU_PC_REQ="gl"
966        GLU_PC_LIB_PRIV="-lm"
967        if test "$enable_static" = no; then
968            GLU_LIB_DEPS="-lm"
969            GLU_MESA_DEPS='-l$(GL_LIB)'
970        else
971            GLU_LIB_DEPS=""
972            GLU_MESA_DEPS=""
973            APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
974        fi
975        ;;
976    esac
977fi
978if test "$enable_static" = no; then
979    GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
980fi
981GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
982AC_SUBST([GLU_LIB_DEPS])
983AC_SUBST([GLU_MESA_DEPS])
984AC_SUBST([GLU_PC_REQ])
985AC_SUBST([GLU_PC_REQ_PRIV])
986AC_SUBST([GLU_PC_LIB_PRIV])
987AC_SUBST([GLU_PC_CFLAGS])
988
989dnl
990dnl GLw configuration
991dnl
992AC_ARG_ENABLE([glw],
993    [AS_HELP_STRING([--disable-glw],
994        [enable Xt/Motif widget library @<:@default=enabled@:>@])],
995    [enable_glw="$enableval"],
996    [enable_glw=yes])
997dnl Don't build GLw on osmesa
998if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
999    AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
1000    enable_glw=no
1001fi
1002AC_ARG_ENABLE([motif],
1003    [AS_HELP_STRING([--enable-motif],
1004        [use Motif widgets in GLw @<:@default=disabled@:>@])],
1005    [enable_motif="$enableval"],
1006    [enable_motif=no])
1007
1008if test "x$enable_glw" = xyes; then
1009    SRC_DIRS="$SRC_DIRS glw"
1010    if test "$x11_pkgconfig" = yes; then
1011        PKG_CHECK_MODULES([GLW],[x11 xt])
1012        GLW_PC_REQ_PRIV="x11 xt"
1013        GLW_LIB_DEPS="$GLW_LIBS"
1014    else
1015        # should check these...
1016        GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
1017        GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
1018        GLW_PC_CFLAGS="$X11_INCLUDES"
1019    fi
1020
1021    GLW_SOURCES="GLwDrawA.c"
1022    MOTIF_CFLAGS=
1023    if test "x$enable_motif" = xyes; then
1024        GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
1025        AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
1026        if test "x$MOTIF_CONFIG" != xno; then
1027            MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
1028            MOTIF_LIBS=`$MOTIF_CONFIG --libs`
1029        else
1030            AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
1031                [AC_MSG_ERROR([Can't locate Motif headers])])
1032            AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
1033                [AC_MSG_ERROR([Can't locate Motif Xm library])])
1034        fi
1035        # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
1036        GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
1037        GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
1038        GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
1039    fi
1040
1041    # If static, empty GLW_LIB_DEPS and add libs for programs to link
1042    GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV"
1043    if test "$enable_static" = no; then
1044        GLW_MESA_DEPS='-l$(GL_LIB)'
1045        GLW_LIB_DEPS="$GLW_LIB_DEPS"
1046    else
1047        APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
1048        GLW_LIB_DEPS=""
1049        GLW_MESA_DEPS=""
1050    fi
1051fi
1052AC_SUBST([GLW_LIB_DEPS])
1053AC_SUBST([GLW_MESA_DEPS])
1054AC_SUBST([GLW_SOURCES])
1055AC_SUBST([MOTIF_CFLAGS])
1056AC_SUBST([GLW_PC_REQ_PRIV])
1057AC_SUBST([GLW_PC_LIB_PRIV])
1058AC_SUBST([GLW_PC_CFLAGS])
1059
1060dnl
1061dnl GLUT configuration
1062dnl
1063if test -f "$srcdir/include/GL/glut.h"; then
1064    default_glut=yes
1065else
1066    default_glut=no
1067fi
1068AC_ARG_ENABLE([glut],
1069    [AS_HELP_STRING([--disable-glut],
1070        [enable GLUT library @<:@default=enabled if source available@:>@])],
1071    [enable_glut="$enableval"],
1072    [enable_glut="$default_glut"])
1073
1074dnl Can't build glut if GLU not available
1075if test "x$enable_glu$enable_glut" = xnoyes; then
1076    AC_MSG_WARN([Disabling glut since GLU is disabled])
1077    enable_glut=no
1078fi
1079dnl Don't build glut on osmesa
1080if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
1081    AC_MSG_WARN([Disabling glut since the driver is OSMesa])
1082    enable_glut=no
1083fi
1084
1085if test "x$enable_glut" = xyes; then
1086    SRC_DIRS="$SRC_DIRS glut/glx"
1087    GLUT_CFLAGS=""
1088    if test "x$GCC" = xyes; then
1089        GLUT_CFLAGS="-fexceptions"
1090    fi
1091    if test "$x11_pkgconfig" = yes; then
1092        PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
1093        GLUT_PC_REQ_PRIV="x11 xmu xi"
1094        GLUT_LIB_DEPS="$GLUT_LIBS"
1095    else
1096        # should check these...
1097        GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
1098        GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
1099        GLUT_PC_CFLAGS="$X11_INCLUDES"
1100    fi
1101    GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
1102    GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm"
1103
1104    # If glut is available, we can build most programs
1105    if test "$with_demos" = yes; then
1106        PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
1107    fi
1108
1109    # If static, empty GLUT_LIB_DEPS and add libs for programs to link
1110    if test "$enable_static" = no; then
1111        GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
1112    else
1113        APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
1114        GLUT_LIB_DEPS=""
1115        GLUT_MESA_DEPS=""
1116    fi
1117fi
1118AC_SUBST([GLUT_LIB_DEPS])
1119AC_SUBST([GLUT_MESA_DEPS])
1120AC_SUBST([GLUT_CFLAGS])
1121AC_SUBST([GLUT_PC_REQ_PRIV])
1122AC_SUBST([GLUT_PC_LIB_PRIV])
1123AC_SUBST([GLUT_PC_CFLAGS])
1124
1125dnl
1126dnl Program library dependencies
1127dnl    Only libm is added here if necessary as the libraries should
1128dnl    be pulled in by the linker
1129dnl
1130if test "x$APP_LIB_DEPS" = x; then
1131    case "$host_os" in
1132    solaris*)
1133        APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
1134        ;;
1135    cygwin*)
1136        APP_LIB_DEPS="-lX11"
1137        ;;
1138    *)
1139        APP_LIB_DEPS="-lm"
1140        ;;
1141    esac
1142fi
1143AC_SUBST([APP_LIB_DEPS])
1144AC_SUBST([PROGRAM_DIRS])
1145
1146dnl
1147dnl Gallium configuration
1148dnl
1149AC_ARG_ENABLE([gallium],
1150    [AS_HELP_STRING([--disable-gallium],
1151        [build gallium @<:@default=enabled@:>@])],
1152    [enable_gallium="$enableval"],
1153    [enable_gallium=yes])
1154if test "x$enable_gallium" = xyes; then
1155    SRC_DIRS="$SRC_DIRS gallium gallium/winsys"
1156fi
1157
1158dnl
1159dnl Gallium state trackers configuration
1160dnl
1161AC_ARG_WITH([state-trackers],
1162    [AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@],
1163        [comma delimited state_trackers list, e.g.
1164        "egl,glx" @<:@default=auto@:>@])],
1165    [with_state_trackers="$withval"],
1166    [with_state_trackers=yes])
1167
1168case "$with_state_trackers" in
1169no)
1170    GALLIUM_STATE_TRACKERS_DIRS=""
1171    ;;
1172yes)
1173    # look at what else is built
1174    case "$mesa_driver" in
1175    xlib)
1176        GALLIUM_STATE_TRACKERS_DIRS=glx
1177        ;;
1178    dri)
1179        GALLIUM_STATE_TRACKERS_DIRS="dri"
1180        if test "x$enable_egl" = xyes; then
1181            GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
1182        fi
1183        # Have only tested st/xorg on 1.6.0 servers
1184        PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0],
1185            HAVE_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
1186            HAVE_XORG="no")
1187        ;;
1188    esac
1189    ;;
1190*)
1191    # verify the requested state tracker exist
1192    state_trackers=`IFS=', '; echo $with_state_trackers`
1193    for tracker in $state_trackers; do
1194        test -d "$srcdir/src/gallium/state_trackers/$tracker" || \
1195            AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
1196
1197        case "$tracker" in
1198        egl)
1199            if test "x$enable_egl" != xyes; then
1200                AC_MSG_ERROR([cannot build egl state tracker without EGL library])
1201            fi
1202            ;;
1203        xorg)
1204	    PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
1205                  HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
1206                  HAVE_XEXTPROTO_71="no")
1207            ;;
1208        es)
1209            # mesa/es is required to build es state tracker
1210            CORE_DIRS="$CORE_DIRS mesa/es"
1211            ;;
1212        esac
1213    done
1214    GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
1215    ;;
1216esac
1217
1218AC_ARG_WITH([egl-displays],
1219    [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@],
1220        [comma delimited native displays libEGL supports, e.g.
1221        "x11,kms" @<:@default=auto@:>@])],
1222    [with_egl_displays="$withval"],
1223    [with_egl_displays=yes])
1224
1225EGL_DISPLAYS=""
1226case "$with_egl_displays" in
1227yes)
1228    if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then
1229        EGL_DISPLAYS="x11"
1230    fi
1231    ;;
1232*)
1233    if test "x$enable_egl" != xyes; then
1234        AC_MSG_ERROR([cannot build egl state tracker without EGL library])
1235    fi
1236    # verify the requested driver directories exist
1237    egl_displays=`IFS=', '; echo $with_egl_displays`
1238    for dpy in $egl_displays; do
1239        test -d "$srcdir/src/gallium/state_trackers/egl/$dpy" || \
1240            AC_MSG_ERROR([EGL display '$dpy' does't exist])
1241    done
1242    EGL_DISPLAYS="$egl_displays"
1243    ;;
1244esac
1245AC_SUBST([EGL_DISPLAYS])
1246
1247AC_ARG_WITH([egl-driver-dir],
1248    [AS_HELP_STRING([--with-egl-driver-dir=DIR],
1249                    [directory for EGL drivers [[default=${libdir}/egl]]])],
1250    [EGL_DRIVER_INSTALL_DIR="$withval"],
1251    [EGL_DRIVER_INSTALL_DIR='${libdir}/egl'])
1252AC_SUBST([EGL_DRIVER_INSTALL_DIR])
1253
1254AC_ARG_WITH([xorg-driver-dir],
1255    [AS_HELP_STRING([--with-xorg-driver-dir=DIR],
1256                    [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])],
1257    [XORG_DRIVER_INSTALL_DIR="$withval"],
1258    [XORG_DRIVER_INSTALL_DIR="${libdir}/xorg/modules/drivers"])
1259AC_SUBST([XORG_DRIVER_INSTALL_DIR])
1260
1261AC_ARG_WITH([max-width],
1262    [AS_HELP_STRING([--with-max-width=N],
1263                    [Maximum framebuffer width (4096)])],
1264    [DEFINES="${DEFINES} -DMAX_WIDTH=${withval}";
1265     AS_IF([test "${withval}" -gt "4096"],
1266           [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
1267)
1268AC_ARG_WITH([max-height],
1269    [AS_HELP_STRING([--with-max-height=N],
1270                    [Maximum framebuffer height (4096)])],
1271    [DEFINES="${DEFINES} -DMAX_HEIGHT=${withval}";
1272     AS_IF([test "${withval}" -gt "4096"],
1273           [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
1274)
1275
1276dnl
1277dnl Gallium SVGA configuration
1278dnl
1279AC_ARG_ENABLE([gallium-svga],
1280    [AS_HELP_STRING([--enable-gallium-svga],
1281        [build gallium SVGA @<:@default=disabled@:>@])],
1282    [enable_gallium_svga="$enableval"],
1283    [enable_gallium_svga=auto])
1284if test "x$enable_gallium_svga" = xyes; then
1285    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware"
1286    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
1287elif test "x$enable_gallium_svga" = xauto; then
1288    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
1289fi
1290
1291dnl
1292dnl Gallium Intel configuration
1293dnl
1294AC_ARG_ENABLE([gallium-intel],
1295    [AS_HELP_STRING([--enable-gallium-intel],
1296        [build gallium intel @<:@default=disabled@:>@])],
1297    [enable_gallium_intel="$enableval"],
1298    [enable_gallium_intel=auto])
1299if test "x$enable_gallium_intel" = xyes; then
1300    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel i965"
1301    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965"
1302elif test "x$enable_gallium_intel" = xauto; then
1303    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965"
1304fi
1305
1306dnl
1307dnl Gallium Radeon configuration
1308dnl
1309AC_ARG_ENABLE([gallium-radeon],
1310    [AS_HELP_STRING([--enable-gallium-radeon],
1311        [build gallium radeon @<:@default=disabled@:>@])],
1312    [enable_gallium_radeon="$enableval"],
1313    [enable_gallium_radeon=auto])
1314if test "x$enable_gallium_radeon" = xyes; then
1315    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS radeon"
1316    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
1317elif test "x$enable_gallium_radeon" = xauto; then
1318    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
1319fi
1320
1321dnl
1322dnl Gallium Nouveau configuration
1323dnl
1324AC_ARG_ENABLE([gallium-nouveau],
1325    [AS_HELP_STRING([--enable-gallium-nouveau],
1326        [build gallium nouveau @<:@default=disabled@:>@])],
1327    [enable_gallium_nouveau="$enableval"],
1328    [enable_gallium_nouveau=no])
1329if test "x$enable_gallium_nouveau" = xyes; then
1330    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau"
1331    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv30 nv40 nv50"
1332fi
1333
1334dnl
1335dnl Gallium swrast configuration
1336dnl
1337AC_ARG_ENABLE([gallium-swrast],
1338    [AS_HELP_STRING([--enable-gallium-swrast],
1339        [build gallium swrast @<:@default=disabled@:>@])],
1340    [enable_gallium_swrast="$enableval"],
1341    [enable_gallium_swrast=auto])
1342if test "x$enable_gallium_swrast" = xyes; then
1343    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS swrast"
1344fi
1345
1346dnl prepend CORE_DIRS to SRC_DIRS
1347SRC_DIRS="$CORE_DIRS $SRC_DIRS"
1348
1349dnl Restore LDFLAGS and CPPFLAGS
1350LDFLAGS="$_SAVE_LDFLAGS"
1351CPPFLAGS="$_SAVE_CPPFLAGS"
1352
1353dnl Substitute the config
1354AC_CONFIG_FILES([configs/autoconf])
1355
1356dnl Replace the configs/current symlink
1357AC_CONFIG_COMMANDS([configs],[
1358if test -f configs/current || test -L configs/current; then
1359    rm -f configs/current
1360fi
1361ln -s autoconf configs/current
1362])
1363
1364AC_OUTPUT
1365
1366dnl
1367dnl Output some configuration info for the user
1368dnl
1369echo ""
1370echo "        prefix:          $prefix"
1371echo "        exec_prefix:     $exec_prefix"
1372echo "        libdir:          $libdir"
1373echo "        includedir:      $includedir"
1374
1375dnl Driver info
1376echo ""
1377echo "        Driver:          $mesa_driver"
1378if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1379    echo "        OSMesa:          lib$OSMESA_LIB"
1380else
1381    echo "        OSMesa:          no"
1382fi
1383if test "$mesa_driver" = dri; then
1384    # cleanup the drivers var
1385    dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
1386if test "x$DRI_DIRS" = x; then
1387    echo "        DRI drivers:     no"
1388else
1389    echo "        DRI drivers:     $dri_dirs"
1390fi
1391    echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
1392fi
1393echo "        Use XCB:         $enable_xcb"
1394
1395echo ""
1396if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
1397    echo "        Gallium:         yes"
1398    echo "        Gallium dirs:    $GALLIUM_DIRS"
1399    echo "        Winsys dirs:     $GALLIUM_WINSYS_DIRS"
1400    echo "        Winsys drm dirs:$GALLIUM_WINSYS_DRM_DIRS"
1401    echo "        Driver dirs:     $GALLIUM_DRIVERS_DIRS"
1402    echo "        Trackers dirs:   $GALLIUM_STATE_TRACKERS_DIRS"
1403else
1404    echo "        Gallium:         no"
1405fi
1406
1407dnl Libraries
1408echo ""
1409echo "        Shared libs:     $enable_shared"
1410echo "        Static libs:     $enable_static"
1411if test "$enable_egl" = yes; then
1412    echo "        EGL:             $EGL_DRIVERS_DIRS"
1413else
1414    echo "        EGL:             no"
1415fi
1416echo "        GLU:             $enable_glu"
1417echo "        GLw:             $enable_glw (Motif: $enable_motif)"
1418echo "        glut:            $enable_glut"
1419
1420dnl Programs
1421# cleanup the programs var for display
1422program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
1423if test "x$program_dirs" = x; then
1424    echo "        Demos:           no"
1425else
1426    echo "        Demos:           $program_dirs"
1427fi
1428
1429dnl Compiler options
1430# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1431cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1432    $SED 's/^ *//;s/  */ /;s/ *$//'`
1433cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1434    $SED 's/^ *//;s/  */ /;s/ *$//'`
1435defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/  */ /;s/ *$//'`
1436echo ""
1437echo "        CFLAGS:          $cflags"
1438echo "        CXXFLAGS:        $cxxflags"
1439echo "        Macros:          $defines"
1440
1441echo ""
1442echo "        Run '${MAKE-make}' to build Mesa"
1443echo ""
1444