configure.ac 82.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
dnl Copyright © 2011-2014 Intel Corporation
dnl Copyright © 2011-2014 Emil Velikov <emil.l.velikov@gmail.com>
dnl Copyright © 2007-2010 Dan Nicholson
dnl Copyright © 2010-2014 Marek Olšák <maraeo@gmail.com>
dnl Copyright © 2010-2014 Christian König
dnl Copyright © 2012-2014 Tom Stellard <tstellar@gmail.com>
dnl Copyright © 2009-2012 Jakob Bornecrantz
dnl Copyright © 2009-2014 Jon TURNEY
dnl Copyright © 2011-2012 Benjamin Franzke
dnl Copyright © 2008-2014 David Airlie
dnl Copyright © 2009-2013 Brian Paul
Carl Worth's avatar
Carl Worth committed
12
dnl Copyright © 2003-2007 Keith Packard, Daniel Stone
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice (including the next
dnl paragraph) shall be included in all copies or substantial portions of the
dnl Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl
33
dnl Process this file with autoconf to create configure.
34

35
AC_PREREQ([2.60])
36

37 38 39 40
dnl Tell the user about autoconf.html in the --help output
m4_divert_once([HELP_END], [
See docs/autoconf.html for more details on the options for Mesa.])

41 42
m4_define(MESA_VERSION, m4_normalize(m4_include(VERSION)))
AC_INIT([Mesa], [MESA_VERSION],
43
    [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
44
AC_CONFIG_AUX_DIR([bin])
45
AC_CONFIG_MACRO_DIR([m4])
46
AC_CANONICAL_SYSTEM
47
AM_INIT_AUTOMAKE([foreign tar-ustar dist-xz subdir-objects])
48

49 50 51 52 53 54 55
dnl We only support native Windows builds (MinGW/MSVC) through SCons.
case "$host_os" in
mingw*)
    AC_MSG_ERROR([MinGW build not supported through autoconf/automake, use SCons instead])
    ;;
esac

56 57 58
# Support silent build rules, requires at least automake-1.11. Disable
# by either passing --disable-silent-rules to configure or passing V=1
# to make
59 60
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
61

62 63
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

Johannes Obermayr's avatar
Johannes Obermayr committed
64 65 66
dnl Set internal versions
OSMESA_VERSION=8
AC_SUBST([OSMESA_VERSION])
67 68
OPENCL_VERSION=1
AC_SUBST([OPENCL_VERSION])
Johannes Obermayr's avatar
Johannes Obermayr committed
69

70
dnl Versions for external dependencies
71
LIBDRM_REQUIRED=2.4.60
72
LIBDRM_RADEON_REQUIRED=2.4.56
73
LIBDRM_AMDGPU_REQUIRED=2.4.63
74
LIBDRM_INTEL_REQUIRED=2.4.61
75
LIBDRM_NVVIEUX_REQUIRED=2.4.33
76
LIBDRM_NOUVEAU_REQUIRED=2.4.62
77
LIBDRM_FREEDRENO_REQUIRED=2.4.64
78
DRI2PROTO_REQUIRED=2.6
Keith Packard's avatar
Keith Packard committed
79 80 81
DRI3PROTO_REQUIRED=1.0
PRESENTPROTO_REQUIRED=1.0
LIBUDEV_REQUIRED=151
82
GLPROTO_REQUIRED=1.4.14
83
LIBOMXIL_BELLAGIO_REQUIRED=0.0
84
LIBVA_REQUIRED=0.35.0
85
VDPAU_REQUIRED=1.1
86
WAYLAND_REQUIRED=1.2.0
87
XCB_REQUIRED=1.9.3
88 89 90 91
XCBDRI2_REQUIRED=1.8
XCBGLX_REQUIRED=1.8.1
XSHMFENCE_REQUIRED=1.1
XVMC_REQUIRED=1.0.6
92
PYTHON_MAKO_REQUIRED=0.3.4
93

94 95 96 97
dnl Check for progs
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CXX
98
AM_PROG_CC_C_O
99
AM_PROG_AS
100
AX_CHECK_GNU_MAKE
101
AC_CHECK_PROGS([PYTHON2], [python2 python])
Matt Turner's avatar
Matt Turner committed
102
AC_PROG_SED
103
AC_PROG_MKDIR_P
104

105 106
AC_SYS_LARGEFILE

107 108 109
LT_PREREQ([2.2])
LT_INIT([disable-static])

Matt Turner's avatar
Matt Turner committed
110
AX_PROG_BISON([],
111
              AS_IF([test ! -f "$srcdir/src/glsl/glcpp/glcpp-parse.c"],
Matt Turner's avatar
Matt Turner committed
112
                    [AC_MSG_ERROR([bison not found - unable to compile glcpp-parse.y])]))
Matt Turner's avatar
Matt Turner committed
113
AX_PROG_FLEX([],
114
             AS_IF([test ! -f "$srcdir/src/glsl/glcpp/glcpp-lex.c"],
Matt Turner's avatar
Matt Turner committed
115
                   [AC_MSG_ERROR([flex not found - unable to compile glcpp-lex.l])]))
116

117 118
AC_CHECK_PROG(INDENT, indent, indent, cat)
if test "x$INDENT" != "xcat"; then
119 120 121 122 123 124 125
    # Only GNU indent is supported
    INDENT_VERSION=`indent --version | grep GNU`
    if test $? -eq 0; then
       AC_SUBST(INDENT_FLAGS, '-i4 -nut -br -brs -npcs -ce -TGLubyte -TGLbyte -TBool')
    else
       INDENT="cat"
    fi
126 127
fi

128
AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED)
129 130 131 132 133 134 135 136 137 138 139

if test -z "$PYTHON2"; then
    if test ! -f "$srcdir/src/util/format_srgb.c"; then
        AC_MSG_ERROR([Python not found - unable to generate sources])
    fi
else
    if test "x$acv_mako_found" = xno; then
        if test ! -f "$srcdir/src/mesa/main/format_unpack.c"; then
            AC_MSG_ERROR([Python mako module v$PYTHON_MAKO_REQUIRED or higher not found])
        fi
    fi
140
fi
141

142 143
AC_PROG_INSTALL

144 145
dnl We need a POSIX shell for parts of the build. Assume we have one
dnl in most cases.
146 147 148 149
case "$host_os" in
solaris*)
    # Solaris /bin/sh is too old/non-POSIX compliant
    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
150
    SHELL="$POSIX_SHELL"
151 152 153
    ;;
esac

nobled's avatar
nobled committed
154 155 156 157 158 159 160 161 162 163
dnl clang is mostly GCC-compatible, but its version is much lower,
dnl so we have to check for it.
AC_MSG_CHECKING([if compiling with clang])

AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
       not clang
#endif
]])],
164
[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])
nobled's avatar
nobled committed
165

166
AC_MSG_RESULT([$acv_mesa_CLANG])
nobled's avatar
nobled committed
167

168
dnl If we're using GCC, make sure that it is at least version 4.2.0.  Older
Ian Romanick's avatar
Ian Romanick committed
169
dnl versions are explictly not supported.
170
GEN_ASM_OFFSETS=no
171
USE_GNU99=no
172
if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
Ian Romanick's avatar
Ian Romanick committed
173 174 175 176 177 178
    AC_MSG_CHECKING([whether gcc version is sufficient])
    major=0
    minor=0

    GCC_VERSION=`$CC -dumpversion`
    if test $? -eq 0; then
Tom Stellard's avatar
Tom Stellard committed
179 180
        GCC_VERSION_MAJOR=`echo $GCC_VERSION | cut -d. -f1`
        GCC_VERSION_MINOR=`echo $GCC_VERSION | cut -d. -f2`
Ian Romanick's avatar
Ian Romanick committed
181 182
    fi

183
    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 2 ; then
Ian Romanick's avatar
Ian Romanick committed
184
        AC_MSG_RESULT([no])
185
        AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
Ian Romanick's avatar
Ian Romanick committed
186 187 188
    else
        AC_MSG_RESULT([yes])
    fi
189

190 191 192
    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 6 ; then
        USE_GNU99=yes
    fi
193 194 195
    if test "x$cross_compiling" = xyes; then
        GEN_ASM_OFFSETS=yes
    fi
Ian Romanick's avatar
Ian Romanick committed
196
fi
197 198 199

dnl Check for compiler builtins
AX_GCC_BUILTIN([__builtin_bswap32])
Tom Stellard's avatar
Tom Stellard committed
200
AX_GCC_BUILTIN([__builtin_bswap64])
201 202 203 204 205 206 207 208 209
AX_GCC_BUILTIN([__builtin_clz])
AX_GCC_BUILTIN([__builtin_clzll])
AX_GCC_BUILTIN([__builtin_ctz])
AX_GCC_BUILTIN([__builtin_expect])
AX_GCC_BUILTIN([__builtin_ffs])
AX_GCC_BUILTIN([__builtin_ffsll])
AX_GCC_BUILTIN([__builtin_popcount])
AX_GCC_BUILTIN([__builtin_popcountll])
AX_GCC_BUILTIN([__builtin_unreachable])
210

211
AX_GCC_FUNC_ATTRIBUTE([const])
212 213
AX_GCC_FUNC_ATTRIBUTE([flatten])
AX_GCC_FUNC_ATTRIBUTE([format])
214
AX_GCC_FUNC_ATTRIBUTE([malloc])
215
AX_GCC_FUNC_ATTRIBUTE([packed])
216
AX_GCC_FUNC_ATTRIBUTE([pure])
217
AX_GCC_FUNC_ATTRIBUTE([unused])
218
AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
219

220
AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes)
Ian Romanick's avatar
Ian Romanick committed
221

222
dnl Make sure the pkg-config macros are defined
223 224 225 226 227
m4_ifndef([PKG_PROG_PKG_CONFIG],
    [m4_fatal([Could not locate the pkg-config autoconf macros.
  These are usually located in /usr/share/aclocal/pkg.m4. If your macros
  are in a different location, try setting the environment variable
  ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
228 229 230 231
PKG_PROG_PKG_CONFIG()

dnl LIB_DIR - library basename
LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
232
AC_SUBST([LIB_DIR])
233

Matt Turner's avatar
Matt Turner committed
234
dnl Cache LDFLAGS and CPPFLAGS so we can add to them and restore later
235 236 237 238
_SAVE_LDFLAGS="$LDFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"

dnl Compiler macros
239
DEFINES="-D__STDC_LIMIT_MACROS"
240
AC_SUBST([DEFINES])
241
case "$host_os" in
Samuel Thibault's avatar
Samuel Thibault committed
242
linux*|*-gnu*|gnu*)
243
    DEFINES="$DEFINES -D_GNU_SOURCE"
244
    ;;
245
solaris*)
246
    DEFINES="$DEFINES -DSVR4"
247
    ;;
248
cygwin*)
249
    DEFINES="$DEFINES -D_XOPEN_SOURCE=700"
250
    ;;
251 252 253 254
esac

dnl Add flags for gcc and g++
if test "x$GCC" = xyes; then
255 256 257 258 259 260 261
    CFLAGS="$CFLAGS -Wall"

    if test "x$USE_GNU99" = xyes; then
	CFLAGS="$CFLAGS -std=gnu99"
    else
	CFLAGS="$CFLAGS -std=c99"
    fi
262 263 264 265 266 267 268 269 270 271 272 273 274

    # Enable -Werror=implicit-function-declaration and
    # -Werror=missing-prototypes, if available, or otherwise, just
    # -Wmissing-prototypes.  This is particularly useful to avoid
    # generating a loadable driver module that has undefined symbols.
    save_CFLAGS="$CFLAGS"
    AC_MSG_CHECKING([whether $CC supports -Werror=missing-prototypes])
    CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
    CFLAGS="$CFLAGS -Werror=missing-prototypes"
    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
		   AC_MSG_RESULT([yes]),
		   [CFLAGS="$save_CFLAGS -Wmissing-prototypes";
		    AC_MSG_RESULT([no])]);
275 276 277

    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CFLAGS="$CFLAGS"
278
    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
279 280
    VISIBILITY_CFLAGS="-fvisibility=hidden"
    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
281
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
282 283 284 285
		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);

    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
    CFLAGS=$save_CFLAGS
286 287 288

    # Work around aliasing bugs - developers should comment this out
    CFLAGS="$CFLAGS -fno-strict-aliasing"
289

290 291
    # We don't want floating-point math functions to set errno or trap
    CFLAGS="$CFLAGS -fno-math-errno -fno-trapping-math"
292

293 294 295
    # gcc's builtin memcmp is slower than glibc's
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
    CFLAGS="$CFLAGS -fno-builtin-memcmp"
296 297 298 299 300 301 302 303

    # Flags to help ensure that certain portions of the code -- and only those
    # portions -- can be built with MSVC:
    # - src/util, src/gallium/auxiliary, and src/gallium/drivers/llvmpipe needs
    #   to build with Windows SDK 7.0.7600, which bundles MSVC 2008
    # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which
    #   supports most of C99)
    # - the rest has no compiler compiler restrictions
304 305 306 307 308 309 310 311 312 313 314 315 316 317
    MSVC2013_COMPAT_CFLAGS="-Werror=pointer-arith"
    MSVC2013_COMPAT_CXXFLAGS="-Werror=pointer-arith"

    # Enable -Werror=vla if compiler supports it
    save_CFLAGS="$CFLAGS"
    AC_MSG_CHECKING([whether $CC supports -Werror=vla])
    CFLAGS="$CFLAGS -Werror=vla"
    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
		   [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=vla";
		    MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=vla";
		    AC_MSG_RESULT([yes])],
		    AC_MSG_RESULT([no]));
    CFLAGS="$save_CFLAGS"

318 319
    MSVC2008_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=declaration-after-statement"
    MSVC2008_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS"
320 321 322
fi
if test "x$GXX" = xyes; then
    CXXFLAGS="$CXXFLAGS -Wall"
323

324 325 326
    # Enable -fvisibility=hidden if using a gcc that supports it
    save_CXXFLAGS="$CXXFLAGS"
    AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
327 328
    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
    CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
329
    AC_LANG_PUSH([C++])
330
    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
331
		   [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
332
    AC_LANG_POP([C++])
333 334 335

    # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
    CXXFLAGS=$save_CXXFLAGS
336

337 338
    # Work around aliasing bugs - developers should comment this out
    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
339 340 341 342

    # gcc's builtin memcmp is slower than glibc's
    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
    CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp"
343 344
fi

345 346 347 348 349
AC_SUBST([MSVC2013_COMPAT_CFLAGS])
AC_SUBST([MSVC2013_COMPAT_CXXFLAGS])
AC_SUBST([MSVC2008_COMPAT_CFLAGS])
AC_SUBST([MSVC2008_COMPAT_CXXFLAGS])

350 351 352 353 354 355 356 357 358
dnl even if the compiler appears to support it, using visibility attributes isn't
dnl going to do anything useful currently on cygwin apart from emit lots of warnings
case "$host_os" in
cygwin*)
    VISIBILITY_CFLAGS=""
    VISIBILITY_CXXFLAGS=""
    ;;
esac

359 360 361
AC_SUBST([VISIBILITY_CFLAGS])
AC_SUBST([VISIBILITY_CXXFLAGS])

362 363 364
dnl
dnl Optional flags, check for compiler support
dnl
365 366 367 368 369 370 371 372
SSE41_CFLAGS="-msse4.1"
dnl Code compiled by GCC with -msse* assumes a 16 byte aligned
dnl stack, but on x86-32 such alignment is not guaranteed.
case "$target_cpu" in
i?86)
    SSE41_CFLAGS="$SSE41_CFLAGS -mstackrealign"
    ;;
esac
373
save_CFLAGS="$CFLAGS"
374
CFLAGS="$SSE41_CFLAGS $CFLAGS"
375 376 377 378 379 380 381 382
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <smmintrin.h>
int main () {
    __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
    c = _mm_max_epu32(a, b);
    return 0;
}]])], SSE41_SUPPORTED=1)
CFLAGS="$save_CFLAGS"
383 384 385
if test "x$SSE41_SUPPORTED" = x1; then
    DEFINES="$DEFINES -DUSE_SSE41"
fi
386
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
387
AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS)
388

389 390
dnl Can't have static and shared libraries, default to static if user
dnl explicitly requested. If both disabled, set to static since shared
391
dnl was explicitly requested.
392
case "x$enable_static$enable_shared" in
393 394 395
xyesyes)
    AC_MSG_WARN([Cannot build static and shared libraries, disabling shared])
    enable_shared=no
396
    ;;
397 398
xnono)
    AC_MSG_WARN([Cannot disable both static and shared libraries, enabling shared])
399
    enable_shared=yes
400 401 402
    ;;
esac

403 404
AM_CONDITIONAL(BUILD_SHARED, test "x$enable_shared" = xyes)

405 406 407
dnl
dnl other compiler options
dnl
408
AC_ARG_ENABLE([debug],
409 410
    [AS_HELP_STRING([--enable-debug],
        [use debug compiler flags and macros @<:@default=disabled@:>@])],
411 412
    [enable_debug="$enableval"],
    [enable_debug=no]
413 414 415 416
)
if test "x$enable_debug" = xyes; then
    DEFINES="$DEFINES -DDEBUG"
    if test "x$GCC" = xyes; then
417 418 419 420 421 422
        if ! echo "$CFLAGS" | grep -q -e '-g'; then
            CFLAGS="$CFLAGS -g"
        fi
        if ! echo "$CFLAGS" | grep -q -e '-O'; then
            CFLAGS="$CFLAGS -O0"
        fi
423 424
    fi
    if test "x$GXX" = xyes; then
425 426 427 428 429 430
        if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
            CXXFLAGS="$CXXFLAGS -g"
        fi
        if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
            CXXFLAGS="$CXXFLAGS -O0"
        fi
431
    fi
432 433
else
   DEFINES="$DEFINES -DNDEBUG"
434
fi
435

Jon TURNEY's avatar
Jon TURNEY committed
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
dnl
dnl Check if linker supports -Bsymbolic
dnl
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
AC_MSG_CHECKING([if ld supports -Bsymbolic])
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([int main() { return 0;}])],
    [AC_MSG_RESULT([yes])
        BSYMBOLIC="-Wl,-Bsymbolic";],
    [AC_MSG_RESULT([no])
        BSYMBOLIC="";])
LDFLAGS=$save_LDFLAGS

AC_SUBST([BSYMBOLIC])

452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
dnl
dnl Check if linker supports garbage collection
dnl
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--gc-sections"
AC_MSG_CHECKING([whether ld supports --gc-sections])
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([static char UnusedFunc() { return 5; } int main() { return 0;}])],
    [AC_MSG_RESULT([yes])
        GC_SECTIONS="-Wl,--gc-sections";],
    [AC_MSG_RESULT([no])
        GC_SECTIONS="";])
LDFLAGS=$save_LDFLAGS

AC_SUBST([GC_SECTIONS])

468 469 470 471 472
dnl
dnl OpenBSD does not have DT_NEEDED entries for libc by design
dnl so when these flags are passed to ld via libtool the checks will fail
dnl
case "$host_os" in
473
openbsd* | darwin* )
474 475 476 477 478 479 480
    LD_NO_UNDEFINED="" ;;
*)
    LD_NO_UNDEFINED="-Wl,--no-undefined" ;;
esac

AC_SUBST([LD_NO_UNDEFINED])

Jon TURNEY's avatar
Jon TURNEY committed
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
dnl
dnl Check if linker supports version scripts
dnl
AC_MSG_CHECKING([if the linker supports version-scripts])
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
cat > conftest.map <<EOF
VERSION_1 {
     global:
         main;

     local:
         *;
};
EOF
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([int main() { return 0;}])],
    [have_ld_version_script=yes;AC_MSG_RESULT(yes)],
    [have_ld_version_script=no; AC_MSG_RESULT(no)])
LDFLAGS=$save_LDFLAGS
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")

503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
dnl
dnl Check if linker supports dynamic list files
dnl
AC_MSG_CHECKING([if the linker supports --dynamic-list])
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--dynamic-list=conftest.dyn"
cat > conftest.dyn <<EOF
{
	radeon_drm_winsys_create;
};
EOF
AC_LINK_IFELSE(
    [AC_LANG_SOURCE([int main() { return 0;}])],
    [have_ld_dynamic_list=yes;AC_MSG_RESULT(yes)],
    [have_ld_dynamic_list=no; AC_MSG_RESULT(no)])
LDFLAGS=$save_LDFLAGS
AM_CONDITIONAL(HAVE_LD_DYNAMIC_LIST, test "$have_ld_dynamic_list" = "yes")

521 522 523 524 525 526 527 528 529 530 531 532
dnl
dnl compatibility symlinks
dnl
case "$host_os" in
linux* )
    HAVE_COMPAT_SYMLINKS=yes ;;
* )
    HAVE_COMPAT_SYMLINKS=no ;;
esac

AM_CONDITIONAL(HAVE_COMPAT_SYMLINKS, test "x$HAVE_COMPAT_SYMLINKS" = xyes)

533 534 535
dnl
dnl library names
dnl
536 537 538 539 540 541 542 543 544
dnl Unfortunately we need to do a few things that libtool can't help us with,
dnl so we need some knowledge of shared library filenames:
dnl
dnl LIB_EXT is the extension used when creating symlinks for alternate
dnl filenames for a shared library which will be dynamically loaded
dnl
dnl IMP_LIB_EXT is the extension used when checking for the presence of a
dnl the file for a shared library we wish to link with
dnl
545 546
case "$host_os" in
darwin* )
547 548 549
    LIB_EXT='dylib'
    IMP_LIB_EXT=$LIB_EXT
    ;;
550
cygwin* )
551 552 553
    LIB_EXT='dll'
    IMP_LIB_EXT='dll.a'
    ;;
554
aix* )
555 556 557
    LIB_EXT='a'
    IMP_LIB_EXT=$LIB_EXT
    ;;
558
* )
559 560 561
    LIB_EXT='so'
    IMP_LIB_EXT=$LIB_EXT
    ;;
562
esac
563 564 565

AC_SUBST([LIB_EXT])

566 567 568 569 570 571 572 573 574 575 576 577
AC_ARG_WITH([gl-lib-name],
  [AS_HELP_STRING([--with-gl-lib-name@<:@=NAME@:>@],
    [specify GL library name @<:@default=GL@:>@])],
  [GL_LIB=$withval],
  [GL_LIB=GL])
AC_ARG_WITH([osmesa-lib-name],
  [AS_HELP_STRING([--with-osmesa-lib-name@<:@=NAME@:>@],
    [specify OSMesa library name @<:@default=OSMesa@:>@])],
  [OSMESA_LIB=$withval],
  [OSMESA_LIB=OSMesa])
AS_IF([test "x$GL_LIB" = xyes], [GL_LIB=GL])
AS_IF([test "x$OSMESA_LIB" = xyes], [OSMESA_LIB=OSMesa])
578

579 580 581 582 583 584 585 586 587 588 589
dnl
dnl Mangled Mesa support
dnl
AC_ARG_ENABLE([mangling],
  [AS_HELP_STRING([--enable-mangling],
    [enable mangled symbols and library name @<:@default=disabled@:>@])],
  [enable_mangling="${enableval}"],
  [enable_mangling=no]
)
if test "x${enable_mangling}" = "xyes" ; then
  DEFINES="${DEFINES} -DUSE_MGL_NAMESPACE"
590 591
  GL_LIB="Mangled${GL_LIB}"
  OSMESA_LIB="Mangled${OSMESA_LIB}"
592 593 594 595
fi
AC_SUBST([GL_LIB])
AC_SUBST([OSMESA_LIB])

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
dnl
dnl potentially-infringing-but-nobody-knows-for-sure stuff
dnl
AC_ARG_ENABLE([texture-float],
    [AS_HELP_STRING([--enable-texture-float],
        [enable floating-point textures and renderbuffers @<:@default=disabled@:>@])],
    [enable_texture_float="$enableval"],
    [enable_texture_float=no]
)
if test "x$enable_texture_float" = xyes; then
    AC_MSG_WARN([Floating-point textures enabled.])
    AC_MSG_WARN([Please consult docs/patents.txt with your lawyer before building Mesa.])
    DEFINES="$DEFINES -DTEXTURE_FLOAT_ENABLED"
fi

611 612 613 614 615 616 617 618 619 620 621 622 623
dnl
dnl Arch/platform-specific settings
dnl
AC_ARG_ENABLE([asm],
    [AS_HELP_STRING([--disable-asm],
        [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
    [enable_asm="$enableval"],
    [enable_asm=yes]
)
asm_arch=""
AC_MSG_CHECKING([whether to enable assembly])
test "x$enable_asm" = xno && AC_MSG_RESULT([no])
# disable if cross compiling on x86/x86_64 since we must run gen_matypes
624
if test "x$enable_asm" = xyes -a "x$cross_compiling" = xyes; then
625
    case "$host_cpu" in
626
    i?86 | x86_64 | amd64)
627 628 629 630 631 632 633 634 635 636
        enable_asm=no
        AC_MSG_RESULT([no, cross compiling])
        ;;
    esac
fi
# check for supported arches
if test "x$enable_asm" = xyes; then
    case "$host_cpu" in
    i?86)
        case "$host_os" in
637
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | gnu*)
638 639
            asm_arch=x86
            ;;
640 641
        esac
        ;;
642
    x86_64|amd64)
643
        case "$host_os" in
Jonathan Gray's avatar
Jonathan Gray committed
644
        linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*)
645
            asm_arch=x86_64
646 647 648
            ;;
        esac
        ;;
649 650 651 652 653 654 655
    sparc*)
        case "$host_os" in
        linux*)
            asm_arch=sparc
            ;;
        esac
        ;;
656 657 658 659
    esac

    case "$asm_arch" in
    x86)
660
        DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
661 662
        AC_MSG_RESULT([yes, x86])
        ;;
663
    x86_64|amd64)
664
        DEFINES="$DEFINES -DUSE_X86_64_ASM"
665 666
        AC_MSG_RESULT([yes, x86_64])
        ;;
667
    sparc)
668
        DEFINES="$DEFINES -DUSE_SPARC_ASM"
669 670
        AC_MSG_RESULT([yes, sparc])
        ;;
671 672 673 674 675 676
    *)
        AC_MSG_RESULT([no, platform not supported])
        ;;
    esac
fi

677
AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
678
AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
679
AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
680
AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
681

682 683
dnl Check to see if dlopen is in default libraries (like Solaris, which
dnl has it in libc), or if libdl is needed to get it.
684 685 686
AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
    [AC_CHECK_LIB([dl], [dlopen],
       [DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])])
Chia-I Wu's avatar
Chia-I Wu committed
687
AC_SUBST([DLOPEN_LIBS])
688

689
dnl Check if that library also has dladdr
690 691 692 693
save_LIBS="$LIBS"
LIBS="$LIBS $DLOPEN_LIBS"
AC_CHECK_FUNCS([dladdr])
LIBS="$save_LIBS"
694

695
case "$host_os" in
696
darwin*)
697 698 699 700
    ;;
*)
    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
                   [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
701
                                 [AC_MSG_ERROR([Could not find clock_gettime])])])
702 703 704
    AC_SUBST([CLOCK_LIB])
    ;;
esac
705

706 707 708
dnl See if posix_memalign is available
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])

709
dnl Check for pthreads
710 711 712 713
AX_PTHREAD
if test "x$ax_pthread_ok" = xno; then
    AC_MSG_ERROR([Building mesa on this platform requires pthreads])
fi
714 715 716 717
dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS
dnl to -pthread, which causes problems if we need -lpthread to appear in
dnl pkgconfig files.
test -z "$PTHREAD_LIBS" && PTHREAD_LIBS="-lpthread"
718

719 720 721 722 723 724 725
dnl SELinux awareness.
AC_ARG_ENABLE([selinux],
    [AS_HELP_STRING([--enable-selinux],
        [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
    [MESA_SELINUX="$enableval"],
    [MESA_SELINUX=no])
if test "x$enable_selinux" = "xyes"; then
726 727 728 729 730 731
    PKG_CHECK_MODULES([SELINUX], [libselinux], [],
        [AC_CHECK_HEADER([selinux/selinux.h],[],
                         [AC_MSG_ERROR([SELinux headers not found])])
         AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
                      [AC_MSG_ERROR([SELinux library not found])])
         SELINUX_LIBS="-lselinux"])
732 733
    DEFINES="$DEFINES -DMESA_SELINUX"
fi
734
AC_SUBST([SELINUX_CFLAGS])
735
AC_SUBST([SELINUX_LIBS])
736

737
dnl Options for APIs
738 739
AC_ARG_ENABLE([opengl],
    [AS_HELP_STRING([--disable-opengl],
740
        [disable support for standard OpenGL API @<:@default=enabled@:>@])],
741 742 743
    [enable_opengl="$enableval"],
    [enable_opengl=yes])
AC_ARG_ENABLE([gles1],
744 745
    [AS_HELP_STRING([--disable-gles1],
        [disable support for OpenGL ES 1.x API @<:@default=enabled@:>@])],
746
    [enable_gles1="$enableval"],
747
    [enable_gles1=yes])
748
AC_ARG_ENABLE([gles2],
749 750
    [AS_HELP_STRING([--disable-gles2],
        [disable support for OpenGL ES 2.x API @<:@default=enabled@:>@])],
751
    [enable_gles2="$enableval"],
752
    [enable_gles2=yes])
753 754 755

AC_ARG_ENABLE([dri],
    [AS_HELP_STRING([--enable-dri],
756
        [enable DRI modules @<:@default=enabled@:>@])],
757
    [enable_dri="$enableval"],
758
    [enable_dri=yes])
759 760 761 762 763 764 765 766 767

case "$host_os" in
linux*)
    dri3_default=yes
    ;;
*)
    dri3_default=no
    ;;
esac
768 769
AC_ARG_ENABLE([dri3],
    [AS_HELP_STRING([--enable-dri3],
770
        [enable DRI3 @<:@default=auto@:>@])],
771
    [enable_dri3="$enableval"],
772
    [enable_dri3="$dri3_default"])
773 774
AC_ARG_ENABLE([glx],
    [AS_HELP_STRING([--enable-glx],
775
        [enable GLX library @<:@default=enabled@:>@])],
776
    [enable_glx="$enableval"],
777
    [enable_glx=yes])
778 779
AC_ARG_ENABLE([osmesa],
    [AS_HELP_STRING([--enable-osmesa],
780
        [enable OSMesa library @<:@default=disabled@:>@])],
781
    [enable_osmesa="$enableval"],
782
    [enable_osmesa=no])
783 784 785 786 787
AC_ARG_ENABLE([gallium-osmesa],
    [AS_HELP_STRING([--enable-gallium-osmesa],
        [enable Gallium implementation of the OSMesa library @<:@default=disabled@:>@])],
    [enable_gallium_osmesa="$enableval"],
    [enable_gallium_osmesa=no])
788 789 790 791 792 793
AC_ARG_ENABLE([egl],
    [AS_HELP_STRING([--disable-egl],
        [disable EGL library @<:@default=enabled@:>@])],
    [enable_egl="$enableval"],
    [enable_egl=yes])

Thomas Hellstrom's avatar
Thomas Hellstrom committed
794 795
AC_ARG_ENABLE([xa],
    [AS_HELP_STRING([--enable-xa],
796
        [enable build of the XA X Acceleration API @<:@default=disabled@:>@])],
Thomas Hellstrom's avatar
Thomas Hellstrom committed
797 798
    [enable_xa="$enableval"],
    [enable_xa=no])
799 800 801 802 803
AC_ARG_ENABLE([gbm],
   [AS_HELP_STRING([--enable-gbm],
         [enable gbm library @<:@default=auto@:>@])],
   [enable_gbm="$enableval"],
   [enable_gbm=auto])
804 805 806 807 808
AC_ARG_ENABLE([nine],
    [AS_HELP_STRING([--enable-nine],
        [enable build of the nine Direct3D9 API @<:@default=no@:>@])],
    [enable_nine="$enableval"],
    [enable_nine=no])
809

810 811 812 813
AC_ARG_ENABLE([xvmc],
   [AS_HELP_STRING([--enable-xvmc],
         [enable xvmc library @<:@default=auto@:>@])],
   [enable_xvmc="$enableval"],
814
   [enable_xvmc=auto])
815 816 817 818 819
AC_ARG_ENABLE([vdpau],
   [AS_HELP_STRING([--enable-vdpau],
         [enable vdpau library @<:@default=auto@:>@])],
   [enable_vdpau="$enableval"],
   [enable_vdpau=auto])
820 821
AC_ARG_ENABLE([omx],
   [AS_HELP_STRING([--enable-omx],
822
         [enable OpenMAX library @<:@default=disabled@:>@])],
823 824
   [enable_omx="$enableval"],
   [enable_omx=no])
825 826 827 828 829
AC_ARG_ENABLE([va],
   [AS_HELP_STRING([--enable-va],
         [enable va library @<:@default=auto@:>@])],
   [enable_va="$enableval"],
   [enable_va=auto])
830 831
AC_ARG_ENABLE([opencl],
   [AS_HELP_STRING([--enable-opencl],
832
         [enable OpenCL library @<:@default=disabled@:>@])],
833
   [enable_opencl="$enableval"],
834
   [enable_opencl=no])
835 836 837
AC_ARG_ENABLE([opencl_icd],
   [AS_HELP_STRING([--enable-opencl-icd],
          [Build an OpenCL ICD library to be loaded by an ICD implementation
838
           @<:@default=disabled@:>@])],
839 840
    [enable_opencl_icd="$enableval"],
    [enable_opencl_icd=no])
841
AC_ARG_ENABLE([xlib-glx],
842
    [AS_HELP_STRING([--enable-xlib-glx],
843
        [make GLX library Xlib-based instead of DRI-based @<:@default=disabled@:>@])],
844
    [enable_xlib_glx="$enableval"],
845
    [enable_xlib_glx=no])
846

847
AC_ARG_ENABLE([r600-llvm-compiler],
848
    [AS_HELP_STRING([--enable-r600-llvm-compiler],
849
        [Enable experimental LLVM backend for graphics shaders @<:@default=disabled@:>@])],
850 851 852
    [enable_r600_llvm="$enableval"],
    [enable_r600_llvm=no])

853
AC_ARG_ENABLE([gallium-tests],
854
    [AS_HELP_STRING([--enable-gallium-tests],
855
        [Enable optional Gallium tests) @<:@default=disabled@:>@])],
856 857 858
    [enable_gallium_tests="$enableval"],
    [enable_gallium_tests=no])

859
# Option for Gallium drivers
860 861

# Keep this in sync with the --with-gallium-drivers help string default value
862
GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
863 864 865 866

AC_ARG_WITH([gallium-drivers],
    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
        [comma delimited Gallium drivers list, e.g.
867
        "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4"
868
        @<:@default=r300,r600,svga,swrast@:>@])],
869 870
    [with_gallium_drivers="$withval"],
    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
871

872 873 874 875 876 877 878
# Doing '--without-gallium-drivers' will set this variable to 'no'.  Clear it
# here so that the script doesn't choke on an unknown driver name later.
case "$with_gallium_drivers" in
    yes) with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT" ;;
    no) with_gallium_drivers='' ;;
esac

879 880 881
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xno -a \
        "x$enable_gles2" = xno -a \
882
        "x$enable_nine" = xno -a \
Thomas Hellstrom's avatar
Thomas Hellstrom committed
883
        "x$enable_xa" = xno -a \
884 885
        "x$enable_xvmc" = xno -a \
        "x$enable_vdpau" = xno -a \
886
        "x$enable_omx" = xno -a \
887
        "x$enable_va" = xno -a \
888
        "x$enable_opencl" = xno; then
889 890 891
    AC_MSG_ERROR([at least one API should be enabled])
fi

892 893 894 895 896 897 898 899 900 901 902
# Building OpenGL ES1 and/or ES2 without OpenGL is not supported on mesa 9.0.x
if test "x$enable_opengl" = xno -a \
        "x$enable_gles1" = xyes; then
    AC_MSG_ERROR([Building OpenGL ES1 without OpenGL is not supported])
fi

if test "x$enable_opengl" = xno -a \
        "x$enable_gles2" = xyes; then
    AC_MSG_ERROR([Building OpenGL ES2 without OpenGL is not supported])
fi

Matt Turner's avatar
Matt Turner committed
903 904 905 906 907 908 909
AM_CONDITIONAL(HAVE_OPENGL, test "x$enable_opengl" = xyes)
AM_CONDITIONAL(HAVE_OPENGL_ES1, test "x$enable_gles1" = xyes)
AM_CONDITIONAL(HAVE_OPENGL_ES2, test "x$enable_gles2" = xyes)
AM_CONDITIONAL(NEED_OPENGL_COMMON, test "x$enable_opengl" = xyes -o \
                                        "x$enable_gles1" = xyes -o \
                                        "x$enable_gles2" = xyes)

910 911 912
if test "x$enable_glx" = xno; then
    AC_MSG_WARN([GLX disabled, disabling Xlib-GLX])
    enable_xlib_glx=no
913 914
fi

915 916
if test "x$enable_dri$enable_xlib_glx" = xyesyes; then
    AC_MSG_ERROR([DRI and Xlib-GLX cannot be built together])
917 918
fi

919 920 921 922 923 924 925 926 927 928
if test "x$enable_opengl$enable_xlib_glx" = xnoyes; then
    AC_MSG_ERROR([Xlib-GLX cannot be built without OpenGL])
fi

# Disable GLX if OpenGL is not enabled
if test "x$enable_glx$enable_opengl" = xyesno; then
    AC_MSG_WARN([OpenGL not enabled, disabling GLX])
    enable_glx=no
fi

929
# Disable GLX if DRI and Xlib-GLX are not enabled
930
if test "x$enable_glx" = xyes -a \
931
        "x$enable_dri" = xno -a \
932
        "x$enable_xlib_glx" = xno; then
933
    AC_MSG_WARN([Neither DRI nor Xlib-GLX enabled, disabling GLX])
934
    enable_glx=no
935
fi
936

Matt Turner's avatar
Matt Turner committed
937
AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xyes -a \
938
                                  "x$enable_dri" = xyes)
939

940 941 942 943 944 945 946
# Check for libdrm
PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
                  [have_libdrm=yes], [have_libdrm=no])
if test "x$have_libdrm" = xyes; then
	DEFINES="$DEFINES -DHAVE_LIBDRM"
fi

947 948 949 950
# Select which platform-dependent DRI code gets built
case "$host_os" in
darwin*)
    dri_platform='apple' ;;
951
gnu*|cygwin*)
952 953 954 955 956 957 958
    dri_platform='none' ;;
*)
    dri_platform='drm' ;;
esac

AM_CONDITIONAL(HAVE_DRICOMMON, test "x$enable_dri" = xyes )
AM_CONDITIONAL(HAVE_DRISW, test "x$enable_dri" = xyes )
959 960
AM_CONDITIONAL(HAVE_DRI2, test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes )
AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = xyes )
961
AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xapple )
Matt Turner's avatar
Matt Turner committed
962

963 964
AC_ARG_ENABLE([shared-glapi],
    [AS_HELP_STRING([--enable-shared-glapi],
965
        [Enable shared glapi for OpenGL @<:@default=enabled@:>@])],
966
    [enable_shared_glapi="$enableval"],
967
    [enable_shared_glapi=yes])
968

969 970 971 972 973 974 975 976
case "x$enable_opengl$enable_gles1$enable_gles2" in
x*yes*yes*)
    if test "x$enable_shared_glapi" = xno; then
        AC_MSG_ERROR([shared GLAPI required when building two or more of
                      the following APIs - opengl, gles1 gles2])
    fi
    ;;
esac
977 978 979

AM_CONDITIONAL(HAVE_SHARED_GLAPI, test "x$enable_shared_glapi" = xyes)

980 981 982 983 984
# Build the pipe-drivers as separate libraries/modules.
# Do not touch this unless you know what you are doing.
# XXX: Expose via configure option ?
enable_shared_pipe_drivers=no

985 986
dnl
dnl Driver specific build directories
987
dnl
988

989
if test -n "$with_gallium_drivers" -a "x$enable_glx$enable_xlib_glx" = xyesyes; then
990
    NEED_WINSYS_XLIB="yes"
991
fi
992 993

if test "x$enable_dri" = xyes; then
994
    enable_gallium_loader="$enable_shared_pipe_drivers"
995 996
fi

997
if test "x$enable_gallium_osmesa" = xyes; then
998 999
    if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
        AC_MSG_ERROR([gallium_osmesa requires the gallium swrast driver])
1000 1001 1002 1003
    fi
    if test "x$enable_osmesa" = xyes; then
        AC_MSG_ERROR([Cannot enable both classic and Gallium OSMesa implementations])
    fi
1004 1005
fi

1006
AC_SUBST([MESA_LLVM])
1007

Carl Worth's avatar
Carl Worth committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
# SHA1 hashing
AC_ARG_WITH([sha1],
        [AS_HELP_STRING([--with-sha1=libc|libmd|libnettle|libgcrypt|libcrypto|libsha1|CommonCrypto|CryptoAPI],
        [choose SHA1 implementation])])
case "x$with_sha1" in
x | xlibc | xlibmd | xlibnettle | xlibgcrypt | xlibcrypto | xlibsha1 | xCommonCrypto | xCryptoAPI)
  ;;
*)
        AC_MSG_ERROR([Illegal value for --with-sha1: $with_sha1])
esac

AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
	with_sha1=libc
fi
if test "x$with_sha1" = xlibc && test "x$HAVE_SHA1_IN_LIBC" != xyes; then
	AC_MSG_ERROR([sha1 in libc requested but not found])
fi
if test "x$with_sha1" = xlibc; then
	AC_DEFINE([HAVE_SHA1_IN_LIBC], [1],
		[Use libc SHA1 functions])
	SHA1_LIBS=""
fi
AC_CHECK_FUNC([CC_SHA1_Init], [HAVE_SHA1_IN_COMMONCRYPTO=yes])
if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_COMMONCRYPTO" = xyes; then
	with_sha1=CommonCrypto
fi
if test "x$with_sha1" = xCommonCrypto && test "x$HAVE_SHA1_IN_COMMONCRYPTO" != xyes; then
	AC_MSG_ERROR([CommonCrypto requested but not found])
fi
if test "x$with_sha1" = xCommonCrypto; then
	AC_DEFINE([HAVE_SHA1_IN_COMMONCRYPTO], [1],
		[Use CommonCrypto SHA1 functions])
	SHA1_LIBS=""
fi
dnl stdcall functions cannot be tested with AC_CHECK_LIB
AC_CHECK_HEADER([wincrypt.h], [HAVE_SHA1_IN_CRYPTOAPI=yes], [], [#include <windows.h>])
if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_CRYPTOAPI" = xyes; then
	with_sha1=CryptoAPI
fi
if test "x$with_sha1" = xCryptoAPI && test "x$HAVE_SHA1_IN_CRYPTOAPI" != xyes; then
	AC_MSG_ERROR([CryptoAPI requested but not found])
fi
if test "x$with_sha1" = xCryptoAPI; then
	AC_DEFINE([HAVE_SHA1_IN_CRYPTOAPI], [1],
		[Use CryptoAPI SHA1 functions])
	SHA1_LIBS=""
fi
AC_CHECK_LIB([md], [SHA1Init], [HAVE_LIBMD=yes])
if test "x$with_sha1" = x && test "x$HAVE_LIBMD" = xyes; then
	with_sha1=libmd
fi
if test "x$with_sha1" = xlibmd && test "x$HAVE_LIBMD" != xyes; then
	AC_MSG_ERROR([libmd requested but not found])
fi
if test "x$with_sha1" = xlibmd; then
	AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
	          [Use libmd SHA1 functions])
	SHA1_LIBS=-lmd
fi
PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
   with_sha1=libsha1
fi
if test "x$with_sha1" = xlibsha1 && test "x$HAVE_LIBSHA1" != xyes; then
	AC_MSG_ERROR([libsha1 requested but not found])
fi
if test "x$with_sha1" = xlibsha1; then
	AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1],
	          [Use libsha1 for SHA1])
	SHA1_LIBS=-lsha1
fi
AC_CHECK_LIB([nettle], [nettle_sha1_init], [HAVE_LIBNETTLE=yes])
if test "x$with_sha1" = x && test "x$HAVE_LIBNETTLE" = xyes; then
	with_sha1=libnettle
fi
if test "x$with_sha1" = xlibnettle && test "x$HAVE_LIBNETTLE" != xyes; then
	AC_MSG_ERROR([libnettle requested but not found])
fi
if test "x$with_sha1" = xlibnettle; then
	AC_DEFINE([HAVE_SHA1_IN_LIBNETTLE], [1],
	          [Use libnettle SHA1 functions])
	SHA1_LIBS=-lnettle
fi
AC_CHECK_LIB([gcrypt], [gcry_md_open], [HAVE_LIBGCRYPT=yes])
if test "x$with_sha1" = x && test "x$HAVE_LIBGCRYPT" = xyes; then
	with_sha1=libgcrypt
fi
if test "x$with_sha1" = xlibgcrypt && test "x$HAVE_LIBGCRYPT" != xyes; then
	AC_MSG_ERROR([libgcrypt requested but not found])
fi
if test "x$with_sha1" = xlibgcrypt; then
	AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
	          [Use libgcrypt SHA1 functions])
	SHA1_LIBS=-lgcrypt
fi
# We don't need all of the OpenSSL libraries, just libcrypto
AC_CHECK_LIB([crypto], [SHA1_Init], [HAVE_LIBCRYPTO=yes])
PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
                  [HAVE_OPENSSL_PKC=no])
if test "x$HAVE_LIBCRYPTO" = xyes || test "x$HAVE_OPENSSL_PKC" = xyes; then
	if test "x$with_sha1" = x; then
		with_sha1=libcrypto
	fi
else
	if test "x$with_sha1" = xlibcrypto; then
		AC_MSG_ERROR([OpenSSL libcrypto requested but not found])
	fi
fi
if test "x$with_sha1" = xlibcrypto; then
	if test "x$HAVE_LIBCRYPTO" = xyes; then
		SHA1_LIBS=-lcrypto
	else
		SHA1_LIBS="$OPENSSL_LIBS"
		SHA1_CFLAGS="$OPENSSL_CFLAGS"
	fi
fi
AC_MSG_CHECKING([for SHA1 implementation])
AC_MSG_RESULT([$with_sha1])
AC_SUBST(SHA1_LIBS)
AC_SUBST(SHA1_CFLAGS)

1130 1131 1132 1133 1134
# Enable a define for SHA1
if test "x$with_sha1" != "x"; then
	DEFINES="$DEFINES -DHAVE_SHA1"
fi

1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
# Allow user to configure out the shader-cache feature
AC_ARG_ENABLE([shader-cache],
    AS_HELP_STRING([--disable-shader-cache], [Disable binary shader cache]),
    [enable_shader_cache="$enableval"],
    [if test "x$with_sha1" != "x"; then
        enable_shader_cache=yes
     else
        enable_shader_cache=no
     fi])
if test "x$with_sha1" = "x"; then
    if test "x$enable_shader_cache" = "xyes"; then
        AC_MSG_ERROR([Cannot enable shader cache (no SHA-1 implementation found)])
    fi
fi
AM_CONDITIONAL([ENABLE_SHADER_CACHE], [test x$enable_shader_cache = xyes])

1151 1152
case "$host_os" in
linux*)
1153
    need_pci_id=yes ;;
1154
*)
1155
    need_pci_id=no ;;
1156 1157
esac

1158 1159 1160
PKG_CHECK_MODULES([LIBUDEV], [libudev >= $LIBUDEV_REQUIRED],
                  have_libudev=yes, have_libudev=no)

1161 1162 1163 1164 1165 1166 1167
AC_ARG_ENABLE([sysfs],
    [AS_HELP_STRING([--enable-sysfs],
        [enable /sys PCI identification @<:@default=disabled@:>@])],
    [have_sysfs="$enableval"],
    [have_sysfs=no]
)

Chia-I Wu's avatar
Chia-I Wu committed
1168
if test "x$enable_dri" = xyes; then
1169 1170 1171 1172
    if test "$enable_static" = yes; then
        AC_MSG_ERROR([Cannot use static libraries for DRI drivers])
    fi

1173 1174 1175
    # not a hard requirement as swrast does not depend on it
    if test "x$have_libdrm" = xyes; then
        DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
Chia-I Wu's avatar
Chia-I Wu committed
1176 1177 1178
    fi
fi

1179 1180
AC_ARG_ENABLE([driglx-direct],
    [AS_HELP_STRING([--disable-driglx-direct],
1181
        [disable direct rendering in GLX and EGL for DRI \
nobled's avatar
nobled committed
1182
            @<:@default=auto@:>@])],
1183
    [driglx_direct="$enableval"],
1184
    [driglx_direct="yes"])
1185

1186
dnl
1187
dnl libGL configuration per driver
1188
dnl
1189 1190 1191
case "x$enable_glx$enable_xlib_glx" in
xyesyes)
    # Xlib-based GLX
1192 1193 1194
    dri_modules="x11 xext xcb"
    PKG_CHECK_MODULES([XLIBGL], [$dri_modules])
    GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
1195 1196
    X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
    GL_LIB_DEPS="$XLIBGL_LIBS"