blob: e44f619a7518beda533f0c134822e440f8d434bc [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 Nicholson985e1cd2008-06-04 13:17:06 -070088 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS"
Dan Nicholsondca1b792007-10-23 09:25:58 -070089 ;;
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
Dan Nicholson985e1cd2008-06-04 13:17:06 -0700328dnl See if posix_memalign is available
329AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
330
Dan Nicholson871125a2008-06-04 13:00:35 -0700331dnl SELinux awareness.
332AC_ARG_ENABLE([selinux],
333 [AS_HELP_STRING([--enable-selinux],
334 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
335 [MESA_SELINUX="$enableval"],
336 [MESA_SELINUX=no])
337if test "x$enable_selinux" = "xyes"; then
338 AC_CHECK_HEADER([selinux/selinux.h],[],
339 [AC_MSG_ERROR([SELinux headers not found])])
340 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
341 [AC_MSG_ERROR([SELinux library not found])])
342 SELINUX_LIBS="-lselinux"
343 DEFINES="$DEFINES -DMESA_SELINUX"
344fi
345
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700346dnl OS-specific libraries
347OS_LIBS=""
348case "$host_os" in
349solaris*)
350 OS_LIBS="-lc"
351 if test "x$GXX" != xyes; then
352 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
353 fi
354 ;;
355esac
Dan Nicholson871125a2008-06-04 13:00:35 -0700356
357dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800358dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800359dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800360dnl
Eric Anholt711222b2008-04-18 15:03:01 -0700361default_driver="xlib"
362
363case "$host_os" in
364linux*)
365 case "$host_cpu" in
366 i*86|x86_64|powerpc*) default_driver="dri";;
367 esac
368 ;;
369freebsd* | dragonfly*)
370 case "$host_cpu" in
371 i*86|x86_64) default_driver="dri";;
372 esac
373 ;;
374esac
375
Dan Nicholson297e16c2008-05-05 15:42:53 -0700376AC_ARG_WITH([driver],
Dan Nicholson44d99142007-12-05 18:47:01 -0800377 [AS_HELP_STRING([--with-driver=DRIVER],
Eric Anholt711222b2008-04-18 15:03:01 -0700378 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700379 [mesa_driver="$withval"],
380 [mesa_driver="$default_driver"])
Dan Nicholson44d99142007-12-05 18:47:01 -0800381dnl Check for valid option
382case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800383xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800384 ;;
385*)
386 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
387 ;;
388esac
389
390dnl
391dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700392dnl
393SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700394GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800395WINDOW_SYSTEM=""
396case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800397xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800398 DRIVER_DIRS="x11"
399 ;;
400dri)
401 SRC_DIRS="glx/x11 $SRC_DIRS"
402 DRIVER_DIRS="dri"
403 WINDOW_SYSTEM="dri"
404 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800405osmesa)
406 DRIVER_DIRS="osmesa"
407 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800408esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700409AC_SUBST([SRC_DIRS])
410AC_SUBST([GLU_DIRS])
411AC_SUBST([DRIVER_DIRS])
412AC_SUBST([WINDOW_SYSTEM])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700413
414dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800415dnl User supplied program configuration
416dnl
417if test -d "$srcdir/progs/demos"; then
418 default_demos=yes
419else
420 default_demos=no
421fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700422AC_ARG_WITH([demos],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800423 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
424 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800425 @<:@default=auto if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700426 [with_demos="$withval"],
427 [with_demos="$default_demos"])
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800428if test "x$with_demos" = x; then
429 with_demos=no
430fi
431
432dnl If $with_demos is yes, directories will be added as libs available
433PROGRAM_DIRS=""
434case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700435no) ;;
436yes)
437 # If the driver isn't osmesa, we have libGL and can build xdemos
438 if test "$mesa_driver" != osmesa; then
439 PROGRAM_DIRS="xdemos"
440 fi
441 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800442*)
443 # verify the requested demos directories exist
444 demos=`IFS=,; echo $with_demos`
445 for demo in $demos; do
446 test -d "$srcdir/progs/$demo" || \
447 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
448 done
449 PROGRAM_DIRS="$demos"
450 ;;
451esac
452
453dnl
Dan Nicholsone6a06092008-05-05 15:16:22 -0700454dnl Find out if X is available. The variable have_x is set if libX11 is
455dnl to mimic AC_PATH_XTRA.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700456dnl
457if test -n "$PKG_CONFIG"; then
458 AC_MSG_CHECKING([pkg-config files for X11 are available])
Dan Nicholsone6a06092008-05-05 15:16:22 -0700459 PKG_CHECK_EXISTS([x11],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700460 x11_pkgconfig=yes
461 have_x=yes
Dan Nicholsone6a06092008-05-05 15:16:22 -0700462 ],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700463 x11_pkgconfig=no
Dan Nicholsone6a06092008-05-05 15:16:22 -0700464 ])
465 AC_MSG_RESULT([$x11_pkgconfig])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700466else
467 x11_pkgconfig=no
468fi
469dnl Use the autoconf macro if no pkg-config files
470if test "$x11_pkgconfig" = no; then
471 AC_PATH_XTRA
472fi
473
Dan Nicholson44d99142007-12-05 18:47:01 -0800474dnl We need X for xlib and dri, so bomb now if it's not found
475case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800476xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800477 if test "$no_x" = yes; then
478 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
479 fi
480 ;;
481esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700482
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700483dnl XCB - this is only used for GLX right now
484AC_ARG_ENABLE([xcb],
485 [AS_HELP_STRING([--enable-xcb],
486 [use XCB for GLX @<:@default=disabled@:>@])],
487 [enable_xcb="$enableval"],
488 [enable_xcb=no])
489if test "x$enable_xcb" = xyes; then
490 DEFINES="$DEFINES -DUSE_XCB"
491else
492 enable_xcb=no
493fi
494
Dan Nicholson44d99142007-12-05 18:47:01 -0800495dnl
496dnl libGL configuration per driver
497dnl
498case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800499xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800500 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700501 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
Dan Nicholsona1307182007-12-12 17:49:49 -0800502 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
503 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800504 else
505 # should check these...
506 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
507 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
508 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700509 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800510
511 # if static, move the external libraries to the programs
512 # and empty the libraries for libGL
513 if test "$enable_static" = yes; then
514 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
515 GL_LIB_DEPS=""
516 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800517 ;;
518dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800519 # DRI must be shared, I think
520 if test "$enable_static" = yes; then
521 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
522 fi
523
Dan Nicholson44d99142007-12-05 18:47:01 -0800524 # Check for libdrm
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -0700525 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
526 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
Dan Nicholson44d99142007-12-05 18:47:01 -0800527
528 # find the DRI deps for libGL
529 if test "$x11_pkgconfig" = yes; then
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700530 # add xcb modules if necessary
531 dri_modules="x11 xext xxf86vm xdamage xfixes"
532 if test "$enable_xcb" = yes; then
533 dri_modules="$dri_modules x11-xcb xcb-glx"
534 fi
535
536 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
Dan Nicholson44d99142007-12-05 18:47:01 -0800537 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
538 GL_LIB_DEPS="$DRIGL_LIBS"
539 else
540 # should check these...
541 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
542 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700543
544 # XCB can only be used from pkg-config
545 if test "$enable_xcb" = yes; then
546 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
547 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
548 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
549 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800550 fi
551
552 # need DRM libs, -lpthread, etc.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700553 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800554 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800555osmesa)
556 # No libGL for osmesa
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700557 GL_LIB_DEPS="$OS_LIBS"
Dan Nicholson979ff512007-12-05 18:47:01 -0800558 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800559esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700560AC_SUBST([GL_LIB_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700561
562dnl
563dnl More X11 setup
564dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800565if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700566 DEFINES="$DEFINES -DUSE_XSHM"
567fi
568
569dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800570dnl More DRI setup
571dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700572AC_ARG_ENABLE([glx-tls],
Dan Nicholson44d99142007-12-05 18:47:01 -0800573 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800574 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700575 [GLX_USE_TLS="$enableval"],
576 [GLX_USE_TLS=no])
Dan Nicholson44d99142007-12-05 18:47:01 -0800577dnl Directory for DRI drivers
Dan Nicholson297e16c2008-05-05 15:42:53 -0700578AC_ARG_WITH([dri-driverdir],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800579 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700580 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700581 [DRI_DRIVER_INSTALL_DIR="$withval"],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700582 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700583AC_SUBST([DRI_DRIVER_INSTALL_DIR])
Dan Nicholson44d99142007-12-05 18:47:01 -0800584dnl Direct rendering or just indirect rendering
Dan Nicholson297e16c2008-05-05 15:42:53 -0700585AC_ARG_ENABLE([driglx-direct],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800586 [AS_HELP_STRING([--disable-driglx-direct],
587 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700588 [driglx_direct="$enableval"],
589 [driglx_direct="yes"])
Dave Airlie0b734bd2008-05-28 15:55:44 +1000590dnl ttm support
591AC_ARG_ENABLE([ttm-api],
592 [AS_HELP_STRING([--enable-ttm-api],
Dan Nicholson871125a2008-06-04 13:00:35 -0700593 [enable TTM API users @<:@default=disabled@:>@])],
Dave Airlie0b734bd2008-05-28 15:55:44 +1000594 [ttmapi="$enableval"],
595 [ttmapi="no"])
596
597if test "x$ttmapi" = "xyes"; then
598 save_CFLAGS=$CFLAGS
599 CFLAGS=$LIBDRM_CFLAGS
600 AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
601 CFLAGS=$save_CFLAGS
602fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800603
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800604dnl Which drivers to build - default is chosen by platform
Dan Nicholson297e16c2008-05-05 15:42:53 -0700605AC_ARG_WITH([dri-drivers],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800606 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800607 [comma delimited DRI drivers, e.g. "i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700608 [with_dri_drivers="$withval"],
609 [with_dri_drivers=yes])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800610if test "x$with_dri_drivers" = x; then
611 with_dri_drivers=no
612fi
613
614dnl If $with_dri_drivers is yes, directories will be added through
615dnl platform checks
616DRI_DIRS=""
617case "$with_dri_drivers" in
618no|yes) ;;
619*)
620 # verify the requested driver directories exist
621 dri_drivers=`IFS=,; echo $with_dri_drivers`
622 for driver in $dri_drivers; do
623 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
624 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
625 done
626 DRI_DIRS="$dri_drivers"
627 ;;
628esac
629
Dan Nicholson44d99142007-12-05 18:47:01 -0800630dnl Just default to no EGL for now
631USING_EGL=0
Dan Nicholson297e16c2008-05-05 15:42:53 -0700632AC_SUBST([USING_EGL])
Dan Nicholson44d99142007-12-05 18:47:01 -0800633
634dnl Set DRI_DIRS, DEFINES and LIB_DEPS
635if test "$mesa_driver" = dri; then
636 # Use TLS in GLX?
637 if test "x$GLX_USE_TLS" = xyes; then
638 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
639 fi
640
Dave Airlie0b734bd2008-05-28 15:55:44 +1000641 if test "x$ttmapi" = xyes; then
642 DEFINES="$DEFINES -DTTM_API"
643 fi
644
Dan Nicholson44d99142007-12-05 18:47:01 -0800645 if test "x$USING_EGL" = x1; then
646 PROGRAM_DIRS="egl"
647 fi
648
649 # Platform specific settings and drivers to build
650 case "$host_os" in
651 linux*)
652 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
653 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
654 if test "x$driglx_direct" = xyes; then
655 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
656 fi
657
658 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800659 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800660 # ffb, gamma, and sis are missing because they have not be
661 # converted to use the new interface. i810 are missing
662 # because there is no x86-64 system where they could *ever*
663 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800664 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800665 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
George Sapountzis280bf892008-05-11 14:43:40 +0300666 savage tdfx unichrome swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800667 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800668 ;;
669 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800670 # Build only the drivers for cards that exist on PowerPC.
671 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800672 if test "x$DRI_DIRS" = x; then
George Sapountzis280bf892008-05-11 14:43:40 +0300673 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800674 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800675 ;;
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000676 sparc*)
677 # Build only the drivers for cards that exist on sparc`
678 if test "x$DRI_DIRS" = x; then
Dave Airlie41bdb882008-06-12 16:26:46 +1000679 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000680 fi
681 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800682 esac
683 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700684 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800685 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
686 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
687 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
688 if test "x$driglx_direct" = xyes; then
689 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
690 fi
691 if test "x$GXX" = xyes; then
692 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
693 fi
694
Dan Nicholsona76e2452007-12-07 11:25:08 -0800695 # ffb and gamma are missing because they have not been converted
696 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800697 if test "x$DRI_DIRS" = x; then
698 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
George Sapountzis280bf892008-05-11 14:43:40 +0300699 unichrome savage sis swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800700 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800701 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700702 solaris*)
703 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
704 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
705 if test "x$driglx_direct" = xyes; then
706 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
707 fi
708 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800709 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800710
711 # default drivers
712 if test "x$DRI_DIRS" = x; then
713 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
George Sapountzis280bf892008-05-11 14:43:40 +0300714 savage sis tdfx trident unichrome ffb swrast"
Dan Nicholson112a40e2008-02-21 10:17:19 -0800715 fi
716
Dan Nicholson44d99142007-12-05 18:47:01 -0800717 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
718
719 # Check for expat
720 EXPAT_INCLUDES=""
721 EXPAT_LIB=-lexpat
Dan Nicholson297e16c2008-05-05 15:42:53 -0700722 AC_ARG_WITH([expat],
723 [AS_HELP_STRING([--with-expat=DIR],
724 [expat install directory])],[
Dan Nicholson44d99142007-12-05 18:47:01 -0800725 EXPAT_INCLUDES="-I$withval/include"
726 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
727 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
728 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
729 ])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700730 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
731 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
732 [AC_MSG_ERROR([Expat required for DRI.])])
Dan Nicholson44d99142007-12-05 18:47:01 -0800733
734 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700735 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800736fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700737AC_SUBST([DRI_DIRS])
738AC_SUBST([EXPAT_INCLUDES])
739AC_SUBST([DRI_LIB_DEPS])
Dan Nicholson44d99142007-12-05 18:47:01 -0800740
741dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700742dnl OSMesa configuration
743dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800744if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800745 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800746else
Dan Nicholson544ab202007-12-30 08:41:53 -0800747 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800748fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700749AC_ARG_ENABLE([gl-osmesa],
Dan Nicholson544ab202007-12-30 08:41:53 -0800750 [AS_HELP_STRING([--enable-gl-osmesa],
751 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700752 [gl_osmesa="$enableval"],
753 [gl_osmesa="$default_gl_osmesa"])
Dan Nicholson544ab202007-12-30 08:41:53 -0800754if test "x$gl_osmesa" = xyes; then
755 if test "$mesa_driver" = osmesa; then
756 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800757 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800758 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800759 fi
760fi
761
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800762dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
Dan Nicholson297e16c2008-05-05 15:42:53 -0700763AC_ARG_WITH([osmesa-bits],
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800764 [AS_HELP_STRING([--with-osmesa-bits=BITS],
765 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700766 [osmesa_bits="$withval"],
767 [osmesa_bits=8])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800768if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
769 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
770 osmesa_bits=8
771fi
772case "x$osmesa_bits" in
773x8)
774 OSMESA_LIB=OSMesa
775 ;;
776x16|x32)
777 OSMESA_LIB="OSMesa$osmesa_bits"
778 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
779 ;;
780*)
781 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
782 ;;
783esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700784AC_SUBST([OSMESA_LIB])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800785
Dan Nicholson979ff512007-12-05 18:47:01 -0800786case "$mesa_driver" in
787osmesa)
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700788 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800789 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500790 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800791 else
792 OSMESA_LIB_DEPS=""
793 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800794 OSMESA_MESA_DEPS=""
795 ;;
796*)
797 # Link OSMesa to libGL otherwise
798 OSMESA_LIB_DEPS=""
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700799 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800800 if test "$enable_static" = no; then
801 OSMESA_MESA_DEPS='-l$(GL_LIB)'
802 else
803 OSMESA_MESA_DEPS=""
804 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800805 ;;
806esac
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700807if test "$enable_static" = no; then
808 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
809fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700810AC_SUBST([OSMESA_LIB_DEPS])
811AC_SUBST([OSMESA_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700812
813dnl
814dnl GLU configuration
815dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700816AC_ARG_ENABLE([glu],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800817 [AS_HELP_STRING([--disable-glu],
818 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700819 [enable_glu="$enableval"],
820 [enable_glu=yes])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700821if test "x$enable_glu" = xyes; then
822 SRC_DIRS="$SRC_DIRS glu"
823
Dan Nicholson979ff512007-12-05 18:47:01 -0800824 case "$mesa_driver" in
825 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800826 # If GLU is available and we have libOSMesa (not 16 or 32),
827 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800828 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800829 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
830 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700831
Dan Nicholson979ff512007-12-05 18:47:01 -0800832 # Link libGLU to libOSMesa instead of libGL
833 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800834 if test "$enable_static" = no; then
835 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
836 else
837 GLU_MESA_DEPS=""
838 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800839 ;;
840 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800841 # If static, empty GLU_LIB_DEPS and add libs for programs to link
842 if test "$enable_static" = no; then
843 GLU_LIB_DEPS="-lm"
844 GLU_MESA_DEPS='-l$(GL_LIB)'
845 else
846 GLU_LIB_DEPS=""
847 GLU_MESA_DEPS=""
848 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
849 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800850 ;;
851 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700852fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700853if test "$enable_static" = no; then
854 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
855fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700856AC_SUBST([GLU_LIB_DEPS])
857AC_SUBST([GLU_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700858
859dnl
860dnl GLw configuration
861dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700862AC_ARG_ENABLE([glw],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800863 [AS_HELP_STRING([--disable-glw],
864 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700865 [enable_glw="$enableval"],
866 [enable_glw=yes])
Dan Nicholson979ff512007-12-05 18:47:01 -0800867dnl Don't build GLw on osmesa
868if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
869 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
870 enable_glw=no
871fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700872if test "x$enable_glw" = xyes; then
873 SRC_DIRS="$SRC_DIRS glw"
874 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700875 PKG_CHECK_MODULES([GLW],[x11 xt])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700876 GLW_LIB_DEPS="$GLW_LIBS"
877 else
878 # should check these...
879 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
880 fi
881
Dan Nicholson88586332007-11-15 08:59:57 -0800882 # If static, empty GLW_LIB_DEPS and add libs for programs to link
883 if test "$enable_static" = no; then
884 GLW_MESA_DEPS='-l$(GL_LIB)'
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700885 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800886 else
887 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
888 GLW_LIB_DEPS=""
889 GLW_MESA_DEPS=""
890 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700891fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700892AC_SUBST([GLW_LIB_DEPS])
893AC_SUBST([GLW_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700894
895dnl
896dnl GLUT configuration
897dnl
898if test -f "$srcdir/include/GL/glut.h"; then
899 default_glut=yes
900else
901 default_glut=no
902fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700903AC_ARG_ENABLE([glut],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800904 [AS_HELP_STRING([--disable-glut],
905 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700906 [enable_glut="$enableval"],
907 [enable_glut="$default_glut"])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700908
909dnl Can't build glut if GLU not available
910if test "x$enable_glu$enable_glut" = xnoyes; then
911 AC_MSG_WARN([Disabling glut since GLU is disabled])
912 enable_glut=no
913fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800914dnl Don't build glut on osmesa
915if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
916 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
917 enable_glut=no
918fi
919
Dan Nicholsondca1b792007-10-23 09:25:58 -0700920if test "x$enable_glut" = xyes; then
921 SRC_DIRS="$SRC_DIRS glut/glx"
922 GLUT_CFLAGS=""
923 if test "x$GCC" = xyes; then
924 GLUT_CFLAGS="-fexceptions"
925 fi
926 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700927 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700928 GLUT_LIB_DEPS="$GLUT_LIBS"
929 else
930 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800931 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700932 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700933 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700934
935 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800936 if test "$with_demos" = yes; then
937 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
938 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700939
Dan Nicholson88586332007-11-15 08:59:57 -0800940 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
941 if test "$enable_static" = no; then
942 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
943 else
944 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
945 GLUT_LIB_DEPS=""
946 GLUT_MESA_DEPS=""
947 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700948fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700949AC_SUBST([GLUT_LIB_DEPS])
950AC_SUBST([GLUT_MESA_DEPS])
951AC_SUBST([GLUT_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700952
953dnl
954dnl Program library dependencies
955dnl Only libm is added here if necessary as the libraries should
956dnl be pulled in by the linker
957dnl
958if test "x$APP_LIB_DEPS" = x; then
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700959 case "$host_os" in
960 solaris*)
961 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
962 ;;
963 *)
964 APP_LIB_DEPS="-lm"
965 ;;
966 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700967fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700968AC_SUBST([APP_LIB_DEPS])
969AC_SUBST([PROGRAM_DIRS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700970
Dan Nicholsondca1b792007-10-23 09:25:58 -0700971
972dnl Restore LDFLAGS and CPPFLAGS
973LDFLAGS="$_SAVE_LDFLAGS"
974CPPFLAGS="$_SAVE_CPPFLAGS"
975
976dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800977AC_CONFIG_FILES([configs/autoconf])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700978
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800979dnl Replace the configs/current symlink
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700980AC_CONFIG_COMMANDS([configs],[
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800981if test -f configs/current || test -L configs/current; then
982 rm -f configs/current
983fi
984ln -s autoconf configs/current
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700985])
986
987AC_OUTPUT
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800988
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800989dnl
990dnl Output some configuration info for the user
991dnl
992echo ""
993echo " prefix: $prefix"
994echo " exec_prefix: $exec_prefix"
995echo " libdir: $libdir"
996
997dnl Driver info
998echo ""
999echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -08001000if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1001 echo " OSMesa: lib$OSMESA_LIB"
1002else
1003 echo " OSMesa: no"
1004fi
1005if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001006 # cleanup the drivers var
1007 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1008 echo " DRI drivers: $dri_dirs"
1009 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dave Airlie0b734bd2008-05-28 15:55:44 +10001010 echo " TTM API support: $ttmapi"
Dan Nicholson544ab202007-12-30 08:41:53 -08001011fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001012
1013dnl Libraries
1014echo ""
1015echo " Shared libs: $enable_shared"
1016echo " Static libs: $enable_static"
1017echo " GLU: $enable_glu"
1018echo " GLw: $enable_glw"
1019echo " glut: $enable_glut"
1020
1021dnl Programs
1022# cleanup the programs var for display
1023program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1024if test "x$program_dirs" = x; then
1025 echo " Demos: no"
1026else
1027 echo " Demos: $program_dirs"
1028fi
1029
Dan Nicholson16a07fb2007-12-12 09:12:15 -08001030dnl Compiler options
1031# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1032cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1033 $SED 's/^ *//;s/ */ /;s/ *$//'`
1034cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1035 $SED 's/^ *//;s/ */ /;s/ *$//'`
1036defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1037echo ""
1038echo " CFLAGS: $cflags"
1039echo " CXXFLAGS: $cxxflags"
1040echo " Macros: $defines"
1041
Dan Nicholsondca1b792007-10-23 09:25:58 -07001042echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -07001043echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001044echo ""