configure: allow C{,XX}FLAGS override
[mesa.git] / configure.ac
index 5a54370b51d28e3cbb55690d5910fb5897dcfa8f..712569444488323df27daea4665ce75d9e04e127 100644 (file)
@@ -17,13 +17,17 @@ AC_INIT([Mesa],[mesa_version],
 AC_CONFIG_AUX_DIR([bin])
 AC_CANONICAL_HOST
 
+dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
+USER_CFLAGS="$CFLAGS"
+USER_CXXFLAGS="$CXXFLAGS"
+
 dnl Versions for external dependencies
 LIBDRM_REQUIRED=2.4.24
 LIBDRM_RADEON_REQUIRED=2.4.24
 LIBDRM_INTEL_REQUIRED=2.4.24
 LIBDRM_NOUVEAU_REQUIRED=0.6
-DRI2PROTO_REQUIRED=2.1
-GLPROTO_REQUIRED=1.4.11
+DRI2PROTO_REQUIRED=2.6
+GLPROTO_REQUIRED=1.4.14
 LIBDRM_XORG_REQUIRED=2.4.24
 LIBKMS_XORG_REQUIRED=1.0.0
 
@@ -85,7 +89,7 @@ if test "x$GCC" = xyes -a "x$CLANG" = xno; then
     GCC_VERSION=`$CC -dumpversion`
     if test $? -eq 0; then
         major=`echo $GCC_VERSION | cut -d. -f1`
-        minor=`echo $GCC_VERSION | cut -d. -f1`
+        minor=`echo $GCC_VERSION | cut -d. -f2`
     fi
 
     if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then
@@ -570,6 +574,11 @@ AC_ARG_ENABLE([xorg],
         [enable support for X.Org DDX API @<:@default=no@:>@])],
     [enable_xorg="$enableval"],
     [enable_xorg=no])
+AC_ARG_ENABLE([xa],
+    [AS_HELP_STRING([--enable-xa],
+        [enable build of the XA X Acceleration API @<:@default=no@:>@])],
+    [enable_xa="$enableval"],
+    [enable_xa=no])
 AC_ARG_ENABLE([d3d1x],
     [AS_HELP_STRING([--enable-d3d1x],
         [enable support for Direct3D 10 & 11 low-level API @<:@default=no@:>@])],
@@ -581,6 +590,22 @@ AC_ARG_ENABLE([gbm],
    [enable_gbm="$enableval"],
    [enable_gbm=auto])
 
+AC_ARG_ENABLE([xvmc],
+   [AS_HELP_STRING([--enable-xvmc],
+         [enable xvmc library @<:@default=auto@:>@])],
+   [enable_xvmc="$enableval"],
+   [enable_xvmc=auto])
+AC_ARG_ENABLE([vdpau],
+   [AS_HELP_STRING([--enable-vdpau],
+         [enable vdpau library @<:@default=auto@:>@])],
+   [enable_vdpau="$enableval"],
+   [enable_vdpau=auto])
+AC_ARG_ENABLE([va],
+   [AS_HELP_STRING([--enable-va],
+         [enable va library @<:@default=auto@:>@])],
+   [enable_va="$enableval"],
+   [enable_va=auto])
+
 AC_ARG_ENABLE([xlib_glx],
     [AS_HELP_STRING([--enable-xlib-glx],
         [make GLX library Xlib-based instead of DRI-based @<:@default=disable@:>@])],
@@ -597,9 +622,9 @@ AC_ARG_ENABLE([gallium_gbm],
     [AS_HELP_STRING([--enable-gallium-gbm],
         [enable optional gbm state tracker (not required for
          gbm support in Gallium)
-         @<:@default=disable@:>@])],
+         @<:@default=auto@:>@])],
     [enable_gallium_gbm="$enableval"],
-    [enable_gallium_gbm=no])
+    [enable_gallium_gbm=auto])
 
 # Option for Gallium drivers
 GALLIUM_DRIVERS_DEFAULT="r300,r600,swrast"
@@ -612,12 +637,23 @@ AC_ARG_WITH([gallium-drivers],
     [with_gallium_drivers="$withval"],
     [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
 
+# 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
+
 if test "x$enable_opengl" = xno -a \
         "x$enable_gles1" = xno -a \
         "x$enable_gles2" = xno -a \
         "x$enable_openvg" = xno -a \
         "x$enable_xorg" = xno -a \
-        "x$enable_d3d1x" = xno; then
+        "x$enable_xa" = xno -a \
+        "x$enable_d3d1x" = xno -a \
+        "x$enable_xvmc" = xno -a \
+        "x$enable_vdpau" = xno -a \
+        "x$enable_va" = xno; then
     AC_MSG_ERROR([at least one API should be enabled])
 fi
 
@@ -737,7 +773,7 @@ GLU_DIRS="sgi"
 GALLIUM_DIRS="auxiliary drivers state_trackers"
 GALLIUM_TARGET_DIRS=""
 GALLIUM_WINSYS_DIRS="sw"
-GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity"
+GALLIUM_DRIVERS_DIRS="failover galahad trace rbug noop identity"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
 # build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled
@@ -785,7 +821,7 @@ esac
 if test "x$enable_dri" = xyes; then
     DRIVER_DIRS="$DRIVER_DIRS dri"
 
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri"
+    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/dri"
     GALLIUM_STATE_TRACKERS_DIRS="dri $GALLIUM_STATE_TRACKERS_DIRS"
     HAVE_ST_DRI="yes"
 fi
@@ -1386,6 +1422,14 @@ fi
 dnl
 dnl gbm Gallium configuration
 dnl
+if test "x$enable_gallium_gbm" = xauto; then
+    case "$enable_gbm$HAVE_ST_EGL$with_egl_platforms" in
+        yesyes*drm*)
+            enable_gallium_gbm=yes ;;
+         *)
+            enable_gallium_gbm=no ;;
+    esac
+fi
 if test "x$enable_gallium_gbm" = xyes; then
     if test "x$with_gallium_drivers" = x; then
         AC_MSG_ERROR([cannot enable gbm_gallium without Gallium])
@@ -1413,6 +1457,14 @@ if test "x$enable_xorg" = xyes; then
     HAVE_ST_XORG=yes
 fi
 
+dnl
+dnl XA configuration
+dnl
+if test "x$enable_xa" = xyes; then
+    GALLIUM_STATE_TRACKERS_DIRS="xa $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_ST_XA=yes
+fi
+
 dnl
 dnl OpenVG configuration
 dnl
@@ -1449,6 +1501,59 @@ if test "x$enable_d3d1x" = xyes; then
     HAVE_ST_D3D1X=yes
 fi
 
+dnl
+dnl Gallium G3DVL configuration
+dnl
+AC_ARG_ENABLE([gallium-g3dvl],
+    [AS_HELP_STRING([--enable-gallium-g3dvl],
+        [build gallium g3dvl @<:@default=disabled@:>@])],
+    [enable_gallium_g3dvl="$enableval"],
+    [enable_gallium_g3dvl=no])
+if test "x$enable_gallium_g3dvl" = xyes; then
+    if test "x$with_gallium_drivers" = x; then
+        AC_MSG_ERROR([cannot enable G3DVL without Gallium])
+    fi
+
+    if test "x$enable_xvmc" = xauto; then
+       PKG_CHECK_EXISTS([xvmc], [enable_xvmc=yes], [enable_xvmc=no])
+    fi
+
+    if test "x$enable_vdpau" = xauto; then
+       PKG_CHECK_EXISTS([vdpau], [enable_vdpau=yes], [enable_vdpau=no])
+    fi
+
+    if test "x$enable_va" = xauto; then
+       #don't enable vaapi state tracker even if package exists
+       #PKG_CHECK_EXISTS([libva], [enable_vdpau=yes], [enable_vdpau=no])
+        enable_va=no
+    fi
+fi
+
+if test "x$enable_xvmc" = xyes; then
+    PKG_CHECK_MODULES([XVMC], [xvmc >= 1.0.6 xorg-server])
+    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg/xvmc"
+    HAVE_ST_XVMC="yes"
+fi
+
+if test "x$enable_vdpau" = xyes; then
+    PKG_CHECK_MODULES([VDPAU], [vdpau >= 0.4.1])
+    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vdpau"
+    HAVE_ST_VDPAU="yes"
+fi
+
+if test "x$enable_va" = xyes; then
+    PKG_CHECK_MODULES([LIBVA], [libva = 0.31.1])
+    AC_MSG_WARN([vaapi state tracker currently unmaintained])
+    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS va"
+    HAVE_ST_VA="yes"
+fi
+
+if test "x$enable_xvmc" = xyes || 
+    test "x$enable_vdpau" = xyes ||
+    test "x$enable_va" = xyes; then
+    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS g3dvl/dri"
+fi
+
 dnl
 dnl GLU configuration
 dnl
@@ -1668,8 +1773,6 @@ AC_SUBST([LLVM_LIBS])
 AC_SUBST([LLVM_LDFLAGS])
 AC_SUBST([LLVM_VERSION])
 
-
-
 case "x$enable_opengl$enable_gles1$enable_gles2" in
 x*yes*)
     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)'
@@ -1713,9 +1816,13 @@ yes)
                WAYLAND_EGL_LIB_DEPS="$WAYLAND_LIBS $LIBDRM_LIBS"
                 GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/wayland"
        fi
-        if test "$plat" = "drm" && test "x$enable_gbm" = no; then
+        if test "$plat" = "drm" && test "x$enable_gbm" = "xno"; then
                 AC_MSG_ERROR([EGL platform drm needs gbm])
         fi
+        case "$plat$have_libudev" in
+                waylandno|drmno)
+                    AC_MSG_ERROR([cannot build $plat platfrom without udev]) ;;
+        esac
     done
     EGL_PLATFORMS="$egl_platforms"
     ;;
@@ -1780,12 +1887,11 @@ fi
 if test "x$enable_gallium_llvm" = xyes; then
     if test "x$LLVM_CONFIG" != xno; then
        LLVM_VERSION=`$LLVM_CONFIG --version`
-       LLVM_CFLAGS=`$LLVM_CONFIG --cppflags`
+       LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed 's/-DNDEBUG\>//g'`
        LLVM_LIBS="`$LLVM_CONFIG --libs` -lstdc++"
 
        LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
-       GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
-       DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS"
+       DEFINES="$DEFINES -D__STDC_CONSTANT_MACROS"
        MESA_LLVM=1
     else
        MESA_LLVM=0
@@ -1794,11 +1900,29 @@ else
     MESA_LLVM=0
 fi
 
+dnl Directory for VDPAU libs
+AC_ARG_WITH([vdpau-libdir],
+    [AS_HELP_STRING([--with-vdpau-libdir=DIR],
+        [directory for the VDPAU libraries @<:@default=${libdir}/vdpau@:>@])],
+    [VDPAU_LIB_INSTALL_DIR="$withval"],
+    [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau'])
+AC_SUBST([VDPAU_LIB_INSTALL_DIR])
+
+dnl Directory for VA libs
+AC_ARG_WITH([va-libdir],
+    [AS_HELP_STRING([--with-va-libdir=DIR],
+        [directory for the VA libraries @<:@default=${libdir}/va@:>@])],
+    [VA_LIB_INSTALL_DIR="$withval"],
+    [VA_LIB_INSTALL_DIR='${libdir}/va'])
+AC_SUBST([VA_LIB_INSTALL_DIR])
+
 dnl
 dnl Gallium helper functions
 dnl
 gallium_check_st() {
-    if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes; then
+    if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes ||
+        test "x$HAVE_ST_XA" = xyes || test "x$HAVE_ST_XVMC" = xyes ||
+        test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then
          if test "x$have_libdrm" != xyes; then
             AC_MSG_ERROR([DRI or Xorg DDX requires libdrm >= $LIBDRM_REQUIRED])
          fi
@@ -1810,6 +1934,18 @@ gallium_check_st() {
     if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then
          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
     fi
+    if test "x$HAVE_ST_XA" = xyes && test "x$4" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4"
+    fi
+    if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5"
+    fi
+    if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6"
+    fi
+    if test "x$HAVE_ST_VA" = xyes && test "x$7" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7"
+    fi
 }
 
 gallium_require_llvm() {
@@ -1821,39 +1957,60 @@ gallium_require_llvm() {
 }
 
 dnl Gallium drivers
+dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block
 if test "x$with_gallium_drivers" != x; then
-    # This is for compile-testing
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965 r300 svga"
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
-
     gallium_drivers=`IFS=', '; echo $with_gallium_drivers`
     for driver in $gallium_drivers; do
         case "x$driver" in
         xsvga)
-            gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx"
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga softpipe"
+            gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx" "xa-vmwgfx"
             ;;
         xi915)
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 softpipe"
+            if test "x$MESA_LLVM" = x1; then
+                GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+            fi
+            GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
             gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
             ;;
         xi965)
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965 softpipe"
+            if test "x$MESA_LLVM" = x1; then
+                GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+            fi
             gallium_check_st "i965/drm" "dri-i965" "xorg-i965"
             ;;
         xr300)
             gallium_require_llvm "Gallium R300"
-            gallium_check_st "radeon/drm" "dri-r300" "xorg-r300"
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
+            gallium_check_st "radeon/drm" "dri-r300" "xorg-r300" "" "xvmc-r300" "vdpau-r300" "va-r300"
             ;;
         xr600)
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
-            gallium_check_st "r600/drm" "dri-r600"
+            gallium_check_st "r600/drm" "dri-r600" "" "" "xvmc-r600" "vdpau-r600" "va-r600"
             ;;
         xnouveau)
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0"
-            gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau"
+            gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "" "xvmc-nouveau"
             ;;
         xswrast)
             if test "x$HAVE_ST_DRI" = xyes; then
+                GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
+                if test "x$MESA_LLVM" = x1; then
+                    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+                fi
                 GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
             fi
+            if test "x$HAVE_ST_VDPAU" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe"
+            fi
+            if test "x$HAVE_ST_XVMC" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xvmc-softpipe"
+            fi
+            if test "x$HAVE_ST_VA" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS va-softpipe"
+            fi
             ;;
         *)
             AC_MSG_ERROR([Unknown Gallium driver: $driver])
@@ -1869,6 +2026,10 @@ dnl Restore LDFLAGS and CPPFLAGS
 LDFLAGS="$_SAVE_LDFLAGS"
 CPPFLAGS="$_SAVE_CPPFLAGS"
 
+dnl Add user CFLAGS and CXXFLAGS
+CFLAGS="$CFLAGS $USER_CFLAGS"
+CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
+
 dnl Substitute the config
 AC_CONFIG_FILES([configs/autoconf])