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