blob: f15d9ff94a62751ff644036c270072a8ae41b1d6 [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 Nicholson5cae1b72008-06-30 10:28:02 -0700607 [comma delimited DRI drivers list, e.g.
608 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700609 [with_dri_drivers="$withval"],
610 [with_dri_drivers=yes])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800611if test "x$with_dri_drivers" = x; then
612 with_dri_drivers=no
613fi
614
615dnl If $with_dri_drivers is yes, directories will be added through
616dnl platform checks
617DRI_DIRS=""
618case "$with_dri_drivers" in
619no|yes) ;;
620*)
621 # verify the requested driver directories exist
622 dri_drivers=`IFS=,; echo $with_dri_drivers`
623 for driver in $dri_drivers; do
624 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
625 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
626 done
627 DRI_DIRS="$dri_drivers"
628 ;;
629esac
630
Dan Nicholson44d99142007-12-05 18:47:01 -0800631dnl Just default to no EGL for now
632USING_EGL=0
Dan Nicholson297e16c2008-05-05 15:42:53 -0700633AC_SUBST([USING_EGL])
Dan Nicholson44d99142007-12-05 18:47:01 -0800634
635dnl Set DRI_DIRS, DEFINES and LIB_DEPS
636if test "$mesa_driver" = dri; then
637 # Use TLS in GLX?
638 if test "x$GLX_USE_TLS" = xyes; then
639 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
640 fi
641
Dave Airlie0b734bd2008-05-28 15:55:44 +1000642 if test "x$ttmapi" = xyes; then
643 DEFINES="$DEFINES -DTTM_API"
644 fi
645
Dan Nicholson44d99142007-12-05 18:47:01 -0800646 if test "x$USING_EGL" = x1; then
647 PROGRAM_DIRS="egl"
648 fi
649
650 # Platform specific settings and drivers to build
651 case "$host_os" in
652 linux*)
653 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
654 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
655 if test "x$driglx_direct" = xyes; then
656 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
657 fi
658
659 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800660 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800661 # ffb, gamma, and sis are missing because they have not be
662 # converted to use the new interface. i810 are missing
663 # because there is no x86-64 system where they could *ever*
664 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800665 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800666 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
George Sapountzis280bf892008-05-11 14:43:40 +0300667 savage tdfx unichrome swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800668 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800669 ;;
670 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800671 # Build only the drivers for cards that exist on PowerPC.
672 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800673 if test "x$DRI_DIRS" = x; then
George Sapountzis280bf892008-05-11 14:43:40 +0300674 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800675 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800676 ;;
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000677 sparc*)
678 # Build only the drivers for cards that exist on sparc`
679 if test "x$DRI_DIRS" = x; then
Dave Airlie41bdb882008-06-12 16:26:46 +1000680 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000681 fi
682 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800683 esac
684 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700685 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800686 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
687 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
688 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
689 if test "x$driglx_direct" = xyes; then
690 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
691 fi
692 if test "x$GXX" = xyes; then
693 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
694 fi
695
Dan Nicholsona76e2452007-12-07 11:25:08 -0800696 # ffb and gamma are missing because they have not been converted
697 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800698 if test "x$DRI_DIRS" = x; then
699 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
George Sapountzis280bf892008-05-11 14:43:40 +0300700 unichrome savage sis swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800701 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800702 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700703 solaris*)
704 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
705 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
706 if test "x$driglx_direct" = xyes; then
707 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
708 fi
709 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800710 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800711
712 # default drivers
713 if test "x$DRI_DIRS" = x; then
714 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
George Sapountzis280bf892008-05-11 14:43:40 +0300715 savage sis tdfx trident unichrome ffb swrast"
Dan Nicholson112a40e2008-02-21 10:17:19 -0800716 fi
717
Dan Nicholson44d99142007-12-05 18:47:01 -0800718 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
719
720 # Check for expat
721 EXPAT_INCLUDES=""
722 EXPAT_LIB=-lexpat
Dan Nicholson297e16c2008-05-05 15:42:53 -0700723 AC_ARG_WITH([expat],
724 [AS_HELP_STRING([--with-expat=DIR],
725 [expat install directory])],[
Dan Nicholson44d99142007-12-05 18:47:01 -0800726 EXPAT_INCLUDES="-I$withval/include"
727 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
728 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
729 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
730 ])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700731 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
732 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
733 [AC_MSG_ERROR([Expat required for DRI.])])
Dan Nicholson44d99142007-12-05 18:47:01 -0800734
735 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700736 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800737fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700738AC_SUBST([DRI_DIRS])
739AC_SUBST([EXPAT_INCLUDES])
740AC_SUBST([DRI_LIB_DEPS])
Dan Nicholson44d99142007-12-05 18:47:01 -0800741
742dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700743dnl OSMesa configuration
744dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800745if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800746 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800747else
Dan Nicholson544ab202007-12-30 08:41:53 -0800748 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800749fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700750AC_ARG_ENABLE([gl-osmesa],
Dan Nicholson544ab202007-12-30 08:41:53 -0800751 [AS_HELP_STRING([--enable-gl-osmesa],
752 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700753 [gl_osmesa="$enableval"],
754 [gl_osmesa="$default_gl_osmesa"])
Dan Nicholson544ab202007-12-30 08:41:53 -0800755if test "x$gl_osmesa" = xyes; then
756 if test "$mesa_driver" = osmesa; then
757 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800758 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800759 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800760 fi
761fi
762
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800763dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
Dan Nicholson297e16c2008-05-05 15:42:53 -0700764AC_ARG_WITH([osmesa-bits],
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800765 [AS_HELP_STRING([--with-osmesa-bits=BITS],
766 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700767 [osmesa_bits="$withval"],
768 [osmesa_bits=8])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800769if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
770 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
771 osmesa_bits=8
772fi
773case "x$osmesa_bits" in
774x8)
775 OSMESA_LIB=OSMesa
776 ;;
777x16|x32)
778 OSMESA_LIB="OSMesa$osmesa_bits"
779 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
780 ;;
781*)
782 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
783 ;;
784esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700785AC_SUBST([OSMESA_LIB])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800786
Dan Nicholson979ff512007-12-05 18:47:01 -0800787case "$mesa_driver" in
788osmesa)
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700789 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800790 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500791 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800792 else
793 OSMESA_LIB_DEPS=""
794 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800795 OSMESA_MESA_DEPS=""
796 ;;
797*)
798 # Link OSMesa to libGL otherwise
799 OSMESA_LIB_DEPS=""
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700800 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800801 if test "$enable_static" = no; then
802 OSMESA_MESA_DEPS='-l$(GL_LIB)'
803 else
804 OSMESA_MESA_DEPS=""
805 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800806 ;;
807esac
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700808if test "$enable_static" = no; then
809 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
810fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700811AC_SUBST([OSMESA_LIB_DEPS])
812AC_SUBST([OSMESA_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700813
814dnl
815dnl GLU configuration
816dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700817AC_ARG_ENABLE([glu],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800818 [AS_HELP_STRING([--disable-glu],
819 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700820 [enable_glu="$enableval"],
821 [enable_glu=yes])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700822if test "x$enable_glu" = xyes; then
823 SRC_DIRS="$SRC_DIRS glu"
824
Dan Nicholson979ff512007-12-05 18:47:01 -0800825 case "$mesa_driver" in
826 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800827 # If GLU is available and we have libOSMesa (not 16 or 32),
828 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800829 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800830 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
831 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700832
Dan Nicholson979ff512007-12-05 18:47:01 -0800833 # Link libGLU to libOSMesa instead of libGL
834 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800835 if test "$enable_static" = no; then
836 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
837 else
838 GLU_MESA_DEPS=""
839 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800840 ;;
841 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800842 # If static, empty GLU_LIB_DEPS and add libs for programs to link
843 if test "$enable_static" = no; then
844 GLU_LIB_DEPS="-lm"
845 GLU_MESA_DEPS='-l$(GL_LIB)'
846 else
847 GLU_LIB_DEPS=""
848 GLU_MESA_DEPS=""
849 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
850 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800851 ;;
852 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700853fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700854if test "$enable_static" = no; then
855 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
856fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700857AC_SUBST([GLU_LIB_DEPS])
858AC_SUBST([GLU_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700859
860dnl
861dnl GLw configuration
862dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700863AC_ARG_ENABLE([glw],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800864 [AS_HELP_STRING([--disable-glw],
865 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700866 [enable_glw="$enableval"],
867 [enable_glw=yes])
Dan Nicholson979ff512007-12-05 18:47:01 -0800868dnl Don't build GLw on osmesa
869if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
870 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
871 enable_glw=no
872fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700873if test "x$enable_glw" = xyes; then
874 SRC_DIRS="$SRC_DIRS glw"
875 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700876 PKG_CHECK_MODULES([GLW],[x11 xt])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700877 GLW_LIB_DEPS="$GLW_LIBS"
878 else
879 # should check these...
880 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
881 fi
882
Dan Nicholson88586332007-11-15 08:59:57 -0800883 # If static, empty GLW_LIB_DEPS and add libs for programs to link
884 if test "$enable_static" = no; then
885 GLW_MESA_DEPS='-l$(GL_LIB)'
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700886 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800887 else
888 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
889 GLW_LIB_DEPS=""
890 GLW_MESA_DEPS=""
891 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700892fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700893AC_SUBST([GLW_LIB_DEPS])
894AC_SUBST([GLW_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700895
896dnl
897dnl GLUT configuration
898dnl
899if test -f "$srcdir/include/GL/glut.h"; then
900 default_glut=yes
901else
902 default_glut=no
903fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700904AC_ARG_ENABLE([glut],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800905 [AS_HELP_STRING([--disable-glut],
906 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700907 [enable_glut="$enableval"],
908 [enable_glut="$default_glut"])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700909
910dnl Can't build glut if GLU not available
911if test "x$enable_glu$enable_glut" = xnoyes; then
912 AC_MSG_WARN([Disabling glut since GLU is disabled])
913 enable_glut=no
914fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800915dnl Don't build glut on osmesa
916if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
917 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
918 enable_glut=no
919fi
920
Dan Nicholsondca1b792007-10-23 09:25:58 -0700921if test "x$enable_glut" = xyes; then
922 SRC_DIRS="$SRC_DIRS glut/glx"
923 GLUT_CFLAGS=""
924 if test "x$GCC" = xyes; then
925 GLUT_CFLAGS="-fexceptions"
926 fi
927 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700928 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700929 GLUT_LIB_DEPS="$GLUT_LIBS"
930 else
931 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800932 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700933 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700934 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700935
936 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800937 if test "$with_demos" = yes; then
938 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
939 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700940
Dan Nicholson88586332007-11-15 08:59:57 -0800941 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
942 if test "$enable_static" = no; then
943 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
944 else
945 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
946 GLUT_LIB_DEPS=""
947 GLUT_MESA_DEPS=""
948 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700949fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700950AC_SUBST([GLUT_LIB_DEPS])
951AC_SUBST([GLUT_MESA_DEPS])
952AC_SUBST([GLUT_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700953
954dnl
955dnl Program library dependencies
956dnl Only libm is added here if necessary as the libraries should
957dnl be pulled in by the linker
958dnl
959if test "x$APP_LIB_DEPS" = x; then
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700960 case "$host_os" in
961 solaris*)
962 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
963 ;;
964 *)
965 APP_LIB_DEPS="-lm"
966 ;;
967 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700968fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700969AC_SUBST([APP_LIB_DEPS])
970AC_SUBST([PROGRAM_DIRS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700971
Dan Nicholsondca1b792007-10-23 09:25:58 -0700972
973dnl Restore LDFLAGS and CPPFLAGS
974LDFLAGS="$_SAVE_LDFLAGS"
975CPPFLAGS="$_SAVE_CPPFLAGS"
976
977dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800978AC_CONFIG_FILES([configs/autoconf])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700979
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800980dnl Replace the configs/current symlink
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700981AC_CONFIG_COMMANDS([configs],[
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800982if test -f configs/current || test -L configs/current; then
983 rm -f configs/current
984fi
985ln -s autoconf configs/current
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700986])
987
988AC_OUTPUT
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800989
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800990dnl
991dnl Output some configuration info for the user
992dnl
993echo ""
994echo " prefix: $prefix"
995echo " exec_prefix: $exec_prefix"
996echo " libdir: $libdir"
997
998dnl Driver info
999echo ""
1000echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -08001001if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1002 echo " OSMesa: lib$OSMESA_LIB"
1003else
1004 echo " OSMesa: no"
1005fi
1006if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001007 # cleanup the drivers var
1008 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1009 echo " DRI drivers: $dri_dirs"
1010 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dave Airlie0b734bd2008-05-28 15:55:44 +10001011 echo " TTM API support: $ttmapi"
Dan Nicholson544ab202007-12-30 08:41:53 -08001012fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001013
1014dnl Libraries
1015echo ""
1016echo " Shared libs: $enable_shared"
1017echo " Static libs: $enable_static"
1018echo " GLU: $enable_glu"
1019echo " GLw: $enable_glw"
1020echo " glut: $enable_glut"
1021
1022dnl Programs
1023# cleanup the programs var for display
1024program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1025if test "x$program_dirs" = x; then
1026 echo " Demos: no"
1027else
1028 echo " Demos: $program_dirs"
1029fi
1030
Dan Nicholson16a07fb2007-12-12 09:12:15 -08001031dnl Compiler options
1032# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1033cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1034 $SED 's/^ *//;s/ */ /;s/ *$//'`
1035cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1036 $SED 's/^ *//;s/ */ /;s/ *$//'`
1037defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1038echo ""
1039echo " CFLAGS: $cflags"
1040echo " CXXFLAGS: $cxxflags"
1041echo " Macros: $defines"
1042
Dan Nicholsondca1b792007-10-23 09:25:58 -07001043echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -07001044echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001045echo ""