blob: c4b65db4ea4e46461851b38251c85741882961de [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 Nicholson00994ac2008-04-30 15:06:00 -070015AC_INIT([Mesa],[mesa_version],
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -080016 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
Dan Nicholson297e16c2008-05-05 15:42:53 -070017AC_CONFIG_AUX_DIR([bin])
Dan Nicholsondca1b792007-10-23 09:25:58 -070018AC_CANONICAL_HOST
19
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -070020dnl Versions for external dependencies
21LIBDRM_REQUIRED=2.3.1
22DRI2PROTO_REQUIRED=1.1
23
Dan Nicholsondca1b792007-10-23 09:25:58 -070024dnl Check for progs
25AC_PROG_CPP
26AC_PROG_CC
27AC_PROG_CXX
Dan Nicholson297e16c2008-05-05 15:42:53 -070028AC_CHECK_PROGS([MAKE], [gmake make])
29AC_PATH_PROG([MKDEP], [makedepend])
30AC_PATH_PROG([SED], [sed])
Dan Nicholson41b00702007-12-12 08:48:30 -080031
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070032dnl Platform-specific program settings
33EXTRA_CONFIG_LINES=""
34AC_SUBST([EXTRA_CONFIG_LINES])
35case "$host_os" in
36solaris*)
37 # Solaris /bin/sh is too old/non-POSIX compliant
38 AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
39 EXTRA_CONFIG_LINES="SHELL=$POSIX_SHELL"
40 ;;
41esac
42
43
Dan Nicholsondb7fc632008-03-07 11:48:09 -080044MKDEP_OPTIONS=-fdepend
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050045dnl Ask gcc where it's keeping its secret headers
46if test "x$GCC" = xyes; then
Dan Nicholsondb7fc632008-03-07 11:48:09 -080047 GCC_INCLUDES=`$CC -print-file-name=include`
48 if test "x$GCC_INCLUDES" != x; then
49 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
50 fi
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050051fi
Dan Nicholson297e16c2008-05-05 15:42:53 -070052AC_SUBST([MKDEP_OPTIONS])
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050053
Dan Nicholson41b00702007-12-12 08:48:30 -080054dnl Make sure the pkg-config macros are defined
Dan Nicholson297e16c2008-05-05 15:42:53 -070055m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
Dan Nicholson7154d662008-04-30 13:53:37 -070056 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
57 These are usually located in /usr/share/aclocal/pkg.m4. If your
58 macros are in a different location, try setting the environment
59 variable ACLOCAL="aclocal -I/other/macro/dir" before running
60 autoreconf.
61])
62 m4_exit([1])
63])
Dan Nicholsondca1b792007-10-23 09:25:58 -070064PKG_PROG_PKG_CONFIG()
65
66dnl LIB_DIR - library basename
67LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
Dan Nicholson297e16c2008-05-05 15:42:53 -070068AC_SUBST([LIB_DIR])
Dan Nicholsondca1b792007-10-23 09:25:58 -070069
70dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
71_SAVE_LDFLAGS="$LDFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070072AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
73AC_SUBST([EXTRA_LIB_PATH])
Dan Nicholsondca1b792007-10-23 09:25:58 -070074
75dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
76_SAVE_CPPFLAGS="$CPPFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070077AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
78AC_SUBST([X11_INCLUDES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070079
80dnl Compiler macros
81DEFINES=""
Dan Nicholson297e16c2008-05-05 15:42:53 -070082AC_SUBST([DEFINES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070083case "$host_os" in
84linux*)
Eric Anholt5ad06152008-03-20 17:14:20 -070085if test "x$GCC" = xyes; then
86 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
87fi
Dan Nicholsondca1b792007-10-23 09:25:58 -070088 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
89 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070090solaris*)
91 DEFINES="$DEFINES -DPTHREADS -DSVR4"
92 ;;
Dan Nicholsondca1b792007-10-23 09:25:58 -070093esac
94
95dnl Add flags for gcc and g++
96if test "x$GCC" = xyes; then
97 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -080098
99 # Work around aliasing bugs - developers should comment this out
100 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700101fi
102if test "x$GXX" = xyes; then
103 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800104
105 # Work around aliasing bugs - developers should comment this out
106 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700107fi
108
109dnl These should be unnecessary, but let the user set them if they want
Dan Nicholson297e16c2008-05-05 15:42:53 -0700110AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700111 Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700112AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
Dan Nicholsondca1b792007-10-23 09:25:58 -0700113 compiler. Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700114AC_SUBST([OPT_FLAGS])
115AC_SUBST([ARCH_FLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700116
117dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600118dnl Hacks to enable 32 or 64 bit build
119dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700120AC_ARG_ENABLE([32-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600121 [AS_HELP_STRING([--enable-32-bit],
122 [build 32-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700123 [enable_32bit="$enableval"],
124 [enable_32bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600125)
126if test "x$enable_32bit" = xyes; then
127 if test "x$GCC" = xyes; then
128 CFLAGS="$CFLAGS -m32"
129 fi
130 if test "x$GXX" = xyes; then
131 CXXFLAGS="$CXXFLAGS -m32"
132 fi
133fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700134AC_ARG_ENABLE([64-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600135 [AS_HELP_STRING([--enable-64-bit],
136 [build 64-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700137 [enable_64bit="$enableval"],
138 [enable_64bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600139)
140if test "x$enable_64bit" = xyes; then
141 if test "x$GCC" = xyes; then
142 CFLAGS="$CFLAGS -m64"
143 fi
144 if test "x$GXX" = xyes; then
145 CXXFLAGS="$CXXFLAGS -m64"
146 fi
147fi
148
149dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800150dnl shared/static libraries, mimic libtool options
151dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700152AC_ARG_ENABLE([static],
Dan Nicholson88586332007-11-15 08:59:57 -0800153 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800154 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700155 [enable_static="$enableval"],
156 [enable_static=no]
Dan Nicholson88586332007-11-15 08:59:57 -0800157)
158case "x$enable_static" in
159xyes|xno ) ;;
160x ) enable_static=no ;;
161* )
162 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
163 ;;
164esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700165AC_ARG_ENABLE([shared],
Dan Nicholson88586332007-11-15 08:59:57 -0800166 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800167 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700168 [enable_shared="$enableval"],
169 [enable_shared=yes]
Dan Nicholson88586332007-11-15 08:59:57 -0800170)
171case "x$enable_shared" in
172xyes|xno ) ;;
173x ) enable_shared=yes ;;
174* )
175 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
176 ;;
177esac
178
179dnl Can't have static and shared libraries, default to static if user
180dnl explicitly requested. If both disabled, set to static since shared
181dnl was explicitly requirested.
182case "x$enable_static$enable_shared" in
183xyesyes )
184 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
185 enable_shared=no
186 ;;
187xnono )
188 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
189 enable_static=yes
190 ;;
191esac
192
193dnl
194dnl mklib options
195dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700196AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
Dan Nicholson88586332007-11-15 08:59:57 -0800197if test "$enable_static" = yes; then
198 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
199fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700200AC_SUBST([MKLIB_OPTIONS])
Dan Nicholson88586332007-11-15 08:59:57 -0800201
Dan Nicholson23656c42007-12-12 09:02:31 -0800202dnl
203dnl other compiler options
204dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700205AC_ARG_ENABLE([debug],
Dan Nicholson23656c42007-12-12 09:02:31 -0800206 [AS_HELP_STRING([--enable-debug],
207 [use debug compiler flags and macros @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700208 [enable_debug="$enableval"],
209 [enable_debug=no]
Dan Nicholson23656c42007-12-12 09:02:31 -0800210)
211if test "x$enable_debug" = xyes; then
212 DEFINES="$DEFINES -DDEBUG"
213 if test "x$GCC" = xyes; then
214 CFLAGS="$CFLAGS -g"
215 fi
216 if test "x$GXX" = xyes; then
217 CXXFLAGS="$CXXFLAGS -g"
218 fi
219fi
Dan Nicholson88586332007-11-15 08:59:57 -0800220
221dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700222dnl library names
223dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800224if test "$enable_static" = yes; then
225 GL_LIB_NAME='lib$(GL_LIB).a'
226 GLU_LIB_NAME='lib$(GLU_LIB).a'
227 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
228 GLW_LIB_NAME='lib$(GLW_LIB).a'
229 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
230else
231 GL_LIB_NAME='lib$(GL_LIB).so'
232 GLU_LIB_NAME='lib$(GLU_LIB).so'
233 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
234 GLW_LIB_NAME='lib$(GLW_LIB).so'
235 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
236fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700237AC_SUBST([GL_LIB_NAME])
238AC_SUBST([GLU_LIB_NAME])
239AC_SUBST([GLUT_LIB_NAME])
240AC_SUBST([GLW_LIB_NAME])
241AC_SUBST([OSMESA_LIB_NAME])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700242
243dnl
Dan Nicholson871125a2008-06-04 13:00:35 -0700244dnl Arch/platform-specific settings
245dnl
246AC_ARG_ENABLE([asm],
247 [AS_HELP_STRING([--disable-asm],
248 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
249 [enable_asm="$enableval"],
250 [enable_asm=yes]
251)
252asm_arch=""
253ASM_FLAGS=""
254ASM_SOURCES=""
255ASM_API=""
256AC_MSG_CHECKING([whether to enable assembly])
257test "x$enable_asm" = xno && AC_MSG_RESULT([no])
258# disable if cross compiling on x86/x86_64 since we must run gen_matypes
259if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
260 case "$host_cpu" in
261 i?86 | x86_64)
262 enable_asm=no
263 AC_MSG_RESULT([no, cross compiling])
264 ;;
265 esac
266fi
267# check for supported arches
268if test "x$enable_asm" = xyes; then
269 case "$host_cpu" in
270 i?86)
271 case "$host_os" in
272 linux* | freebsd* | dragonfly*)
273 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
274 ;;
275 esac
276 ;;
277 x86_64)
278 case "$host_os" in
279 linux* | freebsd* | dragonfly*)
280 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
281 ;;
282 esac
283 ;;
284 powerpc)
285 case "$host_os" in
286 linux*)
287 asm_arch=ppc
288 ;;
289 esac
290 ;;
291 esac
292
293 case "$asm_arch" in
294 x86)
295 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
296 ASM_SOURCES='$(X86_SOURCES)'
297 ASM_API='$(X86_API)'
298 AC_MSG_RESULT([yes, x86])
299 ;;
300 x86_64)
301 ASM_FLAGS="-DUSE_X86_64_ASM"
302 ASM_SOURCES='$(X86-64_SOURCES)'
303 ASM_API='$(X86-64_API)'
304 AC_MSG_RESULT([yes, x86_64])
305 ;;
306 ppc)
307 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
308 ASM_SOURCES='$(PPC_SOURCES)'
309 AC_MSG_RESULT([yes, ppc])
310 ;;
311 *)
312 AC_MSG_RESULT([no, platform not supported])
313 ;;
314 esac
315fi
316AC_SUBST([ASM_FLAGS])
317AC_SUBST([ASM_SOURCES])
318AC_SUBST([ASM_API])
319
320dnl PIC code macro
321MESA_PIC_FLAGS
322
323dnl Check to see if dlopen is in default libraries (like Solaris, which
324dnl has it in libc), or if libdl is needed to get it.
325AC_CHECK_FUNC([dlopen], [],
326 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
327
328dnl SELinux awareness.
329AC_ARG_ENABLE([selinux],
330 [AS_HELP_STRING([--enable-selinux],
331 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
332 [MESA_SELINUX="$enableval"],
333 [MESA_SELINUX=no])
334if test "x$enable_selinux" = "xyes"; then
335 AC_CHECK_HEADER([selinux/selinux.h],[],
336 [AC_MSG_ERROR([SELinux headers not found])])
337 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
338 [AC_MSG_ERROR([SELinux library not found])])
339 SELINUX_LIBS="-lselinux"
340 DEFINES="$DEFINES -DMESA_SELINUX"
341fi
342
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700343dnl OS-specific libraries
344OS_LIBS=""
345case "$host_os" in
346solaris*)
347 OS_LIBS="-lc"
348 if test "x$GXX" != xyes; then
349 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
350 fi
351 ;;
352esac
Dan Nicholson871125a2008-06-04 13:00:35 -0700353
354dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800355dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800356dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800357dnl
Eric Anholt711222b2008-04-18 15:03:01 -0700358default_driver="xlib"
359
360case "$host_os" in
361linux*)
362 case "$host_cpu" in
363 i*86|x86_64|powerpc*) default_driver="dri";;
364 esac
365 ;;
366freebsd* | dragonfly*)
367 case "$host_cpu" in
368 i*86|x86_64) default_driver="dri";;
369 esac
370 ;;
371esac
372
Dan Nicholson297e16c2008-05-05 15:42:53 -0700373AC_ARG_WITH([driver],
Dan Nicholson44d99142007-12-05 18:47:01 -0800374 [AS_HELP_STRING([--with-driver=DRIVER],
Eric Anholt711222b2008-04-18 15:03:01 -0700375 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700376 [mesa_driver="$withval"],
377 [mesa_driver="$default_driver"])
Dan Nicholson44d99142007-12-05 18:47:01 -0800378dnl Check for valid option
379case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800380xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800381 ;;
382*)
383 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
384 ;;
385esac
386
387dnl
388dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700389dnl
390SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700391GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800392WINDOW_SYSTEM=""
393case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800394xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800395 DRIVER_DIRS="x11"
396 ;;
397dri)
398 SRC_DIRS="glx/x11 $SRC_DIRS"
399 DRIVER_DIRS="dri"
400 WINDOW_SYSTEM="dri"
401 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800402osmesa)
403 DRIVER_DIRS="osmesa"
404 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800405esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700406AC_SUBST([SRC_DIRS])
407AC_SUBST([GLU_DIRS])
408AC_SUBST([DRIVER_DIRS])
409AC_SUBST([WINDOW_SYSTEM])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700410
411dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800412dnl User supplied program configuration
413dnl
414if test -d "$srcdir/progs/demos"; then
415 default_demos=yes
416else
417 default_demos=no
418fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700419AC_ARG_WITH([demos],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800420 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
421 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800422 @<:@default=auto if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700423 [with_demos="$withval"],
424 [with_demos="$default_demos"])
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800425if test "x$with_demos" = x; then
426 with_demos=no
427fi
428
429dnl If $with_demos is yes, directories will be added as libs available
430PROGRAM_DIRS=""
431case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700432no) ;;
433yes)
434 # If the driver isn't osmesa, we have libGL and can build xdemos
435 if test "$mesa_driver" != osmesa; then
436 PROGRAM_DIRS="xdemos"
437 fi
438 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800439*)
440 # verify the requested demos directories exist
441 demos=`IFS=,; echo $with_demos`
442 for demo in $demos; do
443 test -d "$srcdir/progs/$demo" || \
444 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
445 done
446 PROGRAM_DIRS="$demos"
447 ;;
448esac
449
450dnl
Dan Nicholsone6a06092008-05-05 15:16:22 -0700451dnl Find out if X is available. The variable have_x is set if libX11 is
452dnl to mimic AC_PATH_XTRA.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700453dnl
454if test -n "$PKG_CONFIG"; then
455 AC_MSG_CHECKING([pkg-config files for X11 are available])
Dan Nicholsone6a06092008-05-05 15:16:22 -0700456 PKG_CHECK_EXISTS([x11],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700457 x11_pkgconfig=yes
458 have_x=yes
Dan Nicholsone6a06092008-05-05 15:16:22 -0700459 ],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700460 x11_pkgconfig=no
Dan Nicholsone6a06092008-05-05 15:16:22 -0700461 ])
462 AC_MSG_RESULT([$x11_pkgconfig])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700463else
464 x11_pkgconfig=no
465fi
466dnl Use the autoconf macro if no pkg-config files
467if test "$x11_pkgconfig" = no; then
468 AC_PATH_XTRA
469fi
470
Dan Nicholson44d99142007-12-05 18:47:01 -0800471dnl We need X for xlib and dri, so bomb now if it's not found
472case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800473xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800474 if test "$no_x" = yes; then
475 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
476 fi
477 ;;
478esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700479
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700480dnl XCB - this is only used for GLX right now
481AC_ARG_ENABLE([xcb],
482 [AS_HELP_STRING([--enable-xcb],
483 [use XCB for GLX @<:@default=disabled@:>@])],
484 [enable_xcb="$enableval"],
485 [enable_xcb=no])
486if test "x$enable_xcb" = xyes; then
487 DEFINES="$DEFINES -DUSE_XCB"
488else
489 enable_xcb=no
490fi
491
Dan Nicholson44d99142007-12-05 18:47:01 -0800492dnl
493dnl libGL configuration per driver
494dnl
495case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800496xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800497 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700498 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
Dan Nicholsona1307182007-12-12 17:49:49 -0800499 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
500 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800501 else
502 # should check these...
503 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
504 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
505 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700506 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800507
508 # if static, move the external libraries to the programs
509 # and empty the libraries for libGL
510 if test "$enable_static" = yes; then
511 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
512 GL_LIB_DEPS=""
513 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800514 ;;
515dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800516 # DRI must be shared, I think
517 if test "$enable_static" = yes; then
518 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
519 fi
520
Dan Nicholson44d99142007-12-05 18:47:01 -0800521 # Check for libdrm
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -0700522 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
523 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
Dan Nicholson44d99142007-12-05 18:47:01 -0800524
525 # find the DRI deps for libGL
526 if test "$x11_pkgconfig" = yes; then
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700527 # add xcb modules if necessary
528 dri_modules="x11 xext xxf86vm xdamage xfixes"
529 if test "$enable_xcb" = yes; then
530 dri_modules="$dri_modules x11-xcb xcb-glx"
531 fi
532
533 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
Dan Nicholson44d99142007-12-05 18:47:01 -0800534 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
535 GL_LIB_DEPS="$DRIGL_LIBS"
536 else
537 # should check these...
538 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
539 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700540
541 # XCB can only be used from pkg-config
542 if test "$enable_xcb" = yes; then
543 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
544 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
545 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
546 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800547 fi
548
549 # need DRM libs, -lpthread, etc.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700550 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800551 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800552osmesa)
553 # No libGL for osmesa
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700554 GL_LIB_DEPS="$OS_LIBS"
Dan Nicholson979ff512007-12-05 18:47:01 -0800555 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800556esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700557AC_SUBST([GL_LIB_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700558
559dnl
560dnl More X11 setup
561dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800562if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700563 DEFINES="$DEFINES -DUSE_XSHM"
564fi
565
566dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800567dnl More DRI setup
568dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700569AC_ARG_ENABLE([glx-tls],
Dan Nicholson44d99142007-12-05 18:47:01 -0800570 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800571 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700572 [GLX_USE_TLS="$enableval"],
573 [GLX_USE_TLS=no])
Dan Nicholson44d99142007-12-05 18:47:01 -0800574dnl Directory for DRI drivers
Dan Nicholson297e16c2008-05-05 15:42:53 -0700575AC_ARG_WITH([dri-driverdir],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800576 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700577 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700578 [DRI_DRIVER_INSTALL_DIR="$withval"],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700579 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700580AC_SUBST([DRI_DRIVER_INSTALL_DIR])
Dan Nicholson44d99142007-12-05 18:47:01 -0800581dnl Direct rendering or just indirect rendering
Dan Nicholson297e16c2008-05-05 15:42:53 -0700582AC_ARG_ENABLE([driglx-direct],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800583 [AS_HELP_STRING([--disable-driglx-direct],
584 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700585 [driglx_direct="$enableval"],
586 [driglx_direct="yes"])
Dave Airlie0b734bd2008-05-28 15:55:44 +1000587dnl ttm support
588AC_ARG_ENABLE([ttm-api],
589 [AS_HELP_STRING([--enable-ttm-api],
Dan Nicholson871125a2008-06-04 13:00:35 -0700590 [enable TTM API users @<:@default=disabled@:>@])],
Dave Airlie0b734bd2008-05-28 15:55:44 +1000591 [ttmapi="$enableval"],
592 [ttmapi="no"])
593
594if test "x$ttmapi" = "xyes"; then
595 save_CFLAGS=$CFLAGS
596 CFLAGS=$LIBDRM_CFLAGS
597 AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
598 CFLAGS=$save_CFLAGS
599fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800600
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800601dnl Which drivers to build - default is chosen by platform
Dan Nicholson297e16c2008-05-05 15:42:53 -0700602AC_ARG_WITH([dri-drivers],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800603 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800604 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700605 [with_dri_drivers="$withval"],
606 [with_dri_drivers=yes])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800607if test "x$with_dri_drivers" = x; then
608 with_dri_drivers=no
609fi
610
611dnl If $with_dri_drivers is yes, directories will be added through
612dnl platform checks
613DRI_DIRS=""
614case "$with_dri_drivers" in
615no|yes) ;;
616*)
617 # verify the requested driver directories exist
618 dri_drivers=`IFS=,; echo $with_dri_drivers`
619 for driver in $dri_drivers; do
620 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
621 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
622 done
623 DRI_DIRS="$dri_drivers"
624 ;;
625esac
626
Dan Nicholson44d99142007-12-05 18:47:01 -0800627dnl Just default to no EGL for now
628USING_EGL=0
Dan Nicholson297e16c2008-05-05 15:42:53 -0700629AC_SUBST([USING_EGL])
Dan Nicholson44d99142007-12-05 18:47:01 -0800630
631dnl Set DRI_DIRS, DEFINES and LIB_DEPS
632if test "$mesa_driver" = dri; then
633 # Use TLS in GLX?
634 if test "x$GLX_USE_TLS" = xyes; then
635 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
636 fi
637
Dave Airlie0b734bd2008-05-28 15:55:44 +1000638 if test "x$ttmapi" = xyes; then
639 DEFINES="$DEFINES -DTTM_API"
640 fi
641
Dan Nicholson44d99142007-12-05 18:47:01 -0800642 if test "x$USING_EGL" = x1; then
643 PROGRAM_DIRS="egl"
644 fi
645
646 # Platform specific settings and drivers to build
647 case "$host_os" in
648 linux*)
649 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
650 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
651 if test "x$driglx_direct" = xyes; then
652 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
653 fi
654
655 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800656 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800657 # ffb, gamma, and sis are missing because they have not be
658 # converted to use the new interface. i810 are missing
659 # because there is no x86-64 system where they could *ever*
660 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800661 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800662 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
George Sapountzis280bf892008-05-11 14:43:40 +0300663 savage tdfx unichrome swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800664 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800665 ;;
666 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800667 # Build only the drivers for cards that exist on PowerPC.
668 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800669 if test "x$DRI_DIRS" = x; then
George Sapountzis280bf892008-05-11 14:43:40 +0300670 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800671 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800672 ;;
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000673 sparc*)
674 # Build only the drivers for cards that exist on sparc`
675 if test "x$DRI_DIRS" = x; then
Dave Airlie41bdb882008-06-12 16:26:46 +1000676 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000677 fi
678 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800679 esac
680 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700681 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800682 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
683 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
684 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
685 if test "x$driglx_direct" = xyes; then
686 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
687 fi
688 if test "x$GXX" = xyes; then
689 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
690 fi
691
Dan Nicholsona76e2452007-12-07 11:25:08 -0800692 # ffb and gamma are missing because they have not been converted
693 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800694 if test "x$DRI_DIRS" = x; then
695 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
George Sapountzis280bf892008-05-11 14:43:40 +0300696 unichrome savage sis swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800697 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800698 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700699 solaris*)
700 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
701 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
702 if test "x$driglx_direct" = xyes; then
703 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
704 fi
705 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800706 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800707
708 # default drivers
709 if test "x$DRI_DIRS" = x; then
710 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
George Sapountzis280bf892008-05-11 14:43:40 +0300711 savage sis tdfx trident unichrome ffb swrast"
Dan Nicholson112a40e2008-02-21 10:17:19 -0800712 fi
713
Dan Nicholson44d99142007-12-05 18:47:01 -0800714 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
715
716 # Check for expat
717 EXPAT_INCLUDES=""
718 EXPAT_LIB=-lexpat
Dan Nicholson297e16c2008-05-05 15:42:53 -0700719 AC_ARG_WITH([expat],
720 [AS_HELP_STRING([--with-expat=DIR],
721 [expat install directory])],[
Dan Nicholson44d99142007-12-05 18:47:01 -0800722 EXPAT_INCLUDES="-I$withval/include"
723 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
724 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
725 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
726 ])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700727 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
728 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
729 [AC_MSG_ERROR([Expat required for DRI.])])
Dan Nicholson44d99142007-12-05 18:47:01 -0800730
731 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700732 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800733fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700734AC_SUBST([DRI_DIRS])
735AC_SUBST([EXPAT_INCLUDES])
736AC_SUBST([DRI_LIB_DEPS])
Dan Nicholson44d99142007-12-05 18:47:01 -0800737
738dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700739dnl OSMesa configuration
740dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800741if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800742 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800743else
Dan Nicholson544ab202007-12-30 08:41:53 -0800744 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800745fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700746AC_ARG_ENABLE([gl-osmesa],
Dan Nicholson544ab202007-12-30 08:41:53 -0800747 [AS_HELP_STRING([--enable-gl-osmesa],
748 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700749 [gl_osmesa="$enableval"],
750 [gl_osmesa="$default_gl_osmesa"])
Dan Nicholson544ab202007-12-30 08:41:53 -0800751if test "x$gl_osmesa" = xyes; then
752 if test "$mesa_driver" = osmesa; then
753 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800754 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800755 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800756 fi
757fi
758
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800759dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
Dan Nicholson297e16c2008-05-05 15:42:53 -0700760AC_ARG_WITH([osmesa-bits],
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800761 [AS_HELP_STRING([--with-osmesa-bits=BITS],
762 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700763 [osmesa_bits="$withval"],
764 [osmesa_bits=8])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800765if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
766 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
767 osmesa_bits=8
768fi
769case "x$osmesa_bits" in
770x8)
771 OSMESA_LIB=OSMesa
772 ;;
773x16|x32)
774 OSMESA_LIB="OSMesa$osmesa_bits"
775 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
776 ;;
777*)
778 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
779 ;;
780esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700781AC_SUBST([OSMESA_LIB])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800782
Dan Nicholson979ff512007-12-05 18:47:01 -0800783case "$mesa_driver" in
784osmesa)
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700785 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800786 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500787 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800788 else
789 OSMESA_LIB_DEPS=""
790 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800791 OSMESA_MESA_DEPS=""
792 ;;
793*)
794 # Link OSMesa to libGL otherwise
795 OSMESA_LIB_DEPS=""
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700796 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800797 if test "$enable_static" = no; then
798 OSMESA_MESA_DEPS='-l$(GL_LIB)'
799 else
800 OSMESA_MESA_DEPS=""
801 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800802 ;;
803esac
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700804if test "$enable_static" = no; then
805 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
806fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700807AC_SUBST([OSMESA_LIB_DEPS])
808AC_SUBST([OSMESA_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700809
810dnl
811dnl GLU configuration
812dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700813AC_ARG_ENABLE([glu],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800814 [AS_HELP_STRING([--disable-glu],
815 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700816 [enable_glu="$enableval"],
817 [enable_glu=yes])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700818if test "x$enable_glu" = xyes; then
819 SRC_DIRS="$SRC_DIRS glu"
820
Dan Nicholson979ff512007-12-05 18:47:01 -0800821 case "$mesa_driver" in
822 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800823 # If GLU is available and we have libOSMesa (not 16 or 32),
824 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800825 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800826 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
827 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700828
Dan Nicholson979ff512007-12-05 18:47:01 -0800829 # Link libGLU to libOSMesa instead of libGL
830 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800831 if test "$enable_static" = no; then
832 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
833 else
834 GLU_MESA_DEPS=""
835 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800836 ;;
837 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800838 # If static, empty GLU_LIB_DEPS and add libs for programs to link
839 if test "$enable_static" = no; then
840 GLU_LIB_DEPS="-lm"
841 GLU_MESA_DEPS='-l$(GL_LIB)'
842 else
843 GLU_LIB_DEPS=""
844 GLU_MESA_DEPS=""
845 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
846 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800847 ;;
848 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700849fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700850if test "$enable_static" = no; then
851 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
852fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700853AC_SUBST([GLU_LIB_DEPS])
854AC_SUBST([GLU_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700855
856dnl
857dnl GLw configuration
858dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700859AC_ARG_ENABLE([glw],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800860 [AS_HELP_STRING([--disable-glw],
861 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700862 [enable_glw="$enableval"],
863 [enable_glw=yes])
Dan Nicholson979ff512007-12-05 18:47:01 -0800864dnl Don't build GLw on osmesa
865if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
866 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
867 enable_glw=no
868fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700869if test "x$enable_glw" = xyes; then
870 SRC_DIRS="$SRC_DIRS glw"
871 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700872 PKG_CHECK_MODULES([GLW],[x11 xt])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700873 GLW_LIB_DEPS="$GLW_LIBS"
874 else
875 # should check these...
876 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
877 fi
878
Dan Nicholson88586332007-11-15 08:59:57 -0800879 # If static, empty GLW_LIB_DEPS and add libs for programs to link
880 if test "$enable_static" = no; then
881 GLW_MESA_DEPS='-l$(GL_LIB)'
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700882 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800883 else
884 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
885 GLW_LIB_DEPS=""
886 GLW_MESA_DEPS=""
887 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700888fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700889AC_SUBST([GLW_LIB_DEPS])
890AC_SUBST([GLW_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700891
892dnl
893dnl GLUT configuration
894dnl
895if test -f "$srcdir/include/GL/glut.h"; then
896 default_glut=yes
897else
898 default_glut=no
899fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700900AC_ARG_ENABLE([glut],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800901 [AS_HELP_STRING([--disable-glut],
902 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700903 [enable_glut="$enableval"],
904 [enable_glut="$default_glut"])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700905
906dnl Can't build glut if GLU not available
907if test "x$enable_glu$enable_glut" = xnoyes; then
908 AC_MSG_WARN([Disabling glut since GLU is disabled])
909 enable_glut=no
910fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800911dnl Don't build glut on osmesa
912if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
913 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
914 enable_glut=no
915fi
916
Dan Nicholsondca1b792007-10-23 09:25:58 -0700917if test "x$enable_glut" = xyes; then
918 SRC_DIRS="$SRC_DIRS glut/glx"
919 GLUT_CFLAGS=""
920 if test "x$GCC" = xyes; then
921 GLUT_CFLAGS="-fexceptions"
922 fi
923 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700924 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700925 GLUT_LIB_DEPS="$GLUT_LIBS"
926 else
927 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800928 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700929 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700930 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700931
932 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800933 if test "$with_demos" = yes; then
934 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
935 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700936
Dan Nicholson88586332007-11-15 08:59:57 -0800937 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
938 if test "$enable_static" = no; then
939 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
940 else
941 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
942 GLUT_LIB_DEPS=""
943 GLUT_MESA_DEPS=""
944 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700945fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700946AC_SUBST([GLUT_LIB_DEPS])
947AC_SUBST([GLUT_MESA_DEPS])
948AC_SUBST([GLUT_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700949
950dnl
951dnl Program library dependencies
952dnl Only libm is added here if necessary as the libraries should
953dnl be pulled in by the linker
954dnl
955if test "x$APP_LIB_DEPS" = x; then
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700956 case "$host_os" in
957 solaris*)
958 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
959 ;;
960 *)
961 APP_LIB_DEPS="-lm"
962 ;;
963 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700964fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700965AC_SUBST([APP_LIB_DEPS])
966AC_SUBST([PROGRAM_DIRS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700967
Dan Nicholsondca1b792007-10-23 09:25:58 -0700968
969dnl Restore LDFLAGS and CPPFLAGS
970LDFLAGS="$_SAVE_LDFLAGS"
971CPPFLAGS="$_SAVE_CPPFLAGS"
972
973dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800974AC_CONFIG_FILES([configs/autoconf])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700975
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800976dnl Replace the configs/current symlink
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700977AC_CONFIG_COMMANDS([configs],[
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800978if test -f configs/current || test -L configs/current; then
979 rm -f configs/current
980fi
981ln -s autoconf configs/current
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700982])
983
984AC_OUTPUT
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800985
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800986dnl
987dnl Output some configuration info for the user
988dnl
989echo ""
990echo " prefix: $prefix"
991echo " exec_prefix: $exec_prefix"
992echo " libdir: $libdir"
993
994dnl Driver info
995echo ""
996echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -0800997if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
998 echo " OSMesa: lib$OSMESA_LIB"
999else
1000 echo " OSMesa: no"
1001fi
1002if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001003 # cleanup the drivers var
1004 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1005 echo " DRI drivers: $dri_dirs"
1006 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dave Airlie0b734bd2008-05-28 15:55:44 +10001007 echo " TTM API support: $ttmapi"
Dan Nicholson544ab202007-12-30 08:41:53 -08001008fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001009
1010dnl Libraries
1011echo ""
1012echo " Shared libs: $enable_shared"
1013echo " Static libs: $enable_static"
1014echo " GLU: $enable_glu"
1015echo " GLw: $enable_glw"
1016echo " glut: $enable_glut"
1017
1018dnl Programs
1019# cleanup the programs var for display
1020program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1021if test "x$program_dirs" = x; then
1022 echo " Demos: no"
1023else
1024 echo " Demos: $program_dirs"
1025fi
1026
Dan Nicholson16a07fb2007-12-12 09:12:15 -08001027dnl Compiler options
1028# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1029cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1030 $SED 's/^ *//;s/ */ /;s/ *$//'`
1031cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1032 $SED 's/^ *//;s/ */ /;s/ *$//'`
1033defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1034echo ""
1035echo " CFLAGS: $cflags"
1036echo " CXXFLAGS: $cxxflags"
1037echo " Macros: $defines"
1038
Dan Nicholsondca1b792007-10-23 09:25:58 -07001039echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -07001040echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001041echo ""