blob: b040b4d20bc0d96210b9c27d9552ca99d196cb62 [file] [log] [blame]
Dan Nicholsondca1b792007-10-23 09:25:58 -07001dnl Process this file with autoconf to create configure.
2
3AC_PREREQ(2.59)
4
5dnl Versioning
6dnl Make version number available to autoconf and configure
7m4_define(mesa_major, 7)
8m4_define(mesa_minor, 1)
9m4_define(mesa_tiny, 0)
10m4_define(mesa_version, [mesa_major().mesa_minor().mesa_tiny()])
11
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -080012AC_INIT([Mesa],[mesa_version()],
13 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
Dan Nicholsondca1b792007-10-23 09:25:58 -070014AC_CONFIG_AUX_DIR(bin)
15AC_CANONICAL_HOST
16
17dnl Substitute the version number into shell variables
18MESA_MAJOR=mesa_major()
19MESA_MINOR=mesa_minor()
20MESA_TINY=mesa_tiny()
21AC_SUBST(MESA_MAJOR)
22AC_SUBST(MESA_MINOR)
23AC_SUBST(MESA_TINY)
24
25dnl Check for progs
26AC_PROG_CPP
27AC_PROG_CC
28AC_PROG_CXX
29AC_PATH_PROG(MAKE, make)
30AC_PATH_PROG(MKDEP, makedepend)
31AC_PATH_PROG(SED, sed)
Dan Nicholson41b00702007-12-12 08:48:30 -080032
33dnl Make sure the pkg-config macros are defined
34m4_ifdef([PKG_PROG_PKG_CONFIG],,[
35 AC_MSG_ERROR([The pkg-config autoconf macros are not defined.
36 Did you run 'make configure'?])]
37)
Dan Nicholsondca1b792007-10-23 09:25:58 -070038PKG_PROG_PKG_CONFIG()
39
40dnl LIB_DIR - library basename
41LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
42AC_SUBST(LIB_DIR)
43
44dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
45_SAVE_LDFLAGS="$LDFLAGS"
46AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
47AC_SUBST(EXTRA_LIB_PATH)
48
49dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
50_SAVE_CPPFLAGS="$CPPFLAGS"
51AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
52AC_SUBST(X11_INCLUDES)
53
54dnl Compiler macros
55DEFINES=""
56AC_SUBST(DEFINES)
57if test "x$GCC" = xyes; then
58 DEFINES="-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
59fi
60case "$host_os" in
61linux*)
62 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
63 ;;
64esac
65
66dnl Add flags for gcc and g++
67if test "x$GCC" = xyes; then
68 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
69fi
70if test "x$GXX" = xyes; then
71 CXXFLAGS="$CXXFLAGS -Wall"
72fi
73
74dnl These should be unnecessary, but let the user set them if they want
75AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
76 Default is to use CFLAGS.])
77AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
78 compiler. Default is to use CFLAGS.])
79AC_SUBST(OPT_FLAGS)
80AC_SUBST(ARCH_FLAGS)
81
82dnl
Dan Nicholson88586332007-11-15 08:59:57 -080083dnl shared/static libraries, mimic libtool options
84dnl
85AC_ARG_ENABLE(static,
86 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -080087 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -080088 enable_static="$enableval",
89 enable_static=no
90)
91case "x$enable_static" in
92xyes|xno ) ;;
93x ) enable_static=no ;;
94* )
95 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
96 ;;
97esac
98AC_ARG_ENABLE(shared,
99 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800100 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800101 enable_shared="$enableval",
102 enable_shared=yes
103)
104case "x$enable_shared" in
105xyes|xno ) ;;
106x ) enable_shared=yes ;;
107* )
108 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
109 ;;
110esac
111
112dnl Can't have static and shared libraries, default to static if user
113dnl explicitly requested. If both disabled, set to static since shared
114dnl was explicitly requirested.
115case "x$enable_static$enable_shared" in
116xyesyes )
117 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
118 enable_shared=no
119 ;;
120xnono )
121 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
122 enable_static=yes
123 ;;
124esac
125
126dnl
127dnl mklib options
128dnl
129AC_ARG_VAR(MKLIB_OPTIONS,[Options for the Mesa library script, mklib])
130if test "$enable_static" = yes; then
131 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
132fi
133AC_SUBST(MKLIB_OPTIONS)
134
Dan Nicholson23656c42007-12-12 09:02:31 -0800135dnl
136dnl other compiler options
137dnl
138AC_ARG_ENABLE(debug,
139 [AS_HELP_STRING([--enable-debug],
140 [use debug compiler flags and macros @<:@default=disabled@:>@])],
141 enable_debug="$enableval",
142 enable_debug=no
143)
144if test "x$enable_debug" = xyes; then
145 DEFINES="$DEFINES -DDEBUG"
146 if test "x$GCC" = xyes; then
147 CFLAGS="$CFLAGS -g"
148 fi
149 if test "x$GXX" = xyes; then
150 CXXFLAGS="$CXXFLAGS -g"
151 fi
152fi
Dan Nicholson3e288622007-12-12 09:02:31 -0800153dnl These will be used near the end in the arch specific options
154AC_ARG_ENABLE(asm,
155 [AS_HELP_STRING([--disable-asm],
156 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
157 enable_asm="$enableval",
158 enable_asm=yes
159)
Dan Nicholson88586332007-11-15 08:59:57 -0800160
161dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700162dnl library names
163dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800164if test "$enable_static" = yes; then
165 GL_LIB_NAME='lib$(GL_LIB).a'
166 GLU_LIB_NAME='lib$(GLU_LIB).a'
167 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
168 GLW_LIB_NAME='lib$(GLW_LIB).a'
169 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
170else
171 GL_LIB_NAME='lib$(GL_LIB).so'
172 GLU_LIB_NAME='lib$(GLU_LIB).so'
173 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
174 GLW_LIB_NAME='lib$(GLW_LIB).so'
175 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
176fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700177AC_SUBST(GL_LIB_NAME)
178AC_SUBST(GLU_LIB_NAME)
179AC_SUBST(GLUT_LIB_NAME)
180AC_SUBST(GLW_LIB_NAME)
181AC_SUBST(OSMESA_LIB_NAME)
182
183dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800184dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800185dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800186dnl
187AC_ARG_WITH(driver,
188 [AS_HELP_STRING([--with-driver=DRIVER],
Dan Nicholsona1307182007-12-12 17:49:49 -0800189 [driver for Mesa: xlib,dri,osmesa @<:@default=xlib@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800190 mesa_driver="$withval",
Dan Nicholsona1307182007-12-12 17:49:49 -0800191 mesa_driver="xlib")
Dan Nicholson44d99142007-12-05 18:47:01 -0800192dnl Check for valid option
193case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800194xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800195 ;;
196*)
197 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
198 ;;
199esac
200
201dnl
202dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700203dnl
204SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700205GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800206WINDOW_SYSTEM=""
207case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800208xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800209 DRIVER_DIRS="x11"
210 ;;
211dri)
212 SRC_DIRS="glx/x11 $SRC_DIRS"
213 DRIVER_DIRS="dri"
214 WINDOW_SYSTEM="dri"
215 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800216osmesa)
217 DRIVER_DIRS="osmesa"
218 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800219esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700220AC_SUBST(SRC_DIRS)
221AC_SUBST(GLU_DIRS)
222AC_SUBST(DRIVER_DIRS)
Dan Nicholson44d99142007-12-05 18:47:01 -0800223AC_SUBST(WINDOW_SYSTEM)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700224
225dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800226dnl User supplied program configuration
227dnl
228if test -d "$srcdir/progs/demos"; then
229 default_demos=yes
230else
231 default_demos=no
232fi
233AC_ARG_WITH(demos,
234 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
235 [optional comma delimited demo directories to build
236 @<:@default=yes if source available@:>@])],
237 with_demos="$withval",
238 with_demos="$default_demos")
239if test "x$with_demos" = x; then
240 with_demos=no
241fi
242
243dnl If $with_demos is yes, directories will be added as libs available
244PROGRAM_DIRS=""
245case "$with_demos" in
246no|yes) ;;
247*)
248 # verify the requested demos directories exist
249 demos=`IFS=,; echo $with_demos`
250 for demo in $demos; do
251 test -d "$srcdir/progs/$demo" || \
252 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
253 done
254 PROGRAM_DIRS="$demos"
255 ;;
256esac
257
258dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700259dnl Find out if X is available. The variables have_x or no_x will be
260dnl set and used later in the driver setups
261dnl
262if test -n "$PKG_CONFIG"; then
263 AC_MSG_CHECKING([pkg-config files for X11 are available])
264 if $PKG_CONFIG --exists x11; then
265 x11_pkgconfig=yes
266 have_x=yes
267 AC_MSG_RESULT(yes)
268 else
269 x11_pkgconfig=no
270 no_x=yes
271 AC_MSG_RESULT(no)
272 fi
273else
274 x11_pkgconfig=no
275fi
276dnl Use the autoconf macro if no pkg-config files
277if test "$x11_pkgconfig" = no; then
278 AC_PATH_XTRA
279fi
280
Dan Nicholson44d99142007-12-05 18:47:01 -0800281dnl We need X for xlib and dri, so bomb now if it's not found
282case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800283xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800284 if test "$no_x" = yes; then
285 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
286 fi
287 ;;
288esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700289
Dan Nicholson44d99142007-12-05 18:47:01 -0800290dnl
291dnl libGL configuration per driver
292dnl
293case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800294xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800295 if test "$x11_pkgconfig" = yes; then
Dan Nicholsona1307182007-12-12 17:49:49 -0800296 PKG_CHECK_MODULES(XLIBGL, x11 xext)
297 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
298 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800299 else
300 # should check these...
301 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
302 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
303 fi
304 GL_LIB_DEPS="$GL_LIB_DEPS -lm -lpthread"
Dan Nicholson88586332007-11-15 08:59:57 -0800305
306 # if static, move the external libraries to the programs
307 # and empty the libraries for libGL
308 if test "$enable_static" = yes; then
309 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
310 GL_LIB_DEPS=""
311 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800312 ;;
313dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800314 # DRI must be shared, I think
315 if test "$enable_static" = yes; then
316 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
317 fi
318
Dan Nicholson44d99142007-12-05 18:47:01 -0800319 # Check for libdrm
320 PKG_CHECK_MODULES(LIBDRM, libdrm)
321
322 # find the DRI deps for libGL
323 if test "$x11_pkgconfig" = yes; then
324 PKG_CHECK_MODULES(DRIGL, x11 xext xxf86vm xdamage xfixes)
325 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
326 GL_LIB_DEPS="$DRIGL_LIBS"
327 else
328 # should check these...
329 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
330 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
331 fi
332
333 # need DRM libs, -lpthread, etc.
334 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread -ldl"
335 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800336osmesa)
337 # No libGL for osmesa
338 GL_LIB_DEPS=""
339 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800340esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700341AC_SUBST(GL_LIB_DEPS)
342
343dnl
344dnl More X11 setup
345dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800346if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700347 DEFINES="$DEFINES -DUSE_XSHM"
348fi
349
350dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800351dnl More DRI setup
352dnl
353AC_ARG_ENABLE(glx-tls,
354 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800355 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800356 GLX_USE_TLS="$enableval",
357 GLX_USE_TLS=no)
358dnl Directory for DRI drivers
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800359AC_ARG_WITH(dri-driverdir,
360 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson44d99142007-12-05 18:47:01 -0800361 [directory for the DRI drivers @<:@/usr/X11R6/lib/modules/dri@:>@])],
362 DRI_DRIVER_INSTALL_DIR="$withval",
363 DRI_DRIVER_INSTALL_DIR='/usr/X11R6/lib/modules/dri')
364AC_SUBST(DRI_DRIVER_INSTALL_DIR)
365dnl Direct rendering or just indirect rendering
366AC_ARG_ENABLE(driglx-direct,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800367 [AS_HELP_STRING([--disable-driglx-direct],
368 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800369 driglx_direct="$enableval",
370 driglx_direct="yes")
371
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800372dnl Which drivers to build - default is chosen by platform
373AC_ARG_WITH(dri-drivers,
374 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
375 [comma delimited DRI drivers to build @<:@default=auto by platform@:>@])],
376 with_dri_drivers="$withval",
377 with_dri_drivers=yes)
378if test "x$with_dri_drivers" = x; then
379 with_dri_drivers=no
380fi
381
382dnl If $with_dri_drivers is yes, directories will be added through
383dnl platform checks
384DRI_DIRS=""
385case "$with_dri_drivers" in
386no|yes) ;;
387*)
388 # verify the requested driver directories exist
389 dri_drivers=`IFS=,; echo $with_dri_drivers`
390 for driver in $dri_drivers; do
391 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
392 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
393 done
394 DRI_DIRS="$dri_drivers"
395 ;;
396esac
397
Dan Nicholson44d99142007-12-05 18:47:01 -0800398dnl Just default to no EGL for now
399USING_EGL=0
400AC_SUBST(USING_EGL)
401
402dnl Set DRI_DIRS, DEFINES and LIB_DEPS
403if test "$mesa_driver" = dri; then
404 # Use TLS in GLX?
405 if test "x$GLX_USE_TLS" = xyes; then
406 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
407 fi
408
409 if test "x$USING_EGL" = x1; then
410 PROGRAM_DIRS="egl"
411 fi
412
Dan Nicholsona76e2452007-12-07 11:25:08 -0800413 # default drivers
414 if test "x$DRI_DIRS" = x; then
415 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
416 savage sis tdfx trident unichrome ffb"
417 fi
418
Dan Nicholson44d99142007-12-05 18:47:01 -0800419 # Platform specific settings and drivers to build
420 case "$host_os" in
421 linux*)
422 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
423 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
424 if test "x$driglx_direct" = xyes; then
425 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
426 fi
427
428 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800429 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800430 # ffb, gamma, and sis are missing because they have not be
431 # converted to use the new interface. i810 are missing
432 # because there is no x86-64 system where they could *ever*
433 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800434 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800435 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
436 savage tdfx unichrome"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800437 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800438 ;;
439 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800440 # Build only the drivers for cards that exist on PowerPC.
441 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800442 if test "x$DRI_DIRS" = x; then
443 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
444 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800445 ;;
446 esac
447 ;;
448 freebsd*)
449 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
450 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
451 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
452 if test "x$driglx_direct" = xyes; then
453 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
454 fi
455 if test "x$GXX" = xyes; then
456 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
457 fi
458
Dan Nicholsona76e2452007-12-07 11:25:08 -0800459 # ffb and gamma are missing because they have not been converted
460 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800461 if test "x$DRI_DIRS" = x; then
462 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
463 unichrome savage sis"
464 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800465 ;;
466 esac
467 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
468
469 # Check for expat
470 EXPAT_INCLUDES=""
471 EXPAT_LIB=-lexpat
472 AC_ARG_WITH(expat, AS_HELP_STRING([--with-expat=DIR],
473 [expat install directory]),[
474 EXPAT_INCLUDES="-I$withval/include"
475 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
476 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
477 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
478 ])
479 AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR([Expat required for DRI.]))
480 AC_CHECK_LIB(expat, XML_ParserCreate,,
481 AC_MSG_ERROR([Expat required for DRI.]))
482
483 # put all the necessary libs together
484 DRI_LIB_DEPS="$LIBDRM_LIBS $EXPAT_LIB -lm -lpthread -ldl"
485fi
486AC_SUBST(DRI_DIRS)
487AC_SUBST(EXPAT_INCLUDES)
488AC_SUBST(DRI_LIB_DEPS)
489
490dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700491dnl OSMesa configuration
492dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800493if test "$mesa_driver" = xlib; then
494 default_xlib_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800495else
Dan Nicholsona1307182007-12-12 17:49:49 -0800496 default_xlib_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800497fi
Dan Nicholsona1307182007-12-12 17:49:49 -0800498AC_ARG_ENABLE(xlib-osmesa,
499 [AS_HELP_STRING([--disable-xlib-osmesa],
500 [enable OSMesa on Xlib libGL @<:@default=enabled for xlib driver@:>@])],
501 xlib_osmesa="$enableval",
502 xlib_osmesa="$default_xlib_osmesa")
503if test "x$xlib_osmesa" = xyes; then
504 if test "$mesa_driver" = xlib; then
Dan Nicholson979ff512007-12-05 18:47:01 -0800505 DRIVER_DIRS="$DRIVER_DIRS osmesa"
506 else
Dan Nicholsona1307182007-12-12 17:49:49 -0800507 AC_MSG_ERROR([Can only enable OSMesa on libGL for Xlib])
Dan Nicholson979ff512007-12-05 18:47:01 -0800508 fi
509fi
510
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800511dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
512AC_ARG_WITH(osmesa-bits,
513 [AS_HELP_STRING([--with-osmesa-bits=BITS],
514 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
515 osmesa_bits="$withval",
516 osmesa_bits=8)
517if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
518 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
519 osmesa_bits=8
520fi
521case "x$osmesa_bits" in
522x8)
523 OSMESA_LIB=OSMesa
524 ;;
525x16|x32)
526 OSMESA_LIB="OSMesa$osmesa_bits"
527 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
528 ;;
529*)
530 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
531 ;;
532esac
533AC_SUBST(OSMESA_LIB)
534
Dan Nicholson979ff512007-12-05 18:47:01 -0800535case "$mesa_driver" in
536osmesa)
Dan Nicholson88586332007-11-15 08:59:57 -0800537 # only link librararies with osmesa if shared
538 if test "$enable_static" = no; then
539 OSMESA_LIB_DEPS="-lm -lpthread"
540 else
541 OSMESA_LIB_DEPS=""
542 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800543 OSMESA_MESA_DEPS=""
544 ;;
545*)
546 # Link OSMesa to libGL otherwise
547 OSMESA_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800548 # only link librararies with osmesa if shared
549 if test "$enable_static" = no; then
550 OSMESA_MESA_DEPS='-l$(GL_LIB)'
551 else
552 OSMESA_MESA_DEPS=""
553 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800554 ;;
555esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700556AC_SUBST(OSMESA_LIB_DEPS)
557AC_SUBST(OSMESA_MESA_DEPS)
558
559dnl
560dnl GLU configuration
561dnl
562AC_ARG_ENABLE(glu,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800563 [AS_HELP_STRING([--disable-glu],
564 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700565 enable_glu="$enableval",
566 enable_glu=yes)
567if test "x$enable_glu" = xyes; then
568 SRC_DIRS="$SRC_DIRS glu"
569
Dan Nicholson979ff512007-12-05 18:47:01 -0800570 case "$mesa_driver" in
571 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800572 # If GLU is available and we have libOSMesa (not 16 or 32),
573 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800574 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800575 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
576 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700577
Dan Nicholson979ff512007-12-05 18:47:01 -0800578 # Link libGLU to libOSMesa instead of libGL
579 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800580 if test "$enable_static" = no; then
581 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
582 else
583 GLU_MESA_DEPS=""
584 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800585 ;;
586 *)
587 # If GLU is available, we can build the xdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800588 if test "$with_demos" = yes; then
589 PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
590 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800591
Dan Nicholson88586332007-11-15 08:59:57 -0800592 # If static, empty GLU_LIB_DEPS and add libs for programs to link
593 if test "$enable_static" = no; then
594 GLU_LIB_DEPS="-lm"
595 GLU_MESA_DEPS='-l$(GL_LIB)'
596 else
597 GLU_LIB_DEPS=""
598 GLU_MESA_DEPS=""
599 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
600 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800601 ;;
602 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700603fi
604AC_SUBST(GLU_LIB_DEPS)
605AC_SUBST(GLU_MESA_DEPS)
606
607dnl
608dnl GLw configuration
609dnl
610AC_ARG_ENABLE(glw,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800611 [AS_HELP_STRING([--disable-glw],
612 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700613 enable_glw="$enableval",
614 enable_glw=yes)
Dan Nicholson979ff512007-12-05 18:47:01 -0800615dnl Don't build GLw on osmesa
616if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
617 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
618 enable_glw=no
619fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700620if test "x$enable_glw" = xyes; then
621 SRC_DIRS="$SRC_DIRS glw"
622 if test "$x11_pkgconfig" = yes; then
623 PKG_CHECK_MODULES(GLW, x11 xt)
624 GLW_LIB_DEPS="$GLW_LIBS"
625 else
626 # should check these...
627 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
628 fi
629
Dan Nicholson88586332007-11-15 08:59:57 -0800630 # If static, empty GLW_LIB_DEPS and add libs for programs to link
631 if test "$enable_static" = no; then
632 GLW_MESA_DEPS='-l$(GL_LIB)'
633 else
634 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
635 GLW_LIB_DEPS=""
636 GLW_MESA_DEPS=""
637 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700638fi
639AC_SUBST(GLW_LIB_DEPS)
640AC_SUBST(GLW_MESA_DEPS)
641
642dnl
643dnl GLUT configuration
644dnl
645if test -f "$srcdir/include/GL/glut.h"; then
646 default_glut=yes
647else
648 default_glut=no
649fi
650AC_ARG_ENABLE(glut,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800651 [AS_HELP_STRING([--disable-glut],
652 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700653 enable_glut="$enableval",
654 enable_glut="$default_glut")
655
656dnl Can't build glut if GLU not available
657if test "x$enable_glu$enable_glut" = xnoyes; then
658 AC_MSG_WARN([Disabling glut since GLU is disabled])
659 enable_glut=no
660fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800661dnl Don't build glut on osmesa
662if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
663 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
664 enable_glut=no
665fi
666
Dan Nicholsondca1b792007-10-23 09:25:58 -0700667if test "x$enable_glut" = xyes; then
668 SRC_DIRS="$SRC_DIRS glut/glx"
669 GLUT_CFLAGS=""
670 if test "x$GCC" = xyes; then
671 GLUT_CFLAGS="-fexceptions"
672 fi
673 if test "$x11_pkgconfig" = yes; then
Dan Nicholson70d0c832007-12-07 11:12:20 -0800674 PKG_CHECK_MODULES(GLUT, x11 xmu xi)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700675 GLUT_LIB_DEPS="$GLUT_LIBS"
676 else
677 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800678 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700679 fi
680 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
681
682 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800683 if test "$with_demos" = yes; then
684 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
685 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700686
Dan Nicholson88586332007-11-15 08:59:57 -0800687 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
688 if test "$enable_static" = no; then
689 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
690 else
691 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
692 GLUT_LIB_DEPS=""
693 GLUT_MESA_DEPS=""
694 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700695fi
696AC_SUBST(GLUT_LIB_DEPS)
697AC_SUBST(GLUT_MESA_DEPS)
698AC_SUBST(GLUT_CFLAGS)
699
700dnl
701dnl Program library dependencies
702dnl Only libm is added here if necessary as the libraries should
703dnl be pulled in by the linker
704dnl
705if test "x$APP_LIB_DEPS" = x; then
706 APP_LIB_DEPS="-lm"
707fi
708AC_SUBST(APP_LIB_DEPS)
709AC_SUBST(PROGRAM_DIRS)
710
711dnl Arch/platform-specific settings
712PIC_FLAGS=""
713ASM_FLAGS=""
714ASM_SOURCES=""
715ASM_API=""
716AC_SUBST(PIC_FLAGS)
717AC_SUBST(ASM_FLAGS)
718AC_SUBST(ASM_SOURCES)
719AC_SUBST(ASM_API)
720case "$host_os" in
721linux*)
722 PIC_FLAGS="-fPIC"
723 case "$host_cpu" in
724 i*86)
Dan Nicholson3e288622007-12-12 09:02:31 -0800725 if test "x$enable_asm" = xyes; then
726 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
727 ASM_SOURCES='$(X86_SOURCES)'
728 ASM_API='$(X86_API)'
729 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700730 ;;
731 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800732 if test "x$enable_asm" = xyes; then
733 ASM_FLAGS="-DUSE_X86_64_ASM"
734 ASM_SOURCES='$(X86-64_SOURCES)'
735 ASM_API='$(X86-64_API)'
736 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700737 ;;
738 powerpc)
Dan Nicholson3e288622007-12-12 09:02:31 -0800739 if test "x$enable_asm" = xyes; then
740 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
741 ASM_SOURCES='$(PPC_SOURCES)'
742 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700743 ;;
744 esac
745 ;;
746freebsd*)
747 PIC_FLAGS="-fPIC"
748 case "$host_os" in
749 i*86)
750 PIC_FLAGS=""
Dan Nicholson3e288622007-12-12 09:02:31 -0800751 if test "x$enable_asm" = xyes; then
752 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
753 ASM_SOURCES='$(X86_SOURCES)'
754 ASM_API='$(X86_API)'
755 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700756 ;;
757 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800758 if test "x$enable_asm" = xyes; then
759 ASM_FLAGS="-DUSE_X86_64_ASM"
760 ASM_SOURCES='$(X86-64_SOURCES)'
761 ASM_API='$(X86-64_API)'
762 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700763 ;;
764 esac
765 ;;
766esac
767
768dnl Restore LDFLAGS and CPPFLAGS
769LDFLAGS="$_SAVE_LDFLAGS"
770CPPFLAGS="$_SAVE_CPPFLAGS"
771
772dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800773AC_CONFIG_FILES([configs/autoconf])
774AC_OUTPUT
Dan Nicholsondca1b792007-10-23 09:25:58 -0700775
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800776dnl Replace the configs/current symlink
777if test -f configs/current || test -L configs/current; then
778 rm -f configs/current
779fi
780ln -s autoconf configs/current
781
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800782dnl
783dnl Output some configuration info for the user
784dnl
785echo ""
786echo " prefix: $prefix"
787echo " exec_prefix: $exec_prefix"
788echo " libdir: $libdir"
789
790dnl Driver info
791echo ""
792echo " Driver: $mesa_driver"
793case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800794xlib|osmesa)
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800795 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
796 echo " OSMesa: lib$OSMESA_LIB"
797 else
798 echo " OSMesa: no"
799 fi
800 ;;
801dri)
802 # cleanup the drivers var
803 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
804 echo " DRI drivers: $dri_dirs"
805 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
806 ;;
807esac
808
809dnl Libraries
810echo ""
811echo " Shared libs: $enable_shared"
812echo " Static libs: $enable_static"
813echo " GLU: $enable_glu"
814echo " GLw: $enable_glw"
815echo " glut: $enable_glut"
816
817dnl Programs
818# cleanup the programs var for display
819program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
820if test "x$program_dirs" = x; then
821 echo " Demos: no"
822else
823 echo " Demos: $program_dirs"
824fi
825
Dan Nicholson16a07fb2007-12-12 09:12:15 -0800826dnl Compiler options
827# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
828cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
829 $SED 's/^ *//;s/ */ /;s/ *$//'`
830cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
831 $SED 's/^ *//;s/ */ /;s/ *$//'`
832defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
833echo ""
834echo " CFLAGS: $cflags"
835echo " CXXFLAGS: $cxxflags"
836echo " Macros: $defines"
837
Dan Nicholsondca1b792007-10-23 09:25:58 -0700838echo ""
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800839echo " Run 'make' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700840echo ""