blob: 5db4af77eea53f29dffeb748af2c9c72d56128c8 [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
12AC_INIT(Mesa, mesa_version(), mesa3d@sourceforge.net)
13AC_CONFIG_AUX_DIR(bin)
14AC_CANONICAL_HOST
15
16dnl Substitute the version number into shell variables
17MESA_MAJOR=mesa_major()
18MESA_MINOR=mesa_minor()
19MESA_TINY=mesa_tiny()
20AC_SUBST(MESA_MAJOR)
21AC_SUBST(MESA_MINOR)
22AC_SUBST(MESA_TINY)
23
24dnl Check for progs
25AC_PROG_CPP
26AC_PROG_CC
27AC_PROG_CXX
28AC_PATH_PROG(MAKE, make)
29AC_PATH_PROG(MKDEP, makedepend)
30AC_PATH_PROG(SED, sed)
Dan Nicholson41b00702007-12-12 08:48:30 -080031
32dnl Make sure the pkg-config macros are defined
33m4_ifdef([PKG_PROG_PKG_CONFIG],,[
34 AC_MSG_ERROR([The pkg-config autoconf macros are not defined.
35 Did you run 'make configure'?])]
36)
Dan Nicholsondca1b792007-10-23 09:25:58 -070037PKG_PROG_PKG_CONFIG()
38
39dnl LIB_DIR - library basename
40LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
41AC_SUBST(LIB_DIR)
42
43dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
44_SAVE_LDFLAGS="$LDFLAGS"
45AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
46AC_SUBST(EXTRA_LIB_PATH)
47
48dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
49_SAVE_CPPFLAGS="$CPPFLAGS"
50AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
51AC_SUBST(X11_INCLUDES)
52
53dnl Compiler macros
54DEFINES=""
55AC_SUBST(DEFINES)
56if test "x$GCC" = xyes; then
57 DEFINES="-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
58fi
59case "$host_os" in
60linux*)
61 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
62 ;;
63esac
64
65dnl Add flags for gcc and g++
66if test "x$GCC" = xyes; then
67 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
68fi
69if test "x$GXX" = xyes; then
70 CXXFLAGS="$CXXFLAGS -Wall"
71fi
72
73dnl These should be unnecessary, but let the user set them if they want
74AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
75 Default is to use CFLAGS.])
76AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
77 compiler. Default is to use CFLAGS.])
78AC_SUBST(OPT_FLAGS)
79AC_SUBST(ARCH_FLAGS)
80
81dnl
Dan Nicholson88586332007-11-15 08:59:57 -080082dnl shared/static libraries, mimic libtool options
83dnl
84AC_ARG_ENABLE(static,
85 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -080086 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -080087 enable_static="$enableval",
88 enable_static=no
89)
90case "x$enable_static" in
91xyes|xno ) ;;
92x ) enable_static=no ;;
93* )
94 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
95 ;;
96esac
97AC_ARG_ENABLE(shared,
98 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -080099 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800100 enable_shared="$enableval",
101 enable_shared=yes
102)
103case "x$enable_shared" in
104xyes|xno ) ;;
105x ) enable_shared=yes ;;
106* )
107 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
108 ;;
109esac
110
111dnl Can't have static and shared libraries, default to static if user
112dnl explicitly requested. If both disabled, set to static since shared
113dnl was explicitly requirested.
114case "x$enable_static$enable_shared" in
115xyesyes )
116 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
117 enable_shared=no
118 ;;
119xnono )
120 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
121 enable_static=yes
122 ;;
123esac
124
125dnl
126dnl mklib options
127dnl
128AC_ARG_VAR(MKLIB_OPTIONS,[Options for the Mesa library script, mklib])
129if test "$enable_static" = yes; then
130 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
131fi
132AC_SUBST(MKLIB_OPTIONS)
133
Dan Nicholson23656c42007-12-12 09:02:31 -0800134dnl
135dnl other compiler options
136dnl
137AC_ARG_ENABLE(debug,
138 [AS_HELP_STRING([--enable-debug],
139 [use debug compiler flags and macros @<:@default=disabled@:>@])],
140 enable_debug="$enableval",
141 enable_debug=no
142)
143if test "x$enable_debug" = xyes; then
144 DEFINES="$DEFINES -DDEBUG"
145 if test "x$GCC" = xyes; then
146 CFLAGS="$CFLAGS -g"
147 fi
148 if test "x$GXX" = xyes; then
149 CXXFLAGS="$CXXFLAGS -g"
150 fi
151fi
Dan Nicholson3e288622007-12-12 09:02:31 -0800152dnl These will be used near the end in the arch specific options
153AC_ARG_ENABLE(asm,
154 [AS_HELP_STRING([--disable-asm],
155 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
156 enable_asm="$enableval",
157 enable_asm=yes
158)
Dan Nicholson88586332007-11-15 08:59:57 -0800159
160dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700161dnl library names
162dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800163if test "$enable_static" = yes; then
164 GL_LIB_NAME='lib$(GL_LIB).a'
165 GLU_LIB_NAME='lib$(GLU_LIB).a'
166 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
167 GLW_LIB_NAME='lib$(GLW_LIB).a'
168 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
169else
170 GL_LIB_NAME='lib$(GL_LIB).so'
171 GLU_LIB_NAME='lib$(GLU_LIB).so'
172 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
173 GLW_LIB_NAME='lib$(GLW_LIB).so'
174 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
175fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700176AC_SUBST(GL_LIB_NAME)
177AC_SUBST(GLU_LIB_NAME)
178AC_SUBST(GLUT_LIB_NAME)
179AC_SUBST(GLW_LIB_NAME)
180AC_SUBST(OSMESA_LIB_NAME)
181
182dnl
Dan Nicholson979ff512007-12-05 18:47:01 -0800183dnl Driver configuration. Options are x11 (Xlib), dri and osmesa right now.
184dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800185dnl
186AC_ARG_WITH(driver,
187 [AS_HELP_STRING([--with-driver=DRIVER],
Dan Nicholson979ff512007-12-05 18:47:01 -0800188 [driver for Mesa: x11,dri,osmesa @<:@default=x11@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800189 mesa_driver="$withval",
190 mesa_driver="x11")
191dnl Check for valid option
192case "x$mesa_driver" in
Dan Nicholson979ff512007-12-05 18:47:01 -0800193xx11|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800194 ;;
195*)
196 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
197 ;;
198esac
199
200dnl
201dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700202dnl
203SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700204GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800205WINDOW_SYSTEM=""
206case "$mesa_driver" in
207x11)
208 DRIVER_DIRS="x11"
209 ;;
210dri)
211 SRC_DIRS="glx/x11 $SRC_DIRS"
212 DRIVER_DIRS="dri"
213 WINDOW_SYSTEM="dri"
214 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800215osmesa)
216 DRIVER_DIRS="osmesa"
217 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800218esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700219AC_SUBST(SRC_DIRS)
220AC_SUBST(GLU_DIRS)
221AC_SUBST(DRIVER_DIRS)
Dan Nicholson44d99142007-12-05 18:47:01 -0800222AC_SUBST(WINDOW_SYSTEM)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700223
224dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800225dnl User supplied program configuration
226dnl
227if test -d "$srcdir/progs/demos"; then
228 default_demos=yes
229else
230 default_demos=no
231fi
232AC_ARG_WITH(demos,
233 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
234 [optional comma delimited demo directories to build
235 @<:@default=yes if source available@:>@])],
236 with_demos="$withval",
237 with_demos="$default_demos")
238if test "x$with_demos" = x; then
239 with_demos=no
240fi
241
242dnl If $with_demos is yes, directories will be added as libs available
243PROGRAM_DIRS=""
244case "$with_demos" in
245no|yes) ;;
246*)
247 # verify the requested demos directories exist
248 demos=`IFS=,; echo $with_demos`
249 for demo in $demos; do
250 test -d "$srcdir/progs/$demo" || \
251 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
252 done
253 PROGRAM_DIRS="$demos"
254 ;;
255esac
256
257dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700258dnl Find out if X is available. The variables have_x or no_x will be
259dnl set and used later in the driver setups
260dnl
261if test -n "$PKG_CONFIG"; then
262 AC_MSG_CHECKING([pkg-config files for X11 are available])
263 if $PKG_CONFIG --exists x11; then
264 x11_pkgconfig=yes
265 have_x=yes
266 AC_MSG_RESULT(yes)
267 else
268 x11_pkgconfig=no
269 no_x=yes
270 AC_MSG_RESULT(no)
271 fi
272else
273 x11_pkgconfig=no
274fi
275dnl Use the autoconf macro if no pkg-config files
276if test "$x11_pkgconfig" = no; then
277 AC_PATH_XTRA
278fi
279
Dan Nicholson44d99142007-12-05 18:47:01 -0800280dnl We need X for xlib and dri, so bomb now if it's not found
281case "$mesa_driver" in
282x11|dri)
283 if test "$no_x" = yes; then
284 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
285 fi
286 ;;
287esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700288
Dan Nicholson44d99142007-12-05 18:47:01 -0800289dnl
290dnl libGL configuration per driver
291dnl
292case "$mesa_driver" in
293x11)
294 if test "$x11_pkgconfig" = yes; then
295 PKG_CHECK_MODULES(X11GL, x11 xext)
296 X11_INCLUDES="$X11_INCLUDES $X11GL_CFLAGS"
297 GL_LIB_DEPS="$X11GL_LIBS"
298 else
299 # should check these...
300 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
301 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
302 fi
303 GL_LIB_DEPS="$GL_LIB_DEPS -lm -lpthread"
Dan Nicholson88586332007-11-15 08:59:57 -0800304
305 # if static, move the external libraries to the programs
306 # and empty the libraries for libGL
307 if test "$enable_static" = yes; then
308 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
309 GL_LIB_DEPS=""
310 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800311 ;;
312dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800313 # DRI must be shared, I think
314 if test "$enable_static" = yes; then
315 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
316 fi
317
Dan Nicholson44d99142007-12-05 18:47:01 -0800318 # Check for libdrm
319 PKG_CHECK_MODULES(LIBDRM, libdrm)
320
321 # find the DRI deps for libGL
322 if test "$x11_pkgconfig" = yes; then
323 PKG_CHECK_MODULES(DRIGL, x11 xext xxf86vm xdamage xfixes)
324 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
325 GL_LIB_DEPS="$DRIGL_LIBS"
326 else
327 # should check these...
328 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
329 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
330 fi
331
332 # need DRM libs, -lpthread, etc.
333 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread -ldl"
334 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800335osmesa)
336 # No libGL for osmesa
337 GL_LIB_DEPS=""
338 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800339esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700340AC_SUBST(GL_LIB_DEPS)
341
342dnl
343dnl More X11 setup
344dnl
345if test "$mesa_driver" = x11; then
346 DEFINES="$DEFINES -DUSE_XSHM"
347fi
348
349dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800350dnl More DRI setup
351dnl
352AC_ARG_ENABLE(glx-tls,
353 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800354 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800355 GLX_USE_TLS="$enableval",
356 GLX_USE_TLS=no)
357dnl Directory for DRI drivers
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800358AC_ARG_WITH(dri-driverdir,
359 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson44d99142007-12-05 18:47:01 -0800360 [directory for the DRI drivers @<:@/usr/X11R6/lib/modules/dri@:>@])],
361 DRI_DRIVER_INSTALL_DIR="$withval",
362 DRI_DRIVER_INSTALL_DIR='/usr/X11R6/lib/modules/dri')
363AC_SUBST(DRI_DRIVER_INSTALL_DIR)
364dnl Direct rendering or just indirect rendering
365AC_ARG_ENABLE(driglx-direct,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800366 [AS_HELP_STRING([--disable-driglx-direct],
367 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800368 driglx_direct="$enableval",
369 driglx_direct="yes")
370
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800371dnl Which drivers to build - default is chosen by platform
372AC_ARG_WITH(dri-drivers,
373 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
374 [comma delimited DRI drivers to build @<:@default=auto by platform@:>@])],
375 with_dri_drivers="$withval",
376 with_dri_drivers=yes)
377if test "x$with_dri_drivers" = x; then
378 with_dri_drivers=no
379fi
380
381dnl If $with_dri_drivers is yes, directories will be added through
382dnl platform checks
383DRI_DIRS=""
384case "$with_dri_drivers" in
385no|yes) ;;
386*)
387 # verify the requested driver directories exist
388 dri_drivers=`IFS=,; echo $with_dri_drivers`
389 for driver in $dri_drivers; do
390 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
391 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
392 done
393 DRI_DIRS="$dri_drivers"
394 ;;
395esac
396
Dan Nicholson44d99142007-12-05 18:47:01 -0800397dnl Just default to no EGL for now
398USING_EGL=0
399AC_SUBST(USING_EGL)
400
401dnl Set DRI_DIRS, DEFINES and LIB_DEPS
402if test "$mesa_driver" = dri; then
403 # Use TLS in GLX?
404 if test "x$GLX_USE_TLS" = xyes; then
405 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
406 fi
407
408 if test "x$USING_EGL" = x1; then
409 PROGRAM_DIRS="egl"
410 fi
411
Dan Nicholsona76e2452007-12-07 11:25:08 -0800412 # default drivers
413 if test "x$DRI_DIRS" = x; then
414 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
415 savage sis tdfx trident unichrome ffb"
416 fi
417
Dan Nicholson44d99142007-12-05 18:47:01 -0800418 # Platform specific settings and drivers to build
419 case "$host_os" in
420 linux*)
421 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
422 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
423 if test "x$driglx_direct" = xyes; then
424 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
425 fi
426
427 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800428 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800429 # ffb, gamma, and sis are missing because they have not be
430 # converted to use the new interface. i810 are missing
431 # because there is no x86-64 system where they could *ever*
432 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800433 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800434 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
435 savage tdfx unichrome"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800436 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800437 ;;
438 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800439 # Build only the drivers for cards that exist on PowerPC.
440 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800441 if test "x$DRI_DIRS" = x; then
442 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
443 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800444 ;;
445 esac
446 ;;
447 freebsd*)
448 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
449 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
450 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
451 if test "x$driglx_direct" = xyes; then
452 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
453 fi
454 if test "x$GXX" = xyes; then
455 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
456 fi
457
Dan Nicholsona76e2452007-12-07 11:25:08 -0800458 # ffb and gamma are missing because they have not been converted
459 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800460 if test "x$DRI_DIRS" = x; then
461 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
462 unichrome savage sis"
463 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800464 ;;
465 esac
466 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
467
468 # Check for expat
469 EXPAT_INCLUDES=""
470 EXPAT_LIB=-lexpat
471 AC_ARG_WITH(expat, AS_HELP_STRING([--with-expat=DIR],
472 [expat install directory]),[
473 EXPAT_INCLUDES="-I$withval/include"
474 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
475 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
476 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
477 ])
478 AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR([Expat required for DRI.]))
479 AC_CHECK_LIB(expat, XML_ParserCreate,,
480 AC_MSG_ERROR([Expat required for DRI.]))
481
482 # put all the necessary libs together
483 DRI_LIB_DEPS="$LIBDRM_LIBS $EXPAT_LIB -lm -lpthread -ldl"
484fi
485AC_SUBST(DRI_DIRS)
486AC_SUBST(EXPAT_INCLUDES)
487AC_SUBST(DRI_LIB_DEPS)
488
489dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700490dnl OSMesa configuration
491dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800492if test "$mesa_driver" = x11; then
Dan Nicholson979ff512007-12-05 18:47:01 -0800493 default_x11_osmesa=yes
494else
495 default_x11_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800496fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800497AC_ARG_ENABLE(x11-osmesa,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800498 [AS_HELP_STRING([--disable-x11-osmesa],
499 [enable OSMesa on X11 libGL @<:@default=enabled for x11 driver@:>@])],
Dan Nicholson979ff512007-12-05 18:47:01 -0800500 x11_osmesa="$enableval",
501 x11_osmesa="$default_x11_osmesa")
502if test "x$x11_osmesa" = xyes; then
503 if test "$mesa_driver" = x11; then
504 DRIVER_DIRS="$DRIVER_DIRS osmesa"
505 else
506 AC_MSG_ERROR([Can only enable OSMesa on libGL for X11])
507 fi
508fi
509
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800510dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
511AC_ARG_WITH(osmesa-bits,
512 [AS_HELP_STRING([--with-osmesa-bits=BITS],
513 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
514 osmesa_bits="$withval",
515 osmesa_bits=8)
516if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
517 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
518 osmesa_bits=8
519fi
520case "x$osmesa_bits" in
521x8)
522 OSMESA_LIB=OSMesa
523 ;;
524x16|x32)
525 OSMESA_LIB="OSMesa$osmesa_bits"
526 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
527 ;;
528*)
529 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
530 ;;
531esac
532AC_SUBST(OSMESA_LIB)
533
Dan Nicholson979ff512007-12-05 18:47:01 -0800534case "$mesa_driver" in
535osmesa)
Dan Nicholson88586332007-11-15 08:59:57 -0800536 # only link librararies with osmesa if shared
537 if test "$enable_static" = no; then
538 OSMESA_LIB_DEPS="-lm -lpthread"
539 else
540 OSMESA_LIB_DEPS=""
541 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800542 OSMESA_MESA_DEPS=""
543 ;;
544*)
545 # Link OSMesa to libGL otherwise
546 OSMESA_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800547 # only link librararies with osmesa if shared
548 if test "$enable_static" = no; then
549 OSMESA_MESA_DEPS='-l$(GL_LIB)'
550 else
551 OSMESA_MESA_DEPS=""
552 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800553 ;;
554esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700555AC_SUBST(OSMESA_LIB_DEPS)
556AC_SUBST(OSMESA_MESA_DEPS)
557
558dnl
559dnl GLU configuration
560dnl
561AC_ARG_ENABLE(glu,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800562 [AS_HELP_STRING([--disable-glu],
563 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700564 enable_glu="$enableval",
565 enable_glu=yes)
566if test "x$enable_glu" = xyes; then
567 SRC_DIRS="$SRC_DIRS glu"
568
Dan Nicholson979ff512007-12-05 18:47:01 -0800569 case "$mesa_driver" in
570 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800571 # If GLU is available and we have libOSMesa (not 16 or 32),
572 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800573 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800574 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
575 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700576
Dan Nicholson979ff512007-12-05 18:47:01 -0800577 # Link libGLU to libOSMesa instead of libGL
578 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800579 if test "$enable_static" = no; then
580 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
581 else
582 GLU_MESA_DEPS=""
583 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800584 ;;
585 *)
586 # If GLU is available, we can build the xdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800587 if test "$with_demos" = yes; then
588 PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
589 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800590
Dan Nicholson88586332007-11-15 08:59:57 -0800591 # If static, empty GLU_LIB_DEPS and add libs for programs to link
592 if test "$enable_static" = no; then
593 GLU_LIB_DEPS="-lm"
594 GLU_MESA_DEPS='-l$(GL_LIB)'
595 else
596 GLU_LIB_DEPS=""
597 GLU_MESA_DEPS=""
598 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
599 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800600 ;;
601 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700602fi
603AC_SUBST(GLU_LIB_DEPS)
604AC_SUBST(GLU_MESA_DEPS)
605
606dnl
607dnl GLw configuration
608dnl
609AC_ARG_ENABLE(glw,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800610 [AS_HELP_STRING([--disable-glw],
611 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700612 enable_glw="$enableval",
613 enable_glw=yes)
Dan Nicholson979ff512007-12-05 18:47:01 -0800614dnl Don't build GLw on osmesa
615if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
616 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
617 enable_glw=no
618fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700619if test "x$enable_glw" = xyes; then
620 SRC_DIRS="$SRC_DIRS glw"
621 if test "$x11_pkgconfig" = yes; then
622 PKG_CHECK_MODULES(GLW, x11 xt)
623 GLW_LIB_DEPS="$GLW_LIBS"
624 else
625 # should check these...
626 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
627 fi
628
Dan Nicholson88586332007-11-15 08:59:57 -0800629 # If static, empty GLW_LIB_DEPS and add libs for programs to link
630 if test "$enable_static" = no; then
631 GLW_MESA_DEPS='-l$(GL_LIB)'
632 else
633 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
634 GLW_LIB_DEPS=""
635 GLW_MESA_DEPS=""
636 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700637fi
638AC_SUBST(GLW_LIB_DEPS)
639AC_SUBST(GLW_MESA_DEPS)
640
641dnl
642dnl GLUT configuration
643dnl
644if test -f "$srcdir/include/GL/glut.h"; then
645 default_glut=yes
646else
647 default_glut=no
648fi
649AC_ARG_ENABLE(glut,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800650 [AS_HELP_STRING([--disable-glut],
651 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700652 enable_glut="$enableval",
653 enable_glut="$default_glut")
654
655dnl Can't build glut if GLU not available
656if test "x$enable_glu$enable_glut" = xnoyes; then
657 AC_MSG_WARN([Disabling glut since GLU is disabled])
658 enable_glut=no
659fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800660dnl Don't build glut on osmesa
661if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
662 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
663 enable_glut=no
664fi
665
Dan Nicholsondca1b792007-10-23 09:25:58 -0700666if test "x$enable_glut" = xyes; then
667 SRC_DIRS="$SRC_DIRS glut/glx"
668 GLUT_CFLAGS=""
669 if test "x$GCC" = xyes; then
670 GLUT_CFLAGS="-fexceptions"
671 fi
672 if test "$x11_pkgconfig" = yes; then
Dan Nicholson70d0c832007-12-07 11:12:20 -0800673 PKG_CHECK_MODULES(GLUT, x11 xmu xi)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700674 GLUT_LIB_DEPS="$GLUT_LIBS"
675 else
676 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800677 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700678 fi
679 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
680
681 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800682 if test "$with_demos" = yes; then
683 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
684 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700685
Dan Nicholson88586332007-11-15 08:59:57 -0800686 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
687 if test "$enable_static" = no; then
688 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
689 else
690 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
691 GLUT_LIB_DEPS=""
692 GLUT_MESA_DEPS=""
693 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700694fi
695AC_SUBST(GLUT_LIB_DEPS)
696AC_SUBST(GLUT_MESA_DEPS)
697AC_SUBST(GLUT_CFLAGS)
698
699dnl
700dnl Program library dependencies
701dnl Only libm is added here if necessary as the libraries should
702dnl be pulled in by the linker
703dnl
704if test "x$APP_LIB_DEPS" = x; then
705 APP_LIB_DEPS="-lm"
706fi
707AC_SUBST(APP_LIB_DEPS)
708AC_SUBST(PROGRAM_DIRS)
709
710dnl Arch/platform-specific settings
711PIC_FLAGS=""
712ASM_FLAGS=""
713ASM_SOURCES=""
714ASM_API=""
715AC_SUBST(PIC_FLAGS)
716AC_SUBST(ASM_FLAGS)
717AC_SUBST(ASM_SOURCES)
718AC_SUBST(ASM_API)
719case "$host_os" in
720linux*)
721 PIC_FLAGS="-fPIC"
722 case "$host_cpu" in
723 i*86)
Dan Nicholson3e288622007-12-12 09:02:31 -0800724 if test "x$enable_asm" = xyes; then
725 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
726 ASM_SOURCES='$(X86_SOURCES)'
727 ASM_API='$(X86_API)'
728 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700729 ;;
730 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800731 if test "x$enable_asm" = xyes; then
732 ASM_FLAGS="-DUSE_X86_64_ASM"
733 ASM_SOURCES='$(X86-64_SOURCES)'
734 ASM_API='$(X86-64_API)'
735 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700736 ;;
737 powerpc)
Dan Nicholson3e288622007-12-12 09:02:31 -0800738 if test "x$enable_asm" = xyes; then
739 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
740 ASM_SOURCES='$(PPC_SOURCES)'
741 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700742 ;;
743 esac
744 ;;
745freebsd*)
746 PIC_FLAGS="-fPIC"
747 case "$host_os" in
748 i*86)
749 PIC_FLAGS=""
Dan Nicholson3e288622007-12-12 09:02:31 -0800750 if test "x$enable_asm" = xyes; then
751 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
752 ASM_SOURCES='$(X86_SOURCES)'
753 ASM_API='$(X86_API)'
754 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700755 ;;
756 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800757 if test "x$enable_asm" = xyes; then
758 ASM_FLAGS="-DUSE_X86_64_ASM"
759 ASM_SOURCES='$(X86-64_SOURCES)'
760 ASM_API='$(X86-64_API)'
761 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700762 ;;
763 esac
764 ;;
765esac
766
767dnl Restore LDFLAGS and CPPFLAGS
768LDFLAGS="$_SAVE_LDFLAGS"
769CPPFLAGS="$_SAVE_CPPFLAGS"
770
771dnl Substitute the config
772AC_OUTPUT([configs/autoconf])
773
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800774dnl Replace the configs/current symlink
775if test -f configs/current || test -L configs/current; then
776 rm -f configs/current
777fi
778ln -s autoconf configs/current
779
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800780dnl
781dnl Output some configuration info for the user
782dnl
783echo ""
784echo " prefix: $prefix"
785echo " exec_prefix: $exec_prefix"
786echo " libdir: $libdir"
787
788dnl Driver info
789echo ""
790echo " Driver: $mesa_driver"
791case "$mesa_driver" in
792x11|osmesa)
793 if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
794 echo " OSMesa: lib$OSMESA_LIB"
795 else
796 echo " OSMesa: no"
797 fi
798 ;;
799dri)
800 # cleanup the drivers var
801 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
802 echo " DRI drivers: $dri_dirs"
803 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
804 ;;
805esac
806
807dnl Libraries
808echo ""
809echo " Shared libs: $enable_shared"
810echo " Static libs: $enable_static"
811echo " GLU: $enable_glu"
812echo " GLw: $enable_glw"
813echo " glut: $enable_glut"
814
815dnl Programs
816# cleanup the programs var for display
817program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
818if test "x$program_dirs" = x; then
819 echo " Demos: no"
820else
821 echo " Demos: $program_dirs"
822fi
823
Dan Nicholson16a07fb2007-12-12 09:12:15 -0800824dnl Compiler options
825# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
826cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
827 $SED 's/^ *//;s/ */ /;s/ *$//'`
828cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
829 $SED 's/^ *//;s/ */ /;s/ *$//'`
830defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
831echo ""
832echo " CFLAGS: $cflags"
833echo " CXXFLAGS: $cxxflags"
834echo " Macros: $defines"
835
Dan Nicholsondca1b792007-10-23 09:25:58 -0700836echo ""
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800837echo " Run 'make' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700838echo ""