blob: 8566384e0c8fce0a3d9ba3f060058d84f197ebba [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
Dan Nicholsonb6459422008-03-24 10:01:50 -070029AC_CHECK_PROGS(MAKE, [gmake make])
Dan Nicholsondca1b792007-10-23 09:25:58 -070030AC_PATH_PROG(MKDEP, makedepend)
31AC_PATH_PROG(SED, sed)
Dan Nicholson41b00702007-12-12 08:48:30 -080032
Dan Nicholsondb7fc632008-03-07 11:48:09 -080033MKDEP_OPTIONS=-fdepend
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050034dnl Ask gcc where it's keeping its secret headers
35if test "x$GCC" = xyes; then
Dan Nicholsondb7fc632008-03-07 11:48:09 -080036 GCC_INCLUDES=`$CC -print-file-name=include`
37 if test "x$GCC_INCLUDES" != x; then
38 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
39 fi
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050040fi
41AC_SUBST(MKDEP_OPTIONS)
42
Eric Anholt050c5332008-03-20 17:28:58 -070043dnl Check to see if dlopen is in default libraries (like Solaris, which
44dnl has it in libc), or if libdl is needed to get it.
45AC_CHECK_FUNC([dlopen], [],
46 AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
47
Dan Nicholson41b00702007-12-12 08:48:30 -080048dnl Make sure the pkg-config macros are defined
49m4_ifdef([PKG_PROG_PKG_CONFIG],,[
50 AC_MSG_ERROR([The pkg-config autoconf macros are not defined.
51 Did you run 'make configure'?])]
52)
Dan Nicholsondca1b792007-10-23 09:25:58 -070053PKG_PROG_PKG_CONFIG()
54
55dnl LIB_DIR - library basename
56LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
57AC_SUBST(LIB_DIR)
58
59dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
60_SAVE_LDFLAGS="$LDFLAGS"
61AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
62AC_SUBST(EXTRA_LIB_PATH)
63
64dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
65_SAVE_CPPFLAGS="$CPPFLAGS"
66AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
67AC_SUBST(X11_INCLUDES)
68
69dnl Compiler macros
70DEFINES=""
71AC_SUBST(DEFINES)
Dan Nicholsondca1b792007-10-23 09:25:58 -070072case "$host_os" in
73linux*)
Eric Anholt5ad06152008-03-20 17:14:20 -070074if test "x$GCC" = xyes; then
75 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
76fi
Dan Nicholsondca1b792007-10-23 09:25:58 -070077 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
78 ;;
79esac
80
81dnl Add flags for gcc and g++
82if test "x$GCC" = xyes; then
83 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -080084
85 # Work around aliasing bugs - developers should comment this out
86 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -070087fi
88if test "x$GXX" = xyes; then
89 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -080090
91 # Work around aliasing bugs - developers should comment this out
92 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -070093fi
94
95dnl These should be unnecessary, but let the user set them if they want
96AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
97 Default is to use CFLAGS.])
98AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
99 compiler. Default is to use CFLAGS.])
100AC_SUBST(OPT_FLAGS)
101AC_SUBST(ARCH_FLAGS)
102
103dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600104dnl Hacks to enable 32 or 64 bit build
105dnl
106AC_ARG_ENABLE(32-bit,
107 [AS_HELP_STRING([--enable-32-bit],
108 [build 32-bit libraries @<:@default=auto@:>@])],
109 enable_32bit="$enableval",
110 enable_32bit=auto
111)
112if test "x$enable_32bit" = xyes; then
113 if test "x$GCC" = xyes; then
114 CFLAGS="$CFLAGS -m32"
115 fi
116 if test "x$GXX" = xyes; then
117 CXXFLAGS="$CXXFLAGS -m32"
118 fi
119fi
120AC_ARG_ENABLE(64-bit,
121 [AS_HELP_STRING([--enable-64-bit],
122 [build 64-bit libraries @<:@default=auto@:>@])],
123 enable_64bit="$enableval",
124 enable_64bit=auto
125)
126if test "x$enable_64bit" = xyes; then
127 if test "x$GCC" = xyes; then
128 CFLAGS="$CFLAGS -m64"
129 fi
130 if test "x$GXX" = xyes; then
131 CXXFLAGS="$CXXFLAGS -m64"
132 fi
133fi
134
135dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800136dnl shared/static libraries, mimic libtool options
137dnl
138AC_ARG_ENABLE(static,
139 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800140 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800141 enable_static="$enableval",
142 enable_static=no
143)
144case "x$enable_static" in
145xyes|xno ) ;;
146x ) enable_static=no ;;
147* )
148 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
149 ;;
150esac
151AC_ARG_ENABLE(shared,
152 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800153 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800154 enable_shared="$enableval",
155 enable_shared=yes
156)
157case "x$enable_shared" in
158xyes|xno ) ;;
159x ) enable_shared=yes ;;
160* )
161 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
162 ;;
163esac
164
165dnl Can't have static and shared libraries, default to static if user
166dnl explicitly requested. If both disabled, set to static since shared
167dnl was explicitly requirested.
168case "x$enable_static$enable_shared" in
169xyesyes )
170 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
171 enable_shared=no
172 ;;
173xnono )
174 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
175 enable_static=yes
176 ;;
177esac
178
179dnl
180dnl mklib options
181dnl
182AC_ARG_VAR(MKLIB_OPTIONS,[Options for the Mesa library script, mklib])
183if test "$enable_static" = yes; then
184 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
185fi
186AC_SUBST(MKLIB_OPTIONS)
187
Dan Nicholson23656c42007-12-12 09:02:31 -0800188dnl
189dnl other compiler options
190dnl
191AC_ARG_ENABLE(debug,
192 [AS_HELP_STRING([--enable-debug],
193 [use debug compiler flags and macros @<:@default=disabled@:>@])],
194 enable_debug="$enableval",
195 enable_debug=no
196)
197if test "x$enable_debug" = xyes; then
198 DEFINES="$DEFINES -DDEBUG"
199 if test "x$GCC" = xyes; then
200 CFLAGS="$CFLAGS -g"
201 fi
202 if test "x$GXX" = xyes; then
203 CXXFLAGS="$CXXFLAGS -g"
204 fi
205fi
Dan Nicholson3e288622007-12-12 09:02:31 -0800206dnl These will be used near the end in the arch specific options
207AC_ARG_ENABLE(asm,
208 [AS_HELP_STRING([--disable-asm],
209 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
210 enable_asm="$enableval",
211 enable_asm=yes
212)
Dan Nicholson88586332007-11-15 08:59:57 -0800213
214dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700215dnl library names
216dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800217if test "$enable_static" = yes; then
218 GL_LIB_NAME='lib$(GL_LIB).a'
219 GLU_LIB_NAME='lib$(GLU_LIB).a'
220 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
221 GLW_LIB_NAME='lib$(GLW_LIB).a'
222 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
223else
224 GL_LIB_NAME='lib$(GL_LIB).so'
225 GLU_LIB_NAME='lib$(GLU_LIB).so'
226 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
227 GLW_LIB_NAME='lib$(GLW_LIB).so'
228 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
229fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700230AC_SUBST(GL_LIB_NAME)
231AC_SUBST(GLU_LIB_NAME)
232AC_SUBST(GLUT_LIB_NAME)
233AC_SUBST(GLW_LIB_NAME)
234AC_SUBST(OSMESA_LIB_NAME)
235
236dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800237dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800238dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800239dnl
Eric Anholt711222b2008-04-18 15:03:01 -0700240default_driver="xlib"
241
242case "$host_os" in
243linux*)
244 case "$host_cpu" in
245 i*86|x86_64|powerpc*) default_driver="dri";;
246 esac
247 ;;
248freebsd* | dragonfly*)
249 case "$host_cpu" in
250 i*86|x86_64) default_driver="dri";;
251 esac
252 ;;
253esac
254
Dan Nicholson44d99142007-12-05 18:47:01 -0800255AC_ARG_WITH(driver,
256 [AS_HELP_STRING([--with-driver=DRIVER],
Eric Anholt711222b2008-04-18 15:03:01 -0700257 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800258 mesa_driver="$withval",
Eric Anholt711222b2008-04-18 15:03:01 -0700259 mesa_driver="$default_driver")
Dan Nicholson44d99142007-12-05 18:47:01 -0800260dnl Check for valid option
261case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800262xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800263 ;;
264*)
265 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
266 ;;
267esac
268
269dnl
270dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700271dnl
272SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700273GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800274WINDOW_SYSTEM=""
275case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800276xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800277 DRIVER_DIRS="x11"
278 ;;
279dri)
280 SRC_DIRS="glx/x11 $SRC_DIRS"
281 DRIVER_DIRS="dri"
282 WINDOW_SYSTEM="dri"
283 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800284osmesa)
285 DRIVER_DIRS="osmesa"
286 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800287esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700288AC_SUBST(SRC_DIRS)
289AC_SUBST(GLU_DIRS)
290AC_SUBST(DRIVER_DIRS)
Dan Nicholson44d99142007-12-05 18:47:01 -0800291AC_SUBST(WINDOW_SYSTEM)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700292
293dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800294dnl User supplied program configuration
295dnl
296if test -d "$srcdir/progs/demos"; then
297 default_demos=yes
298else
299 default_demos=no
300fi
301AC_ARG_WITH(demos,
302 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
303 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800304 @<:@default=auto if source available@:>@])],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800305 with_demos="$withval",
306 with_demos="$default_demos")
307if test "x$with_demos" = x; then
308 with_demos=no
309fi
310
311dnl If $with_demos is yes, directories will be added as libs available
312PROGRAM_DIRS=""
313case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700314no) ;;
315yes)
316 # If the driver isn't osmesa, we have libGL and can build xdemos
317 if test "$mesa_driver" != osmesa; then
318 PROGRAM_DIRS="xdemos"
319 fi
320 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800321*)
322 # verify the requested demos directories exist
323 demos=`IFS=,; echo $with_demos`
324 for demo in $demos; do
325 test -d "$srcdir/progs/$demo" || \
326 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
327 done
328 PROGRAM_DIRS="$demos"
329 ;;
330esac
331
332dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700333dnl Find out if X is available. The variables have_x or no_x will be
334dnl set and used later in the driver setups
335dnl
336if test -n "$PKG_CONFIG"; then
337 AC_MSG_CHECKING([pkg-config files for X11 are available])
338 if $PKG_CONFIG --exists x11; then
339 x11_pkgconfig=yes
340 have_x=yes
341 AC_MSG_RESULT(yes)
342 else
343 x11_pkgconfig=no
344 no_x=yes
345 AC_MSG_RESULT(no)
346 fi
347else
348 x11_pkgconfig=no
349fi
350dnl Use the autoconf macro if no pkg-config files
351if test "$x11_pkgconfig" = no; then
352 AC_PATH_XTRA
353fi
354
Dan Nicholson44d99142007-12-05 18:47:01 -0800355dnl We need X for xlib and dri, so bomb now if it's not found
356case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800357xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800358 if test "$no_x" = yes; then
359 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
360 fi
361 ;;
362esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700363
Adam Jackson66611f22008-02-15 13:49:12 -0500364# SELinux awareness.
365AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux], [Build SELinux-aware Mesa (default: disabled)]), [MESA_SELINUX=$enableval], [MESA_SELINUX=no])
366if test "x$enable_selinux" = "xyes"; then
367 AC_CHECK_HEADER(selinux/selinux.h,,
368 AC_MSG_ERROR([SELinux headers not found]))
369 AC_CHECK_LIB(selinux,is_selinux_enabled,,
370 AC_MSG_ERROR([SELinux library not found]))
371 SELINUX_LIBS="-lselinux"
372 DEFINES="$DEFINES -DMESA_SELINUX"
373fi
374
Dan Nicholson44d99142007-12-05 18:47:01 -0800375dnl
376dnl libGL configuration per driver
377dnl
378case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800379xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800380 if test "$x11_pkgconfig" = yes; then
Dan Nicholsona1307182007-12-12 17:49:49 -0800381 PKG_CHECK_MODULES(XLIBGL, x11 xext)
382 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
383 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800384 else
385 # should check these...
386 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
387 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
388 fi
Adam Jackson66611f22008-02-15 13:49:12 -0500389 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
Dan Nicholson88586332007-11-15 08:59:57 -0800390
391 # if static, move the external libraries to the programs
392 # and empty the libraries for libGL
393 if test "$enable_static" = yes; then
394 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
395 GL_LIB_DEPS=""
396 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800397 ;;
398dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800399 # DRI must be shared, I think
400 if test "$enable_static" = yes; then
401 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
402 fi
403
Dan Nicholson44d99142007-12-05 18:47:01 -0800404 # Check for libdrm
405 PKG_CHECK_MODULES(LIBDRM, libdrm)
Kristian Høgsberge7869242008-04-02 19:17:31 -0400406 PKG_CHECK_MODULES(DRI2PROTO, dri2proto >= 1.1)
Dan Nicholson44d99142007-12-05 18:47:01 -0800407
408 # find the DRI deps for libGL
409 if test "$x11_pkgconfig" = yes; then
410 PKG_CHECK_MODULES(DRIGL, x11 xext xxf86vm xdamage xfixes)
411 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
412 GL_LIB_DEPS="$DRIGL_LIBS"
413 else
414 # should check these...
415 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
416 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
417 fi
418
419 # need DRM libs, -lpthread, etc.
Eric Anholt050c5332008-03-20 17:28:58 -0700420 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800421 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800422osmesa)
423 # No libGL for osmesa
424 GL_LIB_DEPS=""
425 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800426esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700427AC_SUBST(GL_LIB_DEPS)
428
429dnl
430dnl More X11 setup
431dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800432if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700433 DEFINES="$DEFINES -DUSE_XSHM"
434fi
435
436dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800437dnl More DRI setup
438dnl
439AC_ARG_ENABLE(glx-tls,
440 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800441 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800442 GLX_USE_TLS="$enableval",
443 GLX_USE_TLS=no)
444dnl Directory for DRI drivers
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800445AC_ARG_WITH(dri-driverdir,
446 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson44d99142007-12-05 18:47:01 -0800447 [directory for the DRI drivers @<:@/usr/X11R6/lib/modules/dri@:>@])],
448 DRI_DRIVER_INSTALL_DIR="$withval",
449 DRI_DRIVER_INSTALL_DIR='/usr/X11R6/lib/modules/dri')
450AC_SUBST(DRI_DRIVER_INSTALL_DIR)
451dnl Direct rendering or just indirect rendering
452AC_ARG_ENABLE(driglx-direct,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800453 [AS_HELP_STRING([--disable-driglx-direct],
454 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800455 driglx_direct="$enableval",
456 driglx_direct="yes")
457
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800458dnl Which drivers to build - default is chosen by platform
459AC_ARG_WITH(dri-drivers,
460 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800461 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800462 with_dri_drivers="$withval",
463 with_dri_drivers=yes)
464if test "x$with_dri_drivers" = x; then
465 with_dri_drivers=no
466fi
467
468dnl If $with_dri_drivers is yes, directories will be added through
469dnl platform checks
470DRI_DIRS=""
471case "$with_dri_drivers" in
472no|yes) ;;
473*)
474 # verify the requested driver directories exist
475 dri_drivers=`IFS=,; echo $with_dri_drivers`
476 for driver in $dri_drivers; do
477 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
478 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
479 done
480 DRI_DIRS="$dri_drivers"
481 ;;
482esac
483
Dan Nicholson44d99142007-12-05 18:47:01 -0800484dnl Just default to no EGL for now
485USING_EGL=0
486AC_SUBST(USING_EGL)
487
488dnl Set DRI_DIRS, DEFINES and LIB_DEPS
489if test "$mesa_driver" = dri; then
490 # Use TLS in GLX?
491 if test "x$GLX_USE_TLS" = xyes; then
492 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
493 fi
494
495 if test "x$USING_EGL" = x1; then
496 PROGRAM_DIRS="egl"
497 fi
498
499 # Platform specific settings and drivers to build
500 case "$host_os" in
501 linux*)
502 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
503 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
504 if test "x$driglx_direct" = xyes; then
505 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
506 fi
507
508 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800509 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800510 # ffb, gamma, and sis are missing because they have not be
511 # converted to use the new interface. i810 are missing
512 # because there is no x86-64 system where they could *ever*
513 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800514 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800515 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
516 savage tdfx unichrome"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800517 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800518 ;;
519 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800520 # Build only the drivers for cards that exist on PowerPC.
521 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800522 if test "x$DRI_DIRS" = x; then
523 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
524 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800525 ;;
526 esac
527 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700528 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800529 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
530 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
531 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
532 if test "x$driglx_direct" = xyes; then
533 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
534 fi
535 if test "x$GXX" = xyes; then
536 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
537 fi
538
Dan Nicholsona76e2452007-12-07 11:25:08 -0800539 # ffb and gamma are missing because they have not been converted
540 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800541 if test "x$DRI_DIRS" = x; then
542 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
543 unichrome savage sis"
544 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800545 ;;
546 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800547
548 # default drivers
549 if test "x$DRI_DIRS" = x; then
550 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
551 savage sis tdfx trident unichrome ffb"
552 fi
553
Dan Nicholson44d99142007-12-05 18:47:01 -0800554 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
555
556 # Check for expat
557 EXPAT_INCLUDES=""
558 EXPAT_LIB=-lexpat
559 AC_ARG_WITH(expat, AS_HELP_STRING([--with-expat=DIR],
560 [expat install directory]),[
561 EXPAT_INCLUDES="-I$withval/include"
562 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
563 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
564 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
565 ])
566 AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR([Expat required for DRI.]))
567 AC_CHECK_LIB(expat, XML_ParserCreate,,
568 AC_MSG_ERROR([Expat required for DRI.]))
569
570 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700571 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800572fi
573AC_SUBST(DRI_DIRS)
574AC_SUBST(EXPAT_INCLUDES)
575AC_SUBST(DRI_LIB_DEPS)
576
577dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700578dnl OSMesa configuration
579dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800580if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800581 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800582else
Dan Nicholson544ab202007-12-30 08:41:53 -0800583 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800584fi
Dan Nicholson544ab202007-12-30 08:41:53 -0800585AC_ARG_ENABLE(gl-osmesa,
586 [AS_HELP_STRING([--enable-gl-osmesa],
587 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
588 gl_osmesa="$enableval",
589 gl_osmesa="$default_gl_osmesa")
590if test "x$gl_osmesa" = xyes; then
591 if test "$mesa_driver" = osmesa; then
592 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800593 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800594 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800595 fi
596fi
597
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800598dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
599AC_ARG_WITH(osmesa-bits,
600 [AS_HELP_STRING([--with-osmesa-bits=BITS],
601 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
602 osmesa_bits="$withval",
603 osmesa_bits=8)
604if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
605 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
606 osmesa_bits=8
607fi
608case "x$osmesa_bits" in
609x8)
610 OSMESA_LIB=OSMesa
611 ;;
612x16|x32)
613 OSMESA_LIB="OSMesa$osmesa_bits"
614 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
615 ;;
616*)
617 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
618 ;;
619esac
620AC_SUBST(OSMESA_LIB)
621
Dan Nicholson979ff512007-12-05 18:47:01 -0800622case "$mesa_driver" in
623osmesa)
Dan Nicholson88586332007-11-15 08:59:57 -0800624 # only link librararies with osmesa if shared
625 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500626 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800627 else
628 OSMESA_LIB_DEPS=""
629 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800630 OSMESA_MESA_DEPS=""
631 ;;
632*)
633 # Link OSMesa to libGL otherwise
634 OSMESA_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800635 # only link librararies with osmesa if shared
636 if test "$enable_static" = no; then
637 OSMESA_MESA_DEPS='-l$(GL_LIB)'
638 else
639 OSMESA_MESA_DEPS=""
640 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800641 ;;
642esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700643AC_SUBST(OSMESA_LIB_DEPS)
644AC_SUBST(OSMESA_MESA_DEPS)
645
646dnl
647dnl GLU configuration
648dnl
649AC_ARG_ENABLE(glu,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800650 [AS_HELP_STRING([--disable-glu],
651 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700652 enable_glu="$enableval",
653 enable_glu=yes)
654if test "x$enable_glu" = xyes; then
655 SRC_DIRS="$SRC_DIRS glu"
656
Dan Nicholson979ff512007-12-05 18:47:01 -0800657 case "$mesa_driver" in
658 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800659 # If GLU is available and we have libOSMesa (not 16 or 32),
660 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800661 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800662 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
663 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700664
Dan Nicholson979ff512007-12-05 18:47:01 -0800665 # Link libGLU to libOSMesa instead of libGL
666 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800667 if test "$enable_static" = no; then
668 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
669 else
670 GLU_MESA_DEPS=""
671 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800672 ;;
673 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800674 # If static, empty GLU_LIB_DEPS and add libs for programs to link
675 if test "$enable_static" = no; then
676 GLU_LIB_DEPS="-lm"
677 GLU_MESA_DEPS='-l$(GL_LIB)'
678 else
679 GLU_LIB_DEPS=""
680 GLU_MESA_DEPS=""
681 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
682 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800683 ;;
684 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700685fi
686AC_SUBST(GLU_LIB_DEPS)
687AC_SUBST(GLU_MESA_DEPS)
688
689dnl
690dnl GLw configuration
691dnl
692AC_ARG_ENABLE(glw,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800693 [AS_HELP_STRING([--disable-glw],
694 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700695 enable_glw="$enableval",
696 enable_glw=yes)
Dan Nicholson979ff512007-12-05 18:47:01 -0800697dnl Don't build GLw on osmesa
698if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
699 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
700 enable_glw=no
701fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700702if test "x$enable_glw" = xyes; then
703 SRC_DIRS="$SRC_DIRS glw"
704 if test "$x11_pkgconfig" = yes; then
705 PKG_CHECK_MODULES(GLW, x11 xt)
706 GLW_LIB_DEPS="$GLW_LIBS"
707 else
708 # should check these...
709 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
710 fi
711
Dan Nicholson88586332007-11-15 08:59:57 -0800712 # If static, empty GLW_LIB_DEPS and add libs for programs to link
713 if test "$enable_static" = no; then
714 GLW_MESA_DEPS='-l$(GL_LIB)'
715 else
716 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
717 GLW_LIB_DEPS=""
718 GLW_MESA_DEPS=""
719 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700720fi
721AC_SUBST(GLW_LIB_DEPS)
722AC_SUBST(GLW_MESA_DEPS)
723
724dnl
725dnl GLUT configuration
726dnl
727if test -f "$srcdir/include/GL/glut.h"; then
728 default_glut=yes
729else
730 default_glut=no
731fi
732AC_ARG_ENABLE(glut,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800733 [AS_HELP_STRING([--disable-glut],
734 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700735 enable_glut="$enableval",
736 enable_glut="$default_glut")
737
738dnl Can't build glut if GLU not available
739if test "x$enable_glu$enable_glut" = xnoyes; then
740 AC_MSG_WARN([Disabling glut since GLU is disabled])
741 enable_glut=no
742fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800743dnl Don't build glut on osmesa
744if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
745 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
746 enable_glut=no
747fi
748
Dan Nicholsondca1b792007-10-23 09:25:58 -0700749if test "x$enable_glut" = xyes; then
750 SRC_DIRS="$SRC_DIRS glut/glx"
751 GLUT_CFLAGS=""
752 if test "x$GCC" = xyes; then
753 GLUT_CFLAGS="-fexceptions"
754 fi
755 if test "$x11_pkgconfig" = yes; then
Dan Nicholson70d0c832007-12-07 11:12:20 -0800756 PKG_CHECK_MODULES(GLUT, x11 xmu xi)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700757 GLUT_LIB_DEPS="$GLUT_LIBS"
758 else
759 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800760 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700761 fi
762 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
763
764 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800765 if test "$with_demos" = yes; then
766 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
767 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700768
Dan Nicholson88586332007-11-15 08:59:57 -0800769 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
770 if test "$enable_static" = no; then
771 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
772 else
773 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
774 GLUT_LIB_DEPS=""
775 GLUT_MESA_DEPS=""
776 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700777fi
778AC_SUBST(GLUT_LIB_DEPS)
779AC_SUBST(GLUT_MESA_DEPS)
780AC_SUBST(GLUT_CFLAGS)
781
782dnl
783dnl Program library dependencies
784dnl Only libm is added here if necessary as the libraries should
785dnl be pulled in by the linker
786dnl
787if test "x$APP_LIB_DEPS" = x; then
788 APP_LIB_DEPS="-lm"
789fi
790AC_SUBST(APP_LIB_DEPS)
791AC_SUBST(PROGRAM_DIRS)
792
793dnl Arch/platform-specific settings
794PIC_FLAGS=""
795ASM_FLAGS=""
796ASM_SOURCES=""
797ASM_API=""
798AC_SUBST(PIC_FLAGS)
799AC_SUBST(ASM_FLAGS)
800AC_SUBST(ASM_SOURCES)
801AC_SUBST(ASM_API)
802case "$host_os" in
803linux*)
804 PIC_FLAGS="-fPIC"
805 case "$host_cpu" in
806 i*86)
Dan Nicholson3e288622007-12-12 09:02:31 -0800807 if test "x$enable_asm" = xyes; then
808 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
809 ASM_SOURCES='$(X86_SOURCES)'
810 ASM_API='$(X86_API)'
811 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700812 ;;
813 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800814 if test "x$enable_asm" = xyes; then
815 ASM_FLAGS="-DUSE_X86_64_ASM"
816 ASM_SOURCES='$(X86-64_SOURCES)'
817 ASM_API='$(X86-64_API)'
818 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700819 ;;
820 powerpc)
Dan Nicholson3e288622007-12-12 09:02:31 -0800821 if test "x$enable_asm" = xyes; then
822 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
823 ASM_SOURCES='$(PPC_SOURCES)'
824 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700825 ;;
826 esac
827 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700828freebsd* | dragonfly*)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700829 PIC_FLAGS="-fPIC"
Dan Nicholson758b9982008-02-21 10:32:04 -0800830 case "$host_cpu" in
Dan Nicholsondca1b792007-10-23 09:25:58 -0700831 i*86)
832 PIC_FLAGS=""
Dan Nicholson3e288622007-12-12 09:02:31 -0800833 if test "x$enable_asm" = xyes; then
834 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
835 ASM_SOURCES='$(X86_SOURCES)'
836 ASM_API='$(X86_API)'
837 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700838 ;;
839 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800840 if test "x$enable_asm" = xyes; then
841 ASM_FLAGS="-DUSE_X86_64_ASM"
842 ASM_SOURCES='$(X86-64_SOURCES)'
843 ASM_API='$(X86-64_API)'
844 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700845 ;;
846 esac
847 ;;
848esac
849
850dnl Restore LDFLAGS and CPPFLAGS
851LDFLAGS="$_SAVE_LDFLAGS"
852CPPFLAGS="$_SAVE_CPPFLAGS"
853
854dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800855AC_CONFIG_FILES([configs/autoconf])
856AC_OUTPUT
Dan Nicholsondca1b792007-10-23 09:25:58 -0700857
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800858dnl Replace the configs/current symlink
859if test -f configs/current || test -L configs/current; then
860 rm -f configs/current
861fi
862ln -s autoconf configs/current
863
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800864dnl
865dnl Output some configuration info for the user
866dnl
867echo ""
868echo " prefix: $prefix"
869echo " exec_prefix: $exec_prefix"
870echo " libdir: $libdir"
871
872dnl Driver info
873echo ""
874echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -0800875if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
876 echo " OSMesa: lib$OSMESA_LIB"
877else
878 echo " OSMesa: no"
879fi
880if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800881 # cleanup the drivers var
882 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
883 echo " DRI drivers: $dri_dirs"
884 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dan Nicholson544ab202007-12-30 08:41:53 -0800885fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800886
887dnl Libraries
888echo ""
889echo " Shared libs: $enable_shared"
890echo " Static libs: $enable_static"
891echo " GLU: $enable_glu"
892echo " GLw: $enable_glw"
893echo " glut: $enable_glut"
894
895dnl Programs
896# cleanup the programs var for display
897program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
898if test "x$program_dirs" = x; then
899 echo " Demos: no"
900else
901 echo " Demos: $program_dirs"
902fi
903
Dan Nicholson16a07fb2007-12-12 09:12:15 -0800904dnl Compiler options
905# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
906cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
907 $SED 's/^ *//;s/ */ /;s/ *$//'`
908cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
909 $SED 's/^ *//;s/ */ /;s/ *$//'`
910defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
911echo ""
912echo " CFLAGS: $cflags"
913echo " CXXFLAGS: $cxxflags"
914echo " Macros: $defines"
915
Dan Nicholsondca1b792007-10-23 09:25:58 -0700916echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -0700917echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700918echo ""