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