OSDN Git Service

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