blob: a916af2baafc83becdc9d19c010268c096e8c2a3 [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
Brian44557bf2009-01-10 16:32:32 -070025LIBDRM_REQUIRED=2.4.3
Kristian Høgsberg154a9e52008-12-01 21:44:03 -050026DRI2PROTO_REQUIRED=1.99.3
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -070027
Dan Nicholsondca1b792007-10-23 09:25:58 -070028dnl Check for progs
29AC_PROG_CPP
30AC_PROG_CC
31AC_PROG_CXX
Dan Nicholson297e16c2008-05-05 15:42:53 -070032AC_CHECK_PROGS([MAKE], [gmake make])
33AC_PATH_PROG([MKDEP], [makedepend])
34AC_PATH_PROG([SED], [sed])
Dan Nicholson41b00702007-12-12 08:48:30 -080035
Dan Nicholsonbfb27b52008-06-30 09:40:30 -070036dnl We need a POSIX shell for parts of the build. Assume we have one
37dnl in most cases.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070038case "$host_os" in
39solaris*)
40 # Solaris /bin/sh is too old/non-POSIX compliant
41 AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
Dan Nicholsonbfb27b52008-06-30 09:40:30 -070042 SHELL="$POSIX_SHELL"
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070043 ;;
44esac
45
Dan Nicholsondb7fc632008-03-07 11:48:09 -080046MKDEP_OPTIONS=-fdepend
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050047dnl Ask gcc where it's keeping its secret headers
48if test "x$GCC" = xyes; then
Dan Nicholsona3d223f2009-01-30 10:52:09 -080049 for dir in include include-fixed; do
50 GCC_INCLUDES=`$CC -print-file-name=$dir`
51 if test "x$GCC_INCLUDES" != x && \
52 test "$GCC_INCLUDES" != "$dir" && \
53 test -d "$GCC_INCLUDES"; then
54 MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
55 fi
56 done
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050057fi
Dan Nicholson297e16c2008-05-05 15:42:53 -070058AC_SUBST([MKDEP_OPTIONS])
Kristian Høgsbergbcecea62008-02-25 18:50:26 -050059
Dan Nicholson41b00702007-12-12 08:48:30 -080060dnl Make sure the pkg-config macros are defined
Dan Nicholson297e16c2008-05-05 15:42:53 -070061m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
Dan Nicholson7154d662008-04-30 13:53:37 -070062 m4_errprint([Error: Could not locate the pkg-config autoconf macros.
63 These are usually located in /usr/share/aclocal/pkg.m4. If your
64 macros are in a different location, try setting the environment
65 variable ACLOCAL="aclocal -I/other/macro/dir" before running
66 autoreconf.
67])
68 m4_exit([1])
69])
Dan Nicholsondca1b792007-10-23 09:25:58 -070070PKG_PROG_PKG_CONFIG()
71
72dnl LIB_DIR - library basename
73LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
Dan Nicholson297e16c2008-05-05 15:42:53 -070074AC_SUBST([LIB_DIR])
Dan Nicholsondca1b792007-10-23 09:25:58 -070075
76dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
77_SAVE_LDFLAGS="$LDFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070078AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
79AC_SUBST([EXTRA_LIB_PATH])
Dan Nicholsondca1b792007-10-23 09:25:58 -070080
81dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
82_SAVE_CPPFLAGS="$CPPFLAGS"
Dan Nicholson297e16c2008-05-05 15:42:53 -070083AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
84AC_SUBST([X11_INCLUDES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070085
86dnl Compiler macros
87DEFINES=""
Dan Nicholson297e16c2008-05-05 15:42:53 -070088AC_SUBST([DEFINES])
Dan Nicholsondca1b792007-10-23 09:25:58 -070089case "$host_os" in
Julien Cristau7f7fc3e2009-01-12 16:04:32 +010090*-gnu*)
Dan Nicholson29f603a2009-01-12 11:10:31 -080091 DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
Dan Nicholsondca1b792007-10-23 09:25:58 -070092 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -070093solaris*)
94 DEFINES="$DEFINES -DPTHREADS -DSVR4"
95 ;;
Dan Nicholsondca1b792007-10-23 09:25:58 -070096esac
97
98dnl Add flags for gcc and g++
99if test "x$GCC" = xyes; then
100 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800101
102 # Work around aliasing bugs - developers should comment this out
103 CFLAGS="$CFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700104fi
105if test "x$GXX" = xyes; then
106 CXXFLAGS="$CXXFLAGS -Wall"
Dan Nicholson0c275b62008-01-15 22:52:25 -0800107
108 # Work around aliasing bugs - developers should comment this out
109 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700110fi
111
112dnl These should be unnecessary, but let the user set them if they want
Dan Nicholson297e16c2008-05-05 15:42:53 -0700113AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700114 Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700115AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
Dan Nicholsondca1b792007-10-23 09:25:58 -0700116 compiler. Default is to use CFLAGS.])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700117AC_SUBST([OPT_FLAGS])
118AC_SUBST([ARCH_FLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700119
120dnl
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600121dnl Hacks to enable 32 or 64 bit build
122dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700123AC_ARG_ENABLE([32-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600124 [AS_HELP_STRING([--enable-32-bit],
125 [build 32-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700126 [enable_32bit="$enableval"],
127 [enable_32bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600128)
129if test "x$enable_32bit" = xyes; then
130 if test "x$GCC" = xyes; then
131 CFLAGS="$CFLAGS -m32"
132 fi
133 if test "x$GXX" = xyes; then
134 CXXFLAGS="$CXXFLAGS -m32"
135 fi
136fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700137AC_ARG_ENABLE([64-bit],
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600138 [AS_HELP_STRING([--enable-64-bit],
139 [build 64-bit libraries @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700140 [enable_64bit="$enableval"],
141 [enable_64bit=auto]
Dan Nicholsonab57cba2007-12-26 11:12:29 -0600142)
143if test "x$enable_64bit" = xyes; then
144 if test "x$GCC" = xyes; then
145 CFLAGS="$CFLAGS -m64"
146 fi
147 if test "x$GXX" = xyes; then
148 CXXFLAGS="$CXXFLAGS -m64"
149 fi
150fi
151
152dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800153dnl shared/static libraries, mimic libtool options
154dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700155AC_ARG_ENABLE([static],
Dan Nicholson88586332007-11-15 08:59:57 -0800156 [AS_HELP_STRING([--enable-static],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800157 [build static libraries @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700158 [enable_static="$enableval"],
159 [enable_static=no]
Dan Nicholson88586332007-11-15 08:59:57 -0800160)
161case "x$enable_static" in
162xyes|xno ) ;;
163x ) enable_static=no ;;
164* )
165 AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
166 ;;
167esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700168AC_ARG_ENABLE([shared],
Dan Nicholson88586332007-11-15 08:59:57 -0800169 [AS_HELP_STRING([--disable-shared],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800170 [build shared libraries @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700171 [enable_shared="$enableval"],
172 [enable_shared=yes]
Dan Nicholson88586332007-11-15 08:59:57 -0800173)
174case "x$enable_shared" in
175xyes|xno ) ;;
176x ) enable_shared=yes ;;
177* )
178 AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
179 ;;
180esac
181
182dnl Can't have static and shared libraries, default to static if user
183dnl explicitly requested. If both disabled, set to static since shared
184dnl was explicitly requirested.
185case "x$enable_static$enable_shared" in
186xyesyes )
187 AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
188 enable_shared=no
189 ;;
190xnono )
191 AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
192 enable_static=yes
193 ;;
194esac
195
196dnl
197dnl mklib options
198dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700199AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
Dan Nicholson88586332007-11-15 08:59:57 -0800200if test "$enable_static" = yes; then
201 MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
202fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700203AC_SUBST([MKLIB_OPTIONS])
Dan Nicholson88586332007-11-15 08:59:57 -0800204
Dan Nicholson23656c42007-12-12 09:02:31 -0800205dnl
206dnl other compiler options
207dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700208AC_ARG_ENABLE([debug],
Dan Nicholson23656c42007-12-12 09:02:31 -0800209 [AS_HELP_STRING([--enable-debug],
210 [use debug compiler flags and macros @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700211 [enable_debug="$enableval"],
212 [enable_debug=no]
Dan Nicholson23656c42007-12-12 09:02:31 -0800213)
214if test "x$enable_debug" = xyes; then
215 DEFINES="$DEFINES -DDEBUG"
216 if test "x$GCC" = xyes; then
217 CFLAGS="$CFLAGS -g"
218 fi
219 if test "x$GXX" = xyes; then
220 CXXFLAGS="$CXXFLAGS -g"
221 fi
222fi
Dan Nicholson88586332007-11-15 08:59:57 -0800223
224dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700225dnl library names
226dnl
Dan Nicholson88586332007-11-15 08:59:57 -0800227if test "$enable_static" = yes; then
228 GL_LIB_NAME='lib$(GL_LIB).a'
229 GLU_LIB_NAME='lib$(GLU_LIB).a'
230 GLUT_LIB_NAME='lib$(GLUT_LIB).a'
231 GLW_LIB_NAME='lib$(GLW_LIB).a'
232 OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
233else
Siddhartha Chaudhuri1a46c8a2009-02-09 07:58:38 -0700234 case "$host_os" in
235 darwin* )
236 LIB_EXTENSION='dylib' ;;
237 * )
238 LIB_EXTENSION='so' ;;
239 esac
240
241 GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
242 GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
243 GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
244 GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
245 OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
246
247 GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*'
248 GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*'
249 GLUT_LIB_GLOB='lib$(GLUT_LIB).*'${LIB_EXTENSION}'*'
250 GLW_LIB_GLOB='lib$(GLW_LIB).*'${LIB_EXTENSION}'*'
251 OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*'
Dan Nicholson88586332007-11-15 08:59:57 -0800252fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700253AC_SUBST([GL_LIB_NAME])
254AC_SUBST([GLU_LIB_NAME])
255AC_SUBST([GLUT_LIB_NAME])
256AC_SUBST([GLW_LIB_NAME])
257AC_SUBST([OSMESA_LIB_NAME])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700258
Siddhartha Chaudhuri1a46c8a2009-02-09 07:58:38 -0700259AC_SUBST([GL_LIB_GLOB])
260AC_SUBST([GLU_LIB_GLOB])
261AC_SUBST([GLUT_LIB_GLOB])
262AC_SUBST([GLW_LIB_GLOB])
263AC_SUBST([OSMESA_LIB_GLOB])
264
Dan Nicholsondca1b792007-10-23 09:25:58 -0700265dnl
Dan Nicholson871125a2008-06-04 13:00:35 -0700266dnl Arch/platform-specific settings
267dnl
268AC_ARG_ENABLE([asm],
269 [AS_HELP_STRING([--disable-asm],
270 [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
271 [enable_asm="$enableval"],
272 [enable_asm=yes]
273)
274asm_arch=""
275ASM_FLAGS=""
276ASM_SOURCES=""
277ASM_API=""
278AC_MSG_CHECKING([whether to enable assembly])
279test "x$enable_asm" = xno && AC_MSG_RESULT([no])
280# disable if cross compiling on x86/x86_64 since we must run gen_matypes
281if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
282 case "$host_cpu" in
283 i?86 | x86_64)
284 enable_asm=no
285 AC_MSG_RESULT([no, cross compiling])
286 ;;
287 esac
288fi
289# check for supported arches
290if test "x$enable_asm" = xyes; then
291 case "$host_cpu" in
292 i?86)
293 case "$host_os" in
Julien Cristau98fcdf32008-10-28 18:56:05 +0100294 linux* | *freebsd* | dragonfly*)
Dan Nicholson871125a2008-06-04 13:00:35 -0700295 test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
296 ;;
297 esac
298 ;;
299 x86_64)
300 case "$host_os" in
Julien Cristau98fcdf32008-10-28 18:56:05 +0100301 linux* | *freebsd* | dragonfly*)
Dan Nicholson871125a2008-06-04 13:00:35 -0700302 test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
303 ;;
304 esac
305 ;;
306 powerpc)
307 case "$host_os" in
308 linux*)
309 asm_arch=ppc
310 ;;
311 esac
312 ;;
313 esac
314
315 case "$asm_arch" in
316 x86)
317 ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
318 ASM_SOURCES='$(X86_SOURCES)'
319 ASM_API='$(X86_API)'
320 AC_MSG_RESULT([yes, x86])
321 ;;
322 x86_64)
323 ASM_FLAGS="-DUSE_X86_64_ASM"
324 ASM_SOURCES='$(X86-64_SOURCES)'
325 ASM_API='$(X86-64_API)'
326 AC_MSG_RESULT([yes, x86_64])
327 ;;
328 ppc)
329 ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
330 ASM_SOURCES='$(PPC_SOURCES)'
331 AC_MSG_RESULT([yes, ppc])
332 ;;
333 *)
334 AC_MSG_RESULT([no, platform not supported])
335 ;;
336 esac
337fi
338AC_SUBST([ASM_FLAGS])
339AC_SUBST([ASM_SOURCES])
340AC_SUBST([ASM_API])
341
342dnl PIC code macro
343MESA_PIC_FLAGS
344
345dnl Check to see if dlopen is in default libraries (like Solaris, which
346dnl has it in libc), or if libdl is needed to get it.
347AC_CHECK_FUNC([dlopen], [],
348 [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
349
Dan Nicholson985e1cd2008-06-04 13:17:06 -0700350dnl See if posix_memalign is available
351AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
352
Dan Nicholson871125a2008-06-04 13:00:35 -0700353dnl SELinux awareness.
354AC_ARG_ENABLE([selinux],
355 [AS_HELP_STRING([--enable-selinux],
356 [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
357 [MESA_SELINUX="$enableval"],
358 [MESA_SELINUX=no])
359if test "x$enable_selinux" = "xyes"; then
360 AC_CHECK_HEADER([selinux/selinux.h],[],
361 [AC_MSG_ERROR([SELinux headers not found])])
362 AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
363 [AC_MSG_ERROR([SELinux library not found])])
364 SELINUX_LIBS="-lselinux"
365 DEFINES="$DEFINES -DMESA_SELINUX"
366fi
367
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700368dnl OS-specific libraries
369OS_LIBS=""
370case "$host_os" in
371solaris*)
372 OS_LIBS="-lc"
373 if test "x$GXX" != xyes; then
374 OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
375 fi
376 ;;
377esac
Dan Nicholson871125a2008-06-04 13:00:35 -0700378
379dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800380dnl Driver configuration. Options are xlib, dri and osmesa right now.
Dan Nicholson979ff512007-12-05 18:47:01 -0800381dnl More later: directfb, fbdev, ...
Dan Nicholson44d99142007-12-05 18:47:01 -0800382dnl
Eric Anholt711222b2008-04-18 15:03:01 -0700383default_driver="xlib"
384
385case "$host_os" in
386linux*)
387 case "$host_cpu" in
388 i*86|x86_64|powerpc*) default_driver="dri";;
389 esac
390 ;;
Julien Cristau98fcdf32008-10-28 18:56:05 +0100391*freebsd* | dragonfly*)
Eric Anholt711222b2008-04-18 15:03:01 -0700392 case "$host_cpu" in
393 i*86|x86_64) default_driver="dri";;
394 esac
395 ;;
396esac
397
Dan Nicholson297e16c2008-05-05 15:42:53 -0700398AC_ARG_WITH([driver],
Dan Nicholson44d99142007-12-05 18:47:01 -0800399 [AS_HELP_STRING([--with-driver=DRIVER],
Eric Anholt711222b2008-04-18 15:03:01 -0700400 [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700401 [mesa_driver="$withval"],
402 [mesa_driver="$default_driver"])
Dan Nicholson44d99142007-12-05 18:47:01 -0800403dnl Check for valid option
404case "x$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800405xxlib|xdri|xosmesa)
Dan Nicholson44d99142007-12-05 18:47:01 -0800406 ;;
407*)
408 AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
409 ;;
410esac
411
412dnl
413dnl Driver specific build directories
Dan Nicholsondca1b792007-10-23 09:25:58 -0700414dnl
415SRC_DIRS="mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700416GLU_DIRS="sgi"
Dan Nicholson44d99142007-12-05 18:47:01 -0800417WINDOW_SYSTEM=""
418case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800419xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800420 DRIVER_DIRS="x11"
421 ;;
422dri)
423 SRC_DIRS="glx/x11 $SRC_DIRS"
424 DRIVER_DIRS="dri"
425 WINDOW_SYSTEM="dri"
426 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800427osmesa)
428 DRIVER_DIRS="osmesa"
429 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800430esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700431AC_SUBST([SRC_DIRS])
432AC_SUBST([GLU_DIRS])
433AC_SUBST([DRIVER_DIRS])
434AC_SUBST([WINDOW_SYSTEM])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700435
436dnl
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800437dnl User supplied program configuration
438dnl
439if test -d "$srcdir/progs/demos"; then
440 default_demos=yes
441else
442 default_demos=no
443fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700444AC_ARG_WITH([demos],
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800445 [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
446 [optional comma delimited demo directories to build
Dan Nicholsonc79c93c2007-12-12 18:13:04 -0800447 @<:@default=auto if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700448 [with_demos="$withval"],
449 [with_demos="$default_demos"])
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800450if test "x$with_demos" = x; then
451 with_demos=no
452fi
453
454dnl If $with_demos is yes, directories will be added as libs available
455PROGRAM_DIRS=""
456case "$with_demos" in
Dan Nicholsonb9576552008-03-10 14:05:46 -0700457no) ;;
458yes)
459 # If the driver isn't osmesa, we have libGL and can build xdemos
460 if test "$mesa_driver" != osmesa; then
461 PROGRAM_DIRS="xdemos"
462 fi
463 ;;
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800464*)
465 # verify the requested demos directories exist
466 demos=`IFS=,; echo $with_demos`
467 for demo in $demos; do
468 test -d "$srcdir/progs/$demo" || \
469 AC_MSG_ERROR([Program directory '$demo' doesn't exist])
470 done
471 PROGRAM_DIRS="$demos"
472 ;;
473esac
474
475dnl
Dan Nicholsone6a06092008-05-05 15:16:22 -0700476dnl Find out if X is available. The variable have_x is set if libX11 is
Dan Nicholson99803a42008-07-01 09:03:15 -0700477dnl found to mimic AC_PATH_XTRA.
Dan Nicholsondca1b792007-10-23 09:25:58 -0700478dnl
479if test -n "$PKG_CONFIG"; then
480 AC_MSG_CHECKING([pkg-config files for X11 are available])
Dan Nicholsone6a06092008-05-05 15:16:22 -0700481 PKG_CHECK_EXISTS([x11],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700482 x11_pkgconfig=yes
483 have_x=yes
Dan Nicholsone6a06092008-05-05 15:16:22 -0700484 ],[
Dan Nicholsondca1b792007-10-23 09:25:58 -0700485 x11_pkgconfig=no
Dan Nicholsone6a06092008-05-05 15:16:22 -0700486 ])
487 AC_MSG_RESULT([$x11_pkgconfig])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700488else
489 x11_pkgconfig=no
490fi
491dnl Use the autoconf macro if no pkg-config files
492if test "$x11_pkgconfig" = no; then
493 AC_PATH_XTRA
494fi
495
Dan Nicholson99803a42008-07-01 09:03:15 -0700496dnl Try to tell the user that the --x-* options are only used when
497dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
498m4_divert_once([HELP_BEGIN],
499[These options are only used when the X libraries cannot be found by the
500pkg-config utility.])
501
Dan Nicholson44d99142007-12-05 18:47:01 -0800502dnl We need X for xlib and dri, so bomb now if it's not found
503case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800504xlib|dri)
Dan Nicholson44d99142007-12-05 18:47:01 -0800505 if test "$no_x" = yes; then
506 AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
507 fi
508 ;;
509esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700510
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700511dnl XCB - this is only used for GLX right now
512AC_ARG_ENABLE([xcb],
513 [AS_HELP_STRING([--enable-xcb],
514 [use XCB for GLX @<:@default=disabled@:>@])],
515 [enable_xcb="$enableval"],
516 [enable_xcb=no])
517if test "x$enable_xcb" = xyes; then
518 DEFINES="$DEFINES -DUSE_XCB"
519else
520 enable_xcb=no
521fi
522
Dan Nicholson44d99142007-12-05 18:47:01 -0800523dnl
524dnl libGL configuration per driver
525dnl
526case "$mesa_driver" in
Dan Nicholsona1307182007-12-12 17:49:49 -0800527xlib)
Dan Nicholson44d99142007-12-05 18:47:01 -0800528 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700529 PKG_CHECK_MODULES([XLIBGL], [x11 xext])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800530 GL_PC_REQ_PRIV="x11 xext"
Dan Nicholsona1307182007-12-12 17:49:49 -0800531 X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
532 GL_LIB_DEPS="$XLIBGL_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800533 else
534 # should check these...
535 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
536 GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
Dan Nicholson71e208b2008-11-24 11:01:57 -0800537 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
538 GL_PC_CFLAGS="$X11_INCLUDES"
Dan Nicholson44d99142007-12-05 18:47:01 -0800539 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700540 GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
Dan Nicholson71e208b2008-11-24 11:01:57 -0800541 GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800542
543 # if static, move the external libraries to the programs
544 # and empty the libraries for libGL
545 if test "$enable_static" = yes; then
546 APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
547 GL_LIB_DEPS=""
548 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800549 ;;
550dri)
Dan Nicholson88586332007-11-15 08:59:57 -0800551 # DRI must be shared, I think
552 if test "$enable_static" = yes; then
553 AC_MSG_ERROR([Can't use static libraries for DRI drivers])
554 fi
555
Dan Nicholson44d99142007-12-05 18:47:01 -0800556 # Check for libdrm
Dan Nicholsoncc77e8f2008-05-05 14:38:22 -0700557 PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
558 PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800559 GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
560 DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
Dan Nicholson44d99142007-12-05 18:47:01 -0800561
562 # find the DRI deps for libGL
563 if test "$x11_pkgconfig" = yes; then
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700564 # add xcb modules if necessary
565 dri_modules="x11 xext xxf86vm xdamage xfixes"
566 if test "$enable_xcb" = yes; then
567 dri_modules="$dri_modules x11-xcb xcb-glx"
568 fi
569
570 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800571 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
Dan Nicholson44d99142007-12-05 18:47:01 -0800572 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
573 GL_LIB_DEPS="$DRIGL_LIBS"
574 else
575 # should check these...
576 X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
577 GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
Dan Nicholson71e208b2008-11-24 11:01:57 -0800578 GL_PC_LIB_PRIV="$GL_LIB_DEPS"
579 GL_PC_CFLAGS="$X11_INCLUDES"
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700580
581 # XCB can only be used from pkg-config
582 if test "$enable_xcb" = yes; then
583 PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800584 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
Dan Nicholson2d709fe2008-05-06 10:51:49 -0700585 X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
586 GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
587 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800588 fi
589
590 # need DRM libs, -lpthread, etc.
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700591 GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
Dan Nicholson71e208b2008-11-24 11:01:57 -0800592 GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS $OS_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800593 ;;
Dan Nicholson979ff512007-12-05 18:47:01 -0800594osmesa)
595 # No libGL for osmesa
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700596 GL_LIB_DEPS="$OS_LIBS"
Dan Nicholson979ff512007-12-05 18:47:01 -0800597 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800598esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700599AC_SUBST([GL_LIB_DEPS])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800600AC_SUBST([GL_PC_REQ_PRIV])
601AC_SUBST([GL_PC_LIB_PRIV])
602AC_SUBST([GL_PC_CFLAGS])
603AC_SUBST([DRI_PC_REQ_PRIV])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700604
605dnl
606dnl More X11 setup
607dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800608if test "$mesa_driver" = xlib; then
Dan Nicholsondca1b792007-10-23 09:25:58 -0700609 DEFINES="$DEFINES -DUSE_XSHM"
610fi
611
612dnl
Dan Nicholson44d99142007-12-05 18:47:01 -0800613dnl More DRI setup
614dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700615AC_ARG_ENABLE([glx-tls],
Dan Nicholson44d99142007-12-05 18:47:01 -0800616 [AS_HELP_STRING([--enable-glx-tls],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800617 [enable TLS support in GLX @<:@default=disabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700618 [GLX_USE_TLS="$enableval"],
619 [GLX_USE_TLS=no])
Dan Nicholson44d99142007-12-05 18:47:01 -0800620dnl Directory for DRI drivers
Dan Nicholson297e16c2008-05-05 15:42:53 -0700621AC_ARG_WITH([dri-driverdir],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800622 [AS_HELP_STRING([--with-dri-driverdir=DIR],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700623 [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700624 [DRI_DRIVER_INSTALL_DIR="$withval"],
Dan Nicholson5dbbde52008-05-06 06:21:41 -0700625 [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700626AC_SUBST([DRI_DRIVER_INSTALL_DIR])
Dan Nicholson44d99142007-12-05 18:47:01 -0800627dnl Direct rendering or just indirect rendering
Dan Nicholson297e16c2008-05-05 15:42:53 -0700628AC_ARG_ENABLE([driglx-direct],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800629 [AS_HELP_STRING([--disable-driglx-direct],
630 [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700631 [driglx_direct="$enableval"],
632 [driglx_direct="yes"])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800633dnl Which drivers to build - default is chosen by platform
Dan Nicholson297e16c2008-05-05 15:42:53 -0700634AC_ARG_WITH([dri-drivers],
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800635 [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
Dan Nicholson5cae1b72008-06-30 10:28:02 -0700636 [comma delimited DRI drivers list, e.g.
637 "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700638 [with_dri_drivers="$withval"],
639 [with_dri_drivers=yes])
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800640if test "x$with_dri_drivers" = x; then
641 with_dri_drivers=no
642fi
643
644dnl If $with_dri_drivers is yes, directories will be added through
645dnl platform checks
646DRI_DIRS=""
647case "$with_dri_drivers" in
Florent Thoumieb5095ab2008-07-28 14:44:43 +0100648no) ;;
649yes)
650 DRI_DIRS="yes"
651 ;;
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800652*)
653 # verify the requested driver directories exist
Dan Nicholsone6e4f252008-07-06 14:17:39 -0700654 dri_drivers=`IFS=', '; echo $with_dri_drivers`
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800655 for driver in $dri_drivers; do
656 test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
657 AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
658 done
659 DRI_DIRS="$dri_drivers"
660 ;;
661esac
662
Dan Nicholson44d99142007-12-05 18:47:01 -0800663dnl Just default to no EGL for now
664USING_EGL=0
Dan Nicholson297e16c2008-05-05 15:42:53 -0700665AC_SUBST([USING_EGL])
Dan Nicholson44d99142007-12-05 18:47:01 -0800666
667dnl Set DRI_DIRS, DEFINES and LIB_DEPS
668if test "$mesa_driver" = dri; then
669 # Use TLS in GLX?
670 if test "x$GLX_USE_TLS" = xyes; then
671 DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
672 fi
673
674 if test "x$USING_EGL" = x1; then
675 PROGRAM_DIRS="egl"
676 fi
677
678 # Platform specific settings and drivers to build
679 case "$host_os" in
680 linux*)
681 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
682 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
683 if test "x$driglx_direct" = xyes; then
684 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
685 fi
686
687 case "$host_cpu" in
Dan Nicholson44d99142007-12-05 18:47:01 -0800688 x86_64)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800689 # ffb, gamma, and sis are missing because they have not be
690 # converted to use the new interface. i810 are missing
691 # because there is no x86-64 system where they could *ever*
692 # be used.
Florent Thoumieb5095ab2008-07-28 14:44:43 +0100693 if test "x$DRI_DIRS" = "xyes"; then
Dan Nicholsona76e2452007-12-07 11:25:08 -0800694 DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
George Sapountzis280bf892008-05-11 14:43:40 +0300695 savage tdfx unichrome swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800696 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800697 ;;
698 powerpc*)
Dan Nicholsona76e2452007-12-07 11:25:08 -0800699 # Build only the drivers for cards that exist on PowerPC.
700 # At some point MGA will be added, but not yet.
Florent Thoumieb5095ab2008-07-28 14:44:43 +0100701 if test "x$DRI_DIRS" = "xyes"; then
George Sapountzis280bf892008-05-11 14:43:40 +0300702 DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800703 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800704 ;;
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000705 sparc*)
706 # Build only the drivers for cards that exist on sparc`
Florent Thoumieb5095ab2008-07-28 14:44:43 +0100707 if test "x$DRI_DIRS" = "xyes"; then
Dave Airlie41bdb882008-06-12 16:26:46 +1000708 DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
Dave Airlie2b0e75e2008-06-12 12:06:50 +1000709 fi
710 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800711 esac
712 ;;
Hasso Tepper9f8df2d2008-04-09 10:51:21 -0700713 freebsd* | dragonfly*)
Dan Nicholson44d99142007-12-05 18:47:01 -0800714 DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
715 DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
716 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
717 if test "x$driglx_direct" = xyes; then
718 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
719 fi
720 if test "x$GXX" = xyes; then
721 CXXFLAGS="$CXXFLAGS -ansi -pedantic"
722 fi
723
Dan Nicholsona76e2452007-12-07 11:25:08 -0800724 # ffb and gamma are missing because they have not been converted
725 # to use the new interface.
Florent Thoumieb5095ab2008-07-28 14:44:43 +0100726 if test "x$DRI_DIRS" = "xyes"; then
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800727 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
George Sapountzis280bf892008-05-11 14:43:40 +0300728 unichrome savage sis swrast"
Dan Nicholsonaf3d2f22007-11-15 08:59:57 -0800729 fi
Dan Nicholson44d99142007-12-05 18:47:01 -0800730 ;;
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700731 solaris*)
732 DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
733 DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
734 if test "x$driglx_direct" = xyes; then
735 DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
736 fi
737 ;;
Dan Nicholson44d99142007-12-05 18:47:01 -0800738 esac
Dan Nicholson112a40e2008-02-21 10:17:19 -0800739
740 # default drivers
Florent Thoumieb5095ab2008-07-28 14:44:43 +0100741 if test "x$DRI_DIRS" = "xyes"; then
Dan Nicholson112a40e2008-02-21 10:17:19 -0800742 DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
George Sapountzis280bf892008-05-11 14:43:40 +0300743 savage sis tdfx trident unichrome ffb swrast"
Dan Nicholson112a40e2008-02-21 10:17:19 -0800744 fi
745
Dan Nicholson44d99142007-12-05 18:47:01 -0800746 DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
747
748 # Check for expat
749 EXPAT_INCLUDES=""
750 EXPAT_LIB=-lexpat
Dan Nicholson297e16c2008-05-05 15:42:53 -0700751 AC_ARG_WITH([expat],
752 [AS_HELP_STRING([--with-expat=DIR],
753 [expat install directory])],[
Dan Nicholson44d99142007-12-05 18:47:01 -0800754 EXPAT_INCLUDES="-I$withval/include"
755 CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
756 LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
757 EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
758 ])
Dan Nicholson297e16c2008-05-05 15:42:53 -0700759 AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
760 AC_CHECK_LIB([expat],[XML_ParserCreate],[],
761 [AC_MSG_ERROR([Expat required for DRI.])])
Dan Nicholson44d99142007-12-05 18:47:01 -0800762
763 # put all the necessary libs together
Eric Anholt050c5332008-03-20 17:28:58 -0700764 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
Dan Nicholson44d99142007-12-05 18:47:01 -0800765fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700766AC_SUBST([DRI_DIRS])
767AC_SUBST([EXPAT_INCLUDES])
768AC_SUBST([DRI_LIB_DEPS])
Dan Nicholson44d99142007-12-05 18:47:01 -0800769
770dnl
Dan Nicholsondca1b792007-10-23 09:25:58 -0700771dnl OSMesa configuration
772dnl
Dan Nicholsona1307182007-12-12 17:49:49 -0800773if test "$mesa_driver" = xlib; then
Dan Nicholson544ab202007-12-30 08:41:53 -0800774 default_gl_osmesa=yes
Dan Nicholson979ff512007-12-05 18:47:01 -0800775else
Dan Nicholson544ab202007-12-30 08:41:53 -0800776 default_gl_osmesa=no
Dan Nicholson44d99142007-12-05 18:47:01 -0800777fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700778AC_ARG_ENABLE([gl-osmesa],
Dan Nicholson544ab202007-12-30 08:41:53 -0800779 [AS_HELP_STRING([--enable-gl-osmesa],
780 [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700781 [gl_osmesa="$enableval"],
782 [gl_osmesa="$default_gl_osmesa"])
Dan Nicholson544ab202007-12-30 08:41:53 -0800783if test "x$gl_osmesa" = xyes; then
784 if test "$mesa_driver" = osmesa; then
785 AC_MSG_ERROR([libGL is not available for OSMesa driver])
Dan Nicholson979ff512007-12-05 18:47:01 -0800786 else
Dan Nicholson544ab202007-12-30 08:41:53 -0800787 DRIVER_DIRS="$DRIVER_DIRS osmesa"
Dan Nicholson979ff512007-12-05 18:47:01 -0800788 fi
789fi
790
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800791dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
Dan Nicholson297e16c2008-05-05 15:42:53 -0700792AC_ARG_WITH([osmesa-bits],
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800793 [AS_HELP_STRING([--with-osmesa-bits=BITS],
794 [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700795 [osmesa_bits="$withval"],
796 [osmesa_bits=8])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800797if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
798 AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
799 osmesa_bits=8
800fi
801case "x$osmesa_bits" in
802x8)
803 OSMESA_LIB=OSMesa
804 ;;
805x16|x32)
806 OSMESA_LIB="OSMesa$osmesa_bits"
807 DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
808 ;;
809*)
810 AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
811 ;;
812esac
Dan Nicholson297e16c2008-05-05 15:42:53 -0700813AC_SUBST([OSMESA_LIB])
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800814
Dan Nicholson979ff512007-12-05 18:47:01 -0800815case "$mesa_driver" in
816osmesa)
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700817 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800818 if test "$enable_static" = no; then
Adam Jackson66611f22008-02-15 13:49:12 -0500819 OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800820 else
821 OSMESA_LIB_DEPS=""
822 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800823 OSMESA_MESA_DEPS=""
Dan Nicholson8be02fc2008-12-14 09:35:29 -0800824 OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS"
Dan Nicholson979ff512007-12-05 18:47:01 -0800825 ;;
826*)
827 # Link OSMesa to libGL otherwise
828 OSMESA_LIB_DEPS=""
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700829 # only link libraries with osmesa if shared
Dan Nicholson88586332007-11-15 08:59:57 -0800830 if test "$enable_static" = no; then
831 OSMESA_MESA_DEPS='-l$(GL_LIB)'
832 else
833 OSMESA_MESA_DEPS=""
834 fi
Dan Nicholson8be02fc2008-12-14 09:35:29 -0800835 OSMESA_PC_REQ="gl"
Dan Nicholson979ff512007-12-05 18:47:01 -0800836 ;;
837esac
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700838if test "$enable_static" = no; then
839 OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
840fi
Dan Nicholson8be02fc2008-12-14 09:35:29 -0800841OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV $OS_LIBS"
Dan Nicholson297e16c2008-05-05 15:42:53 -0700842AC_SUBST([OSMESA_LIB_DEPS])
843AC_SUBST([OSMESA_MESA_DEPS])
Dan Nicholson8be02fc2008-12-14 09:35:29 -0800844AC_SUBST([OSMESA_PC_REQ])
845AC_SUBST([OSMESA_PC_LIB_PRIV])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700846
847dnl
848dnl GLU configuration
849dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700850AC_ARG_ENABLE([glu],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800851 [AS_HELP_STRING([--disable-glu],
852 [enable OpenGL Utility library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700853 [enable_glu="$enableval"],
854 [enable_glu=yes])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700855if test "x$enable_glu" = xyes; then
856 SRC_DIRS="$SRC_DIRS glu"
857
Dan Nicholson979ff512007-12-05 18:47:01 -0800858 case "$mesa_driver" in
859 osmesa)
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800860 # If GLU is available and we have libOSMesa (not 16 or 32),
861 # we can build the osdemos
Dan Nicholson8e4d1472007-11-15 08:59:57 -0800862 if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
Dan Nicholson6689f9e2007-12-05 21:04:15 -0800863 PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
864 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700865
Dan Nicholson979ff512007-12-05 18:47:01 -0800866 # Link libGLU to libOSMesa instead of libGL
867 GLU_LIB_DEPS=""
Dan Nicholson8be02fc2008-12-14 09:35:29 -0800868 GLU_PC_REQ="osmesa"
Dan Nicholson88586332007-11-15 08:59:57 -0800869 if test "$enable_static" = no; then
870 GLU_MESA_DEPS='-l$(OSMESA_LIB)'
871 else
872 GLU_MESA_DEPS=""
873 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800874 ;;
875 *)
Dan Nicholson88586332007-11-15 08:59:57 -0800876 # If static, empty GLU_LIB_DEPS and add libs for programs to link
Dan Nicholson71e208b2008-11-24 11:01:57 -0800877 GLU_PC_REQ="gl"
878 GLU_PC_LIB_PRIV="-lm"
Dan Nicholson88586332007-11-15 08:59:57 -0800879 if test "$enable_static" = no; then
880 GLU_LIB_DEPS="-lm"
881 GLU_MESA_DEPS='-l$(GL_LIB)'
882 else
883 GLU_LIB_DEPS=""
884 GLU_MESA_DEPS=""
885 APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
886 fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800887 ;;
888 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -0700889fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700890if test "$enable_static" = no; then
891 GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
892fi
Dan Nicholson71e208b2008-11-24 11:01:57 -0800893GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
Dan Nicholson297e16c2008-05-05 15:42:53 -0700894AC_SUBST([GLU_LIB_DEPS])
895AC_SUBST([GLU_MESA_DEPS])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800896AC_SUBST([GLU_PC_REQ])
897AC_SUBST([GLU_PC_REQ_PRIV])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800898AC_SUBST([GLU_PC_LIB_PRIV])
899AC_SUBST([GLU_PC_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700900
901dnl
902dnl GLw configuration
903dnl
Dan Nicholson297e16c2008-05-05 15:42:53 -0700904AC_ARG_ENABLE([glw],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800905 [AS_HELP_STRING([--disable-glw],
906 [enable Xt/Motif widget library @<:@default=enabled@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700907 [enable_glw="$enableval"],
908 [enable_glw=yes])
Dan Nicholson979ff512007-12-05 18:47:01 -0800909dnl Don't build GLw on osmesa
910if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
911 AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
912 enable_glw=no
913fi
Dan Nicholson776c60d2008-07-18 07:40:41 -0700914AC_ARG_ENABLE([motif],
915 [AS_HELP_STRING([--enable-motif],
916 [use Motif widgets in GLw @<:@default=disabled@:>@])],
917 [enable_motif="$enableval"],
918 [enable_motif=no])
919
Dan Nicholsondca1b792007-10-23 09:25:58 -0700920if test "x$enable_glw" = xyes; then
921 SRC_DIRS="$SRC_DIRS glw"
922 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -0700923 PKG_CHECK_MODULES([GLW],[x11 xt])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800924 GLW_PC_REQ_PRIV="x11 xt"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700925 GLW_LIB_DEPS="$GLW_LIBS"
926 else
927 # should check these...
Dan Nicholson776c60d2008-07-18 07:40:41 -0700928 GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
Dan Nicholson71e208b2008-11-24 11:01:57 -0800929 GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
930 GLW_PC_CFLAGS="$X11_INCLUDES"
Dan Nicholson776c60d2008-07-18 07:40:41 -0700931 fi
932
933 GLW_SOURCES="GLwDrawA.c"
934 MOTIF_CFLAGS=
935 if test "x$enable_motif" = xyes; then
936 GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
937 AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
938 if test "x$MOTIF_CONFIG" != xno; then
939 MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
940 MOTIF_LIBS=`$MOTIF_CONFIG --libs`
941 else
942 AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
943 [AC_MSG_ERROR([Can't locate Motif headers])])
944 AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
945 [AC_MSG_ERROR([Can't locate Motif Xm library])])
946 fi
947 # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
948 GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
Dan Nicholson71e208b2008-11-24 11:01:57 -0800949 GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
950 GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
Dan Nicholsondca1b792007-10-23 09:25:58 -0700951 fi
952
Dan Nicholson88586332007-11-15 08:59:57 -0800953 # If static, empty GLW_LIB_DEPS and add libs for programs to link
Dan Nicholson71e208b2008-11-24 11:01:57 -0800954 GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800955 if test "$enable_static" = no; then
956 GLW_MESA_DEPS='-l$(GL_LIB)'
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -0700957 GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
Dan Nicholson88586332007-11-15 08:59:57 -0800958 else
959 APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
960 GLW_LIB_DEPS=""
961 GLW_MESA_DEPS=""
962 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -0700963fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700964AC_SUBST([GLW_LIB_DEPS])
965AC_SUBST([GLW_MESA_DEPS])
Dan Nicholson776c60d2008-07-18 07:40:41 -0700966AC_SUBST([GLW_SOURCES])
967AC_SUBST([MOTIF_CFLAGS])
Dan Nicholson71e208b2008-11-24 11:01:57 -0800968AC_SUBST([GLW_PC_REQ_PRIV])
969AC_SUBST([GLW_PC_LIB_PRIV])
970AC_SUBST([GLW_PC_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700971
972dnl
973dnl GLUT configuration
974dnl
975if test -f "$srcdir/include/GL/glut.h"; then
976 default_glut=yes
977else
978 default_glut=no
979fi
Dan Nicholson297e16c2008-05-05 15:42:53 -0700980AC_ARG_ENABLE([glut],
Dan Nicholson79ad4582007-12-07 19:11:01 -0800981 [AS_HELP_STRING([--disable-glut],
982 [enable GLUT library @<:@default=enabled if source available@:>@])],
Dan Nicholson297e16c2008-05-05 15:42:53 -0700983 [enable_glut="$enableval"],
984 [enable_glut="$default_glut"])
Dan Nicholsondca1b792007-10-23 09:25:58 -0700985
986dnl Can't build glut if GLU not available
987if test "x$enable_glu$enable_glut" = xnoyes; then
988 AC_MSG_WARN([Disabling glut since GLU is disabled])
989 enable_glut=no
990fi
Dan Nicholson979ff512007-12-05 18:47:01 -0800991dnl Don't build glut on osmesa
992if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
993 AC_MSG_WARN([Disabling glut since the driver is OSMesa])
994 enable_glut=no
995fi
996
Dan Nicholsondca1b792007-10-23 09:25:58 -0700997if test "x$enable_glut" = xyes; then
998 SRC_DIRS="$SRC_DIRS glut/glx"
999 GLUT_CFLAGS=""
1000 if test "x$GCC" = xyes; then
1001 GLUT_CFLAGS="-fexceptions"
1002 fi
1003 if test "$x11_pkgconfig" = yes; then
Dan Nicholson297e16c2008-05-05 15:42:53 -07001004 PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
Dan Nicholson71e208b2008-11-24 11:01:57 -08001005 GLUT_PC_REQ_PRIV="x11 xmu xi"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001006 GLUT_LIB_DEPS="$GLUT_LIBS"
1007 else
1008 # should check these...
Dan Nicholson70d0c832007-12-07 11:12:20 -08001009 GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
Dan Nicholson71e208b2008-11-24 11:01:57 -08001010 GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
1011 GLUT_PC_CFLAGS="$X11_INCLUDES"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001012 fi
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -07001013 GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
Dan Nicholson71e208b2008-11-24 11:01:57 -08001014 GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm $OS_LIBS"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001015
1016 # If glut is available, we can build most programs
Dan Nicholson8e4d1472007-11-15 08:59:57 -08001017 if test "$with_demos" = yes; then
1018 PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
1019 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -07001020
Dan Nicholson88586332007-11-15 08:59:57 -08001021 # If static, empty GLUT_LIB_DEPS and add libs for programs to link
1022 if test "$enable_static" = no; then
1023 GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
1024 else
1025 APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
1026 GLUT_LIB_DEPS=""
1027 GLUT_MESA_DEPS=""
1028 fi
Dan Nicholsondca1b792007-10-23 09:25:58 -07001029fi
Dan Nicholson297e16c2008-05-05 15:42:53 -07001030AC_SUBST([GLUT_LIB_DEPS])
1031AC_SUBST([GLUT_MESA_DEPS])
1032AC_SUBST([GLUT_CFLAGS])
Dan Nicholson71e208b2008-11-24 11:01:57 -08001033AC_SUBST([GLUT_PC_REQ_PRIV])
1034AC_SUBST([GLUT_PC_LIB_PRIV])
1035AC_SUBST([GLUT_PC_CFLAGS])
Dan Nicholsondca1b792007-10-23 09:25:58 -07001036
1037dnl
1038dnl Program library dependencies
1039dnl Only libm is added here if necessary as the libraries should
1040dnl be pulled in by the linker
1041dnl
1042if test "x$APP_LIB_DEPS" = x; then
Alan Coopersmithe1f9adc2008-06-20 17:58:53 -07001043 case "$host_os" in
1044 solaris*)
1045 APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
1046 ;;
1047 *)
1048 APP_LIB_DEPS="-lm"
1049 ;;
1050 esac
Dan Nicholsondca1b792007-10-23 09:25:58 -07001051fi
Dan Nicholson297e16c2008-05-05 15:42:53 -07001052AC_SUBST([APP_LIB_DEPS])
1053AC_SUBST([PROGRAM_DIRS])
Dan Nicholsondca1b792007-10-23 09:25:58 -07001054
Dan Nicholsondca1b792007-10-23 09:25:58 -07001055
1056dnl Restore LDFLAGS and CPPFLAGS
1057LDFLAGS="$_SAVE_LDFLAGS"
1058CPPFLAGS="$_SAVE_CPPFLAGS"
1059
1060dnl Substitute the config
Dan Nicholsonf64d6fe2007-12-12 17:57:45 -08001061AC_CONFIG_FILES([configs/autoconf])
Dan Nicholsondca1b792007-10-23 09:25:58 -07001062
Dan Nicholsonaab38cf2007-12-11 08:21:51 -08001063dnl Replace the configs/current symlink
Dan Nicholsone14ebbc2008-05-06 11:28:43 -07001064AC_CONFIG_COMMANDS([configs],[
Dan Nicholsonaab38cf2007-12-11 08:21:51 -08001065if test -f configs/current || test -L configs/current; then
1066 rm -f configs/current
1067fi
1068ln -s autoconf configs/current
Dan Nicholsone14ebbc2008-05-06 11:28:43 -07001069])
1070
1071AC_OUTPUT
Dan Nicholsonaab38cf2007-12-11 08:21:51 -08001072
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001073dnl
1074dnl Output some configuration info for the user
1075dnl
1076echo ""
1077echo " prefix: $prefix"
1078echo " exec_prefix: $exec_prefix"
1079echo " libdir: $libdir"
Dan Nicholson11ac5b22008-07-03 09:17:44 -07001080echo " includedir: $includedir"
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001081
1082dnl Driver info
1083echo ""
1084echo " Driver: $mesa_driver"
Dan Nicholson544ab202007-12-30 08:41:53 -08001085if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
1086 echo " OSMesa: lib$OSMESA_LIB"
1087else
1088 echo " OSMesa: no"
1089fi
1090if test "$mesa_driver" = dri; then
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001091 # cleanup the drivers var
1092 dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
Florent Thoumieb5095ab2008-07-28 14:44:43 +01001093if test "x$DRI_DIRS" = x; then
1094 echo " DRI drivers: no"
1095else
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001096 echo " DRI drivers: $dri_dirs"
Florent Thoumieb5095ab2008-07-28 14:44:43 +01001097fi
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001098 echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
Dan Nicholson544ab202007-12-30 08:41:53 -08001099fi
RALOVICH, Kristóf5f19f5c2008-11-04 11:53:32 +01001100echo " Use XCB: $enable_xcb"
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001101
1102dnl Libraries
1103echo ""
1104echo " Shared libs: $enable_shared"
1105echo " Static libs: $enable_static"
1106echo " GLU: $enable_glu"
Dan Nicholson776c60d2008-07-18 07:40:41 -07001107echo " GLw: $enable_glw (Motif: $enable_motif)"
Dan Nicholson9cad8e32007-11-30 08:49:57 -08001108echo " glut: $enable_glut"
1109
1110dnl Programs
1111# cleanup the programs var for display
1112program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1113if test "x$program_dirs" = x; then
1114 echo " Demos: no"
1115else
1116 echo " Demos: $program_dirs"
1117fi
1118
Dan Nicholson16a07fb2007-12-12 09:12:15 -08001119dnl Compiler options
1120# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
1121cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1122 $SED 's/^ *//;s/ */ /;s/ *$//'`
1123cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
1124 $SED 's/^ *//;s/ */ /;s/ *$//'`
1125defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/ */ /;s/ *$//'`
1126echo ""
1127echo " CFLAGS: $cflags"
1128echo " CXXFLAGS: $cxxflags"
1129echo " Macros: $defines"
1130
Dan Nicholsondca1b792007-10-23 09:25:58 -07001131echo ""
Dan Nicholsonb6459422008-03-24 10:01:50 -07001132echo " Run '${MAKE-make}' to build Mesa"
Dan Nicholsondca1b792007-10-23 09:25:58 -07001133echo ""