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