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