blob: ec1bb8288efc1731f829fc439b28fe57be865de3 [file] [log] [blame]
Dan Nicholsondca1b792007-10-23 09:25:58 -07001dnl Process this file with autoconf to create configure.
2
3AC_PREREQ(2.59)
4
5dnl Versioning
6dnl Make version number available to autoconf and configure
7m4_define(mesa_major, 7)
8m4_define(mesa_minor, 1)
9m4_define(mesa_tiny, 0)
10m4_define(mesa_version, [mesa_major().mesa_minor().mesa_tiny()])
11
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -080012AC_INIT([Mesa],[mesa_version()],
13 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
Dan Nicholsondca1b792007-10-23 09:25:58 -070014AC_CONFIG_AUX_DIR(bin)
15AC_CANONICAL_HOST
16
17dnl Substitute the version number into shell variables
18MESA_MAJOR=mesa_major()
19MESA_MINOR=mesa_minor()
20MESA_TINY=mesa_tiny()
21AC_SUBST(MESA_MAJOR)
22AC_SUBST(MESA_MINOR)
23AC_SUBST(MESA_TINY)
24
25dnl Check for progs
26AC_PROG_CPP
27AC_PROG_CC
28AC_PROG_CXX
29AC_PATH_PROG(MAKE, make)
30AC_PATH_PROG(MKDEP, makedepend)
31AC_PATH_PROG(SED, sed)
Dan Nicholson41b00702007-12-12 08:48:30 -080032
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050033dnl Ask gcc where it's keeping its secret headers
34if test "x$GCC" = xyes; then
35 GCC_PATH=$(gcc -print-search-dirs | sed -ne 's/install: //p')
36 MKDEP_OPTIONS="-fdepend -I${GCC_PATH}include"
37else
38 MKDEP_OPTIONS=-fdepend
39fi
40AC_SUBST(MKDEP_OPTIONS)
41
Dan Nicholson41b00702007-12-12 08:48:30 -080042dnl Make sure the pkg-config macros are defined
43m4_ifdef([PKG_PROG_PKG_CONFIG],,[
44 AC_MSG_ERROR([The pkg-config autoconf macros are not defined.
45 Did you run 'make configure'?])]
46)
Dan Nicholsondca1b792007-10-23 09:25:58 -070047PKG_PROG_PKG_CONFIG()
48
49dnl LIB_DIR - library basename
50LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
51AC_SUBST(LIB_DIR)
52
53dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
54_SAVE_LDFLAGS="$LDFLAGS"
55AC_ARG_VAR(EXTRA_LIB_PATH,[Extra -L paths for the linker])
56AC_SUBST(EXTRA_LIB_PATH)
57
58dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
59_SAVE_CPPFLAGS="$CPPFLAGS"
60AC_ARG_VAR(X11_INCLUDES,[Extra -I paths for X11 headers])
61AC_SUBST(X11_INCLUDES)
62
63dnl Compiler macros
64DEFINES=""
65AC_SUBST(DEFINES)
66if test "x$GCC" = xyes; then
67 DEFINES="-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
68fi
69case "$host_os" in
70linux*)
71 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
72 ;;
73esac
74
75dnl Add flags for gcc and g++
76if test "x$GCC" = xyes; then
77 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -080078
79 # Work around aliasing bugs - developers should comment this out
80 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -070081fi
82if test "x$GXX" = xyes; then
83 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -080084
85 # Work around aliasing bugs - developers should comment this out
86 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -070087fi
88
89dnl These should be unnecessary, but let the user set them if they want
90AC_ARG_VAR(OPT_FLAGS, [Additional optimization flags for the compiler.
91 Default is to use CFLAGS.])
92AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
93 compiler. Default is to use CFLAGS.])
94AC_SUBST(OPT_FLAGS)
95AC_SUBST(ARCH_FLAGS)
96
97dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -060098dnl Hacks to enable 32 or 64 bit build
99dnl
100AC_ARG_ENABLE(32-bit,
101 [AS_HELP_STRING([--enable-32-bit],
102 [build 32-bit libraries @<:@default=auto@:>@])],
103 enable_32bit="$enableval",
104 enable_32bit=auto
105)
106if test "x$enable_32bit" = xyes; then
107 if test "x$GCC" = xyes; then
108 CFLAGS="$CFLAGS -m32"
109 fi
110 if test "x$GXX" = xyes; then
111 CXXFLAGS="$CXXFLAGS -m32"
112 fi
113fi
114AC_ARG_ENABLE(64-bit,
115 [AS_HELP_STRING([--enable-64-bit],
116 [build 64-bit libraries @<:@default=auto@:>@])],
117 enable_64bit="$enableval",
118 enable_64bit=auto
119)
120if test "x$enable_64bit" = xyes; then
121 if test "x$GCC" = xyes; then
122 CFLAGS="$CFLAGS -m64"
123 fi
124 if test "x$GXX" = xyes; then
125 CXXFLAGS="$CXXFLAGS -m64"
126 fi
127fi
128
129dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800130dnl shared/static libraries, mimic libtool options
131dnl
132AC_ARG_ENABLE(static,
133 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800134 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800135 enable_static="$enableval",
136 enable_static=no
137)
138case "x$enable_static" in
139xyes|xno ) ;;
140x ) enable_static=no ;;
141* )
142 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
143 ;;
144esac
145AC_ARG_ENABLE(shared,
146 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800147 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson88586332007-11-15 08:59:57 -0800148 enable_shared="$enableval",
149 enable_shared=yes
150)
151case "x$enable_shared" in
152xyes|xno ) ;;
153x ) enable_shared=yes ;;
154* )
155 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
156 ;;
157esac
158
159dnl Can't have static and shared libraries, default to static if user
160dnl explicitly requested. If both disabled, set to static since shared
161dnl was explicitly requirested.
162case "x$enable_static$enable_shared" in
163xyesyes )
164 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
165 enable_shared=no
166 ;;
167xnono )
168 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
169 enable_static=yes
170 ;;
171esac
172
173dnl
174dnl mklib options
175dnl
176AC_ARG_VAR(MKLIB_OPTIONS,[Options for the Mesa library script, mklib])
177if test "$enable_static" = yes; then
178 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
179fi
180AC_SUBST(MKLIB_OPTIONS)
181
Dan Nicholson23656c42007-12-12 09:02:31 -0800182dnl
183dnl other compiler options
184dnl
185AC_ARG_ENABLE(debug,
186 [AS_HELP_STRING([--enable-debug],
187 [use debug compiler flags and macros @<:@default=disabled@:>@])],
188 enable_debug="$enableval",
189 enable_debug=no
190)
191if test "x$enable_debug" = xyes; then
192 DEFINES="$DEFINES -DDEBUG"
193 if test "x$GCC" = xyes; then
194 CFLAGS="$CFLAGS -g"
195 fi
196 if test "x$GXX" = xyes; then
197 CXXFLAGS="$CXXFLAGS -g"
198 fi
199fi
Dan Nicholson3e288622007-12-12 09:02:31 -0800200dnl These will be used near the end in the arch specific options
201AC_ARG_ENABLE(asm,
202 [AS_HELP_STRING([--disable-asm],
203 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
204 enable_asm="$enableval",
205 enable_asm=yes
206)
Dan Nicholson88586332007-11-15 08:59:57 -0800207
208dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700209dnl library names
210dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800211if test "$enable_static" = yes; then
212 GL_LIB_NAME='lib$(GL_LIB).a'
213 GLU_LIB_NAME='lib$(GLU_LIB).a'
214 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
215 GLW_LIB_NAME='lib$(GLW_LIB).a'
216 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
217else
218 GL_LIB_NAME='lib$(GL_LIB).so'
219 GLU_LIB_NAME='lib$(GLU_LIB).so'
220 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
221 GLW_LIB_NAME='lib$(GLW_LIB).so'
222 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
223fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700224AC_SUBST(GL_LIB_NAME)
225AC_SUBST(GLU_LIB_NAME)
226AC_SUBST(GLUT_LIB_NAME)
227AC_SUBST(GLW_LIB_NAME)
228AC_SUBST(OSMESA_LIB_NAME)
229
230dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800231dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800232dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800233dnl
234AC_ARG_WITH(driver,
235 [AS_HELP_STRING([--with-driver=DRIVER],
Dan Nicholsona1307182007-12-12 17:49:49 -0800236 [driver for Mesa: xlib,dri,osmesa @<:@default=xlib@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800237 mesa_driver="$withval",
Dan Nicholsona1307182007-12-12 17:49:49 -0800238 mesa_driver="xlib")
Dan Nicholson44d99142007-12-05 18:47:01 -0800239dnl Check for valid option
240case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800241xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800242 ;;
243*)
244 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
245 ;;
246esac
247
248dnl
249dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700250dnl
251SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700252GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800253WINDOW_SYSTEM=""
254case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800255xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800256 DRIVER_DIRS="x11"
257 ;;
258dri)
259 SRC_DIRS="glx/x11 $SRC_DIRS"
260 DRIVER_DIRS="dri"
261 WINDOW_SYSTEM="dri"
262 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800263osmesa)
264 DRIVER_DIRS="osmesa"
265 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800266esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700267AC_SUBST(SRC_DIRS)
268AC_SUBST(GLU_DIRS)
269AC_SUBST(DRIVER_DIRS)
Dan Nicholson44d99142007-12-05 18:47:01 -0800270AC_SUBST(WINDOW_SYSTEM)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700271
272dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800273dnl User supplied program configuration
274dnl
275if test -d "$srcdir/progs/demos"; then
276 default_demos=yes
277else
278 default_demos=no
279fi
280AC_ARG_WITH(demos,
281 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
282 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800283 @<:@default=auto if source available@:>@])],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800284 with_demos="$withval",
285 with_demos="$default_demos")
286if test "x$with_demos" = x; then
287 with_demos=no
288fi
289
290dnl If $with_demos is yes, directories will be added as libs available
291PROGRAM_DIRS=""
292case "$with_demos" in
293no|yes) ;;
294*)
295 # verify the requested demos directories exist
296 demos=`IFS=,; echo $with_demos`
297 for demo in $demos; do
298 test -d "$srcdir/progs/$demo" || \
299 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
300 done
301 PROGRAM_DIRS="$demos"
302 ;;
303esac
304
305dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700306dnl Find out if X is available. The variables have_x or no_x will be
307dnl set and used later in the driver setups
308dnl
309if test -n "$PKG_CONFIG"; then
310 AC_MSG_CHECKING([pkg-config files for X11 are available])
311 if $PKG_CONFIG --exists x11; then
312 x11_pkgconfig=yes
313 have_x=yes
314 AC_MSG_RESULT(yes)
315 else
316 x11_pkgconfig=no
317 no_x=yes
318 AC_MSG_RESULT(no)
319 fi
320else
321 x11_pkgconfig=no
322fi
323dnl Use the autoconf macro if no pkg-config files
324if test "$x11_pkgconfig" = no; then
325 AC_PATH_XTRA
326fi
327
Dan Nicholson44d99142007-12-05 18:47:01 -0800328dnl We need X for xlib and dri, so bomb now if it's not found
329case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800330xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800331 if test "$no_x" = yes; then
332 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
333 fi
334 ;;
335esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700336
Adam Jackson66611f22008-02-15 13:49:12 -0500337# SELinux awareness.
338AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux], [Build SELinux-aware Mesa (default: disabled)]), [MESA_SELINUX=$enableval], [MESA_SELINUX=no])
339if test "x$enable_selinux" = "xyes"; then
340 AC_CHECK_HEADER(selinux/selinux.h,,
341 AC_MSG_ERROR([SELinux headers not found]))
342 AC_CHECK_LIB(selinux,is_selinux_enabled,,
343 AC_MSG_ERROR([SELinux library not found]))
344 SELINUX_LIBS="-lselinux"
345 DEFINES="$DEFINES -DMESA_SELINUX"
346fi
347
Dan Nicholson44d99142007-12-05 18:47:01 -0800348dnl
349dnl libGL configuration per driver
350dnl
351case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800352xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800353 if test "$x11_pkgconfig" = yes; then
Dan Nicholsona1307182007-12-12 17:49:49 -0800354 PKG_CHECK_MODULES(XLIBGL, x11 xext)
355 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
356 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800357 else
358 # should check these...
359 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
360 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
361 fi
Adam Jackson66611f22008-02-15 13:49:12 -0500362 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
Dan Nicholson88586332007-11-15 08:59:57 -0800363
364 # if static, move the external libraries to the programs
365 # and empty the libraries for libGL
366 if test "$enable_static" = yes; then
367 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
368 GL_LIB_DEPS=""
369 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800370 ;;
371dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800372 # DRI must be shared, I think
373 if test "$enable_static" = yes; then
374 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
375 fi
376
Dan Nicholson44d99142007-12-05 18:47:01 -0800377 # Check for libdrm
378 PKG_CHECK_MODULES(LIBDRM, libdrm)
379
380 # find the DRI deps for libGL
381 if test "$x11_pkgconfig" = yes; then
382 PKG_CHECK_MODULES(DRIGL, x11 xext xxf86vm xdamage xfixes)
383 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
384 GL_LIB_DEPS="$DRIGL_LIBS"
385 else
386 # should check these...
387 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
388 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
389 fi
390
391 # need DRM libs, -lpthread, etc.
392 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread -ldl"
393 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800394osmesa)
395 # No libGL for osmesa
396 GL_LIB_DEPS=""
397 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800398esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700399AC_SUBST(GL_LIB_DEPS)
400
401dnl
402dnl More X11 setup
403dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800404if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700405 DEFINES="$DEFINES -DUSE_XSHM"
406fi
407
408dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800409dnl More DRI setup
410dnl
411AC_ARG_ENABLE(glx-tls,
412 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800413 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800414 GLX_USE_TLS="$enableval",
415 GLX_USE_TLS=no)
416dnl Directory for DRI drivers
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800417AC_ARG_WITH(dri-driverdir,
418 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson44d99142007-12-05 18:47:01 -0800419 [directory for the DRI drivers @<:@/usr/X11R6/lib/modules/dri@:>@])],
420 DRI_DRIVER_INSTALL_DIR="$withval",
421 DRI_DRIVER_INSTALL_DIR='/usr/X11R6/lib/modules/dri')
422AC_SUBST(DRI_DRIVER_INSTALL_DIR)
423dnl Direct rendering or just indirect rendering
424AC_ARG_ENABLE(driglx-direct,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800425 [AS_HELP_STRING([--disable-driglx-direct],
426 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson44d99142007-12-05 18:47:01 -0800427 driglx_direct="$enableval",
428 driglx_direct="yes")
429
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800430dnl Which drivers to build - default is chosen by platform
431AC_ARG_WITH(dri-drivers,
432 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800433 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800434 with_dri_drivers="$withval",
435 with_dri_drivers=yes)
436if test "x$with_dri_drivers" = x; then
437 with_dri_drivers=no
438fi
439
440dnl If $with_dri_drivers is yes, directories will be added through
441dnl platform checks
442DRI_DIRS=""
443case "$with_dri_drivers" in
444no|yes) ;;
445*)
446 # verify the requested driver directories exist
447 dri_drivers=`IFS=,; echo $with_dri_drivers`
448 for driver in $dri_drivers; do
449 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
450 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
451 done
452 DRI_DIRS="$dri_drivers"
453 ;;
454esac
455
Dan Nicholson44d99142007-12-05 18:47:01 -0800456dnl Just default to no EGL for now
457USING_EGL=0
458AC_SUBST(USING_EGL)
459
460dnl Set DRI_DIRS, DEFINES and LIB_DEPS
461if test "$mesa_driver" = dri; then
462 # Use TLS in GLX?
463 if test "x$GLX_USE_TLS" = xyes; then
464 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
465 fi
466
467 if test "x$USING_EGL" = x1; then
468 PROGRAM_DIRS="egl"
469 fi
470
471 # Platform specific settings and drivers to build
472 case "$host_os" in
473 linux*)
474 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
475 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
476 if test "x$driglx_direct" = xyes; then
477 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
478 fi
479
480 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800481 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800482 # ffb, gamma, and sis are missing because they have not be
483 # converted to use the new interface. i810 are missing
484 # because there is no x86-64 system where they could *ever*
485 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800486 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800487 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
488 savage tdfx unichrome"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800489 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800490 ;;
491 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800492 # Build only the drivers for cards that exist on PowerPC.
493 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800494 if test "x$DRI_DIRS" = x; then
495 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx"
496 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800497 ;;
498 esac
499 ;;
500 freebsd*)
501 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
502 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
503 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
504 if test "x$driglx_direct" = xyes; then
505 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
506 fi
507 if test "x$GXX" = xyes; then
508 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
509 fi
510
Dan Nicholsona76e2452007-12-07 11:25:08 -0800511 # ffb and gamma are missing because they have not been converted
512 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800513 if test "x$DRI_DIRS" = x; then
514 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
515 unichrome savage sis"
516 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800517 ;;
518 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800519
520 # default drivers
521 if test "x$DRI_DIRS" = x; then
522 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
523 savage sis tdfx trident unichrome ffb"
524 fi
525
Dan Nicholson44d99142007-12-05 18:47:01 -0800526 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
527
528 # Check for expat
529 EXPAT_INCLUDES=""
530 EXPAT_LIB=-lexpat
531 AC_ARG_WITH(expat, AS_HELP_STRING([--with-expat=DIR],
532 [expat install directory]),[
533 EXPAT_INCLUDES="-I$withval/include"
534 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
535 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
536 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
537 ])
538 AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR([Expat required for DRI.]))
539 AC_CHECK_LIB(expat, XML_ParserCreate,,
540 AC_MSG_ERROR([Expat required for DRI.]))
541
542 # put all the necessary libs together
Adam Jackson66611f22008-02-15 13:49:12 -0500543 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread -ldl"
Dan Nicholson44d99142007-12-05 18:47:01 -0800544fi
545AC_SUBST(DRI_DIRS)
546AC_SUBST(EXPAT_INCLUDES)
547AC_SUBST(DRI_LIB_DEPS)
548
549dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700550dnl OSMesa configuration
551dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800552if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800553 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800554else
Dan Nicholson544ab202007-12-30 08:41:53 -0800555 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800556fi
Dan Nicholson544ab202007-12-30 08:41:53 -0800557AC_ARG_ENABLE(gl-osmesa,
558 [AS_HELP_STRING([--enable-gl-osmesa],
559 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
560 gl_osmesa="$enableval",
561 gl_osmesa="$default_gl_osmesa")
562if test "x$gl_osmesa" = xyes; then
563 if test "$mesa_driver" = osmesa; then
564 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800565 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800566 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800567 fi
568fi
569
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800570dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
571AC_ARG_WITH(osmesa-bits,
572 [AS_HELP_STRING([--with-osmesa-bits=BITS],
573 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
574 osmesa_bits="$withval",
575 osmesa_bits=8)
576if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
577 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
578 osmesa_bits=8
579fi
580case "x$osmesa_bits" in
581x8)
582 OSMESA_LIB=OSMesa
583 ;;
584x16|x32)
585 OSMESA_LIB="OSMesa$osmesa_bits"
586 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
587 ;;
588*)
589 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
590 ;;
591esac
592AC_SUBST(OSMESA_LIB)
593
Dan Nicholson979ff512007-12-05 18:47:01 -0800594case "$mesa_driver" in
595osmesa)
Dan Nicholson88586332007-11-15 08:59:57 -0800596 # only link librararies with osmesa if shared
597 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500598 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800599 else
600 OSMESA_LIB_DEPS=""
601 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800602 OSMESA_MESA_DEPS=""
603 ;;
604*)
605 # Link OSMesa to libGL otherwise
606 OSMESA_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800607 # only link librararies with osmesa if shared
608 if test "$enable_static" = no; then
609 OSMESA_MESA_DEPS='-l$(GL_LIB)'
610 else
611 OSMESA_MESA_DEPS=""
612 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800613 ;;
614esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700615AC_SUBST(OSMESA_LIB_DEPS)
616AC_SUBST(OSMESA_MESA_DEPS)
617
618dnl
619dnl GLU configuration
620dnl
621AC_ARG_ENABLE(glu,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800622 [AS_HELP_STRING([--disable-glu],
623 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700624 enable_glu="$enableval",
625 enable_glu=yes)
626if test "x$enable_glu" = xyes; then
627 SRC_DIRS="$SRC_DIRS glu"
628
Dan Nicholson979ff512007-12-05 18:47:01 -0800629 case "$mesa_driver" in
630 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800631 # If GLU is available and we have libOSMesa (not 16 or 32),
632 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800633 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800634 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
635 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700636
Dan Nicholson979ff512007-12-05 18:47:01 -0800637 # Link libGLU to libOSMesa instead of libGL
638 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800639 if test "$enable_static" = no; then
640 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
641 else
642 GLU_MESA_DEPS=""
643 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800644 ;;
645 *)
646 # If GLU is available, we can build the xdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800647 if test "$with_demos" = yes; then
648 PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
649 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800650
Dan Nicholson88586332007-11-15 08:59:57 -0800651 # If static, empty GLU_LIB_DEPS and add libs for programs to link
652 if test "$enable_static" = no; then
653 GLU_LIB_DEPS="-lm"
654 GLU_MESA_DEPS='-l$(GL_LIB)'
655 else
656 GLU_LIB_DEPS=""
657 GLU_MESA_DEPS=""
658 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
659 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800660 ;;
661 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700662fi
663AC_SUBST(GLU_LIB_DEPS)
664AC_SUBST(GLU_MESA_DEPS)
665
666dnl
667dnl GLw configuration
668dnl
669AC_ARG_ENABLE(glw,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800670 [AS_HELP_STRING([--disable-glw],
671 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700672 enable_glw="$enableval",
673 enable_glw=yes)
Dan Nicholson979ff512007-12-05 18:47:01 -0800674dnl Don't build GLw on osmesa
675if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
676 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
677 enable_glw=no
678fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700679if test "x$enable_glw" = xyes; then
680 SRC_DIRS="$SRC_DIRS glw"
681 if test "$x11_pkgconfig" = yes; then
682 PKG_CHECK_MODULES(GLW, x11 xt)
683 GLW_LIB_DEPS="$GLW_LIBS"
684 else
685 # should check these...
686 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
687 fi
688
Dan Nicholson88586332007-11-15 08:59:57 -0800689 # If static, empty GLW_LIB_DEPS and add libs for programs to link
690 if test "$enable_static" = no; then
691 GLW_MESA_DEPS='-l$(GL_LIB)'
692 else
693 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
694 GLW_LIB_DEPS=""
695 GLW_MESA_DEPS=""
696 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700697fi
698AC_SUBST(GLW_LIB_DEPS)
699AC_SUBST(GLW_MESA_DEPS)
700
701dnl
702dnl GLUT configuration
703dnl
704if test -f "$srcdir/include/GL/glut.h"; then
705 default_glut=yes
706else
707 default_glut=no
708fi
709AC_ARG_ENABLE(glut,
Dan Nicholson79ad4582007-12-07 19:11:01 -0800710 [AS_HELP_STRING([--disable-glut],
711 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholsondca1b792007-10-23 09:25:58 -0700712 enable_glut="$enableval",
713 enable_glut="$default_glut")
714
715dnl Can't build glut if GLU not available
716if test "x$enable_glu$enable_glut" = xnoyes; then
717 AC_MSG_WARN([Disabling glut since GLU is disabled])
718 enable_glut=no
719fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800720dnl Don't build glut on osmesa
721if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
722 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
723 enable_glut=no
724fi
725
Dan Nicholsondca1b792007-10-23 09:25:58 -0700726if test "x$enable_glut" = xyes; then
727 SRC_DIRS="$SRC_DIRS glut/glx"
728 GLUT_CFLAGS=""
729 if test "x$GCC" = xyes; then
730 GLUT_CFLAGS="-fexceptions"
731 fi
732 if test "$x11_pkgconfig" = yes; then
Dan Nicholson70d0c832007-12-07 11:12:20 -0800733 PKG_CHECK_MODULES(GLUT, x11 xmu xi)
Dan Nicholsondca1b792007-10-23 09:25:58 -0700734 GLUT_LIB_DEPS="$GLUT_LIBS"
735 else
736 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800737 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700738 fi
739 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
740
741 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800742 if test "$with_demos" = yes; then
743 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
744 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700745
Dan Nicholson88586332007-11-15 08:59:57 -0800746 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
747 if test "$enable_static" = no; then
748 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
749 else
750 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
751 GLUT_LIB_DEPS=""
752 GLUT_MESA_DEPS=""
753 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700754fi
755AC_SUBST(GLUT_LIB_DEPS)
756AC_SUBST(GLUT_MESA_DEPS)
757AC_SUBST(GLUT_CFLAGS)
758
759dnl
760dnl Program library dependencies
761dnl Only libm is added here if necessary as the libraries should
762dnl be pulled in by the linker
763dnl
764if test "x$APP_LIB_DEPS" = x; then
765 APP_LIB_DEPS="-lm"
766fi
767AC_SUBST(APP_LIB_DEPS)
768AC_SUBST(PROGRAM_DIRS)
769
770dnl Arch/platform-specific settings
771PIC_FLAGS=""
772ASM_FLAGS=""
773ASM_SOURCES=""
774ASM_API=""
775AC_SUBST(PIC_FLAGS)
776AC_SUBST(ASM_FLAGS)
777AC_SUBST(ASM_SOURCES)
778AC_SUBST(ASM_API)
779case "$host_os" in
780linux*)
781 PIC_FLAGS="-fPIC"
782 case "$host_cpu" in
783 i*86)
Dan Nicholson3e288622007-12-12 09:02:31 -0800784 if test "x$enable_asm" = xyes; then
785 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
786 ASM_SOURCES='$(X86_SOURCES)'
787 ASM_API='$(X86_API)'
788 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700789 ;;
790 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800791 if test "x$enable_asm" = xyes; then
792 ASM_FLAGS="-DUSE_X86_64_ASM"
793 ASM_SOURCES='$(X86-64_SOURCES)'
794 ASM_API='$(X86-64_API)'
795 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700796 ;;
797 powerpc)
Dan Nicholson3e288622007-12-12 09:02:31 -0800798 if test "x$enable_asm" = xyes; then
799 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
800 ASM_SOURCES='$(PPC_SOURCES)'
801 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700802 ;;
803 esac
804 ;;
805freebsd*)
806 PIC_FLAGS="-fPIC"
Dan Nicholson758b9982008-02-21 10:32:04 -0800807 case "$host_cpu" in
Dan Nicholsondca1b792007-10-23 09:25:58 -0700808 i*86)
809 PIC_FLAGS=""
Dan Nicholson3e288622007-12-12 09:02:31 -0800810 if test "x$enable_asm" = xyes; then
811 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
812 ASM_SOURCES='$(X86_SOURCES)'
813 ASM_API='$(X86_API)'
814 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700815 ;;
816 x86_64)
Dan Nicholson3e288622007-12-12 09:02:31 -0800817 if test "x$enable_asm" = xyes; then
818 ASM_FLAGS="-DUSE_X86_64_ASM"
819 ASM_SOURCES='$(X86-64_SOURCES)'
820 ASM_API='$(X86-64_API)'
821 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700822 ;;
823 esac
824 ;;
825esac
826
827dnl Restore LDFLAGS and CPPFLAGS
828LDFLAGS="$_SAVE_LDFLAGS"
829CPPFLAGS="$_SAVE_CPPFLAGS"
830
831dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800832AC_CONFIG_FILES([configs/autoconf])
833AC_OUTPUT
Dan Nicholsondca1b792007-10-23 09:25:58 -0700834
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800835dnl Replace the configs/current symlink
836if test -f configs/current || test -L configs/current; then
837 rm -f configs/current
838fi
839ln -s autoconf configs/current
840
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800841dnl
842dnl Output some configuration info for the user
843dnl
844echo ""
845echo " prefix: $prefix"
846echo " exec_prefix: $exec_prefix"
847echo " libdir: $libdir"
848
849dnl Driver info
850echo ""
851echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -0800852if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
853 echo " OSMesa: lib$OSMESA_LIB"
854else
855 echo " OSMesa: no"
856fi
857if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800858 # cleanup the drivers var
859 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
860 echo " DRI drivers: $dri_dirs"
861 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dan Nicholson544ab202007-12-30 08:41:53 -0800862fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800863
864dnl Libraries
865echo ""
866echo " Shared libs: $enable_shared"
867echo " Static libs: $enable_static"
868echo " GLU: $enable_glu"
869echo " GLw: $enable_glw"
870echo " glut: $enable_glut"
871
872dnl Programs
873# cleanup the programs var for display
874program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
875if test "x$program_dirs" = x; then
876 echo " Demos: no"
877else
878 echo " Demos: $program_dirs"
879fi
880
Dan Nicholson16a07fb2007-12-12 09:12:15 -0800881dnl Compiler options
882# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
883cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
884 $SED 's/^ *//;s/ */ /;s/ *$//'`
885cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
886 $SED 's/^ *//;s/ */ /;s/ *$//'`
887defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
888echo ""
889echo " CFLAGS: $cflags"
890echo " CXXFLAGS: $cxxflags"
891echo " Macros: $defines"
892
Dan Nicholsondca1b792007-10-23 09:25:58 -0700893echo ""
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800894echo " Run 'make' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700895echo ""