blob: 504d9acdc91ef89917ca1433bca9faba05df4c76 [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
Eric Anholt5ad06152008-03-20 17:14:20 -070029AC_PATH_PROG(MAKE, gmake, [not_found])
30if test "x$MAKE" = "xnot_found"; then
31 AC_PATH_PROG(MAKE, make)
32fi
Dan Nicholsondca1b792007-10-23 09:25:58 -070033AC_PATH_PROG(MKDEP, makedepend)
34AC_PATH_PROG(SED, sed)
Dan Nicholson41b00702007-12-12 08:48:30 -080035
Dan Nicholsondb7fc632008-03-07 11:48:09 -080036MKDEP_OPTIONS=-fdepend
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050037dnl Ask gcc where it's keeping its secret headers
38if test "x$GCC" = xyes; then
Dan Nicholsondb7fc632008-03-07 11:48:09 -080039 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
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050043fi
44AC_SUBST(MKDEP_OPTIONS)
45
Dan Nicholson41b00702007-12-12 08:48:30 -080046dnl Make sure the pkg-config macros are defined
47m4_ifdef([PKG_PROG_PKG_CONFIG],,[
48 AC_MSG_ERROR([The pkg-config autoconf macros are not defined.
49 Did you run 'make configure'?])]
50)
Dan Nicholsondca1b792007-10-23 09:25:58 -070051PKG_PROG_PKG_CONFIG()
52
53dnl LIB_DIR - library basename
54LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
55AC_SUBST(LIB_DIR)
56
57dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
58_SAVE_LDFLAGS="$LDFLAGS"
59AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
60AC_SUBST(EXTRA_LIB_PATH)
61
62dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
63_SAVE_CPPFLAGS="$CPPFLAGS"
64AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
65AC_SUBST(X11_INCLUDES)
66
67dnl Compiler macros
68DEFINES=""
69AC_SUBST(DEFINES)
Dan Nicholsondca1b792007-10-23 09:25:58 -070070case "$host_os" in
71linux*)
Eric Anholt5ad06152008-03-20 17:14:20 -070072if test "x$GCC" = xyes; then
73 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
74fi
Dan Nicholsondca1b792007-10-23 09:25:58 -070075 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
76 ;;
77esac
78
79dnl Add flags for gcc and g++
80if test "x$GCC" = xyes; then
81 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -080082
83 # Work around aliasing bugs - developers should comment this out
84 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -070085fi
86if test "x$GXX" = xyes; then
87 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -080088
89 # Work around aliasing bugs - developers should comment this out
90 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -070091fi
92
93dnl These should be unnecessary, but let the user set them if they want
94AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
95 Default is to use CFLAGS.])
96AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
97 compiler. Default is to use CFLAGS.])
98AC_SUBST(OPT_FLAGS)
99AC_SUBST(ARCH_FLAGS)
100
101dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600102dnl Hacks to enable 32 or 64 bit build
103dnl
104AC_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)
110if 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
117fi
118AC_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)
124if 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
131fi
132
133dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800134dnl shared/static libraries, mimic libtool options
135dnl
136AC_ARG_ENABLE(static,
137 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800138 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800139 enable_static="$enableval",
140 enable_static=no
141)
142case "x$enable_static" in
143xyes|xno ) ;;
144x ) enable_static=no ;;
145* )
146 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
147 ;;
148esac
149AC_ARG_ENABLE(shared,
150 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800151 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800152 enable_shared="$enableval",
153 enable_shared=yes
154)
155case "x$enable_shared" in
156xyes|xno ) ;;
157x ) enable_shared=yes ;;
158* )
159 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
160 ;;
161esac
162
163dnl Can't have static and shared libraries, default to static if user
164dnl explicitly requested. If both disabled, set to static since shared
165dnl was explicitly requirested.
166case "x$enable_static$enable_shared" in
167xyesyes )
168 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
169 enable_shared=no
170 ;;
171xnono )
172 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
173 enable_static=yes
174 ;;
175esac
176
177dnl
178dnl mklib options
179dnl
180AC_ARG_VAR(MKLIB_OPTIONS,[Options for the Mesa library script, mklib])
181if test "$enable_static" = yes; then
182 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
183fi
184AC_SUBST(MKLIB_OPTIONS)
185
Dan Nicholson23656c42007-12-12 09:02:31 -0800186dnl
187dnl other compiler options
188dnl
189AC_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)
195if 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
203fi
Dan Nicholson3e288622007-12-12 09:02:31 -0800204dnl These will be used near the end in the arch specific options
205AC_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)
Dan Nicholson88586332007-11-15 08:59:57 -0800211
212dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700213dnl library names
214dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800215if 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'
221else
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'
227fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700228AC_SUBST(GL_LIB_NAME)
229AC_SUBST(GLU_LIB_NAME)
230AC_SUBST(GLUT_LIB_NAME)
231AC_SUBST(GLW_LIB_NAME)
232AC_SUBST(OSMESA_LIB_NAME)
233
234dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800235dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800236dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800237dnl
238AC_ARG_WITH(driver,
239 [AS_HELP_STRING([--with-driver=DRIVER],
Dan Nicholsona1307182007-12-12 17:49:49 -0800240 [driver for Mesa: xlib,dri,osmesa @<:@default=xlib@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800241 mesa_driver="$withval",
Dan Nicholsona1307182007-12-12 17:49:49 -0800242 mesa_driver="xlib")
Dan Nicholson44d99142007-12-05 18:47:01 -0800243dnl Check for valid option
244case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800245xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800246 ;;
247*)
248 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
249 ;;
250esac
251
252dnl
253dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700254dnl
255SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700256GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800257WINDOW_SYSTEM=""
258case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800259xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800260 DRIVER_DIRS="x11"
261 ;;
262dri)
263 SRC_DIRS="glx/x11 $SRC_DIRS"
264 DRIVER_DIRS="dri"
265 WINDOW_SYSTEM="dri"
266 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800267osmesa)
268 DRIVER_DIRS="osmesa"
269 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800270esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700271AC_SUBST(SRC_DIRS)
272AC_SUBST(GLU_DIRS)
273AC_SUBST(DRIVER_DIRS)
Dan Nicholson44d99142007-12-05 18:47:01 -0800274AC_SUBST(WINDOW_SYSTEM)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700275
276dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800277dnl User supplied program configuration
278dnl
279if test -d "$srcdir/progs/demos"; then
280 default_demos=yes
281else
282 default_demos=no
283fi
284AC_ARG_WITH(demos,
285 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
286 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800287 @<:@default=auto if source available@:>@])],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800288 with_demos="$withval",
289 with_demos="$default_demos")
290if test "x$with_demos" = x; then
291 with_demos=no
292fi
293
294dnl If $with_demos is yes, directories will be added as libs available
295PROGRAM_DIRS=""
296case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700297no) ;;
298yes)
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 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800304*)
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 ;;
313esac
314
315dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700316dnl Find out if X is available. The variables have_x or no_x will be
317dnl set and used later in the driver setups
318dnl
319if 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
330else
331 x11_pkgconfig=no
332fi
333dnl Use the autoconf macro if no pkg-config files
334if test "$x11_pkgconfig" = no; then
335 AC_PATH_XTRA
336fi
337
Dan Nicholson44d99142007-12-05 18:47:01 -0800338dnl We need X for xlib and dri, so bomb now if it's not found
339case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800340xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800341 if test "$no_x" = yes; then
342 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
343 fi
344 ;;
345esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700346
Adam Jackson66611f22008-02-15 13:49:12 -0500347# SELinux awareness.
348AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux], [Build SELinux-aware Mesa (default: disabled)]), [MESA_SELINUX=$enableval], [MESA_SELINUX=no])
349if 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"
356fi
357
Dan Nicholson44d99142007-12-05 18:47:01 -0800358dnl
359dnl libGL configuration per driver
360dnl
361case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800362xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800363 if test "$x11_pkgconfig" = yes; then
Dan Nicholsona1307182007-12-12 17:49:49 -0800364 PKG_CHECK_MODULES(XLIBGL, x11 xext)
365 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
366 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800367 else
368 # should check these...
369 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
370 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
371 fi
Adam Jackson66611f22008-02-15 13:49:12 -0500372 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
Dan Nicholson88586332007-11-15 08:59:57 -0800373
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
Dan Nicholson44d99142007-12-05 18:47:01 -0800380 ;;
381dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800382 # 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
Dan Nicholson44d99142007-12-05 18:47:01 -0800387 # 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 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800404osmesa)
405 # No libGL for osmesa
406 GL_LIB_DEPS=""
407 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800408esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700409AC_SUBST(GL_LIB_DEPS)
410
411dnl
412dnl More X11 setup
413dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800414if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700415 DEFINES="$DEFINES -DUSE_XSHM"
416fi
417
418dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800419dnl More DRI setup
420dnl
421AC_ARG_ENABLE(glx-tls,
422 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800423 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800424 GLX_USE_TLS="$enableval",
425 GLX_USE_TLS=no)
426dnl Directory for DRI drivers
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800427AC_ARG_WITH(dri-driverdir,
428 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson44d99142007-12-05 18:47:01 -0800429 [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')
432AC_SUBST(DRI_DRIVER_INSTALL_DIR)
433dnl Direct rendering or just indirect rendering
434AC_ARG_ENABLE(driglx-direct,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800435 [AS_HELP_STRING([--disable-driglx-direct],
436 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800437 driglx_direct="$enableval",
438 driglx_direct="yes")
439
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800440dnl Which drivers to build - default is chosen by platform
441AC_ARG_WITH(dri-drivers,
442 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800443 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800444 with_dri_drivers="$withval",
445 with_dri_drivers=yes)
446if test "x$with_dri_drivers" = x; then
447 with_dri_drivers=no
448fi
449
450dnl If $with_dri_drivers is yes, directories will be added through
451dnl platform checks
452DRI_DIRS=""
453case "$with_dri_drivers" in
454no|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 ;;
464esac
465
Dan Nicholson44d99142007-12-05 18:47:01 -0800466dnl Just default to no EGL for now
467USING_EGL=0
468AC_SUBST(USING_EGL)
469
470dnl Set DRI_DIRS, DEFINES and LIB_DEPS
471if 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
Dan Nicholson44d99142007-12-05 18:47:01 -0800491 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800492 # 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.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800496 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800497 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
498 savage tdfx unichrome"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800499 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800500 ;;
501 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800502 # Build only the drivers for cards that exist on PowerPC.
503 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800504 if test "x$DRI_DIRS" = x; then
505 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
506 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800507 ;;
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
Dan Nicholsona76e2452007-12-07 11:25:08 -0800521 # ffb and gamma are missing because they have not been converted
522 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800523 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
Dan Nicholson44d99142007-12-05 18:47:01 -0800527 ;;
528 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800529
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
Dan Nicholson44d99142007-12-05 18:47:01 -0800536 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
Adam Jackson66611f22008-02-15 13:49:12 -0500553 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread -ldl"
Dan Nicholson44d99142007-12-05 18:47:01 -0800554fi
555AC_SUBST(DRI_DIRS)
556AC_SUBST(EXPAT_INCLUDES)
557AC_SUBST(DRI_LIB_DEPS)
558
559dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700560dnl OSMesa configuration
561dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800562if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800563 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800564else
Dan Nicholson544ab202007-12-30 08:41:53 -0800565 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800566fi
Dan Nicholson544ab202007-12-30 08:41:53 -0800567AC_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")
572if test "x$gl_osmesa" = xyes; then
573 if test "$mesa_driver" = osmesa; then
574 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800575 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800576 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800577 fi
578fi
579
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800580dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
581AC_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)
586if 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
589fi
590case "x$osmesa_bits" in
591x8)
592 OSMESA_LIB=OSMesa
593 ;;
594x16|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 ;;
601esac
602AC_SUBST(OSMESA_LIB)
603
Dan Nicholson979ff512007-12-05 18:47:01 -0800604case "$mesa_driver" in
605osmesa)
Dan Nicholson88586332007-11-15 08:59:57 -0800606 # only link librararies with osmesa if shared
607 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500608 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800609 else
610 OSMESA_LIB_DEPS=""
611 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800612 OSMESA_MESA_DEPS=""
613 ;;
614*)
615 # Link OSMesa to libGL otherwise
616 OSMESA_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800617 # 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
Dan Nicholson979ff512007-12-05 18:47:01 -0800623 ;;
624esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700625AC_SUBST(OSMESA_LIB_DEPS)
626AC_SUBST(OSMESA_MESA_DEPS)
627
628dnl
629dnl GLU configuration
630dnl
631AC_ARG_ENABLE(glu,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800632 [AS_HELP_STRING([--disable-glu],
633 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700634 enable_glu="$enableval",
635 enable_glu=yes)
636if test "x$enable_glu" = xyes; then
637 SRC_DIRS="$SRC_DIRS glu"
638
Dan Nicholson979ff512007-12-05 18:47:01 -0800639 case "$mesa_driver" in
640 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800641 # If GLU is available and we have libOSMesa (not 16 or 32),
642 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800643 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800644 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
645 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700646
Dan Nicholson979ff512007-12-05 18:47:01 -0800647 # Link libGLU to libOSMesa instead of libGL
648 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800649 if test "$enable_static" = no; then
650 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
651 else
652 GLU_MESA_DEPS=""
653 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800654 ;;
655 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800656 # 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
Dan Nicholson979ff512007-12-05 18:47:01 -0800665 ;;
666 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700667fi
668AC_SUBST(GLU_LIB_DEPS)
669AC_SUBST(GLU_MESA_DEPS)
670
671dnl
672dnl GLw configuration
673dnl
674AC_ARG_ENABLE(glw,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800675 [AS_HELP_STRING([--disable-glw],
676 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700677 enable_glw="$enableval",
678 enable_glw=yes)
Dan Nicholson979ff512007-12-05 18:47:01 -0800679dnl Don't build GLw on osmesa
680if 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
683fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700684if 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
Dan Nicholson88586332007-11-15 08:59:57 -0800694 # 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
Dan Nicholsondca1b792007-10-23 09:25:58 -0700702fi
703AC_SUBST(GLW_LIB_DEPS)
704AC_SUBST(GLW_MESA_DEPS)
705
706dnl
707dnl GLUT configuration
708dnl
709if test -f "$srcdir/include/GL/glut.h"; then
710 default_glut=yes
711else
712 default_glut=no
713fi
714AC_ARG_ENABLE(glut,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800715 [AS_HELP_STRING([--disable-glut],
716 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700717 enable_glut="$enableval",
718 enable_glut="$default_glut")
719
720dnl Can't build glut if GLU not available
721if test "x$enable_glu$enable_glut" = xnoyes; then
722 AC_MSG_WARN([Disabling glut since GLU is disabled])
723 enable_glut=no
724fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800725dnl Don't build glut on osmesa
726if 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
729fi
730
Dan Nicholsondca1b792007-10-23 09:25:58 -0700731if 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
Dan Nicholson70d0c832007-12-07 11:12:20 -0800738 PKG_CHECK_MODULES(GLUT, x11 xmu xi)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700739 GLUT_LIB_DEPS="$GLUT_LIBS"
740 else
741 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800742 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700743 fi
744 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
745
746 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800747 if test "$with_demos" = yes; then
748 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
749 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700750
Dan Nicholson88586332007-11-15 08:59:57 -0800751 # 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
Dan Nicholsondca1b792007-10-23 09:25:58 -0700759fi
760AC_SUBST(GLUT_LIB_DEPS)
761AC_SUBST(GLUT_MESA_DEPS)
762AC_SUBST(GLUT_CFLAGS)
763
764dnl
765dnl Program library dependencies
766dnl Only libm is added here if necessary as the libraries should
767dnl be pulled in by the linker
768dnl
769if test "x$APP_LIB_DEPS" = x; then
770 APP_LIB_DEPS="-lm"
771fi
772AC_SUBST(APP_LIB_DEPS)
773AC_SUBST(PROGRAM_DIRS)
774
775dnl Arch/platform-specific settings
776PIC_FLAGS=""
777ASM_FLAGS=""
778ASM_SOURCES=""
779ASM_API=""
780AC_SUBST(PIC_FLAGS)
781AC_SUBST(ASM_FLAGS)
782AC_SUBST(ASM_SOURCES)
783AC_SUBST(ASM_API)
784case "$host_os" in
785linux*)
786 PIC_FLAGS="-fPIC"
787 case "$host_cpu" in
788 i*86)
Dan Nicholson3e288622007-12-12 09:02:31 -0800789 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
Dan Nicholsondca1b792007-10-23 09:25:58 -0700794 ;;
795 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800796 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
Dan Nicholsondca1b792007-10-23 09:25:58 -0700801 ;;
802 powerpc)
Dan Nicholson3e288622007-12-12 09:02:31 -0800803 if test "x$enable_asm" = xyes; then
804 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
805 ASM_SOURCES='$(PPC_SOURCES)'
806 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700807 ;;
808 esac
809 ;;
810freebsd*)
811 PIC_FLAGS="-fPIC"
Dan Nicholson758b9982008-02-21 10:32:04 -0800812 case "$host_cpu" in
Dan Nicholsondca1b792007-10-23 09:25:58 -0700813 i*86)
814 PIC_FLAGS=""
Dan Nicholson3e288622007-12-12 09:02:31 -0800815 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
Dan Nicholsondca1b792007-10-23 09:25:58 -0700820 ;;
821 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800822 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
Dan Nicholsondca1b792007-10-23 09:25:58 -0700827 ;;
828 esac
829 ;;
830esac
831
832dnl Restore LDFLAGS and CPPFLAGS
833LDFLAGS="$_SAVE_LDFLAGS"
834CPPFLAGS="$_SAVE_CPPFLAGS"
835
836dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800837AC_CONFIG_FILES([configs/autoconf])
838AC_OUTPUT
Dan Nicholsondca1b792007-10-23 09:25:58 -0700839
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800840dnl Replace the configs/current symlink
841if test -f configs/current || test -L configs/current; then
842 rm -f configs/current
843fi
844ln -s autoconf configs/current
845
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800846dnl
847dnl Output some configuration info for the user
848dnl
849echo ""
850echo " prefix: $prefix"
851echo " exec_prefix: $exec_prefix"
852echo " libdir: $libdir"
853
854dnl Driver info
855echo ""
856echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -0800857if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
858 echo " OSMesa: lib$OSMESA_LIB"
859else
860 echo " OSMesa: no"
861fi
862if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800863 # 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"
Dan Nicholson544ab202007-12-30 08:41:53 -0800867fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800868
869dnl Libraries
870echo ""
871echo " Shared libs: $enable_shared"
872echo " Static libs: $enable_static"
873echo " GLU: $enable_glu"
874echo " GLw: $enable_glw"
875echo " glut: $enable_glut"
876
877dnl Programs
878# cleanup the programs var for display
879program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
880if test "x$program_dirs" = x; then
881 echo " Demos: no"
882else
883 echo " Demos: $program_dirs"
884fi
885
Dan Nicholson16a07fb2007-12-12 09:12:15 -0800886dnl Compiler options
887# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
888cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
889 $SED 's/^ *//;s/ */ /;s/ *$//'`
890cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
891 $SED 's/^ *//;s/ */ /;s/ *$//'`
892defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
893echo ""
894echo " CFLAGS: $cflags"
895echo " CXXFLAGS: $cxxflags"
896echo " Macros: $defines"
897
Dan Nicholsondca1b792007-10-23 09:25:58 -0700898echo ""
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800899echo " Run 'make' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700900echo ""