blob: dbd81909f1520707ae69d3055025326a5a704fbb [file] [log] [blame]
Dan Nicholsondca1b792007-10-23 09:25:58 -07001dnl Process this file with autoconf to create configure.
2
Dan Nicholson297e16c2008-05-05 15:42:53 -07003AC_PREREQ([2.59])
Dan Nicholsondca1b792007-10-23 09:25:58 -07004
Dan Nicholson00994ac2008-04-30 15:06:00 -07005dnl Versioning - scrape the version from configs/default
6m4_define([mesa_version],
7 [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])])
8m4_ifval(mesa_version,[],[
9 m4_errprint([Error: Failed to get the Mesa version from the output of
10 running `make -f bin/version.mk version'
11])
12 m4_exit([1])
13])
Dan Nicholsondca1b792007-10-23 09:25:58 -070014
Dan Nicholsone97ab722008-07-01 08:55:42 -070015dnl Tell the user about autoconf.html in the --help output
16m4_divert_once([HELP_END], [
17See docs/autoconf.html for more details on the options for Mesa.])
18
Dan Nicholson00994ac2008-04-30 15:06:00 -070019AC_INIT([Mesa],[mesa_version],
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -080020 [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
Dan Nicholson297e16c2008-05-05 15:42:53 -070021AC_CONFIG_AUX_DIR([bin])
Dan Nicholsondca1b792007-10-23 09:25:58 -070022AC_CANONICAL_HOST
23
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -070024dnl Versions for external dependencies
25LIBDRM_REQUIRED=2.3.1
26DRI2PROTO_REQUIRED=1.1
27
Dan Nicholsondca1b792007-10-23 09:25:58 -070028dnl Check for progs
29AC_PROG_CPP
30AC_PROG_CC
31AC_PROG_CXX
Dan Nicholson297e16c2008-05-05 15:42:53 -070032AC_CHECK_PROGS([MAKE], [gmake make])
33AC_PATH_PROG([MKDEP], [makedepend])
34AC_PATH_PROG([SED], [sed])
Dan Nicholson41b00702007-12-12 08:48:30 -080035
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070036dnl Platform-specific program settings
37EXTRA_CONFIG_LINES=""
38AC_SUBST([EXTRA_CONFIG_LINES])
39case "$host_os" in
40solaris*)
41 # Solaris /bin/sh is too old/non-POSIX compliant
42 AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
43 EXTRA_CONFIG_LINES="SHELL=$POSIX_SHELL"
44 ;;
45esac
46
47
Dan Nicholsondb7fc632008-03-07 11:48:09 -080048MKDEP_OPTIONS=-fdepend
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050049dnl Ask gcc where it's keeping its secret headers
50if test "x$GCC" = xyes; then
Dan Nicholsondb7fc632008-03-07 11:48:09 -080051 GCC_INCLUDES=`$CC -print-file-name=include`
52 if test "x$GCC_INCLUDES" != x; then
53 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
54 fi
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050055fi
Dan Nicholson297e16c2008-05-05 15:42:53 -070056AC_SUBST([MKDEP_OPTIONS])
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050057
Dan Nicholson41b00702007-12-12 08:48:30 -080058dnl Make sure the pkg-config macros are defined
Dan Nicholson297e16c2008-05-05 15:42:53 -070059m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
Dan Nicholson7154d662008-04-30 13:53:37 -070060 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
61 These are usually located in /usr/share/aclocal/pkg.m4. If your
62 macros are in a different location, try setting the environment
63 variable ACLOCAL="aclocal -I/other/macro/dir" before running
64 autoreconf.
65])
66 m4_exit([1])
67])
Dan Nicholsondca1b792007-10-23 09:25:58 -070068PKG_PROG_PKG_CONFIG()
69
70dnl LIB_DIR - library basename
71LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
Dan Nicholson297e16c2008-05-05 15:42:53 -070072AC_SUBST([LIB_DIR])
Dan Nicholsondca1b792007-10-23 09:25:58 -070073
74dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
75_SAVE_LDFLAGS="$LDFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070076AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
77AC_SUBST([EXTRA_LIB_PATH])
Dan Nicholsondca1b792007-10-23 09:25:58 -070078
79dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
80_SAVE_CPPFLAGS="$CPPFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070081AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
82AC_SUBST([X11_INCLUDES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070083
84dnl Compiler macros
85DEFINES=""
Dan Nicholson297e16c2008-05-05 15:42:53 -070086AC_SUBST([DEFINES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070087case "$host_os" in
88linux*)
Eric Anholt5ad06152008-03-20 17:14:20 -070089if test "x$GCC" = xyes; then
90 DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
91fi
Dan Nicholson985e1cd2008-06-04 13:17:06 -070092 DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS"
Dan Nicholsondca1b792007-10-23 09:25:58 -070093 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070094solaris*)
95 DEFINES="$DEFINES -DPTHREADS -DSVR4"
96 ;;
Dan Nicholsondca1b792007-10-23 09:25:58 -070097esac
98
99dnl Add flags for gcc and g++
100if test "x$GCC" = xyes; then
101 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800102
103 # Work around aliasing bugs - developers should comment this out
104 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700105fi
106if test "x$GXX" = xyes; then
107 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800108
109 # Work around aliasing bugs - developers should comment this out
110 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700111fi
112
113dnl These should be unnecessary, but let the user set them if they want
Dan Nicholson297e16c2008-05-05 15:42:53 -0700114AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700115 Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700116AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
Dan Nicholsondca1b792007-10-23 09:25:58 -0700117 compiler. Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700118AC_SUBST([OPT_FLAGS])
119AC_SUBST([ARCH_FLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700120
121dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600122dnl Hacks to enable 32 or 64 bit build
123dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700124AC_ARG_ENABLE([32-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600125 [AS_HELP_STRING([--enable-32-bit],
126 [build 32-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700127 [enable_32bit="$enableval"],
128 [enable_32bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600129)
130if test "x$enable_32bit" = xyes; then
131 if test "x$GCC" = xyes; then
132 CFLAGS="$CFLAGS -m32"
133 fi
134 if test "x$GXX" = xyes; then
135 CXXFLAGS="$CXXFLAGS -m32"
136 fi
137fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700138AC_ARG_ENABLE([64-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600139 [AS_HELP_STRING([--enable-64-bit],
140 [build 64-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700141 [enable_64bit="$enableval"],
142 [enable_64bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600143)
144if test "x$enable_64bit" = xyes; then
145 if test "x$GCC" = xyes; then
146 CFLAGS="$CFLAGS -m64"
147 fi
148 if test "x$GXX" = xyes; then
149 CXXFLAGS="$CXXFLAGS -m64"
150 fi
151fi
152
153dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800154dnl shared/static libraries, mimic libtool options
155dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700156AC_ARG_ENABLE([static],
Dan Nicholson88586332007-11-15 08:59:57 -0800157 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800158 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700159 [enable_static="$enableval"],
160 [enable_static=no]
Dan Nicholson88586332007-11-15 08:59:57 -0800161)
162case "x$enable_static" in
163xyes|xno ) ;;
164x ) enable_static=no ;;
165* )
166 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
167 ;;
168esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700169AC_ARG_ENABLE([shared],
Dan Nicholson88586332007-11-15 08:59:57 -0800170 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800171 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700172 [enable_shared="$enableval"],
173 [enable_shared=yes]
Dan Nicholson88586332007-11-15 08:59:57 -0800174)
175case "x$enable_shared" in
176xyes|xno ) ;;
177x ) enable_shared=yes ;;
178* )
179 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
180 ;;
181esac
182
183dnl Can't have static and shared libraries, default to static if user
184dnl explicitly requested. If both disabled, set to static since shared
185dnl was explicitly requirested.
186case "x$enable_static$enable_shared" in
187xyesyes )
188 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
189 enable_shared=no
190 ;;
191xnono )
192 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
193 enable_static=yes
194 ;;
195esac
196
197dnl
198dnl mklib options
199dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700200AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
Dan Nicholson88586332007-11-15 08:59:57 -0800201if test "$enable_static" = yes; then
202 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
203fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700204AC_SUBST([MKLIB_OPTIONS])
Dan Nicholson88586332007-11-15 08:59:57 -0800205
Dan Nicholson23656c42007-12-12 09:02:31 -0800206dnl
207dnl other compiler options
208dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700209AC_ARG_ENABLE([debug],
Dan Nicholson23656c42007-12-12 09:02:31 -0800210 [AS_HELP_STRING([--enable-debug],
211 [use debug compiler flags and macros @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700212 [enable_debug="$enableval"],
213 [enable_debug=no]
Dan Nicholson23656c42007-12-12 09:02:31 -0800214)
215if test "x$enable_debug" = xyes; then
216 DEFINES="$DEFINES -DDEBUG"
217 if test "x$GCC" = xyes; then
218 CFLAGS="$CFLAGS -g"
219 fi
220 if test "x$GXX" = xyes; then
221 CXXFLAGS="$CXXFLAGS -g"
222 fi
223fi
Dan Nicholson88586332007-11-15 08:59:57 -0800224
225dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700226dnl library names
227dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800228if test "$enable_static" = yes; then
229 GL_LIB_NAME='lib$(GL_LIB).a'
230 GLU_LIB_NAME='lib$(GLU_LIB).a'
231 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
232 GLW_LIB_NAME='lib$(GLW_LIB).a'
233 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
234else
235 GL_LIB_NAME='lib$(GL_LIB).so'
236 GLU_LIB_NAME='lib$(GLU_LIB).so'
237 GLUT_LIB_NAME='lib$(GLUT_LIB).so'
238 GLW_LIB_NAME='lib$(GLW_LIB).so'
239 OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
240fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700241AC_SUBST([GL_LIB_NAME])
242AC_SUBST([GLU_LIB_NAME])
243AC_SUBST([GLUT_LIB_NAME])
244AC_SUBST([GLW_LIB_NAME])
245AC_SUBST([OSMESA_LIB_NAME])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700246
247dnl
Dan Nicholson871125a2008-06-04 13:00:35 -0700248dnl Arch/platform-specific settings
249dnl
250AC_ARG_ENABLE([asm],
251 [AS_HELP_STRING([--disable-asm],
252 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
253 [enable_asm="$enableval"],
254 [enable_asm=yes]
255)
256asm_arch=""
257ASM_FLAGS=""
258ASM_SOURCES=""
259ASM_API=""
260AC_MSG_CHECKING([whether to enable assembly])
261test "x$enable_asm" = xno && AC_MSG_RESULT([no])
262# disable if cross compiling on x86/x86_64 since we must run gen_matypes
263if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
264 case "$host_cpu" in
265 i?86 | x86_64)
266 enable_asm=no
267 AC_MSG_RESULT([no, cross compiling])
268 ;;
269 esac
270fi
271# check for supported arches
272if test "x$enable_asm" = xyes; then
273 case "$host_cpu" in
274 i?86)
275 case "$host_os" in
276 linux* | freebsd* | dragonfly*)
277 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
278 ;;
279 esac
280 ;;
281 x86_64)
282 case "$host_os" in
283 linux* | freebsd* | dragonfly*)
284 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
285 ;;
286 esac
287 ;;
288 powerpc)
289 case "$host_os" in
290 linux*)
291 asm_arch=ppc
292 ;;
293 esac
294 ;;
295 esac
296
297 case "$asm_arch" in
298 x86)
299 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
300 ASM_SOURCES='$(X86_SOURCES)'
301 ASM_API='$(X86_API)'
302 AC_MSG_RESULT([yes, x86])
303 ;;
304 x86_64)
305 ASM_FLAGS="-DUSE_X86_64_ASM"
306 ASM_SOURCES='$(X86-64_SOURCES)'
307 ASM_API='$(X86-64_API)'
308 AC_MSG_RESULT([yes, x86_64])
309 ;;
310 ppc)
311 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
312 ASM_SOURCES='$(PPC_SOURCES)'
313 AC_MSG_RESULT([yes, ppc])
314 ;;
315 *)
316 AC_MSG_RESULT([no, platform not supported])
317 ;;
318 esac
319fi
320AC_SUBST([ASM_FLAGS])
321AC_SUBST([ASM_SOURCES])
322AC_SUBST([ASM_API])
323
324dnl PIC code macro
325MESA_PIC_FLAGS
326
327dnl Check to see if dlopen is in default libraries (like Solaris, which
328dnl has it in libc), or if libdl is needed to get it.
329AC_CHECK_FUNC([dlopen], [],
330 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
331
Dan Nicholson985e1cd2008-06-04 13:17:06 -0700332dnl See if posix_memalign is available
333AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
334
Dan Nicholson871125a2008-06-04 13:00:35 -0700335dnl SELinux awareness.
336AC_ARG_ENABLE([selinux],
337 [AS_HELP_STRING([--enable-selinux],
338 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
339 [MESA_SELINUX="$enableval"],
340 [MESA_SELINUX=no])
341if test "x$enable_selinux" = "xyes"; then
342 AC_CHECK_HEADER([selinux/selinux.h],[],
343 [AC_MSG_ERROR([SELinux headers not found])])
344 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
345 [AC_MSG_ERROR([SELinux library not found])])
346 SELINUX_LIBS="-lselinux"
347 DEFINES="$DEFINES -DMESA_SELINUX"
348fi
349
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700350dnl OS-specific libraries
351OS_LIBS=""
352case "$host_os" in
353solaris*)
354 OS_LIBS="-lc"
355 if test "x$GXX" != xyes; then
356 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
357 fi
358 ;;
359esac
Dan Nicholson871125a2008-06-04 13:00:35 -0700360
361dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800362dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800363dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800364dnl
Eric Anholt711222b2008-04-18 15:03:01 -0700365default_driver="xlib"
366
367case "$host_os" in
368linux*)
369 case "$host_cpu" in
370 i*86|x86_64|powerpc*) default_driver="dri";;
371 esac
372 ;;
373freebsd* | dragonfly*)
374 case "$host_cpu" in
375 i*86|x86_64) default_driver="dri";;
376 esac
377 ;;
378esac
379
Dan Nicholson297e16c2008-05-05 15:42:53 -0700380AC_ARG_WITH([driver],
Dan Nicholson44d99142007-12-05 18:47:01 -0800381 [AS_HELP_STRING([--with-driver=DRIVER],
Eric Anholt711222b2008-04-18 15:03:01 -0700382 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700383 [mesa_driver="$withval"],
384 [mesa_driver="$default_driver"])
Dan Nicholson44d99142007-12-05 18:47:01 -0800385dnl Check for valid option
386case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800387xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800388 ;;
389*)
390 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
391 ;;
392esac
393
394dnl
395dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700396dnl
397SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700398GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800399WINDOW_SYSTEM=""
400case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800401xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800402 DRIVER_DIRS="x11"
403 ;;
404dri)
405 SRC_DIRS="glx/x11 $SRC_DIRS"
406 DRIVER_DIRS="dri"
407 WINDOW_SYSTEM="dri"
408 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800409osmesa)
410 DRIVER_DIRS="osmesa"
411 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800412esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700413AC_SUBST([SRC_DIRS])
414AC_SUBST([GLU_DIRS])
415AC_SUBST([DRIVER_DIRS])
416AC_SUBST([WINDOW_SYSTEM])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700417
418dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800419dnl User supplied program configuration
420dnl
421if test -d "$srcdir/progs/demos"; then
422 default_demos=yes
423else
424 default_demos=no
425fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700426AC_ARG_WITH([demos],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800427 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
428 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800429 @<:@default=auto if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700430 [with_demos="$withval"],
431 [with_demos="$default_demos"])
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800432if test "x$with_demos" = x; then
433 with_demos=no
434fi
435
436dnl If $with_demos is yes, directories will be added as libs available
437PROGRAM_DIRS=""
438case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700439no) ;;
440yes)
441 # If the driver isn't osmesa, we have libGL and can build xdemos
442 if test "$mesa_driver" != osmesa; then
443 PROGRAM_DIRS="xdemos"
444 fi
445 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800446*)
447 # verify the requested demos directories exist
448 demos=`IFS=,; echo $with_demos`
449 for demo in $demos; do
450 test -d "$srcdir/progs/$demo" || \
451 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
452 done
453 PROGRAM_DIRS="$demos"
454 ;;
455esac
456
457dnl
Dan Nicholsone6a06092008-05-05 15:16:22 -0700458dnl Find out if X is available. The variable have_x is set if libX11 is
459dnl to mimic AC_PATH_XTRA.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700460dnl
461if test -n "$PKG_CONFIG"; then
462 AC_MSG_CHECKING([pkg-config files for X11 are available])
Dan Nicholsone6a06092008-05-05 15:16:22 -0700463 PKG_CHECK_EXISTS([x11],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700464 x11_pkgconfig=yes
465 have_x=yes
Dan Nicholsone6a06092008-05-05 15:16:22 -0700466 ],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700467 x11_pkgconfig=no
Dan Nicholsone6a06092008-05-05 15:16:22 -0700468 ])
469 AC_MSG_RESULT([$x11_pkgconfig])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700470else
471 x11_pkgconfig=no
472fi
473dnl Use the autoconf macro if no pkg-config files
474if test "$x11_pkgconfig" = no; then
475 AC_PATH_XTRA
476fi
477
Dan Nicholson44d99142007-12-05 18:47:01 -0800478dnl We need X for xlib and dri, so bomb now if it's not found
479case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800480xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800481 if test "$no_x" = yes; then
482 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
483 fi
484 ;;
485esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700486
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700487dnl XCB - this is only used for GLX right now
488AC_ARG_ENABLE([xcb],
489 [AS_HELP_STRING([--enable-xcb],
490 [use XCB for GLX @<:@default=disabled@:>@])],
491 [enable_xcb="$enableval"],
492 [enable_xcb=no])
493if test "x$enable_xcb" = xyes; then
494 DEFINES="$DEFINES -DUSE_XCB"
495else
496 enable_xcb=no
497fi
498
Dan Nicholson44d99142007-12-05 18:47:01 -0800499dnl
500dnl libGL configuration per driver
501dnl
502case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800503xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800504 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700505 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
Dan Nicholsona1307182007-12-12 17:49:49 -0800506 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
507 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800508 else
509 # should check these...
510 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
511 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
512 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700513 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800514
515 # if static, move the external libraries to the programs
516 # and empty the libraries for libGL
517 if test "$enable_static" = yes; then
518 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
519 GL_LIB_DEPS=""
520 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800521 ;;
522dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800523 # DRI must be shared, I think
524 if test "$enable_static" = yes; then
525 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
526 fi
527
Dan Nicholson44d99142007-12-05 18:47:01 -0800528 # Check for libdrm
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -0700529 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
530 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
Dan Nicholson44d99142007-12-05 18:47:01 -0800531
532 # find the DRI deps for libGL
533 if test "$x11_pkgconfig" = yes; then
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700534 # add xcb modules if necessary
535 dri_modules="x11 xext xxf86vm xdamage xfixes"
536 if test "$enable_xcb" = yes; then
537 dri_modules="$dri_modules x11-xcb xcb-glx"
538 fi
539
540 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
Dan Nicholson44d99142007-12-05 18:47:01 -0800541 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
542 GL_LIB_DEPS="$DRIGL_LIBS"
543 else
544 # should check these...
545 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
546 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700547
548 # XCB can only be used from pkg-config
549 if test "$enable_xcb" = yes; then
550 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
551 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
552 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
553 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800554 fi
555
556 # need DRM libs, -lpthread, etc.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700557 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800558 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800559osmesa)
560 # No libGL for osmesa
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700561 GL_LIB_DEPS="$OS_LIBS"
Dan Nicholson979ff512007-12-05 18:47:01 -0800562 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800563esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700564AC_SUBST([GL_LIB_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700565
566dnl
567dnl More X11 setup
568dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800569if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700570 DEFINES="$DEFINES -DUSE_XSHM"
571fi
572
573dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800574dnl More DRI setup
575dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700576AC_ARG_ENABLE([glx-tls],
Dan Nicholson44d99142007-12-05 18:47:01 -0800577 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800578 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700579 [GLX_USE_TLS="$enableval"],
580 [GLX_USE_TLS=no])
Dan Nicholson44d99142007-12-05 18:47:01 -0800581dnl Directory for DRI drivers
Dan Nicholson297e16c2008-05-05 15:42:53 -0700582AC_ARG_WITH([dri-driverdir],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800583 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700584 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700585 [DRI_DRIVER_INSTALL_DIR="$withval"],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700586 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700587AC_SUBST([DRI_DRIVER_INSTALL_DIR])
Dan Nicholson44d99142007-12-05 18:47:01 -0800588dnl Direct rendering or just indirect rendering
Dan Nicholson297e16c2008-05-05 15:42:53 -0700589AC_ARG_ENABLE([driglx-direct],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800590 [AS_HELP_STRING([--disable-driglx-direct],
591 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700592 [driglx_direct="$enableval"],
593 [driglx_direct="yes"])
Dave Airlie0b734bd2008-05-28 15:55:44 +1000594dnl ttm support
595AC_ARG_ENABLE([ttm-api],
596 [AS_HELP_STRING([--enable-ttm-api],
Dan Nicholson871125a2008-06-04 13:00:35 -0700597 [enable TTM API users @<:@default=disabled@:>@])],
Dave Airlie0b734bd2008-05-28 15:55:44 +1000598 [ttmapi="$enableval"],
599 [ttmapi="no"])
600
601if test "x$ttmapi" = "xyes"; then
602 save_CFLAGS=$CFLAGS
603 CFLAGS=$LIBDRM_CFLAGS
604 AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
605 CFLAGS=$save_CFLAGS
606fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800607
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800608dnl Which drivers to build - default is chosen by platform
Dan Nicholson297e16c2008-05-05 15:42:53 -0700609AC_ARG_WITH([dri-drivers],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800610 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholson5cae1b72008-06-30 10:28:02 -0700611 [comma delimited DRI drivers list, e.g.
612 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700613 [with_dri_drivers="$withval"],
614 [with_dri_drivers=yes])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800615if test "x$with_dri_drivers" = x; then
616 with_dri_drivers=no
617fi
618
619dnl If $with_dri_drivers is yes, directories will be added through
620dnl platform checks
621DRI_DIRS=""
622case "$with_dri_drivers" in
623no|yes) ;;
624*)
625 # verify the requested driver directories exist
Dan Nicholsone6e4f252008-07-06 14:17:39 -0700626 dri_drivers=`IFS=', '; echo $with_dri_drivers`
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800627 for driver in $dri_drivers; do
628 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
629 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
630 done
631 DRI_DIRS="$dri_drivers"
632 ;;
633esac
634
Dan Nicholson44d99142007-12-05 18:47:01 -0800635dnl Just default to no EGL for now
636USING_EGL=0
Dan Nicholson297e16c2008-05-05 15:42:53 -0700637AC_SUBST([USING_EGL])
Dan Nicholson44d99142007-12-05 18:47:01 -0800638
639dnl Set DRI_DIRS, DEFINES and LIB_DEPS
640if test "$mesa_driver" = dri; then
641 # Use TLS in GLX?
642 if test "x$GLX_USE_TLS" = xyes; then
643 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
644 fi
645
Dave Airlie0b734bd2008-05-28 15:55:44 +1000646 if test "x$ttmapi" = xyes; then
647 DEFINES="$DEFINES -DTTM_API"
648 fi
649
Dan Nicholson44d99142007-12-05 18:47:01 -0800650 if test "x$USING_EGL" = x1; then
651 PROGRAM_DIRS="egl"
652 fi
653
654 # Platform specific settings and drivers to build
655 case "$host_os" in
656 linux*)
657 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
658 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
659 if test "x$driglx_direct" = xyes; then
660 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
661 fi
662
663 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800664 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800665 # ffb, gamma, and sis are missing because they have not be
666 # converted to use the new interface. i810 are missing
667 # because there is no x86-64 system where they could *ever*
668 # be used.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800669 if test "x$DRI_DIRS" = x; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800670 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
George Sapountzis280bf892008-05-11 14:43:40 +0300671 savage tdfx unichrome swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800672 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800673 ;;
674 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800675 # Build only the drivers for cards that exist on PowerPC.
676 # At some point MGA will be added, but not yet.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800677 if test "x$DRI_DIRS" = x; then
George Sapountzis280bf892008-05-11 14:43:40 +0300678 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800679 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800680 ;;
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000681 sparc*)
682 # Build only the drivers for cards that exist on sparc`
683 if test "x$DRI_DIRS" = x; then
Dave Airlie41bdb882008-06-12 16:26:46 +1000684 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000685 fi
686 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800687 esac
688 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700689 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800690 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
691 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
692 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
693 if test "x$driglx_direct" = xyes; then
694 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
695 fi
696 if test "x$GXX" = xyes; then
697 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
698 fi
699
Dan Nicholsona76e2452007-12-07 11:25:08 -0800700 # ffb and gamma are missing because they have not been converted
701 # to use the new interface.
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800702 if test "x$DRI_DIRS" = x; then
703 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
George Sapountzis280bf892008-05-11 14:43:40 +0300704 unichrome savage sis swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800705 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800706 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700707 solaris*)
708 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
709 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
710 if test "x$driglx_direct" = xyes; then
711 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
712 fi
713 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800714 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800715
716 # default drivers
717 if test "x$DRI_DIRS" = x; then
718 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
George Sapountzis280bf892008-05-11 14:43:40 +0300719 savage sis tdfx trident unichrome ffb swrast"
Dan Nicholson112a40e2008-02-21 10:17:19 -0800720 fi
721
Dan Nicholson44d99142007-12-05 18:47:01 -0800722 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
723
724 # Check for expat
725 EXPAT_INCLUDES=""
726 EXPAT_LIB=-lexpat
Dan Nicholson297e16c2008-05-05 15:42:53 -0700727 AC_ARG_WITH([expat],
728 [AS_HELP_STRING([--with-expat=DIR],
729 [expat install directory])],[
Dan Nicholson44d99142007-12-05 18:47:01 -0800730 EXPAT_INCLUDES="-I$withval/include"
731 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
732 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
733 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
734 ])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700735 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
736 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
737 [AC_MSG_ERROR([Expat required for DRI.])])
Dan Nicholson44d99142007-12-05 18:47:01 -0800738
739 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700740 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800741fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700742AC_SUBST([DRI_DIRS])
743AC_SUBST([EXPAT_INCLUDES])
744AC_SUBST([DRI_LIB_DEPS])
Dan Nicholson44d99142007-12-05 18:47:01 -0800745
746dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700747dnl OSMesa configuration
748dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800749if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800750 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800751else
Dan Nicholson544ab202007-12-30 08:41:53 -0800752 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800753fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700754AC_ARG_ENABLE([gl-osmesa],
Dan Nicholson544ab202007-12-30 08:41:53 -0800755 [AS_HELP_STRING([--enable-gl-osmesa],
756 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700757 [gl_osmesa="$enableval"],
758 [gl_osmesa="$default_gl_osmesa"])
Dan Nicholson544ab202007-12-30 08:41:53 -0800759if test "x$gl_osmesa" = xyes; then
760 if test "$mesa_driver" = osmesa; then
761 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800762 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800763 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800764 fi
765fi
766
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800767dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
Dan Nicholson297e16c2008-05-05 15:42:53 -0700768AC_ARG_WITH([osmesa-bits],
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800769 [AS_HELP_STRING([--with-osmesa-bits=BITS],
770 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700771 [osmesa_bits="$withval"],
772 [osmesa_bits=8])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800773if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
774 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
775 osmesa_bits=8
776fi
777case "x$osmesa_bits" in
778x8)
779 OSMESA_LIB=OSMesa
780 ;;
781x16|x32)
782 OSMESA_LIB="OSMesa$osmesa_bits"
783 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
784 ;;
785*)
786 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
787 ;;
788esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700789AC_SUBST([OSMESA_LIB])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800790
Dan Nicholson979ff512007-12-05 18:47:01 -0800791case "$mesa_driver" in
792osmesa)
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700793 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800794 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500795 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800796 else
797 OSMESA_LIB_DEPS=""
798 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800799 OSMESA_MESA_DEPS=""
800 ;;
801*)
802 # Link OSMesa to libGL otherwise
803 OSMESA_LIB_DEPS=""
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700804 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800805 if test "$enable_static" = no; then
806 OSMESA_MESA_DEPS='-l$(GL_LIB)'
807 else
808 OSMESA_MESA_DEPS=""
809 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800810 ;;
811esac
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700812if test "$enable_static" = no; then
813 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
814fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700815AC_SUBST([OSMESA_LIB_DEPS])
816AC_SUBST([OSMESA_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700817
818dnl
819dnl GLU configuration
820dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700821AC_ARG_ENABLE([glu],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800822 [AS_HELP_STRING([--disable-glu],
823 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700824 [enable_glu="$enableval"],
825 [enable_glu=yes])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700826if test "x$enable_glu" = xyes; then
827 SRC_DIRS="$SRC_DIRS glu"
828
Dan Nicholson979ff512007-12-05 18:47:01 -0800829 case "$mesa_driver" in
830 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800831 # If GLU is available and we have libOSMesa (not 16 or 32),
832 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800833 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800834 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
835 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700836
Dan Nicholson979ff512007-12-05 18:47:01 -0800837 # Link libGLU to libOSMesa instead of libGL
838 GLU_LIB_DEPS=""
Dan Nicholson88586332007-11-15 08:59:57 -0800839 if test "$enable_static" = no; then
840 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
841 else
842 GLU_MESA_DEPS=""
843 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800844 ;;
845 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800846 # If static, empty GLU_LIB_DEPS and add libs for programs to link
847 if test "$enable_static" = no; then
848 GLU_LIB_DEPS="-lm"
849 GLU_MESA_DEPS='-l$(GL_LIB)'
850 else
851 GLU_LIB_DEPS=""
852 GLU_MESA_DEPS=""
853 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
854 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800855 ;;
856 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700857fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700858if test "$enable_static" = no; then
859 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
860fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700861AC_SUBST([GLU_LIB_DEPS])
862AC_SUBST([GLU_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700863
864dnl
865dnl GLw configuration
866dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700867AC_ARG_ENABLE([glw],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800868 [AS_HELP_STRING([--disable-glw],
869 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700870 [enable_glw="$enableval"],
871 [enable_glw=yes])
Dan Nicholson979ff512007-12-05 18:47:01 -0800872dnl Don't build GLw on osmesa
873if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
874 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
875 enable_glw=no
876fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700877if test "x$enable_glw" = xyes; then
878 SRC_DIRS="$SRC_DIRS glw"
879 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700880 PKG_CHECK_MODULES([GLW],[x11 xt])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700881 GLW_LIB_DEPS="$GLW_LIBS"
882 else
883 # should check these...
884 GLW_LIB_DEPS="$X_LIBS -lX11 -lXt"
885 fi
886
Dan Nicholson88586332007-11-15 08:59:57 -0800887 # If static, empty GLW_LIB_DEPS and add libs for programs to link
888 if test "$enable_static" = no; then
889 GLW_MESA_DEPS='-l$(GL_LIB)'
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700890 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800891 else
892 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
893 GLW_LIB_DEPS=""
894 GLW_MESA_DEPS=""
895 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700896fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700897AC_SUBST([GLW_LIB_DEPS])
898AC_SUBST([GLW_MESA_DEPS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700899
900dnl
901dnl GLUT configuration
902dnl
903if test -f "$srcdir/include/GL/glut.h"; then
904 default_glut=yes
905else
906 default_glut=no
907fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700908AC_ARG_ENABLE([glut],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800909 [AS_HELP_STRING([--disable-glut],
910 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700911 [enable_glut="$enableval"],
912 [enable_glut="$default_glut"])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700913
914dnl Can't build glut if GLU not available
915if test "x$enable_glu$enable_glut" = xnoyes; then
916 AC_MSG_WARN([Disabling glut since GLU is disabled])
917 enable_glut=no
918fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800919dnl Don't build glut on osmesa
920if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
921 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
922 enable_glut=no
923fi
924
Dan Nicholsondca1b792007-10-23 09:25:58 -0700925if test "x$enable_glut" = xyes; then
926 SRC_DIRS="$SRC_DIRS glut/glx"
927 GLUT_CFLAGS=""
928 if test "x$GCC" = xyes; then
929 GLUT_CFLAGS="-fexceptions"
930 fi
931 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700932 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700933 GLUT_LIB_DEPS="$GLUT_LIBS"
934 else
935 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -0800936 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700937 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700938 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700939
940 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800941 if test "$with_demos" = yes; then
942 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
943 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700944
Dan Nicholson88586332007-11-15 08:59:57 -0800945 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
946 if test "$enable_static" = no; then
947 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
948 else
949 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
950 GLUT_LIB_DEPS=""
951 GLUT_MESA_DEPS=""
952 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700953fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700954AC_SUBST([GLUT_LIB_DEPS])
955AC_SUBST([GLUT_MESA_DEPS])
956AC_SUBST([GLUT_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700957
958dnl
959dnl Program library dependencies
960dnl Only libm is added here if necessary as the libraries should
961dnl be pulled in by the linker
962dnl
963if test "x$APP_LIB_DEPS" = x; then
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700964 case "$host_os" in
965 solaris*)
966 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
967 ;;
968 *)
969 APP_LIB_DEPS="-lm"
970 ;;
971 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700972fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700973AC_SUBST([APP_LIB_DEPS])
974AC_SUBST([PROGRAM_DIRS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700975
Dan Nicholsondca1b792007-10-23 09:25:58 -0700976
977dnl Restore LDFLAGS and CPPFLAGS
978LDFLAGS="$_SAVE_LDFLAGS"
979CPPFLAGS="$_SAVE_CPPFLAGS"
980
981dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -0800982AC_CONFIG_FILES([configs/autoconf])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700983
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800984dnl Replace the configs/current symlink
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700985AC_CONFIG_COMMANDS([configs],[
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800986if test -f configs/current || test -L configs/current; then
987 rm -f configs/current
988fi
989ln -s autoconf configs/current
Dan Nicholsone14ebbc2008-05-06 11:28:43 -0700990])
991
992AC_OUTPUT
Dan Nicholsonaab38cf2007-12-11 08:21:51 -0800993
Dan Nicholson9cad8e32007-11-30 08:49:57 -0800994dnl
995dnl Output some configuration info for the user
996dnl
997echo ""
998echo " prefix: $prefix"
999echo " exec_prefix: $exec_prefix"
1000echo " libdir: $libdir"
Dan Nicholson11ac5b22008-07-03 09:17:44 -07001001echo " includedir: $includedir"
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001002
1003dnl Driver info
1004echo ""
1005echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -08001006if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1007 echo " OSMesa: lib$OSMESA_LIB"
1008else
1009 echo " OSMesa: no"
1010fi
1011if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001012 # cleanup the drivers var
1013 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1014 echo " DRI drivers: $dri_dirs"
1015 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dave Airlie0b734bd2008-05-28 15:55:44 +10001016 echo " TTM API support: $ttmapi"
Dan Nicholson544ab202007-12-30 08:41:53 -08001017fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001018
1019dnl Libraries
1020echo ""
1021echo " Shared libs: $enable_shared"
1022echo " Static libs: $enable_static"
1023echo " GLU: $enable_glu"
1024echo " GLw: $enable_glw"
1025echo " glut: $enable_glut"
1026
1027dnl Programs
1028# cleanup the programs var for display
1029program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1030if test "x$program_dirs" = x; then
1031 echo " Demos: no"
1032else
1033 echo " Demos: $program_dirs"
1034fi
1035
Dan Nicholson16a07fb2007-12-12 09:12:15 -08001036dnl Compiler options
1037# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1038cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1039 $SED 's/^ *//;s/ */ /;s/ *$//'`
1040cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1041 $SED 's/^ *//;s/ */ /;s/ *$//'`
1042defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1043echo ""
1044echo " CFLAGS: $cflags"
1045echo " CXXFLAGS: $cxxflags"
1046echo " Macros: $defines"
1047
Dan Nicholsondca1b792007-10-23 09:25:58 -07001048echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -07001049echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001050echo ""