blob: acb29e446863eb328f53d36d9cbc36bc3940cc91 [file] [log] [blame]
Dan Nicholsondca1b792007-10-23 09:25:58 -07001dnl Process this file with autoconf to create configure.
2
Dan Nicholson297e16c2008-05-05 15:42:53 -07003AC_PREREQ([2.59])
Dan Nicholsondca1b792007-10-23 09:25:58 -07004
Dan Nicholson00994ac2008-04-30 15:06:00 -07005dnl Versioning - scrape the version from configs/default
6m4_define([mesa_version],
7 [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])])
8m4_ifval(mesa_version,[],[
9 m4_errprint([Error: Failed to get the Mesa version from the output of
10 running `make -f bin/version.mk version'
11])
12 m4_exit([1])
13])
Dan Nicholsondca1b792007-10-23 09:25:58 -070014
Dan Nicholsone97ab722008-07-01 08:55:42 -070015dnl Tell the user about autoconf.html in the --help output
16m4_divert_once([HELP_END], [
17See docs/autoconf.html for more details on the options for Mesa.])
18
Dan Nicholson00994ac2008-04-30 15:06:00 -070019AC_INIT([Mesa],[mesa_version],
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -080020 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
Dan Nicholson297e16c2008-05-05 15:42:53 -070021AC_CONFIG_AUX_DIR([bin])
Dan Nicholsondca1b792007-10-23 09:25:58 -070022AC_CANONICAL_HOST
23
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -070024dnl Versions for external dependencies
25LIBDRM_REQUIRED=2.3.1
26DRI2PROTO_REQUIRED=1.1
27
Dan Nicholsondca1b792007-10-23 09:25:58 -070028dnl Check for progs
29AC_PROG_CPP
30AC_PROG_CC
31AC_PROG_CXX
Dan Nicholson297e16c2008-05-05 15:42:53 -070032AC_CHECK_PROGS([MAKE], [gmake make])
33AC_PATH_PROG([MKDEP], [makedepend])
34AC_PATH_PROG([SED], [sed])
Dan Nicholson41b00702007-12-12 08:48:30 -080035
Dan Nicholsonbfb27b52008-06-30 09:40:30 -070036dnl We need a POSIX shell for parts of the build. Assume we have one
37dnl in most cases.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070038case "$host_os" in
39solaris*)
40 # Solaris /bin/sh is too old/non-POSIX compliant
41 AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
Dan Nicholsonbfb27b52008-06-30 09:40:30 -070042 SHELL="$POSIX_SHELL"
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070043 ;;
44esac
45
Dan Nicholsondb7fc632008-03-07 11:48:09 -080046MKDEP_OPTIONS=-fdepend
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050047dnl Ask gcc where it's keeping its secret headers
48if test "x$GCC" = xyes; then
Dan Nicholsondb7fc632008-03-07 11:48:09 -080049 GCC_INCLUDES=`$CC -print-file-name=include`
50 if test "x$GCC_INCLUDES" != x; then
51 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
52 fi
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050053fi
Dan Nicholson297e16c2008-05-05 15:42:53 -070054AC_SUBST([MKDEP_OPTIONS])
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050055
Dan Nicholson41b00702007-12-12 08:48:30 -080056dnl Make sure the pkg-config macros are defined
Dan Nicholson297e16c2008-05-05 15:42:53 -070057m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
Dan Nicholson7154d662008-04-30 13:53:37 -070058 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
59 These are usually located in /usr/share/aclocal/pkg.m4. If your
60 macros are in a different location, try setting the environment
61 variable ACLOCAL="aclocal -I/other/macro/dir" before running
62 autoreconf.
63])
64 m4_exit([1])
65])
Dan Nicholsondca1b792007-10-23 09:25:58 -070066PKG_PROG_PKG_CONFIG()
67
68dnl LIB_DIR - library basename
69LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
Dan Nicholson297e16c2008-05-05 15:42:53 -070070AC_SUBST([LIB_DIR])
Dan Nicholsondca1b792007-10-23 09:25:58 -070071
72dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
73_SAVE_LDFLAGS="$LDFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070074AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
75AC_SUBST([EXTRA_LIB_PATH])
Dan Nicholsondca1b792007-10-23 09:25:58 -070076
77dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
78_SAVE_CPPFLAGS="$CPPFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070079AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
80AC_SUBST([X11_INCLUDES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070081
82dnl Compiler macros
83DEFINES=""
Dan Nicholson297e16c2008-05-05 15:42:53 -070084AC_SUBST([DEFINES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070085case "$host_os" in
86linux*)
Eric Anholt5ad06152008-03-20 17:14:20 -070087if test "x$GCC" = xyes; then
88 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
89fi
Dan Nicholson985e1cd2008-06-04 13:17:06 -070090 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS"
Dan Nicholsondca1b792007-10-23 09:25:58 -070091 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070092solaris*)
93 DEFINES="$DEFINES -DPTHREADS -DSVR4"
94 ;;
Dan Nicholsondca1b792007-10-23 09:25:58 -070095esac
96
97dnl Add flags for gcc and g++
98if test "x$GCC" = xyes; then
99 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800100
101 # Work around aliasing bugs - developers should comment this out
102 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700103fi
104if test "x$GXX" = xyes; then
105 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800106
107 # Work around aliasing bugs - developers should comment this out
108 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700109fi
110
111dnl These should be unnecessary, but let the user set them if they want
Dan Nicholson297e16c2008-05-05 15:42:53 -0700112AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700113 Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700114AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
Dan Nicholsondca1b792007-10-23 09:25:58 -0700115 compiler. Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700116AC_SUBST([OPT_FLAGS])
117AC_SUBST([ARCH_FLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700118
119dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600120dnl Hacks to enable 32 or 64 bit build
121dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700122AC_ARG_ENABLE([32-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600123 [AS_HELP_STRING([--enable-32-bit],
124 [build 32-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700125 [enable_32bit="$enableval"],
126 [enable_32bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600127)
128if test "x$enable_32bit" = xyes; then
129 if test "x$GCC" = xyes; then
130 CFLAGS="$CFLAGS -m32"
131 fi
132 if test "x$GXX" = xyes; then
133 CXXFLAGS="$CXXFLAGS -m32"
134 fi
135fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700136AC_ARG_ENABLE([64-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600137 [AS_HELP_STRING([--enable-64-bit],
138 [build 64-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700139 [enable_64bit="$enableval"],
140 [enable_64bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600141)
142if test "x$enable_64bit" = xyes; then
143 if test "x$GCC" = xyes; then
144 CFLAGS="$CFLAGS -m64"
145 fi
146 if test "x$GXX" = xyes; then
147 CXXFLAGS="$CXXFLAGS -m64"
148 fi
149fi
150
151dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800152dnl shared/static libraries, mimic libtool options
153dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700154AC_ARG_ENABLE([static],
Dan Nicholson88586332007-11-15 08:59:57 -0800155 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800156 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700157 [enable_static="$enableval"],
158 [enable_static=no]
Dan Nicholson88586332007-11-15 08:59:57 -0800159)
160case "x$enable_static" in
161xyes|xno ) ;;
162x ) enable_static=no ;;
163* )
164 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
165 ;;
166esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700167AC_ARG_ENABLE([shared],
Dan Nicholson88586332007-11-15 08:59:57 -0800168 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800169 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700170 [enable_shared="$enableval"],
171 [enable_shared=yes]
Dan Nicholson88586332007-11-15 08:59:57 -0800172)
173case "x$enable_shared" in
174xyes|xno ) ;;
175x ) enable_shared=yes ;;
176* )
177 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
178 ;;
179esac
180
181dnl Can't have static and shared libraries, default to static if user
182dnl explicitly requested. If both disabled, set to static since shared
183dnl was explicitly requirested.
184case "x$enable_static$enable_shared" in
185xyesyes )
186 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
187 enable_shared=no
188 ;;
189xnono )
190 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
191 enable_static=yes
192 ;;
193esac
194
195dnl
196dnl mklib options
197dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700198AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
Dan Nicholson88586332007-11-15 08:59:57 -0800199if test "$enable_static" = yes; then
200 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
201fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700202AC_SUBST([MKLIB_OPTIONS])
Dan Nicholson88586332007-11-15 08:59:57 -0800203
Dan Nicholson23656c42007-12-12 09:02:31 -0800204dnl
205dnl other compiler options
206dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700207AC_ARG_ENABLE([debug],
Dan Nicholson23656c42007-12-12 09:02:31 -0800208 [AS_HELP_STRING([--enable-debug],
209 [use debug compiler flags and macros @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700210 [enable_debug="$enableval"],
211 [enable_debug=no]
Dan Nicholson23656c42007-12-12 09:02:31 -0800212)
213if test "x$enable_debug" = xyes; then
214 DEFINES="$DEFINES -DDEBUG"
215 if test "x$GCC" = xyes; then
216 CFLAGS="$CFLAGS -g"
217 fi
218 if test "x$GXX" = xyes; then
219 CXXFLAGS="$CXXFLAGS -g"
220 fi
221fi
Dan Nicholson88586332007-11-15 08:59:57 -0800222
223dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700224dnl library names
225dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800226if test "$enable_static" = yes; then
227 GL_LIB_NAME='lib$(GL_LIB).a'
228 GLU_LIB_NAME='lib$(GLU_LIB).a'
229 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
230 GLW_LIB_NAME='lib$(GLW_LIB).a'
231 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
232else
233 GL_LIB_NAME='lib$(GL_LIB).so'
234 GLU_LIB_NAME='lib$(GLU_LIB).so'
235 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
236 GLW_LIB_NAME='lib$(GLW_LIB).so'
237 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
238fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700239AC_SUBST([GL_LIB_NAME])
240AC_SUBST([GLU_LIB_NAME])
241AC_SUBST([GLUT_LIB_NAME])
242AC_SUBST([GLW_LIB_NAME])
243AC_SUBST([OSMESA_LIB_NAME])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700244
245dnl
Dan Nicholson871125a2008-06-04 13:00:35 -0700246dnl Arch/platform-specific settings
247dnl
248AC_ARG_ENABLE([asm],
249 [AS_HELP_STRING([--disable-asm],
250 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
251 [enable_asm="$enableval"],
252 [enable_asm=yes]
253)
254asm_arch=""
255ASM_FLAGS=""
256ASM_SOURCES=""
257ASM_API=""
258AC_MSG_CHECKING([whether to enable assembly])
259test "x$enable_asm" = xno && AC_MSG_RESULT([no])
260# disable if cross compiling on x86/x86_64 since we must run gen_matypes
261if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
262 case "$host_cpu" in
263 i?86 | x86_64)
264 enable_asm=no
265 AC_MSG_RESULT([no, cross compiling])
266 ;;
267 esac
268fi
269# check for supported arches
270if test "x$enable_asm" = xyes; then
271 case "$host_cpu" in
272 i?86)
273 case "$host_os" in
274 linux* | freebsd* | dragonfly*)
275 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
276 ;;
277 esac
278 ;;
279 x86_64)
280 case "$host_os" in
281 linux* | freebsd* | dragonfly*)
282 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
283 ;;
284 esac
285 ;;
286 powerpc)
287 case "$host_os" in
288 linux*)
289 asm_arch=ppc
290 ;;
291 esac
292 ;;
293 esac
294
295 case "$asm_arch" in
296 x86)
297 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
298 ASM_SOURCES='$(X86_SOURCES)'
299 ASM_API='$(X86_API)'
300 AC_MSG_RESULT([yes, x86])
301 ;;
302 x86_64)
303 ASM_FLAGS="-DUSE_X86_64_ASM"
304 ASM_SOURCES='$(X86-64_SOURCES)'
305 ASM_API='$(X86-64_API)'
306 AC_MSG_RESULT([yes, x86_64])
307 ;;
308 ppc)
309 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
310 ASM_SOURCES='$(PPC_SOURCES)'
311 AC_MSG_RESULT([yes, ppc])
312 ;;
313 *)
314 AC_MSG_RESULT([no, platform not supported])
315 ;;
316 esac
317fi
318AC_SUBST([ASM_FLAGS])
319AC_SUBST([ASM_SOURCES])
320AC_SUBST([ASM_API])
321
322dnl PIC code macro
323MESA_PIC_FLAGS
324
325dnl Check to see if dlopen is in default libraries (like Solaris, which
326dnl has it in libc), or if libdl is needed to get it.
327AC_CHECK_FUNC([dlopen], [],
328 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
329
Dan Nicholson985e1cd2008-06-04 13:17:06 -0700330dnl See if posix_memalign is available
331AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
332
Dan Nicholson871125a2008-06-04 13:00:35 -0700333dnl SELinux awareness.
334AC_ARG_ENABLE([selinux],
335 [AS_HELP_STRING([--enable-selinux],
336 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
337 [MESA_SELINUX="$enableval"],
338 [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
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700348dnl OS-specific libraries
349OS_LIBS=""
350case "$host_os" in
351solaris*)
352 OS_LIBS="-lc"
353 if test "x$GXX" != xyes; then
354 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
355 fi
356 ;;
357esac
Dan Nicholson871125a2008-06-04 13:00:35 -0700358
359dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800360dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800361dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800362dnl
Eric Anholt711222b2008-04-18 15:03:01 -0700363default_driver="xlib"
364
365case "$host_os" in
366linux*)
367 case "$host_cpu" in
368 i*86|x86_64|powerpc*) default_driver="dri";;
369 esac
370 ;;
371freebsd* | dragonfly*)
372 case "$host_cpu" in
373 i*86|x86_64) default_driver="dri";;
374 esac
375 ;;
376esac
377
Dan Nicholson297e16c2008-05-05 15:42:53 -0700378AC_ARG_WITH([driver],
Dan Nicholson44d99142007-12-05 18:47:01 -0800379 [AS_HELP_STRING([--with-driver=DRIVER],
Eric Anholt711222b2008-04-18 15:03:01 -0700380 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700381 [mesa_driver="$withval"],
382 [mesa_driver="$default_driver"])
Dan Nicholson44d99142007-12-05 18:47:01 -0800383dnl Check for valid option
384case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800385xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800386 ;;
387*)
388 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
389 ;;
390esac
391
392dnl
393dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700394dnl
395SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700396GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800397WINDOW_SYSTEM=""
398case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800399xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800400 DRIVER_DIRS="x11"
401 ;;
402dri)
403 SRC_DIRS="glx/x11 $SRC_DIRS"
404 DRIVER_DIRS="dri"
405 WINDOW_SYSTEM="dri"
406 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800407osmesa)
408 DRIVER_DIRS="osmesa"
409 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800410esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700411AC_SUBST([SRC_DIRS])
412AC_SUBST([GLU_DIRS])
413AC_SUBST([DRIVER_DIRS])
414AC_SUBST([WINDOW_SYSTEM])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700415
416dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800417dnl User supplied program configuration
418dnl
419if test -d "$srcdir/progs/demos"; then
420 default_demos=yes
421else
422 default_demos=no
423fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700424AC_ARG_WITH([demos],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800425 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
426 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800427 @<:@default=auto if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700428 [with_demos="$withval"],
429 [with_demos="$default_demos"])
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800430if test "x$with_demos" = x; then
431 with_demos=no
432fi
433
434dnl If $with_demos is yes, directories will be added as libs available
435PROGRAM_DIRS=""
436case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700437no) ;;
438yes)
439 # If the driver isn't osmesa, we have libGL and can build xdemos
440 if test "$mesa_driver" != osmesa; then
441 PROGRAM_DIRS="xdemos"
442 fi
443 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800444*)
445 # verify the requested demos directories exist
446 demos=`IFS=,; echo $with_demos`
447 for demo in $demos; do
448 test -d "$srcdir/progs/$demo" || \
449 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
450 done
451 PROGRAM_DIRS="$demos"
452 ;;
453esac
454
455dnl
Dan Nicholsone6a06092008-05-05 15:16:22 -0700456dnl Find out if X is available. The variable have_x is set if libX11 is
Dan Nicholson99803a42008-07-01 09:03:15 -0700457dnl found to mimic AC_PATH_XTRA.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700458dnl
459if test -n "$PKG_CONFIG"; then
460 AC_MSG_CHECKING([pkg-config files for X11 are available])
Dan Nicholsone6a06092008-05-05 15:16:22 -0700461 PKG_CHECK_EXISTS([x11],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700462 x11_pkgconfig=yes
463 have_x=yes
Dan Nicholsone6a06092008-05-05 15:16:22 -0700464 ],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700465 x11_pkgconfig=no
Dan Nicholsone6a06092008-05-05 15:16:22 -0700466 ])
467 AC_MSG_RESULT([$x11_pkgconfig])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700468else
469 x11_pkgconfig=no
470fi
471dnl Use the autoconf macro if no pkg-config files
472if test "$x11_pkgconfig" = no; then
473 AC_PATH_XTRA
474fi
475
Dan Nicholson99803a42008-07-01 09:03:15 -0700476dnl Try to tell the user that the --x-* options are only used when
477dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
478m4_divert_once([HELP_BEGIN],
479[These options are only used when the X libraries cannot be found by the
480pkg-config utility.])
481
Dan Nicholson44d99142007-12-05 18:47:01 -0800482dnl We need X for xlib and dri, so bomb now if it's not found
483case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800484xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800485 if test "$no_x" = yes; then
486 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
487 fi
488 ;;
489esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700490
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700491dnl XCB - this is only used for GLX right now
492AC_ARG_ENABLE([xcb],
493 [AS_HELP_STRING([--enable-xcb],
494 [use XCB for GLX @<:@default=disabled@:>@])],
495 [enable_xcb="$enableval"],
496 [enable_xcb=no])
497if test "x$enable_xcb" = xyes; then
498 DEFINES="$DEFINES -DUSE_XCB"
499else
500 enable_xcb=no
501fi
502
Dan Nicholson44d99142007-12-05 18:47:01 -0800503dnl
504dnl libGL configuration per driver
505dnl
506case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800507xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800508 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700509 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
Dan Nicholsona1307182007-12-12 17:49:49 -0800510 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
511 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800512 else
513 # should check these...
514 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
515 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
516 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700517 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800518
519 # if static, move the external libraries to the programs
520 # and empty the libraries for libGL
521 if test "$enable_static" = yes; then
522 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
523 GL_LIB_DEPS=""
524 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800525 ;;
526dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800527 # DRI must be shared, I think
528 if test "$enable_static" = yes; then
529 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
530 fi
531
Dan Nicholson44d99142007-12-05 18:47:01 -0800532 # Check for libdrm
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -0700533 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
534 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
Dan Nicholson44d99142007-12-05 18:47:01 -0800535
536 # find the DRI deps for libGL
537 if test "$x11_pkgconfig" = yes; then
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700538 # add xcb modules if necessary
539 dri_modules="x11 xext xxf86vm xdamage xfixes"
540 if test "$enable_xcb" = yes; then
541 dri_modules="$dri_modules x11-xcb xcb-glx"
542 fi
543
544 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
Dan Nicholson44d99142007-12-05 18:47:01 -0800545 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
546 GL_LIB_DEPS="$DRIGL_LIBS"
547 else
548 # should check these...
549 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
550 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700551
552 # XCB can only be used from pkg-config
553 if test "$enable_xcb" = yes; then
554 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
555 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
556 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
557 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800558 fi
559
560 # need DRM libs, -lpthread, etc.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700561 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800562 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800563osmesa)
564 # No libGL for osmesa
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700565 GL_LIB_DEPS="$OS_LIBS"
Dan Nicholson979ff512007-12-05 18:47:01 -0800566 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800567esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700568AC_SUBST([GL_LIB_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700569
570dnl
571dnl More X11 setup
572dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800573if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700574 DEFINES="$DEFINES -DUSE_XSHM"
575fi
576
577dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800578dnl More DRI setup
579dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700580AC_ARG_ENABLE([glx-tls],
Dan Nicholson44d99142007-12-05 18:47:01 -0800581 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800582 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700583 [GLX_USE_TLS="$enableval"],
584 [GLX_USE_TLS=no])
Dan Nicholson44d99142007-12-05 18:47:01 -0800585dnl Directory for DRI drivers
Dan Nicholson297e16c2008-05-05 15:42:53 -0700586AC_ARG_WITH([dri-driverdir],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800587 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700588 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700589 [DRI_DRIVER_INSTALL_DIR="$withval"],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700590 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700591AC_SUBST([DRI_DRIVER_INSTALL_DIR])
Dan Nicholson44d99142007-12-05 18:47:01 -0800592dnl Direct rendering or just indirect rendering
Dan Nicholson297e16c2008-05-05 15:42:53 -0700593AC_ARG_ENABLE([driglx-direct],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800594 [AS_HELP_STRING([--disable-driglx-direct],
595 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700596 [driglx_direct="$enableval"],
597 [driglx_direct="yes"])
Dave Airlie0b734bd2008-05-28 15:55:44 +1000598dnl ttm support
599AC_ARG_ENABLE([ttm-api],
600 [AS_HELP_STRING([--enable-ttm-api],
Dan Nicholson871125a2008-06-04 13:00:35 -0700601 [enable TTM API users @<:@default=disabled@:>@])],
Dave Airlie0b734bd2008-05-28 15:55:44 +1000602 [ttmapi="$enableval"],
603 [ttmapi="no"])
604
605if test "x$ttmapi" = "xyes"; then
606 save_CFLAGS=$CFLAGS
607 CFLAGS=$LIBDRM_CFLAGS
608 AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
609 CFLAGS=$save_CFLAGS
610fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800611
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800612dnl Which drivers to build - default is chosen by platform
Dan Nicholson297e16c2008-05-05 15:42:53 -0700613AC_ARG_WITH([dri-drivers],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800614 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholson5cae1b72008-06-30 10:28:02 -0700615 [comma delimited DRI drivers list, e.g.
616 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700617 [with_dri_drivers="$withval"],
618 [with_dri_drivers=yes])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800619if test "x$with_dri_drivers" = x; then
620 with_dri_drivers=no
621fi
622
623dnl If $with_dri_drivers is yes, directories will be added through
624dnl platform checks
625DRI_DIRS=""
626case "$with_dri_drivers" in
627no|yes) ;;
628*)
629 # verify the requested driver directories exist
Dan Nicholsone6e4f252008-07-06 14:17:39 -0700630 dri_drivers=`IFS=', '; echo $with_dri_drivers`
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800631 for driver in $dri_drivers; do
632 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
633 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
634 done
635 DRI_DIRS="$dri_drivers"
636 ;;
637esac
638
Dan Nicholson44d99142007-12-05 18:47:01 -0800639dnl Just default to no EGL for now
640USING_EGL=0
Dan Nicholson297e16c2008-05-05 15:42:53 -0700641AC_SUBST([USING_EGL])
Dan Nicholson44d99142007-12-05 18:47:01 -0800642
643dnl Set DRI_DIRS, DEFINES and LIB_DEPS
644if test "$mesa_driver" = dri; then
645 # Use TLS in GLX?
646 if test "x$GLX_USE_TLS" = xyes; then
647 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
648 fi
649
Dave Airlie0b734bd2008-05-28 15:55:44 +1000650 if test "x$ttmapi" = xyes; then
651 DEFINES="$DEFINES -DTTM_API"
652 fi
653
Dan Nicholson44d99142007-12-05 18:47:01 -0800654 if test "x$USING_EGL" = x1; then
655 PROGRAM_DIRS="egl"
656 fi
657
658 # Platform specific settings and drivers to build
659 case "$host_os" in
660 linux*)
661 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
662 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
663 if test "x$driglx_direct" = xyes; then
664 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
665 fi
666
667 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800668 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800669 # ffb, gamma, and sis are missing because they have not be
670 # converted to use the new interface. i810 are missing
671 # because there is no x86-64 system where they could *ever*
672 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800673 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800674 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
George Sapountzis280bf892008-05-11 14:43:40 +0300675 savage tdfx unichrome swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800676 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800677 ;;
678 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800679 # Build only the drivers for cards that exist on PowerPC.
680 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800681 if test "x$DRI_DIRS" = x; then
George Sapountzis280bf892008-05-11 14:43:40 +0300682 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800683 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800684 ;;
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000685 sparc*)
686 # Build only the drivers for cards that exist on sparc`
687 if test "x$DRI_DIRS" = x; then
Dave Airlie41bdb882008-06-12 16:26:46 +1000688 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000689 fi
690 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800691 esac
692 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700693 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800694 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
695 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
696 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
697 if test "x$driglx_direct" = xyes; then
698 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
699 fi
700 if test "x$GXX" = xyes; then
701 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
702 fi
703
Dan Nicholsona76e2452007-12-07 11:25:08 -0800704 # ffb and gamma are missing because they have not been converted
705 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800706 if test "x$DRI_DIRS" = x; then
707 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
George Sapountzis280bf892008-05-11 14:43:40 +0300708 unichrome savage sis swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800709 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800710 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700711 solaris*)
712 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
713 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
714 if test "x$driglx_direct" = xyes; then
715 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
716 fi
717 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800718 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800719
720 # default drivers
721 if test "x$DRI_DIRS" = x; then
722 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
George Sapountzis280bf892008-05-11 14:43:40 +0300723 savage sis tdfx trident unichrome ffb swrast"
Dan Nicholson112a40e2008-02-21 10:17:19 -0800724 fi
725
Dan Nicholson44d99142007-12-05 18:47:01 -0800726 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
727
728 # Check for expat
729 EXPAT_INCLUDES=""
730 EXPAT_LIB=-lexpat
Dan Nicholson297e16c2008-05-05 15:42:53 -0700731 AC_ARG_WITH([expat],
732 [AS_HELP_STRING([--with-expat=DIR],
733 [expat install directory])],[
Dan Nicholson44d99142007-12-05 18:47:01 -0800734 EXPAT_INCLUDES="-I$withval/include"
735 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
736 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
737 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
738 ])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700739 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
740 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
741 [AC_MSG_ERROR([Expat required for DRI.])])
Dan Nicholson44d99142007-12-05 18:47:01 -0800742
743 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700744 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800745fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700746AC_SUBST([DRI_DIRS])
747AC_SUBST([EXPAT_INCLUDES])
748AC_SUBST([DRI_LIB_DEPS])
Dan Nicholson44d99142007-12-05 18:47:01 -0800749
750dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700751dnl OSMesa configuration
752dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800753if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800754 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800755else
Dan Nicholson544ab202007-12-30 08:41:53 -0800756 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800757fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700758AC_ARG_ENABLE([gl-osmesa],
Dan Nicholson544ab202007-12-30 08:41:53 -0800759 [AS_HELP_STRING([--enable-gl-osmesa],
760 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700761 [gl_osmesa="$enableval"],
762 [gl_osmesa="$default_gl_osmesa"])
Dan Nicholson544ab202007-12-30 08:41:53 -0800763if test "x$gl_osmesa" = xyes; then
764 if test "$mesa_driver" = osmesa; then
765 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800766 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800767 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800768 fi
769fi
770
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800771dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
Dan Nicholson297e16c2008-05-05 15:42:53 -0700772AC_ARG_WITH([osmesa-bits],
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800773 [AS_HELP_STRING([--with-osmesa-bits=BITS],
774 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700775 [osmesa_bits="$withval"],
776 [osmesa_bits=8])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800777if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
778 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
779 osmesa_bits=8
780fi
781case "x$osmesa_bits" in
782x8)
783 OSMESA_LIB=OSMesa
784 ;;
785x16|x32)
786 OSMESA_LIB="OSMesa$osmesa_bits"
787 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
788 ;;
789*)
790 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
791 ;;
792esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700793AC_SUBST([OSMESA_LIB])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800794
Dan Nicholson979ff512007-12-05 18:47:01 -0800795case "$mesa_driver" in
796osmesa)
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700797 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800798 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500799 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800800 else
801 OSMESA_LIB_DEPS=""
802 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800803 OSMESA_MESA_DEPS=""
804 ;;
805*)
806 # Link OSMesa to libGL otherwise
807 OSMESA_LIB_DEPS=""
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700808 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800809 if test "$enable_static" = no; then
810 OSMESA_MESA_DEPS='-l$(GL_LIB)'
811 else
812 OSMESA_MESA_DEPS=""
813 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800814 ;;
815esac
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700816if test "$enable_static" = no; then
817 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
818fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700819AC_SUBST([OSMESA_LIB_DEPS])
820AC_SUBST([OSMESA_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700821
822dnl
823dnl GLU configuration
824dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700825AC_ARG_ENABLE([glu],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800826 [AS_HELP_STRING([--disable-glu],
827 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700828 [enable_glu="$enableval"],
829 [enable_glu=yes])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700830if test "x$enable_glu" = xyes; then
831 SRC_DIRS="$SRC_DIRS glu"
832
Dan Nicholson979ff512007-12-05 18:47:01 -0800833 case "$mesa_driver" in
834 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800835 # If GLU is available and we have libOSMesa (not 16 or 32),
836 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800837 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800838 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
839 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700840
Dan Nicholson979ff512007-12-05 18:47:01 -0800841 # Link libGLU to libOSMesa instead of libGL
842 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800843 if test "$enable_static" = no; then
844 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
845 else
846 GLU_MESA_DEPS=""
847 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800848 ;;
849 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800850 # If static, empty GLU_LIB_DEPS and add libs for programs to link
851 if test "$enable_static" = no; then
852 GLU_LIB_DEPS="-lm"
853 GLU_MESA_DEPS='-l$(GL_LIB)'
854 else
855 GLU_LIB_DEPS=""
856 GLU_MESA_DEPS=""
857 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
858 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800859 ;;
860 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700861fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700862if test "$enable_static" = no; then
863 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
864fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700865AC_SUBST([GLU_LIB_DEPS])
866AC_SUBST([GLU_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700867
868dnl
869dnl GLw configuration
870dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700871AC_ARG_ENABLE([glw],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800872 [AS_HELP_STRING([--disable-glw],
873 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700874 [enable_glw="$enableval"],
875 [enable_glw=yes])
Dan Nicholson979ff512007-12-05 18:47:01 -0800876dnl Don't build GLw on osmesa
877if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
878 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
879 enable_glw=no
880fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700881if test "x$enable_glw" = xyes; then
882 SRC_DIRS="$SRC_DIRS glw"
883 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700884 PKG_CHECK_MODULES([GLW],[x11 xt])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700885 GLW_LIB_DEPS="$GLW_LIBS"
886 else
887 # should check these...
888 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
889 fi
890
Dan Nicholson88586332007-11-15 08:59:57 -0800891 # If static, empty GLW_LIB_DEPS and add libs for programs to link
892 if test "$enable_static" = no; then
893 GLW_MESA_DEPS='-l$(GL_LIB)'
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700894 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800895 else
896 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
897 GLW_LIB_DEPS=""
898 GLW_MESA_DEPS=""
899 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700900fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700901AC_SUBST([GLW_LIB_DEPS])
902AC_SUBST([GLW_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700903
904dnl
905dnl GLUT configuration
906dnl
907if test -f "$srcdir/include/GL/glut.h"; then
908 default_glut=yes
909else
910 default_glut=no
911fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700912AC_ARG_ENABLE([glut],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800913 [AS_HELP_STRING([--disable-glut],
914 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700915 [enable_glut="$enableval"],
916 [enable_glut="$default_glut"])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700917
918dnl Can't build glut if GLU not available
919if test "x$enable_glu$enable_glut" = xnoyes; then
920 AC_MSG_WARN([Disabling glut since GLU is disabled])
921 enable_glut=no
922fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800923dnl Don't build glut on osmesa
924if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
925 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
926 enable_glut=no
927fi
928
Dan Nicholsondca1b792007-10-23 09:25:58 -0700929if test "x$enable_glut" = xyes; then
930 SRC_DIRS="$SRC_DIRS glut/glx"
931 GLUT_CFLAGS=""
932 if test "x$GCC" = xyes; then
933 GLUT_CFLAGS="-fexceptions"
934 fi
935 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700936 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700937 GLUT_LIB_DEPS="$GLUT_LIBS"
938 else
939 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800940 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700941 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700942 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700943
944 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800945 if test "$with_demos" = yes; then
946 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
947 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700948
Dan Nicholson88586332007-11-15 08:59:57 -0800949 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
950 if test "$enable_static" = no; then
951 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
952 else
953 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
954 GLUT_LIB_DEPS=""
955 GLUT_MESA_DEPS=""
956 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700957fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700958AC_SUBST([GLUT_LIB_DEPS])
959AC_SUBST([GLUT_MESA_DEPS])
960AC_SUBST([GLUT_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700961
962dnl
963dnl Program library dependencies
964dnl Only libm is added here if necessary as the libraries should
965dnl be pulled in by the linker
966dnl
967if test "x$APP_LIB_DEPS" = x; then
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700968 case "$host_os" in
969 solaris*)
970 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
971 ;;
972 *)
973 APP_LIB_DEPS="-lm"
974 ;;
975 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700976fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700977AC_SUBST([APP_LIB_DEPS])
978AC_SUBST([PROGRAM_DIRS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700979
Dan Nicholsondca1b792007-10-23 09:25:58 -0700980
981dnl Restore LDFLAGS and CPPFLAGS
982LDFLAGS="$_SAVE_LDFLAGS"
983CPPFLAGS="$_SAVE_CPPFLAGS"
984
985dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800986AC_CONFIG_FILES([configs/autoconf])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700987
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800988dnl Replace the configs/current symlink
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700989AC_CONFIG_COMMANDS([configs],[
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800990if test -f configs/current || test -L configs/current; then
991 rm -f configs/current
992fi
993ln -s autoconf configs/current
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700994])
995
996AC_OUTPUT
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800997
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800998dnl
999dnl Output some configuration info for the user
1000dnl
1001echo ""
1002echo " prefix: $prefix"
1003echo " exec_prefix: $exec_prefix"
1004echo " libdir: $libdir"
Dan Nicholson11ac5b22008-07-03 09:17:44 -07001005echo " includedir: $includedir"
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001006
1007dnl Driver info
1008echo ""
1009echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -08001010if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1011 echo " OSMesa: lib$OSMESA_LIB"
1012else
1013 echo " OSMesa: no"
1014fi
1015if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001016 # cleanup the drivers var
1017 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1018 echo " DRI drivers: $dri_dirs"
1019 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dave Airlie0b734bd2008-05-28 15:55:44 +10001020 echo " TTM API support: $ttmapi"
Dan Nicholson544ab202007-12-30 08:41:53 -08001021fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001022
1023dnl Libraries
1024echo ""
1025echo " Shared libs: $enable_shared"
1026echo " Static libs: $enable_static"
1027echo " GLU: $enable_glu"
1028echo " GLw: $enable_glw"
1029echo " glut: $enable_glut"
1030
1031dnl Programs
1032# cleanup the programs var for display
1033program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1034if test "x$program_dirs" = x; then
1035 echo " Demos: no"
1036else
1037 echo " Demos: $program_dirs"
1038fi
1039
Dan Nicholson16a07fb2007-12-12 09:12:15 -08001040dnl Compiler options
1041# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1042cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1043 $SED 's/^ *//;s/ */ /;s/ *$//'`
1044cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1045 $SED 's/^ *//;s/ */ /;s/ *$//'`
1046defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1047echo ""
1048echo " CFLAGS: $cflags"
1049echo " CXXFLAGS: $cxxflags"
1050echo " Macros: $defines"
1051
Dan Nicholsondca1b792007-10-23 09:25:58 -07001052echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -07001053echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001054echo ""