[SCM] intel-vaapi-driver/experimental: Imported Upstream version 1.5.0~pre1

sramacher at users.alioth.debian.org sramacher at users.alioth.debian.org
Mon Dec 15 19:59:40 UTC 2014


The following commit has been merged in the experimental branch:
commit d45cafbe730b8bd5cfeacd1b77412d63ac381320
Author: Sebastian Ramacher <sramacher at debian.org>
Date:   Mon Dec 15 20:10:40 2014 +0100

    Imported Upstream version 1.5.0~pre1

diff --git a/Makefile.in b/Makefile.in
index 241073b..bf13c56 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -222,6 +222,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -268,6 +269,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -276,8 +278,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/NEWS b/NEWS
index 5052f3b..103b4d6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,15 @@
-libva-intel-driver NEWS -- summary of changes.  2014-10-24
+libva-intel-driver NEWS -- summary of changes.  2014-12-xx
 Copyright (C) 2009-2014 Intel Corporation
 
+Version 1.5.0 - xx.Dec.2014
+* Add support for Skylake
+  - Decoding: H.264/MPEG-2/VC-1/JPEG/VP8/HEVC
+  - Encoding: H.264/MPEG-2/JPEG
+  - VPP: CSC/scaling/NoiseReduction/Deinterlacing{Bob, MotionAdaptive, MotionCompensated}/ColorBalance
+* Add support for JPEG encoding on Braswell
+* Add enhancement for video post/pre processing
+* Fix out of tree builds (Emil Velikov)
+
 Version 1.4.1 - 24.Oct.2014
 * Use a new method to detect encoding capabilitiy on Haswell
 
diff --git a/aclocal.m4 b/aclocal.m4
index d3e18a7..84bd87f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -20,5022 +20,3895 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_AUTOMAKE_VERSION(VERSION)
-# ----------------------------
-# Automake X.Y traces this macro to ensure aclocal.m4 has been
-# generated from the m4 files accompanying Automake X.Y.
-# (This private macro should not be called outside this file.)
-AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.14'
-dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
-dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.14.1], [],
-      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
-])
-
-# _AM_AUTOCONF_VERSION(VERSION)
-# -----------------------------
-# aclocal traces this macro to find the Autoconf version.
-# This is a private macro too.  Using m4_define simplifies
-# the logic in aclocal, which can simply ignore this definition.
-m4_define([_AM_AUTOCONF_VERSION], [])
-
-# AM_SET_CURRENT_AUTOMAKE_VERSION
-# -------------------------------
-# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
-# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
-AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.14.1])dnl
-m4_ifndef([AC_AUTOCONF_VERSION],
-  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
-
-# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
-
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
 #
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
 
-# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
-# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+m4_define([_LT_COPYING], [dnl
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
 #
-# Of course, Automake must honor this variable whenever it calls a
-# tool from the auxiliary directory.  The problem is that $srcdir (and
-# therefore $ac_aux_dir as well) can be either absolute or relative,
-# depending on how configure is run.  This is pretty annoying, since
-# it makes $ac_aux_dir quite unusable in subdirectories: in the top
-# source directory, any form will work fine, but in subdirectories a
-# relative path needs to be adjusted first.
+#   This file is part of GNU Libtool.
 #
-# $ac_aux_dir/missing
-#    fails when called from a subdirectory if $ac_aux_dir is relative
-# $top_srcdir/$ac_aux_dir/missing
-#    fails if $ac_aux_dir is absolute,
-#    fails when called from a subdirectory in a VPATH build with
-#          a relative $ac_aux_dir
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
 #
-# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
-# are both prefixed by $srcdir.  In an in-source build this is usually
-# harmless because $srcdir is '.', but things will broke when you
-# start a VPATH build or use an absolute $srcdir.
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
 #
-# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
-# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
-#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
-# and then we would define $MISSING as
-#   MISSING="\${SHELL} $am_aux_dir/missing"
-# This will work as long as MISSING is not called from configure, because
-# unfortunately $(top_srcdir) has no meaning in configure.
-# However there are other variables, like CC, which are often used in
-# configure, and could therefore not use this "fixed" $ac_aux_dir.
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-# Another solution, used here, is to always expand $ac_aux_dir to an
-# absolute PATH.  The drawback is that using absolute paths prevent a
-# configured tree to be moved without reconfiguration.
-
-AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 ])
 
-# AM_CONDITIONAL                                            -*- Autoconf -*-
+# serial 57 LT_INIT
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# AM_CONDITIONAL(NAME, SHELL-CONDITION)
-# -------------------------------------
-# Define a conditional.
-AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ([2.52])dnl
- m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])dnl
-AC_SUBST([$1_FALSE])dnl
-_AM_SUBST_NOTMAKE([$1_TRUE])dnl
-_AM_SUBST_NOTMAKE([$1_FALSE])dnl
-m4_define([_AM_COND_VALUE_$1], [$2])dnl
-if $2; then
-  $1_TRUE=
-  $1_FALSE='#'
-else
-  $1_TRUE='#'
-  $1_FALSE=
-fi
-AC_CONFIG_COMMANDS_PRE(
-[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
-  AC_MSG_ERROR([[conditional "$1" was never defined.
-Usually this means the macro was only invoked conditionally.]])
-fi])])
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+       [m4_default([$3],
+		   [m4_fatal([Libtool version $1 or higher is required],
+		             63)])],
+       [$2])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+  *\ * | *\	*)
+    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
 
-# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
-# written in clear, in which case automake, when reading aclocal.m4,
-# will think it sees a *use*, and therefore will trigger all it's
-# C support machinery.  Also note that it means that autoscan, seeing
-# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
 
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
 
-# _AM_DEPENDENCIES(NAME)
-# ----------------------
-# See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
-# We try a few techniques and use that to set a single cache variable.
-#
-# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
-# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
-# dependency, and given that the user is not expected to run this macro,
-# just rely on AC_PROG_CC.
-AC_DEFUN([_AM_DEPENDENCIES],
-[AC_REQUIRE([AM_SET_DEPDIR])dnl
-AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
-AC_REQUIRE([AM_MAKE_INCLUDE])dnl
-AC_REQUIRE([AM_DEP_TRACK])dnl
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
 
-m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
-      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
-      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
-      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
-      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
-      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
-                    [depcc="$$1"   am_compiler_list=])
+_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
 
-AC_CACHE_CHECK([dependency style of $depcc],
-               [am_cv_$1_dependencies_compiler_type],
-[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named 'D' -- because '-MD' means "put the output
-  # in D".
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
 
-  am_cv_$1_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
-  fi
-  am__universal=false
-  m4_case([$1], [CC],
-    [case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac],
-    [CXX],
-    [case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac])
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
 
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
-      # Solaris 10 /bin/sh.
-      echo '/* dummy */' > sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
-    # We check with '-c' and '-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle '-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs.
-    am__obj=sub/conftest.${OBJEXT-o}
-    am__minus_obj="-o $am__obj"
-    case $depmode in
-    gcc)
-      # This depmode causes a compiler race in universal mode.
-      test "$am__universal" = false || continue
-      ;;
-    nosideeffect)
-      # After this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested.
-      if test "x$enable_dependency_tracking" = xyes; then
-	continue
-      else
-	break
-      fi
-      ;;
-    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok '-c -o', but also, the minuso test has
-      # not run yet.  These depmodes are late enough in the game, and
-      # so weak that their functioning should not be impacted.
-      am__obj=conftest.${OBJEXT-o}
-      am__minus_obj=
-      ;;
-    none) break ;;
-    esac
-    if depmode=$depmode \
-       source=sub/conftest.c object=$am__obj \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # or remarks (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
-      #   icc: Command line warning: ignoring option '-M'; no argument required
-      # The diagnosis changed in icc 8.0:
-      #   icc: Command line remark: option '-MP' not supported
-      if (grep 'ignoring option' conftest.err ||
-          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_$1_dependencies_compiler_type=$depmode
-        break
-      fi
-    fi
-  done
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
 
-  cd ..
-  rm -rf conftest.dir
-else
-  am_cv_$1_dependencies_compiler_type=none
-fi
-])
-AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
-AM_CONDITIONAL([am__fastdep$1], [
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
-])
+_LT_SETUP
 
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
 
-# AM_SET_DEPDIR
-# -------------
-# Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
-AC_DEFUN([AM_SET_DEPDIR],
-[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
-])
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
-# AM_DEP_TRACK
-# ------------
-AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE([dependency-tracking], [dnl
-AS_HELP_STRING(
-  [--enable-dependency-tracking],
-  [do not reject slow dependency extractors])
-AS_HELP_STRING(
-  [--disable-dependency-tracking],
-  [speeds up one-time build])])
-if test "x$enable_dependency_tracking" != xno; then
-  am_depcomp="$ac_aux_dir/depcomp"
-  AMDEPBACKSLASH='\'
-  am__nodep='_no'
-fi
-AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])dnl
-_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
-AC_SUBST([am__nodep])dnl
-_AM_SUBST_NOTMAKE([am__nodep])dnl
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 ])
 
-# Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
 
 
-# _AM_OUTPUT_DEPENDENCY_COMMANDS
-# ------------------------------
-AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[{
-  # Older Autoconf quotes --file arguments for eval, but not when files
-  # are listed without --file.  Let's play safe and only enable the eval
-  # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
-  shift
-  for mf
-  do
-    # Strip MF so we end up with the name of the file.
-    mf=`echo "$mf" | sed -e 's/:.*$//'`
-    # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named 'Makefile.in', but
-    # some people rename them; so instead we look at the file content.
-    # Grep'ing the first line is not enough: some people post-process
-    # each Makefile.in and add a new line on top of each file to say so.
-    # Grep'ing the whole file is not good either: AIX grep has a line
-    # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`AS_DIRNAME("$mf")`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running 'make'.
-    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-    test -z "$DEPDIR" && continue
-    am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "$am__include" && continue
-    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # Find all dependency output files, they are included files with
-    # $(DEPDIR) in their names.  We invoke sed twice because it is the
-    # simplest approach to changing $(DEPDIR) to its actual value in the
-    # expansion.
-    for file in `sed -n "
-      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`AS_DIRNAME(["$file"])`
-      AS_MKDIR_P([$dirpart/$fdir])
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
-  done
-}
-])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
 
+_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
+dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_WITH_SYSROOT])dnl
 
-# AM_OUTPUT_DEPENDENCY_COMMANDS
-# -----------------------------
-# This macro should only be invoked once -- use via AC_REQUIRE.
-#
-# This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each '.P' file that we will
-# need in order to bootstrap the dependency handling code.
-AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
-[AC_CONFIG_COMMANDS([depfiles],
-     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
 ])
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
 
-# Do all the work for Automake.                             -*- Autoconf -*-
+_LT_CHECK_OBJDIR
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+m4_require([_LT_TAG_COMPILER])dnl
 
-# This macro actually does too much.  Some checks are only needed if
-# your package does certain things.  But this isn't really a big deal.
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
 
-dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
-m4_define([AC_PROG_CC],
-m4_defn([AC_PROG_CC])
-[_AM_PROG_CC_C_O
-])
+# Global variables:
+ofile=libtool
+can_build_shared=yes
 
-# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
-# AM_INIT_AUTOMAKE([OPTIONS])
-# -----------------------------------------------
-# The call with PACKAGE and VERSION arguments is the old style
-# call (pre autoconf-2.50), which is being phased out.  PACKAGE
-# and VERSION should now be passed to AC_INIT and removed from
-# the call to AM_INIT_AUTOMAKE.
-# We support both call styles for the transition.  After
-# the next Automake release, Autoconf can make the AC_INIT
-# arguments mandatory, and then we can depend on a new Autoconf
-# release and drop the old call support.
-AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.65])dnl
-dnl Autoconf wants to disallow AM_ names.  We explicitly allow
-dnl the ones we care about.
-m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
-AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
-AC_REQUIRE([AC_PROG_INSTALL])dnl
-if test "`cd $srcdir && pwd`" != "`pwd`"; then
-  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
-  # is not polluted with repeated "-I."
-  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
-  # test to see if srcdir already configured
-  if test -f $srcdir/config.status; then
-    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
-  fi
-fi
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
 
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
-  if (cygpath --version) >/dev/null 2>/dev/null; then
-    CYGPATH_W='cygpath -w'
-  else
-    CYGPATH_W=echo
-  fi
-fi
-AC_SUBST([CYGPATH_W])
+with_gnu_ld="$lt_cv_prog_gnu_ld"
 
-# Define the identity of the package.
-dnl Distinguish between old-style and new-style calls.
-m4_ifval([$2],
-[AC_DIAGNOSE([obsolete],
-             [$0: two- and three-arguments forms are deprecated.])
-m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
- AC_SUBST([PACKAGE], [$1])dnl
- AC_SUBST([VERSION], [$2])],
-[_AM_SET_OPTIONS([$1])dnl
-dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
-m4_if(
-  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
-  [ok:ok],,
-  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
- AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
- AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
 
-_AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
- AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
 
-# Some tools Automake needs.
-AC_REQUIRE([AM_SANITY_CHECK])dnl
-AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
-AM_MISSING_PROG([AUTOCONF], [autoconf])
-AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
-AM_MISSING_PROG([AUTOHEADER], [autoheader])
-AM_MISSING_PROG([MAKEINFO], [makeinfo])
-AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
-AC_REQUIRE([AC_PROG_MKDIR_P])dnl
-# For better backward compatibility.  To be removed once Automake 1.9.x
-# dies out for good.  For more background, see:
-# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
-# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
-AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([AC_PROG_MAKE_SET])dnl
-AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
-	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
-			     [_AM_PROG_TAR([v7])])])
-_AM_IF_OPTION([no-dependencies],,
-[AC_PROVIDE_IFELSE([AC_PROG_CC],
-		  [_AM_DEPENDENCIES([CC])],
-		  [m4_define([AC_PROG_CC],
-			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_CXX],
-		  [_AM_DEPENDENCIES([CXX])],
-		  [m4_define([AC_PROG_CXX],
-			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-		  [_AM_DEPENDENCIES([OBJC])],
-		  [m4_define([AC_PROG_OBJC],
-			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
-		  [_AM_DEPENDENCIES([OBJCXX])],
-		  [m4_define([AC_PROG_OBJCXX],
-			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
-])
-AC_REQUIRE([AM_SILENT_RULES])dnl
-dnl The testsuite driver may need to know about EXEEXT, so add the
-dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
-dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
-AC_CONFIG_COMMANDS_PRE(dnl
-[m4_provide_if([_AM_COMPILER_EXEEXT],
-  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+_LT_CC_BASENAME([$compiler])
 
-# POSIX will say in a future version that running "rm -f" with no argument
-# is OK; and we want to be able to make that assumption in our Makefile
-# recipes.  So use an aggressive probe to check that the usage we want is
-# actually supported "in the wild" to an acceptable degree.
-# See automake bug#10828.
-# To make any issue more visible, cause the running configure to be aborted
-# by default if the 'rm' program in use doesn't match our expectations; the
-# user can still override this though.
-if rm -f && rm -fr && rm -rf; then : OK; else
-  cat >&2 <<'END'
-Oops!
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    _LT_PATH_MAGIC
+  fi
+  ;;
+esac
 
-Your 'rm' program seems unable to run without file operands specified
-on the command line, even when the '-f' option is present.  This is contrary
-to the behaviour of most rm programs out there, and not conforming with
-the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
 
-Please tell bug-automake at gnu.org about your system, including the value
-of your $PATH and any error possibly output before this message.  This
-can help us improve future automake versions.
 
-END
-  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
-    echo 'Configuration will proceed anyway, since you have set the' >&2
-    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
-    echo >&2
-  else
-    cat >&2 <<'END'
-Aborting the configuration process, to ensure you take notice of the issue.
+# _LT_PREPARE_SED_QUOTE_VARS
+# --------------------------
+# Define a few sed substitution that help us do robust quoting.
+m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
+[# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
 
-You can download and install GNU coreutils to get an 'rm' implementation
-that behaves properly: <http://www.gnu.org/software/coreutils/>.
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
 
-If you want to complete the configuration process using your problematic
-'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
-to "yes", and re-run configure.
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
 
-END
-    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
-  fi
-fi])
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
 
-dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
-dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
-dnl mangled by Autoconf and run in a shell conditional statement.
-m4_define([_AC_COMPILER_EXEEXT],
-m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+])
 
-# When config.status generates a header, we must update the stamp-h file.
-# This file resides in the same directory as the config header
-# that is generated.  The stamp files are numbered to have different names.
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
 
-# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
-# loop where config.status creates the headers, so we can generate
-# our stamp files there.
-AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
-[# Compute $1's index in $config_headers.
-_am_arg=$1
-_am_stamp_count=1
-for _am_header in $config_headers :; do
-  case $_am_header in
-    $_am_arg | $_am_arg:* )
-      break ;;
-    * )
-      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
-  esac
-done
-echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# AM_PROG_INSTALL_SH
-# ------------------
-# Define $install_sh.
-AC_DEFUN([AM_PROG_INSTALL_SH],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\	*)
-    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
-  *)
-    install_sh="\${SHELL} $am_aux_dir/install-sh"
-  esac
-fi
-AC_SUBST([install_sh])])
-
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
 
-# Check whether the underlying file-system supports filenames
-# with a leading dot.  For instance MS-DOS doesn't.
-AC_DEFUN([AM_SET_LEADING_DOT],
-[rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
-  am__leading_dot=.
-else
-  am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-AC_SUBST([am__leading_dot])])
 
-# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+                     [$1
+])])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
 
-# AM_MAKE_INCLUDE()
-# -----------------
-# Check to see how make treats includes.
-AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
-	@echo this is the am__doit target
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from 'make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
-  am__include=include
-  am__quote=
-  _am_result=GNU
-  ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   case `$am_make -s -f confmf 2> /dev/null` in #(
-   *the\ am__doit\ target*)
-     am__include=.include
-     am__quote="\""
-     _am_result=BSD
-     ;;
-   esac
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
 
-# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+                     [$1
+])])])
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
 
-# AM_MISSING_PROG(NAME, PROGRAM)
-# ------------------------------
-AC_DEFUN([AM_MISSING_PROG],
-[AC_REQUIRE([AM_MISSING_HAS_RUN])
-$1=${$1-"${am_missing_run}$2"}
-AC_SUBST($1)])
 
-# AM_MISSING_HAS_RUN
-# ------------------
-# Define MISSING if not defined so far and test if it is modern enough.
-# If it is, set am_missing_run to use it, otherwise, to nothing.
-AC_DEFUN([AM_MISSING_HAS_RUN],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([missing])dnl
-if test x"${MISSING+set}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\	*)
-    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
-  *)
-    MISSING="\${SHELL} $am_aux_dir/missing" ;;
-  esac
-fi
-# Use eval to expand $SHELL
-if eval "$MISSING --is-lightweight"; then
-  am_missing_run="$MISSING "
-else
-  am_missing_run=
-  AC_MSG_WARN(['missing' script is too old or missing])
-fi
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
 ])
 
-# Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
 
-# _AM_MANGLE_OPTION(NAME)
-# -----------------------
-AC_DEFUN([_AM_MANGLE_OPTION],
-[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
 
-# _AM_SET_OPTION(NAME)
-# --------------------
-# Set option NAME.  Presently that only means defining a flag for this option.
-AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
 
-# _AM_SET_OPTIONS(OPTIONS)
-# ------------------------
-# OPTIONS is a space-separated list of Automake options.
-AC_DEFUN([_AM_SET_OPTIONS],
-[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
 
-# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
-# -------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-AC_DEFUN([_AM_IF_OPTION],
-[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME.  Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+	[m4_ifval([$1], [$1], [$2])])
+    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+    m4_ifval([$4],
+	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+    lt_dict_add_subkey([lt_decl_dict], [$2],
+	[tagged?], [m4_ifval([$5], [yes], [no])])])
+])
 
-# _AM_PROG_CC_C_O
-# ---------------
-# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
-# to automatically call this.
-AC_DEFUN([_AM_PROG_CC_C_O],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([compile])dnl
-AC_LANG_PUSH([C])dnl
-AC_CACHE_CHECK(
-  [whether $CC understands -c and -o together],
-  [am_cv_prog_cc_c_o],
-  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
-  # Make sure it works both with $CC and with simple cc.
-  # Following AC_PROG_CC_C_O, we do the test twice because some
-  # compilers refuse to overwrite an existing .o file with -o,
-  # though they will create one.
-  am_cv_prog_cc_c_o=yes
-  for am_i in 1 2; do
-    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
-         && test -f conftest2.$ac_objext; then
-      : OK
-    else
-      am_cv_prog_cc_c_o=no
-      break
-    fi
-  done
-  rm -f core conftest*
-  unset am_i])
-if test "$am_cv_prog_cc_c_o" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
-AC_LANG_POP([C])])
 
-# For backward compatibility.
-AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# AM_RUN_LOG(COMMAND)
-# -------------------
-# Run COMMAND, save the exit status in ac_status, and log it.
-# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
-AC_DEFUN([AM_RUN_LOG],
-[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
-   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
-   ac_status=$?
-   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   (exit $ac_status); }])
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
 
-# Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+  [0], [m4_fatal([$0: too few arguments: $#])],
+  [1], [m4_fatal([$0: too few arguments: $#: $1])],
+  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
 
-# AM_SANITY_CHECK
-# ---------------
-AC_DEFUN([AM_SANITY_CHECK],
-[AC_MSG_CHECKING([whether build environment is sane])
-# Reject unsafe characters in $srcdir or the absolute working directory
-# name.  Accept space and tab only in the latter.
-am_lf='
-'
-case `pwd` in
-  *[[\\\"\#\$\&\'\`$am_lf]]*)
-    AC_MSG_ERROR([unsafe absolute working directory name]);;
-esac
-case $srcdir in
-  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
-    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
-esac
 
-# Do 'set' in a subshell so we don't clobber the current shell's
-# arguments.  Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
-   am_has_slept=no
-   for am_try in 1 2; do
-     echo "timestamp, slept: $am_has_slept" > conftest.file
-     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-     if test "$[*]" = "X"; then
-	# -L didn't work.
-	set X `ls -t "$srcdir/configure" conftest.file`
-     fi
-     if test "$[*]" != "X $srcdir/configure conftest.file" \
-	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
 
-	# If neither matched, then we have a broken ls.  This can happen
-	# if, for instance, CONFIG_SHELL is bash and it inherits a
-	# broken ls alias from the environment.  This has actually
-	# happened.  Such a system could not be considered "sane".
-	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
-  alias in your environment])
-     fi
-     if test "$[2]" = conftest.file || test $am_try -eq 2; then
-       break
-     fi
-     # Just in case.
-     sleep 1
-     am_has_slept=yes
-   done
-   test "$[2]" = conftest.file
-   )
-then
-   # Ok.
-   :
-else
-   AC_MSG_ERROR([newly created file is older than distributed files!
-Check your system clock])
-fi
-AC_MSG_RESULT([yes])
-# If we didn't sleep, we still need to ensure time stamps of config.status and
-# generated files are strictly newer.
-am_sleep_pid=
-if grep 'slept: no' conftest.file >/dev/null 2>&1; then
-  ( sleep 1 ) &
-  am_sleep_pid=$!
-fi
-AC_CONFIG_COMMANDS_PRE(
-  [AC_MSG_CHECKING([that generated files are newer than configure])
-   if test -n "$am_sleep_pid"; then
-     # Hide warnings about reused PIDs.
-     wait $am_sleep_pid 2>/dev/null
-   fi
-   AC_MSG_RESULT([done])])
-rm -f conftest.file
-])
 
-# Copyright (C) 2009-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
 
-# AM_SILENT_RULES([DEFAULT])
-# --------------------------
-# Enable less verbose build rules; with the default set to DEFAULT
-# ("yes" being less verbose, "no" or empty being verbose).
-AC_DEFUN([AM_SILENT_RULES],
-[AC_ARG_ENABLE([silent-rules], [dnl
-AS_HELP_STRING(
-  [--enable-silent-rules],
-  [less verbose build output (undo: "make V=1")])
-AS_HELP_STRING(
-  [--disable-silent-rules],
-  [verbose build output (undo: "make V=0")])dnl
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+     m4_if([$2], [],
+	   m4_quote(lt_decl_varnames),
+	m4_quote(m4_shift($@))))[]dnl
 ])
-case $enable_silent_rules in @%:@ (((
-  yes) AM_DEFAULT_VERBOSITY=0;;
-   no) AM_DEFAULT_VERBOSITY=1;;
-    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
-esac
-dnl
-dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
-dnl do not support nested variable expansions.
-dnl See automake bug#9928 and bug#10237.
-am_make=${MAKE-make}
-AC_CACHE_CHECK([whether $am_make supports nested variables],
-   [am_cv_make_support_nested_variables],
-   [if AS_ECHO([['TRUE=$(BAR$(V))
-BAR0=false
-BAR1=true
-V=1
-am__doit:
-	@$(TRUE)
-.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
-  am_cv_make_support_nested_variables=yes
-else
-  am_cv_make_support_nested_variables=no
-fi])
-if test $am_cv_make_support_nested_variables = yes; then
-  dnl Using '$V' instead of '$(V)' breaks IRIX make.
-  AM_V='$(V)'
-  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
-else
-  AM_V=$AM_DEFAULT_VERBOSITY
-  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
-fi
-AC_SUBST([AM_V])dnl
-AM_SUBST_NOTMAKE([AM_V])dnl
-AC_SUBST([AM_DEFAULT_V])dnl
-AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
-AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
-AM_BACKSLASH='\'
-AC_SUBST([AM_BACKSLASH])dnl
-_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
 ])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# AM_PROG_INSTALL_STRIP
-# ---------------------
-# One issue with vendor 'install' (even GNU) is that you can't
-# specify the program used to strip binaries.  This is especially
-# annoying in cross-compiling environments, where the build's strip
-# is unlikely to handle the host's binaries.
-# Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in "make install-strip", and initialize
-# STRIPPROG with the value of the STRIP variable (set by the user).
-AC_DEFUN([AM_PROG_INSTALL_STRIP],
-[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using 'strip' when the user
-# run "make install-strip".  However 'strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the 'STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
-if test "$cross_compiling" != no; then
-  AC_CHECK_TOOL([STRIP], [strip], :)
-fi
-INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
-AC_SUBST([INSTALL_STRIP_PROGRAM])])
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'.  VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
 
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly.  In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
 #
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+#    <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
 
-# _AM_SUBST_NOTMAKE(VARIABLE)
-# ---------------------------
-# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
-# This macro is traced by Automake.
-AC_DEFUN([_AM_SUBST_NOTMAKE])
 
-# AM_SUBST_NOTMAKE(VARIABLE)
-# --------------------------
-# Public sister of _AM_SUBST_NOTMAKE.
-AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
 
-# Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
 #
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+#    # Some comment about what VAR is for.
+#    visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+					   [description])))[]dnl
+m4_pushdef([_libtool_name],
+    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+    [0], [_libtool_name=[$]$1],
+    [1], [_libtool_name=$lt_[]$1],
+    [2], [_libtool_name=$lt_[]$1],
+    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
 
-# _AM_PROG_TAR(FORMAT)
-# --------------------
-# Check how to create a tarball in format FORMAT.
-# FORMAT should be one of 'v7', 'ustar', or 'pax'.
-#
-# Substitute a variable $(am__tar) that is a command
-# writing to stdout a FORMAT-tarball containing the directory
-# $tardir.
-#     tardir=directory && $(am__tar) > result.tar
-#
-# Substitute a variable $(am__untar) that extract such
-# a tarball read from stdin.
-#     $(am__untar) < result.tar
-#
-AC_DEFUN([_AM_PROG_TAR],
-[# Always define AMTAR for backward compatibility.  Yes, it's still used
-# in the wild :-(  We should find a proper way to deprecate it ...
-AC_SUBST([AMTAR], ['$${TAR-tar}'])
 
-# We'll loop over all known methods to create a tar archive until one works.
-_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
 
-m4_if([$1], [v7],
-  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
 
-  [m4_case([$1],
-    [ustar],
-     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
-      # There is notably a 21 bits limit for the UID and the GID.  In fact,
-      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
-      # and bug#13588).
-      am_max_uid=2097151 # 2^21 - 1
-      am_max_gid=$am_max_uid
-      # The $UID and $GID variables are not portable, so we need to resort
-      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
-      # below are definitely unexpected, so allow the users to see them
-      # (that is, avoid stderr redirection).
-      am_uid=`id -u || echo unknown`
-      am_gid=`id -g || echo unknown`
-      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
-      if test $am_uid -le $am_max_uid; then
-         AC_MSG_RESULT([yes])
-      else
-         AC_MSG_RESULT([no])
-         _am_tools=none
-      fi
-      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
-      if test $am_gid -le $am_max_gid; then
-         AC_MSG_RESULT([yes])
-      else
-        AC_MSG_RESULT([no])
-        _am_tools=none
-      fi],
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
 
-  [pax],
-    [],
 
-  [m4_fatal([Unknown tar format])])
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 
-  AC_MSG_CHECKING([how to create a $1 tar archive])
 
-  # Go ahead even if we have the value already cached.  We do so because we
-  # need to set the values for the 'am__tar' and 'am__untar' variables.
-  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'.  Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+	dnl If the libtool generation code has been placed in $CONFIG_LT,
+	dnl instead of duplicating it all over again into config.status,
+	dnl then we will have config.status run $CONFIG_LT later, so it
+	dnl needs to know what name is stored there:
+        [AC_CONFIG_COMMANDS([libtool],
+            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+    dnl If the libtool generation code is destined for config.status,
+    dnl expand the accumulated commands and init code now:
+    [AC_CONFIG_COMMANDS([libtool],
+        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
 
-  for _am_tool in $_am_tools; do
-    case $_am_tool in
-    gnutar)
-      for _am_tar in tar gnutar gtar; do
-        AM_RUN_LOG([$_am_tar --version]) && break
-      done
-      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
-      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
-      am__untar="$_am_tar -xf -"
-      ;;
-    plaintar)
-      # Must skip GNU tar: if it does not support --format= it doesn't create
-      # ustar tarball either.
-      (tar --version) >/dev/null 2>&1 && continue
-      am__tar='tar chf - "$$tardir"'
-      am__tar_='tar chf - "$tardir"'
-      am__untar='tar xf -'
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$[]1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
       ;;
-    pax)
-      am__tar='pax -L -x $1 -w "$$tardir"'
-      am__tar_='pax -L -x $1 -w "$tardir"'
-      am__untar='pax -r'
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
       ;;
-    cpio)
-      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
-      am__untar='cpio -i -H $1 -d'
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
       ;;
-    none)
-      am__tar=false
-      am__tar_=false
-      am__untar=false
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
       ;;
     esac
+done
 
-    # If the value was cached, stop now.  We just wanted to have am__tar
-    # and am__untar set.
-    test -n "${am_cv_prog_tar_$1}" && break
+_LT_OUTPUT_LIBTOOL_INIT
+])
 
-    # tar/untar a dummy directory, and stop if the command works.
-    rm -rf conftest.dir
-    mkdir conftest.dir
-    echo GrepMe > conftest.dir/file
-    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
-    rm -rf conftest.dir
-    if test -s conftest.tar; then
-      AM_RUN_LOG([$am__untar <conftest.tar])
-      AM_RUN_LOG([cat conftest.dir/file])
-      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
-    fi
-  done
-  rm -rf conftest.dir
+# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
+# ------------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable.  If COMMENT is supplied, it is inserted after the
+# `#!' sequence but before initialization text begins.  After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script.  The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],
+[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
+[m4_defun([_LT_GENERATED_FILE_INIT],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[lt_write_fail=0
+cat >$1 <<_ASEOF || lt_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || lt_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test $lt_write_fail = 0 && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
-  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
 
-AC_SUBST([am__tar])
-AC_SUBST([am__untar])
-]) # _AM_PROG_TAR
+cat >>"$CONFIG_LT" <<\_LTEOF
+lt_cl_silent=false
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+  echo
+  AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
 
-# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-#
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
 
-m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
-#
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-])
+Usage: $[0] [[OPTIONS]]
 
-# serial 57 LT_INIT
+  -h, --help      print this help, then exit
+  -V, --version   print version number, then exit
+  -q, --quiet     do not print progress messages
+  -d, --debug     don't remove temporary files
 
+Report bugs to <bug-libtool at gnu.org>."
 
-# LT_PREREQ(VERSION)
-# ------------------
-# Complain and exit if this libtool version is less that VERSION.
-m4_defun([LT_PREREQ],
-[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
-       [m4_default([$3],
-		   [m4_fatal([Libtool version $1 or higher is required],
-		             63)])],
-       [$2])])
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
 
+Copyright (C) 2011 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
 
-# _LT_CHECK_BUILDDIR
-# ------------------
-# Complain if the absolute build directory name contains unusual characters
-m4_defun([_LT_CHECK_BUILDDIR],
-[case `pwd` in
-  *\ * | *\	*)
-    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
-esac
-])
+while test $[#] != 0
+do
+  case $[1] in
+    --version | --v* | -V )
+      echo "$lt_cl_version"; exit 0 ;;
+    --help | --h* | -h )
+      echo "$lt_cl_help"; exit 0 ;;
+    --debug | --d* | -d )
+      debug=: ;;
+    --quiet | --q* | --silent | --s* | -q )
+      lt_cl_silent=: ;;
 
+    -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
 
-# LT_INIT([OPTIONS])
-# ------------------
-AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
-AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-AC_BEFORE([$0], [LT_LANG])dnl
-AC_BEFORE([$0], [LT_OUTPUT])dnl
-AC_BEFORE([$0], [LTDL_INIT])dnl
-m4_require([_LT_CHECK_BUILDDIR])dnl
+    *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+  esac
+  shift
+done
 
-dnl Autoconf doesn't catch unexpanded LT_ macros by default:
-m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
-m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
-dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
-dnl unless we require an AC_DEFUNed macro:
-AC_REQUIRE([LTOPTIONS_VERSION])dnl
-AC_REQUIRE([LTSUGAR_VERSION])dnl
-AC_REQUIRE([LTVERSION_VERSION])dnl
-AC_REQUIRE([LTOBSOLETE_VERSION])dnl
-m4_require([_LT_PROG_LTMAIN])dnl
+if $lt_cl_silent; then
+  exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
 
-_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
 
-dnl Parse OPTIONS
-_LT_SET_OPTIONS([$0], [$1])
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
 
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure.  Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+lt_cl_success=:
+test "$silent" = yes &&
+  lt_config_lt_args="$lt_config_lt_args --quiet"
+exec AS_MESSAGE_LOG_FD>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec AS_MESSAGE_LOG_FD>>config.log
+$lt_cl_success || AS_EXIT(1)
+])# LT_OUTPUT
 
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-AC_SUBST(LIBTOOL)dnl
 
-_LT_SETUP
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars.  Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+  m4_if(_LT_TAG, [C], [
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
 
-# Only expand once:
-m4_define([LT_INIT])
-])# LT_INIT
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
 
-# Old names:
-AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
-AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
-dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
 
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
 
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
-])
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
 
+_LT_EOF
 
-# _LT_FILEUTILS_DEFAULTS
-# ----------------------
-# It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
-m4_defun([_LT_FILEUTILS_DEFAULTS],
-[: ${CP="cp -f"}
-: ${MV="mv -f"}
-: ${RM="rm -f"}
-])# _LT_FILEUTILS_DEFAULTS
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
 
+  _LT_PROG_LTMAIN
 
-# _LT_SETUP
-# ---------
-m4_defun([_LT_SETUP],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
-AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" \
+     || (rm -f "$cfgfile"; exit 1)
 
-_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
-dnl
-_LT_DECL([], [host_alias], [0], [The host system])dnl
-_LT_DECL([], [host], [0])dnl
-_LT_DECL([], [host_os], [0])dnl
-dnl
-_LT_DECL([], [build_alias], [0], [The build system])dnl
-_LT_DECL([], [build], [0])dnl
-_LT_DECL([], [build_os], [0])dnl
-dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([LT_PATH_LD])dnl
-AC_REQUIRE([LT_PATH_NM])dnl
-dnl
-AC_REQUIRE([AC_PROG_LN_S])dnl
-test -z "$LN_S" && LN_S="ln -s"
-_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
-dnl
-AC_REQUIRE([LT_CMD_MAX_LEN])dnl
-_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
-_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
-dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_CHECK_SHELL_FEATURES])dnl
-m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
-m4_require([_LT_CMD_RELOAD])dnl
-m4_require([_LT_CHECK_MAGIC_METHOD])dnl
-m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
-m4_require([_LT_CMD_OLD_ARCHIVE])dnl
-m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
-m4_require([_LT_WITH_SYSROOT])dnl
+  _LT_PROG_REPLACE_SHELLFNS
 
-_LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
-   setopt NO_GLOB_SUBST
-fi
-])
-if test -n "${ZSH_VERSION+set}" ; then
-   setopt NO_GLOB_SUBST
-fi
+   mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
 
-_LT_CHECK_OBJDIR
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
 
-m4_require([_LT_TAG_COMPILER])dnl
 
-case $host_os in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
-  fi
-  ;;
-esac
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
 
-# Global variables:
-ofile=libtool
-can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+  [C],			[_LT_LANG(C)],
+  [C++],		[_LT_LANG(CXX)],
+  [Go],			[_LT_LANG(GO)],
+  [Java],		[_LT_LANG(GCJ)],
+  [Fortran 77],		[_LT_LANG(F77)],
+  [Fortran],		[_LT_LANG(FC)],
+  [Windows Resource],	[_LT_LANG(RC)],
+  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+    [_LT_LANG($1)],
+    [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
 
-# Set sane defaults for various variables
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$LD" && LD=ld
-test -z "$ac_objext" && ac_objext=o
 
-_LT_CC_BASENAME([$compiler])
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+  [LT_SUPPORTED_TAG([$1])dnl
+  m4_append([_LT_TAGS], [$1 ])dnl
+  m4_define([_LT_LANG_]$1[_enabled], [])dnl
+  _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
 
-# Only perform the check for file, if the check method requires it
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    _LT_PATH_MAGIC
-  fi
-  ;;
-esac
 
-# Use C for the default configuration in the libtool script
-LT_SUPPORTED_TAG([CC])
-_LT_LANG_C_CONFIG
-_LT_LANG_DEFAULT_CONFIG
-_LT_CONFIG_COMMANDS
-])# _LT_SETUP
+m4_ifndef([AC_PROG_GO], [
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_GO.  When it is available in    #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+m4_defun([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC],     [Go compiler command])dnl
+AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
+  fi
+fi
+if test -z "$GOC"; then
+  AC_CHECK_PROG(GOC, gccgo, gccgo, false)
+fi
+])#m4_defun
+])#m4_ifndef
 
 
-# _LT_PREPARE_SED_QUOTE_VARS
-# --------------------------
-# Define a few sed substitution that help us do robust quoting.
-m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
-[# Backslashify metacharacters that are still active within
-# double-quoted strings.
-sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+  [LT_LANG(CXX)],
+  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
 
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+  [LT_LANG(F77)],
+  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
 
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+  [LT_LANG(FC)],
+  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
 
-# Sed substitution to delay expansion of an escaped single quote.
-delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+  [LT_LANG(GCJ)],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+    [LT_LANG(GCJ)],
+    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+      [LT_LANG(GCJ)],
+      [m4_ifdef([AC_PROG_GCJ],
+	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([A][M_PROG_GCJ],
+	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([LT_PROG_GCJ],
+	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
 
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-])
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+  [LT_LANG(GO)],
+  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
 
-# _LT_PROG_LTMAIN
-# ---------------
-# Note that this code is called both from `configure', and `config.status'
-# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
-# so we pass a copy along to make sure it has a sensible value anyway.
-m4_defun([_LT_PROG_LTMAIN],
-[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
-_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
-])# _LT_PROG_LTMAIN
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+  [LT_LANG(RC)],
+  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
 
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+dnl AC_DEFUN([AC_LIBTOOL_RC], [])
 
 
-# So that we can recreate a full libtool script including additional
-# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
-# label.
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
 
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
 
-# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
-# ----------------------------------------
-# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
-m4_define([_LT_CONFIG_LIBTOOL_INIT],
-[m4_ifval([$1],
-          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
-                     [$1
-])])])
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
-# Initialize.
-m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
 
-# _LT_CONFIG_LIBTOOL([COMMANDS])
-# ------------------------------
-# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
-m4_define([_LT_CONFIG_LIBTOOL],
-[m4_ifval([$1],
-          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
-                     [$1
-])])])
 
-# Initialize.
-m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
 
 
-# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
-# -----------------------------------------------------
-m4_defun([_LT_CONFIG_SAVE_COMMANDS],
-[_LT_CONFIG_LIBTOOL([$1])
-_LT_CONFIG_LIBTOOL_INIT([$2])
-])
-
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
 
-# _LT_FORMAT_COMMENT([COMMENT])
-# -----------------------------
-# Add leading comment marks to the start of each line, and a trailing
-# full-stop to the whole comment if one is not present already.
-m4_define([_LT_FORMAT_COMMENT],
-[m4_ifval([$1], [
-m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
-              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
-)])
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+    AC_CHECK_TOOL([LIPO], [lipo], [:])
+    AC_CHECK_TOOL([OTOOL], [otool], [:])
+    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+    _LT_DECL([], [DSYMUTIL], [1],
+      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+    _LT_DECL([], [NMEDIT], [1],
+      [Tool to change global to local symbols on Mac OS X])
+    _LT_DECL([], [LIPO], [1],
+      [Tool to manipulate fat objects and archives on Mac OS X])
+    _LT_DECL([], [OTOOL], [1],
+      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+    _LT_DECL([], [OTOOL64], [1],
+      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
 
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	# If there is a non-empty error log, and "single_module"
+	# appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+	  cat conftest.err >&AS_MESSAGE_LOG_FD
+	# Otherwise, if the output was created with a 0 exit code from
+	# the compiler, it worked.
+	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&AS_MESSAGE_LOG_FD
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi])
 
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+	[lt_cv_ld_exported_symbols_list=yes],
+	[lt_cv_ld_exported_symbols_list=no])
+	LDFLAGS="$save_LDFLAGS"
+    ])
 
+    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+      [lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+      echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
+      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -s conftest.err && $GREP force_load conftest.err; then
+	cat conftest.err >&AS_MESSAGE_LOG_FD
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+	lt_cv_ld_force_load=yes
+      else
+	cat conftest.err >&AS_MESSAGE_LOG_FD
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[012]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
 
 
-# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
-# -------------------------------------------------------------------
-# CONFIGNAME is the name given to the value in the libtool script.
-# VARNAME is the (base) name used in the configure script.
-# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
-# VARNAME.  Any other value will be used directly.
-m4_define([_LT_DECL],
-[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
-    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
-	[m4_ifval([$1], [$1], [$2])])
-    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
-    m4_ifval([$4],
-	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
-    lt_dict_add_subkey([lt_decl_dict], [$2],
-	[tagged?], [m4_ifval([$5], [yes], [no])])])
+# _LT_DARWIN_LINKER_FEATURES([TAG])
+# ---------------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_automatic, $1)=yes
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+    m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
+                  [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
+  else
+    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  fi
+  _LT_TAGVAR(link_all_deplibs, $1)=yes
+  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    m4_if([$1], [CXX],
+[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+],[])
+  else
+  _LT_TAGVAR(ld_shlibs, $1)=no
+  fi
 ])
 
+# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
+# ----------------------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+# Store the results from the different compilers for each TAGNAME.
+# Allow to override them for all tags through lt_cv_aix_libpath.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
+  [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
+  lt_aix_libpath_sed='[
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }]'
+  _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi],[])
+  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+  fi
+  ])
+  aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
+fi
+])# _LT_SYS_MODULE_PATH_AIX
 
-# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
-# --------------------------------------------------------
-m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
 
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[m4_divert_text([M4SH-INIT], [$1
+])])# _LT_SHELL_INIT
 
-# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
-# ------------------------------------------------
-m4_define([lt_decl_tag_varnames],
-[_lt_decl_filter([tagged?], [yes], $@)])
 
 
-# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
-# ---------------------------------------------------------
-m4_define([_lt_decl_filter],
-[m4_case([$#],
-  [0], [m4_fatal([$0: too few arguments: $#])],
-  [1], [m4_fatal([$0: too few arguments: $#: $1])],
-  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
-  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
-  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
-])
-
-
-# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
-# --------------------------------------------------
-m4_define([lt_decl_quote_varnames],
-[_lt_decl_filter([value], [1], $@)])
-
-
-# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
-# ---------------------------------------------------
-m4_define([lt_decl_dquote_varnames],
-[_lt_decl_filter([value], [2], $@)])
-
-
-# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
-# ---------------------------------------------------
-m4_define([lt_decl_varnames_tagged],
-[m4_assert([$# <= 2])dnl
-_$0(m4_quote(m4_default([$1], [[, ]])),
-    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
-    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
-m4_define([_lt_decl_varnames_tagged],
-[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
-
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Find how we can fake an echo command that does not interpret backslash.
+# In particular, with Autoconf 2.60 or later we add some code to the start
+# of the generated configure script which will find a shell with a builtin
+# printf (which we can use as an echo command).
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
 
-# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
-# ------------------------------------------------
-m4_define([lt_decl_all_varnames],
-[_$0(m4_quote(m4_default([$1], [[, ]])),
-     m4_if([$2], [],
-	   m4_quote(lt_decl_varnames),
-	m4_quote(m4_shift($@))))[]dnl
-])
-m4_define([_lt_decl_all_varnames],
-[lt_join($@, lt_decl_varnames_tagged([$1],
-			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
-])
+AC_MSG_CHECKING([how to print strings])
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$[]1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
 
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*" 
+}
 
-# _LT_CONFIG_STATUS_DECLARE([VARNAME])
-# ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
-# must have a single quote delimited value for this to work.
-m4_define([_LT_CONFIG_STATUS_DECLARE],
-[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
+case "$ECHO" in
+  printf*) AC_MSG_RESULT([printf]) ;;
+  print*) AC_MSG_RESULT([print -r]) ;;
+  *) AC_MSG_RESULT([cat]) ;;
+esac
 
+m4_ifdef([_AS_DETECT_SUGGESTED],
+[_AS_DETECT_SUGGESTED([
+  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
+    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+    PATH=/empty FPATH=/empty; export PATH FPATH
+    test "X`printf %s $ECHO`" = "X$ECHO" \
+      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
 
-# _LT_CONFIG_STATUS_DECLARATIONS
-# ------------------------------
-# We delimit libtool config variables with single quotes, so when
-# we write them to config.status, we have to be sure to quote all
-# embedded single quotes properly.  In configure, this macro expands
-# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
-#
-#    <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
-m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
-[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
-    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
 
 
-# _LT_LIBTOOL_TAGS
+# _LT_WITH_SYSROOT
 # ----------------
-# Output comment and list of tags supported by the script
-m4_defun([_LT_LIBTOOL_TAGS],
-[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
-])
-
-
-# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
-# -----------------------------------
-# Extract the dictionary values for VARNAME (optionally with TAG) and
-# expand to a commented shell variable setting:
-#
-#    # Some comment about what VAR is for.
-#    visible_name=$lt_internal_name
-m4_define([_LT_LIBTOOL_DECLARE],
-[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
-					   [description])))[]dnl
-m4_pushdef([_libtool_name],
-    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
-m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
-    [0], [_libtool_name=[$]$1],
-    [1], [_libtool_name=$lt_[]$1],
-    [2], [_libtool_name=$lt_[]$1],
-    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
-m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
-])
-
-
-# _LT_LIBTOOL_CONFIG_VARS
-# -----------------------
-# Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
-# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
-# section) are produced by _LT_LIBTOOL_TAG_VARS.
-m4_defun([_LT_LIBTOOL_CONFIG_VARS],
-[m4_foreach([_lt_var],
-    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
-    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
-
+AC_DEFUN([_LT_WITH_SYSROOT],
+[AC_MSG_CHECKING([for sysroot])
+AC_ARG_WITH([sysroot],
+[  --with-sysroot[=DIR] Search for dependent libraries within DIR
+                        (or the compiler's sysroot if not specified).],
+[], [with_sysroot=no])
 
-# _LT_LIBTOOL_TAG_VARS(TAG)
-# -------------------------
-m4_define([_LT_LIBTOOL_TAG_VARS],
-[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
-    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+dnl lt_sysroot will always be passed unquoted.  We quote it here
+dnl in case the user passed a directory name.
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+   if test "$GCC" = yes; then
+     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+   fi
+   ;; #(
+ /*)
+   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+   ;; #(
+ no|'')
+   ;; #(
+ *)
+   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_ERROR([The sysroot must be an absolute path.])
+   ;;
+esac
 
+ AC_MSG_RESULT([${lt_sysroot:-no}])
+_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
+[dependent libraries, and in which our libraries should be installed.])])
 
-# _LT_TAGVAR(VARNAME, [TAGNAME])
-# ------------------------------
-m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+  [AS_HELP_STRING([--disable-libtool-lock],
+    [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
 
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
 
-# _LT_CONFIG_COMMANDS
-# -------------------
-# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
-# variables for single and double quote escaping we saved from calls
-# to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
-# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
-m4_defun([_LT_CONFIG_COMMANDS],
-[AC_PROVIDE_IFELSE([LT_OUTPUT],
-	dnl If the libtool generation code has been placed in $CONFIG_LT,
-	dnl instead of duplicating it all over again into config.status,
-	dnl then we will have config.status run $CONFIG_LT later, so it
-	dnl needs to know what name is stored there:
-        [AC_CONFIG_COMMANDS([libtool],
-            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
-    dnl If the libtool generation code is destined for config.status,
-    dnl expand the accumulated commands and init code now:
-    [AC_CONFIG_COMMANDS([libtool],
-        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
-])#_LT_CONFIG_COMMANDS
-
-
-# Initialize.
-m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
-[
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-sed_quote_subst='$sed_quote_subst'
-double_quote_subst='$double_quote_subst'
-delay_variable_subst='$delay_variable_subst'
-_LT_CONFIG_STATUS_DECLARATIONS
-LTCC='$LTCC'
-LTCFLAGS='$LTCFLAGS'
-compiler='$compiler_DEFAULT'
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-\$[]1
-_LTECHO_EOF'
-}
-
-# Quote evaled strings.
-for var in lt_decl_all_varnames([[ \
-]], lt_decl_quote_varnames); do
-    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
-    *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
-      ;;
-    *)
-      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
-      ;;
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    case `/usr/bin/file conftest.o` in
+	      *x86-64*)
+		LD="${LD-ld} -m elf32_x86_64"
+		;;
+	      *)
+		LD="${LD-ld} -m elf_i386"
+		;;
+	    esac
+	    ;;
+	  powerpc64le-*)
+	    LD="${LD-ld} -m elf32lppclinux"
+	    ;;
+	  powerpc64-*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  powerpcle-*)
+	    LD="${LD-ld} -m elf64lppc"
+	    ;;
+	  powerpc-*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
     esac
-done
+  fi
+  rm -rf conftest*
+  ;;
 
-# Double-quote double-evaled strings.
-for var in lt_decl_all_varnames([[ \
-]], lt_decl_dquote_varnames); do
-    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
-    *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
-      ;;
-    *)
-      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
       ;;
     esac
-done
+  fi
+  rm -rf conftest*
+  ;;
+esac
 
-_LT_OUTPUT_LIBTOOL_INIT
-])
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
 
-# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
-# ------------------------------------
-# Generate a child script FILE with all initialization necessary to
-# reuse the environment learned by the parent script, and make the
-# file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
-# macro, additional text can be appended to FILE to form the body of
-# the child script.  The macro ends with non-zero status if the
-# file could not be fully written (such as if the disk is full).
-m4_ifdef([AS_INIT_GENERATED],
-[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
-[m4_defun([_LT_GENERATED_FILE_INIT],
-[m4_require([AS_PREPARE])]dnl
-[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
-[lt_write_fail=0
-cat >$1 <<_ASEOF || lt_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-$2
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$1 <<\_ASEOF || lt_write_fail=1
-AS_SHELL_SANITIZE
-_AS_PREPARE
-exec AS_MESSAGE_FD>&1
-_ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
-m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
-# LT_OUTPUT
-# ---------
-# This macro allows early generation of the libtool script (before
-# AC_OUTPUT is called), incase it is used in configure for compilation
-# tests.
-AC_DEFUN([LT_OUTPUT],
-[: ${CONFIG_LT=./config.lt}
-AC_MSG_NOTICE([creating $CONFIG_LT])
-_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
-[# Run this file to recreate a libtool stub with the current configuration.])
+# _LT_PROG_AR
+# -----------
+m4_defun([_LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar], false)
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
 
-cat >>"$CONFIG_LT" <<\_LTEOF
-lt_cl_silent=false
-exec AS_MESSAGE_LOG_FD>>config.log
-{
-  echo
-  AS_BOX([Running $as_me.])
-} >&AS_MESSAGE_LOG_FD
+AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
+  [lt_cv_ar_at_file=no
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+     [echo conftest.$ac_objext > conftest.lst
+      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
+      AC_TRY_EVAL([lt_ar_try])
+      if test "$ac_status" -eq 0; then
+	# Ensure the archiver fails upon bogus file names.
+	rm -f conftest.$ac_objext libconftest.a
+	AC_TRY_EVAL([lt_ar_try])
+	if test "$ac_status" -ne 0; then
+          lt_cv_ar_at_file=@
+        fi
+      fi
+      rm -f conftest.* libconftest.a
+     ])
+  ])
 
-lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
-for use in further configure time tests before the real libtool is
-generated.
+if test "x$lt_cv_ar_at_file" = xno; then
+  archiver_list_spec=
+else
+  archiver_list_spec=$lt_cv_ar_at_file
+fi
+_LT_DECL([], [archiver_list_spec], [1],
+  [How to feed a file listing to the archiver])
+])# _LT_PROG_AR
 
-Usage: $[0] [[OPTIONS]]
 
-  -h, --help      print this help, then exit
-  -V, --version   print version number, then exit
-  -q, --quiet     do not print progress messages
-  -d, --debug     don't remove temporary files
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[_LT_PROG_AR
 
-Report bugs to <bug-libtool at gnu.org>."
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
 
-lt_cl_version="\
-m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
-m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
-configured by $[0], generated by m4_PACKAGE_STRING.
-
-Copyright (C) 2011 Free Software Foundation, Inc.
-This config.lt script is free software; the Free Software Foundation
-gives unlimited permision to copy, distribute and modify it."
-
-while test $[#] != 0
-do
-  case $[1] in
-    --version | --v* | -V )
-      echo "$lt_cl_version"; exit 0 ;;
-    --help | --h* | -h )
-      echo "$lt_cl_help"; exit 0 ;;
-    --debug | --d* | -d )
-      debug=: ;;
-    --quiet | --q* | --silent | --s* | -q )
-      lt_cl_silent=: ;;
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+    [Commands used to install an old-style archive])
 
-    -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
 
-    *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    ;;
   esac
-  shift
-done
-
-if $lt_cl_silent; then
-  exec AS_MESSAGE_FD>/dev/null
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
 fi
-_LTEOF
 
-cat >>"$CONFIG_LT" <<_LTEOF
-_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
-_LTEOF
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+    [Commands used to build an old-style archive])
+_LT_DECL([], [lock_old_archive_extraction], [0],
+    [Whether to use a lock for old archive extraction])
+])# _LT_CMD_OLD_ARCHIVE
 
-cat >>"$CONFIG_LT" <<\_LTEOF
-AC_MSG_NOTICE([creating $ofile])
-_LT_OUTPUT_LIBTOOL_COMMANDS
-AS_EXIT(0)
-_LTEOF
-chmod +x "$CONFIG_LT"
 
-# configure is writing to config.log, but config.lt does its own redirection,
-# appending to config.log, which fails on DOS, as config.log is still kept
-# open by configure.  Here we exec the FD to /dev/null, effectively closing
-# config.log, so it can be properly (re)opened and appended to by config.lt.
-lt_cl_success=:
-test "$silent" = yes &&
-  lt_config_lt_args="$lt_config_lt_args --quiet"
-exec AS_MESSAGE_LOG_FD>/dev/null
-$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
-exec AS_MESSAGE_LOG_FD>>config.log
-$lt_cl_success || AS_EXIT(1)
-])# LT_OUTPUT
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $RM conftest*
+])
 
+if test x"[$]$2" = xyes; then
+    m4_if([$5], , :, [$5])
+else
+    m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
 
-# _LT_CONFIG(TAG)
-# ---------------
-# If TAG is the built-in tag, create an initial libtool script with a
-# default configuration from the untagged config vars.  Otherwise add code
-# to config.status for appending the configuration named by TAG from the
-# matching tagged config vars.
-m4_defun([_LT_CONFIG],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-_LT_CONFIG_SAVE_COMMANDS([
-  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
-  m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
-    # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
-      setopt NO_GLOB_SUBST
-    fi
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
 
-    cfgfile="${ofile}T"
-    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
-    $RM "$cfgfile"
 
-    cat <<_LT_EOF >> "$cfgfile"
-#! $SHELL
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                  [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
 
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-_LT_COPYING
-_LT_LIBTOOL_TAGS
+if test x"[$]$2" = xyes; then
+    m4_if([$4], , :, [$4])
+else
+    m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
 
-# ### BEGIN LIBTOOL CONFIG
-_LT_LIBTOOL_CONFIG_VARS
-_LT_LIBTOOL_TAG_VARS
-# ### END LIBTOOL CONFIG
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
 
-_LT_EOF
 
-  case $host_os in
-  aix3*)
-    cat <<\_LT_EOF >> "$cfgfile"
-# AIX sometimes has problems with the GCC collect2 program.  For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
-  COLLECT_NAMES=
-  export COLLECT_NAMES
-fi
-_LT_EOF
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
     ;;
-  esac
 
-  _LT_PROG_LTMAIN
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
 
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" \
-     || (rm -f "$cfgfile"; exit 1)
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
-  _LT_PROG_REPLACE_SHELLFNS
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
-   mv -f "$cfgfile" "$ofile" ||
-    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
-  chmod +x "$ofile"
-],
-[cat <<_LT_EOF >> "$ofile"
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
-dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
-dnl in a comment (ie after a #).
-# ### BEGIN LIBTOOL TAG CONFIG: $1
-_LT_LIBTOOL_TAG_VARS(_LT_TAG)
-# ### END LIBTOOL TAG CONFIG: $1
-_LT_EOF
-])dnl /m4_if
-],
-[m4_if([$1], [], [
-    PACKAGE='$PACKAGE'
-    VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
-    RM='$RM'
-    ofile='$ofile'], [])
-])dnl /_LT_CONFIG_SAVE_COMMANDS
-])# _LT_CONFIG
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
 
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
 
-# LT_SUPPORTED_TAG(TAG)
-# ---------------------
-# Trace this macro to discover what tags are supported by the libtool
-# --tag option, using:
-#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
-AC_DEFUN([LT_SUPPORTED_TAG], [])
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
 
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len" && \
+	test undefined != "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+    [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
 
-# C support is built-in for now
-m4_define([_LT_LANG_C_enabled], [])
-m4_define([_LT_TAGS], [])
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
 
 
-# LT_LANG(LANG)
-# -------------
-# Enable libtool support for the given language if not already enabled.
-AC_DEFUN([LT_LANG],
-[AC_BEFORE([$0], [LT_OUTPUT])dnl
-m4_case([$1],
-  [C],			[_LT_LANG(C)],
-  [C++],		[_LT_LANG(CXX)],
-  [Go],			[_LT_LANG(GO)],
-  [Java],		[_LT_LANG(GCJ)],
-  [Fortran 77],		[_LT_LANG(F77)],
-  [Fortran],		[_LT_LANG(FC)],
-  [Windows Resource],	[_LT_LANG(RC)],
-  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
-    [_LT_LANG($1)],
-    [m4_fatal([$0: unsupported language: "$1"])])])dnl
-])# LT_LANG
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
 
 
-# _LT_LANG(LANGNAME)
-# ------------------
-m4_defun([_LT_LANG],
-[m4_ifdef([_LT_LANG_]$1[_enabled], [],
-  [LT_SUPPORTED_TAG([$1])dnl
-  m4_append([_LT_TAGS], [$1 ])dnl
-  m4_define([_LT_LANG_]$1[_enabled], [])dnl
-  _LT_LANG_$1_CONFIG($1)])dnl
-])# _LT_LANG
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+[#line $LINENO "configure"
+#include "confdefs.h"
 
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
-m4_ifndef([AC_PROG_GO], [
-# NOTE: This macro has been submitted for inclusion into   #
-#  GNU Autoconf as AC_PROG_GO.  When it is available in    #
-#  a released version of Autoconf we should remove this    #
-#  macro and use it instead.                               #
-m4_defun([AC_PROG_GO],
-[AC_LANG_PUSH(Go)dnl
-AC_ARG_VAR([GOC],     [Go compiler command])dnl
-AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
-_AC_ARG_VAR_LDFLAGS()dnl
-AC_CHECK_TOOL(GOC, gccgo)
-if test -z "$GOC"; then
-  if test -n "$ac_tool_prefix"; then
-    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
-  fi
-fi
-if test -z "$GOC"; then
-  AC_CHECK_PROG(GOC, gccgo, gccgo, false)
-fi
-])#m4_defun
-])#m4_ifndef
+#include <stdio.h>
 
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-# _LT_LANG_DEFAULT_CONFIG
-# -----------------------
-m4_defun([_LT_LANG_DEFAULT_CONFIG],
-[AC_PROVIDE_IFELSE([AC_PROG_CXX],
-  [LT_LANG(CXX)],
-  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-AC_PROVIDE_IFELSE([AC_PROG_F77],
-  [LT_LANG(F77)],
-  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
 
-AC_PROVIDE_IFELSE([AC_PROG_FC],
-  [LT_LANG(FC)],
-  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
-dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
-dnl pulling things in needlessly.
-AC_PROVIDE_IFELSE([AC_PROG_GCJ],
-  [LT_LANG(GCJ)],
-  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
-    [LT_LANG(GCJ)],
-    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
-      [LT_LANG(GCJ)],
-      [m4_ifdef([AC_PROG_GCJ],
-	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
-       m4_ifdef([A][M_PROG_GCJ],
-	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
-       m4_ifdef([LT_PROG_GCJ],
-	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+	}
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
 
-AC_PROVIDE_IFELSE([AC_PROG_GO],
-  [LT_LANG(GO)],
-  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+  return status;
+}]
+_LT_EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
 
-AC_PROVIDE_IFELSE([LT_PROG_RC],
-  [LT_LANG(RC)],
-  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
-])# _LT_LANG_DEFAULT_CONFIG
 
-# Obsolete macros:
-AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
-AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
-AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
-AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
-AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
-dnl AC_DEFUN([AC_LIBTOOL_F77], [])
-dnl AC_DEFUN([AC_LIBTOOL_FC], [])
-dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
-dnl AC_DEFUN([AC_LIBTOOL_RC], [])
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
 
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
 
-# _LT_TAG_COMPILER
-# ----------------
-m4_defun([_LT_TAG_COMPILER],
-[AC_REQUIRE([AC_PROG_CC])dnl
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
 
-_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
-_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
-_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
-_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+    ;;
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+  *)
+    AC_CHECK_FUNC([shl_load],
+	  [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	[AC_CHECK_FUNC([dlopen],
+	      [lt_cv_dlopen="dlopen"],
+	  [AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+	    [AC_CHECK_LIB([svld], [dlopen],
+		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+	      [AC_CHECK_LIB([dld], [dld_link],
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+	      ])
+	    ])
+	  ])
+	])
+      ])
+    ;;
+  esac
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
-])# _LT_TAG_COMPILER
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
 
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-m4_defun([_LT_COMPILER_BOILERPLATE],
-[m4_require([_LT_DECL_SED])dnl
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
-])# _LT_COMPILER_BOILERPLATE
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
 
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-m4_defun([_LT_LINKER_BOILERPLATE],
-[m4_require([_LT_DECL_SED])dnl
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
-])# _LT_LINKER_BOILERPLATE
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+	  lt_cv_dlopen_self, [dnl
+	  _LT_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
 
-# _LT_REQUIRED_DARWIN_CHECKS
-# -------------------------
-m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
-  case $host_os in
-    rhapsody* | darwin*)
-    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
-    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
-    AC_CHECK_TOOL([LIPO], [lipo], [:])
-    AC_CHECK_TOOL([OTOOL], [otool], [:])
-    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
-    _LT_DECL([], [DSYMUTIL], [1],
-      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
-    _LT_DECL([], [NMEDIT], [1],
-      [Tool to change global to local symbols on Mac OS X])
-    _LT_DECL([], [LIPO], [1],
-      [Tool to manipulate fat objects and archives on Mac OS X])
-    _LT_DECL([], [OTOOL], [1],
-      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
-    _LT_DECL([], [OTOOL64], [1],
-      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+	  lt_cv_dlopen_self_static, [dnl
+	  _LT_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
 
-    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
-      [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
-	# By default we will add the -single_module flag. You can override
-	# by either setting the environment variable LT_MULTI_MODULE
-	# non-empty at configure time, or by adding -multi_module to the
-	# link flags.
-	rm -rf libconftest.dylib*
-	echo "int foo(void){return 1;}" > conftest.c
-	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
--dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
-	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
-        _lt_result=$?
-	# If there is a non-empty error log, and "single_module"
-	# appears in it, assume the flag caused a linker warning
-        if test -s conftest.err && $GREP single_module conftest.err; then
-	  cat conftest.err >&AS_MESSAGE_LOG_FD
-	# Otherwise, if the output was created with a 0 exit code from
-	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
-	  lt_cv_apple_cc_single_mod=yes
-	else
-	  cat conftest.err >&AS_MESSAGE_LOG_FD
-	fi
-	rm -rf libconftest.dylib*
-	rm -f conftest.*
-      fi])
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
 
-    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
-      [lt_cv_ld_exported_symbols_list],
-      [lt_cv_ld_exported_symbols_list=no
-      save_LDFLAGS=$LDFLAGS
-      echo "_main" > conftest.sym
-      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
-      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
-	[lt_cv_ld_exported_symbols_list=yes],
-	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
-    ])
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
 
-    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
-      [lt_cv_ld_force_load=no
-      cat > conftest.c << _LT_EOF
-int forced_loaded() { return 2;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
-      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
-      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
-      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
-      echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
-      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
-      cat > conftest.c << _LT_EOF
-int main() { return 0;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
-      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
-      _lt_result=$?
-      if test -s conftest.err && $GREP force_load conftest.err; then
-	cat conftest.err >&AS_MESSAGE_LOG_FD
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
-	lt_cv_ld_force_load=yes
-      else
-	cat conftest.err >&AS_MESSAGE_LOG_FD
-      fi
-        rm -f conftest.err libconftest.a conftest conftest.c
-        rm -rf conftest.dSYM
-    ])
-    case $host_os in
-    rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
-    darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
-    darwin*) # darwin 5.x on
-      # if running on 10.5 or later, the deployment target defaults
-      # to the OS version, if on x86, and 10.4, the deployment
-      # target defaults to 10.4. Don't you love it?
-      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
-	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-      esac
-    ;;
-  esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
-      _lt_dar_single_mod='$single_module'
-    fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
-    else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
-      _lt_dsymutil='~$DSYMUTIL $lib || :'
-    else
-      _lt_dsymutil=
-    fi
-    ;;
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
   esac
-])
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+	 [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+	 [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+	 [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
 
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
 
-# _LT_DARWIN_LINKER_FEATURES([TAG])
-# ---------------------------------
-# Checks for linker and compiler features on darwin
-m4_defun([_LT_DARWIN_LINKER_FEATURES],
-[
-  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
-  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-  _LT_TAGVAR(hardcode_direct, $1)=no
-  _LT_TAGVAR(hardcode_automatic, $1)=yes
-  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
-    m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
-                  [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
-  else
-    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
-  fi
-  _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
-  case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
-     *) _lt_dar_can_shared=$GCC ;;
-  esac
-  if test "$_lt_dar_can_shared" = "yes"; then
-    output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-    m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
-    fi
-],[])
-  else
-  _LT_TAGVAR(ld_shlibs, $1)=no
-  fi
-])
 
-# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
-# ----------------------------------
-# Links a minimal program and checks the executable
-# for the system default hardcoded library path. In most cases,
-# this is /usr/lib:/lib, but when the MPI compilers are used
-# the location of the communication and MPI libs are included too.
-# If we don't find anything, use the default library path according
-# to the aix ld manual.
-# Store the results from the different compilers for each TAGNAME.
-# Allow to override them for all tags through lt_cv_aix_libpath.
-m4_defun([_LT_SYS_MODULE_PATH_AIX],
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
 [m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
-  [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
-  lt_aix_libpath_sed='[
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }]'
-  _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi],[])
-  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
-  fi
-  ])
-  aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
-fi
-])# _LT_SYS_MODULE_PATH_AIX
-
-
-# _LT_SHELL_INIT(ARG)
-# -------------------
-m4_define([_LT_SHELL_INIT],
-[m4_divert_text([M4SH-INIT], [$1
-])])# _LT_SHELL_INIT
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+	[Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
 
 
-# _LT_PROG_ECHO_BACKSLASH
-# -----------------------
-# Find how we can fake an echo command that does not interpret backslash.
-# In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
-m4_defun([_LT_PROG_ECHO_BACKSLASH],
-[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
 
-AC_MSG_CHECKING([how to print strings])
-# Test print first, because it will be a builtin if present.
-if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
-   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='print -r --'
-elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='printf %s\n'
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
 else
-  # Use this function as a fallback that always works.
-  func_fallback_echo ()
-  {
-    eval 'cat <<_LTECHO_EOF
-$[]1
-_LTECHO_EOF'
-  }
-  ECHO='func_fallback_echo'
+  need_locks=no
 fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*" 
-}
 
-case "$ECHO" in
-  printf*) AC_MSG_RESULT([printf]) ;;
-  print*) AC_MSG_RESULT([print -r]) ;;
-  *) AC_MSG_RESULT([cat]) ;;
-esac
-
-m4_ifdef([_AS_DETECT_SUGGESTED],
-[_AS_DETECT_SUGGESTED([
-  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
-    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
-    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
-    PATH=/empty FPATH=/empty; export PATH FPATH
-    test "X`printf %s $ECHO`" = "X$ECHO" \
-      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
-
-_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
-_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
-])# _LT_PROG_ECHO_BACKSLASH
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+         [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
 
 
-# _LT_WITH_SYSROOT
-# ----------------
-AC_DEFUN([_LT_WITH_SYSROOT],
-[AC_MSG_CHECKING([for sysroot])
-AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
-[], [with_sysroot=no])
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
 
-dnl lt_sysroot will always be passed unquoted.  We quote it here
-dnl in case the user passed a directory name.
-lt_sysroot=
-case ${with_sysroot} in #(
- yes)
-   if test "$GCC" = yes; then
-     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
-   fi
-   ;; #(
- /*)
-   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
-   ;; #(
- no|'')
-   ;; #(
- *)
-   AC_MSG_RESULT([${with_sysroot}])
-   AC_MSG_ERROR([The sysroot must be an absolute path.])
-   ;;
-esac
+  # We can hardcode non-existent directories.
+  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
 
- AC_MSG_RESULT([${lt_sysroot:-no}])
-_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+    [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
 
-# _LT_ENABLE_LOCK
-# ---------------
-m4_defun([_LT_ENABLE_LOCK],
-[AC_ARG_ENABLE([libtool-lock],
-  [AS_HELP_STRING([--disable-libtool-lock],
-    [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
 
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.$ac_objext` in
-      *ELF-32*)
-	HPUX_IA64_MODE="32"
-	;;
-      *ELF-64*)
-	HPUX_IA64_MODE="64"
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-*-*-irix6*)
-  # Find out which ABI we are using.
-  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -melf32bsmip"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -melf32bmipn32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -melf64bmip"
-	;;
-      esac
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      AC_MSG_RESULT([yes])
     else
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -32"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -n32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -64"
-	  ;;
-      esac
+      AC_MSG_RESULT([no])
     fi
-  fi
-  rm -rf conftest*
-  ;;
+    ;;
+  *)
+    AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
-s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-      *32-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_i386_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    case `/usr/bin/file conftest.o` in
-	      *x86-64*)
-		LD="${LD-ld} -m elf32_x86_64"
-		;;
-	      *)
-		LD="${LD-ld} -m elf_i386"
-		;;
-	    esac
-	    ;;
-	  powerpc64le-*)
-	    LD="${LD-ld} -m elf32lppclinux"
-	    ;;
-	  powerpc64-*)
-	    LD="${LD-ld} -m elf32ppclinux"
-	    ;;
-	  s390x-*linux*)
-	    LD="${LD-ld} -m elf_s390"
-	    ;;
-	  sparc64-*linux*)
-	    LD="${LD-ld} -m elf32_sparc"
-	    ;;
-	esac
-	;;
-      *64-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_x86_64_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_x86_64"
-	    ;;
-	  powerpcle-*)
-	    LD="${LD-ld} -m elf64lppc"
-	    ;;
-	  powerpc-*)
-	    LD="${LD-ld} -m elf64ppc"
-	    ;;
-	  s390*-*linux*|s390*-*tpf*)
-	    LD="${LD-ld} -m elf64_s390"
-	    ;;
-	  sparc*-*linux*)
-	    LD="${LD-ld} -m elf64_sparc"
-	    ;;
-	esac
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
 
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -belf"
-  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
-    [AC_LANG_PUSH(C)
-     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
-     AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
-  fi
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+	[], [
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
+    *) lt_sed_strip_eq="s,=/,/,g" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
   ;;
-*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*)
-        case $host in
-        i?86-*-solaris*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        sparc*-*-solaris*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-        esac
-        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
-        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
-        fi
-        ;;
-      *)
-	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
-	  LD="${LD-ld} -64"
-	fi
-	;;
-      esac
+
+aix[[4-9]]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
       ;;
     esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
   fi
-  rm -rf conftest*
   ;;
-esac
-
-need_locks="$enable_libtool_lock"
-])# _LT_ENABLE_LOCK
 
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
 
-# _LT_PROG_AR
-# -----------
-m4_defun([_LT_PROG_AR],
-[AC_CHECK_TOOLS(AR, [ar], false)
-: ${AR=ar}
-: ${AR_FLAGS=cru}
-_LT_DECL([], [AR], [1], [The archiver])
-_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
-
-AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
-  [lt_cv_ar_at_file=no
-   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
-     [echo conftest.$ac_objext > conftest.lst
-      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
-      AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
-	# Ensure the archiver fails upon bogus file names.
-	rm -f conftest.$ac_objext libconftest.a
-	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
-          lt_cv_ar_at_file=@
-        fi
-      fi
-      rm -f conftest.* libconftest.a
-     ])
-  ])
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
-if test "x$lt_cv_ar_at_file" = xno; then
-  archiver_list_spec=
-else
-  archiver_list_spec=$lt_cv_ar_at_file
-fi
-_LT_DECL([], [archiver_list_spec], [1],
-  [How to feed a file listing to the archiver])
-])# _LT_PROG_AR
+bsdi[[45]]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
 
-# _LT_CMD_OLD_ARCHIVE
-# -------------------
-m4_defun([_LT_CMD_OLD_ARCHIVE],
-[_LT_PROG_AR
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
-AC_CHECK_TOOL(STRIP, strip, :)
-test -z "$STRIP" && STRIP=:
-_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+m4_if([$1], [],[
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
 
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-test -z "$RANLIB" && RANLIB=:
-_LT_DECL([], [RANLIB], [1],
-    [Commands used to install an old-style archive])
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
 
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
 
-if test -n "$RANLIB"; then
-  case $host_os in
-  openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
     ;;
+
   *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
     ;;
   esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
-fi
-
-case $host_os in
-  darwin*)
-    lock_old_archive_extraction=yes ;;
-  *)
-    lock_old_archive_extraction=no ;;
-esac
-_LT_DECL([], [old_postinstall_cmds], [2])
-_LT_DECL([], [old_postuninstall_cmds], [2])
-_LT_TAGDECL([], [old_archive_cmds], [2],
-    [Commands used to build an old-style archive])
-_LT_DECL([], [lock_old_archive_extraction], [0],
-    [Whether to use a lock for old archive extraction])
-])# _LT_CMD_OLD_ARCHIVE
-
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
-# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([_LT_COMPILER_OPTION],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_SED])dnl
-AC_CACHE_CHECK([$1], [$2],
-  [$2=no
-   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&AS_MESSAGE_LOG_FD
-   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       $2=yes
-     fi
-   fi
-   $RM conftest*
-])
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
-if test x"[$]$2" = xyes; then
-    m4_if([$5], , :, [$5])
-else
-    m4_if([$6], , :, [$6])
-fi
-])# _LT_COMPILER_OPTION
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-# Old name:
-AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[23]].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
 
-# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-#                  [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------
-# Check whether the given linker option works
-AC_DEFUN([_LT_LINKER_OPTION],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_SED])dnl
-AC_CACHE_CHECK([$1], [$2],
-  [$2=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $3"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&AS_MESSAGE_LOG_FD
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         $2=yes
-       fi
-     else
-       $2=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
-])
-
-if test x"[$]$2" = xyes; then
-    m4_if([$4], , :, [$4])
-else
-    m4_if([$5], , :, [$5])
-fi
-])# _LT_LINKER_OPTION
-
-# Old name:
-AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
-
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
 
-# LT_CMD_MAX_LEN
-#---------------
-AC_DEFUN([LT_CMD_MAX_LEN],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-# find the maximum length of command line arguments
-AC_MSG_CHECKING([the maximum length of command line arguments])
-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
-  i=0
-  teststring="ABCD"
+interix[[3-9]]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux # correct to gnu/linux during the next big refactor
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
     ;;
-
-  gnu*)
-    # Under GNU Hurd, this test is not required because there is
-    # no limit to the length of command line arguments.
-    # Libtool will interpret -1 as no limit whatsoever
-    lt_cv_sys_max_cmd_len=-1;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
     ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
 
-  cygwin* | mingw* | cegcc*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
-  mint*)
-    # On MiNT this can take a long time and run out of memory.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
 
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+  # Some binutils ld are patched to set DT_RUNPATH
+  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
+    [lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+	 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+	 [lt_cv_shlibpath_overrides_runpath=yes])])
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+    ])
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
 
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
 
-  os2*)
-    # The test takes a long time on OS/2.
-    lt_cv_sys_max_cmd_len=8192
-    ;;
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
 
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
-    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
-    if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    else
-      # Make teststring a little bigger before we do anything with it.
-      # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
-        teststring=$teststring$teststring
-      done
-      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-      # If test is not a shell built-in, we'll probably end up computing a
-      # maximum length that is only half of the actual maximum length, but
-      # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
-	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
-      do
-        i=`expr $i + 1`
-        teststring=$teststring$teststring
-      done
-      # Only check the string length outside the loop.
-      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
-      teststring=
-      # Add a significant safety factor because C++ compilers can tack on
-      # massive amounts of additional arguments before passing them to the
-      # linker.  It appears as though 1/2 is a usable value.
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
-    fi
-    ;;
-  esac
-])
-if test -n $lt_cv_sys_max_cmd_len ; then
-  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
-else
-  AC_MSG_RESULT(none)
-fi
-max_cmd_len=$lt_cv_sys_max_cmd_len
-_LT_DECL([], [max_cmd_len], [0],
-    [What is the maximum length of a command?])
-])# LT_CMD_MAX_LEN
-
-# Old name:
-AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
 
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-# _LT_HEADER_DLFCN
-# ----------------
-m4_defun([_LT_HEADER_DLFCN],
-[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
-])# _LT_HEADER_DLFCN
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
 
-# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
-#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ----------------------------------------------------------------
-m4_defun([_LT_TRY_DLOPEN_SELF],
-[m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
-  [$4]
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-[#line $LINENO "configure"
-#include "confdefs.h"
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
 
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
 
-#include <stdio.h>
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
 
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
+rdos*)
+  dynamic_linker=no
+  ;;
 
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
-   correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
-int fnord () __attribute__((visibility("default")));
-#endif
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
 
-int fnord () { return 42; }
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
 
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else
-        {
-	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
-          else puts (dlerror ());
-	}
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
 
-  return status;
-}]
-_LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) $1 ;;
-      x$lt_dlneed_uscore) $2 ;;
-      x$lt_dlunknown|x*) $3 ;;
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
     esac
-  else :
-    # compilation failed
-    $3
   fi
-fi
-rm -fr conftest*
-])# _LT_TRY_DLOPEN_SELF
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
 
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
-# LT_SYS_DLOPEN_SELF
-# ------------------
-AC_DEFUN([LT_SYS_DLOPEN_SELF],
-[m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-  case $host_os in
-  beos*)
-    lt_cv_dlopen="load_add_on"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ;;
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
 
-  mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
-    lt_cv_dlopen_libs=
-    ;;
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
 
-  cygwin*)
-    lt_cv_dlopen="dlopen"
-    lt_cv_dlopen_libs=
-    ;;
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
 
-  darwin*)
-  # if libdl is installed we need to link against it
-    AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ])
-    ;;
+_LT_DECL([], [variables_saved_for_relink], [1],
+    [Variables whose values should be saved in libtool wrapper scripts and
+    restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+    [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+    [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+    [[List of archive names.  First name is the real one, the rest are links.
+    The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+    [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+    [Permission mode override for installation of shared libraries])
+_LT_DECL([], [postinstall_cmds], [2],
+    [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+    [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+    [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+    [[As "finish_cmds", except a single script fragment to be evaled but
+    not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+    [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+    [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+    [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
 
-  *)
-    AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
-      [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
-	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
-	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
-	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
-	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
-	      ])
-	    ])
-	  ])
-	])
-      ])
-    ;;
-  esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="m4_if([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
 
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
 
-    save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
 
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
 
-    AC_CACHE_CHECK([whether a program can dlopen itself],
-	  lt_cv_dlopen_self, [dnl
-	  _LT_TRY_DLOPEN_SELF(
-	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
-	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
-    ])
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
-	  lt_cv_dlopen_self_static, [dnl
-	  _LT_TRY_DLOPEN_SELF(
-	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
-	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
-      ])
-    fi
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# _LT_PATH_MAGIC
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
 
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
 
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
+AC_ARG_WITH([gnu-ld],
+    [AS_HELP_STRING([--with-gnu-ld],
+	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
   esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
 fi
-_LT_DECL([dlopen_support], [enable_dlopen], [0],
-	 [Whether dlopen is supported])
-_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
-	 [Whether dlopen of programs is supported])
-_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
-	 [Whether dlopen of statically linked programs is supported])
-])# LT_SYS_DLOPEN_SELF
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
 
-# Old name:
-AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
 dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
 
 
-# _LT_COMPILER_C_O([TAGNAME])
-# ---------------------------
-# Check to see if options -c and -o are simultaneously supported by compiler.
-# This macro does not hard code the compiler like AC_PROG_CC_C_O.
-m4_defun([_LT_COMPILER_C_O],
-[m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_TAG_COMPILER])dnl
-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
-  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
-  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&AS_MESSAGE_LOG_FD
-   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-     fi
-   fi
-   chmod u+w . 2>&AS_MESSAGE_LOG_FD
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
-])
-_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
-	[Does compiler simultaneously support -c and -o options?])
-])# _LT_COMPILER_C_O
 
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    if test "$GCC" != yes; then
+      reload_cmds=false
+    fi
+    ;;
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_TAGDECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
 
-# _LT_COMPILER_FILE_LOCKS([TAGNAME])
-# ----------------------------------
-# Check to see if we can do hard links to lock some files if needed
-m4_defun([_LT_COMPILER_FILE_LOCKS],
-[m4_require([_LT_ENABLE_LOCK])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-_LT_COMPILER_C_O([$1])
 
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  AC_MSG_CHECKING([if we can lock with hard links])
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
-])# _LT_COMPILER_FILE_LOCKS
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
 
+case $host_os in
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# _LT_CHECK_OBJDIR
-# ----------------
-m4_defun([_LT_CHECK_OBJDIR],
-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
-[rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  lt_cv_objdir=.libs
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null])
-objdir=$lt_cv_objdir
-_LT_DECL([], [objdir], [0],
-         [The name of the directory that contains temporary libtool files])dnl
-m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
-])# _LT_CHECK_OBJDIR
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
 
-# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
-# --------------------------------------
-# Check hardcoding attributes.
-m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
-[AC_MSG_CHECKING([how to hardcode library paths into programs])
-_LT_TAGVAR(hardcode_action, $1)=
-if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
-   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
 
-  # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
-    # Linking always hardcodes the temporary library directory.
-    _LT_TAGVAR(hardcode_action, $1)=relink
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
   else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    _LT_TAGVAR(hardcode_action, $1)=immediate
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
   fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  _LT_TAGVAR(hardcode_action, $1)=unsupported
-fi
-AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+  ;;
 
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-_LT_TAGDECL([], [hardcode_action], [0],
-    [How to hardcode a shared library path into an executable])
-])# _LT_LINKER_HARDCODE_LIBPATH
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
 
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# _LT_CMD_STRIPLIB
-# ----------------
-m4_defun([_LT_CMD_STRIPLIB],
-[m4_require([_LT_DECL_EGREP])
-striplib=
-old_striplib=
-AC_MSG_CHECKING([whether stripping libraries is possible])
-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  AC_MSG_RESULT([yes])
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-  darwin*)
-    if test -n "$STRIP" ; then
-      striplib="$STRIP -x"
-      old_striplib="$STRIP -S"
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_RESULT([no])
-    fi
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
     ;;
   *)
-    AC_MSG_RESULT([no])
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
     ;;
   esac
-fi
-_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
-_LT_DECL([], [striplib], [1])
-])# _LT_CMD_STRIPLIB
+  ;;
 
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
 
-# _LT_SYS_DYNAMIC_LINKER([TAG])
-# -----------------------------
-# PORTME Fill in your ld.so characteristics
-m4_defun([_LT_SYS_DYNAMIC_LINKER],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_OBJDUMP])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_CHECK_SHELL_FEATURES])dnl
-AC_MSG_CHECKING([dynamic linker characteristics])
-m4_if([$1],
-	[], [
-if test "$GCC" = yes; then
-  case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
-  esac
-  case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
-  esac
-  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
-  case $lt_search_path_spec in
-  *\;*)
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
-    ;;
-  *)
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
-    ;;
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
   esac
-  # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
-  lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
-  for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
-      test -d "$lt_sys_path" && \
-	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
-    fi
-  done
-  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
-  for (lt_i = NF; lt_i > 0; lt_i--) {
-    if ($lt_i != "" && $lt_i != ".") {
-      if ($lt_i == "..") {
-        lt_count++;
-      } else {
-        if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
-        } else {
-          lt_count--;
-        }
-      }
-    }
-  }
-  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
-  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
-}'`
-  # AWK program above erroneously prepends '/' to C:/dos/paths
-  # for these hosts.
-  case $host_os in
-    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
-  esac
-  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi])
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-case $host_os in
-aix3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+netbsd* | netbsdelf*-gnu)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
   ;;
 
-aix[[4-9]]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
   else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[[01]] | aix4.[[01]].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   fi
   ;;
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
   ;;
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
   ;;
 
-bsdi[[45]]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
   ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-  case $GCC,$cc_basename in
-  yes,*)
-    # gcc
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-m4_if([$1], [],[
-      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
-      ;;
-    mingw* | cegcc*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    dynamic_linker='Win32 ld.exe'
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+  case $host_os in
+  mingw* | pw32*)
+    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+      want_nocaseglob=yes
+    else
+      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
+    fi
     ;;
+  esac
+fi
 
-  *,cl*)
-    # Native MSVC
-    libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
-    case $build_os in
-    mingw*)
-      sys_lib_search_path_spec=
-      lt_save_ifs=$IFS
-      IFS=';'
-      for lt_path in $LIB
-      do
-        IFS=$lt_save_ifs
-        # Let DOS variable expansion print the short 8.3 style file name.
-        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
-        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
-      done
-      IFS=$lt_save_ifs
-      # Convert to MSYS style.
-      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
-      ;;
-    cygwin*)
-      # Convert to unix form, then to dos form, then back to unix form
-      # but this time dos style (no spaces!) so that the unix form looks
-      # like /cygdrive/c/PROGRA~1:/cygdr...
-      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
-      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
-      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+_LT_DECL([], [deplibs_check_method], [1],
+    [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+    [Command to use when deplibs_check_method = "file_magic"])
+_LT_DECL([], [file_magic_glob], [1],
+    [How to find potential files when deplibs_check_method = "file_magic"])
+_LT_DECL([], [want_nocaseglob], [1],
+    [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
-      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
-        # It is most probably a Windows format PATH.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      # FIXME: find the short name or the path components, as spaces are
-      # common. (e.g. "Program Files" -> "PROGRA~1")
+      DUMPBIN=:
       ;;
     esac
+  fi
+  AC_SUBST([DUMPBIN])
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
 
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-    dynamic_linker='Win32 link.exe'
-    ;;
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+  [lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
+  cat conftest.out >&AS_MESSAGE_LOG_FD
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
 
+# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+# --------------------------------
+# how to determine the name of the shared library
+# associated with a specific link library.
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+m4_require([_LT_DECL_DLLTOOL])
+AC_CACHE_CHECK([how to associate runtime and link libraries],
+lt_cv_sharedlib_from_linklib_cmd,
+[lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+  # two different shell functions defined in ltmain.sh
+  # decide which to use based on capabilities of $DLLTOOL
+  case `$DLLTOOL --help 2>&1` in
+  *--identify-strict*)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+    ;;
   *)
-    # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    dynamic_linker='Win32 ld.exe'
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
     ;;
   esac
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
   ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-m4_if([$1], [],[
-  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+*)
+  # fallback: assume linklib IS sharedlib
+  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
   ;;
+esac
+])
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
 
-dgux*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
+    [Command to associate shared and link libraries])
+])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[[23]].*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
+
+# _LT_PATH_MANIFEST_TOOL
+# ----------------------
+# locate the manifest tool
+m4_defun([_LT_PATH_MANIFEST_TOOL],
+[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
+  [lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
   fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2.*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
-  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
+  rm -f conftest*])
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+  MANIFEST_TOOL=:
+fi
+_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
+])# _LT_PATH_MANIFEST_TOOL
 
-haiku*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
-  hardcode_into_libs=yes
-  ;;
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
-  postinstall_cmds='chmod 555 $lib'
-  # or fails outright, so override atomically:
-  install_override_mode=555
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
   ;;
-
-interix[[3-9]]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
   ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux # correct to gnu/linux during the next big refactor
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  case $cc_basename in
+  nvcc*)
+    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
   *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
+    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
   esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
+  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+	[Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
 
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
 
-  # Some binutils ld are patched to set DT_RUNPATH
-  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
-    [lt_cv_shlibpath_overrides_runpath=no
-    save_LDFLAGS=$LDFLAGS
-    save_libdir=$libdir
-    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
-	 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
-      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
-	 [lt_cv_shlibpath_overrides_runpath=yes])])
-    LDFLAGS=$save_LDFLAGS
-    libdir=$save_libdir
-    ])
-  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
   ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
   fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
   ;;
-
-newsos6)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
   ;;
-
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
+osf*)
+  symcode='[[BCDEGQRST]]'
   ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
+solaris*)
+  symcode='[[BDRT]]'
   ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+sco3.2v5*)
+  symcode='[[DT]]'
   ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+sysv4.2uw2*)
+  symcode='[[DT]]'
   ;;
-
-rdos*)
-  dynamic_linker=no
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
   ;;
-
-solaris*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
+sysv4)
+  symcode='[[DFNSTU]]'
   ;;
+esac
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
 
-sysv4 | sysv4.3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
 
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
   ;;
+esac
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK ['"\
+"     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx]"
   else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
   fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
+  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
 
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+  # Check to see that the pipe works correctly.
+  pipe_works=no
 
-uts4*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
 
-*)
-  dynamic_linker=no
-  ;;
-esac
-AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT@&t at _DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data.  */
+# define LT@&t at _DLSYM_CONST
+#else
+# define LT@&t at _DLSYM_CONST const
+#endif
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-_LT_DECL([], [variables_saved_for_relink], [1],
-    [Variables whose values should be saved in libtool wrapper scripts and
-    restored at link time])
-_LT_DECL([], [need_lib_prefix], [0],
-    [Do we need the "lib" prefix for modules?])
-_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
-_LT_DECL([], [version_type], [0], [Library versioning type])
-_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
-_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
-_LT_DECL([], [shlibpath_overrides_runpath], [0],
-    [Is shlibpath searched before the hard-coded library search path?])
-_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
-_LT_DECL([], [library_names_spec], [1],
-    [[List of archive names.  First name is the real one, the rest are links.
-    The last name is the one that the linker finds with -lNAME]])
-_LT_DECL([], [soname_spec], [1],
-    [[The coded name of the library, if different from the real name]])
-_LT_DECL([], [install_override_mode], [1],
-    [Permission mode override for installation of shared libraries])
-_LT_DECL([], [postinstall_cmds], [2],
-    [Command to use after installation of a shared archive])
-_LT_DECL([], [postuninstall_cmds], [2],
-    [Command to use after uninstallation of a shared archive])
-_LT_DECL([], [finish_cmds], [2],
-    [Commands used to finish a libtool library installation in a directory])
-_LT_DECL([], [finish_eval], [1],
-    [[As "finish_cmds", except a single script fragment to be evaled but
-    not shown]])
-_LT_DECL([], [hardcode_into_libs], [0],
-    [Whether we should hardcode library paths into libraries])
-_LT_DECL([], [sys_lib_search_path_spec], [2],
-    [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
-])# _LT_SYS_DYNAMIC_LINKER
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
 
+	  cat <<_LT_EOF >> conftest.$ac_ext
 
-# _LT_PATH_TOOL_PREFIX(TOOL)
-# --------------------------
-# find a file program which can recognize shared library
-AC_DEFUN([_LT_PATH_TOOL_PREFIX],
-[m4_require([_LT_DECL_EGREP])dnl
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
-[case $MAGIC_CMD in
-[[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word.  This closes a longstanding sh security hole.
-  ac_dummy="m4_if([$2], , $PATH, [$2])"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<_LT_EOF 1>&2
+/* The mapping between symbol names and symbols.  */
+LT@&t at _DLSYM_CONST struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
 
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool at gnu.org
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
 
+#ifdef __cplusplus
+}
+#endif
 _LT_EOF
-	  fi ;;
-	esac
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_globsym_save_LIBS=$LIBS
+	  lt_globsym_save_CFLAGS=$CFLAGS
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS=$lt_globsym_save_LIBS
+	  CFLAGS=$lt_globsym_save_CFLAGS
+	else
+	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
       fi
-      break
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
     fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  AC_MSG_RESULT($MAGIC_CMD)
-else
-  AC_MSG_RESULT(no)
-fi
-_LT_DECL([], [MAGIC_CMD], [0],
-	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
-])# _LT_PATH_TOOL_PREFIX
-
-# Old name:
-AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
-
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
 
-# _LT_PATH_MAGIC
-# --------------
-# find a file program which can recognize a shared library
-m4_defun([_LT_PATH_MAGIC],
-[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
   else
-    MAGIC_CMD=:
+    lt_cv_sys_global_symbol_pipe=
   fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
 fi
-])# _LT_PATH_MAGIC
 
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
+  nm_file_list_spec='@'
+fi
 
-# LT_PATH_LD
-# ----------
-# find the pathname to the GNU or non-GNU linker
-AC_DEFUN([LT_PATH_LD],
-[AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+    [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+    [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+    [lt_cv_sys_global_symbol_to_c_name_address], [1],
+    [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+    [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([], [nm_file_list_spec], [1],
+    [Specify filename containing input files for $NM])
+]) # _LT_CMD_GLOBAL_SYMBOLS
 
-AC_ARG_WITH([gnu-ld],
-    [AS_HELP_STRING([--with-gnu-ld],
-	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
-    [with_gnu_ld=no])dnl
 
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  AC_MSG_CHECKING([for ld used by $CC])
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [[\\/]]* | ?:[[\\/]]*)
-      re_direlt='/[[^/]][[^/]]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
-      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  AC_MSG_CHECKING([for GNU ld])
-else
-  AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(lt_cv_path_LD,
-[if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
-      *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
-	;;
-      *)
-	test "$with_gnu_ld" != yes && break
-	;;
-      esac
-    fi
-  done
-  IFS="$lt_save_ifs"
-else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi])
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  AC_MSG_RESULT($LD)
-else
-  AC_MSG_RESULT(no)
-fi
-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-_LT_PATH_LD_GNU
-AC_SUBST([LD])
-
-_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
-])# LT_PATH_LD
-
-# Old names:
-AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
-AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_PROG_LD], [])
-dnl AC_DEFUN([AC_PROG_LD], [])
-
-
-# _LT_PATH_LD_GNU
-#- --------------
-m4_defun([_LT_PATH_LD_GNU],
-[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
-  lt_cv_prog_gnu_ld=yes
-  ;;
-*)
-  lt_cv_prog_gnu_ld=no
-  ;;
-esac])
-with_gnu_ld=$lt_cv_prog_gnu_ld
-])# _LT_PATH_LD_GNU
-
-
-# _LT_CMD_RELOAD
-# --------------
-# find reload flag for linker
-#   -- PORTME Some linkers may need a different reload flag.
-m4_defun([_LT_CMD_RELOAD],
-[AC_CACHE_CHECK([for $LD option to reload object files],
-  lt_cv_ld_reload_flag,
-  [lt_cv_ld_reload_flag='-r'])
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
-      reload_cmds=false
-    fi
-    ;;
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
-_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
-_LT_TAGDECL([], [reload_cmds], [2])dnl
-])# _LT_CMD_RELOAD
-
-
-# _LT_CHECK_MAGIC_METHOD
-# ----------------------
-# how to check for library dependencies
-#  -- PORTME fill in with the dynamic library characteristics
-m4_defun([_LT_CHECK_MAGIC_METHOD],
-[m4_require([_LT_DECL_EGREP])
-m4_require([_LT_DECL_OBJDUMP])
-AC_CACHE_CHECK([how to recognize dependent libraries],
-lt_cv_deplibs_check_method,
-[lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix[[4-9]]*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-beos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-bsdi[[45]]*)
-  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  ;;
-
-cygwin*)
-  # func_win32_libid is a shell function defined in ltmain.sh
-  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-  lt_cv_file_magic_cmd='func_win32_libid'
-  ;;
-
-mingw* | pw32*)
-  # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump',
-  # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
-    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-    lt_cv_file_magic_cmd='func_win32_libid'
-  else
-    # Keep this pattern in sync with the one in func_win32_libid.
-    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
-    lt_cv_file_magic_cmd='$OBJDUMP -f'
-  fi
-  ;;
-
-cegcc*)
-  # use the weaker test based on 'objdump'. See mingw*.
-  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
-
-darwin* | rhapsody*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-freebsd* | dragonfly*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
-  else
-    lt_cv_deplibs_check_method=pass_all
-  fi
-  ;;
-
-haiku*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-hpux10.20* | hpux11*)
-  lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  hppa*64*)
-    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
-    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
-    ;;
-  *)
-    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  esac
-  ;;
-
-interix[[3-9]]*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $LD in
-  *-32|*"-32 ") libmagic=32-bit;;
-  *-n32|*"-n32 ") libmagic=N32;;
-  *-64|*"-64 ") libmagic=64-bit;;
-  *) libmagic=never-match;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-netbsd* | netbsdelf*-gnu)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
-  fi
-  ;;
-
-newos6*)
-  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
-
-*nto* | *qnx*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
-  fi
-  ;;
-
-osf3* | osf4* | osf5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-rdos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv4 | sysv4.3*)
-  case $host_vendor in
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  sequent)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
-    ;;
-  sni)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
-    lt_cv_file_magic_test_file=/lib/libc.so
-    ;;
-  siemens)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  esac
-  ;;
-
-tpf*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-esac
-])
-
-file_magic_glob=
-want_nocaseglob=no
-if test "$build" = "$host"; then
-  case $host_os in
-  mingw* | pw32*)
-    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
-      want_nocaseglob=yes
-    else
-      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
-    fi
-    ;;
-  esac
-fi
-
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-_LT_DECL([], [deplibs_check_method], [1],
-    [Method to check whether dependent libraries are shared objects])
-_LT_DECL([], [file_magic_cmd], [1],
-    [Command to use when deplibs_check_method = "file_magic"])
-_LT_DECL([], [file_magic_glob], [1],
-    [How to find potential files when deplibs_check_method = "file_magic"])
-_LT_DECL([], [want_nocaseglob], [1],
-    [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
-])# _LT_CHECK_MAGIC_METHOD
-
-
-# LT_PATH_NM
-# ----------
-# find the pathname to a BSD- or MS-compatible name lister
-AC_DEFUN([LT_PATH_NM],
-[AC_REQUIRE([AC_PROG_CC])dnl
-AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
-[if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
-else
-  # Didn't find any BSD compatible name lister, look for dumpbin.
-  if test -n "$DUMPBIN"; then :
-    # Let the user override the test.
-  else
-    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
-    *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
-      ;;
-    *)
-      DUMPBIN=:
-      ;;
-    esac
-  fi
-  AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
-  fi
-fi
-test -z "$NM" && NM=nm
-AC_SUBST([NM])
-_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
-
-AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
-  [lt_cv_nm_interface="BSD nm"
-  echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
-  (eval "$ac_compile" 2>conftest.err)
-  cat conftest.err >&AS_MESSAGE_LOG_FD
-  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
-  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
-  cat conftest.err >&AS_MESSAGE_LOG_FD
-  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
-  cat conftest.out >&AS_MESSAGE_LOG_FD
-  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
-    lt_cv_nm_interface="MS dumpbin"
-  fi
-  rm -f conftest*])
-])# LT_PATH_NM
-
-# Old names:
-AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
-AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_PROG_NM], [])
-dnl AC_DEFUN([AC_PROG_NM], [])
-
-# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
-# --------------------------------
-# how to determine the name of the shared library
-# associated with a specific link library.
-#  -- PORTME fill in with the dynamic library characteristics
-m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
-[m4_require([_LT_DECL_EGREP])
-m4_require([_LT_DECL_OBJDUMP])
-m4_require([_LT_DECL_DLLTOOL])
-AC_CACHE_CHECK([how to associate runtime and link libraries],
-lt_cv_sharedlib_from_linklib_cmd,
-[lt_cv_sharedlib_from_linklib_cmd='unknown'
-
-case $host_os in
-cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
-  case `$DLLTOOL --help 2>&1` in
-  *--identify-strict*)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
-    ;;
-  *)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
-    ;;
-  esac
-  ;;
-*)
-  # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
-  ;;
-esac
-])
-sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
-test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
-
-_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
-    [Command to associate shared and link libraries])
-])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
-
-
-# _LT_PATH_MANIFEST_TOOL
-# ----------------------
-# locate the manifest tool
-m4_defun([_LT_PATH_MANIFEST_TOOL],
-[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
-test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
-AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
-  [lt_cv_path_mainfest_tool=no
-  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
-  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
-  cat conftest.err >&AS_MESSAGE_LOG_FD
-  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
-    lt_cv_path_mainfest_tool=yes
-  fi
-  rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
-  MANIFEST_TOOL=:
-fi
-_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
-])# _LT_PATH_MANIFEST_TOOL
-
-
-# LT_LIB_M
-# --------
-# check for math library
-AC_DEFUN([LT_LIB_M],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-LIBM=
-case $host in
-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
-  # These system don't have libm, or don't need it
-  ;;
-*-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
-  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
-  ;;
-*)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
-  ;;
-esac
-AC_SUBST([LIBM])
-])# LT_LIB_M
-
-# Old name:
-AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_CHECK_LIBM], [])
-
-
-# _LT_COMPILER_NO_RTTI([TAGNAME])
-# -------------------------------
-m4_defun([_LT_COMPILER_NO_RTTI],
-[m4_require([_LT_TAG_COMPILER])dnl
-
-_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-
-if test "$GCC" = yes; then
-  case $cc_basename in
-  nvcc*)
-    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
-  *)
-    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
-  esac
-
-  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
-    lt_cv_prog_compiler_rtti_exceptions,
-    [-fno-rtti -fno-exceptions], [],
-    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
-fi
-_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
-	[Compiler flag to turn off builtin functions])
-])# _LT_COMPILER_NO_RTTI
-
-
-# _LT_CMD_GLOBAL_SYMBOLS
-# ----------------------
-m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([LT_PATH_NM])dnl
-AC_REQUIRE([LT_PATH_LD])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_TAG_COMPILER])dnl
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
-[
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[[BCDEGRST]]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
-
-# Define system-specific variables.
-case $host_os in
-aix*)
-  symcode='[[BCDT]]'
-  ;;
-cygwin* | mingw* | pw32* | cegcc*)
-  symcode='[[ABCDGISTW]]'
-  ;;
-hpux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[[ABCDEGRST]]'
-  fi
-  ;;
-irix* | nonstopux*)
-  symcode='[[BCDEGRST]]'
-  ;;
-osf*)
-  symcode='[[BCDEGQRST]]'
-  ;;
-solaris*)
-  symcode='[[BDRT]]'
-  ;;
-sco3.2v5*)
-  symcode='[[DT]]'
-  ;;
-sysv4.2uw2*)
-  symcode='[[DT]]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[[ABDT]]'
-  ;;
-sysv4)
-  symcode='[[DFNSTU]]'
-  ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
-  symcode='[[ABCDGIRSTW]]' ;;
-esac
-
-# Transform an extracted symbol line into a proper C declaration.
-# Some systems (esp. on ia64) link data and code symbols differently,
-# so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
-  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
-  ;;
-esac
-
-# Try without a prefix underscore, then with it.
-for ac_symprfx in "" "_"; do
-
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
-  # Write the raw and C identifiers.
-  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
-    # Also find C++ and __fastcall symbols from MSVC++,
-    # which start with @ or ?.
-    lt_cv_sys_global_symbol_pipe="$AWK ['"\
-"     {last_section=section; section=\$ 3};"\
-"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
-"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
-"     \$ 0!~/External *\|/{next};"\
-"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
-"     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
-"     ' prfx=^$ac_symprfx]"
-  else
-    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-  fi
-  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-
-  rm -f conftest*
-  cat > conftest.$ac_ext <<_LT_EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(void);
-void nm_test_func(void){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-_LT_EOF
-
-  if AC_TRY_EVAL(ac_compile); then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-	mv -f "$nlist"T "$nlist"
-      else
-	rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
-	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
-	  cat <<_LT_EOF > conftest.$ac_ext
-/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
-   relocations are performed -- see ld's documentation on pseudo-relocs.  */
-# define LT@&t at _DLSYM_CONST
-#elif defined(__osf__)
-/* This system does not cope well with relocations in const data.  */
-# define LT@&t at _DLSYM_CONST
-#else
-# define LT@&t at _DLSYM_CONST const
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-_LT_EOF
-	  # Now generate the symbol file.
-	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
-
-	  cat <<_LT_EOF >> conftest.$ac_ext
-
-/* The mapping between symbol names and symbols.  */
-LT@&t at _DLSYM_CONST struct {
-  const char *name;
-  void       *address;
-}
-lt__PROGRAM__LTX_preloaded_symbols[[]] =
-{
-  { "@PROGRAM@", (void *) 0 },
-_LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
-	  cat <<\_LT_EOF >> conftest.$ac_ext
-  {0, (void *) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
-  return lt__PROGRAM__LTX_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-_LT_EOF
-	  # Now try linking the two files.
-	  mv conftest.$ac_objext conftstm.$ac_objext
-	  lt_globsym_save_LIBS=$LIBS
-	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
-	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
-	    pipe_works=yes
-	  fi
-	  LIBS=$lt_globsym_save_LIBS
-	  CFLAGS=$lt_globsym_save_CFLAGS
-	else
-	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
-	fi
-      else
-	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
-      fi
-    else
-      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
-    fi
-  else
-    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
-    cat conftest.$ac_ext >&5
-  fi
-  rm -rf conftest* conftst*
-
-  # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
-    break
-  else
-    lt_cv_sys_global_symbol_pipe=
-  fi
-done
-])
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
-  lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  AC_MSG_RESULT(failed)
-else
-  AC_MSG_RESULT(ok)
-fi
-
-# Response file support.
-if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-  nm_file_list_spec='@'
-elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
-  nm_file_list_spec='@'
-fi
-
-_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
-    [Take the output of nm and produce a listing of raw symbols and C names])
-_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
-    [Transform the output of nm in a proper C declaration])
-_LT_DECL([global_symbol_to_c_name_address],
-    [lt_cv_sys_global_symbol_to_c_name_address], [1],
-    [Transform the output of nm in a C name address pair])
-_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
-    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
-    [Transform the output of nm in a C name address pair when lib prefix is needed])
-_LT_DECL([], [nm_file_list_spec], [1],
-    [Specify filename containing input files for $NM])
-]) # _LT_CMD_GLOBAL_SYMBOLS
-
-
-# _LT_COMPILER_PIC([TAGNAME])
-# ---------------------------
-m4_defun([_LT_COMPILER_PIC],
-[m4_require([_LT_TAG_COMPILER])dnl
-_LT_TAGVAR(lt_prog_compiler_wl, $1)=
-_LT_TAGVAR(lt_prog_compiler_pic, $1)=
-_LT_TAGVAR(lt_prog_compiler_static, $1)=
-
-m4_if([$1], [CXX], [
-  # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
-    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
-    case $host_os in
-    aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+m4_if([$1], [CXX], [
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
       ;;
 
     amigaos*)
@@ -6884,473 +5757,1102 @@ dnl    [Compiler flag to generate thread safe objects])
 ])# _LT_LINKER_SHLIBS
 
 
-# _LT_LANG_C_CONFIG([TAG])
-# ------------------------
-# Ensure that the configuration variables for a C compiler are suitably
-# defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_C_CONFIG],
-[m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
-AC_LANG_PUSH(C)
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_SYS_DYNAMIC_LINKER($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+  LT_SYS_DLOPEN_SELF
+  _LT_CMD_STRIPLIB
+
+  # Report which library types will actually be built
+  AC_MSG_CHECKING([if libtool supports shared libraries])
+  AC_MSG_RESULT([$can_build_shared])
+
+  AC_MSG_CHECKING([whether to build shared libraries])
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[[4-9]]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  AC_MSG_RESULT([$enable_shared])
+
+  AC_MSG_CHECKING([whether to build static libraries])
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  AC_MSG_RESULT([$enable_static])
+
+  _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+else
+  _lt_caught_CXX_error=yes
+fi
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_CFLAGS=$CFLAGS
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  CFLAGS=$CXXFLAGS
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+    else
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
 
-# Source file extension for C test sources.
-ac_ext=c
+      LT_PATH_LD
 
-# Object file extension for compiled C test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;"
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}'
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
 
-_LT_TAG_COMPILER
-# Save the default compiler, since it gets overwritten when the other
-# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
-compiler_DEFAULT=$CC
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+	  $GREP 'no-whole-archive' > /dev/null; then
+          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
 
-if test -n "$compiler"; then
-  _LT_COMPILER_NO_RTTI($1)
-  _LT_COMPILER_PIC($1)
-  _LT_COMPILER_C_O($1)
-  _LT_COMPILER_FILE_LOCKS($1)
-  _LT_LINKER_SHLIBS($1)
-  _LT_SYS_DYNAMIC_LINKER($1)
-  _LT_LINKER_HARDCODE_LIBPATH($1)
-  LT_SYS_DLOPEN_SELF
-  _LT_CMD_STRIPLIB
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 
-  # Report which library types will actually be built
-  AC_MSG_CHECKING([if libtool supports shared libraries])
-  AC_MSG_RESULT([$can_build_shared])
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
 
-  AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
+    # PORTME: fill in a description of your system's C++ link characteristics
+    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+    _LT_TAGVAR(ld_shlibs, $1)=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+      aix[[4-9]]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	    for ld_flag in $LDFLAGS; do
+	      case $ld_flag in
+	      *-brtl*)
+	        aix_use_runtimelinking=yes
+	        break
+	        ;;
+	      esac
+	    done
+	    ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        _LT_TAGVAR(archive_cmds, $1)=''
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[[012]]|aix4.[[012]].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	    # We have reworked collect2
+	    :
+	  else
+	    # We have old collect2
+	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
+	    # It fails to find uninstalled libraries when the uninstalled
+	    # path is not listed in the libpath.  Setting hardcode_minus_L
+	    # to unsupported forces relinking
+	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+          esac
+          shared_flag='-shared'
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag="$shared_flag "'${wl}-G'
+	  fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	  # chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+          else
+	    if test "$aix_use_runtimelinking" = yes; then
+	      shared_flag='${wl}-G'
+	    else
+	      shared_flag='${wl}-bM:SRE'
+	    fi
+          fi
+        fi
+
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+	# export.
+        _LT_TAGVAR(always_export_symbols, $1)=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          _LT_SYS_MODULE_PATH_AIX([$1])
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+	    # Determine the default libpath from the value encoded in an
+	    # empty executable.
+	    _LT_SYS_MODULE_PATH_AIX([$1])
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    # Warning - without using the other run time loading flags,
+	    # -berok will link without error, but may produce a broken library.
+	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	    if test "$with_gnu_ld" = yes; then
+	      # We only use this code for GNU lds that support --whole-archive.
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    else
+	      # Exported symbols can be pulled into shared objects from archives
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	    fi
+	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+	    # This is similar to how AIX traditionally builds its shared
+	    # libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	  # support --undefined.  This deserves some investigation.  FIXME
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	else
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+	  # FIXME: insert proper C++ library support
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	  ;;
+        esac
+        ;;
 
-  # On AIX, shared libraries and static libraries use the same namespace, and
-  # are all built from PIC.
-  case $host_os in
-  aix3*)
-    test "$enable_shared" = yes && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds~\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
+      cygwin* | mingw* | pw32* | cegcc*)
+	case $GXX,$cc_basename in
+	,cl* | no,cl*)
+	  # Native MSVC
+	  # hardcode_libdir_flag_spec is actually meaningless, as there is
+	  # no search path for DLLs.
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	  _LT_TAGVAR(always_export_symbols, $1)=yes
+	  _LT_TAGVAR(file_list_spec, $1)='@'
+	  # Tell ltmain to make .lib files, not .a files.
+	  libext=lib
+	  # Tell ltmain to make .dll files, not .so files.
+	  shrext_cmds=".dll"
+	  # FIXME: Setting linknames here is a bad hack.
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+	    else
+	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+	    fi~
+	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+	    linknames='
+	  # The linker will not automatically build a static lib if we build a DLL.
+	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	  # Don't use ranlib
+	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+	    lt_tool_outputfile="@TOOL_OUTPUT@"~
+	    case $lt_outputfile in
+	      *.exe|*.EXE) ;;
+	      *)
+		lt_outputfile="$lt_outputfile.exe"
+		lt_tool_outputfile="$lt_tool_outputfile.exe"
+		;;
+	    esac~
+	    func_to_tool_file "$lt_outputfile"~
+	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+	      $RM "$lt_outputfile.manifest";
+	    fi'
+	  ;;
+	*)
+	  # g++
+	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+	  # as there is no search path for DLLs.
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	  _LT_TAGVAR(always_export_symbols, $1)=no
+	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
-  aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
-    fi
-    ;;
-  esac
-  AC_MSG_RESULT([$enable_shared])
+	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file (1st line
+	    # is EXPORTS), use it as is; otherwise, prepend...
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	      cp $export_symbols $output_objdir/$soname.def;
+	    else
+	      echo EXPORTS > $output_objdir/$soname.def;
+	      cat $export_symbols >> $output_objdir/$soname.def;
+	    fi~
+	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	  else
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	  ;;
+	esac
+	;;
+      darwin* | rhapsody*)
+        _LT_DARWIN_LINKER_FEATURES($1)
+	;;
 
-  AC_MSG_CHECKING([whether to build static libraries])
-  # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
-  AC_MSG_RESULT([$enable_static])
+      dgux*)
+        case $cc_basename in
+          ec++*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          ghcx*)
+	    # Green Hills C++ Compiler
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
 
-  _LT_CONFIG($1)
-fi
-AC_LANG_POP
-CC="$lt_save_CC"
-])# _LT_LANG_C_CONFIG
+      freebsd2.*)
+        # C++ shared libraries reported to be fairly broken before
+	# switch to ELF
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
 
+      freebsd-elf*)
+        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        ;;
 
-# _LT_LANG_CXX_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for a C++ compiler are suitably
-# defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_CXX_CONFIG],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  AC_PROG_CXXCPP
-else
-  _lt_caught_CXX_error=yes
-fi
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+        ;;
 
-AC_LANG_PUSH(C++)
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_TAGVAR(allow_undefined_flag, $1)=
-_LT_TAGVAR(always_export_symbols, $1)=no
-_LT_TAGVAR(archive_expsym_cmds, $1)=
-_LT_TAGVAR(compiler_needs_object, $1)=no
-_LT_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_TAGVAR(hardcode_direct, $1)=no
-_LT_TAGVAR(hardcode_direct_absolute, $1)=no
-_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_TAGVAR(hardcode_minus_L, $1)=no
-_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-_LT_TAGVAR(hardcode_automatic, $1)=no
-_LT_TAGVAR(inherit_rpath, $1)=no
-_LT_TAGVAR(module_cmds, $1)=
-_LT_TAGVAR(module_expsym_cmds, $1)=
-_LT_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-_LT_TAGVAR(no_undefined_flag, $1)=
-_LT_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+      haiku*)
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        ;;
 
-# Source file extension for C++ test sources.
-ac_ext=cpp
+      hpux9*)
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+				             # but as the default
+				             # location of the library.
 
-# Object file extension for compiled C++ test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            _LT_TAGVAR(ld_shlibs, $1)=no
+            ;;
+          aCC*)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              _LT_TAGVAR(ld_shlibs, $1)=no
+            fi
+            ;;
+        esac
+        ;;
 
-# No sense in running all these tests if we already determined that
-# the CXX compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="int some_variable = 0;"
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
-  # Code to be used in simple link tests
-  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            _LT_TAGVAR(hardcode_direct, $1)=no
+            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+            ;;
+          *)
+            _LT_TAGVAR(hardcode_direct, $1)=yes
+            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+					         # but as the default
+					         # location of the library.
+            ;;
+        esac
 
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-  _LT_TAG_COMPILER
+        case $cc_basename in
+          CC*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          aCC*)
+	    case $host_cpu in
+	      hppa*64*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      ia64*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      *)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	    esac
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test $with_gnu_ld = no; then
+	        case $host_cpu in
+	          hppa*64*)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          ia64*)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          *)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	        esac
+	      fi
+	    else
+	      # FIXME: insert proper C++ library support
+	      _LT_TAGVAR(ld_shlibs, $1)=no
+	    fi
+	    ;;
+        esac
+        ;;
 
-  # save warnings/boilerplate of simple test code
-  _LT_COMPILER_BOILERPLATE
-  _LT_LINKER_BOILERPLATE
+      interix[[3-9]]*)
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+	# Instead, shared libraries are loaded at an image base (0x10000000 by
+	# default) and relocated if they conflict, which is a slow very memory
+	# consuming and fragmenting process.  To avoid this, we pick a random,
+	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+	    # SGI C++
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
 
-  # Allow CC to be a program name with arguments.
-  lt_save_CC=$CC
-  lt_save_CFLAGS=$CFLAGS
-  lt_save_LD=$LD
-  lt_save_GCC=$GCC
-  GCC=$GXX
-  lt_save_with_gnu_ld=$with_gnu_ld
-  lt_save_path_LD=$lt_cv_path_LD
-  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
-    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-  else
-    $as_unset lt_cv_prog_gnu_ld
-  fi
-  if test -n "${lt_cv_path_LDCXX+set}"; then
-    lt_cv_path_LD=$lt_cv_path_LDCXX
-  else
-    $as_unset lt_cv_path_LD
-  fi
-  test -z "${LDCXX+set}" || LD=$LDCXX
-  CC=${CXX-"c++"}
-  CFLAGS=$CXXFLAGS
-  compiler=$CC
-  _LT_TAGVAR(compiler, $1)=$CC
-  _LT_CC_BASENAME([$compiler])
+	    # Archives containing C++ object files must be created using
+	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test "$with_gnu_ld" = no; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	      else
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	      fi
+	    fi
+	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+	    ;;
+        esac
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(inherit_rpath, $1)=yes
+        ;;
 
-  if test -n "$compiler"; then
-    # We don't want -fno-exception when compiling C++ code, so set the
-    # no_builtin_flag separately
-    if test "$GXX" = yes; then
-      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-    else
-      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-    fi
+      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
 
-    if test "$GXX" = yes; then
-      # Set up default GNU C++ configuration
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-      LT_PATH_LD
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 
-      # Check if GNU C++ uses GNU ld as the underlying linker, since the
-      # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    # Archives containing C++ object files must be created using
+	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    with_gnu_ld=yes
+	    # version 8.0 and above of icpc choke on multiply defined symbols
+	    # if we add $predep_objects and $postdep_objects, however 7.1 and
+	    # earlier do not add the objects themselves.
+	    case `$CC -V 2>&1` in
+	      *"Version 7."*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	      *)  # Version 8.0 or newer
+	        tmp_idyn=
+	        case $host_cpu in
+		  ia64*) tmp_idyn=' -i_dynamic';;
+		esac
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	    esac
+	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+	    case `$CC -V` in
+	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
+	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+		$RANLIB $oldlib'
+	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    *) # Version 6 and above use weak symbols
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    esac
 
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+	  cxx*)
+	    # Compaq C++
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
 
-        # If archive_cmds runs LD, not CC, wlarc should be empty
-        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
-        #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+	    runpath_var=LD_RUN_PATH
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
-        # ancient GNU ld didn't support --whole-archive et. al.
-        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
-	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-        else
-          _LT_TAGVAR(whole_archive_flag_spec, $1)=
-        fi
-      else
-        with_gnu_ld=no
-        wlarc=
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    ;;
+	  xl* | mpixl* | bgxl*)
+	    # IBM XL 8.0 on PPC, with GNU ld
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    if test "x$supports_anon_versioning" = xyes; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+		echo "local: *; };" >> $output_objdir/$libname.ver~
+		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	    fi
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(compiler_needs_object, $1)=yes
 
-        # A generic and very simple default shared library creation
-        # command for GNU C++ for the case where it uses the native
-        # linker, instead of GNU ld.  If possible, this setting should
-        # overridden to take advantage of the native linker features on
-        # the platform it is being used on.
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-      fi
+	      # Not sure whether something based on
+	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	      # would be better.
+	      output_verbose_link_cmd='func_echo_all'
 
-      # Commands to make compiler produce verbose output that lists
-      # what "hidden" libraries, object files and flags are used when
-      # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	      # Archives containing C++ object files must be created using
+	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	      # necessary to make sure instantiated templates are included
+	      # in the archive.
+	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
 
-    else
-      GXX=no
-      with_gnu_ld=no
-      wlarc=
-    fi
+      lynxos*)
+        # FIXME: insert proper C++ library support
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	;;
 
-    # PORTME: fill in a description of your system's C++ link characteristics
-    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-    _LT_TAGVAR(ld_shlibs, $1)=yes
-    case $host_os in
-      aix3*)
+      m88k*)
         # FIXME: insert proper C++ library support
         _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
-      aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
-          # On IA64, the linker does run time linking by default, so we don't
-          # have to do anything special.
-          aix_use_runtimelinking=no
-          exp_sym_flag='-Bexport'
-          no_entry_flag=""
-        else
-          aix_use_runtimelinking=no
+	;;
 
-          # Test if we are trying to use run time linking or normal
-          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
-          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
-	    for ld_flag in $LDFLAGS; do
-	      case $ld_flag in
-	      *-brtl*)
-	        aix_use_runtimelinking=yes
-	        break
-	        ;;
-	      esac
-	    done
+      mvs*)
+        case $cc_basename in
+          cxx*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
 	    ;;
-          esac
+	  *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+	esac
+	;;
 
-          exp_sym_flag='-bexport'
-          no_entry_flag='-bnoentry'
-        fi
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+	  wlarc=
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	fi
+	# Workaround some broken pre-1.5 toolchains
+	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+	;;
 
-        # When large executables or shared objects are built, AIX ld can
-        # have problems creating the table of contents.  If linking a library
-        # or program results in "error TOC overflow" add -mminimal-toc to
-        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+      *nto* | *qnx*)
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+	;;
 
-        _LT_TAGVAR(archive_cmds, $1)=''
-        _LT_TAGVAR(hardcode_direct, $1)=yes
-        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
-        _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	;;
 
-        if test "$GXX" = yes; then
-          case $host_os in aix4.[[012]]|aix4.[[012]].*)
-          # We only want to do this on AIX 4.2 and lower, the check
-          # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	    # We have reworked collect2
-	    :
-	  else
-	    # We have old collect2
-	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
-	    # It fails to find uninstalled libraries when the uninstalled
-	    # path is not listed in the libpath.  Setting hardcode_minus_L
-	    # to unsupported forces relinking
-	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
-	  fi
-          esac
-          shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+      openbsd*)
+	if test -f /usr/libexec/ld.so; then
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
 	  fi
-        else
-          # not using gcc
-          if test "$host_cpu" = ia64; then
-	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	  # chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-          else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
-	    else
-	      shared_flag='${wl}-bM:SRE'
-	    fi
-          fi
-        fi
+	  output_verbose_link_cmd=func_echo_all
+	else
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
 
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
-        # It seems that -bexpall does not export symbols beginning with
-        # underscore (_), so it is better to generate a list of symbols to
-	# export.
-        _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
-          # Warning - without using the other runtime loading flags (-brtl),
-          # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
-          # Determine the default libpath from the value encoded in an empty
-          # executable.
-          _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Archives containing C++ object files must be created using
+	    # the KAI C++ compiler.
+	    case $host in
+	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+	    esac
+	    ;;
+          RCC*)
+	    # Rational C++ 2.4.1
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          cxx*)
+	    case $host in
+	      osf3*)
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+		;;
+	      *)
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	          echo "-hidden">> $lib.exp~
+	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+	          $RM $lib.exp'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+		;;
+	    esac
+
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    ;;
+	  *)
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	      case $host in
+	        osf3*)
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	        *)
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	      esac
+
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	      # Commands to make compiler produce verbose output that lists
+	      # what "hidden" libraries, object files and flags are used when
+	      # linking a shared library.
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-        else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
-	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-          else
-	    # Determine the default libpath from the value encoded in an
-	    # empty executable.
-	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-	    # Warning - without using the other run time loading flags,
-	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
-	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	    else
-	      # Exported symbols can be pulled into shared objects from archives
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	      # FIXME: insert proper C++ library support
+	      _LT_TAGVAR(ld_shlibs, $1)=no
 	    fi
-	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-          fi
-        fi
+	    ;;
+        esac
         ;;
 
-      beos*)
-	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	else
-	  _LT_TAGVAR(ld_shlibs, $1)=no
-	fi
-	;;
+      psos*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
 
-      chorus*)
+      sunos4*)
         case $cc_basename in
+          CC*)
+	    # Sun C++ 4.x
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          lcc*)
+	    # Lucid
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
           *)
-	  # FIXME: insert proper C++ library support
-	  _LT_TAGVAR(ld_shlibs, $1)=no
-	  ;;
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
         esac
         ;;
 
-      cygwin* | mingw* | pw32* | cegcc*)
-	case $GXX,$cc_basename in
-	,cl* | no,cl*)
-	  # Native MSVC
-	  # hardcode_libdir_flag_spec is actually meaningless, as there is
-	  # no search path for DLLs.
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
-	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	  _LT_TAGVAR(always_export_symbols, $1)=yes
-	  _LT_TAGVAR(file_list_spec, $1)='@'
-	  # Tell ltmain to make .lib files, not .a files.
-	  libext=lib
-	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
-	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
-	  # The linker will not automatically build a static lib if we build a DLL.
-	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
-	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-	  # Don't use ranlib
-	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
-	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
+      solaris*)
+        case $cc_basename in
+          CC* | sunCC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	    case $host_os in
+	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+		# The compiler driver will combine and reorder linker options,
+		# but understands `-z linker_flag'.
+	        # Supported since Solaris 2.6 (maybe 2.5.1?)
+		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	        ;;
+	    esac
+	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+	    output_verbose_link_cmd='func_echo_all'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	    ;;
+          gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	    # The C++ compiler must be used to create the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    # GNU C++ compiler with Solaris linker
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	      else
+	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # platform.
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	      fi
+
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      case $host_os in
+		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+		*)
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  ;;
+	      esac
+	    fi
+	    ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  # g++
-	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
-	  # as there is no search path for DLLs.
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	  _LT_TAGVAR(always_export_symbols, $1)=no
-	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
-	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	  else
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	  fi
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
-	esac
-	;;
-      darwin* | rhapsody*)
-        _LT_DARWIN_LINKER_FEATURES($1)
-	;;
+      esac
+      ;;
 
-      dgux*)
-        case $cc_basename in
-          ec++*)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
+      sysv5* | sco3.2v5* | sco5v6*)
+	# Note: We can NOT use -z defs as we might desire, because we do not
+	# link with -lc, and that would cause any symbols used from libc to
+	# always be unresolved, which means just about no library would
+	# ever link correctly.  If we're not using GNU ld we use -z text
+	# though, which does catch some bad symbols but isn't as heavy-handed
+	# as -z defs.
+	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+	_LT_TAGVAR(link_all_deplibs, $1)=yes
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	runpath_var='LD_RUN_PATH'
+
+	case $cc_basename in
+          CC*)
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
+	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
+	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
+	      '"$_LT_TAGVAR(reload_cmds, $1)"
 	    ;;
-          ghcx*)
-	    # Green Hills C++ Compiler
+	  *)
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+	    # NonStop-UX NCC 3.20
 	    # FIXME: insert proper C++ library support
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	    ;;
@@ -7361,650 +6863,564 @@ if test "$_lt_caught_CXX_error" != yes; then
         esac
         ;;
 
-      freebsd2.*)
-        # C++ shared libraries reported to be fairly broken before
-	# switch to ELF
+      vxworks*)
+        # FIXME: insert proper C++ library support
         _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
 
-      freebsd-elf*)
-        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      *)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
+    esac
 
-      freebsd* | dragonfly*)
-        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
-        # conventions
-        _LT_TAGVAR(ld_shlibs, $1)=yes
-        ;;
+    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
 
-      haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(link_all_deplibs, $1)=yes
-        ;;
+    _LT_TAGVAR(GCC, $1)="$GXX"
+    _LT_TAGVAR(LD, $1)="$LD"
 
-      hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-        _LT_TAGVAR(hardcode_direct, $1)=yes
-        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-				             # but as the default
-				             # location of the library.
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
 
-        case $cc_basename in
-          CC*)
-            # FIXME: insert proper C++ library support
-            _LT_TAGVAR(ld_shlibs, $1)=no
-            ;;
-          aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-            # Commands to make compiler produce verbose output that lists
-            # what "hidden" libraries, object files and flags are used when
-            # linking a shared library.
-            #
-            # There doesn't appear to be a way to prevent this compiler from
-            # explicitly linking system object files so we need to strip them
-            # from the output so that they don't get included in the library
-            # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-            ;;
-          *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-            else
-              # FIXME: insert proper C++ library support
-              _LT_TAGVAR(ld_shlibs, $1)=no
-            fi
-            ;;
-        esac
-        ;;
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
 
-      hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_FUNC_STRIPNAME_CNF
+# ----------------------
+# func_stripname_cnf prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+#
+# This function is identical to the (non-XSI) version of func_stripname,
+# except this one can be used by m4 code that may be executed by configure,
+# rather than the libtool script.
+m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
+AC_REQUIRE([_LT_DECL_SED])
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
+func_stripname_cnf ()
+{
+  case ${2} in
+  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+} # func_stripname_cnf
+])# _LT_FUNC_STRIPNAME_CNF
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+_LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
+])
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case ${prev}${p} in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       fi
+
+       # Expand the sysroot to ease extracting the directories later.
+       if test -z "$prev"; then
+         case $p in
+         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+         esac
+       fi
+       case $p in
+       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+       esac
+       if test "$pre_test_object_deps_done" = no; then
+	 case ${prev} in
+	 -L | -R)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	   else
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	 else
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	 fi
+       fi
+       prev=
+       ;;
+
+    *.lto.$objext) ;; # Ignore GCC LTO objects
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
 
-          case $host_cpu in
-            hppa*64*|ia64*)
-              ;;
-            *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-              ;;
-          esac
-        fi
-        case $host_cpu in
-          hppa*64*|ia64*)
-            _LT_TAGVAR(hardcode_direct, $1)=no
-            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-            ;;
-          *)
-            _LT_TAGVAR(hardcode_direct, $1)=yes
-            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-					         # but as the default
-					         # location of the library.
-            ;;
-        esac
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+	   _LT_TAGVAR(predep_objects, $1)="$p"
+	 else
+	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+	 fi
+       else
+	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	 else
+	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+	 fi
+       fi
+       ;;
 
-        case $cc_basename in
-          CC*)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          aCC*)
-	    case $host_cpu in
-	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	    esac
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-	    ;;
-          *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
-	        case $host_cpu in
-	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	        esac
-	      fi
-	    else
-	      # FIXME: insert proper C++ library support
-	      _LT_TAGVAR(ld_shlibs, $1)=no
-	    fi
-	    ;;
-        esac
-        ;;
+    *) ;; # Ignore the rest.
 
-      interix[[3-9]]*)
-	_LT_TAGVAR(hardcode_direct, $1)=no
-	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-	# Instead, shared libraries are loaded at an image base (0x10000000 by
-	# default) and relocated if they conflict, which is a slow very memory
-	# consuming and fragmenting process.  To avoid this, we pick a random,
-	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	;;
-      irix5* | irix6*)
-        case $cc_basename in
-          CC*)
-	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+    esac
+  done
 
-	    # Archives containing C++ object files must be created using
-	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
-	    # necessary to make sure instantiated templates are included
-	    # in the archive.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
-	    ;;
-          *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
-	      fi
-	    fi
-	    _LT_TAGVAR(link_all_deplibs, $1)=yes
-	    ;;
-        esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(inherit_rpath, $1)=yes
-        ;;
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
 
-      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
-        case $cc_basename in
-          KCC*)
-	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
 
-	    # KCC will only create a shared library if the output file
-	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
-	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_TAGVAR(predep_objects,$1)=
+  _LT_TAGVAR(postdep_objects,$1)=
+  _LT_TAGVAR(postdeps,$1)=
+  ;;
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
 
-	    # Archives containing C++ object files must be created using
-	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-	    ;;
-	  icpc* | ecpc* )
-	    # Intel C++
-	    with_gnu_ld=yes
-	    # version 8.0 and above of icpc choke on multiply defined symbols
-	    # if we add $predep_objects and $postdep_objects, however 7.1 and
-	    # earlier do not add the objects themselves.
-	    case `$CC -V 2>&1` in
-	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-		;;
-	      *)  # Version 8.0 or newer
-	        tmp_idyn=
-	        case $host_cpu in
-		  ia64*) tmp_idyn=' -i_dynamic';;
-		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-		;;
-	    esac
-	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	    ;;
-          pgCC* | pgcpp*)
-            # Portland Group C++ compiler
-	    case `$CC -V` in
-	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
-	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
-	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
-	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-	      ;;
-	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-	      ;;
-	    esac
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-            ;;
-	  cxx*)
-	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
 
-	    runpath_var=LD_RUN_PATH
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+solaris*)
+  case $cc_basename in
+  CC* | sunCC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
 
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
-	    ;;
-	  xl* | mpixl* | bgxl*)
-	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	    fi
-	    ;;
-	  *)
-	    case `$CC -V 2>&1 | sed 5q` in
-	    *Sun\ C*)
-	      # Sun C++ 5.9
-	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	      _LT_TAGVAR(compiler_needs_object, $1)=yes
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
 
-	      # Not sure whether something based on
-	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
-	      # would be better.
-	      output_verbose_link_cmd='func_echo_all'
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+    [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+    [Dependencies to place before and after the objects being linked to
+    create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+    [The library search path used internally by the compiler when linking
+    a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
 
-	      # Archives containing C++ object files must be created using
-	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	      # necessary to make sure instantiated templates are included
-	      # in the archive.
-	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
-	      ;;
-	    esac
-	    ;;
-	esac
-	;;
 
-      lynxos*)
-        # FIXME: insert proper C++ library support
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_LANG_PUSH(Fortran 77)
+if test -z "$F77" || test "X$F77" = "Xno"; then
+  _lt_disable_F77=yes
+fi
 
-      m88k*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-	;;
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
 
-      mvs*)
-        case $cc_basename in
-          cxx*)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-	  *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-	esac
-	;;
+# Source file extension for f77 test sources.
+ac_ext=f
 
-      netbsd*)
-        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
-	  wlarc=
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	  _LT_TAGVAR(hardcode_direct, $1)=yes
-	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	fi
-	# Workaround some broken pre-1.5 toolchains
-	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
-	;;
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
 
-      *nto* | *qnx*)
-        _LT_TAGVAR(ld_shlibs, $1)=yes
-	;;
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
 
-      openbsd*)
-	if test -f /usr/libexec/ld.so; then
-	  _LT_TAGVAR(hardcode_direct, $1)=yes
-	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-	  fi
-	  output_verbose_link_cmd=func_echo_all
-	else
-	  _LT_TAGVAR(ld_shlibs, $1)=no
-	fi
-	;;
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
 
-      osf3* | osf4* | osf5*)
-        case $cc_basename in
-          KCC*)
-	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
 
-	    # KCC will only create a shared library if the output file
-	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
-	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  lt_save_CFLAGS=$CFLAGS
+  CC=${F77-"f77"}
+  CFLAGS=$FFLAGS
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+  GCC=$G77
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
 
-	    # Archives containing C++ object files must be created using
-	    # the KAI C++ compiler.
-	    case $host in
-	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
-	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
-	    esac
-	    ;;
-          RCC*)
-	    # Rational C++ 2.4.1
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          cxx*)
-	    case $host in
-	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-		;;
-	      *)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-		;;
-	    esac
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
 
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
 
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-	    ;;
-	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	      case $host in
-	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-		  ;;
-	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-		  ;;
-	      esac
+    _LT_TAGVAR(GCC, $1)="$G77"
+    _LT_TAGVAR(LD, $1)="$LD"
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
 
-	      # Commands to make compiler produce verbose output that lists
-	      # what "hidden" libraries, object files and flags are used when
-	      # linking a shared library.
-	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
 
-	    else
-	      # FIXME: insert proper C++ library support
-	      _LT_TAGVAR(ld_shlibs, $1)=no
-	    fi
-	    ;;
-        esac
-        ;;
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+  CFLAGS="$lt_save_CFLAGS"
+fi # test "$_lt_disable_F77" != yes
 
-      psos*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
 
-      sunos4*)
-        case $cc_basename in
-          CC*)
-	    # Sun C++ 4.x
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          lcc*)
-	    # Lucid
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-        esac
-        ;;
 
-      solaris*)
-        case $cc_basename in
-          CC* | sunCC*)
-	    # Sun C++ 4.2, 5.x and Centerline C++
-            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
-	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_LANG_PUSH(Fortran)
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	    case $host_os in
-	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-	      *)
-		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
-	        # Supported since Solaris 2.6 (maybe 2.5.1?)
-		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
-	        ;;
-	    esac
-	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
 
-	    output_verbose_link_cmd='func_echo_all'
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
 
-	    # Archives containing C++ object files must be created using
-	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	    # necessary to make sure instantiated templates are included
-	    # in the archive.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
-	    ;;
-          gcx*)
-	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
 
-	    # The C++ compiler must be used to create the archive.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
-	    ;;
-          *)
-	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
-	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
 
-	        # Commands to make compiler produce verbose output that lists
-	        # what "hidden" libraries, object files and flags are used when
-	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
-	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
 
-	        # Commands to make compiler produce verbose output that lists
-	        # what "hidden" libraries, object files and flags are used when
-	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-	      fi
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
-	      case $host_os in
-		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-		  ;;
-	      esac
-	    fi
-	    ;;
-        esac
-        ;;
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      runpath_var='LD_RUN_PATH'
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
 
-      case $cc_basename in
-        CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-      esac
-      ;;
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  lt_save_CFLAGS=$CFLAGS
+  CC=${FC-"f95"}
+  CFLAGS=$FCFLAGS
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
 
-      sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
-	# link with -lc, and that would cause any symbols used from libc to
-	# always be unresolved, which means just about no library would
-	# ever link correctly.  If we're not using GNU ld we use -z text
-	# though, which does catch some bad symbols but isn't as heavy-handed
-	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
-	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
-	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
-	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-	runpath_var='LD_RUN_PATH'
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
 
-	case $cc_basename in
-          CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
-	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
-	    ;;
-	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    ;;
-	esac
-      ;;
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
 
-      tandem*)
-        case $cc_basename in
-          NCC*)
-	    # NonStop-UX NCC 3.20
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-        esac
-        ;;
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
 
-      vxworks*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
         ;;
-
-      *)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
+      aix[[4-9]]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
         ;;
     esac
+    AC_MSG_RESULT([$enable_shared])
 
-    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$GXX"
+    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
     _LT_TAGVAR(LD, $1)="$LD"
 
     ## CAVEAT EMPTOR:
@@ -8022,1904 +7438,2491 @@ if test "$_lt_caught_CXX_error" != yes; then
     _LT_CONFIG($1)
   fi # test -n "$compiler"
 
+  GCC=$lt_save_GCC
   CC=$lt_save_CC
   CFLAGS=$lt_save_CFLAGS
-  LDCXX=$LD
-  LD=$lt_save_LD
-  GCC=$lt_save_GCC
-  with_gnu_ld=$lt_save_with_gnu_ld
-  lt_cv_path_LDCXX=$lt_cv_path_LD
-  lt_cv_path_LD=$lt_save_path_LD
-  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test "$_lt_disable_FC" != yes
 
 AC_LANG_POP
-])# _LT_LANG_CXX_CONFIG
+])# _LT_LANG_FC_CONFIG
 
 
-# _LT_FUNC_STRIPNAME_CNF
-# ----------------------
-# func_stripname_cnf prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-#
-# This function is identical to the (non-XSI) version of func_stripname,
-# except this one can be used by m4 code that may be executed by configure,
-# rather than the libtool script.
-m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
-AC_REQUIRE([_LT_DECL_SED])
-AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
-func_stripname_cnf ()
-{
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-  esac
-} # func_stripname_cnf
-])# _LT_FUNC_STRIPNAME_CNF
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
 
-# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
-# ---------------------------------
-# Figure out "hidden" library dependencies from verbose
-# compiler output when linking a shared library.
-# Parse the compiler output and extract the necessary
-# objects, libraries and library flags.
-m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
-# Dependencies to place before and after the object being linked:
-_LT_TAGVAR(predep_objects, $1)=
-_LT_TAGVAR(postdep_objects, $1)=
-_LT_TAGVAR(predeps, $1)=
-_LT_TAGVAR(postdeps, $1)=
-_LT_TAGVAR(compiler_lib_search_path, $1)=
+# Source file extension for Java test sources.
+ac_ext=java
 
-dnl we can't use the lt_simple_compile_test_code here,
-dnl because it contains code intended for an executable,
-dnl not a library.  It's possible we should let each
-dnl tag define a new lt_????_link_test_code variable,
-dnl but it's only used here...
-m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
-int a;
-void foo (void) { a = 0; }
-_LT_EOF
-], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
-class Foo
-{
-public:
-  Foo (void) { a = 0; }
-private:
-  int a;
-};
-_LT_EOF
-], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
-      subroutine foo
-      implicit none
-      integer*4 a
-      a=0
-      return
-      end
-_LT_EOF
-], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
-      subroutine foo
-      implicit none
-      integer a
-      a=0
-      return
-      end
-_LT_EOF
-], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
-public class foo {
-  private int a;
-  public void bar (void) {
-    a = 0;
-  }
-};
-_LT_EOF
-], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
-package foo
-func foo() {
-}
-_LT_EOF
-])
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+CFLAGS=$GCJFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GOC-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
 
-_lt_libdeps_save_CFLAGS=$CFLAGS
-case "$CC $CFLAGS " in #(
-*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
-*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
-*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
-esac
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
 
-dnl Parse the compiler output and extract the necessary
-dnl objects, libraries and library flags.
-if AC_TRY_EVAL(ac_compile); then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
 
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
 
-  for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+  _LT_CONFIG($1)
+fi
 
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
-	 prev=$p
-	 continue
-       fi
+AC_LANG_RESTORE
 
-       # Expand the sysroot to ease extracting the directories later.
-       if test -z "$prev"; then
-         case $p in
-         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
-         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
-         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
-         esac
-       fi
-       case $p in
-       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
-       esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
-	 -L | -R)
-	   # Internal compiler library paths should come after those
-	   # provided the user.  The postdeps already come after the
-	   # user supplied libs so there is no need to process them.
-	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
-	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
-	   fi
-	   ;;
-	 # The "-l" case would never come before the object being
-	 # linked, so don't bother handling this case.
-	 esac
-       else
-	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
-	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
-	 fi
-       fi
-       prev=
-       ;;
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
 
-    *.lto.$objext) ;; # Ignore GCC LTO objects
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-	 pre_test_object_deps_done=yes
-	 continue
-       fi
 
-       if test "$pre_test_object_deps_done" = no; then
-	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
-	 else
-	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
-	 fi
-       else
-	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
-	 else
-	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
-	 fi
-       fi
-       ;;
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
 
-    *) ;; # Ignore the rest.
+# Source file extension for RC test sources.
+ac_ext=rc
 
-    esac
-  done
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
 
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling $1 test program"
-fi
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
 
-$RM -f confest.$objext
-CFLAGS=$_lt_libdeps_save_CFLAGS
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
 
-# PORTME: override above test on systems where it is broken
-m4_if([$1], [CXX],
-[case $host_os in
-interix[[3-9]]*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  _LT_TAGVAR(predep_objects,$1)=
-  _LT_TAGVAR(postdep_objects,$1)=
-  _LT_TAGVAR(postdeps,$1)=
-  ;;
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
 
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
 
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+CFLAGS=
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
 
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
+if test -n "$compiler"; then
+  :
+  _LT_CONFIG($1)
+fi
 
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_RC_CONFIG
 
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-esac
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+    [AC_CHECK_TOOL(GCJ, gcj,)
+      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      AC_SUBST(GCJFLAGS)])])[]dnl
 ])
 
-case " $_LT_TAGVAR(postdeps, $1) " in
-*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
-esac
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=
-if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
-fi
-_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
-    [The directories searched by this compiler when creating a shared library])
-_LT_TAGDECL([], [predep_objects], [1],
-    [Dependencies to place before and after the objects being linked to
-    create a shared library])
-_LT_TAGDECL([], [postdep_objects], [1])
-_LT_TAGDECL([], [predeps], [1])
-_LT_TAGDECL([], [postdeps], [1])
-_LT_TAGDECL([], [compiler_lib_search_path], [1],
-    [The library search path used internally by the compiler when linking
-    a shared library])
-])# _LT_SYS_HIDDEN_LIBDEPS
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GOC, gccgo,)
+])
 
 
-# _LT_LANG_F77_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for a Fortran 77 compiler are
-# suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_F77_CONFIG],
-[AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
-  _lt_disable_F77=yes
-fi
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
 
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_TAGVAR(allow_undefined_flag, $1)=
-_LT_TAGVAR(always_export_symbols, $1)=no
-_LT_TAGVAR(archive_expsym_cmds, $1)=
-_LT_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_TAGVAR(hardcode_direct, $1)=no
-_LT_TAGVAR(hardcode_direct_absolute, $1)=no
-_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_TAGVAR(hardcode_minus_L, $1)=no
-_LT_TAGVAR(hardcode_automatic, $1)=no
-_LT_TAGVAR(inherit_rpath, $1)=no
-_LT_TAGVAR(module_cmds, $1)=
-_LT_TAGVAR(module_expsym_cmds, $1)=
-_LT_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-_LT_TAGVAR(no_undefined_flag, $1)=
-_LT_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
 
-# Source file extension for f77 test sources.
-ac_ext=f
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
 
-# Object file extension for compiled f77 test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
 
-# No sense in running all these tests if we already determined that
-# the F77 compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
 
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
+# _LT_DECL_DLLTOOL
+# ----------------
+# Ensure DLLTOOL variable is set.
+m4_defun([_LT_DECL_DLLTOOL],
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
+AC_SUBST([DLLTOOL])
+])
 
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-  _LT_TAG_COMPILER
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
 
-  # save warnings/boilerplate of simple test code
-  _LT_COMPILER_BOILERPLATE
-  _LT_LINKER_BOILERPLATE
+m4_ifndef([AC_PROG_SED], [
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
 
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  lt_save_CFLAGS=$CFLAGS
-  CC=${F77-"f77"}
-  CFLAGS=$FFLAGS
-  compiler=$CC
-  _LT_TAGVAR(compiler, $1)=$CC
-  _LT_CC_BASENAME([$compiler])
-  GCC=$G77
-  if test -n "$compiler"; then
-    AC_MSG_CHECKING([if libtool supports shared libraries])
-    AC_MSG_RESULT([$can_build_shared])
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
 
-    AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
 
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
-        ;;
-      aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
-        ;;
-    esac
-    AC_MSG_RESULT([$enable_shared])
 
-    AC_MSG_CHECKING([whether to build static libraries])
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    AC_MSG_RESULT([$enable_static])
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,b/c, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
 
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
 
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    _LT_COMPILER_PIC($1)
-    _LT_COMPILER_C_O($1)
-    _LT_COMPILER_FILE_LOCKS($1)
-    _LT_LINKER_SHLIBS($1)
-    _LT_SYS_DYNAMIC_LINKER($1)
-    _LT_LINKER_HARDCODE_LIBPATH($1)
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
 
-    _LT_CONFIG($1)
-  fi # test -n "$compiler"
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
 
-  GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
 
-AC_LANG_POP
-])# _LT_LANG_F77_CONFIG
+# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
+# ------------------------------------------------------
+# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
+# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
+m4_defun([_LT_PROG_FUNCTION_REPLACE],
+[dnl {
+sed -e '/^$1 ()$/,/^} # $1 /c\
+$1 ()\
+{\
+m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
+} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+])
 
 
-# _LT_LANG_FC_CONFIG([TAG])
+# _LT_PROG_REPLACE_SHELLFNS
 # -------------------------
-# Ensure that the configuration variables for a Fortran compiler are
-# suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_FC_CONFIG],
-[AC_LANG_PUSH(Fortran)
+# Replace existing portable implementations of several shell functions with
+# equivalent extended shell implementations where those features are available..
+m4_defun([_LT_PROG_REPLACE_SHELLFNS],
+[if test x"$xsi_shell" = xyes; then
+  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
+    case ${1} in
+      */*) func_dirname_result="${1%/*}${2}" ;;
+      *  ) func_dirname_result="${3}" ;;
+    esac])
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
-  _lt_disable_FC=yes
-fi
+  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
+    func_basename_result="${1##*/}"])
 
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_TAGVAR(allow_undefined_flag, $1)=
-_LT_TAGVAR(always_export_symbols, $1)=no
-_LT_TAGVAR(archive_expsym_cmds, $1)=
-_LT_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_TAGVAR(hardcode_direct, $1)=no
-_LT_TAGVAR(hardcode_direct_absolute, $1)=no
-_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_TAGVAR(hardcode_minus_L, $1)=no
-_LT_TAGVAR(hardcode_automatic, $1)=no
-_LT_TAGVAR(inherit_rpath, $1)=no
-_LT_TAGVAR(module_cmds, $1)=
-_LT_TAGVAR(module_expsym_cmds, $1)=
-_LT_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-_LT_TAGVAR(no_undefined_flag, $1)=
-_LT_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
+    case ${1} in
+      */*) func_dirname_result="${1%/*}${2}" ;;
+      *  ) func_dirname_result="${3}" ;;
+    esac
+    func_basename_result="${1##*/}"])
 
-# Source file extension for fc test sources.
-ac_ext=${ac_fc_srcext-f}
+  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary parameter first.
+    func_stripname_result=${3}
+    func_stripname_result=${func_stripname_result#"${1}"}
+    func_stripname_result=${func_stripname_result%"${2}"}])
 
-# Object file extension for compiled fc test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
+  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
+    func_split_long_opt_name=${1%%=*}
+    func_split_long_opt_arg=${1#*=}])
 
-# No sense in running all these tests if we already determined that
-# the FC compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
+  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
+    func_split_short_opt_arg=${1#??}
+    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
 
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
+  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
+    case ${1} in
+      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+      *)    func_lo2o_result=${1} ;;
+    esac])
 
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-  _LT_TAG_COMPILER
+  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
 
-  # save warnings/boilerplate of simple test code
-  _LT_COMPILER_BOILERPLATE
-  _LT_LINKER_BOILERPLATE
+  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
 
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  lt_save_CFLAGS=$CFLAGS
-  CC=${FC-"f95"}
-  CFLAGS=$FCFLAGS
-  compiler=$CC
-  GCC=$ac_cv_fc_compiler_gnu
+  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
+fi
 
-  _LT_TAGVAR(compiler, $1)=$CC
-  _LT_CC_BASENAME([$compiler])
+if test x"$lt_shell_append" = xyes; then
+  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
 
-  if test -n "$compiler"; then
-    AC_MSG_CHECKING([if libtool supports shared libraries])
-    AC_MSG_RESULT([$can_build_shared])
+  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
+    func_quote_for_eval "${2}"
+dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
+    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
 
-    AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+  # Save a `func_append' function call where possible by direct use of '+='
+  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+else
+  # Save a `func_append' function call even when '+=' is not available
+  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+fi
 
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
+if test x"$_lt_function_replace_fail" = x":"; then
+  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
+fi
+])
+
+# _LT_PATH_CONVERSION_FUNCTIONS
+# -----------------------------
+# Determine which file name conversion functions should be used by
+# func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
+# for certain cross-compile configurations and native mingw.
+m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_MSG_CHECKING([how to convert $build file names to $host format])
+AC_CACHE_VAL(lt_cv_to_host_file_cmd,
+[case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
         ;;
-      aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
         ;;
     esac
-    AC_MSG_RESULT([$enable_shared])
-
-    AC_MSG_CHECKING([whether to build static libraries])
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    AC_MSG_RESULT([$enable_static])
-
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
+    ;;
+  *-*-cygwin* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_noop
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_cv_to_host_file_cmd=func_convert_file_noop
+    ;;
+esac
+])
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
+_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
+         [0], [convert $build file names to $host format])dnl
 
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    _LT_SYS_HIDDEN_LIBDEPS($1)
-    _LT_COMPILER_PIC($1)
-    _LT_COMPILER_C_O($1)
-    _LT_COMPILER_FILE_LOCKS($1)
-    _LT_LINKER_SHLIBS($1)
-    _LT_SYS_DYNAMIC_LINKER($1)
-    _LT_LINKER_HARDCODE_LIBPATH($1)
+AC_MSG_CHECKING([how to convert $build file names to toolchain format])
+AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
+[#assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+        ;;
+    esac
+    ;;
+esac
+])
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
+_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
+         [0], [convert $build files to toolchain format])dnl
+])# _LT_PATH_CONVERSION_FUNCTIONS
 
-    _LT_CONFIG($1)
-  fi # test -n "$compiler"
+# Helper functions for option handling.                    -*- Autoconf -*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
+#   Inc.
+#   Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
 
-  GCC=$lt_save_GCC
-  CC=$lt_save_CC
-  CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+# serial 7 ltoptions.m4
 
-AC_LANG_POP
-])# _LT_LANG_FC_CONFIG
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
 
 
-# _LT_LANG_GCJ_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for the GNU Java Compiler compiler
-# are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_GCJ_CONFIG],
-[AC_REQUIRE([LT_PROG_GCJ])dnl
-AC_LANG_SAVE
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
 
-# Source file extension for Java test sources.
-ac_ext=java
 
-# Object file extension for compiled Java test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+        _LT_MANGLE_DEFUN([$1], [$2]),
+    [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}"
 
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
 
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_TAG_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+		      [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
 
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_CFLAGS=$CFLAGS
-lt_save_GCC=$GCC
-GCC=yes
-CC=${GCJ-"gcj"}
-CFLAGS=$GCJFLAGS
-compiler=$CC
-_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
-_LT_CC_BASENAME([$compiler])
 
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME.  If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+    [_LT_SET_OPTION([$1], _LT_Option)])
 
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+m4_if([$1],[LT_INIT],[
+  dnl
+  dnl Simply set some default values (i.e off) if boolean options were not
+  dnl specified:
+  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+  ])
+  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+  ])
+  dnl
+  dnl If no reference was made to various pairs of opposing options, then
+  dnl we run the default mode handler for the pair.  For example, if neither
+  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl archives by default:
+  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+  		   [_LT_ENABLE_FAST_INSTALL])
+  ])
+])# _LT_SET_OPTIONS
 
-if test -n "$compiler"; then
-  _LT_COMPILER_NO_RTTI($1)
-  _LT_COMPILER_PIC($1)
-  _LT_COMPILER_C_O($1)
-  _LT_COMPILER_FILE_LOCKS($1)
-  _LT_LINKER_SHLIBS($1)
-  _LT_LINKER_HARDCODE_LIBPATH($1)
 
-  _LT_CONFIG($1)
-fi
 
-AC_LANG_RESTORE
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
 
-GCC=$lt_save_GCC
-CC=$lt_save_CC
-CFLAGS=$lt_save_CFLAGS
-])# _LT_LANG_GCJ_CONFIG
 
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
 
-# _LT_LANG_GO_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for the GNU Go compiler
-# are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_GO_CONFIG],
-[AC_REQUIRE([LT_PROG_GO])dnl
-AC_LANG_SAVE
 
-# Source file extension for Go test sources.
-ac_ext=go
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
 
-# Object file extension for compiled Go test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="package main; func main() { }"
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
 
-# Code to be used in simple link tests
-lt_simple_link_test_code='package main; func main() { }'
 
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_TAG_COMPILER
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+esac
 
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_CFLAGS=$CFLAGS
-lt_save_GCC=$GCC
-GCC=yes
-CC=${GOC-"gccgo"}
-CFLAGS=$GOFLAGS
-compiler=$CC
-_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
-_LT_CC_BASENAME([$compiler])
+test -z "$AS" && AS=as
+_LT_DECL([], [AS],      [1], [Assembler program])dnl
 
-# Go did not exist at the time GCC didn't implicitly link libc in.
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
 
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
+])# win32-dll
 
-if test -n "$compiler"; then
-  _LT_COMPILER_NO_RTTI($1)
-  _LT_COMPILER_PIC($1)
-  _LT_COMPILER_C_O($1)
-  _LT_COMPILER_FILE_LOCKS($1)
-  _LT_LINKER_SHLIBS($1)
-  _LT_LINKER_HARDCODE_LIBPATH($1)
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
 
-  _LT_CONFIG($1)
-fi
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
-AC_LANG_RESTORE
 
-GCC=$lt_save_GCC
-CC=$lt_save_CC
-CFLAGS=$lt_save_CFLAGS
-])# _LT_LANG_GO_CONFIG
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
 
+    _LT_DECL([build_libtool_libs], [enable_shared], [0],
+	[Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
 
-# _LT_LANG_RC_CONFIG([TAG])
-# -------------------------
-# Ensure that the configuration variables for the Windows resource compiler
-# are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_RC_CONFIG],
-[AC_REQUIRE([LT_PROG_RC])dnl
-AC_LANG_SAVE
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
 
-# Source file extension for RC test sources.
-ac_ext=rc
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
 
-# Object file extension for compiled RC test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
 
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_TAG_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
 
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-lt_save_CFLAGS=$CFLAGS
-lt_save_GCC=$GCC
-GCC=
-CC=${RC-"windres"}
-CFLAGS=
-compiler=$CC
-_LT_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
 
-if test -n "$compiler"; then
-  :
-  _LT_CONFIG($1)
-fi
+    _LT_DECL([build_old_libs], [enable_static], [0],
+	[Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
 
-GCC=$lt_save_GCC
-AC_LANG_RESTORE
-CC=$lt_save_CC
-CFLAGS=$lt_save_CFLAGS
-])# _LT_LANG_RC_CONFIG
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
 
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
 
-# LT_PROG_GCJ
-# -----------
-AC_DEFUN([LT_PROG_GCJ],
-[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
-  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
-    [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
-      AC_SUBST(GCJFLAGS)])])[]dnl
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
 ])
 
-# Old name:
-AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
 dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 
-# LT_PROG_GO
-# ----------
-AC_DEFUN([LT_PROG_GO],
-[AC_CHECK_TOOL(GOC, gccgo,)
-])
 
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
 
-# LT_PROG_RC
-# ----------
-AC_DEFUN([LT_PROG_RC],
-[AC_CHECK_TOOL(RC, windres,)
-])
+_LT_DECL([fast_install], [enable_fast_install], [0],
+	 [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
 
-# Old name:
-AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([LT_AC_PROG_RC], [])
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
 
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
 
-# _LT_DECL_EGREP
-# --------------
-# If we don't have a new enough Autoconf to choose the best grep
-# available, choose the one first in the user's PATH.
-m4_defun([_LT_DECL_EGREP],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_REQUIRE([AC_PROG_FGREP])dnl
-test -z "$GREP" && GREP=grep
-_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
-_LT_DECL([], [EGREP], [1], [An ERE matcher])
-_LT_DECL([], [FGREP], [1], [A literal string matcher])
-dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
-AC_SUBST([GREP])
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
-# _LT_DECL_OBJDUMP
-# --------------
-# If we don't have a new enough Autoconf to choose the best objdump
-# available, choose the one first in the user's PATH.
-m4_defun([_LT_DECL_OBJDUMP],
-[AC_CHECK_TOOL(OBJDUMP, objdump, false)
-test -z "$OBJDUMP" && OBJDUMP=objdump
-_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
-AC_SUBST([OBJDUMP])
-])
 
-# _LT_DECL_DLLTOOL
-# ----------------
-# Ensure DLLTOOL variable is set.
-m4_defun([_LT_DECL_DLLTOOL],
-[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
-AC_SUBST([DLLTOOL])
-])
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
+	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+	IFS="$lt_save_ifs"
+	if test "X$lt_pkg" = "X$lt_p"; then
+	  pic_mode=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [pic_mode=default])
 
-# _LT_DECL_SED
-# ------------
-# Check for a fully-functional sed program, that truncates
-# as few characters as possible.  Prefer GNU sed if found.
-m4_defun([_LT_DECL_SED],
-[AC_PROG_SED
-test -z "$SED" && SED=sed
-Xsed="$SED -e 1s/^X//"
-_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
-_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
-    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
-])# _LT_DECL_SED
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
 
-m4_ifndef([AC_PROG_SED], [
-# NOTE: This macro has been submitted for inclusion into   #
-#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
-#  a released version of Autoconf we should remove this    #
-#  macro and use it instead.                               #
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
 
-m4_defun([AC_PROG_SED],
-[AC_MSG_CHECKING([for a sed that does not truncate output])
-AC_CACHE_VAL(lt_cv_path_SED,
-[# Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for lt_ac_prog in sed gsed; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
-        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
-      fi
-    done
-  done
-done
-IFS=$as_save_IFS
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
-  cat /dev/null > conftest.in
-  lt_ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
-  # Check for GNU sed and select it if it is found.
-  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
-    lt_cv_path_SED=$lt_ac_sed
-    break
-  fi
-  while true; do
-    cat conftest.in conftest.in >conftest.tmp
-    mv conftest.tmp conftest.in
-    cp conftest.in conftest.nl
-    echo >>conftest.nl
-    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
-    cmp -s conftest.out conftest.nl || break
-    # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
-    lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
-      lt_ac_max=$lt_ac_count
-      lt_cv_path_SED=$lt_ac_sed
-    fi
-  done
-done
-])
-SED=$lt_cv_path_SED
-AC_SUBST([SED])
-AC_MSG_RESULT([$SED])
-])#AC_PROG_SED
-])#m4_ifndef
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
 
 # Old name:
-AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
 dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([LT_AC_PROG_SED], [])
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
 
 
-# _LT_CHECK_SHELL_FEATURES
-# ------------------------
-# Find out whether the shell is Bourne or XSI compatible,
-# or has some other useful features.
-m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+		 [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+		 [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+		 [m4_define([_LTDL_MODE], [subproject])])
 
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+		 [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+		 [m4_define([_LTDL_TYPE], [convenience])])
 
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  lt_unset=unset
-else
-  lt_unset=false
-fi
-_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
 
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  lt_SP2NL='tr \040 \012'
-  lt_NL2SP='tr \015\012 \040\040'
-  ;;
- *) # EBCDIC based system
-  lt_SP2NL='tr \100 \n'
-  lt_NL2SP='tr \r\n \100\100'
-  ;;
-esac
-_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
-_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
-])# _LT_CHECK_SHELL_FEATURES
+# serial 6 ltsugar.m4
 
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
 
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
 
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+       [$#], [2], [[$2]],
+       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
 
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
 
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+       [$#], 1, [],
+       [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
 
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
 
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
 
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
 
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
 
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+	     [m4_foreach([_Lt_suffix],
+		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+		 [lt_append([$1], [$2], [$3])$4],
+		 [$5])],
+	  [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
 
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
 
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
 
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
 
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
 
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+	[$5],
+    [$6])])
 
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
 
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+  [lt_join(m4_quote(m4_default([$4], [[, ]])),
+           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
 ])
 
-# _LT_PATH_CONVERSION_FUNCTIONS
-# -----------------------------
-# Determine which file name conversion functions should be used by
-# func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
-# for certain cross-compile configurations and native mingw.
-m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_MSG_CHECKING([how to convert $build file names to $host format])
-AC_CACHE_VAL(lt_cv_to_host_file_cmd,
-[case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
-        ;;
-    esac
-    ;;
-  *-*-cygwin* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_noop
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
-        ;;
-    esac
-    ;;
-  * ) # unhandled hosts (and "normal" native builds)
-    lt_cv_to_host_file_cmd=func_convert_file_noop
-    ;;
-esac
-])
-to_host_file_cmd=$lt_cv_to_host_file_cmd
-AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
-_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
-         [0], [convert $build file names to $host format])dnl
+# ltversion.m4 -- version numbers			-*- Autoconf -*-
+#
+#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
 
-AC_MSG_CHECKING([how to convert $build file names to toolchain format])
-AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
-[#assume ordinary cross tools, or native build.
-lt_cv_to_tool_file_cmd=func_convert_file_noop
-case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
-        ;;
-    esac
-    ;;
-esac
+# @configure_input@
+
+# serial 3337 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.4.2])
+m4_define([LT_PACKAGE_REVISION], [1.3337])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.4.2'
+macro_revision='1.3337'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
 ])
-to_tool_file_cmd=$lt_cv_to_tool_file_cmd
-AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
-_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
-         [0], [convert $build files to toolchain format])dnl
-])# _LT_PATH_CONVERSION_FUNCTIONS
 
-# Helper functions for option handling.                    -*- Autoconf -*-
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
-#   Written by Gary V. Vaughan, 2004
+#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 7 ltoptions.m4
+# serial 5 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else.  This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
 
 # This is to help aclocal find these macros, as it can't see m4_define.
-AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],	[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
+m4_ifndef([_LT_AC_PROG_CXXCPP],		[AC_DEFUN([_LT_AC_PROG_CXXCPP])])
+m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],	[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
+m4_ifndef([_LT_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
+m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
+m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
+
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+# 
+# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
 
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
 
-# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
-# ------------------------------------------
-m4_define([_LT_MANGLE_OPTION],
-[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
 
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
 
-# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
-# ---------------------------------------
-# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
-# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
-# saved as a flag.
-m4_define([_LT_SET_OPTION],
-[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
-m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
-        _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
-])
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
 
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
 
-# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
-# ------------------------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-m4_define([_LT_IF_OPTION],
-[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
 
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
 
-# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
-# -------------------------------------------------------
-# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
-# are set.
-m4_define([_LT_UNLESS_OPTIONS],
-[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
-	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
-		      [m4_define([$0_found])])])[]dnl
-m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
-])[]dnl
-])
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
 
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
 
-# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
-# ----------------------------------------
-# OPTION-LIST is a space-separated list of Libtool options associated
-# with MACRO-NAME.  If any OPTION has a matching handler declared with
-# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
-# the unknown option and exit.
-m4_defun([_LT_SET_OPTIONS],
-[# Set options
-m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
-    [_LT_SET_OPTION([$1], _LT_Option)])
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
 
-m4_if([$1],[LT_INIT],[
-  dnl
-  dnl Simply set some default values (i.e off) if boolean options were not
-  dnl specified:
-  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
-  ])
-  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
-  ])
-  dnl
-  dnl If no reference was made to various pairs of opposing options, then
-  dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
-  dnl archives by default:
-  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
-  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
-  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
-  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
-  ])
-])# _LT_SET_OPTIONS
+if test $pkg_failed = yes; then
+   	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else 
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
 
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
 
+$$1_PKG_ERRORS
 
-# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
-# -----------------------------------------
-m4_define([_LT_MANGLE_DEFUN],
-[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+     	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
 
-# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
-# -----------------------------------------------
-m4_define([LT_OPTION_DEFINE],
-[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
-])# LT_OPTION_DEFINE
+_PKG_TEXT
 
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])# PKG_CHECK_MODULES
 
-# dlopen
-# ------
-LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
-])
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-AU_DEFUN([AC_LIBTOOL_DLOPEN],
-[_LT_SET_OPTION([LT_INIT], [dlopen])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.14'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.14.1], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
-
-
-# win32-dll
-# ---------
-# Declare package support for building win32 dll's.
-LT_OPTION_DEFINE([LT_INIT], [win32-dll],
-[enable_win32_dll=yes
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
 
-case $host in
-*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
-  AC_CHECK_TOOL(AS, as, false)
-  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
-  AC_CHECK_TOOL(OBJDUMP, objdump, false)
-  ;;
-esac
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.14.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
-test -z "$AS" && AS=as
-_LT_DECL([], [AS],      [1], [Assembler program])dnl
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-test -z "$OBJDUMP" && OBJDUMP=objdump
-_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
-])# win32-dll
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
 
-AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-_LT_SET_OPTION([LT_INIT], [win32-dll])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
 ])
 
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+# AM_CONDITIONAL                                            -*- Autoconf -*-
 
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# _LT_ENABLE_SHARED([DEFAULT])
-# ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-m4_define([_LT_ENABLE_SHARED],
-[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
-AC_ARG_ENABLE([shared],
-    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
-	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_shared=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
 
-    _LT_DECL([build_libtool_libs], [enable_shared], [0],
-	[Whether or not to build shared libraries])
-])# _LT_ENABLE_SHARED
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
-LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
 
-# Old names:
-AC_DEFUN([AC_ENABLE_SHARED],
-[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
-])
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
 
-AC_DEFUN([AC_DISABLE_SHARED],
-[_LT_SET_OPTION([LT_INIT], [disable-shared])
-])
 
-AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
-AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
 
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_ENABLE_SHARED], [])
-dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
 
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
 
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-# _LT_ENABLE_STATIC([DEFAULT])
-# ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-m4_define([_LT_ENABLE_STATIC],
-[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
-AC_ARG_ENABLE([static],
-    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
-	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_static=yes ;;
-    no) enable_static=no ;;
-    *)
-     enable_static=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_static=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
       ;;
-    esac],
-    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
-
-    _LT_DECL([build_old_libs], [enable_static], [0],
-	[Whether or not to build static libraries])
-])# _LT_ENABLE_STATIC
-
-LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
-LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
 
-# Old names:
-AC_DEFUN([AC_ENABLE_STATIC],
-[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
 ])
-
-AC_DEFUN([AC_DISABLE_STATIC],
-[_LT_SET_OPTION([LT_INIT], [disable-static])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
 ])
 
-AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
-AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_ENABLE_STATIC], [])
-dnl AC_DEFUN([AM_DISABLE_STATIC], [])
-
 
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
 
-# _LT_ENABLE_FAST_INSTALL([DEFAULT])
-# ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-m4_define([_LT_ENABLE_FAST_INSTALL],
-[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
-AC_ARG_ENABLE([fast-install],
-    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
-    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_fast_install=yes ;;
-    no) enable_fast_install=no ;;
-    *)
-      enable_fast_install=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_fast_install=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
-
-_LT_DECL([fast_install], [enable_fast_install], [0],
-	 [Whether or not to optimize for fast installation])dnl
-])# _LT_ENABLE_FAST_INSTALL
-
-LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
-LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
 
-# Old names:
-AU_DEFUN([AC_ENABLE_FAST_INSTALL],
-[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
 ])
 
-AU_DEFUN([AC_DISABLE_FAST_INSTALL],
-[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
-])
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
-dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 
-# _LT_WITH_PIC([MODE])
-# --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
-# LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
-m4_define([_LT_WITH_PIC],
-[AC_ARG_WITH([pic],
-    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
-	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
-    [lt_p=${PACKAGE-default}
-    case $withval in
-    yes|no) pic_mode=$withval ;;
-    *)
-      pic_mode=default
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
-	if test "X$lt_pkg" = "X$lt_p"; then
-	  pic_mode=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [pic_mode=default])
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Older Autoconf quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named 'Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running 'make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "$am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
 
-_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
-])# _LT_WITH_PIC
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
 
-LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
-LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+# Do all the work for Automake.                             -*- Autoconf -*-
 
-# Old name:
-AU_DEFUN([AC_LIBTOOL_PICMODE],
-[_LT_SET_OPTION([LT_INIT], [pic-only])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
-])
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
 
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
 
-m4_define([_LTDL_MODE], [])
-LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
-		 [m4_define([_LTDL_MODE], [nonrecursive])])
-LT_OPTION_DEFINE([LTDL_INIT], [recursive],
-		 [m4_define([_LTDL_MODE], [recursive])])
-LT_OPTION_DEFINE([LTDL_INIT], [subproject],
-		 [m4_define([_LTDL_MODE], [subproject])])
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.65])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
 
-m4_define([_LTDL_TYPE], [])
-LT_OPTION_DEFINE([LTDL_INIT], [installable],
-		 [m4_define([_LTDL_TYPE], [installable])])
-LT_OPTION_DEFINE([LTDL_INIT], [convenience],
-		 [m4_define([_LTDL_TYPE], [convenience])])
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
 
-# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
-#
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
-# Written by Gary V. Vaughan, 2004
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+             [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 
-# serial 6 ltsugar.m4
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
 
-# This is to help aclocal find these macros, as it can't see m4_define.
-AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+			     [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+		  [_AM_DEPENDENCIES([CC])],
+		  [m4_define([AC_PROG_CC],
+			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+		  [_AM_DEPENDENCIES([CXX])],
+		  [m4_define([AC_PROG_CXX],
+			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+		  [_AM_DEPENDENCIES([OBJC])],
+		  [m4_define([AC_PROG_OBJC],
+			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+		  [_AM_DEPENDENCIES([OBJCXX])],
+		  [m4_define([AC_PROG_OBJCXX],
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
+])
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
 
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
 
-# lt_join(SEP, ARG1, [ARG2...])
-# -----------------------------
-# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
-# associated separator.
-# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
-# versions in m4sugar had bugs.
-m4_define([lt_join],
-[m4_if([$#], [1], [],
-       [$#], [2], [[$2]],
-       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
-m4_define([_lt_join],
-[m4_if([$#$2], [2], [],
-       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
 
+Please tell bug-automake at gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
 
-# lt_car(LIST)
-# lt_cdr(LIST)
-# ------------
-# Manipulate m4 lists.
-# These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
-m4_define([lt_car], [[$1]])
-m4_define([lt_cdr],
-[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
-       [$#], 1, [],
-       [m4_dquote(m4_shift($@))])])
-m4_define([lt_unquote], $1)
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
 
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
 
-# lt_append(MACRO-NAME, STRING, [SEPARATOR])
-# ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
-# Note that neither SEPARATOR nor STRING are expanded; they are appended
-# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
-# No SEPARATOR is output if MACRO-NAME was previously undefined (different
-# than defined and empty).
-#
-# This macro is needed until we can rely on Autoconf 2.62, since earlier
-# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
-m4_define([lt_append],
-[m4_define([$1],
-	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
 
+END
+    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+  fi
+fi])
 
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
 
-# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
-# ----------------------------------------------------------
-# Produce a SEP delimited list of all paired combinations of elements of
-# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
-# has the form PREFIXmINFIXSUFFIXn.
-# Needed until we can rely on m4_combine added in Autoconf 2.62.
-m4_define([lt_combine],
-[m4_if(m4_eval([$# > 3]), [1],
-       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
-[[m4_foreach([_Lt_prefix], [$2],
-	     [m4_foreach([_Lt_suffix],
-		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
-	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
 
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
-# -----------------------------------------------------------------------
-# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
-# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
-m4_define([lt_if_append_uniq],
-[m4_ifdef([$1],
-	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
-		 [lt_append([$1], [$2], [$3])$4],
-		 [$5])],
-	  [lt_append([$1], [$2], [$3])$4])])
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST([install_sh])])
 
-# lt_dict_add(DICT, KEY, VALUE)
-# -----------------------------
-m4_define([lt_dict_add],
-[m4_define([$1($2)], [$3])])
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
 
-# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
-# --------------------------------------------
-m4_define([lt_dict_add_subkey],
-[m4_define([$1($2:$3)], [$4])])
+# Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# lt_dict_fetch(DICT, KEY, [SUBKEY])
-# ----------------------------------
-m4_define([lt_dict_fetch],
-[m4_ifval([$3],
-	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
-    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
 
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
-# -----------------------------------------------------------------
-m4_define([lt_if_dict_fetch],
-[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
-	[$5],
-    [$6])])
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
 
-# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
-# --------------------------------------------------------------
-m4_define([lt_dict_filter],
-[m4_if([$5], [], [],
-  [lt_join(m4_quote(m4_default([$4], [[, ]])),
-           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
-		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
+else
+  am_missing_run=
+  AC_MSG_WARN(['missing' script is too old or missing])
+fi
 ])
 
-# ltversion.m4 -- version numbers			-*- Autoconf -*-
-#
-#   Copyright (C) 2004 Free Software Foundation, Inc.
-#   Written by Scott James Remnant, 2004
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# @configure_input@
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
 
-# serial 3337 ltversion.m4
-# This file is part of GNU Libtool
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
 
-AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
-_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
-_LT_DECL(, macro_revision, 0)
-])
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
-#
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
-#   Written by Scott James Remnant, 2004.
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
 #
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 5 lt~obsolete.m4
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+  [whether $CC understands -c and -o together],
+  [am_cv_prog_cc_c_o],
+  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
 
-# These exist entirely to fool aclocal when bootstrapping libtool.
-#
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
-# which have later been changed to m4_define as they aren't part of the
-# exported API, or moved to Autoconf or Automake where they belong.
-#
-# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
-# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
-# using a macro with the same name in our local m4/libtool.m4 it'll
-# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
-# and doesn't know about Autoconf macros at all.)
-#
-# So we provide this file, which has a silly filename so it's always
-# included after everything else.  This provides aclocal with the
-# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
-# because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
-# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
-# Yes, that means every name once taken will need to remain here until
-# we give up compatibility with versions before 1.7, at which point
-# we need to keep only those names which we still refer to.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# This is to help aclocal find these macros, as it can't see m4_define.
-AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   (exit $ac_status); }])
 
-m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
-m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
-m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
-m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
-m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
-m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
-m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
-m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
-m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
-m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
-m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
-m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
-m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
-m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
-m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
-m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
-m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
-m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
-m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
-m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
-m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
-m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
-m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
-m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
-m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
-m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
-m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
-m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
-m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
-m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
-m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
-m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
-m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
-m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
-m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
-m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
-m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
-m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
-m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
-m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
-m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
-m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
-m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
-m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
-m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
-m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
-m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
-m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
-m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
-m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
-m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],	[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
-m4_ifndef([_LT_AC_PROG_CXXCPP],		[AC_DEFUN([_LT_AC_PROG_CXXCPP])])
-m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],	[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
-m4_ifndef([_LT_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
-m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
-m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
-m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-# 
-# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 #
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
-AC_DEFUN([PKG_PROG_PKG_CONFIG],
-[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
-m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
-AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
-AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
-AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
 
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
 fi
-if test -n "$PKG_CONFIG"; then
-	_pkg_min_version=m4_default([$1], [0.9.0])
-	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
-	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-		AC_MSG_RESULT([yes])
-	else
-		AC_MSG_RESULT([no])
-		PKG_CONFIG=""
-	fi
-fi[]dnl
-])# PKG_PROG_PKG_CONFIG
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+   [am_cv_make_support_nested_variables],
+   [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
 
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
-# Check to see whether a particular set of modules exists.  Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
 #
-# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
-# it's called might be skipped (such as if it is within an "if", you
-# have to call PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
-AC_DEFUN([PKG_CHECK_EXISTS],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-if test -n "$PKG_CONFIG" && \
-    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
-  m4_default([$2], [:])
-m4_ifvaln([$3], [else
-  $3])dnl
-fi])
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
-m4_define([_PKG_CONFIG],
-[if test -n "$$1"; then
-    pkg_cv_[]$1="$$1"
- elif test -n "$PKG_CONFIG"; then
-    PKG_CHECK_EXISTS([$3],
-                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes ],
-		     [pkg_failed=yes])
- else
-    pkg_failed=untried
-fi[]dnl
-])# _PKG_CONFIG
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
 
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
-AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
+# Check how to create a tarball.                            -*- Autoconf -*-
 
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
 #
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
 #
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
 #
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
 #
-# --------------------------------------------------------------
-AC_DEFUN([PKG_CHECK_MODULES],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
-AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
 
-pkg_failed=no
-AC_MSG_CHECKING([for $1])
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
 
-_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+m4_if([$1], [v7],
+  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
 
-m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
-and $1[]_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.])
+  [m4_case([$1],
+    [ustar],
+     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+      # There is notably a 21 bits limit for the UID and the GID.  In fact,
+      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+      # and bug#13588).
+      am_max_uid=2097151 # 2^21 - 1
+      am_max_gid=$am_max_uid
+      # The $UID and $GID variables are not portable, so we need to resort
+      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
+      # below are definitely unexpected, so allow the users to see them
+      # (that is, avoid stderr redirection).
+      am_uid=`id -u || echo unknown`
+      am_gid=`id -g || echo unknown`
+      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+      if test $am_uid -le $am_max_uid; then
+         AC_MSG_RESULT([yes])
+      else
+         AC_MSG_RESULT([no])
+         _am_tools=none
+      fi
+      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+      if test $am_gid -le $am_max_gid; then
+         AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+        _am_tools=none
+      fi],
 
-if test $pkg_failed = yes; then
-   	AC_MSG_RESULT([no])
-        _PKG_SHORT_ERRORS_SUPPORTED
-        if test $_pkg_short_errors_supported = yes; then
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
-        else 
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+  [pax],
+    [],
 
-	m4_default([$4], [AC_MSG_ERROR(
-[Package requirements ($2) were not met:
+  [m4_fatal([Unknown tar format])])
 
-$$1_PKG_ERRORS
+  AC_MSG_CHECKING([how to create a $1 tar archive])
 
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
+  # Go ahead even if we have the value already cached.  We do so because we
+  # need to set the values for the 'am__tar' and 'am__untar' variables.
+  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
 
-_PKG_TEXT])[]dnl
-        ])
-elif test $pkg_failed = untried; then
-     	AC_MSG_RESULT([no])
-	m4_default([$4], [AC_MSG_FAILURE(
-[The pkg-config script could not be found or is too old.  Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
+  for _am_tool in $_am_tools; do
+    case $_am_tool in
+    gnutar)
+      for _am_tar in tar gnutar gtar; do
+        AM_RUN_LOG([$_am_tar --version]) && break
+      done
+      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+      am__untar="$_am_tar -xf -"
+      ;;
+    plaintar)
+      # Must skip GNU tar: if it does not support --format= it doesn't create
+      # ustar tarball either.
+      (tar --version) >/dev/null 2>&1 && continue
+      am__tar='tar chf - "$$tardir"'
+      am__tar_='tar chf - "$tardir"'
+      am__untar='tar xf -'
+      ;;
+    pax)
+      am__tar='pax -L -x $1 -w "$$tardir"'
+      am__tar_='pax -L -x $1 -w "$tardir"'
+      am__untar='pax -r'
+      ;;
+    cpio)
+      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__untar='cpio -i -H $1 -d'
+      ;;
+    none)
+      am__tar=false
+      am__tar_=false
+      am__untar=false
+      ;;
+    esac
 
-_PKG_TEXT
+    # If the value was cached, stop now.  We just wanted to have am__tar
+    # and am__untar set.
+    test -n "${am_cv_prog_tar_$1}" && break
 
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
-        ])
-else
-	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
-	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
-        AC_MSG_RESULT([yes])
-	$3
-fi[]dnl
-])# PKG_CHECK_MODULES
+    # tar/untar a dummy directory, and stop if the command works.
+    rm -rf conftest.dir
+    mkdir conftest.dir
+    echo GrepMe > conftest.dir/file
+    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    rm -rf conftest.dir
+    if test -s conftest.tar; then
+      AM_RUN_LOG([$am__untar <conftest.tar])
+      AM_RUN_LOG([cat conftest.dir/file])
+      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+    fi
+  done
+  rm -rf conftest.dir
 
-AC_DEFUN([WAYLAND_SCANNER_RULES], [
-    PKG_PROG_PKG_CONFIG
+  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
 
-    PKG_CHECK_MODULES([WAYLAND_SCANNER], [wayland-scanner])
+AC_DEFUN([WAYLAND_SCANNER_RULES], [
+    wayland__prefix=${prefix}
+    wayland__exec_prefix=${exec_prefix}
 
-    wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
-    AC_SUBST([wayland_scanner])
+    prefix=/opt/X11R7
+    exec_prefix=${prefix}
 
-    wayland_scanner_rules=`$PKG_CONFIG --variable=pkgdatadir wayland-scanner`/wayland-scanner.mk
+    AC_PATH_PROG([wayland_scanner], [wayland-scanner], [/bin/false],
+		 [${exec_prefix}/bin$PATH_SEPARATOR$PATH])
     AC_SUBST_FILE([wayland_scanner_rules])
-
     AC_SUBST([wayland_protocoldir], [$1])
+    wayland_scanner_rules=${prefix}/share/aclocal/wayland-scanner.mk
+
+    prefix=${wayland__prefix}
+    exec_prefix=${wayland__exec_prefix}
 ])
 
diff --git a/configure b/configure
index f3e8ac1..f6da06c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for intel_driver 1.4.1.
+# Generated by GNU Autoconf 2.69 for intel_driver 1.5.0.pre1.
 #
 # Report bugs to <haihao.xiang at intel.com>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='intel_driver'
 PACKAGE_TARNAME='libva-intel-driver'
-PACKAGE_VERSION='1.4.1'
-PACKAGE_STRING='intel_driver 1.4.1'
+PACKAGE_VERSION='1.5.0.pre1'
+PACKAGE_STRING='intel_driver 1.5.0.pre1'
 PACKAGE_BUGREPORT='haihao.xiang at intel.com'
 PACKAGE_URL=''
 
@@ -638,8 +638,6 @@ LTLIBOBJS
 LIBOBJS
 wayland_protocoldir
 wayland_scanner
-WAYLAND_SCANNER_LIBS
-WAYLAND_SCANNER_CFLAGS
 USE_WAYLAND_FALSE
 USE_WAYLAND_TRUE
 LIBVA_WAYLAND_DEPS_LIBS
@@ -661,6 +659,9 @@ LIBVA_DRM_DEPS_LIBS
 LIBVA_DRM_DEPS_CFLAGS
 LIBVA_DEPS_LIBS
 LIBVA_DEPS_CFLAGS
+HAVE_GIT_FALSE
+HAVE_GIT_TRUE
+GIT
 GEN4ASM
 HAVE_GEN4ASM_FALSE
 HAVE_GEN4ASM_TRUE
@@ -673,6 +674,7 @@ PKG_CONFIG_LIBDIR
 PKG_CONFIG_PATH
 PKG_CONFIG
 LIBVA_PACKAGE_VERSION
+PYTHON2
 CPP
 OTOOL64
 OTOOL
@@ -819,6 +821,7 @@ DRM_CFLAGS
 DRM_LIBS
 GEN4ASM_CFLAGS
 GEN4ASM_LIBS
+GIT
 LIBVA_DEPS_CFLAGS
 LIBVA_DEPS_LIBS
 LIBVA_DRM_DEPS_CFLAGS
@@ -830,9 +833,7 @@ EGL_LIBS
 WAYLAND_CFLAGS
 WAYLAND_LIBS
 LIBVA_WAYLAND_DEPS_CFLAGS
-LIBVA_WAYLAND_DEPS_LIBS
-WAYLAND_SCANNER_CFLAGS
-WAYLAND_SCANNER_LIBS'
+LIBVA_WAYLAND_DEPS_LIBS'
 
 
 # Initialize some variables set by options.
@@ -1373,7 +1374,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures intel_driver 1.4.1 to adapt to many kinds of systems.
+\`configure' configures intel_driver 1.5.0.pre1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1444,7 +1445,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of intel_driver 1.4.1:";;
+     short | recursive ) echo "Configuration of intel_driver 1.5.0.pre1:";;
    esac
   cat <<\_ACEOF
 
@@ -1497,6 +1498,7 @@ Some influential environment variables:
               C compiler flags for GEN4ASM, overriding pkg-config
   GEN4ASM_LIBS
               linker flags for GEN4ASM, overriding pkg-config
+  GIT         Path to git program, if any
   LIBVA_DEPS_CFLAGS
               C compiler flags for LIBVA_DEPS, overriding pkg-config
   LIBVA_DEPS_LIBS
@@ -1519,10 +1521,6 @@ Some influential environment variables:
               C compiler flags for LIBVA_WAYLAND_DEPS, overriding pkg-config
   LIBVA_WAYLAND_DEPS_LIBS
               linker flags for LIBVA_WAYLAND_DEPS, overriding pkg-config
-  WAYLAND_SCANNER_CFLAGS
-              C compiler flags for WAYLAND_SCANNER, overriding pkg-config
-  WAYLAND_SCANNER_LIBS
-              linker flags for WAYLAND_SCANNER, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -1590,7 +1588,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-intel_driver configure 1.4.1
+intel_driver configure 1.5.0.pre1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1959,7 +1957,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by intel_driver $as_me 1.4.1, which was
+It was created by intel_driver $as_me 1.5.0.pre1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2823,7 +2821,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libva-intel-driver'
- VERSION='1.4.1'
+ VERSION='1.5.0.pre1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3036,19 +3034,19 @@ ac_config_headers="$ac_config_headers src/config.h"
 
 
 INTEL_DRIVER_MAJOR_VERSION=1
-INTEL_DRIVER_MINOR_VERSION=4
-INTEL_DRIVER_MICRO_VERSION=1
+INTEL_DRIVER_MINOR_VERSION=5
+INTEL_DRIVER_MICRO_VERSION=0
 
 $as_echo "#define INTEL_DRIVER_MAJOR_VERSION 1" >>confdefs.h
 
 
-$as_echo "#define INTEL_DRIVER_MINOR_VERSION 4" >>confdefs.h
+$as_echo "#define INTEL_DRIVER_MINOR_VERSION 5" >>confdefs.h
 
 
-$as_echo "#define INTEL_DRIVER_MICRO_VERSION 1" >>confdefs.h
+$as_echo "#define INTEL_DRIVER_MICRO_VERSION 0" >>confdefs.h
 
 
-$as_echo "#define INTEL_DRIVER_PRE_VERSION 0" >>confdefs.h
+$as_echo "#define INTEL_DRIVER_PRE_VERSION 1" >>confdefs.h
 
 
 INTEL_DRIVER_LT_LDFLAGS="-avoid-version"
@@ -13071,8 +13069,50 @@ _ACEOF
 fi
 done
 
+for ac_prog in python2 python
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_PYTHON2+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$PYTHON2"; then
+  ac_cv_prog_PYTHON2="$PYTHON2" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_PYTHON2="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+PYTHON2=$ac_cv_prog_PYTHON2
+if test -n "$PYTHON2"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON2" >&5
+$as_echo "$PYTHON2" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$PYTHON2" && break
+done
+
 
-LIBVA_PACKAGE_VERSION=1.4.0
+LIBVA_PACKAGE_VERSION=1.5.0
 
 
 LIBDRM_VERSION=2.4.45
@@ -13298,12 +13338,12 @@ if test -n "$GEN4ASM_CFLAGS"; then
     pkg_cv_GEN4ASM_CFLAGS="$GEN4ASM_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"intel-gen4asm >= 1.5\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "intel-gen4asm >= 1.5") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"intel-gen4asm >= 1.9\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "intel-gen4asm >= 1.9") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_GEN4ASM_CFLAGS=`$PKG_CONFIG --cflags "intel-gen4asm >= 1.5" 2>/dev/null`
+  pkg_cv_GEN4ASM_CFLAGS=`$PKG_CONFIG --cflags "intel-gen4asm >= 1.9" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -13315,12 +13355,12 @@ if test -n "$GEN4ASM_LIBS"; then
     pkg_cv_GEN4ASM_LIBS="$GEN4ASM_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"intel-gen4asm >= 1.5\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "intel-gen4asm >= 1.5") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"intel-gen4asm >= 1.9\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "intel-gen4asm >= 1.9") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_GEN4ASM_LIBS=`$PKG_CONFIG --libs "intel-gen4asm >= 1.5" 2>/dev/null`
+  pkg_cv_GEN4ASM_LIBS=`$PKG_CONFIG --libs "intel-gen4asm >= 1.9" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -13341,9 +13381,9 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        GEN4ASM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "intel-gen4asm >= 1.5" 2>&1`
+	        GEN4ASM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "intel-gen4asm >= 1.9" 2>&1`
         else
-	        GEN4ASM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "intel-gen4asm >= 1.5" 2>&1`
+	        GEN4ASM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "intel-gen4asm >= 1.9" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$GEN4ASM_PKG_ERRORS" >&5
@@ -13410,6 +13450,56 @@ fi
 
 
 
+# Extract the first word of "git", so it can be a program name with args.
+set dummy git; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GIT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GIT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GIT="$GIT" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GIT="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GIT=$ac_cv_path_GIT
+if test -n "$GIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GIT" >&5
+$as_echo "$GIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test -n "$GIT"; then
+  HAVE_GIT_TRUE=
+  HAVE_GIT_FALSE='#'
+else
+  HAVE_GIT_TRUE='#'
+  HAVE_GIT_FALSE=
+fi
+
+
+
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBVA_DEPS" >&5
 $as_echo_n "checking for LIBVA_DEPS... " >&6; }
@@ -13418,12 +13508,12 @@ if test -n "$LIBVA_DEPS_CFLAGS"; then
     pkg_cv_LIBVA_DEPS_CFLAGS="$LIBVA_DEPS_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libva >= 0.36\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libva >= 0.36") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libva >= 0.37\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libva >= 0.37") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_LIBVA_DEPS_CFLAGS=`$PKG_CONFIG --cflags "libva >= 0.36" 2>/dev/null`
+  pkg_cv_LIBVA_DEPS_CFLAGS=`$PKG_CONFIG --cflags "libva >= 0.37" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -13435,12 +13525,12 @@ if test -n "$LIBVA_DEPS_LIBS"; then
     pkg_cv_LIBVA_DEPS_LIBS="$LIBVA_DEPS_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libva >= 0.36\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libva >= 0.36") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libva >= 0.37\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libva >= 0.37") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_LIBVA_DEPS_LIBS=`$PKG_CONFIG --libs "libva >= 0.36" 2>/dev/null`
+  pkg_cv_LIBVA_DEPS_LIBS=`$PKG_CONFIG --libs "libva >= 0.37" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -13461,14 +13551,14 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        LIBVA_DEPS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libva >= 0.36" 2>&1`
+	        LIBVA_DEPS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libva >= 0.37" 2>&1`
         else
-	        LIBVA_DEPS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libva >= 0.36" 2>&1`
+	        LIBVA_DEPS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libva >= 0.37" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$LIBVA_DEPS_PKG_ERRORS" >&5
 
-	as_fn_error $? "Package requirements (libva >= 0.36) were not met:
+	as_fn_error $? "Package requirements (libva >= 0.37) were not met:
 
 $LIBVA_DEPS_PKG_ERRORS
 
@@ -13713,7 +13803,7 @@ fi
 $as_echo_n "checking for VA drivers path... " >&6; }
 LIBVA_DRIVERS_PATH=`$PKG_CONFIG libva --variable driverdir`
 if test -z "$LIBVA_DRIVERS_PATH"; then
-    LIBVA_DRIVERS_PATH="/usr/lib/xorg/modules/drivers"
+    LIBVA_DRIVERS_PATH="${libdir}/xorg/modules/drivers"
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBVA_DRIVERS_PATH" >&5
 $as_echo "$LIBVA_DRIVERS_PATH" >&6; }
@@ -14027,35 +14117,32 @@ fi
 
 
 
+    wayland__prefix=${prefix}
+    wayland__exec_prefix=${exec_prefix}
 
+    prefix=/opt/X11R7
+    exec_prefix=${prefix}
 
-
-
-
-
-
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-	if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+    # Extract the first word of "wayland-scanner", so it can be a program name with args.
+set dummy wayland-scanner; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_PKG_CONFIG+:} false; then :
+if ${ac_cv_path_wayland_scanner+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $PKG_CONFIG in
+  case $wayland_scanner in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ac_cv_path_wayland_scanner="$wayland_scanner" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+for as_dir in ${exec_prefix}/bin$PATH_SEPARATOR$PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    ac_cv_path_wayland_scanner="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -14063,194 +14150,30 @@ done
   done
 IFS=$as_save_IFS
 
+  test -z "$ac_cv_path_wayland_scanner" && ac_cv_path_wayland_scanner="/bin/false"
   ;;
 esac
 fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-$as_echo "$PKG_CONFIG" >&6; }
+wayland_scanner=$ac_cv_path_wayland_scanner
+if test -n "$wayland_scanner"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $wayland_scanner" >&5
+$as_echo "$wayland_scanner" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-fi
-if test -z "$ac_cv_path_PKG_CONFIG"; then
-  ac_pt_PKG_CONFIG=$PKG_CONFIG
-  # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ac_pt_PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-  ;;
-esac
-fi
-ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
-if test -n "$ac_pt_PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
-$as_echo "$ac_pt_PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+    wayland_protocoldir='$(top_builddir)/src/wayland'
 
-  if test "x$ac_pt_PKG_CONFIG" = x; then
-    PKG_CONFIG=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    PKG_CONFIG=$ac_pt_PKG_CONFIG
-  fi
-else
-  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-fi
+    wayland_scanner_rules=${prefix}/share/aclocal/wayland-scanner.mk
 
-fi
-if test -n "$PKG_CONFIG"; then
-	_pkg_min_version=0.9.0
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
-$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
-	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	else
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		PKG_CONFIG=""
-	fi
-fi
+    prefix=${wayland__prefix}
+    exec_prefix=${wayland__exec_prefix}
 
 
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WAYLAND_SCANNER" >&5
-$as_echo_n "checking for WAYLAND_SCANNER... " >&6; }
-
-if test -n "$WAYLAND_SCANNER_CFLAGS"; then
-    pkg_cv_WAYLAND_SCANNER_CFLAGS="$WAYLAND_SCANNER_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"wayland-scanner\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "wayland-scanner") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_WAYLAND_SCANNER_CFLAGS=`$PKG_CONFIG --cflags "wayland-scanner" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$WAYLAND_SCANNER_LIBS"; then
-    pkg_cv_WAYLAND_SCANNER_LIBS="$WAYLAND_SCANNER_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"wayland-scanner\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "wayland-scanner") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_WAYLAND_SCANNER_LIBS=`$PKG_CONFIG --libs "wayland-scanner" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        WAYLAND_SCANNER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "wayland-scanner" 2>&1`
-        else
-	        WAYLAND_SCANNER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "wayland-scanner" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$WAYLAND_SCANNER_PKG_ERRORS" >&5
-
-	as_fn_error $? "Package requirements (wayland-scanner) were not met:
-
-$WAYLAND_SCANNER_PKG_ERRORS
-
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
-
-Alternatively, you may set the environment variables WAYLAND_SCANNER_CFLAGS
-and WAYLAND_SCANNER_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." "$LINENO" 5
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "The pkg-config script could not be found or is too old.  Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-Alternatively, you may set the environment variables WAYLAND_SCANNER_CFLAGS
-and WAYLAND_SCANNER_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.
-See \`config.log' for more details" "$LINENO" 5; }
-else
-	WAYLAND_SCANNER_CFLAGS=$pkg_cv_WAYLAND_SCANNER_CFLAGS
-	WAYLAND_SCANNER_LIBS=$pkg_cv_WAYLAND_SCANNER_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-fi
-
-    wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
-
-
-    wayland_scanner_rules=`$PKG_CONFIG --variable=pkgdatadir wayland-scanner`/wayland-scanner.mk
-
-
-    wayland_protocoldir='$(top_srcdir)/src/wayland'
-
-
-
-ac_config_files="$ac_config_files Makefile debian.upstream/Makefile src/Makefile src/shaders/Makefile src/shaders/h264/Makefile src/shaders/h264/ildb/Makefile src/shaders/h264/mc/Makefile src/shaders/mpeg2/Makefile src/shaders/mpeg2/vld/Makefile src/shaders/post_processing/Makefile src/shaders/post_processing/gen5_6/Makefile src/shaders/post_processing/gen7/Makefile src/shaders/post_processing/gen75/Makefile src/shaders/post_processing/gen8/Makefile src/shaders/render/Makefile src/shaders/utils/Makefile src/shaders/vme/Makefile src/wayland/Makefile"
+ac_config_files="$ac_config_files Makefile debian.upstream/Makefile src/Makefile src/shaders/Makefile src/shaders/h264/Makefile src/shaders/h264/ildb/Makefile src/shaders/h264/mc/Makefile src/shaders/mpeg2/Makefile src/shaders/mpeg2/vld/Makefile src/shaders/post_processing/Makefile src/shaders/post_processing/gen5_6/Makefile src/shaders/post_processing/gen7/Makefile src/shaders/post_processing/gen75/Makefile src/shaders/post_processing/gen8/Makefile src/shaders/post_processing/gen9/Makefile src/shaders/render/Makefile src/shaders/utils/Makefile src/shaders/vme/Makefile src/wayland/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -14394,6 +14317,10 @@ if test -z "${HAVE_GEN4ASM_TRUE}" && test -z "${HAVE_GEN4ASM_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_GEN4ASM\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_GIT_TRUE}" && test -z "${HAVE_GIT_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_GIT\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${USE_DRM_TRUE}" && test -z "${USE_DRM_FALSE}"; then
   as_fn_error $? "conditional \"USE_DRM\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -14807,7 +14734,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by intel_driver $as_me 1.4.1, which was
+This file was extended by intel_driver $as_me 1.5.0.pre1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14873,7 +14800,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-intel_driver config.status 1.4.1
+intel_driver config.status 1.5.0.pre1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -15296,6 +15223,7 @@ do
     "src/shaders/post_processing/gen7/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/post_processing/gen7/Makefile" ;;
     "src/shaders/post_processing/gen75/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/post_processing/gen75/Makefile" ;;
     "src/shaders/post_processing/gen8/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/post_processing/gen8/Makefile" ;;
+    "src/shaders/post_processing/gen9/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/post_processing/gen9/Makefile" ;;
     "src/shaders/render/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/render/Makefile" ;;
     "src/shaders/utils/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/utils/Makefile" ;;
     "src/shaders/vme/Makefile") CONFIG_FILES="$CONFIG_FILES src/shaders/vme/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 28b7376..43fd2db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
 # intel-driver package version number
 m4_define([intel_driver_major_version], [1])
-m4_define([intel_driver_minor_version], [4])
-m4_define([intel_driver_micro_version], [1])
-m4_define([intel_driver_pre_version],   [0])
+m4_define([intel_driver_minor_version], [5])
+m4_define([intel_driver_micro_version], [0])
+m4_define([intel_driver_pre_version],   [1])
 m4_define([intel_driver_version],
           [intel_driver_major_version.intel_driver_minor_version.intel_driver_micro_version])
 m4_if(intel_driver_pre_version, [0], [], [
@@ -10,8 +10,8 @@ m4_append([intel_driver_version], intel_driver_pre_version, [.pre])
 ])
 
 # libva minimum version requirement
-m4_define([va_api_version], [0.36])
-m4_define([libva_package_version], [1.4.0])
+m4_define([va_api_version], [0.37])
+m4_define([libva_package_version], [1.5.0])
 
 # libdrm minimum version requirement
 m4_define([libdrm_version], [2.4.45])
@@ -66,6 +66,7 @@ AC_HEADER_STDC
 AC_SYS_LARGEFILE
 AC_CHECK_LIB([m], [sin])
 AC_CHECK_FUNCS([log2f])
+AC_CHECK_PROGS([PYTHON2], [python2 python])
 
 LIBVA_PACKAGE_VERSION=libva_package_version
 AC_SUBST(LIBVA_PACKAGE_VERSION)
@@ -76,10 +77,15 @@ PKG_CHECK_MODULES([DRM], [libdrm >= $LIBDRM_VERSION])
 AC_SUBST(LIBDRM_VERSION)
 
 dnl Check for gen4asm
-PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.5], [gen4asm=yes], [gen4asm=no])
+PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.9], [gen4asm=yes], [gen4asm=no])
 AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
 AC_PATH_PROG([GEN4ASM], [intel-gen4asm])
 
+dnl Check for git
+AC_ARG_VAR([GIT], [Path to git program, if any])
+AC_PATH_PROG([GIT], [git])
+AM_CONDITIONAL([HAVE_GIT], [test -n "$GIT"])
+
 dnl Check for VA-API
 PKG_CHECK_MODULES(LIBVA_DEPS,     [libva >= va_api_version])
 
@@ -127,7 +133,7 @@ dnl Check for VA-API drivers path
 AC_MSG_CHECKING([for VA drivers path])
 LIBVA_DRIVERS_PATH=`$PKG_CONFIG libva --variable driverdir`
 if test -z "$LIBVA_DRIVERS_PATH"; then
-    LIBVA_DRIVERS_PATH="/usr/lib/xorg/modules/drivers"
+    LIBVA_DRIVERS_PATH="${libdir}/xorg/modules/drivers"
 fi
 AC_MSG_RESULT([$LIBVA_DRIVERS_PATH])
 AC_SUBST(LIBVA_DRIVERS_PATH)
@@ -162,7 +168,7 @@ fi
 AM_CONDITIONAL(USE_WAYLAND, test "$USE_WAYLAND" = "yes")
 
 m4_ifdef([WAYLAND_SCANNER_RULES],
-    [WAYLAND_SCANNER_RULES(['$(top_srcdir)/src/wayland'])],
+    [WAYLAND_SCANNER_RULES(['$(top_builddir)/src/wayland'])],
     [wayland_scanner_rules=""; AC_SUBST(wayland_scanner_rules)])
 
 AC_OUTPUT([
@@ -180,6 +186,7 @@ AC_OUTPUT([
     src/shaders/post_processing/gen7/Makefile
     src/shaders/post_processing/gen75/Makefile
     src/shaders/post_processing/gen8/Makefile
+    src/shaders/post_processing/gen9/Makefile
     src/shaders/render/Makefile
     src/shaders/utils/Makefile
     src/shaders/vme/Makefile
diff --git a/debian.upstream/Makefile.am b/debian.upstream/Makefile.am
index 9ef70b6..04a848f 100644
--- a/debian.upstream/Makefile.am
+++ b/debian.upstream/Makefile.am
@@ -16,8 +16,10 @@ EXTRA_DIST = $(DEBIANFILES)
 
 dist_noinst_DATA = $(DEBIANGENFILES)
 
+DISTCLEANFILES = $(DEBIANGENFILES)
+
 # Extra clean files so that maintainer-clean removes *everything*
-MAINTAINERCLEANFILES = Makefile.in $(DEBIANGENFILES)
+MAINTAINERCLEANFILES = Makefile.in
 
 $(DEBIANGENFILES): %: %.in Makefile
 	-$(AM_V_GEN)sed \
diff --git a/debian.upstream/Makefile.in b/debian.upstream/Makefile.in
index 8a05bc9..f3dbb6f 100644
--- a/debian.upstream/Makefile.in
+++ b/debian.upstream/Makefile.in
@@ -143,6 +143,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -189,6 +190,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -197,8 +199,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -269,9 +269,10 @@ DEBIANGENFILES = \
 
 EXTRA_DIST = $(DEBIANFILES)
 dist_noinst_DATA = $(DEBIANGENFILES)
+DISTCLEANFILES = $(DEBIANGENFILES)
 
 # Extra clean files so that maintainer-clean removes *everything*
-MAINTAINERCLEANFILES = Makefile.in $(DEBIANGENFILES)
+MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
 .SUFFIXES:
@@ -378,6 +379,7 @@ clean-generic:
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
diff --git a/debian.upstream/changelog b/debian.upstream/changelog
index 6ebe4b7..8ad5052 100644
--- a/debian.upstream/changelog
+++ b/debian.upstream/changelog
@@ -1,5 +1,5 @@
-libva-intel-driver (1.4.1-1) unstable; urgency=low
+libva-intel-driver (1.5.0.pre1-1) unstable; urgency=low
 
   * Autogenerated package, see NEWS file for ChangeLog.
 
- -- Gwenole Beauchesne <gwenole.beauchesne at intel.com>  Fri, 24 Oct 2014 15:02:37 +0800
+ -- Gwenole Beauchesne <gwenole.beauchesne at intel.com>  Mon, 15 Dec 2014 14:43:12 +0800
diff --git a/debian.upstream/control b/debian.upstream/control
index a639505..d5c08ea 100644
--- a/debian.upstream/control
+++ b/debian.upstream/control
@@ -5,13 +5,13 @@ Maintainer: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
 Build-Depends: debhelper (>= 5),
 	       cdbs,
 	       libdrm-dev (>= 2.4.45),
-	       libva-dev (>= 1.4.0)
+	       libva-dev (>= 1.5.0)
 Standards-Version: 3.7.2
 
 Package: libva-intel-driver
 Section: libs
 Architecture: any
-Depends: libva1 (>= 1.4.0),
+Depends: libva1 (>= 1.5.0),
 	 ${shlibs:Depends}, ${misc:Depends}
 Description: VA driver for Intel G45 & HD Graphics family
  Video decode & encode driver for Intel G45 chipsets and Intel HD
diff --git a/src/.VERSION.pkg b/src/.VERSION.pkg
new file mode 100644
index 0000000..4c9c062
--- /dev/null
+++ b/src/.VERSION.pkg
@@ -0,0 +1 @@
+1.3.2-72-g2b002e2
diff --git a/src/Makefile.am b/src/Makefile.am
index b35d1ac..7e755dc 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,7 +20,10 @@
 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-SUBDIRS = shaders
+SUBDIRS		= shaders
+DIST_SUBDIRS	= $(SUBDIRS)
+EXTRA_DIST	=
+BUILT_SOURCES	=
 
 AM_CPPFLAGS = \
 	-DPTHREADS		\
@@ -42,7 +45,6 @@ driver_ldflags = \
 driver_libs = \
 	-lpthread -lm -ldl	\
 	$(DRM_LIBS) -ldrm_intel	\
-	$(LIBVA_DEPS_LIBS)	\
 	$(NULL)
 
 source_c = \
@@ -59,10 +61,14 @@ source_c = \
 	gen8_mfc.c		\
 	gen8_mfd.c		\
 	gen8_vme.c		\
+	gen9_vme.c		\
+	gen9_mfc.c		\
+	gen9_mfd.c		\
 	gen75_picture_process.c	\
 	gen75_vme.c		\
 	gen75_vpp_gpe.c  	\
 	gen75_vpp_vebox.c	\
+	gen9_post_processing.c	\
 	i965_avc_bsd.c		\
 	i965_avc_hw_scoreboard.c\
 	i965_avc_ildb.c		\
@@ -78,7 +84,9 @@ source_c = \
 	i965_post_processing.c	\
 	gen8_post_processing.c	\
 	i965_render.c		\
+	i965_vpp_avs.c		\
 	gen8_render.c		\
+	gen9_render.c		\
 	intel_batchbuffer.c	\
 	intel_batchbuffer_dump.c\
 	intel_driver.c		\
@@ -96,6 +104,8 @@ source_h = \
 	gen75_picture_process.h	\
 	gen75_vpp_gpe.h 	\
 	gen75_vpp_vebox.h	\
+	gen8_post_processing.h	\
+	gen9_mfd.h		\
 	i965_avc_bsd.h		\
 	i965_avc_hw_scoreboard.h\
 	i965_avc_ildb.h		\
@@ -114,12 +124,14 @@ source_h = \
 	i965_post_processing.h	\
 	i965_render.h           \
 	i965_structs.h		\
+	i965_vpp_avs.h		\
 	intel_batchbuffer.h     \
 	intel_batchbuffer_dump.h\
 	intel_compiler.h	\
 	intel_driver.h          \
 	intel_media.h           \
 	intel_memman.h          \
+	intel_version.h		\
 	object_heap.h           \
 	sysdeps.h		\
 	va_backend_compat.h	\
@@ -142,15 +154,47 @@ endif
 if USE_WAYLAND
 source_c			+= i965_output_wayland.c
 source_h			+= i965_output_wayland.h
+source_h			+= $(protocol_source_h)
 driver_cflags			+= $(WAYLAND_CFLAGS)
 endif
 
+# git version
+VERSION_FILE			= .VERSION
+OLD_VERSION_FILE		= $(VERSION_FILE).old
+NEW_VERSION_FILE		= $(VERSION_FILE).new
+PKG_VERSION_FILE		= $(VERSION_FILE).pkg
+
+intel_version.h: gen-version
+	$(AM_V_GEN)							 \
+	OV=`[ -f $(OLD_VERSION_FILE) ] && cat $(OLD_VERSION_FILE) || :`; \
+	NV=`cat $(NEW_VERSION_FILE)`;					 \
+	if [ "$$OV" != "$$NV" -o ! -f intel_version.h ]; then		 \
+		cp -f $(NEW_VERSION_FILE) $(OLD_VERSION_FILE);		 \
+		$(SED) -e "s|\@INTEL_DRIVER_GIT_VERSION\@|$${NV}|"	 \
+			$(srcdir)/intel_version.h.in > intel_version.h;	 \
+	fi
+
+gen-version:
+	@echo $(VERSION) > $(NEW_VERSION_FILE)
+if HAVE_GIT
+	@[ -d $(top_srcdir)/.git ] && \
+	(cd $(top_srcdir) && $(GIT) describe --tags) > $(NEW_VERSION_FILE) || :
+endif
+	@[ -f $(srcdir)/$(PKG_VERSION_FILE) ] && \
+	cp -f $(srcdir)/$(PKG_VERSION_FILE) $(NEW_VERSION_FILE) || :
+
+$(PKG_VERSION_FILE): $(NEW_VERSION_FILE)
+	@cp -f $< $@
+
+BUILT_SOURCES	+= intel_version.h
+EXTRA_DIST	+= intel_version.h.in $(PKG_VERSION_FILE)
+
 # Wayland protocol
 protocol_source_h = wayland-drm-client-protocol.h
 i965_output_wayland.c: $(protocol_source_h)
 @wayland_scanner_rules@
 
-DIST_SUBDIRS = $(SUBDIRS) wayland
+DIST_SUBDIRS	+= wayland
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = Makefile.in config.h.in
diff --git a/src/Makefile.in b/src/Makefile.in
index 7a0b8ba..aaaa8d2 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -104,7 +104,8 @@ host_triplet = @host@
 @USE_X11_TRUE at am__append_1 = i965_output_dri.c
 @USE_X11_TRUE at am__append_2 = i965_output_dri.h
 @USE_WAYLAND_TRUE at am__append_3 = i965_output_wayland.c
- at USE_WAYLAND_TRUE@am__append_4 = i965_output_wayland.h
+ at USE_WAYLAND_TRUE@am__append_4 = i965_output_wayland.h \
+ at USE_WAYLAND_TRUE@	$(protocol_source_h)
 @USE_WAYLAND_TRUE at am__append_5 = $(WAYLAND_CFLAGS)
 subdir = src
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
@@ -148,18 +149,20 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(i965_drv_video_ladir)"
 LTLIBRARIES = $(i965_drv_video_la_LTLIBRARIES)
 am__DEPENDENCIES_1 =
-am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
 i965_drv_video_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
 am__i965_drv_video_la_SOURCES_DIST = dso_utils.c gen6_mfc.c \
 	gen6_mfc_common.c gen6_mfd.c gen6_vme.c gen7_vme.c gen7_mfc.c \
 	gen7_mfd.c gen75_mfd.c gen75_mfc.c gen8_mfc.c gen8_mfd.c \
-	gen8_vme.c gen75_picture_process.c gen75_vme.c gen75_vpp_gpe.c \
-	gen75_vpp_vebox.c i965_avc_bsd.c i965_avc_hw_scoreboard.c \
-	i965_avc_ildb.c i965_decoder_utils.c i965_device_info.c \
-	i965_drv_video.c i965_encoder.c i965_encoder_utils.c \
-	i965_media.c i965_media_h264.c i965_media_mpeg2.c \
-	i965_gpe_utils.c i965_post_processing.c gen8_post_processing.c \
-	i965_render.c gen8_render.c intel_batchbuffer.c \
+	gen8_vme.c gen9_vme.c gen9_mfc.c gen9_mfd.c \
+	gen75_picture_process.c gen75_vme.c gen75_vpp_gpe.c \
+	gen75_vpp_vebox.c gen9_post_processing.c i965_avc_bsd.c \
+	i965_avc_hw_scoreboard.c i965_avc_ildb.c i965_decoder_utils.c \
+	i965_device_info.c i965_drv_video.c i965_encoder.c \
+	i965_encoder_utils.c i965_media.c i965_media_h264.c \
+	i965_media_mpeg2.c i965_gpe_utils.c i965_post_processing.c \
+	gen8_post_processing.c i965_render.c i965_vpp_avs.c \
+	gen8_render.c gen9_render.c intel_batchbuffer.c \
 	intel_batchbuffer_dump.c intel_driver.c intel_memman.c \
 	object_heap.c intel_media_common.c i965_output_dri.c \
 	i965_output_wayland.c
@@ -174,10 +177,13 @@ am__objects_3 = i965_drv_video_la-dso_utils.lo \
 	i965_drv_video_la-gen7_mfd.lo i965_drv_video_la-gen75_mfd.lo \
 	i965_drv_video_la-gen75_mfc.lo i965_drv_video_la-gen8_mfc.lo \
 	i965_drv_video_la-gen8_mfd.lo i965_drv_video_la-gen8_vme.lo \
+	i965_drv_video_la-gen9_vme.lo i965_drv_video_la-gen9_mfc.lo \
+	i965_drv_video_la-gen9_mfd.lo \
 	i965_drv_video_la-gen75_picture_process.lo \
 	i965_drv_video_la-gen75_vme.lo \
 	i965_drv_video_la-gen75_vpp_gpe.lo \
 	i965_drv_video_la-gen75_vpp_vebox.lo \
+	i965_drv_video_la-gen9_post_processing.lo \
 	i965_drv_video_la-i965_avc_bsd.lo \
 	i965_drv_video_la-i965_avc_hw_scoreboard.lo \
 	i965_drv_video_la-i965_avc_ildb.lo \
@@ -193,7 +199,9 @@ am__objects_3 = i965_drv_video_la-dso_utils.lo \
 	i965_drv_video_la-i965_post_processing.lo \
 	i965_drv_video_la-gen8_post_processing.lo \
 	i965_drv_video_la-i965_render.lo \
+	i965_drv_video_la-i965_vpp_avs.lo \
 	i965_drv_video_la-gen8_render.lo \
+	i965_drv_video_la-gen9_render.lo \
 	i965_drv_video_la-intel_batchbuffer.lo \
 	i965_drv_video_la-intel_batchbuffer_dump.lo \
 	i965_drv_video_la-intel_driver.lo \
@@ -262,16 +270,18 @@ am__can_run_installinfo = \
   esac
 am__noinst_HEADERS_DIST = dso_utils.h gen6_mfc.h gen6_mfd.h gen6_vme.h \
 	gen7_mfd.h gen75_picture_process.h gen75_vpp_gpe.h \
-	gen75_vpp_vebox.h i965_avc_bsd.h i965_avc_hw_scoreboard.h \
-	i965_avc_ildb.h i965_decoder.h i965_decoder_utils.h \
-	i965_defines.h i965_drv_video.h i965_encoder.h \
-	i965_encoder_utils.h i965_media.h i965_media_h264.h \
-	i965_media_mpeg2.h i965_mutext.h i965_gpe_utils.h \
-	i965_pciids.h i965_post_processing.h i965_render.h \
-	i965_structs.h intel_batchbuffer.h intel_batchbuffer_dump.h \
+	gen75_vpp_vebox.h gen8_post_processing.h gen9_mfd.h \
+	i965_avc_bsd.h i965_avc_hw_scoreboard.h i965_avc_ildb.h \
+	i965_decoder.h i965_decoder_utils.h i965_defines.h \
+	i965_drv_video.h i965_encoder.h i965_encoder_utils.h \
+	i965_media.h i965_media_h264.h i965_media_mpeg2.h \
+	i965_mutext.h i965_gpe_utils.h i965_pciids.h \
+	i965_post_processing.h i965_render.h i965_structs.h \
+	i965_vpp_avs.h intel_batchbuffer.h intel_batchbuffer_dump.h \
 	intel_compiler.h intel_driver.h intel_media.h intel_memman.h \
-	object_heap.h sysdeps.h va_backend_compat.h i965_fourcc.h \
-	i965_output_dri.h i965_output_wayland.h
+	intel_version.h object_heap.h sysdeps.h va_backend_compat.h \
+	i965_fourcc.h i965_output_dri.h i965_output_wayland.h \
+	wayland-drm-client-protocol.h
 HEADERS = $(noinst_HEADERS)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
@@ -359,6 +369,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -405,6 +416,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -413,8 +425,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -470,6 +480,9 @@ top_srcdir = @top_srcdir@
 wayland_protocoldir = @wayland_protocoldir@
 wayland_scanner = @wayland_scanner@
 SUBDIRS = shaders
+DIST_SUBDIRS = $(SUBDIRS) wayland
+EXTRA_DIST = intel_version.h.in $(PKG_VERSION_FILE)
+BUILT_SOURCES = intel_version.h
 AM_CPPFLAGS = \
 	-DPTHREADS		\
 	$(DRM_CFLAGS)		\
@@ -486,34 +499,35 @@ driver_ldflags = \
 driver_libs = \
 	-lpthread -lm -ldl	\
 	$(DRM_LIBS) -ldrm_intel	\
-	$(LIBVA_DEPS_LIBS)	\
 	$(NULL)
 
 source_c = dso_utils.c gen6_mfc.c gen6_mfc_common.c gen6_mfd.c \
 	gen6_vme.c gen7_vme.c gen7_mfc.c gen7_mfd.c gen75_mfd.c \
-	gen75_mfc.c gen8_mfc.c gen8_mfd.c gen8_vme.c \
-	gen75_picture_process.c gen75_vme.c gen75_vpp_gpe.c \
-	gen75_vpp_vebox.c i965_avc_bsd.c i965_avc_hw_scoreboard.c \
-	i965_avc_ildb.c i965_decoder_utils.c i965_device_info.c \
-	i965_drv_video.c i965_encoder.c i965_encoder_utils.c \
-	i965_media.c i965_media_h264.c i965_media_mpeg2.c \
-	i965_gpe_utils.c i965_post_processing.c gen8_post_processing.c \
-	i965_render.c gen8_render.c intel_batchbuffer.c \
+	gen75_mfc.c gen8_mfc.c gen8_mfd.c gen8_vme.c gen9_vme.c \
+	gen9_mfc.c gen9_mfd.c gen75_picture_process.c gen75_vme.c \
+	gen75_vpp_gpe.c gen75_vpp_vebox.c gen9_post_processing.c \
+	i965_avc_bsd.c i965_avc_hw_scoreboard.c i965_avc_ildb.c \
+	i965_decoder_utils.c i965_device_info.c i965_drv_video.c \
+	i965_encoder.c i965_encoder_utils.c i965_media.c \
+	i965_media_h264.c i965_media_mpeg2.c i965_gpe_utils.c \
+	i965_post_processing.c gen8_post_processing.c i965_render.c \
+	i965_vpp_avs.c gen8_render.c gen9_render.c intel_batchbuffer.c \
 	intel_batchbuffer_dump.c intel_driver.c intel_memman.c \
 	object_heap.c intel_media_common.c $(NULL) $(am__append_1) \
 	$(am__append_3)
 source_h = dso_utils.h gen6_mfc.h gen6_mfd.h gen6_vme.h gen7_mfd.h \
 	gen75_picture_process.h gen75_vpp_gpe.h gen75_vpp_vebox.h \
-	i965_avc_bsd.h i965_avc_hw_scoreboard.h i965_avc_ildb.h \
-	i965_decoder.h i965_decoder_utils.h i965_defines.h \
-	i965_drv_video.h i965_encoder.h i965_encoder_utils.h \
-	i965_media.h i965_media_h264.h i965_media_mpeg2.h \
-	i965_mutext.h i965_gpe_utils.h i965_pciids.h \
-	i965_post_processing.h i965_render.h i965_structs.h \
+	gen8_post_processing.h gen9_mfd.h i965_avc_bsd.h \
+	i965_avc_hw_scoreboard.h i965_avc_ildb.h i965_decoder.h \
+	i965_decoder_utils.h i965_defines.h i965_drv_video.h \
+	i965_encoder.h i965_encoder_utils.h i965_media.h \
+	i965_media_h264.h i965_media_mpeg2.h i965_mutext.h \
+	i965_gpe_utils.h i965_pciids.h i965_post_processing.h \
+	i965_render.h i965_structs.h i965_vpp_avs.h \
 	intel_batchbuffer.h intel_batchbuffer_dump.h intel_compiler.h \
-	intel_driver.h intel_media.h intel_memman.h object_heap.h \
-	sysdeps.h va_backend_compat.h i965_fourcc.h $(NULL) \
-	$(am__append_2) $(am__append_4)
+	intel_driver.h intel_media.h intel_memman.h intel_version.h \
+	object_heap.h sysdeps.h va_backend_compat.h i965_fourcc.h \
+	$(NULL) $(am__append_2) $(am__append_4)
 i965_drv_video_la_LTLIBRARIES = i965_drv_video.la
 i965_drv_video_ladir = $(LIBVA_DRIVERS_PATH)
 i965_drv_video_la_CFLAGS = $(driver_cflags)
@@ -522,13 +536,18 @@ i965_drv_video_la_LIBADD = $(driver_libs)
 i965_drv_video_la_SOURCES = $(source_c)
 noinst_HEADERS = $(source_h)
 
+# git version
+VERSION_FILE = .VERSION
+OLD_VERSION_FILE = $(VERSION_FILE).old
+NEW_VERSION_FILE = $(VERSION_FILE).new
+PKG_VERSION_FILE = $(VERSION_FILE).pkg
+
 # Wayland protocol
 protocol_source_h = wayland-drm-client-protocol.h
-DIST_SUBDIRS = $(SUBDIRS) wayland
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = Makefile.in config.h.in
-all: config.h
+all: $(BUILT_SOURCES) config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
@@ -642,6 +661,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen8_post_processing.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen8_render.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen8_vme.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen9_mfc.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen9_mfd.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen9_post_processing.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen9_render.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-gen9_vme.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_avc_bsd.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_avc_hw_scoreboard.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_avc_ildb.Plo at am__quote@
@@ -658,6 +682,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_output_wayland.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_post_processing.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_render.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-i965_vpp_avs.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-intel_batchbuffer.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-intel_batchbuffer_dump.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/i965_drv_video_la-intel_driver.Plo at am__quote@
@@ -777,6 +802,27 @@ i965_drv_video_la-gen8_vme.lo: gen8_vme.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen8_vme.lo `test -f 'gen8_vme.c' || echo '$(srcdir)/'`gen8_vme.c
 
+i965_drv_video_la-gen9_vme.lo: gen9_vme.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen9_vme.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen9_vme.Tpo -c -o i965_drv_video_la-gen9_vme.lo `test -f 'gen9_vme.c' || echo '$(srcdir)/'`gen9_vme.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen9_vme.Tpo $(DEPDIR)/i965_drv_video_la-gen9_vme.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gen9_vme.c' object='i965_drv_video_la-gen9_vme.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen9_vme.lo `test -f 'gen9_vme.c' || echo '$(srcdir)/'`gen9_vme.c
+
+i965_drv_video_la-gen9_mfc.lo: gen9_mfc.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen9_mfc.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen9_mfc.Tpo -c -o i965_drv_video_la-gen9_mfc.lo `test -f 'gen9_mfc.c' || echo '$(srcdir)/'`gen9_mfc.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen9_mfc.Tpo $(DEPDIR)/i965_drv_video_la-gen9_mfc.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gen9_mfc.c' object='i965_drv_video_la-gen9_mfc.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen9_mfc.lo `test -f 'gen9_mfc.c' || echo '$(srcdir)/'`gen9_mfc.c
+
+i965_drv_video_la-gen9_mfd.lo: gen9_mfd.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen9_mfd.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen9_mfd.Tpo -c -o i965_drv_video_la-gen9_mfd.lo `test -f 'gen9_mfd.c' || echo '$(srcdir)/'`gen9_mfd.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen9_mfd.Tpo $(DEPDIR)/i965_drv_video_la-gen9_mfd.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gen9_mfd.c' object='i965_drv_video_la-gen9_mfd.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen9_mfd.lo `test -f 'gen9_mfd.c' || echo '$(srcdir)/'`gen9_mfd.c
+
 i965_drv_video_la-gen75_picture_process.lo: gen75_picture_process.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen75_picture_process.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen75_picture_process.Tpo -c -o i965_drv_video_la-gen75_picture_process.lo `test -f 'gen75_picture_process.c' || echo '$(srcdir)/'`gen75_picture_process.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen75_picture_process.Tpo $(DEPDIR)/i965_drv_video_la-gen75_picture_process.Plo
@@ -805,6 +851,13 @@ i965_drv_video_la-gen75_vpp_vebox.lo: gen75_vpp_vebox.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen75_vpp_vebox.lo `test -f 'gen75_vpp_vebox.c' || echo '$(srcdir)/'`gen75_vpp_vebox.c
 
+i965_drv_video_la-gen9_post_processing.lo: gen9_post_processing.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen9_post_processing.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen9_post_processing.Tpo -c -o i965_drv_video_la-gen9_post_processing.lo `test -f 'gen9_post_processing.c' || echo '$(srcdir)/'`gen9_post_processing.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen9_post_processing.Tpo $(DEPDIR)/i965_drv_video_la-gen9_post_processing.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gen9_post_processing.c' object='i965_drv_video_la-gen9_post_processing.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen9_post_processing.lo `test -f 'gen9_post_processing.c' || echo '$(srcdir)/'`gen9_post_processing.c
+
 i965_drv_video_la-i965_avc_bsd.lo: i965_avc_bsd.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-i965_avc_bsd.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-i965_avc_bsd.Tpo -c -o i965_drv_video_la-i965_avc_bsd.lo `test -f 'i965_avc_bsd.c' || echo '$(srcdir)/'`i965_avc_bsd.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-i965_avc_bsd.Tpo $(DEPDIR)/i965_drv_video_la-i965_avc_bsd.Plo
@@ -910,6 +963,13 @@ i965_drv_video_la-i965_render.lo: i965_render.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-i965_render.lo `test -f 'i965_render.c' || echo '$(srcdir)/'`i965_render.c
 
+i965_drv_video_la-i965_vpp_avs.lo: i965_vpp_avs.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-i965_vpp_avs.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-i965_vpp_avs.Tpo -c -o i965_drv_video_la-i965_vpp_avs.lo `test -f 'i965_vpp_avs.c' || echo '$(srcdir)/'`i965_vpp_avs.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-i965_vpp_avs.Tpo $(DEPDIR)/i965_drv_video_la-i965_vpp_avs.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='i965_vpp_avs.c' object='i965_drv_video_la-i965_vpp_avs.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-i965_vpp_avs.lo `test -f 'i965_vpp_avs.c' || echo '$(srcdir)/'`i965_vpp_avs.c
+
 i965_drv_video_la-gen8_render.lo: gen8_render.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen8_render.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen8_render.Tpo -c -o i965_drv_video_la-gen8_render.lo `test -f 'gen8_render.c' || echo '$(srcdir)/'`gen8_render.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen8_render.Tpo $(DEPDIR)/i965_drv_video_la-gen8_render.Plo
@@ -917,6 +977,13 @@ i965_drv_video_la-gen8_render.lo: gen8_render.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen8_render.lo `test -f 'gen8_render.c' || echo '$(srcdir)/'`gen8_render.c
 
+i965_drv_video_la-gen9_render.lo: gen9_render.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-gen9_render.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-gen9_render.Tpo -c -o i965_drv_video_la-gen9_render.lo `test -f 'gen9_render.c' || echo '$(srcdir)/'`gen9_render.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-gen9_render.Tpo $(DEPDIR)/i965_drv_video_la-gen9_render.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gen9_render.c' object='i965_drv_video_la-gen9_render.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -c -o i965_drv_video_la-gen9_render.lo `test -f 'gen9_render.c' || echo '$(srcdir)/'`gen9_render.c
+
 i965_drv_video_la-intel_batchbuffer.lo: intel_batchbuffer.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(i965_drv_video_la_CFLAGS) $(CFLAGS) -MT i965_drv_video_la-intel_batchbuffer.lo -MD -MP -MF $(DEPDIR)/i965_drv_video_la-intel_batchbuffer.Tpo -c -o i965_drv_video_la-intel_batchbuffer.lo `test -f 'intel_batchbuffer.c' || echo '$(srcdir)/'`intel_batchbuffer.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/i965_drv_video_la-intel_batchbuffer.Tpo $(DEPDIR)/i965_drv_video_la-intel_batchbuffer.Plo
@@ -1134,14 +1201,16 @@ distdir: $(DISTFILES)
 	  fi; \
 	done
 check-am: all-am
-check: check-recursive
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-recursive
 all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(i965_drv_video_ladir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
-install: install-recursive
+install: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-recursive
 install-exec: install-exec-recursive
 install-data: install-data-recursive
 uninstall: uninstall-recursive
@@ -1171,6 +1240,7 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
 clean: clean-recursive
 
@@ -1243,7 +1313,8 @@ ps-am:
 
 uninstall-am: uninstall-i965_drv_video_laLTLIBRARIES
 
-.MAKE: $(am__recursive_targets) all install-am install-strip
+.MAKE: $(am__recursive_targets) all check install install-am \
+	install-strip
 
 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
 	check-am clean clean-generic \
@@ -1262,6 +1333,26 @@ uninstall-am: uninstall-i965_drv_video_laLTLIBRARIES
 	tags tags-am uninstall uninstall-am \
 	uninstall-i965_drv_video_laLTLIBRARIES
 
+
+intel_version.h: gen-version
+	$(AM_V_GEN)							 \
+	OV=`[ -f $(OLD_VERSION_FILE) ] && cat $(OLD_VERSION_FILE) || :`; \
+	NV=`cat $(NEW_VERSION_FILE)`;					 \
+	if [ "$$OV" != "$$NV" -o ! -f intel_version.h ]; then		 \
+		cp -f $(NEW_VERSION_FILE) $(OLD_VERSION_FILE);		 \
+		$(SED) -e "s|\@INTEL_DRIVER_GIT_VERSION\@|$${NV}|"	 \
+			$(srcdir)/intel_version.h.in > intel_version.h;	 \
+	fi
+
+gen-version:
+	@echo $(VERSION) > $(NEW_VERSION_FILE)
+ at HAVE_GIT_TRUE@	@[ -d $(top_srcdir)/.git ] && \
+ at HAVE_GIT_TRUE@	(cd $(top_srcdir) && $(GIT) describe --tags) > $(NEW_VERSION_FILE) || :
+	@[ -f $(srcdir)/$(PKG_VERSION_FILE) ] && \
+	cp -f $(srcdir)/$(PKG_VERSION_FILE) $(NEW_VERSION_FILE) || :
+
+$(PKG_VERSION_FILE): $(NEW_VERSION_FILE)
+	@cp -f $< $@
 i965_output_wayland.c: $(protocol_source_h)
 @wayland_scanner_rules@
 
diff --git a/src/gen6_mfc.h b/src/gen6_mfc.h
index 67c62a4..c079863 100644
--- a/src/gen6_mfc.h
+++ b/src/gen6_mfc.h
@@ -190,6 +190,9 @@ struct gen6_mfc_context
         int i_dpb_output_delay_length;
     }vui_hrd;
 
+    //"buffered_QMatrix" will be used to buffer the QMatrix if the app sends one.
+    // Or else, we will load a default QMatrix from the driver for JPEG encode.
+    VAQMatrixBufferJPEG buffered_qmatrix;
     struct i965_gpe_context gpe_context;
     struct i965_buffer_surface mfc_batchbuffer_surface;
     struct intel_batchbuffer *aux_batchbuffer;
@@ -278,4 +281,7 @@ intel_avc_slice_insert_packed_data(VADriverContextP ctx,
                              int slice_index,
                              struct intel_batchbuffer *slice_batch);
 
+extern
+Bool gen9_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
+
 #endif	/* _GEN6_MFC_BCS_H_ */
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 77c46dd..218fb8b 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -603,7 +603,7 @@ void intel_mfc_avc_pipeline_header_programing(VADriverContextP ctx,
                                    (unsigned int *)sei_data,
                                    ALIGN(length_in_bits, 32) >> 5,
                                    length_in_bits & 0x1f,
-                                   4,   
+                                   5,
                                    0,   
                                    0,   
                                    1,
diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c
index b6d19e8..ea13e4f 100755
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -61,7 +61,7 @@ gen6_mfd_init_avc_surface(VADriverContextP ctx,
 
     if (!gen6_avc_surface) {
         gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1);
-        gen6_avc_surface->frame_store_id = -1;
+        gen6_avc_surface->base.frame_store_id = -1;
         assert((obj_surface->size & 0x3f) == 0);
         obj_surface->private_data = gen6_avc_surface;
     }
diff --git a/src/gen6_vme.h b/src/gen6_vme.h
index d461982..bc62c14 100644
--- a/src/gen6_vme.h
+++ b/src/gen6_vme.h
@@ -175,4 +175,6 @@ intel_avc_vme_reference_state(VADriverContextP ctx,
                                   struct intel_encoder_context *encoder_context));
 
 extern Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
+
+extern Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
 #endif /* _GEN6_VME_H_ */
diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c
index 299f2b5..1847d2c 100644
--- a/src/gen75_mfd.c
+++ b/src/gen75_mfd.c
@@ -67,7 +67,7 @@ gen75_mfd_init_avc_surface(VADriverContextP ctx,
 
     if (!gen7_avc_surface) {
         gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1);
-        gen7_avc_surface->frame_store_id = -1;
+        gen7_avc_surface->base.frame_store_id = -1;
         assert((obj_surface->size & 0x3f) == 0);
         obj_surface->private_data = gen7_avc_surface;
     }
diff --git a/src/gen75_picture_process.c b/src/gen75_picture_process.c
index 6978d4b..d64ef05 100644
--- a/src/gen75_picture_process.c
+++ b/src/gen75_picture_process.c
@@ -84,7 +84,9 @@ gen75_vpp_vebox(VADriverContextP ctx,
          va_status = gen75_vebox_process_picture(ctx, proc_ctx->vpp_vebox_ctx);
      else if (IS_GEN8(i965->intel.device_info))
          va_status = gen8_vebox_process_picture(ctx, proc_ctx->vpp_vebox_ctx);
- 
+     else if (IS_GEN9(i965->intel.device_info))
+         va_status = gen9_vebox_process_picture(ctx, proc_ctx->vpp_vebox_ctx);
+
      return va_status;
 } 
 
@@ -156,7 +158,7 @@ gen75_proc_picture(VADriverContextP ctx,
     }
 
     if (!obj_dst_surf->bo) {
-        unsigned int is_tiled = 0;
+        unsigned int is_tiled = 1;
         unsigned int fourcc = VA_FOURCC_NV12;
         int sampling = SUBSAMPLE_YUV420;
         i965_check_alloc_surface_bo(ctx, obj_dst_surf, is_tiled, fourcc, sampling);
diff --git a/src/gen75_vpp_gpe.c b/src/gen75_vpp_gpe.c
index 042e4e6..52a0e2f 100644
--- a/src/gen75_vpp_gpe.c
+++ b/src/gen75_vpp_gpe.c
@@ -301,14 +301,12 @@ gen75_gpe_process_init(VADriverContextP ctx,
                       "vpp batch buffer",
                        batch_buf_size, 0x1000);
     vpp_gpe_ctx->vpp_batchbuffer.bo = bo;
-    dri_bo_reference(vpp_gpe_ctx->vpp_batchbuffer.bo);
 
     dri_bo_unreference(vpp_gpe_ctx->vpp_kernel_return.bo);
     bo = dri_bo_alloc(i965->intel.bufmgr,
                       "vpp kernel return buffer",
                        kernel_return_size, 0x1000);
     vpp_gpe_ctx->vpp_kernel_return.bo = bo;
-    dri_bo_reference(vpp_gpe_ctx->vpp_kernel_return.bo); 
 
     vpp_gpe_ctx->gpe_context_init(ctx, &vpp_gpe_ctx->gpe_ctx);
 
@@ -545,14 +543,12 @@ gen8_gpe_process_init(VADriverContextP ctx,
                       "vpp batch buffer",
                        batch_buf_size, 0x1000);
     vpp_gpe_ctx->vpp_batchbuffer.bo = bo;
-    dri_bo_reference(vpp_gpe_ctx->vpp_batchbuffer.bo);
 
     dri_bo_unreference(vpp_gpe_ctx->vpp_kernel_return.bo);
     bo = dri_bo_alloc(i965->intel.bufmgr,
                       "vpp kernel return buffer",
                        kernel_return_size, 0x1000);
     vpp_gpe_ctx->vpp_kernel_return.bo = bo;
-    dri_bo_reference(vpp_gpe_ctx->vpp_kernel_return.bo);
 
     vpp_gpe_ctx->gpe_context_init(ctx, &vpp_gpe_ctx->gpe_ctx);
 
@@ -611,7 +607,8 @@ vpp_gpe_process(VADriverContextP ctx,
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     if (IS_HASWELL(i965->intel.device_info))
        return gen75_gpe_process(ctx, vpp_gpe_ctx);
-    else if (IS_GEN8(i965->intel.device_info))
+    else if (IS_GEN8(i965->intel.device_info) ||
+             IS_GEN9(i965->intel.device_info))
        return gen8_gpe_process(ctx, vpp_gpe_ctx);
 
      return VA_STATUS_ERROR_UNIMPLEMENTED;
@@ -651,7 +648,8 @@ vpp_gpe_process_sharpening(VADriverContextP ctx,
          struct i965_kernel * vpp_kernels;
          if (IS_HASWELL(i965->intel.device_info))
              vpp_kernels = gen75_vpp_sharpening_kernels;
-         else if (IS_GEN8(i965->intel.device_info))
+         else if (IS_GEN8(i965->intel.device_info) ||
+                  IS_GEN9(i965->intel.device_info)) // TODO: build the sharpening kernel for GEN9
              vpp_kernels = gen8_vpp_sharpening_kernels;
 
          vpp_gpe_ctx->gpe_load_kernels(ctx,
@@ -862,7 +860,8 @@ vpp_gpe_context_destroy(VADriverContextP ctx,
         vpp_gpe_ctx->surface_tmp_object = NULL;
     }   
 
-    free(vpp_gpe_ctx->batch);
+    if (vpp_gpe_ctx->batch)
+        intel_batchbuffer_free(vpp_gpe_ctx->batch);
 
     free(vpp_gpe_ctx);
 }
@@ -875,7 +874,8 @@ vpp_gpe_context_init(VADriverContextP ctx)
     struct i965_gpe_context *gpe_ctx = &(vpp_gpe_ctx->gpe_ctx);
 
     assert(IS_HASWELL(i965->intel.device_info) ||
-           IS_GEN8(i965->intel.device_info));
+           IS_GEN8(i965->intel.device_info) ||
+           IS_GEN9(i965->intel.device_info));
 
     vpp_gpe_ctx->surface_tmp = VA_INVALID_ID;
     vpp_gpe_ctx->surface_tmp_object = NULL;
@@ -899,7 +899,8 @@ vpp_gpe_context_init(VADriverContextP ctx)
         gpe_ctx->idrt.max_entries = MAX_INTERFACE_DESC_GEN6;
         gpe_ctx->idrt.entry_size = sizeof(struct gen6_interface_descriptor_data);
 
-    } else if (IS_GEN8(i965->intel.device_info)) {
+    } else if (IS_GEN8(i965->intel.device_info) ||
+               IS_GEN9(i965->intel.device_info)) {
         vpp_gpe_ctx->gpe_context_init     = gen8_gpe_context_init;
         vpp_gpe_ctx->gpe_context_destroy  = gen8_gpe_context_destroy;
         vpp_gpe_ctx->gpe_load_kernels     = gen8_gpe_load_kernels;
diff --git a/src/gen75_vpp_vebox.c b/src/gen75_vpp_vebox.c
index 1113c90..2ae9813 100644
--- a/src/gen75_vpp_vebox.c
+++ b/src/gen75_vpp_vebox.c
@@ -53,10 +53,9 @@ i965_DeriveImage(VADriverContextP ctx, VABufferID surface, VAImage *out_image);
 extern VAStatus
 i965_DestroyImage(VADriverContextP ctx, VAImageID image);
 
-
-VAStatus vpp_surface_convert(VADriverContextP ctx,
-                             struct object_surface *src_obj_surf,
-                             struct object_surface *dst_obj_surf)
+VAStatus
+vpp_surface_convert(VADriverContextP ctx, struct object_surface *src_obj_surf,
+    struct object_surface *dst_obj_surf)
 {
     VAStatus va_status = VA_STATUS_SUCCESS;
 
@@ -86,12 +85,11 @@ VAStatus vpp_surface_convert(VADriverContextP ctx,
     return va_status;
 }
 
-VAStatus vpp_surface_scaling(VADriverContextP ctx,
-                             struct object_surface *dst_obj_surf,
-                             struct object_surface *src_obj_surf)
+static VAStatus
+vpp_surface_scaling(VADriverContextP ctx, struct object_surface *src_obj_surf,
+    struct object_surface *dst_obj_surf, uint32_t flags)
 {
     VAStatus va_status = VA_STATUS_SUCCESS;
-    int flags = I965_PP_FLAG_AVS;
 
     assert(src_obj_surf->fourcc == VA_FOURCC_NV12);
     assert(dst_obj_surf->fourcc == VA_FOURCC_NV12);
@@ -121,18 +119,24 @@ void hsw_veb_dndi_table(VADriverContextP ctx, struct intel_vebox_context *proc_c
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     unsigned int* p_table ;
-    int progressive_dn = 1;
-    int dndi_top_first = 0;
-    int motion_compensated_enable = 0;
+    unsigned int progressive_dn = 1;
+    unsigned int dndi_top_first = 0;
+    unsigned int is_mcdi_enabled = 0;
 
-    if (proc_ctx->filters_mask & VPP_DNDI_DI) {
-        VAProcFilterParameterBufferDeinterlacing *di_param =
-            (VAProcFilterParameterBufferDeinterlacing *)proc_ctx->filter_di;
-        assert(di_param);
+    if (proc_ctx->is_di_enabled) {
+        const VAProcFilterParameterBufferDeinterlacing * const deint_params =
+            proc_ctx->filter_di;
 
         progressive_dn = 0;
-        dndi_top_first = !(di_param->flags & VA_DEINTERLACING_BOTTOM_FIELD);
-        motion_compensated_enable = (di_param->algorithm == VAProcDeinterlacingMotionCompensated);
+
+        /* If we are in "First Frame" mode, i.e. past frames are not
+           available for motion measure, then don't use the TFF flag */
+        dndi_top_first = !(deint_params->flags & (proc_ctx->is_first_frame ?
+                VA_DEINTERLACING_BOTTOM_FIELD :
+                VA_DEINTERLACING_BOTTOM_FIELD_FIRST));
+
+        is_mcdi_enabled =
+            (deint_params->algorithm == VAProcDeinterlacingMotionCompensated);
     }
 
     /*
@@ -193,7 +197,7 @@ void hsw_veb_dndi_table(VADriverContextP ctx, struct intel_vebox_context *proc_c
                     100<< 16  |  // FMD #2 vertical difference th
                     0  << 14  |  // CAT th1
                     2  << 8   |  // FMD tear threshold
-                    motion_compensated_enable  << 7   |  // MCDI Enable, use motion compensated deinterlace algorithm
+                    is_mcdi_enabled  << 7  |  // MCDI Enable, use motion compensated deinterlace algorithm
                     progressive_dn  << 6   |  // progressive DN
                     0  << 4   |  // reserved
                     dndi_top_first  << 3   |  // DN/DI Top First
@@ -216,7 +220,8 @@ void hsw_veb_dndi_table(VADriverContextP ctx, struct intel_vebox_context *proc_c
                     13 << 6   |  // chr temp diff th
                     7 );         // chr temp diff low
 
-    if (IS_GEN8(i965->intel.device_info))
+    if (IS_GEN8(i965->intel.device_info) ||
+        IS_GEN9(i965->intel.device_info))
         *p_table ++ = 0;         // parameters for hot pixel, 
 }
 
@@ -626,7 +631,7 @@ void hsw_veb_iecp_aoi_table(VADriverContextP ctx, struct intel_vebox_context *pr
 
 void hsw_veb_state_table_setup(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
 {
-    if(proc_ctx->filters_mask & 0x000000ff) {
+    if(proc_ctx->filters_mask & VPP_DNDI_MASK) {
         dri_bo *dndi_bo = proc_ctx->dndi_state_table.bo;
         dri_bo_map(dndi_bo, 1);
         proc_ctx->dndi_state_table.ptr = dndi_bo->virtual;
@@ -636,7 +641,7 @@ void hsw_veb_state_table_setup(VADriverContextP ctx, struct intel_vebox_context
         dri_bo_unmap(dndi_bo);
     }
 
-    if(proc_ctx->filters_mask & 0x0000ff00) {
+    if(proc_ctx->filters_mask & VPP_IECP_MASK) {
         dri_bo *iecp_bo = proc_ctx->iecp_state_table.bo;
         dri_bo_map(iecp_bo, 1);
         proc_ctx->iecp_state_table.ptr = iecp_bo->virtual;
@@ -655,33 +660,6 @@ void hsw_veb_state_table_setup(VADriverContextP ctx, struct intel_vebox_context
 void hsw_veb_state_command(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
 {
     struct intel_batchbuffer *batch = proc_ctx->batch;
-    unsigned int is_dn_enabled   = (proc_ctx->filters_mask & 0x01)? 1: 0;
-    unsigned int is_di_enabled   = (proc_ctx->filters_mask & 0x02)? 1: 0;
-    unsigned int is_iecp_enabled = (proc_ctx->filters_mask & 0xff00)?1:0;
-    unsigned int is_first_frame  = !!((proc_ctx->frame_order == -1) &&
-                                      (is_di_enabled ||
-                                       is_dn_enabled));
-    unsigned int di_output_frames_flag = 2; /* Output Current Frame Only */
-
-    if(proc_ctx->fourcc_input != proc_ctx->fourcc_output ||
-       (is_dn_enabled == 0 && is_di_enabled == 0)){
-       is_iecp_enabled = 1;
-    }
-
-    if (is_di_enabled) {
-        VAProcFilterParameterBufferDeinterlacing *di_param =
-            (VAProcFilterParameterBufferDeinterlacing *)proc_ctx->filter_di;
-
-        assert(di_param);
-        
-        if (di_param->algorithm == VAProcDeinterlacingBob)
-            is_first_frame = 1;
-
-        if ((di_param->algorithm == VAProcDeinterlacingMotionAdaptive ||
-            di_param->algorithm == VAProcDeinterlacingMotionCompensated) &&
-            proc_ctx->frame_order != -1)
-            di_output_frames_flag = 0; /* Output both Current Frame and Previous Frame */
-    }
 
     BEGIN_VEB_BATCH(batch, 6);
     OUT_VEB_BATCH(batch, VEB_STATE | (6 - 2));
@@ -689,13 +667,13 @@ void hsw_veb_state_command(VADriverContextP ctx, struct intel_vebox_context *pro
                   0 << 26 |       // state surface control bits
                   0 << 11 |       // reserved.
                   0 << 10 |       // pipe sync disable
-                  di_output_frames_flag << 8  |       // DI output frame
+                  proc_ctx->current_output_type << 8  | // DI output frame
                   1 << 7  |       // 444->422 downsample method
                   1 << 6  |       // 422->420 downsample method
-                  is_first_frame  << 5  |   // DN/DI first frame
-                  is_di_enabled   << 4  |             // DI enable
-                  is_dn_enabled   << 3  |             // DN enable
-                  is_iecp_enabled << 2  |             // global IECP enabled
+                  proc_ctx->is_first_frame  << 5  |   // DN/DI first frame
+                  proc_ctx->is_di_enabled   << 4  |   // DI enable
+                  proc_ctx->is_dn_enabled   << 3  |   // DN enable
+                  proc_ctx->is_iecp_enabled << 2  |   // global IECP enabled
                   0 << 1  |       // ColorGamutCompressionEnable
                   0 ) ;           // ColorGamutExpansionEnable.
 
@@ -805,8 +783,7 @@ void hsw_veb_dndi_iecp_command(VADriverContextP ctx, struct intel_vebox_context
 {
     struct intel_batchbuffer *batch = proc_ctx->batch;
     unsigned char frame_ctrl_bits = 0;
-    unsigned int startingX = 0;
-    unsigned int endingX = (proc_ctx->width_input + 63 ) / 64 * 64;
+    const unsigned int width64 = ALIGN(proc_ctx->width_input, 64);
 
     /* s1:update the previous and current input */
 /*    tempFrame = proc_ctx->frame_store[FRAME_IN_PREVIOUS];
@@ -829,9 +806,7 @@ void hsw_veb_dndi_iecp_command(VADriverContextP ctx, struct intel_vebox_context
     /*s3:set reloc buffer address */
     BEGIN_VEB_BATCH(batch, 10);
     OUT_VEB_BATCH(batch, VEB_DNDI_IECP_STATE | (10 - 2));
-    OUT_VEB_BATCH(batch,
-                  startingX << 16 |
-                  (endingX-1));
+    OUT_VEB_BATCH(batch, (width64 - 1));
     OUT_RELOC(batch,
               proc_ctx->frame_store[FRAME_IN_CURRENT].obj_surface->bo,
               I915_GEM_DOMAIN_RENDER, 0, frame_ctrl_bits);
@@ -860,259 +835,259 @@ void hsw_veb_dndi_iecp_command(VADriverContextP ctx, struct intel_vebox_context
     ADVANCE_VEB_BATCH(batch);
 }
 
-void hsw_veb_resource_prepare(VADriverContextP ctx,
-                              struct intel_vebox_context *proc_ctx)
+static void
+frame_store_reset(VEBFrameStore *fs)
 {
-    VAStatus va_status;
-    dri_bo *bo;
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    fs->obj_surface = NULL;
+    fs->surface_id = VA_INVALID_ID;
+    fs->is_internal_surface = 0;
+    fs->is_scratch_surface = 0;
+}
+
+static void
+frame_store_clear(VEBFrameStore *fs, VADriverContextP ctx)
+{
+    if (fs->obj_surface && fs->is_scratch_surface) {
+        VASurfaceID surface_id = fs->obj_surface->base.id;
+        i965_DestroySurfaces(ctx, &surface_id, 1);
+    }
+    frame_store_reset(fs);
+}
+
+static VAStatus
+gen75_vebox_ensure_surfaces_storage(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
+{
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
+    struct object_surface *input_obj_surface, *output_obj_surface;
     unsigned int input_fourcc, output_fourcc;
     unsigned int input_sampling, output_sampling;
     unsigned int input_tiling, output_tiling;
     unsigned int i, swizzle;
-    struct object_surface *obj_surf_out = NULL, *obj_surf_in = NULL;
-
-    if (proc_ctx->surface_input_vebox_object != NULL) {
-        obj_surf_in = proc_ctx->surface_input_vebox_object;
-    } else {
-        obj_surf_in = proc_ctx->surface_input_object;
-    } 
-
-    if (proc_ctx->surface_output_vebox_object != NULL) {
-        obj_surf_out = proc_ctx->surface_output_vebox_object;
-    } else {
-        obj_surf_out = proc_ctx->surface_output_object;
-    } 
-
-    if(obj_surf_in->bo == NULL){
-          input_fourcc = VA_FOURCC_NV12;
-          input_sampling = SUBSAMPLE_YUV420;
-          input_tiling = 0;
-          i965_check_alloc_surface_bo(ctx, obj_surf_in, input_tiling, input_fourcc, input_sampling);
-    } else {
-        input_fourcc = obj_surf_in->fourcc;
-        input_sampling = obj_surf_in->subsampling;
-        dri_bo_get_tiling(obj_surf_in->bo, &input_tiling, &swizzle);
+    drm_intel_bo *bo;
+    VAStatus status;
+
+    /* Determine input surface info. Use native VEBOX format whenever
+       possible. i.e. when the input surface format is not supported
+       by the VEBOX engine, then allocate a temporary surface (live
+       during the whole VPP pipeline lifetime)
+
+       XXX: derive an actual surface format compatible with the input
+       surface chroma format */
+    input_obj_surface = proc_ctx->surface_input_vebox_object ?
+        proc_ctx->surface_input_vebox_object : proc_ctx->surface_input_object;
+    if (input_obj_surface->bo) {
+        input_fourcc = input_obj_surface->fourcc;
+        input_sampling = input_obj_surface->subsampling;
+        dri_bo_get_tiling(input_obj_surface->bo, &input_tiling, &swizzle);
         input_tiling = !!input_tiling;
     }
+    else {
+        input_fourcc = VA_FOURCC_NV12;
+        input_sampling = SUBSAMPLE_YUV420;
+        input_tiling = 1;
+        status = i965_check_alloc_surface_bo(ctx, input_obj_surface,
+            input_tiling, input_fourcc, input_sampling);
+        if (status != VA_STATUS_SUCCESS)
+            return status;
+    }
 
-    if(obj_surf_out->bo == NULL){
-          output_fourcc = VA_FOURCC_NV12;
-          output_sampling = SUBSAMPLE_YUV420;
-          output_tiling = 0;
-          i965_check_alloc_surface_bo(ctx, obj_surf_out, output_tiling, output_fourcc, output_sampling);
-    }else {
-        output_fourcc   = obj_surf_out->fourcc;
-        output_sampling = obj_surf_out->subsampling;
-        dri_bo_get_tiling(obj_surf_out->bo, &output_tiling, &swizzle);
+    /* Determine output surface info.
+
+       XXX: derive an actual surface format compatible with the input
+       surface chroma format */
+    output_obj_surface = proc_ctx->surface_output_vebox_object ?
+        proc_ctx->surface_output_vebox_object : proc_ctx->surface_output_object;
+    if (output_obj_surface->bo) {
+        output_fourcc   = output_obj_surface->fourcc;
+        output_sampling = output_obj_surface->subsampling;
+        dri_bo_get_tiling(output_obj_surface->bo, &output_tiling, &swizzle);
         output_tiling = !!output_tiling;
     }
+    else {
+        output_fourcc = VA_FOURCC_NV12;
+        output_sampling = SUBSAMPLE_YUV420;
+        output_tiling = 1;
+        status = i965_check_alloc_surface_bo(ctx, output_obj_surface,
+            output_tiling, output_fourcc, output_sampling);
+        if (status != VA_STATUS_SUCCESS)
+            return status;
+    }
 
-    /* vebox pipelien input surface format info */
+    /* Update VEBOX pipeline formats */
     proc_ctx->fourcc_input = input_fourcc;
     proc_ctx->fourcc_output = output_fourcc;
+    if (input_fourcc != output_fourcc)
+        proc_ctx->is_iecp_enabled = 1; // IECP needed for format conversion
    
-    /* create pipeline surfaces */
-    for(i = 0; i < FRAME_STORE_SUM; i ++) {
-        if(proc_ctx->frame_store[i].obj_surface){
-            continue; //refer external surface for vebox pipeline
-        }
-    
+    /* Create pipeline surfaces */
+    for (i = 0; i < ARRAY_ELEMS(proc_ctx->frame_store); i ++) {
+        struct object_surface *obj_surface;
         VASurfaceID new_surface;
-        struct object_surface *obj_surf = NULL;
-
-        va_status =   i965_CreateSurfaces(ctx,
-                                          proc_ctx ->width_input,
-                                          proc_ctx ->height_input,
-                                          VA_RT_FORMAT_YUV420,
-                                          1,
-                                          &new_surface);
-        assert(va_status == VA_STATUS_SUCCESS);
-
-        obj_surf = SURFACE(new_surface);
-        assert(obj_surf);
-
-        if( i <= FRAME_IN_PREVIOUS || i == FRAME_OUT_CURRENT_DN) {
-            i965_check_alloc_surface_bo(ctx, obj_surf, input_tiling, input_fourcc, input_sampling);
-        } else if( i == FRAME_IN_STMM || i == FRAME_OUT_STMM){
-            i965_check_alloc_surface_bo(ctx, obj_surf, 1, input_fourcc, input_sampling);
-        } else if( i >= FRAME_OUT_CURRENT){
-            i965_check_alloc_surface_bo(ctx, obj_surf, output_tiling, output_fourcc, output_sampling);
+
+        if (proc_ctx->frame_store[i].obj_surface)
+            continue; // user allocated surface, not VEBOX internal
+
+        status = i965_CreateSurfaces(ctx, proc_ctx->width_input,
+            proc_ctx->height_input, VA_RT_FORMAT_YUV420, 1, &new_surface);
+        if (status != VA_STATUS_SUCCESS)
+            return status;
+
+        obj_surface = SURFACE(new_surface);
+        assert(obj_surface != NULL);
+
+        if (i <= FRAME_IN_PREVIOUS || i == FRAME_OUT_CURRENT_DN) {
+            status = i965_check_alloc_surface_bo(ctx, obj_surface,
+                input_tiling, input_fourcc, input_sampling);
+        }
+        else if (i == FRAME_IN_STMM || i == FRAME_OUT_STMM) {
+            status = i965_check_alloc_surface_bo(ctx, obj_surface,
+                1, input_fourcc, input_sampling);
         }
+        else if (i >= FRAME_OUT_CURRENT) {
+            status = i965_check_alloc_surface_bo(ctx, obj_surface,
+                output_tiling, output_fourcc, output_sampling);
+        }
+        if (status != VA_STATUS_SUCCESS)
+            return status;
 
-        proc_ctx->frame_store[i].surface_id = new_surface;
+        proc_ctx->frame_store[i].obj_surface = obj_surface;
         proc_ctx->frame_store[i].is_internal_surface = 1;
-        proc_ctx->frame_store[i].obj_surface = obj_surf;
+        proc_ctx->frame_store[i].is_scratch_surface = 1;
     }
 
-    /* alloc dndi state table  */
-    dri_bo_unreference(proc_ctx->dndi_state_table.bo);
-    bo = dri_bo_alloc(i965->intel.bufmgr,
-                      "vebox: dndi state Buffer",
-                      0x1000, 0x1000);
+    /* Allocate DNDI state table  */
+    drm_intel_bo_unreference(proc_ctx->dndi_state_table.bo);
+    bo = drm_intel_bo_alloc(i965->intel.bufmgr, "vebox: dndi state Buffer",
+        0x1000, 0x1000);
     proc_ctx->dndi_state_table.bo = bo;
-    dri_bo_reference(proc_ctx->dndi_state_table.bo);
+    if (!bo)
+        return VA_STATUS_ERROR_ALLOCATION_FAILED;
  
-    /* alloc iecp state table  */
-    dri_bo_unreference(proc_ctx->iecp_state_table.bo);
-    bo = dri_bo_alloc(i965->intel.bufmgr,
-                      "vebox: iecp state Buffer",
-                      0x1000, 0x1000);
+    /* Allocate IECP state table  */
+    drm_intel_bo_unreference(proc_ctx->iecp_state_table.bo);
+    bo = drm_intel_bo_alloc(i965->intel.bufmgr, "vebox: iecp state Buffer",
+        0x1000, 0x1000);
     proc_ctx->iecp_state_table.bo = bo;
-    dri_bo_reference(proc_ctx->iecp_state_table.bo);
+    if (!bo)
+        return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
-    /* alloc gamut state table  */
-    dri_bo_unreference(proc_ctx->gamut_state_table.bo);
-    bo = dri_bo_alloc(i965->intel.bufmgr,
-                      "vebox: gamut state Buffer",
-                      0x1000, 0x1000);
+    /* Allocate Gamut state table  */
+    drm_intel_bo_unreference(proc_ctx->gamut_state_table.bo);
+    bo = drm_intel_bo_alloc(i965->intel.bufmgr, "vebox: gamut state Buffer",
+        0x1000, 0x1000);
     proc_ctx->gamut_state_table.bo = bo;
-    dri_bo_reference(proc_ctx->gamut_state_table.bo);
+    if (!bo)
+        return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
-    /* alloc vertex state table  */
-    dri_bo_unreference(proc_ctx->vertex_state_table.bo);
-    bo = dri_bo_alloc(i965->intel.bufmgr,
-                      "vertex: iecp state Buffer",
-                      0x1000, 0x1000);
+    /* Allocate vertex state table  */
+    drm_intel_bo_unreference(proc_ctx->vertex_state_table.bo);
+    bo = drm_intel_bo_alloc(i965->intel.bufmgr, "vebox: vertex state Buffer",
+        0x1000, 0x1000);
     proc_ctx->vertex_state_table.bo = bo;
-    dri_bo_reference(proc_ctx->vertex_state_table.bo);
+    if (!bo)
+        return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
+    return VA_STATUS_SUCCESS;
 }
 
 static VAStatus
-hsw_veb_surface_reference(VADriverContextP ctx,
-                          struct intel_vebox_context *proc_ctx)
+gen75_vebox_ensure_surfaces(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
 {
-    struct object_surface * obj_surf; 
-    VEBFrameStore tmp_store;
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
+    struct object_surface *obj_surface;
+    VEBFrameStore *ifs, *ofs;
+    bool is_new_frame = 0;
+    int i;
 
-    if (proc_ctx->surface_input_vebox_object != NULL) {
-        obj_surf = proc_ctx->surface_input_vebox_object;
-    } else {
-        obj_surf = proc_ctx->surface_input_object;
-    } 
-
-    /* update the input surface */ 
-    proc_ctx->frame_store[FRAME_IN_CURRENT].surface_id = VA_INVALID_ID;
-    proc_ctx->frame_store[FRAME_IN_CURRENT].is_internal_surface = 0;
-    proc_ctx->frame_store[FRAME_IN_CURRENT].obj_surface = obj_surf;
-
-    /* update the previous input surface */
-    if (proc_ctx->frame_order != -1) {
-        if (proc_ctx->filters_mask == VPP_DNDI_DN) {
-            proc_ctx->frame_store[FRAME_IN_PREVIOUS] = proc_ctx->frame_store[FRAME_OUT_CURRENT_DN];
-        } else if (proc_ctx->filters_mask & VPP_DNDI_DI) {
-            VAProcFilterParameterBufferDeinterlacing *di_param =
-                (VAProcFilterParameterBufferDeinterlacing *)proc_ctx->filter_di;
-
-            if (di_param && 
-                (di_param->algorithm == VAProcDeinterlacingMotionAdaptive ||
-                di_param->algorithm == VAProcDeinterlacingMotionCompensated)) {
-                if ((proc_ctx->filters_mask & VPP_DNDI_DN) &&
-                    proc_ctx->frame_order == 0) { /* DNDI */
-                    tmp_store = proc_ctx->frame_store[FRAME_OUT_CURRENT_DN];
-                    proc_ctx->frame_store[FRAME_OUT_CURRENT_DN] = proc_ctx->frame_store[FRAME_IN_PREVIOUS];
-                    proc_ctx->frame_store[FRAME_IN_PREVIOUS] = tmp_store;
-                } else { /* DI only */
-                    VAProcPipelineParameterBuffer *pipe = proc_ctx->pipeline_param;
-                    struct object_surface *obj_surf = NULL;
-                    struct i965_driver_data * const i965 = i965_driver_data(ctx);
-
-                    if (!pipe ||
-                        !pipe->num_forward_references ||
-                        pipe->forward_references[0] == VA_INVALID_ID) {
-                        WARN_ONCE("A forward temporal reference is needed for Motion adaptive/compensated deinterlacing !!!\n");
-
-                        return VA_STATUS_ERROR_INVALID_PARAMETER;
-                    }
-
-                    obj_surf = SURFACE(pipe->forward_references[0]);
-                    assert(obj_surf && obj_surf->bo);
-                
-                    proc_ctx->frame_store[FRAME_IN_PREVIOUS].surface_id = pipe->forward_references[0];
-                    proc_ctx->frame_store[FRAME_IN_PREVIOUS].is_internal_surface = 0;
-                    proc_ctx->frame_store[FRAME_IN_PREVIOUS].obj_surface = obj_surf;
-                }
+    /* Update the previous input surface */
+    obj_surface = proc_ctx->surface_input_object;
+
+    is_new_frame = proc_ctx->frame_store[FRAME_IN_CURRENT].surface_id !=
+        obj_surface->base.id;
+    if (is_new_frame) {
+        ifs = &proc_ctx->frame_store[FRAME_IN_PREVIOUS];
+        ofs = &proc_ctx->frame_store[proc_ctx->is_dn_enabled ?
+            FRAME_OUT_CURRENT_DN : FRAME_IN_CURRENT];
+        do {
+            const VAProcPipelineParameterBuffer * const pipe =
+                proc_ctx->pipeline_param;
+
+            if (pipe->num_forward_references < 1)
+                break;
+            if (pipe->forward_references[0] == VA_INVALID_ID)
+                break;
+
+            obj_surface = SURFACE(pipe->forward_references[0]);
+            if (!obj_surface || obj_surface->base.id == ifs->surface_id)
+                break;
+
+            frame_store_clear(ifs, ctx);
+            if (obj_surface->base.id == ofs->surface_id) {
+                *ifs = *ofs;
+                frame_store_reset(ofs);
             }
-        }
+            else {
+                ifs->obj_surface = obj_surface;
+                ifs->surface_id = obj_surface->base.id;
+                ifs->is_internal_surface = 0;
+                ifs->is_scratch_surface = 0;
+            }
+        } while (0);
     }
 
-    /* update STMM surface */
-    if (proc_ctx->frame_order != -1) {
-        tmp_store = proc_ctx->frame_store[FRAME_IN_STMM];
-        proc_ctx->frame_store[FRAME_IN_STMM] = proc_ctx->frame_store[FRAME_OUT_STMM];
-        proc_ctx->frame_store[FRAME_OUT_STMM] = tmp_store;
+    /* Update the input surface */
+    obj_surface = proc_ctx->surface_input_vebox_object ?
+        proc_ctx->surface_input_vebox_object : proc_ctx->surface_input_object;
+
+    ifs = &proc_ctx->frame_store[FRAME_IN_CURRENT];
+    frame_store_clear(ifs, ctx);
+    ifs->obj_surface = obj_surface;
+    ifs->surface_id = proc_ctx->surface_input_object->base.id;
+    ifs->is_internal_surface = proc_ctx->surface_input_vebox_object != NULL;
+    ifs->is_scratch_surface = 0;
+
+    /* Update the Spatial Temporal Motion Measure (STMM) surfaces */
+    if (is_new_frame) {
+        const VEBFrameStore tmpfs = proc_ctx->frame_store[FRAME_IN_STMM];
+        proc_ctx->frame_store[FRAME_IN_STMM] =
+            proc_ctx->frame_store[FRAME_OUT_STMM];
+        proc_ctx->frame_store[FRAME_OUT_STMM] = tmpfs;
     }
 
-    /* update the output surface */ 
-    if (proc_ctx->surface_output_vebox_object != NULL) {
-        obj_surf = proc_ctx->surface_output_vebox_object;
-    } else {
-        obj_surf = proc_ctx->surface_output_object;
-    } 
+    /* Reset the output surfaces to defaults. i.e. clean from user surfaces */
+    for (i = FRAME_OUT_CURRENT_DN; i <= FRAME_OUT_PREVIOUS; i++) {
+        ofs = &proc_ctx->frame_store[i];
+        if (!ofs->is_scratch_surface)
+            ofs->obj_surface = NULL;
+        ofs->surface_id = proc_ctx->surface_input_object->base.id;
+    }
+
+    /* Update the output surfaces */
+    obj_surface = proc_ctx->surface_output_vebox_object ?
+        proc_ctx->surface_output_vebox_object : proc_ctx->surface_output_object;
 
-    if (proc_ctx->filters_mask == VPP_DNDI_DN) {
-        proc_ctx->frame_store[FRAME_OUT_CURRENT_DN].surface_id = VA_INVALID_ID;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT_DN].is_internal_surface = 0;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT_DN].obj_surface = obj_surf;
+    proc_ctx->current_output_type = 2;
+    if (proc_ctx->filters_mask == VPP_DNDI_DN && !proc_ctx->is_iecp_enabled)
         proc_ctx->current_output = FRAME_OUT_CURRENT_DN;
-    } else if (proc_ctx->filters_mask & VPP_DNDI_DI) {
-        VAProcFilterParameterBufferDeinterlacing *di_param =
-            (VAProcFilterParameterBufferDeinterlacing *)proc_ctx->filter_di;
-
-        if (di_param && 
-            (di_param->algorithm == VAProcDeinterlacingMotionAdaptive ||
-            di_param->algorithm == VAProcDeinterlacingMotionCompensated)) {
-            if (proc_ctx->frame_order == -1) {
-                proc_ctx->frame_store[FRAME_OUT_CURRENT].surface_id = VA_INVALID_ID;
-                proc_ctx->frame_store[FRAME_OUT_CURRENT].is_internal_surface = 0;
-                proc_ctx->frame_store[FRAME_OUT_CURRENT].obj_surface = obj_surf;
-                proc_ctx->current_output = FRAME_OUT_CURRENT;
-            } else if (proc_ctx->frame_order == 0) {
-                proc_ctx->frame_store[FRAME_OUT_PREVIOUS].surface_id = VA_INVALID_ID;
-                proc_ctx->frame_store[FRAME_OUT_PREVIOUS].is_internal_surface = 0;
-                proc_ctx->frame_store[FRAME_OUT_PREVIOUS].obj_surface = obj_surf;
-                proc_ctx->current_output = FRAME_OUT_PREVIOUS;
-            } else {
-                proc_ctx->current_output = FRAME_OUT_CURRENT;
-                proc_ctx->format_convert_flags |= POST_COPY_CONVERT;
-            }
-        } else {
-            proc_ctx->frame_store[FRAME_OUT_CURRENT].surface_id = VA_INVALID_ID;
-            proc_ctx->frame_store[FRAME_OUT_CURRENT].is_internal_surface = 0;
-            proc_ctx->frame_store[FRAME_OUT_CURRENT].obj_surface = obj_surf;
-            proc_ctx->current_output = FRAME_OUT_CURRENT;
-        }
-    } else {
-        proc_ctx->frame_store[FRAME_OUT_CURRENT].surface_id = VA_INVALID_ID;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT].is_internal_surface = 0;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT].obj_surface = obj_surf;
-        proc_ctx->current_output = FRAME_OUT_CURRENT;
+    else if (proc_ctx->is_di_adv_enabled && !proc_ctx->is_first_frame) {
+        proc_ctx->current_output_type = 0;
+        proc_ctx->current_output = proc_ctx->is_second_field ?
+            FRAME_OUT_CURRENT : FRAME_OUT_PREVIOUS;
     }
+    else
+        proc_ctx->current_output = FRAME_OUT_CURRENT;
+    ofs = &proc_ctx->frame_store[proc_ctx->current_output];
+    frame_store_clear(ofs, ctx);
+    ofs->obj_surface = obj_surface;
+    ofs->surface_id = proc_ctx->surface_input_object->base.id;
+    ofs->is_internal_surface = proc_ctx->surface_output_vebox_object != NULL;
+    ofs->is_scratch_surface = 0;
 
     return VA_STATUS_SUCCESS;
 }
 
-void hsw_veb_surface_unreference(VADriverContextP ctx,
-                                 struct intel_vebox_context *proc_ctx)
-{
-    /* unreference the input surface */ 
-    proc_ctx->frame_store[FRAME_IN_CURRENT].surface_id = VA_INVALID_ID;
-    proc_ctx->frame_store[FRAME_IN_CURRENT].is_internal_surface = 0;
-    proc_ctx->frame_store[FRAME_IN_CURRENT].obj_surface = NULL;
-
-    /* unreference the shared output surface */ 
-    if (proc_ctx->filters_mask == VPP_DNDI_DN) {
-        proc_ctx->frame_store[FRAME_OUT_CURRENT_DN].surface_id = VA_INVALID_ID;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT_DN].is_internal_surface = 0;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT_DN].obj_surface = NULL;
-    } else {
-        proc_ctx->frame_store[FRAME_OUT_CURRENT].surface_id = VA_INVALID_ID;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT].is_internal_surface = 0;
-        proc_ctx->frame_store[FRAME_OUT_CURRENT].obj_surface = NULL;
-    }
-}
-
 int hsw_veb_pre_format_convert(VADriverContextP ctx,
                            struct intel_vebox_context *proc_ctx)
 {
@@ -1179,7 +1154,7 @@ int hsw_veb_pre_format_convert(VADriverContextP ctx,
              }
          }
        
-         vpp_surface_convert(ctx, proc_ctx->surface_input_vebox_object, proc_ctx->surface_input_object);
+         vpp_surface_convert(ctx, proc_ctx->surface_input_object, proc_ctx->surface_input_vebox_object);
       }
 
       /* create one temporary NV12 surfaces for conversion*/
@@ -1250,7 +1225,7 @@ int hsw_veb_post_format_convert(VADriverContextP ctx,
 
     if (proc_ctx->format_convert_flags & POST_COPY_CONVERT) {
         /* copy the saved frame in the second call */
-        vpp_surface_convert(ctx,proc_ctx->surface_output_object, obj_surface);
+        vpp_surface_convert(ctx, obj_surface, proc_ctx->surface_output_object);
     } else if(!(proc_ctx->format_convert_flags & POST_FORMAT_CONVERT) &&
        !(proc_ctx->format_convert_flags & POST_SCALING_CONVERT)){
         /* Output surface format is covered by vebox pipeline and 
@@ -1259,14 +1234,16 @@ int hsw_veb_post_format_convert(VADriverContextP ctx,
     } else if ((proc_ctx->format_convert_flags & POST_FORMAT_CONVERT) &&
                !(proc_ctx->format_convert_flags & POST_SCALING_CONVERT)){
        /* convert and copy NV12 to YV12/IMC3/IMC2/RGBA output*/
-        vpp_surface_convert(ctx,proc_ctx->surface_output_object, obj_surface);
+        vpp_surface_convert(ctx, obj_surface, proc_ctx->surface_output_object);
 
     } else if(proc_ctx->format_convert_flags & POST_SCALING_CONVERT) {
+        VAProcPipelineParameterBuffer * const pipe = proc_ctx->pipeline_param;
        /* scaling, convert and copy NV12 to YV12/IMC3/IMC2/RGBA output*/
         assert(obj_surface->fourcc == VA_FOURCC_NV12);
      
         /* first step :surface scaling */
-        vpp_surface_scaling(ctx,proc_ctx->surface_output_scaled_object, obj_surface);
+        vpp_surface_scaling(ctx, obj_surface,
+            proc_ctx->surface_output_scaled_object, pipe->filter_flags);
 
         /* second step: color format convert and copy to output */
         obj_surface = proc_ctx->surface_output_object;
@@ -1278,7 +1255,7 @@ int hsw_veb_post_format_convert(VADriverContextP ctx,
            obj_surface->fourcc ==  VA_FOURCC_IMC1 ||
            obj_surface->fourcc ==  VA_FOURCC_IMC3 ||
            obj_surface->fourcc ==  VA_FOURCC_RGBA) {
-           vpp_surface_convert(ctx, proc_ctx->surface_output_object, proc_ctx->surface_output_scaled_object);
+            vpp_surface_convert(ctx, proc_ctx->surface_output_scaled_object, obj_surface);
        }else {
            assert(0); 
        }
@@ -1287,74 +1264,170 @@ int hsw_veb_post_format_convert(VADriverContextP ctx,
     return 0;
 }
 
-VAStatus gen75_vebox_process_picture(VADriverContextP ctx,
-                         struct intel_vebox_context *proc_ctx)
+static VAStatus
+gen75_vebox_init_pipe_params(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
- 
-    VAProcPipelineParameterBuffer *pipe = proc_ctx->pipeline_param;
-    VAProcFilterParameterBuffer* filter = NULL;
-    struct object_buffer *obj_buf = NULL;
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
+    const VAProcPipelineParameterBuffer * const pipe = proc_ctx->pipeline_param;
+    VAProcFilterParameterBuffer *filter;
     unsigned int i;
 
-    for (i = 0; i < pipe->num_filters; i ++) {
-         obj_buf = BUFFER(pipe->filters[i]);
-         
-         assert(obj_buf && obj_buf->buffer_store);
-
-         if (!obj_buf || !obj_buf->buffer_store)
-             goto error;
-
-         filter = (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer;
-            
-         if (filter->type == VAProcFilterNoiseReduction) {
-             proc_ctx->filters_mask |= VPP_DNDI_DN;
-             proc_ctx->filter_dn = filter;
-         } else if (filter->type == VAProcFilterDeinterlacing) {
-             proc_ctx->filters_mask |= VPP_DNDI_DI;
-             proc_ctx->filter_di = filter;
-         } else if (filter->type == VAProcFilterColorBalance) {
-             proc_ctx->filters_mask |= VPP_IECP_PRO_AMP;
-             proc_ctx->filter_iecp_amp = filter;
-             proc_ctx->filter_iecp_amp_num_elements = obj_buf->num_elements;
-         } else if (filter->type == VAProcFilterSkinToneEnhancement) {
-             proc_ctx->filters_mask |= VPP_IECP_STD_STE;
-             proc_ctx->filter_iecp_std = filter;
-         }
+    proc_ctx->filters_mask = 0;
+    for (i = 0; i < pipe->num_filters; i++) {
+        struct object_buffer * const obj_buffer = BUFFER(pipe->filters[i]);
+
+        assert(obj_buffer && obj_buffer->buffer_store);
+        if (!obj_buffer || !obj_buffer->buffer_store)
+            return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+        filter = (VAProcFilterParameterBuffer *)
+            obj_buffer->buffer_store->buffer;
+        switch (filter->type) {
+        case VAProcFilterNoiseReduction:
+            proc_ctx->filters_mask |= VPP_DNDI_DN;
+            proc_ctx->filter_dn = filter;
+            break;
+        case VAProcFilterDeinterlacing:
+            proc_ctx->filters_mask |= VPP_DNDI_DI;
+            proc_ctx->filter_di = filter;
+            break;
+        case VAProcFilterColorBalance:
+            proc_ctx->filters_mask |= VPP_IECP_PRO_AMP;
+            proc_ctx->filter_iecp_amp = filter;
+            proc_ctx->filter_iecp_amp_num_elements = obj_buffer->num_elements;
+            break;
+        case VAProcFilterSkinToneEnhancement:
+            proc_ctx->filters_mask |= VPP_IECP_STD_STE;
+            proc_ctx->filter_iecp_std = filter;
+            break;
+        default:
+            WARN_ONCE("unsupported filter (type: %d)\n", filter->type);
+            return VA_STATUS_ERROR_UNSUPPORTED_FILTER;
+        }
     }
+    return VA_STATUS_SUCCESS;
+}
 
-    hsw_veb_pre_format_convert(ctx, proc_ctx);
-    hsw_veb_surface_reference(ctx, proc_ctx);
+static VAStatus
+gen75_vebox_init_filter_params(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
+{
+    proc_ctx->format_convert_flags = 0; /* initialized in hsw_veb_pre_format_convert() */
+
+    proc_ctx->is_iecp_enabled = (proc_ctx->filters_mask & VPP_IECP_MASK) != 0;
+    proc_ctx->is_dn_enabled = (proc_ctx->filters_mask & VPP_DNDI_DN) != 0;
+    proc_ctx->is_di_enabled = (proc_ctx->filters_mask & VPP_DNDI_DI) != 0;
+    proc_ctx->is_di_adv_enabled = 0;
+    proc_ctx->is_first_frame = 0;
+    proc_ctx->is_second_field = 0;
+
+    /* Check whether we are deinterlacing the second field */
+    if (proc_ctx->is_di_enabled) {
+        const VAProcFilterParameterBufferDeinterlacing * const deint_params =
+            proc_ctx->filter_di;
+
+        const unsigned int tff =
+            !(deint_params->flags & VA_DEINTERLACING_BOTTOM_FIELD_FIRST);
+        const unsigned int is_top_field =
+            !(deint_params->flags & VA_DEINTERLACING_BOTTOM_FIELD);
+
+        if ((tff ^ is_top_field) != 0) {
+            struct object_surface * const obj_surface =
+                proc_ctx->surface_input_object;
+
+            if (proc_ctx->frame_store[FRAME_IN_CURRENT].surface_id != obj_surface->base.id) {
+                WARN_ONCE("invalid surface provided for second field\n");
+                return VA_STATUS_ERROR_INVALID_PARAMETER;
+            }
+            proc_ctx->is_second_field = 1;
+        }
+    }
 
-    if (proc_ctx->frame_order == -1) {
-        hsw_veb_resource_prepare(ctx, proc_ctx);
+    /* Check whether we are deinterlacing the first frame */
+    if (proc_ctx->is_di_enabled) {
+        const VAProcFilterParameterBufferDeinterlacing * const deint_params =
+            proc_ctx->filter_di;
+
+        switch (deint_params->algorithm) {
+        case VAProcDeinterlacingBob:
+            proc_ctx->is_first_frame = 1;
+            break;
+        case VAProcDeinterlacingMotionAdaptive:
+        case VAProcDeinterlacingMotionCompensated:
+            if (proc_ctx->frame_store[FRAME_IN_CURRENT].surface_id == VA_INVALID_ID)
+                proc_ctx->is_first_frame = 1;
+            else if (proc_ctx->is_second_field) {
+                /* At this stage, we have already deinterlaced the
+                   first field successfully. So, the first frame flag
+                   is trigerred if the previous field was deinterlaced
+                   without reference frame */
+                if (proc_ctx->frame_store[FRAME_IN_PREVIOUS].surface_id == VA_INVALID_ID)
+                    proc_ctx->is_first_frame = 1;
+            }
+            else {
+                const VAProcPipelineParameterBuffer * const pipe =
+                    proc_ctx->pipeline_param;
+
+                if (pipe->num_forward_references < 1 ||
+                    pipe->forward_references[0] == VA_INVALID_ID) {
+                    WARN_ONCE("A forward temporal reference is needed for Motion adaptive/compensated deinterlacing !!!\n");
+                    return VA_STATUS_ERROR_INVALID_PARAMETER;
+                }
+            }
+            proc_ctx->is_di_adv_enabled = 1;
+            break;
+        default:
+            WARN_ONCE("unsupported deinterlacing algorithm (%d)\n",
+                      deint_params->algorithm);
+            return VA_STATUS_ERROR_UNSUPPORTED_FILTER;
+        }
     }
+    return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+gen75_vebox_process_picture(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
+{
+    VAStatus status;
+
+    status = gen75_vebox_init_pipe_params(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    status = gen75_vebox_init_filter_params(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    hsw_veb_pre_format_convert(ctx, proc_ctx);
+
+    status = gen75_vebox_ensure_surfaces(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    status = gen75_vebox_ensure_surfaces_storage(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
 
     if (proc_ctx->format_convert_flags & POST_COPY_CONVERT) {
-        assert(proc_ctx->frame_order == 1);
+        assert(proc_ctx->is_second_field);
         /* directly copy the saved frame in the second call */
     } else {
         intel_batchbuffer_start_atomic_veb(proc_ctx->batch, 0x1000);
         intel_batchbuffer_emit_mi_flush(proc_ctx->batch);
-        hsw_veb_surface_state(ctx, proc_ctx, INPUT_SURFACE); 
-        hsw_veb_surface_state(ctx, proc_ctx, OUTPUT_SURFACE); 
         hsw_veb_state_table_setup(ctx, proc_ctx);
-
         hsw_veb_state_command(ctx, proc_ctx);		
+        hsw_veb_surface_state(ctx, proc_ctx, INPUT_SURFACE);
+        hsw_veb_surface_state(ctx, proc_ctx, OUTPUT_SURFACE);
         hsw_veb_dndi_iecp_command(ctx, proc_ctx);
         intel_batchbuffer_end_atomic(proc_ctx->batch);
         intel_batchbuffer_flush(proc_ctx->batch);
     }
 
     hsw_veb_post_format_convert(ctx, proc_ctx);
-    // hsw_veb_surface_unreference(ctx, proc_ctx);
-
-    proc_ctx->frame_order = (proc_ctx->frame_order + 1) % 2;
      
     return VA_STATUS_SUCCESS;
-
-error:
-    return VA_STATUS_ERROR_INVALID_PARAMETER;
 }
 
 void gen75_vebox_context_destroy(VADriverContextP ctx, 
@@ -1380,33 +1453,23 @@ void gen75_vebox_context_destroy(VADriverContextP ctx,
        proc_ctx->surface_output_scaled_object = NULL;
      }
 
-    for(i = 0; i < FRAME_STORE_SUM; i ++) {
-        if (proc_ctx->frame_store[i].is_internal_surface == 1) {
-            assert(proc_ctx->frame_store[i].surface_id != VA_INVALID_ID);
-
-            if (proc_ctx->frame_store[i].surface_id != VA_INVALID_ID)
-                i965_DestroySurfaces(ctx, &proc_ctx->frame_store[i].surface_id, 1);
-        }
-
-        proc_ctx->frame_store[i].surface_id = VA_INVALID_ID;
-        proc_ctx->frame_store[i].is_internal_surface = 0;
-        proc_ctx->frame_store[i].obj_surface = NULL;
-    }
+    for (i = 0; i < ARRAY_ELEMS(proc_ctx->frame_store); i++)
+        frame_store_clear(&proc_ctx->frame_store[i], ctx);
 
     /* dndi state table  */
-    dri_bo_unreference(proc_ctx->dndi_state_table.bo);
+    drm_intel_bo_unreference(proc_ctx->dndi_state_table.bo);
     proc_ctx->dndi_state_table.bo = NULL;
 
     /* iecp state table  */
-    dri_bo_unreference(proc_ctx->iecp_state_table.bo);
-    proc_ctx->dndi_state_table.bo = NULL;
+    drm_intel_bo_unreference(proc_ctx->iecp_state_table.bo);
+    proc_ctx->iecp_state_table.bo = NULL;
  
     /* gamut statu table */
-    dri_bo_unreference(proc_ctx->gamut_state_table.bo);
+    drm_intel_bo_unreference(proc_ctx->gamut_state_table.bo);
     proc_ctx->gamut_state_table.bo = NULL;
 
     /* vertex state table  */
-    dri_bo_unreference(proc_ctx->vertex_state_table.bo);
+    drm_intel_bo_unreference(proc_ctx->vertex_state_table.bo);
     proc_ctx->vertex_state_table.bo = NULL;
 
     intel_batchbuffer_free(proc_ctx->batch);
@@ -1421,16 +1484,11 @@ struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx)
     int i;
 
     proc_context->batch = intel_batchbuffer_new(intel, I915_EXEC_VEBOX, 0);
-    memset(proc_context->frame_store, 0, sizeof(VEBFrameStore)*FRAME_STORE_SUM);
 
-    for (i = 0; i < FRAME_STORE_SUM; i ++) {
+    for (i = 0; i < ARRAY_ELEMS(proc_context->frame_store); i++)
         proc_context->frame_store[i].surface_id = VA_INVALID_ID;
-        proc_context->frame_store[i].is_internal_surface = 0;
-        proc_context->frame_store[i].obj_surface = NULL;
-    }
   
     proc_context->filters_mask          = 0;
-    proc_context->frame_order           = -1; /* the first frame */
     proc_context->surface_output_object = NULL;
     proc_context->surface_input_object  = NULL;
     proc_context->surface_input_vebox   = VA_INVALID_ID;
@@ -1448,33 +1506,6 @@ struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx)
 void bdw_veb_state_command(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
 {
     struct intel_batchbuffer *batch = proc_ctx->batch;
-    unsigned int is_dn_enabled   = (proc_ctx->filters_mask & 0x01)? 1: 0;
-    unsigned int is_di_enabled   = (proc_ctx->filters_mask & 0x02)? 1: 0;
-    unsigned int is_iecp_enabled = (proc_ctx->filters_mask & 0xff00)?1:0;
-    unsigned int is_first_frame  = !!((proc_ctx->frame_order == -1) &&
-                                      (is_di_enabled ||
-                                       is_dn_enabled));
-    unsigned int di_output_frames_flag = 2; /* Output Current Frame Only */
-
-    if(proc_ctx->fourcc_input != proc_ctx->fourcc_output ||
-       (is_dn_enabled == 0 && is_di_enabled == 0)){
-       is_iecp_enabled = 1;
-    }
-
-    if (is_di_enabled) {
-        VAProcFilterParameterBufferDeinterlacing *di_param =
-            (VAProcFilterParameterBufferDeinterlacing *)proc_ctx->filter_di;
-
-        assert(di_param);
-        
-        if (di_param->algorithm == VAProcDeinterlacingBob)
-            is_first_frame = 1;
-
-        if ((di_param->algorithm == VAProcDeinterlacingMotionAdaptive ||
-            di_param->algorithm == VAProcDeinterlacingMotionCompensated) &&
-            proc_ctx->frame_order != -1)
-            di_output_frames_flag = 0; /* Output both Current Frame and Previous Frame */
-    }
 
     BEGIN_VEB_BATCH(batch, 0xc);
     OUT_VEB_BATCH(batch, VEB_STATE | (0xc - 2));
@@ -1488,13 +1519,13 @@ void bdw_veb_state_command(VADriverContextP ctx, struct intel_vebox_context *pro
                   0 << 12 |       // alpha plane enable
                   0 << 11 |       // vignette enable
                   0 << 10 |       // demosaic enable
-                  di_output_frames_flag << 8  |       // DI output frame
+                  proc_ctx->current_output_type << 8  | // DI output frame
                   1 << 7  |       // 444->422 downsample method
                   1 << 6  |       // 422->420 downsample method
-                  is_first_frame  << 5  |   // DN/DI first frame
-                  is_di_enabled   << 4  |             // DI enable
-                  is_dn_enabled   << 3  |             // DN enable
-                  is_iecp_enabled << 2  |             // global IECP enabled
+                  proc_ctx->is_first_frame  << 5  |   // DN/DI first frame
+                  proc_ctx->is_di_enabled   << 4  |   // DI enable
+                  proc_ctx->is_dn_enabled   << 3  |   // DN enable
+                  proc_ctx->is_iecp_enabled << 2  |   // global IECP enabled
                   0 << 1  |       // ColorGamutCompressionEnable
                   0 ) ;           // ColorGamutExpansionEnable.
 
@@ -1532,14 +1563,11 @@ void bdw_veb_dndi_iecp_command(VADriverContextP ctx, struct intel_vebox_context
 {
     struct intel_batchbuffer *batch = proc_ctx->batch;
     unsigned char frame_ctrl_bits = 0;
-    unsigned int startingX = 0;
-    unsigned int endingX = (proc_ctx->width_input + 63 ) / 64 * 64;
+    const unsigned int width64 = ALIGN(proc_ctx->width_input, 64);
 
     BEGIN_VEB_BATCH(batch, 0x14);
     OUT_VEB_BATCH(batch, VEB_DNDI_IECP_STATE | (0x14 - 2));//DWord 0
-    OUT_VEB_BATCH(batch,
-                  startingX << 16 |
-                  endingX -1);//DWord 1
+    OUT_VEB_BATCH(batch, (width64 - 1));
 
     OUT_RELOC(batch,
               proc_ctx->frame_store[FRAME_IN_CURRENT].obj_surface->bo,
@@ -1587,73 +1615,508 @@ void bdw_veb_dndi_iecp_command(VADriverContextP ctx, struct intel_vebox_context
     ADVANCE_VEB_BATCH(batch);
 }
 
-VAStatus gen8_vebox_process_picture(VADriverContextP ctx,
-                         struct intel_vebox_context *proc_ctx)
+VAStatus
+gen8_vebox_process_picture(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
- 
-    VAProcPipelineParameterBuffer *pipe = proc_ctx->pipeline_param;
-    VAProcFilterParameterBuffer* filter = NULL;
-    struct object_buffer *obj_buf = NULL;
-    unsigned int i;
+    VAStatus status;
 
-    for (i = 0; i < pipe->num_filters; i ++) {
-         obj_buf = BUFFER(pipe->filters[i]);
-         
-         assert(obj_buf && obj_buf->buffer_store);
-
-         if (!obj_buf || !obj_buf->buffer_store)
-             goto error;
-
-         filter = (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer;
-            
-         if (filter->type == VAProcFilterNoiseReduction) {
-             proc_ctx->filters_mask |= VPP_DNDI_DN;
-             proc_ctx->filter_dn = filter;
-         } else if (filter->type == VAProcFilterDeinterlacing) {
-             proc_ctx->filters_mask |= VPP_DNDI_DI;
-             proc_ctx->filter_di = filter;
-         } else if (filter->type == VAProcFilterColorBalance) {
-             proc_ctx->filters_mask |= VPP_IECP_PRO_AMP;
-             proc_ctx->filter_iecp_amp = filter;
-             proc_ctx->filter_iecp_amp_num_elements = obj_buf->num_elements;
-         } else if (filter->type == VAProcFilterSkinToneEnhancement) {
-             proc_ctx->filters_mask |= VPP_IECP_STD_STE;
-             proc_ctx->filter_iecp_std = filter;
-         }
-    }
+    status = gen75_vebox_init_pipe_params(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    status = gen75_vebox_init_filter_params(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
 
     hsw_veb_pre_format_convert(ctx, proc_ctx);
-    hsw_veb_surface_reference(ctx, proc_ctx);
 
-    if (proc_ctx->frame_order == -1) {
-        hsw_veb_resource_prepare(ctx, proc_ctx);
-    }
+    status = gen75_vebox_ensure_surfaces(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    status = gen75_vebox_ensure_surfaces_storage(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
 
     if (proc_ctx->format_convert_flags & POST_COPY_CONVERT) {
-        assert(proc_ctx->frame_order == 1);
+        assert(proc_ctx->is_second_field);
         /* directly copy the saved frame in the second call */
     } else {
         intel_batchbuffer_start_atomic_veb(proc_ctx->batch, 0x1000);
         intel_batchbuffer_emit_mi_flush(proc_ctx->batch);
-        hsw_veb_surface_state(ctx, proc_ctx, INPUT_SURFACE); 
-        hsw_veb_surface_state(ctx, proc_ctx, OUTPUT_SURFACE); 
         hsw_veb_state_table_setup(ctx, proc_ctx);
-
         bdw_veb_state_command(ctx, proc_ctx);		
+        hsw_veb_surface_state(ctx, proc_ctx, INPUT_SURFACE);
+        hsw_veb_surface_state(ctx, proc_ctx, OUTPUT_SURFACE);
         bdw_veb_dndi_iecp_command(ctx, proc_ctx);
         intel_batchbuffer_end_atomic(proc_ctx->batch);
         intel_batchbuffer_flush(proc_ctx->batch);
     }
 
     hsw_veb_post_format_convert(ctx, proc_ctx);
-    // hsw_veb_surface_unreference(ctx, proc_ctx);
-
-    proc_ctx->frame_order = (proc_ctx->frame_order + 1) % 2;
      
     return VA_STATUS_SUCCESS;
+}
+
+
+void
+skl_veb_dndi_table(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
+{
+    unsigned int* p_table ;
+    unsigned int progressive_dn = 1;
+    unsigned int dndi_top_first = 0;
+    unsigned int is_mcdi_enabled = 0;
+
+    if (proc_ctx->is_di_enabled) {
+        const VAProcFilterParameterBufferDeinterlacing * const deint_params =
+            proc_ctx->filter_di;
+
+        progressive_dn = 0;
+
+        /* If we are in "First Frame" mode, i.e. past frames are not
+           available for motion measure, then don't use the TFF flag */
+        dndi_top_first = !(deint_params->flags & (proc_ctx->is_first_frame ?
+                VA_DEINTERLACING_BOTTOM_FIELD :
+                VA_DEINTERLACING_BOTTOM_FIELD_FIRST));
+
+        is_mcdi_enabled =
+            (deint_params->algorithm == VAProcDeinterlacingMotionCompensated);
+    }
+
+    /*
+    VAProcFilterParameterBufferDeinterlacing *di_param =
+            (VAProcFilterParameterBufferDeinterlacing *) proc_ctx->filter_di;
+
+    VAProcFilterParameterBuffer * dn_param =
+            (VAProcFilterParameterBuffer *) proc_ctx->filter_dn;
+    */
+    p_table = (unsigned int *)proc_ctx->dndi_state_table.ptr;
+
+    *p_table ++ = ( 140 << 20 |   // denoise stad threshold . w1
+                    192 << 12 |   // dnmh_history_max
+                    7   << 8  |   // dnmh_delta[3:0]
+                    1 );          // denoise moving pixel threshold
+
+    *p_table ++ = ( 38 << 20 |    // denoise asd threshold
+                    0  << 10 |    // temporal diff th
+                    0 );          // low temporal diff th
+
+    *p_table ++ = ( progressive_dn << 28  |  // progressive dn
+                    38 << 16 |    // denoise th for sum of complexity measure
+                    32 << 10 |    // dnmh_history_init[5:0]
+                    0 );          // reserved
+
+    *p_table ++ = ( 0 << 28  |    // hot pixel count
+                    0 << 20  |    // hot pixel threshold
+                    1 << 12  |    // block noise estimate edge threshold
+                    20 );         // block noise estimate noise threshold
+
+    *p_table ++ = ( 140<< 16 |    // chroma denoise stad threshold
+                    0  << 13 |    // reserved
+                    1  << 12 |    // chrome denoise enable
+                    13 << 6  |    // chr temp diff th
+                    7 );          // chr temp diff low
+
+    *p_table ++ = 0;              // weight
+
+    *p_table ++ = ( 0 << 16  |    // dn_thmax
+                    0 );          // dn_thmin
+
+    *p_table ++ = ( 0 << 16  |    // dn_prt5
+                    0 );          // dn_dyn_thmin
+
+    *p_table ++ = ( 0 << 16  |    // dn_prt4
+                    0 );          // dn_prt3
+
+    *p_table ++ = ( 0 << 16  |    // dn_prt2
+                    0 );          // dn_prt1
+
+    *p_table ++ = ( 0 << 16  |    // dn_prt0
+                    0 << 10  |    // dn_wd22
+                    0 << 5   |    // dh_wd21
+                    0 );          // dh_wd20
+
+   *p_table ++ = ( 0 << 25  |    // dn_wd12
+                    0 << 20  |    // dn_wd11
+                    0 << 15  |    // dn_wd10
+                    0 << 10  |    // dn_wd02
+                    0 << 5   |    // dn_wd01
+                    0 );          // dn_wd00
+
+    *p_table ++ = ( 2 << 10 |     // stmm c2
+                    9 << 6  |     // cat slope minus 1
+                    5 << 2  |     // sad tight threshold
+                    0 );          // smooth mv th
+
+    *p_table ++ = ( 0  << 31 |    // stmm blending constant select
+                    64 << 24 |    // stmm trc1
+                    125<< 16 |    // stmm trc2
+                    0  << 14 |    // reserved
+                    30 << 8  |    // multiplier for vecm
+                    150 );        // maximum stmm
+
+    *p_table ++ = ( 118<< 24  |   // minumum stmm
+                    0  << 22  |   // stmm shift down
+                    1  << 20  |   // stmm shift up
+                    5  << 16  |   // stmm output shift
+                    100 << 8  |   // sdi threshold
+                    5 );          // sdi delta
+
+    *p_table ++ = ( 50  << 24 |   // sdi fallback mode 1 t1 constant
+                    100 << 16 |   // sdi fallback mode 1 t2 constant
+                    37  << 8  |   // sdi fallback mode 2 constant(angle2x1)
+                    175 );        // fmd temporal difference threshold
+
+    *p_table ++ = ( 16 << 24  |   // fmd #1 vertical difference th . w7
+                    100<< 16  |   // fmd #2 vertical difference th
+                    0  << 14  |   // cat threshold
+                    2  << 8   |   // fmd tear threshold
+                    is_mcdi_enabled  << 7  |  // mcdi enable, use motion compensated deinterlace algorithm
+                    dndi_top_first  << 3   |  // dn/di top first
+                    0 );          // reserved
+
+    *p_table ++ = ( 10 << 19  |   // neighbor pixel threshold
+                    0  << 16  |   // fmd for 2nd field of previous frame
+                    25 << 10  |   // mc pixel consistency threshold
+                    0  << 8   |   // fmd for 1st field for current frame
+                    10 << 4   |   // sad thb
+                    5 );          // sad tha
+}
+
+void skl_veb_iecp_csc_table(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
+{
+    unsigned int *p_table = (unsigned int*)(proc_ctx->iecp_state_table.ptr + 220);
+    float tran_coef[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
+    float v_coef[3]    = {0.0, 0.0, 0.0};
+    float u_coef[3]    = {0.0, 0.0, 0.0};
+    int   is_transform_enabled = 0;
+
+    if(!(proc_ctx->filters_mask & VPP_IECP_CSC)){
+        memset(p_table, 0, 12 * 4);
+        return;
+    }
+
+    if(proc_ctx->fourcc_input == VA_FOURCC_RGBA &&
+       (proc_ctx->fourcc_output == VA_FOURCC_NV12 ||
+        proc_ctx->fourcc_output == VA_FOURCC_YV12 ||
+        proc_ctx->fourcc_output == VA_FOURCC_YVY2 ||
+        proc_ctx->fourcc_output == VA_FOURCC_AYUV)) {
+
+        tran_coef[0] = 0.257;
+        tran_coef[1] = 0.504;
+        tran_coef[2] = 0.098;
+        tran_coef[3] = -0.148;
+        tran_coef[4] = -0.291;
+        tran_coef[5] = 0.439;
+        tran_coef[6] = 0.439;
+        tran_coef[7] = -0.368;
+        tran_coef[8] = -0.071;
+
+        u_coef[0] = 16 * 4;
+        u_coef[1] = 128 * 4;
+        u_coef[2] = 128 * 4;
+
+        is_transform_enabled = 1;
+    }else if((proc_ctx->fourcc_input  == VA_FOURCC_NV12 ||
+              proc_ctx->fourcc_input  == VA_FOURCC_YV12 ||
+              proc_ctx->fourcc_input  == VA_FOURCC_YUY2 ||
+              proc_ctx->fourcc_input  == VA_FOURCC_AYUV) &&
+             proc_ctx->fourcc_output == VA_FOURCC_RGBA) {
+        tran_coef[0] = 1.164;
+        tran_coef[1] = 0.000;
+        tran_coef[2] = 1.569;
+        tran_coef[3] = 1.164;
+        tran_coef[4] = -0.813;
+        tran_coef[5] = -0.392;
+        tran_coef[6] = 1.164;
+        tran_coef[7] = 2.017;
+        tran_coef[8] = 0.000;
+
+        v_coef[0] = -16 * 4;
+        v_coef[1] = -128 * 4;
+        v_coef[2] = -128 * 4;
+
+        is_transform_enabled = 1;
+    }else if(proc_ctx->fourcc_input != proc_ctx->fourcc_output){
+        //enable when input and output format are different.
+        is_transform_enabled = 1;
+    }
+
+    if(is_transform_enabled == 0){
+        memset(p_table, 0, 12 * 4);
+    }else{
+        *p_table ++ = ( is_transform_enabled << 31 |
+                        0 << 29 | // yuv_channel swap
+                        intel_format_convert(tran_coef[0], 2, 16, 1));          //c0, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[1], 2, 16, 1));          //c1, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[2], 2, 16, 1));          //c2, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[3], 2, 16, 1));          //c3, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[4], 2, 16, 1));          //c4, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[5], 2, 16, 1));          //c5, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[6], 2, 16, 1));          //c6, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[7], 2, 16, 1));          //c7, s2.16 format
+
+        *p_table ++ = ( 0 << 19 | //reserved
+                        intel_format_convert(tran_coef[8], 2, 16, 1));          //c8, s2.16 format
+
+        *p_table ++ = ( intel_format_convert(u_coef[0], 16, 0, 1) << 16 |
+                        intel_format_convert(v_coef[0], 16, 0, 1));
+
+        *p_table ++ = ( intel_format_convert(u_coef[1], 16, 0, 1) << 16 |
+                        intel_format_convert(v_coef[1], 16, 0, 1));
+
+        *p_table ++ = ( intel_format_convert(u_coef[2], 16, 0, 1) << 16 |
+                        intel_format_convert(v_coef[2], 16, 0, 1));
+    }
+}
+
+void skl_veb_iecp_aoi_table(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
+{
+    unsigned int *p_table = (unsigned int*)(proc_ctx->iecp_state_table.ptr + 27 * sizeof(unsigned int));
+
+    if (!(proc_ctx->filters_mask & VPP_IECP_AOI)) {
+        memset(p_table, 0, 3 * 4);
+    } else {
+        *p_table ++ = 0x00000000;
+        *p_table ++ = 0x00030000;
+        *p_table ++ = 0x00030000;
+    }
+}
+
+void skl_veb_state_table_setup(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
+{
+    if(proc_ctx->filters_mask & VPP_DNDI_MASK) {
+        dri_bo *dndi_bo = proc_ctx->dndi_state_table.bo;
+        dri_bo_map(dndi_bo, 1);
+        proc_ctx->dndi_state_table.ptr = dndi_bo->virtual;
+
+        skl_veb_dndi_table(ctx, proc_ctx);
 
-error:
-    return VA_STATUS_ERROR_INVALID_PARAMETER;
+        dri_bo_unmap(dndi_bo);
+    }
+
+    if(proc_ctx->filters_mask & VPP_IECP_MASK) {
+        dri_bo *iecp_bo = proc_ctx->iecp_state_table.bo;
+        dri_bo_map(iecp_bo, 1);
+        proc_ctx->iecp_state_table.ptr = iecp_bo->virtual;
+
+        hsw_veb_iecp_std_table(ctx, proc_ctx);
+        hsw_veb_iecp_ace_table(ctx, proc_ctx);
+        hsw_veb_iecp_tcc_table(ctx, proc_ctx);
+        hsw_veb_iecp_pro_amp_table(ctx, proc_ctx);
+        skl_veb_iecp_csc_table(ctx, proc_ctx);
+        skl_veb_iecp_aoi_table(ctx, proc_ctx);
+
+        dri_bo_unmap(iecp_bo);
+    }
 }
 
+void
+skl_veb_state_command(VADriverContextP ctx, struct intel_vebox_context *proc_ctx)
+{
+    struct intel_batchbuffer *batch = proc_ctx->batch;
+
+    BEGIN_VEB_BATCH(batch, 0x10);
+    OUT_VEB_BATCH(batch, VEB_STATE | (0x10 - 2));
+    OUT_VEB_BATCH(batch,
+                  0 << 25 |       // state surface control bits
+                  0 << 23 |       // reserved.
+                  0 << 22 |       // gamut expansion position
+                  0 << 15 |       // reserved.
+                  0 << 14 |       // single slice vebox enable
+                  0 << 13 |       // hot pixel filter enable
+                  0 << 12 |       // alpha plane enable
+                  0 << 11 |       // vignette enable
+                  0 << 10 |       // demosaic enable
+                  proc_ctx->current_output_type << 8  | // DI output frame
+                  1 << 7  |       // 444->422 downsample method
+                  1 << 6  |       // 422->420 downsample method
+                  proc_ctx->is_first_frame  << 5  |   // DN/DI first frame
+                  proc_ctx->is_di_enabled   << 4  |   // DI enable
+                  proc_ctx->is_dn_enabled   << 3  |   // DN enable
+                  proc_ctx->is_iecp_enabled << 2  |   // global IECP enabled
+                  0 << 1  |       // ColorGamutCompressionEnable
+                  0 ) ;           // ColorGamutExpansionEnable.
+
+    OUT_RELOC(batch,
+              proc_ctx->dndi_state_table.bo,
+              I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_RELOC(batch,
+              proc_ctx->iecp_state_table.bo,
+              I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_RELOC(batch,
+              proc_ctx->gamut_state_table.bo,
+              I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_RELOC(batch,
+              proc_ctx->vertex_state_table.bo,
+              I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_VEB_BATCH(batch, 0);/*caputre pipe state pointer*/
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_VEB_BATCH(batch, 0);/*lace lut table state pointer*/
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_VEB_BATCH(batch, 0);/*gamma correction values address*/
+    OUT_VEB_BATCH(batch, 0);
+
+    ADVANCE_VEB_BATCH(batch);
+}
+
+void skl_veb_surface_state(VADriverContextP ctx, struct intel_vebox_context *proc_ctx, unsigned int is_output)
+{
+    struct intel_batchbuffer *batch = proc_ctx->batch;
+    unsigned int u_offset_y = 0, v_offset_y = 0;
+    unsigned int is_uv_interleaved = 0, tiling = 0, swizzle = 0;
+    unsigned int surface_format = PLANAR_420_8;
+    struct object_surface* obj_surf = NULL;
+    unsigned int surface_pitch = 0;
+    unsigned int half_pitch_chroma = 0;
+    unsigned int derived_pitch;
+
+    if (is_output) {
+        obj_surf = proc_ctx->frame_store[FRAME_OUT_CURRENT].obj_surface;
+    } else {
+        obj_surf = proc_ctx->frame_store[FRAME_IN_CURRENT].obj_surface;
+    }
+
+    assert(obj_surf->fourcc == VA_FOURCC_NV12 ||
+           obj_surf->fourcc == VA_FOURCC_YUY2 ||
+           obj_surf->fourcc == VA_FOURCC_AYUV ||
+           obj_surf->fourcc == VA_FOURCC_RGBA);
+
+    if (obj_surf->fourcc == VA_FOURCC_NV12) {
+        surface_format = PLANAR_420_8;
+        surface_pitch = obj_surf->width;
+        is_uv_interleaved = 1;
+        half_pitch_chroma = 0;
+    } else if (obj_surf->fourcc == VA_FOURCC_YUY2) {
+        surface_format = YCRCB_NORMAL;
+        surface_pitch = obj_surf->width * 2;
+        is_uv_interleaved = 0;
+        half_pitch_chroma = 0;
+    } else if (obj_surf->fourcc == VA_FOURCC_AYUV) {
+        surface_format = PACKED_444A_8;
+        surface_pitch = obj_surf->width * 4;
+        is_uv_interleaved = 0;
+        half_pitch_chroma = 0;
+    } else if (obj_surf->fourcc == VA_FOURCC_RGBA) {
+        surface_format = R8G8B8A8_UNORM_SRGB;
+        surface_pitch = obj_surf->width * 4;
+        is_uv_interleaved = 0;
+        half_pitch_chroma = 0;
+    }
+
+    derived_pitch = surface_pitch;
+
+    u_offset_y = obj_surf->y_cb_offset;
+    v_offset_y = obj_surf->y_cr_offset;
+
+    dri_bo_get_tiling(obj_surf->bo, &tiling, &swizzle);
+
+    BEGIN_VEB_BATCH(batch, 9);
+    OUT_VEB_BATCH(batch, VEB_SURFACE_STATE | (9 - 2));
+    OUT_VEB_BATCH(batch,
+                  0 << 1 |         // reserved
+                  is_output);      // surface indentification.
+
+    OUT_VEB_BATCH(batch,
+                  (obj_surf->height - 1) << 18 |  // height . w3
+                  (obj_surf->width -1 )  << 4  |  // width
+                  0);                             // reserve
+
+    OUT_VEB_BATCH(batch,
+                  surface_format      << 28  |  // surface format, YCbCr420. w4
+                  is_uv_interleaved   << 27  |  // interleave chrome , two seperate palar
+                  0                   << 20  |  // reserved
+                  (surface_pitch - 1) << 3   |  // surface pitch, 64 align
+                  half_pitch_chroma   << 2   |  // half pitch for chrome
+                  !!tiling            << 1   |  // tiled surface, linear surface used
+                  (tiling == I915_TILING_Y));   // tiled walk, ignored when liner surface
+
+    OUT_VEB_BATCH(batch,
+                  0 << 16  |     // X offset for V(Cb)
+                  u_offset_y);   // Y offset for V(Cb)
+
+    OUT_VEB_BATCH(batch,
+                  0 << 16  |     // X offset for V(Cr)
+                  v_offset_y );  // Y offset for V(Cr)
+
+    OUT_VEB_BATCH(batch, 0);
+
+    OUT_VEB_BATCH(batch, derived_pitch - 1);
+
+    OUT_VEB_BATCH(batch, 0);
+
+    ADVANCE_VEB_BATCH(batch);
+}
+
+VAStatus
+gen9_vebox_process_picture(VADriverContextP ctx,
+    struct intel_vebox_context *proc_ctx)
+{
+    VAStatus status;
+
+    status = gen75_vebox_init_pipe_params(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    status = gen75_vebox_init_filter_params(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    hsw_veb_pre_format_convert(ctx, proc_ctx);
+
+    status = gen75_vebox_ensure_surfaces(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    status = gen75_vebox_ensure_surfaces_storage(ctx, proc_ctx);
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    if (proc_ctx->format_convert_flags & POST_COPY_CONVERT) {
+        assert(proc_ctx->is_second_field);
+        /* directly copy the saved frame in the second call */
+    } else {
+        intel_batchbuffer_start_atomic_veb(proc_ctx->batch, 0x1000);
+        intel_batchbuffer_emit_mi_flush(proc_ctx->batch);
+        skl_veb_state_table_setup(ctx, proc_ctx);
+        skl_veb_state_command(ctx, proc_ctx);
+        skl_veb_surface_state(ctx, proc_ctx, INPUT_SURFACE);
+        skl_veb_surface_state(ctx, proc_ctx, OUTPUT_SURFACE);
+        bdw_veb_dndi_iecp_command(ctx, proc_ctx);
+        intel_batchbuffer_end_atomic(proc_ctx->batch);
+        intel_batchbuffer_flush(proc_ctx->batch);
+    }
+
+    hsw_veb_post_format_convert(ctx, proc_ctx);
+
+    return VA_STATUS_SUCCESS;
+}
diff --git a/src/gen75_vpp_vebox.h b/src/gen75_vpp_vebox.h
index a78a165..a0d5e2e 100644
--- a/src/gen75_vpp_vebox.h
+++ b/src/gen75_vpp_vebox.h
@@ -43,12 +43,14 @@
 
 #define VPP_DNDI_DN        0x00000001
 #define VPP_DNDI_DI        0x00000002
+#define VPP_DNDI_MASK      0x000000ff
 #define VPP_IECP_STD_STE   0x00000100
 #define VPP_IECP_ACE       0x00000200
 #define VPP_IECP_TCC       0x00000400
 #define VPP_IECP_PRO_AMP   0x00000800
 #define VPP_IECP_CSC       0x00001000
 #define VPP_IECP_AOI       0x00002000
+#define VPP_IECP_MASK      0x0000ff00
 #define MAX_FILTER_SUM     8
 
 #define PRE_FORMAT_CONVERT      0x01
@@ -65,7 +67,7 @@ enum {
     FRAME_OUT_CURRENT,
     FRAME_OUT_PREVIOUS,
     FRAME_OUT_STATISTIC,
-    FRAME_STORE_SUM,
+    FRAME_STORE_COUNT,
 };
 
 enum SURFACE_FORMAT{
@@ -87,9 +89,10 @@ enum SURFACE_FORMAT{
 };
 
 typedef struct veb_frame_store {
-    VASurfaceID surface_id;
-    unsigned int is_internal_surface;
     struct object_surface *obj_surface;
+    VASurfaceID surface_id; /* always relative to the input surface */
+    unsigned int is_internal_surface : 1;
+    unsigned int is_scratch_surface : 1;
 } VEBFrameStore;
 
 typedef struct veb_buffer {
@@ -119,7 +122,7 @@ struct intel_vebox_context
     int width_output;
     int height_output;
 
-    VEBFrameStore frame_store[FRAME_STORE_SUM];
+    VEBFrameStore frame_store[FRAME_STORE_COUNT];
 
     VEBBuffer dndi_state_table;
     VEBBuffer iecp_state_table;
@@ -127,8 +130,8 @@ struct intel_vebox_context
     VEBBuffer vertex_state_table;
 
     unsigned int  filters_mask;
-    int frame_order;
     int current_output;
+    int current_output_type; /* 0:Both, 1:Previous, 2:Current */
 
     VAProcPipelineParameterBuffer * pipeline_param;
     void * filter_dn;
@@ -140,6 +143,14 @@ struct intel_vebox_context
 
     unsigned int  filter_iecp_amp_num_elements;
     unsigned char format_convert_flags;
+
+    /* Temporary flags live until the current picture is processed */
+    unsigned int is_iecp_enabled        : 1;
+    unsigned int is_dn_enabled          : 1;
+    unsigned int is_di_enabled          : 1;
+    unsigned int is_di_adv_enabled      : 1;
+    unsigned int is_first_frame         : 1;
+    unsigned int is_second_field        : 1;
 };
 
 VAStatus gen75_vebox_process_picture(VADriverContextP ctx,
@@ -153,4 +164,7 @@ struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx);
 VAStatus gen8_vebox_process_picture(VADriverContextP ctx,
                          struct intel_vebox_context *proc_ctx);
 
+VAStatus gen9_vebox_process_picture(VADriverContextP ctx,
+                         struct intel_vebox_context *proc_ctx);
+
 #endif
diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c
index bfb95bf..376eeb6 100755
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -65,7 +65,7 @@ gen7_mfd_init_avc_surface(VADriverContextP ctx,
 
     if (!gen7_avc_surface) {
         gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1);
-        gen7_avc_surface->frame_store_id = -1;
+        gen7_avc_surface->base.frame_store_id = -1;
         assert((obj_surface->size & 0x3f) == 0);
         obj_surface->private_data = gen7_avc_surface;
     }
diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c
index 2d76816..314b882 100644
--- a/src/gen8_mfc.c
+++ b/src/gen8_mfc.c
@@ -42,6 +42,7 @@
 #include "gen6_mfc.h"
 #include "gen6_vme.h"
 #include "intel_media.h"
+#include <va/va_enc_jpeg.h>
 
 #define SURFACE_STATE_PADDED_SIZE               SURFACE_STATE_PADDED_SIZE_GEN8
 #define SURFACE_STATE_OFFSET(index)             (SURFACE_STATE_PADDED_SIZE * index)
@@ -52,6 +53,53 @@
 #define B0_STEP_REV		2
 #define IS_STEPPING_BPLUS(i965)	((i965->intel.revision) >= B0_STEP_REV)
 
+//Zigzag scan order of the the Luma and Chroma components
+//Note: Jpeg Spec ISO/IEC 10918-1, Figure A.6 shows the zigzag order differently.
+//The Spec is trying to show the zigzag pattern with number positions. The below
+//table will use the pattern shown by A.6 and map the position of the elements in the array
+static const uint32_t zigzag_direct[64] = {
+    0,   1,  8, 16,  9,  2,  3, 10,
+    17, 24, 32, 25, 18, 11,  4,  5,
+    12, 19, 26, 33, 40, 48, 41, 34,
+    27, 20, 13,  6,  7, 14, 21, 28,
+    35, 42, 49, 56, 57, 50, 43, 36,
+    29, 22, 15, 23, 30, 37, 44, 51,
+    58, 59, 52, 45, 38, 31, 39, 46,
+    53, 60, 61, 54, 47, 55, 62, 63
+};
+
+//Default Luminance quantization table
+//Source: Jpeg Spec ISO/IEC 10918-1, Annex K, Table K.1
+static const uint8_t jpeg_luma_quant[64] = {
+    16, 11, 10, 16, 24,  40,  51,  61,
+    12, 12, 14, 19, 26,  58,  60,  55,
+    14, 13, 16, 24, 40,  57,  69,  56,
+    14, 17, 22, 29, 51,  87,  80,  62,
+    18, 22, 37, 56, 68,  109, 103, 77,
+    24, 35, 55, 64, 81,  104, 113, 92,
+    49, 64, 78, 87, 103, 121, 120, 101,
+    72, 92, 95, 98, 112, 100, 103, 99    
+};
+
+//Default Chroma quantization table
+//Source: Jpeg Spec ISO/IEC 10918-1, Annex K, Table K.2
+static const uint8_t jpeg_chroma_quant[64] = {
+    17, 18, 24, 47, 99, 99, 99, 99,
+    18, 21, 26, 66, 99, 99, 99, 99,
+    24, 26, 56, 99, 99, 99, 99, 99,
+    47, 66, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99,
+    99, 99, 99, 99, 99, 99, 99, 99
+};
+
+
+static const int va_to_gen7_jpeg_hufftable[2] = {
+    MFX_HUFFTABLE_ID_Y,
+    MFX_HUFFTABLE_ID_UV
+};
+
 static const uint32_t gen8_mfc_batchbuffer_avc_intra[][4] = {
 #include "shaders/utils/mfc_batchbuffer_avc_intra.g7b"
 };
@@ -97,7 +145,8 @@ gen8_mfc_pipe_mode_select(VADriverContextP ctx,
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
 
     assert(standard_select == MFX_FORMAT_MPEG2 ||
-           standard_select == MFX_FORMAT_AVC);
+           standard_select == MFX_FORMAT_AVC   ||
+           standard_select == MFX_FORMAT_JPEG);
 
     BEGIN_BCS_BATCH(batch, 5);
 
@@ -110,7 +159,7 @@ gen8_mfc_pipe_mode_select(VADriverContextP ctx,
                   ((!!mfc_context->pre_deblocking_output.bo) << 8)  | /* Pre Deblocking Output */
                   (0 << 5)  | /* not in stitch mode */
                   (1 << 4)  | /* encoding mode */
-                  (standard_select << 0));  /* standard select: avc or mpeg2 */
+                  (standard_select << 0));  /* standard select: avc or mpeg2 or jpeg*/
     OUT_BCS_BATCH(batch,
                   (0 << 7)  | /* expand NOA bus flag */
                   (0 << 6)  | /* disable slice-level clock gating */
@@ -163,6 +212,7 @@ gen8_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     int vme_size;
+    unsigned int bse_offset;
 
     BEGIN_BCS_BATCH(batch, 26);
 
@@ -175,13 +225,22 @@ gen8_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
 
-    vme_size = vme_context->vme_output.size_block * vme_context->vme_output.num_blocks;
-    /* the DW6-10 is for MFX Indirect MV Object Base Address */
-    OUT_BCS_RELOC(batch, vme_context->vme_output.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
-    OUT_BCS_BATCH(batch, 0);
-    OUT_BCS_BATCH(batch, 0);
-    OUT_BCS_RELOC(batch, vme_context->vme_output.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, vme_size);
-    OUT_BCS_BATCH(batch, 0);
+    if(encoder_context->codec != CODEC_JPEG) {
+        vme_size = vme_context->vme_output.size_block * vme_context->vme_output.num_blocks;
+        /* the DW6-10 is for MFX Indirect MV Object Base Address */
+        OUT_BCS_RELOC(batch, vme_context->vme_output.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+        OUT_BCS_BATCH(batch, 0);
+        OUT_BCS_BATCH(batch, 0);
+        OUT_BCS_RELOC(batch, vme_context->vme_output.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, vme_size);
+        OUT_BCS_BATCH(batch, 0);
+    } else {
+        /* No VME for JPEG */
+        OUT_BCS_BATCH(batch, 0);
+        OUT_BCS_BATCH(batch, 0);
+        OUT_BCS_BATCH(batch, 0);
+        OUT_BCS_BATCH(batch, 0);
+        OUT_BCS_BATCH(batch, 0);
+    }
 
     /* the DW11-15 is for MFX IT-COFF. Not used on encoder */
     OUT_BCS_BATCH(batch, 0);
@@ -198,10 +257,11 @@ gen8_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
     OUT_BCS_BATCH(batch, 0);
 
     /* the DW21-25 is for MFC Indirect PAK-BSE Object Base Address for Encoder*/	
+    bse_offset = (encoder_context->codec == CODEC_JPEG) ? (mfc_context->mfc_indirect_pak_bse_object.offset) : 0;
     OUT_BCS_RELOC(batch,
                   mfc_context->mfc_indirect_pak_bse_object.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
-                  0);
+                  bse_offset);
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
 	
@@ -406,13 +466,19 @@ static void gen8_mfc_init(VADriverContextP ctx,
         VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
         width_in_mbs = pSequenceParameter->picture_width_in_mbs;
         height_in_mbs = pSequenceParameter->picture_height_in_mbs;
-    } else {
+    } else if (encoder_context->codec == CODEC_MPEG2) {
         VAEncSequenceParameterBufferMPEG2 *pSequenceParameter = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer;
 
         assert(encoder_context->codec == CODEC_MPEG2);
 
         width_in_mbs = ALIGN(pSequenceParameter->picture_width, 16) / 16;
         height_in_mbs = ALIGN(pSequenceParameter->picture_height, 16) / 16;
+    } else {
+        assert(encoder_context->codec == CODEC_JPEG);
+        VAEncPictureParameterBufferJPEG *pic_param = (VAEncPictureParameterBufferJPEG *)encode_state->pic_param_ext->buffer;
+
+        width_in_mbs = ALIGN(pic_param->picture_width, 16) / 16;
+        height_in_mbs = ALIGN(pic_param->picture_height, 16) / 16;
     }
 
     slice_batchbuffer_size = 64 * width_in_mbs * height_in_mbs + 4096 +
@@ -2351,6 +2417,789 @@ gen8_mfc_mpeg2_encode_picture(VADriverContextP ctx,
     return VA_STATUS_SUCCESS;
 }
 
+/* JPEG encode methods */
+
+static VAStatus
+intel_mfc_jpeg_prepare(VADriverContextP ctx, 
+                        struct encode_state *encode_state,
+                        struct intel_encoder_context *encoder_context)
+{
+    struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
+    struct object_surface *obj_surface; 
+    struct object_buffer *obj_buffer;
+    struct i965_coded_buffer_segment *coded_buffer_segment;
+    VAStatus vaStatus = VA_STATUS_SUCCESS;
+    dri_bo *bo;
+   
+    /* input YUV surface */
+    obj_surface = encode_state->input_yuv_object;
+    mfc_context->uncompressed_picture_source.bo = obj_surface->bo;
+    dri_bo_reference(mfc_context->uncompressed_picture_source.bo);
+
+    /* coded buffer */
+    obj_buffer = encode_state->coded_buf_object;
+    bo = obj_buffer->buffer_store->bo;
+    mfc_context->mfc_indirect_pak_bse_object.bo = bo;
+    mfc_context->mfc_indirect_pak_bse_object.offset = I965_CODEDBUFFER_HEADER_SIZE;
+    mfc_context->mfc_indirect_pak_bse_object.end_offset = ALIGN(obj_buffer->size_element - 0x1000, 0x1000);
+    dri_bo_reference(mfc_context->mfc_indirect_pak_bse_object.bo);
+
+    /* set the internal flag to 0 to indicate the coded size is unknown */
+    dri_bo_map(bo, 1);
+    coded_buffer_segment = (struct i965_coded_buffer_segment *)bo->virtual;
+    coded_buffer_segment->mapped = 0;
+    coded_buffer_segment->codec = encoder_context->codec;
+    dri_bo_unmap(bo);
+
+    return vaStatus;
+}
+
+
+static void 
+gen8_mfc_jpeg_set_surface_state(VADriverContextP ctx,
+                        struct intel_encoder_context *encoder_context,
+                        struct encode_state *encode_state)
+{
+    struct intel_batchbuffer *batch = encoder_context->base.batch;
+    struct object_surface *obj_surface = encode_state->input_yuv_object;
+    unsigned int input_fourcc;
+    unsigned int y_cb_offset;
+    unsigned int y_cr_offset;
+    unsigned int surface_format;
+
+    assert(obj_surface);
+
+    y_cb_offset = obj_surface->y_cb_offset;
+    y_cr_offset = obj_surface->y_cr_offset;
+    input_fourcc = obj_surface->fourcc;
+
+    surface_format = (obj_surface->fourcc == VA_FOURCC_Y800) ?
+        MFX_SURFACE_MONOCHROME : MFX_SURFACE_PLANAR_420_8;
+        
+        
+     switch (input_fourcc) {
+        case VA_FOURCC_Y800: {
+            surface_format = MFX_SURFACE_MONOCHROME;
+            break;
+        }
+        case VA_FOURCC_NV12: { 
+            surface_format = MFX_SURFACE_PLANAR_420_8;
+            break;
+        }      
+        case VA_FOURCC_UYVY: { 
+            surface_format = MFX_SURFACE_YCRCB_SWAPY;
+            break;
+        }
+        case VA_FOURCC_YUY2: { 
+            surface_format = MFX_SURFACE_YCRCB_NORMAL;
+            break;
+        }
+        case VA_FOURCC_RGBA:
+        case VA_FOURCC_444P: {
+            surface_format = MFX_SURFACE_R8G8B8A8_UNORM;
+            break;
+        }
+    }
+
+    BEGIN_BCS_BATCH(batch, 6);
+
+    OUT_BCS_BATCH(batch, MFX_SURFACE_STATE | (6 - 2));
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch,
+                  ((obj_surface->orig_height - 1) << 18) |
+                  ((obj_surface->orig_width - 1) << 4));
+    OUT_BCS_BATCH(batch,
+                  (surface_format << 28) | /* Surface Format */
+                  (0 << 27) | /* must be 1 for interleave U/V, hardware requirement for AVC/VC1/MPEG and 0 for JPEG */
+                  (0 << 22) | /* surface object control state, FIXME??? */
+                  ((obj_surface->width - 1) << 3) | /* pitch */
+                  (0 << 2)  | /* must be 0 for interleave U/V */
+                  (1 << 1)  | /* must be tiled */
+                  (I965_TILEWALK_YMAJOR << 0));  /* tile walk, TILEWALK_YMAJOR */
+    OUT_BCS_BATCH(batch,
+                  (0 << 16) | /* X offset for U(Cb), must be 0 */
+                  (y_cb_offset << 0)); /* Y offset for U(Cb) */
+    OUT_BCS_BATCH(batch,
+                  (0 << 16) | /* X offset for V(Cr), must be 0 */
+                  (y_cr_offset << 0)); /* Y offset for V(Cr), must be 0 for video codec, non-zoeo for JPEG */
+                 
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen8_mfc_jpeg_pic_state(VADriverContextP ctx,
+                        struct intel_encoder_context *encoder_context,
+                        struct encode_state *encode_state)
+{
+    struct intel_batchbuffer *batch = encoder_context->base.batch;
+    struct object_surface *obj_surface = encode_state->input_yuv_object;
+    VAEncPictureParameterBufferJPEG *pic_param;
+    unsigned int  surface_format;
+    unsigned int  frame_width_in_blks;
+    unsigned int  frame_height_in_blks;
+    unsigned int  pixels_in_horizontal_lastMCU;
+    unsigned int  pixels_in_vertical_lastMCU;
+    unsigned int  input_surface_format;
+    unsigned int  output_mcu_format;
+    unsigned int  picture_width;
+    unsigned int  picture_height;  
+
+    assert(encode_state->pic_param_ext && encode_state->pic_param_ext->buffer);
+    assert(obj_surface);
+    pic_param = (VAEncPictureParameterBufferJPEG *)encode_state->pic_param_ext->buffer;
+    surface_format = obj_surface->fourcc;
+    picture_width = pic_param->picture_width;
+    picture_height = pic_param->picture_height;
+    
+    switch (surface_format) {
+        case VA_FOURCC_Y800: {
+            input_surface_format = JPEG_ENC_SURFACE_Y8; 
+            output_mcu_format = JPEG_ENC_MCU_YUV400;
+            break;
+        }
+        case VA_FOURCC_NV12: { 
+            input_surface_format = JPEG_ENC_SURFACE_NV12; 
+            output_mcu_format = JPEG_ENC_MCU_YUV420; 
+            break;
+        }      
+        case VA_FOURCC_UYVY: { 
+            input_surface_format = JPEG_ENC_SURFACE_UYVY; 
+            output_mcu_format = JPEG_ENC_MCU_YUV422H_2Y; 
+            break;
+        }
+        case VA_FOURCC_YUY2: { 
+            input_surface_format = JPEG_ENC_SURFACE_YUY2; 
+            output_mcu_format = JPEG_ENC_MCU_YUV422H_2Y; 
+            break;
+        }
+
+        case VA_FOURCC_RGBA:
+        case VA_FOURCC_444P: { 
+            input_surface_format = JPEG_ENC_SURFACE_RGB; 
+            output_mcu_format = JPEG_ENC_MCU_RGB; 
+            break;
+        }
+        default : {
+            input_surface_format = JPEG_ENC_SURFACE_NV12; 
+            output_mcu_format = JPEG_ENC_MCU_YUV420;
+            break;
+        }
+    }
+
+    
+    switch (output_mcu_format) {
+        
+        case JPEG_ENC_MCU_YUV400:
+        case JPEG_ENC_MCU_RGB: {
+            pixels_in_horizontal_lastMCU = (picture_width % 8);
+            pixels_in_vertical_lastMCU = (picture_height % 8); 
+
+            //H1=1,V1=1 for YUV400 and YUV444. So, compute these values accordingly
+            frame_width_in_blks = ((picture_width + 7) / 8); 
+            frame_height_in_blks = ((picture_height + 7) / 8);
+            break;
+        }
+        
+        case JPEG_ENC_MCU_YUV420: {        
+            if((picture_width % 2) == 0) 
+                pixels_in_horizontal_lastMCU = picture_width % 16; 
+            else 
+                pixels_in_horizontal_lastMCU   = ((picture_width % 16) + 1) % 16; 
+            
+            if((picture_height % 2) == 0) 
+                pixels_in_vertical_lastMCU     = picture_height % 16; 
+            else 
+                pixels_in_vertical_lastMCU   = ((picture_height % 16) + 1) % 16; 
+
+            //H1=2,V1=2 for YUV420. So, compute these values accordingly
+            frame_width_in_blks = ((picture_width + 15) / 16) * 2;
+            frame_height_in_blks = ((picture_height + 15) / 16) * 2;
+            break;
+        }
+        
+        case JPEG_ENC_MCU_YUV422H_2Y: {
+            if(picture_width % 2 == 0) 
+                pixels_in_horizontal_lastMCU = picture_width % 16; 
+            else 
+                pixels_in_horizontal_lastMCU = ((picture_width % 16) + 1) % 16; 
+            
+            pixels_in_vertical_lastMCU = picture_height % 8;
+            
+            //H1=2,V1=1 for YUV422H_2Y. So, compute these values accordingly
+            frame_width_in_blks = ((picture_width + 15) / 16) * 2;
+            frame_height_in_blks = ((picture_height + 7) / 8);
+            break;            
+        }       
+    } //end of switch
+   
+    BEGIN_BCS_BATCH(batch, 3);
+    /* DWORD 0 */
+    OUT_BCS_BATCH(batch, MFX_JPEG_PIC_STATE | (3 - 2)); 
+    /* DWORD 1 */
+    OUT_BCS_BATCH(batch,
+                  ( pixels_in_horizontal_lastMCU << 26) |    /* Pixels In Horizontal Last MCU */
+                  ( pixels_in_vertical_lastMCU << 21)   |    /* Pixels In Vertical Last MCU */
+                  ( input_surface_format << 8)          |    /* Input Surface format */
+                  ( output_mcu_format << 0));                /* Output MCU Structure */
+    /* DWORD 2 */
+    OUT_BCS_BATCH(batch,
+                  ((frame_height_in_blks - 1) << 16)    |   /* Frame Height In Blks Minus 1 */
+                  (JPEG_ENC_ROUND_QUANT_DEFAULT  << 13) |   /* Rounding Quant set to default value 0 */
+                  ((frame_width_in_blks - 1) << 0));        /* Frame Width In Blks Minus 1 */
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void 
+get_reciprocal_dword_qm(unsigned char *raster_qm, uint32_t *dword_qm)
+{
+    int i = 0, j = 0;
+    short reciprocal_qm[64];
+    
+    for(i=0; i<64; i++) {
+        reciprocal_qm[i] = 65535/(raster_qm[i]);           
+    }
+    
+    for(i=0; i<64; i++) {
+        dword_qm[j] = ((reciprocal_qm[i+1] <<16) | (reciprocal_qm[i]));
+        j++;
+        i++;
+    }    
+    
+}
+
+
+static void 
+gen8_mfc_jpeg_fqm_state(VADriverContextP ctx,
+                        struct intel_encoder_context *encoder_context,
+                        struct encode_state *encode_state)
+{
+    uint8_t quality = 0;
+    uint32_t temp, i = 0, j = 0, dword_qm[32];
+    VAEncPictureParameterBufferJPEG *pic_param;
+    VAQMatrixBufferJPEG *qmatrix;
+    unsigned char raster_qm[64];
+    struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
+    
+    assert(encode_state->pic_param_ext && encode_state->pic_param_ext->buffer);
+    pic_param = (VAEncPictureParameterBufferJPEG *)encode_state->pic_param_ext->buffer;
+    quality = pic_param->quality;
+    
+    //If the app sends the qmatrix, use it, buffer it for using it with the next frames 
+    //The app can send qmatrix for the first frame and not send for the subsequent frames
+    if(encode_state->q_matrix && encode_state->q_matrix->buffer) {
+        qmatrix = (VAQMatrixBufferJPEG *)encode_state->q_matrix->buffer;
+
+        mfc_context->buffered_qmatrix.load_lum_quantiser_matrix = 1;
+        memcpy(mfc_context->buffered_qmatrix.lum_quantiser_matrix, qmatrix->lum_quantiser_matrix, 64 * (sizeof(unsigned char)));
+
+        if(pic_param->num_components > 1) {
+            mfc_context->buffered_qmatrix.load_chroma_quantiser_matrix = 1;
+            memcpy(mfc_context->buffered_qmatrix.chroma_quantiser_matrix, qmatrix->chroma_quantiser_matrix, 64 * (sizeof(unsigned char)));
+        } else {
+            mfc_context->buffered_qmatrix.load_chroma_quantiser_matrix = 0;
+        }
+
+    } else {
+        //If the app doesnt send the qmatrix, use the buffered/default qmatrix
+        qmatrix = &mfc_context->buffered_qmatrix;
+        qmatrix->load_lum_quantiser_matrix = 1;
+        qmatrix->load_chroma_quantiser_matrix = (pic_param->num_components > 1) ? 1 : 0;
+    }   
+ 
+    quality = (quality < 50) ? (5000/quality) : (200 - (quality*2)); 
+    quality = (quality == 0) ? 1 : quality;
+    
+    //Step 1. Apply Quality factor and clip to range [1, 255] for luma and chroma Quantization matrices
+    //Step 2. HW expects the 1/Q[i] values in the qm sent, so get reciprocals
+    //Step 3. HW also expects 32 dwords, hence combine 2 (1/Q) values into 1 dword
+    //Step 4. Send the Quantization matrix to the HW, use gen8_mfc_fqm_state
+    
+    //For luma (Y or R)
+    if(qmatrix->load_lum_quantiser_matrix) {
+        //apply quality to lum_quantiser_matrix
+        for(i=0; i < 64; i++) {
+            temp = qmatrix->lum_quantiser_matrix[i] * (quality/100);
+            //clamp to range [1,255]
+            temp = (temp > 255) ? 255 : temp;
+            temp = (temp < 1) ? 1 : temp;
+            qmatrix->lum_quantiser_matrix[i] = (unsigned char)temp;
+        }       
+        
+        //For VAAPI, the VAQMatrixBuffer needs to be in zigzag order. 
+        //The App should send it in zigzag. Now, the driver has to extract the raster from it. 
+        for (j = 0; j < 64; j++)
+            raster_qm[zigzag_direct[j]] = qmatrix->lum_quantiser_matrix[j];
+
+        //Convert the raster order(row-ordered) to the column-raster (column by column).
+        //To be consistent with the other encoders, send it in column order.
+        //Need to double check if our HW expects col or row raster.
+        for (j = 0; j < 64; j++) {
+            int row = j / 8, col = j % 8;
+            raster_qm[col * 8 + row] = raster_qm[j]; 
+        }
+        
+        //Convert to raster QM to reciprocal. HW expects values in reciprocal.
+        get_reciprocal_dword_qm(raster_qm, dword_qm);
+        
+        //send the luma qm to the command buffer
+        gen8_mfc_fqm_state(ctx, MFX_QM_JPEG_LUMA_Y_QUANTIZER_MATRIX, dword_qm, 32, encoder_context);
+    } 
+    
+    //For Chroma, if chroma exists (Cb, Cr or G, B)
+    if(qmatrix->load_chroma_quantiser_matrix) {
+        //apply quality to chroma_quantiser_matrix
+        for(i=0; i < 64; i++) {
+            temp = qmatrix->chroma_quantiser_matrix[i] * (quality/100);
+            //clamp to range [1,255]
+            temp = (temp > 255) ? 255 : temp;
+            temp = (temp < 1) ? 1 : temp;
+            qmatrix->chroma_quantiser_matrix[i] = (unsigned char)temp;
+        }
+        
+        //For VAAPI, the VAQMatrixBuffer needs to be in zigzag order. 
+        //The App should send it in zigzag. Now, the driver has to extract the raster from it. 
+        for (j = 0; j < 64; j++)
+            raster_qm[zigzag_direct[j]] = qmatrix->chroma_quantiser_matrix[j];
+        
+        //Convert the raster order(row-ordered) to the column-raster (column by column).
+        //To be consistent with the other encoders, send it in column order.
+        //Need to double check if our HW expects col or row raster.
+        for (j = 0; j < 64; j++) {
+            int row = j / 8, col = j % 8;
+            raster_qm[col * 8 + row] = raster_qm[j]; 
+        }
+
+
+        //Convert to raster QM to reciprocal. HW expects values in reciprocal.
+        get_reciprocal_dword_qm(raster_qm, dword_qm);
+
+        //send the same chroma qm to the command buffer (for both U,V or G,B)
+        gen8_mfc_fqm_state(ctx, MFX_QM_JPEG_CHROMA_CB_QUANTIZER_MATRIX, dword_qm, 32, encoder_context);
+        gen8_mfc_fqm_state(ctx, MFX_QM_JPEG_CHROMA_CR_QUANTIZER_MATRIX, dword_qm, 32, encoder_context);        
+    }
+}
+
+
+//Translation of Table K.5 into code: This method takes the huffval from the 
+//Huffmantable buffer and converts into index for the coefficients and size tables
+uint8_t map_huffval_to_index(uint8_t huff_val) 
+{
+    uint8_t index = 0;
+
+    if(huff_val < 0xF0) {
+        index = (((huff_val >> 4) & 0x0F) * 0xA) + (huff_val & 0x0F);
+    } else {
+        index = 1 + (((huff_val >> 4) & 0x0F) * 0xA) + (huff_val & 0x0F);
+    }
+
+    return index;
+}
+
+
+//Implementation of Flow chart Annex C  - Figure C.1
+static void
+generate_huffman_codesizes_table(uint8_t *bits, uint8_t *huff_size_table, uint8_t *lastK) 
+{
+    uint8_t i=1, j=1, k=0;
+
+    while(i <= 16) {
+        while(j <= (uint8_t)bits[i-1]) {
+            huff_size_table[k] = i;
+            k = k+1;
+            j = j+1;
+        }
+        
+        i = i+1;
+        j = 1;
+    }
+    huff_size_table[k] = 0;
+    (*lastK) = k;    
+}
+
+//Implementation of Flow chart Annex C - Figure C.2
+static void
+generate_huffman_codes_table(uint8_t *huff_size_table, uint16_t *huff_code_table)
+{
+    uint8_t k=0;
+    uint16_t code=0;
+    uint8_t si=huff_size_table[k];
+    
+    while(huff_size_table[k] != 0) {
+    
+        while(huff_size_table[k] == si) {
+            
+            // An huffman code can never be 0xFFFF. Replace it with 0 if 0xFFFF 
+            if(code == 0xFFFF) {
+                code = 0x0000;
+            }
+
+            huff_code_table[k] = code;
+            code = code+1;
+            k = k+1;
+        }
+    
+        code <<= 1;
+        si = si+1;
+    }
+    
+}
+
+//Implementation of Flow chat Annex C - Figure C.3
+static void
+generate_ordered_codes_table(uint8_t *huff_vals, uint8_t *huff_size_table, uint16_t *huff_code_table, uint8_t type, uint8_t lastK)
+{
+    uint8_t huff_val_size=0, i=0, k=0;
+    
+    huff_val_size = (type == 0) ? 12 : 162; 
+    uint8_t huff_si_table[huff_val_size]; 
+    uint16_t huff_co_table[huff_val_size];
+    
+    memset(huff_si_table, 0, huff_val_size);
+    memset(huff_co_table, 0, huff_val_size);
+    
+    do {
+        i = map_huffval_to_index(huff_vals[k]);
+        huff_co_table[i] = huff_code_table[k];
+        huff_si_table[i] = huff_size_table[k];
+        k++;
+    } while(k < lastK);
+    
+    memcpy(huff_size_table, huff_si_table, sizeof(uint8_t)*huff_val_size);
+    memcpy(huff_code_table, huff_co_table, sizeof(uint16_t)*huff_val_size);
+}
+
+
+//This method converts the huffman table to code words which is needed by the HW
+//Flowcharts from Jpeg Spec Annex C - Figure C.1, Figure C.2, Figure C.3 are used here
+static void
+convert_hufftable_to_codes(VAHuffmanTableBufferJPEGBaseline *huff_buffer, uint32_t *table, uint8_t type, uint8_t index)
+{
+    uint8_t lastK = 0, i=0; 
+    uint8_t huff_val_size = 0;
+    uint8_t *huff_bits, *huff_vals;
+
+    huff_val_size = (type == 0) ? 12 : 162; 
+    uint8_t huff_size_table[huff_val_size+1]; //The +1 for adding 0 at the end of huff_val_size
+    uint16_t huff_code_table[huff_val_size];
+
+    memset(huff_size_table, 0, huff_val_size);
+    memset(huff_code_table, 0, huff_val_size);
+
+    huff_bits = (type == 0) ? (huff_buffer->huffman_table[index].num_dc_codes) : (huff_buffer->huffman_table[index].num_ac_codes);
+    huff_vals = (type == 0) ? (huff_buffer->huffman_table[index].dc_values) : (huff_buffer->huffman_table[index].ac_values);
+    
+
+    //Generation of table of Huffman code sizes
+    generate_huffman_codesizes_table(huff_bits, huff_size_table, &lastK);
+       
+    //Generation of table of Huffman codes
+    generate_huffman_codes_table(huff_size_table, huff_code_table);
+       
+    //Ordering procedure for encoding procedure code tables
+    generate_ordered_codes_table(huff_vals, huff_size_table, huff_code_table, type, lastK);
+
+    //HW expects Byte0: Code length; Byte1,Byte2: Code Word, Byte3: Dummy
+    //Since IA is littlended, &, | and << accordingly to store the values in the DWord.
+    for(i=0; i<huff_val_size; i++) {
+        table[i] = 0;
+        table[i] = ((huff_size_table[i] & 0xFF) | ((huff_code_table[i] & 0xFFFF) << 8));
+    }
+
+}
+
+//send the huffman table using MFC_JPEG_HUFF_TABLE_STATE
+static void
+gen8_mfc_jpeg_huff_table_state(VADriverContextP ctx,
+                                           struct encode_state *encode_state,
+                                           struct intel_encoder_context *encoder_context,
+                                           int num_tables)
+{
+    VAHuffmanTableBufferJPEGBaseline *huff_buffer;
+    struct intel_batchbuffer *batch = encoder_context->base.batch;
+    uint8_t index;
+    uint32_t dc_table[12], ac_table[162]; 
+    
+    assert(encode_state->huffman_table && encode_state->huffman_table->buffer);
+    huff_buffer = (VAHuffmanTableBufferJPEGBaseline *)encode_state->huffman_table->buffer;
+
+    memset(dc_table, 0, 12);
+    memset(ac_table, 0, 162);
+
+    for (index = 0; index < num_tables; index++) {
+        int id = va_to_gen7_jpeg_hufftable[index];
+ 
+        if (!huff_buffer->load_huffman_table[index])
+            continue;
+     
+        //load DC table with 12 DWords
+        convert_hufftable_to_codes(huff_buffer, dc_table, 0, index);  //0 for Dc
+
+        //load AC table with 162 DWords 
+        convert_hufftable_to_codes(huff_buffer, ac_table, 1, index);  //1 for AC 
+
+        BEGIN_BCS_BATCH(batch, 176);
+        OUT_BCS_BATCH(batch, MFC_JPEG_HUFF_TABLE_STATE | (176 - 2));
+        OUT_BCS_BATCH(batch, id); //Huff table id
+
+        //DWord 2 - 13 has DC_TABLE
+        intel_batchbuffer_data(batch, dc_table, 12*4);
+
+        //Dword 14 -175 has AC_TABLE
+        intel_batchbuffer_data(batch, ac_table, 162*4);
+        ADVANCE_BCS_BATCH(batch);
+    }    
+}
+
+
+//This method is used to compute the MCU count used for setting MFC_JPEG_SCAN_OBJECT
+static void get_Y_sampling_factors(uint32_t surface_format, uint8_t *h_factor, uint8_t *v_factor)
+{ 
+    switch (surface_format) {
+        case VA_FOURCC_Y800: {
+            (* h_factor) = 1; 
+            (* v_factor) = 1;
+            break;
+        }
+        case VA_FOURCC_NV12: { 
+            (* h_factor) = 2;             
+            (* v_factor) = 2;
+            break;
+        }      
+        case VA_FOURCC_UYVY: { 
+            (* h_factor) = 2; 
+            (* v_factor) = 1;
+            break;
+        }
+        case VA_FOURCC_YUY2: { 
+            (* h_factor) = 2; 
+            (* v_factor) = 1;
+            break;
+        }
+        case VA_FOURCC_RGBA:
+        case VA_FOURCC_444P: { 
+            (* h_factor) = 1; 
+            (* v_factor) = 1;
+            break;
+        }
+        default : { //May be  have to insert error handling here. For now just use as below
+            (* h_factor) = 1; 
+            (* v_factor) = 1;
+            break;
+        }
+    }
+}
+
+//set MFC_JPEG_SCAN_OBJECT
+static void
+gen8_mfc_jpeg_scan_object(VADriverContextP ctx,
+                                           struct encode_state *encode_state,
+                                           struct intel_encoder_context *encoder_context)
+{
+    uint32_t mcu_count, surface_format, Mx, My;
+    uint8_t i, horizontal_sampling_factor, vertical_sampling_factor, huff_ac_table=0, huff_dc_table=0;
+    uint8_t is_last_scan = 1;    //Jpeg has only 1 scan per frame. When last scan, HW inserts EOI code.
+    uint8_t head_present_flag=1; //Header has tables and app data 
+    uint16_t num_components, restart_interval;   //Specifies number of MCUs in an ECS.
+    VAEncSliceParameterBufferJPEG *slice_param;
+    VAEncPictureParameterBufferJPEG *pic_param;
+    
+    struct intel_batchbuffer *batch = encoder_context->base.batch;
+    struct object_surface *obj_surface = encode_state->input_yuv_object;
+    
+    assert(encode_state->slice_params_ext[0] && encode_state->slice_params_ext[0]->buffer);
+    assert(encode_state->pic_param_ext && encode_state->pic_param_ext->buffer);
+    assert(obj_surface);
+    pic_param = (VAEncPictureParameterBufferJPEG *)encode_state->pic_param_ext->buffer;
+    slice_param = (VAEncSliceParameterBufferJPEG *)encode_state->slice_params_ext[0]->buffer;
+    surface_format = obj_surface->fourcc;
+    
+    get_Y_sampling_factors(surface_format, &horizontal_sampling_factor, &vertical_sampling_factor);
+    
+    // Mx = #MCUs in a row, My = #MCUs in a column
+    Mx = (pic_param->picture_width + (horizontal_sampling_factor*8 -1))/(horizontal_sampling_factor*8);
+    My = (pic_param->picture_height + (vertical_sampling_factor*8 -1))/(vertical_sampling_factor*8);
+    mcu_count = (Mx * My);
+ 
+    num_components = pic_param->num_components;    
+    restart_interval = slice_param->restart_interval;
+    
+    //Depending on number of components and values set for table selectors, 
+    //only those bits are set in 24:22 for AC table, 20:18 for DC table
+    for(i=0; i<num_components; i++) {
+        huff_ac_table |= ((slice_param->components[i].ac_table_selector)<<i);
+        huff_dc_table |= ((slice_param->components[i].dc_table_selector)<<i);
+    }
+    
+    
+    BEGIN_BCS_BATCH(batch, 3);
+    /* DWORD 0 */
+    OUT_BCS_BATCH(batch, MFC_JPEG_SCAN_OBJECT | (3 - 2)); 
+    /* DWORD 1 */
+    OUT_BCS_BATCH(batch, mcu_count << 0);       //MCU Count
+    /* DWORD 2 */
+    OUT_BCS_BATCH(batch,
+                  (huff_ac_table << 22)     |   //Huffman AC Table
+                  (huff_dc_table << 18)     |   //Huffman DC Table
+                  (head_present_flag << 17) |   //Head present flag
+                  (is_last_scan << 16)      |   //Is last scan
+                  (restart_interval << 0));     //Restart Interval
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen8_mfc_jpeg_pak_insert_object(struct intel_encoder_context *encoder_context, unsigned int *insert_data, 
+                                int length_in_dws, int data_bits_in_last_dw, int is_last_header, 
+                                int is_end_of_slice)
+{
+    struct intel_batchbuffer *batch = encoder_context->base.batch;
+    assert(batch);
+    
+    if (data_bits_in_last_dw == 0)
+        data_bits_in_last_dw = 32;
+
+    BEGIN_BCS_BATCH(batch, length_in_dws + 2);
+
+    OUT_BCS_BATCH(batch, MFX_INSERT_OBJECT | (length_in_dws + 2 - 2));
+    //DWord 1
+    OUT_BCS_BATCH(batch,
+                  (0 << 16) |                    //DataByteOffset 0 for JPEG Encoder
+                  (0 << 15) |                    //HeaderLengthExcludeFrmSize 0 for JPEG Encoder
+                  (data_bits_in_last_dw << 8) |  //DataBitsInLastDW
+                  (0 << 4) |                     //SkipEmulByteCount 0 for JPEG Encoder
+                  (0 << 3) |                     //EmulationFlag 0 for JPEG Encoder
+                  ((!!is_last_header) << 2) |    //LastHeaderFlag
+                  ((!!is_end_of_slice) << 1) |   //EndOfSliceFlag
+                  (1 << 0));                     //BitstreamStartReset 1 for JPEG Encoder
+    //Data Paylaod
+    intel_batchbuffer_data(batch, insert_data, length_in_dws*4);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+
+//send the jpeg headers to HW using MFX_PAK_INSERT_OBJECT
+static void
+gen8_mfc_jpeg_add_headers(VADriverContextP ctx,
+                                           struct encode_state *encode_state,
+                                           struct intel_encoder_context *encoder_context)
+{
+    if (encode_state->packed_header_data_ext) {
+        VAEncPackedHeaderParameterBuffer *param = NULL;
+        unsigned int *header_data = (unsigned int *)(*encode_state->packed_header_data_ext)->buffer;
+        unsigned int length_in_bits;
+
+        param = (VAEncPackedHeaderParameterBuffer *)(*encode_state->packed_header_params_ext)->buffer;
+        length_in_bits = param->bit_length;
+
+        gen8_mfc_jpeg_pak_insert_object(encoder_context, 
+                                        header_data, 
+                                        ALIGN(length_in_bits, 32) >> 5,
+                                        length_in_bits & 0x1f,
+                                        1,
+                                        1);
+    }
+}
+
+//Initialize the buffered_qmatrix with the default qmatrix in the driver.
+//If the app sends the qmatrix, this will be replaced with the one app sends.
+static void 
+jpeg_init_default_qmatrix(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+{
+    int i=0;
+    struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
+ 
+    //Load the the QM in zigzag order. If app sends QM, it is always in zigzag order.
+    for(i=0; i<64; i++)
+       mfc_context->buffered_qmatrix.lum_quantiser_matrix[i] = jpeg_luma_quant[zigzag_direct[i]];
+
+    for(i=0; i<64; i++)
+        mfc_context->buffered_qmatrix.chroma_quantiser_matrix[i] = jpeg_chroma_quant[zigzag_direct[i]];
+}    
+ 
+/* This is at the picture level */
+static void
+gen8_mfc_jpeg_pipeline_picture_programing(VADriverContextP ctx,
+                                           struct encode_state *encode_state,
+                                           struct intel_encoder_context *encoder_context)
+{
+    int i, j, component, max_selector = 0;
+    VAEncSliceParameterBufferJPEG *slice_param;
+    
+    gen8_mfc_pipe_mode_select(ctx, MFX_FORMAT_JPEG, encoder_context);
+    gen8_mfc_jpeg_set_surface_state(ctx, encoder_context, encode_state);
+    gen8_mfc_pipe_buf_addr_state(ctx, encoder_context);
+    gen8_mfc_ind_obj_base_addr_state(ctx, encoder_context);
+    gen8_mfc_bsp_buf_base_addr_state(ctx, encoder_context);
+    gen8_mfc_jpeg_pic_state(ctx, encoder_context, encode_state);
+    
+    //do the slice level encoding here
+    gen8_mfc_jpeg_fqm_state(ctx, encoder_context, encode_state);
+
+    //I dont think I need this for loop. Just to be consistent with other encoding logic...
+    for(i = 0; i < encode_state->num_slice_params_ext; i++) {
+        assert(encode_state->slice_params && encode_state->slice_params_ext[i]->buffer);
+        slice_param = (VAEncSliceParameterBufferJPEG *)encode_state->slice_params_ext[i]->buffer;
+        
+        for(j = 0; j < encode_state->slice_params_ext[i]->num_elements; j++) {
+            
+            for(component = 0; component < slice_param->num_components; component++) {
+                if(max_selector < slice_param->components[component].dc_table_selector)
+                    max_selector = slice_param->components[component].dc_table_selector;
+                
+                if (max_selector < slice_param->components[component].ac_table_selector)
+                    max_selector = slice_param->components[component].ac_table_selector;
+            }
+            
+            slice_param++;
+        }
+    }    
+
+    assert(max_selector < 2);
+    //send the huffman table using MFC_JPEG_HUFF_TABLE
+    gen8_mfc_jpeg_huff_table_state(ctx, encode_state, encoder_context, max_selector+1);
+    //set MFC_JPEG_SCAN_OBJECT
+    gen8_mfc_jpeg_scan_object(ctx, encode_state, encoder_context);
+    //add headers using MFX_PAK_INSERT_OBJECT (it is refered as MFX_INSERT_OBJECT in this driver code)
+    gen8_mfc_jpeg_add_headers(ctx, encode_state, encoder_context);
+       
+}
+
+static void
+gen8_mfc_jpeg_pipeline_programing(VADriverContextP ctx,
+                                   struct encode_state *encode_state,
+                                   struct intel_encoder_context *encoder_context)
+{
+    struct intel_batchbuffer *batch = encoder_context->base.batch;
+    
+    // begin programing
+    intel_batchbuffer_start_atomic_bcs(batch, 0x4000); 
+    intel_batchbuffer_emit_mi_flush(batch);
+    
+    // picture level programing
+    gen8_mfc_jpeg_pipeline_picture_programing(ctx, encode_state, encoder_context);
+
+    // end programing
+    intel_batchbuffer_end_atomic(batch);
+
+}
+
+
+static VAStatus
+gen8_mfc_jpeg_encode_picture(VADriverContextP ctx, 
+                              struct encode_state *encode_state,
+                              struct intel_encoder_context *encoder_context)
+{
+    gen8_mfc_init(ctx, encode_state, encoder_context);
+    intel_mfc_jpeg_prepare(ctx, encode_state, encoder_context);
+    /*Programing bcs pipeline*/
+    gen8_mfc_jpeg_pipeline_programing(ctx, encode_state, encoder_context);
+    gen8_mfc_run(ctx, encode_state, encoder_context);
+
+    return VA_STATUS_SUCCESS;
+}
+
+
 static void
 gen8_mfc_context_destroy(void *context)
 {
@@ -2430,6 +3279,11 @@ static VAStatus gen8_mfc_pipeline(VADriverContextP ctx,
         vaStatus = gen8_mfc_mpeg2_encode_picture(ctx, encode_state, encoder_context);
         break;
 
+    case VAProfileJPEGBaseline:
+        jpeg_init_default_qmatrix(ctx, encoder_context);
+        vaStatus = gen8_mfc_jpeg_encode_picture(ctx, encode_state, encoder_context);
+        break;
+        
     default:
         vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
         break;
diff --git a/src/gen8_mfd.c b/src/gen8_mfd.c
index b482846..5a802f5 100644
--- a/src/gen8_mfd.c
+++ b/src/gen8_mfd.c
@@ -74,7 +74,7 @@ gen8_mfd_init_avc_surface(VADriverContextP ctx,
 
     if (!gen7_avc_surface) {
         gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1);
-        gen7_avc_surface->frame_store_id = -1;
+        gen7_avc_surface->base.frame_store_id = -1;
         assert((obj_surface->size & 0x3f) == 0);
         obj_surface->private_data = gen7_avc_surface;
     }
diff --git a/src/gen8_post_processing.c b/src/gen8_post_processing.c
index 1e6068d..320a1bf 100644
--- a/src/gen8_post_processing.c
+++ b/src/gen8_post_processing.c
@@ -52,19 +52,19 @@
 
 #define VA_STATUS_SUCCESS_1                     0xFFFFFFFE
 
-static VAStatus pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
-                                   const struct i965_surface *src_surface,
-                                   const VARectangle *src_rect,
-                                   struct i965_surface *dst_surface,
-                                   const VARectangle *dst_rect,
-                                   void *filter_param);
-
-static VAStatus gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
-                                           const struct i965_surface *src_surface,
-                                           const VARectangle *src_rect,
-                                           struct i965_surface *dst_surface,
-                                           const VARectangle *dst_rect,
-                                           void *filter_param);
+VAStatus pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
+                            const struct i965_surface *src_surface,
+                            const VARectangle *src_rect,
+                            struct i965_surface *dst_surface,
+                            const VARectangle *dst_rect,
+                            void *filter_param);
+
+VAStatus gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
+                                    const struct i965_surface *src_surface,
+                                    const VARectangle *src_rect,
+                                    struct i965_surface *dst_surface,
+                                    const VARectangle *dst_rect,
+                                    void *filter_param);
 
 /* TODO: Modify the shader and then compile it again.
  * Currently it is derived from Haswell*/
@@ -638,7 +638,7 @@ pp_null_set_block_parameter(struct i965_post_processing_context *pp_context, int
     return 0;
 }
 
-static VAStatus
+VAStatus
 pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
                    const struct i965_surface *src_surface,
                    const VARectangle *src_rect,
@@ -739,7 +739,30 @@ static void gen7_update_src_surface_uv_offset(VADriverContextP    ctx,
     }
 }
 
-static VAStatus
+static const AVSConfig gen8_avs_config = {
+    .coeff_frac_bits = 6,
+    .coeff_epsilon = 1.0f / (1U << 6),
+    .num_phases = 16,
+    .num_luma_coeffs = 8,
+    .num_chroma_coeffs = 4,
+
+    .coeff_range = {
+        .lower_bound = {
+            .y_k_h = { -2, -2, -2, -2, -2, -2, -2, -2 },
+            .y_k_v = { -2, -2, -2, -2, -2, -2, -2, -2 },
+            .uv_k_h = { -1, -2, -2, -1 },
+            .uv_k_v = { -1, -2, -2, -1 },
+        },
+        .upper_bound = {
+            .y_k_h = { 2, 2, 2, 2, 2, 2, 2, 2 },
+            .y_k_v = { 2, 2, 2, 2, 2, 2, 2, 2 },
+            .uv_k_h = { 1, 2, 2, 1 },
+            .uv_k_v = { 1, 2, 2, 1 },
+        },
+    },
+};
+
+VAStatus
 gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
                            const struct i965_surface *src_surface,
                            const VARectangle *src_rect,
@@ -751,11 +774,12 @@ gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con
     struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->pp_avs_context;
     struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
     struct gen8_sampler_8x8_avs *sampler_8x8;
-    struct i965_sampler_8x8_coefficient *sampler_8x8_state;
     int i;
     int width[3], height[3], pitch[3], offset[3];
     int src_width, src_height;
     unsigned char *cc_ptr;
+    AVSState * const avs = &pp_avs_context->state;
+    float sx, sy;
 
     memset(pp_static_parameter, 0, sizeof(struct gen7_pp_static_parameter));
 
@@ -869,60 +893,77 @@ gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con
     sampler_8x8->dw15.s1u = 113; /* s1u = 0 */
     sampler_8x8->dw15.s2u = 1203; /* s2u = 0 */
 
-    sampler_8x8_state = sampler_8x8->coefficients;
-
-    for (i = 0; i < 17; i++) {
-	float coff;
-	coff = i;
-	coff = coff / 16;
-
-        memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
-        /* for Y channel, currently ignore */
-        sampler_8x8_state->dw0.table_0x_filter_c0 = 0x0;
-        sampler_8x8_state->dw0.table_0x_filter_c1 = 0x0;
-        sampler_8x8_state->dw0.table_0x_filter_c2 = 0x0;
-        sampler_8x8_state->dw0.table_0x_filter_c3 =
-				intel_format_convert(1 - coff, 1, 6, 0);
-        sampler_8x8_state->dw1.table_0x_filter_c4 =
-				intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->dw1.table_0x_filter_c5 = 0x0;
-        sampler_8x8_state->dw1.table_0x_filter_c6 = 0x0;
-        sampler_8x8_state->dw1.table_0x_filter_c7 = 0x0;
-        sampler_8x8_state->dw2.table_0y_filter_c0 = 0x0;
-        sampler_8x8_state->dw2.table_0y_filter_c1 = 0x0;
-        sampler_8x8_state->dw2.table_0y_filter_c2 = 0x0;
-        sampler_8x8_state->dw2.table_0y_filter_c3 =
-                                intel_format_convert(1 - coff, 1, 6, 0);
-        sampler_8x8_state->dw3.table_0y_filter_c4 =
-                                intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->dw3.table_0y_filter_c5 = 0x0;
-        sampler_8x8_state->dw3.table_0y_filter_c6 = 0x0;
-        sampler_8x8_state->dw3.table_0y_filter_c7 = 0x0;
-        /* for U/V channel, 0.25 */
-        sampler_8x8_state->dw4.table_1x_filter_c0 = 0x0;
-        sampler_8x8_state->dw4.table_1x_filter_c1 = 0x0;
-        sampler_8x8_state->dw4.table_1x_filter_c2 = 0x0;
+    sx = (float)dst_rect->width / src_rect->width;
+    sy = (float)dst_rect->height / src_rect->height;
+    avs_update_coefficients(avs, sx, sy, pp_context->filter_flags);
+
+    assert(avs->config->num_phases == 16);
+    for (i = 0; i <= 16; i++) {
+        struct gen8_sampler_8x8_avs_coefficients * const sampler_8x8_state =
+            &sampler_8x8->coefficients[i];
+        const AVSCoeffs * const coeffs = &avs->coeffs[i];
+
+        sampler_8x8_state->dw0.table_0x_filter_c0 =
+            intel_format_convert(coeffs->y_k_h[0], 1, 6, 1);
+        sampler_8x8_state->dw0.table_0y_filter_c0 =
+            intel_format_convert(coeffs->y_k_v[0], 1, 6, 1);
+        sampler_8x8_state->dw0.table_0x_filter_c1 =
+            intel_format_convert(coeffs->y_k_h[1], 1, 6, 1);
+        sampler_8x8_state->dw0.table_0y_filter_c1 =
+            intel_format_convert(coeffs->y_k_v[1], 1, 6, 1);
+
+        sampler_8x8_state->dw1.table_0x_filter_c2 =
+            intel_format_convert(coeffs->y_k_h[2], 1, 6, 1);
+        sampler_8x8_state->dw1.table_0y_filter_c2 =
+            intel_format_convert(coeffs->y_k_v[2], 1, 6, 1);
+        sampler_8x8_state->dw1.table_0x_filter_c3 =
+            intel_format_convert(coeffs->y_k_h[3], 1, 6, 1);
+        sampler_8x8_state->dw1.table_0y_filter_c3 =
+            intel_format_convert(coeffs->y_k_v[3], 1, 6, 1);
+
+        sampler_8x8_state->dw2.table_0x_filter_c4 =
+            intel_format_convert(coeffs->y_k_h[4], 1, 6, 1);
+        sampler_8x8_state->dw2.table_0y_filter_c4 =
+            intel_format_convert(coeffs->y_k_v[4], 1, 6, 1);
+        sampler_8x8_state->dw2.table_0x_filter_c5 =
+            intel_format_convert(coeffs->y_k_h[5], 1, 6, 1);
+        sampler_8x8_state->dw2.table_0y_filter_c5 =
+            intel_format_convert(coeffs->y_k_v[5], 1, 6, 1);
+
+        sampler_8x8_state->dw3.table_0x_filter_c6 =
+            intel_format_convert(coeffs->y_k_h[6], 1, 6, 1);
+        sampler_8x8_state->dw3.table_0y_filter_c6 =
+            intel_format_convert(coeffs->y_k_v[6], 1, 6, 1);
+        sampler_8x8_state->dw3.table_0x_filter_c7 =
+            intel_format_convert(coeffs->y_k_h[7], 1, 6, 1);
+        sampler_8x8_state->dw3.table_0y_filter_c7 =
+            intel_format_convert(coeffs->y_k_v[7], 1, 6, 1);
+
+        sampler_8x8_state->dw4.pad0 = 0;
+        sampler_8x8_state->dw5.pad0 = 0;
+        sampler_8x8_state->dw4.table_1x_filter_c2 =
+            intel_format_convert(coeffs->uv_k_h[0], 1, 6, 1);
         sampler_8x8_state->dw4.table_1x_filter_c3 =
-				intel_format_convert(1 - coff, 1, 6, 0);
+            intel_format_convert(coeffs->uv_k_h[1], 1, 6, 1);
         sampler_8x8_state->dw5.table_1x_filter_c4 =
-                                intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->dw5.table_1x_filter_c5 = 0x00;
-        sampler_8x8_state->dw5.table_1x_filter_c6 = 0x0;
-        sampler_8x8_state->dw5.table_1x_filter_c7 = 0x0;
-        sampler_8x8_state->dw6.table_1y_filter_c0 = 0x0;
-        sampler_8x8_state->dw6.table_1y_filter_c1 = 0x0;
-        sampler_8x8_state->dw6.table_1y_filter_c2 = 0x0;
+            intel_format_convert(coeffs->uv_k_h[2], 1, 6, 1);
+        sampler_8x8_state->dw5.table_1x_filter_c5 =
+            intel_format_convert(coeffs->uv_k_h[3], 1, 6, 1);
+
+        sampler_8x8_state->dw6.pad0 =
+        sampler_8x8_state->dw7.pad0 =
+        sampler_8x8_state->dw6.table_1y_filter_c2 =
+            intel_format_convert(coeffs->uv_k_v[0], 1, 6, 1);
         sampler_8x8_state->dw6.table_1y_filter_c3 =
-				intel_format_convert(1 - coff, 1, 6, 0);
+            intel_format_convert(coeffs->uv_k_v[1], 1, 6, 1);
         sampler_8x8_state->dw7.table_1y_filter_c4 =
-				intel_format_convert(coff, 1, 6,0);
-        sampler_8x8_state->dw7.table_1y_filter_c5 = 0x0;
-        sampler_8x8_state->dw7.table_1y_filter_c6 = 0x0;
-        sampler_8x8_state->dw7.table_1y_filter_c7 = 0x0;
-        sampler_8x8_state++;
+            intel_format_convert(coeffs->uv_k_v[2], 1, 6, 1);
+        sampler_8x8_state->dw7.table_1y_filter_c5 =
+            intel_format_convert(coeffs->uv_k_v[3], 1, 6, 1);
     }
 
-    sampler_8x8->dw152.default_sharpness_level = 0;
+    sampler_8x8->dw152.default_sharpness_level =
+        -avs_is_needed(pp_context->filter_flags);
     sampler_8x8->dw153.adaptive_filter_for_all_channel = 1;
     sampler_8x8->dw153.bypass_y_adaptive_filtering = 1;
     sampler_8x8->dw153.bypass_x_adaptive_filtering = 1;
@@ -965,7 +1006,7 @@ gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con
     return VA_STATUS_SUCCESS;
 }
 
-static VAStatus
+VAStatus
 gen8_pp_initialize(
     VADriverContextP   ctx,
     struct i965_post_processing_context *pp_context,
@@ -1110,7 +1151,7 @@ gen8_pp_upload_constants(VADriverContextP ctx,
     return;
 }
 
-static void
+void
 gen8_pp_states_setup(VADriverContextP ctx,
                      struct i965_post_processing_context *pp_context)
 {
@@ -1164,7 +1205,7 @@ gen8_pp_state_base_address(VADriverContextP ctx,
     ADVANCE_BATCH(batch);
 }
 
-static void
+void
 gen8_pp_vfe_state(VADriverContextP ctx,
                   struct i965_post_processing_context *pp_context)
 {
@@ -1189,7 +1230,7 @@ gen8_pp_vfe_state(VADriverContextP ctx,
     ADVANCE_BATCH(batch);
 }
 
-static void
+void
 gen8_interface_descriptor_load(VADriverContextP ctx,
                                struct i965_post_processing_context *pp_context)
 {
@@ -1208,7 +1249,7 @@ gen8_interface_descriptor_load(VADriverContextP ctx,
     ADVANCE_BATCH(batch);
 }
 
-static void
+void
 gen8_pp_curbe_load(VADriverContextP ctx,
                    struct i965_post_processing_context *pp_context)
 {
@@ -1227,7 +1268,7 @@ gen8_pp_curbe_load(VADriverContextP ctx,
     ADVANCE_BATCH(batch);
 }
 
-static void
+void
 gen8_pp_object_walker(VADriverContextP ctx,
                       struct i965_post_processing_context *pp_context)
 {
@@ -1380,9 +1421,11 @@ gen8_post_processing_context_finalize(struct i965_post_processing_context *pp_co
 #define VPP_CURBE_ALLOCATION_SIZE	32
 
 void
-gen8_post_processing_context_init(VADriverContextP ctx,
-                                  void *data,
-                                  struct intel_batchbuffer *batch)
+gen8_post_processing_context_common_init(VADriverContextP ctx,
+                                         void *data,
+                                         struct pp_module *pp_modules,
+                                         int num_pp_modules,
+                                         struct intel_batchbuffer *batch)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     int i, kernel_size;
@@ -1391,20 +1434,18 @@ gen8_post_processing_context_init(VADriverContextP ctx,
     struct pp_module *pp_module;
     struct i965_post_processing_context *pp_context = data;
 
-    {
-	pp_context->vfe_gpu_state.max_num_threads = 60;
-	pp_context->vfe_gpu_state.num_urb_entries = 59;
-	pp_context->vfe_gpu_state.gpgpu_mode = 0;
-	pp_context->vfe_gpu_state.urb_entry_size = 16 - 1;
-	pp_context->vfe_gpu_state.curbe_allocation_size = VPP_CURBE_ALLOCATION_SIZE;
-    }
+    pp_context->vfe_gpu_state.max_num_threads = 60;
+    pp_context->vfe_gpu_state.num_urb_entries = 59;
+    pp_context->vfe_gpu_state.gpgpu_mode = 0;
+    pp_context->vfe_gpu_state.urb_entry_size = 16 - 1;
+    pp_context->vfe_gpu_state.curbe_allocation_size = VPP_CURBE_ALLOCATION_SIZE;
 
     pp_context->intel_post_processing = gen8_post_processing;
     pp_context->finalize = gen8_post_processing_context_finalize;
 
-    assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen8));
+    assert(ARRAY_ELEMS(pp_context->pp_modules) == num_pp_modules);
 
-    memcpy(pp_context->pp_modules, pp_modules_gen8, sizeof(pp_context->pp_modules));
+    memcpy(pp_context->pp_modules, pp_modules, sizeof(pp_context->pp_modules));
 
     kernel_size = 4096 ;
 
@@ -1463,4 +1504,14 @@ gen8_post_processing_context_init(VADriverContextP ctx,
 
     pp_context->idrt_size = 5 * sizeof(struct gen8_interface_descriptor_data);
     pp_context->curbe_size = 256;
+
+    avs_init_state(&pp_context->pp_avs_context.state, &gen8_avs_config);
+}
+
+void
+gen8_post_processing_context_init(VADriverContextP ctx,
+                                  void *data,
+                                  struct intel_batchbuffer *batch)
+{
+    gen8_post_processing_context_common_init(ctx, data, pp_modules_gen8, ARRAY_ELEMS(pp_modules_gen8), batch);
 }
diff --git a/src/gen8_post_processing.h b/src/gen8_post_processing.h
new file mode 100644
index 0000000..f3c09a8
--- /dev/null
+++ b/src/gen8_post_processing.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef _GEN8_POST_PROCESSING_H_
+#define _GEN8_POST_PROCESSING_H_
+
+VAStatus pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
+                            const struct i965_surface *src_surface,
+                            const VARectangle *src_rect,
+                            struct i965_surface *dst_surface,
+                            const VARectangle *dst_rect,
+                            void *filter_param);
+
+VAStatus
+gen8_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
+                           const struct i965_surface *src_surface,
+                           const VARectangle *src_rect,
+                           struct i965_surface *dst_surface,
+                           const VARectangle *dst_rect,
+                           void *filter_param);
+
+VAStatus
+gen8_pp_nv12_blending_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
+                                 const struct i965_surface *src_surface,
+                                 const VARectangle *src_rect,
+                                 struct i965_surface *dst_surface,
+                                 const VARectangle *dst_rect,
+                                 void *filter_param);
+
+void
+gen8_pp_vfe_state(VADriverContextP ctx,
+                  struct i965_post_processing_context *pp_context);
+
+void
+gen8_interface_descriptor_load(VADriverContextP ctx,
+                               struct i965_post_processing_context *pp_context);
+
+void
+gen8_pp_curbe_load(VADriverContextP ctx,
+                   struct i965_post_processing_context *pp_context);
+
+void
+gen8_pp_object_walker(VADriverContextP ctx,
+                      struct i965_post_processing_context *pp_context);
+
+void
+gen8_pp_states_setup(VADriverContextP ctx,
+                     struct i965_post_processing_context *pp_context);
+
+VAStatus
+gen8_pp_initialize(VADriverContextP ctx,
+                   struct i965_post_processing_context *pp_context,
+                   const struct i965_surface *src_surface,
+                   const VARectangle *src_rect,
+                   struct i965_surface *dst_surface,
+                   const VARectangle *dst_rect,
+                   int pp_index,
+                   void *filter_param);
+
+void
+gen8_post_processing_context_common_init(VADriverContextP ctx,
+                                         void *data,
+                                         struct pp_module *pp_modules,
+                                         int num_pp_modules,
+                                         struct intel_batchbuffer *batch);
+#endif
diff --git a/src/gen8_render.c b/src/gen8_render.c
index 9c49cbc..b7494a1 100644
--- a/src/gen8_render.c
+++ b/src/gen8_render.c
@@ -189,11 +189,11 @@ gen8_render_set_surface_state(
 
     memset(ss, 0, sizeof(*ss));
 
-    switch (flags & (I965_PP_FLAG_TOP_FIELD|I965_PP_FLAG_BOTTOM_FIELD)) {
-    case I965_PP_FLAG_BOTTOM_FIELD:
+    switch (flags & (VA_TOP_FIELD|VA_BOTTOM_FIELD)) {
+    case VA_BOTTOM_FIELD:
         ss->ss0.vert_line_stride_ofs = 1;
         /* fall-through */
-    case I965_PP_FLAG_TOP_FIELD:
+    case VA_TOP_FIELD:
         ss->ss0.vert_line_stride = 1;
         height /= 2;
         break;
diff --git a/src/gen8_vme.c b/src/gen8_vme.c
index 8cae2a0..29d4b5a 100644
--- a/src/gen8_vme.c
+++ b/src/gen8_vme.c
@@ -1155,7 +1155,7 @@ gen8_vme_context_destroy(void *context)
 
 Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
-    struct gen6_vme_context *vme_context = calloc(1, sizeof(struct gen6_vme_context));
+    struct gen6_vme_context *vme_context = NULL;
     struct i965_kernel *vme_kernel_list = NULL;
     int i965_kernel_num;
 
@@ -1171,7 +1171,13 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
         vme_kernel_list = gen8_vme_mpeg2_kernels;
         encoder_context->vme_pipeline = gen8_vme_mpeg2_pipeline;
        	i965_kernel_num = sizeof(gen8_vme_mpeg2_kernels) / sizeof(struct i965_kernel); 
+        break;
 
+   case CODEC_JPEG:
+        //JPEG encode doesnt have vme. So, set the corresponding fields to NULL.
+        encoder_context->vme_context = NULL;
+        encoder_context->vme_pipeline = NULL;
+        encoder_context->vme_context_destroy = NULL;
         break;
 
     default:
@@ -1180,35 +1186,40 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
 
         break;
     }
-    vme_context->vme_kernel_sum = i965_kernel_num;
-    vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
 
-    vme_context->gpe_context.idrt_size = sizeof(struct gen8_interface_descriptor_data) * MAX_INTERFACE_DESC_GEN6;
-    vme_context->gpe_context.curbe_size = CURBE_TOTAL_DATA_LENGTH;
-    vme_context->gpe_context.sampler_size = 0;
+    //If the codec is JPEG, bypass VME
+    if(encoder_context->codec != CODEC_JPEG) {
+        vme_context = calloc(1, sizeof(struct gen6_vme_context));
+        vme_context->vme_kernel_sum = i965_kernel_num;
+        vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
+
+        vme_context->gpe_context.idrt_size = sizeof(struct gen8_interface_descriptor_data) * MAX_INTERFACE_DESC_GEN6;
+        vme_context->gpe_context.curbe_size = CURBE_TOTAL_DATA_LENGTH;
+        vme_context->gpe_context.sampler_size = 0;
 
 
-    vme_context->gpe_context.vfe_state.max_num_threads = 60 - 1;
-    vme_context->gpe_context.vfe_state.num_urb_entries = 64;
-    vme_context->gpe_context.vfe_state.gpgpu_mode = 0;
-    vme_context->gpe_context.vfe_state.urb_entry_size = 16;
-    vme_context->gpe_context.vfe_state.curbe_allocation_size = CURBE_ALLOCATION_SIZE - 1;
+        vme_context->gpe_context.vfe_state.max_num_threads = 60 - 1;
+        vme_context->gpe_context.vfe_state.num_urb_entries = 64;
+        vme_context->gpe_context.vfe_state.gpgpu_mode = 0;
+        vme_context->gpe_context.vfe_state.urb_entry_size = 16;
+        vme_context->gpe_context.vfe_state.curbe_allocation_size = CURBE_ALLOCATION_SIZE - 1;
 
-    gen7_vme_scoreboard_init(ctx, vme_context);
+        gen7_vme_scoreboard_init(ctx, vme_context);
 
-    gen8_gpe_load_kernels(ctx,
+        gen8_gpe_load_kernels(ctx,
                           &vme_context->gpe_context,
                           vme_kernel_list,
                           i965_kernel_num);
-    vme_context->vme_surface2_setup = gen8_gpe_surface2_setup;
-    vme_context->vme_media_rw_surface_setup = gen8_gpe_media_rw_surface_setup;
-    vme_context->vme_buffer_suface_setup = gen8_gpe_buffer_suface_setup;
-    vme_context->vme_media_chroma_surface_setup = gen8_gpe_media_chroma_surface_setup;
+        vme_context->vme_surface2_setup = gen8_gpe_surface2_setup;
+        vme_context->vme_media_rw_surface_setup = gen8_gpe_media_rw_surface_setup;
+        vme_context->vme_buffer_suface_setup = gen8_gpe_buffer_suface_setup;
+        vme_context->vme_media_chroma_surface_setup = gen8_gpe_media_chroma_surface_setup;
 
-    encoder_context->vme_context = vme_context;
-    encoder_context->vme_context_destroy = gen8_vme_context_destroy;
+        encoder_context->vme_context = vme_context;
+        encoder_context->vme_context_destroy = gen8_vme_context_destroy;
 
-    vme_context->vme_state_message = malloc(VME_MSG_LENGTH * sizeof(int));
+        vme_context->vme_state_message = malloc(VME_MSG_LENGTH * sizeof(int));
+    }
 
     return True;
 }
diff --git a/src/gen8_mfc.c b/src/gen9_mfc.c
similarity index 89%
copy from src/gen8_mfc.c
copy to src/gen9_mfc.c
index 2d76816..532695a 100644
--- a/src/gen8_mfc.c
+++ b/src/gen9_mfc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2012 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -52,28 +52,28 @@
 #define B0_STEP_REV		2
 #define IS_STEPPING_BPLUS(i965)	((i965->intel.revision) >= B0_STEP_REV)
 
-static const uint32_t gen8_mfc_batchbuffer_avc_intra[][4] = {
-#include "shaders/utils/mfc_batchbuffer_avc_intra.g7b"
+static const uint32_t gen9_mfc_batchbuffer_avc_intra[][4] = {
+#include "shaders/utils/mfc_batchbuffer_avc_intra.g9b"
 };
 
-static const uint32_t gen8_mfc_batchbuffer_avc_inter[][4] = {
-#include "shaders/utils/mfc_batchbuffer_avc_inter.g7b"
+static const uint32_t gen9_mfc_batchbuffer_avc_inter[][4] = {
+#include "shaders/utils/mfc_batchbuffer_avc_inter.g9b"
 };
 
-static struct i965_kernel gen8_mfc_kernels[] = {
+static struct i965_kernel gen9_mfc_kernels[] = {
     {
         "MFC AVC INTRA BATCHBUFFER ",
         MFC_BATCHBUFFER_AVC_INTRA,
-        gen8_mfc_batchbuffer_avc_intra,
-        sizeof(gen8_mfc_batchbuffer_avc_intra),
+        gen9_mfc_batchbuffer_avc_intra,
+        sizeof(gen9_mfc_batchbuffer_avc_intra),
         NULL
     },
 
     {
         "MFC AVC INTER BATCHBUFFER ",
         MFC_BATCHBUFFER_AVC_INTER,
-        gen8_mfc_batchbuffer_avc_inter,
-        sizeof(gen8_mfc_batchbuffer_avc_inter),
+        gen9_mfc_batchbuffer_avc_inter,
+        sizeof(gen9_mfc_batchbuffer_avc_inter),
         NULL
     },
 };
@@ -89,7 +89,7 @@ static struct i965_kernel gen8_mfc_kernels[] = {
 
 
 static void
-gen8_mfc_pipe_mode_select(VADriverContextP ctx,
+gen9_mfc_pipe_mode_select(VADriverContextP ctx,
                           int standard_select,
                           struct intel_encoder_context *encoder_context)
 {
@@ -127,7 +127,7 @@ gen8_mfc_pipe_mode_select(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_surface_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+gen9_mfc_surface_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
@@ -156,7 +156,7 @@ gen8_mfc_surface_state(VADriverContextP ctx, struct intel_encoder_context *encod
 }
 
 static void
-gen8_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
+gen9_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
                                  struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
@@ -197,14 +197,14 @@ gen8_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
 
-    /* the DW21-25 is for MFC Indirect PAK-BSE Object Base Address for Encoder*/	
+    /* the DW21-25 is for MFC Indirect PAK-BSE Object Base Address for Encoder*/
     OUT_BCS_RELOC(batch,
                   mfc_context->mfc_indirect_pak_bse_object.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
                   0);
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
-	
+
     OUT_BCS_RELOC(batch,
                   mfc_context->mfc_indirect_pak_bse_object.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
@@ -215,7 +215,7 @@ gen8_mfc_ind_obj_base_addr_state(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_avc_img_state(VADriverContextP ctx, struct encode_state *encode_state,  
+gen9_mfc_avc_img_state(VADriverContextP ctx, struct encode_state *encode_state,
                        struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
@@ -231,11 +231,11 @@ gen8_mfc_avc_img_state(VADriverContextP ctx, struct encode_state *encode_state,
     /*DW1. MB setting of frame */
     OUT_BCS_BATCH(batch,
                   ((width_in_mbs * height_in_mbs - 1) & 0xFFFF));
-    OUT_BCS_BATCH(batch, 
-                  ((height_in_mbs - 1) << 16) | 
+    OUT_BCS_BATCH(batch,
+                  ((height_in_mbs - 1) << 16) |
                   ((width_in_mbs - 1) << 0));
     /* DW3 QP setting */
-    OUT_BCS_BATCH(batch, 
+    OUT_BCS_BATCH(batch,
                   (0 << 24) |	/* Second Chroma QP Offset */
                   (0 << 16) |	/* Chroma QP Offset */
                   (0 << 14) |   /* Max-bit conformance Intra flag */
@@ -283,7 +283,7 @@ gen8_mfc_avc_img_state(VADriverContextP ctx, struct encode_state *encode_state,
 }
 
 static void
-gen8_mfc_qm_state(VADriverContextP ctx,
+gen9_mfc_qm_state(VADriverContextP ctx,
                   int qm_type,
                   unsigned int *qm,
                   int qm_length,
@@ -304,7 +304,7 @@ gen8_mfc_qm_state(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_avc_qm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+gen9_mfc_avc_qm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     unsigned int qm[16] = {
         0x10101010, 0x10101010, 0x10101010, 0x10101010,
@@ -313,14 +313,14 @@ gen8_mfc_avc_qm_state(VADriverContextP ctx, struct intel_encoder_context *encode
         0x10101010, 0x10101010, 0x10101010, 0x10101010
     };
 
-    gen8_mfc_qm_state(ctx, MFX_QM_AVC_4X4_INTRA_MATRIX, qm, 12, encoder_context);
-    gen8_mfc_qm_state(ctx, MFX_QM_AVC_4X4_INTER_MATRIX, qm, 12, encoder_context);
-    gen8_mfc_qm_state(ctx, MFX_QM_AVC_8x8_INTRA_MATRIX, qm, 16, encoder_context);
-    gen8_mfc_qm_state(ctx, MFX_QM_AVC_8x8_INTER_MATRIX, qm, 16, encoder_context);
+    gen9_mfc_qm_state(ctx, MFX_QM_AVC_4X4_INTRA_MATRIX, qm, 12, encoder_context);
+    gen9_mfc_qm_state(ctx, MFX_QM_AVC_4X4_INTER_MATRIX, qm, 12, encoder_context);
+    gen9_mfc_qm_state(ctx, MFX_QM_AVC_8x8_INTRA_MATRIX, qm, 16, encoder_context);
+    gen9_mfc_qm_state(ctx, MFX_QM_AVC_8x8_INTER_MATRIX, qm, 16, encoder_context);
 }
 
 static void
-gen8_mfc_fqm_state(VADriverContextP ctx,
+gen9_mfc_fqm_state(VADriverContextP ctx,
                    int fqm_type,
                    unsigned int *fqm,
                    int fqm_length,
@@ -341,7 +341,7 @@ gen8_mfc_fqm_state(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_avc_fqm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+gen9_mfc_avc_fqm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     unsigned int qm[32] = {
         0x10001000, 0x10001000, 0x10001000, 0x10001000,
@@ -354,14 +354,14 @@ gen8_mfc_avc_fqm_state(VADriverContextP ctx, struct intel_encoder_context *encod
         0x10001000, 0x10001000, 0x10001000, 0x10001000
     };
 
-    gen8_mfc_fqm_state(ctx, MFX_QM_AVC_4X4_INTRA_MATRIX, qm, 24, encoder_context);
-    gen8_mfc_fqm_state(ctx, MFX_QM_AVC_4X4_INTER_MATRIX, qm, 24, encoder_context);
-    gen8_mfc_fqm_state(ctx, MFX_QM_AVC_8x8_INTRA_MATRIX, qm, 32, encoder_context);
-    gen8_mfc_fqm_state(ctx, MFX_QM_AVC_8x8_INTER_MATRIX, qm, 32, encoder_context);
+    gen9_mfc_fqm_state(ctx, MFX_QM_AVC_4X4_INTRA_MATRIX, qm, 24, encoder_context);
+    gen9_mfc_fqm_state(ctx, MFX_QM_AVC_4X4_INTER_MATRIX, qm, 24, encoder_context);
+    gen9_mfc_fqm_state(ctx, MFX_QM_AVC_8x8_INTRA_MATRIX, qm, 32, encoder_context);
+    gen9_mfc_fqm_state(ctx, MFX_QM_AVC_8x8_INTER_MATRIX, qm, 32, encoder_context);
 }
 
 static void
-gen8_mfc_avc_insert_object(VADriverContextP ctx, struct intel_encoder_context *encoder_context,
+gen9_mfc_avc_insert_object(VADriverContextP ctx, struct intel_encoder_context *encoder_context,
                            unsigned int *insert_data, int lenght_in_dws, int data_bits_in_last_dw,
                            int skip_emul_byte_count, int is_last_header, int is_end_of_slice, int emulation_flag,
                            struct intel_batchbuffer *batch)
@@ -389,7 +389,7 @@ gen8_mfc_avc_insert_object(VADriverContextP ctx, struct intel_encoder_context *e
 }
 
 
-static void gen8_mfc_init(VADriverContextP ctx,
+static void gen9_mfc_init(VADriverContextP ctx,
                           struct encode_state *encode_state,
                           struct intel_encoder_context *encoder_context)
 {
@@ -428,7 +428,7 @@ static void gen8_mfc_init(VADriverContextP ctx,
     dri_bo_unreference(mfc_context->uncompressed_picture_source.bo);
     mfc_context->uncompressed_picture_source.bo = NULL;
 
-    dri_bo_unreference(mfc_context->mfc_indirect_pak_bse_object.bo); 
+    dri_bo_unreference(mfc_context->mfc_indirect_pak_bse_object.bo);
     mfc_context->mfc_indirect_pak_bse_object.bo = NULL;
 
     for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){
@@ -440,7 +440,7 @@ static void gen8_mfc_init(VADriverContextP ctx,
     for (i = 0; i < MAX_MFC_REFERENCE_SURFACES; i++){
         if (mfc_context->reference_surfaces[i].bo != NULL)
             dri_bo_unreference(mfc_context->reference_surfaces[i].bo);
-        mfc_context->reference_surfaces[i].bo = NULL;  
+        mfc_context->reference_surfaces[i].bo = NULL;
     }
 
     dri_bo_unreference(mfc_context->intra_row_store_scratch_buffer.bo);
@@ -495,7 +495,7 @@ static void gen8_mfc_init(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_pipe_buf_addr_state(VADriverContextP ctx,
+gen9_mfc_pipe_buf_addr_state(VADriverContextP ctx,
                              struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
@@ -518,13 +518,14 @@ gen8_mfc_pipe_buf_addr_state(VADriverContextP ctx,
     OUT_BCS_BATCH(batch, 0);
     /* the DW4-6 is for the post_deblocking */
 
+    /* post output addr  */
     if (mfc_context->post_deblocking_output.bo)
         OUT_BCS_RELOC(batch, mfc_context->post_deblocking_output.bo,
                       I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
-                      0);											/* post output addr  */	
+                      0);
     else
         OUT_BCS_BATCH(batch, 0);
-    
+
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
 
@@ -540,14 +541,14 @@ gen8_mfc_pipe_buf_addr_state(VADriverContextP ctx,
     OUT_BCS_RELOC(batch, mfc_context->macroblock_status_buffer.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
                   0); /* StreamOut data*/
-    
+
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
 
     /* the DW13-15 is for the intra_row_store_scratch */
     OUT_BCS_RELOC(batch, mfc_context->intra_row_store_scratch_buffer.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
-                  0);	
+                  0);
 
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
@@ -565,7 +566,7 @@ gen8_mfc_pipe_buf_addr_state(VADriverContextP ctx,
         if ( mfc_context->reference_surfaces[i].bo != NULL) {
             OUT_BCS_RELOC(batch, mfc_context->reference_surfaces[i].bo,
                           I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
-                          0);			
+                          0);
         } else {
             OUT_BCS_BATCH(batch, 0);
         }
@@ -578,8 +579,8 @@ gen8_mfc_pipe_buf_addr_state(VADriverContextP ctx,
     /* The DW 52-54 is for the MB status buffer */
     OUT_BCS_RELOC(batch, mfc_context->macroblock_status_buffer.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
-                  0);											/* Macroblock status buffer*/
-	
+                  0);
+
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
 
@@ -597,7 +598,7 @@ gen8_mfc_pipe_buf_addr_state(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_avc_directmode_state(VADriverContextP ctx,
+gen9_mfc_avc_directmode_state(VADriverContextP ctx,
                               struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
@@ -612,7 +613,7 @@ gen8_mfc_avc_directmode_state(VADriverContextP ctx,
     /* Reference frames and Current frames */
     /* the DW1-32 is for the direct MV for reference */
     for(i = 0; i < NUM_MFC_DMV_BUFFERS - 2; i += 2) {
-        if ( mfc_context->direct_mv_buffers[i].bo != NULL) { 
+        if ( mfc_context->direct_mv_buffers[i].bo != NULL) {
             OUT_BCS_RELOC(batch, mfc_context->direct_mv_buffers[i].bo,
                           I915_GEM_DOMAIN_INSTRUCTION, 0,
                           0);
@@ -622,7 +623,7 @@ gen8_mfc_avc_directmode_state(VADriverContextP ctx,
             OUT_BCS_BATCH(batch, 0);
         }
     }
-    
+
     OUT_BCS_BATCH(batch, 0);
 
     /* the DW34-36 is the MV for the current reference */
@@ -645,7 +646,7 @@ gen8_mfc_avc_directmode_state(VADriverContextP ctx,
 
 
 static void
-gen8_mfc_bsp_buf_base_addr_state(VADriverContextP ctx,
+gen9_mfc_bsp_buf_base_addr_state(VADriverContextP ctx,
                                  struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
@@ -659,7 +660,7 @@ gen8_mfc_bsp_buf_base_addr_state(VADriverContextP ctx,
                   0);
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
-	
+
     /* the DW4-6 is for MPR Row Store Scratch Buffer Base Address */
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
@@ -674,7 +675,7 @@ gen8_mfc_bsp_buf_base_addr_state(VADriverContextP ctx,
 }
 
 
-static void gen8_mfc_avc_pipeline_picture_programing( VADriverContextP ctx,
+static void gen9_mfc_avc_pipeline_picture_programing( VADriverContextP ctx,
                                                       struct encode_state *encode_state,
                                                       struct intel_encoder_context *encoder_context)
 {
@@ -683,17 +684,17 @@ static void gen8_mfc_avc_pipeline_picture_programing( VADriverContextP ctx,
     mfc_context->pipe_mode_select(ctx, MFX_FORMAT_AVC, encoder_context);
     mfc_context->set_surface_state(ctx, encoder_context);
     mfc_context->ind_obj_base_addr_state(ctx, encoder_context);
-    gen8_mfc_pipe_buf_addr_state(ctx, encoder_context);
-    gen8_mfc_bsp_buf_base_addr_state(ctx, encoder_context);
+    gen9_mfc_pipe_buf_addr_state(ctx, encoder_context);
+    gen9_mfc_bsp_buf_base_addr_state(ctx, encoder_context);
     mfc_context->avc_img_state(ctx, encode_state, encoder_context);
     mfc_context->avc_qm_state(ctx, encoder_context);
     mfc_context->avc_fqm_state(ctx, encoder_context);
-    gen8_mfc_avc_directmode_state(ctx, encoder_context); 
+    gen9_mfc_avc_directmode_state(ctx, encoder_context);
     intel_mfc_avc_ref_idx_state(ctx, encode_state, encoder_context);
 }
 
 
-static VAStatus gen8_mfc_run(VADriverContextP ctx, 
+static VAStatus gen9_mfc_run(VADriverContextP ctx,
                              struct encode_state *encode_state,
                              struct intel_encoder_context *encoder_context)
 {
@@ -706,7 +707,7 @@ static VAStatus gen8_mfc_run(VADriverContextP ctx,
 
 
 static VAStatus
-gen8_mfc_stop(VADriverContextP ctx, 
+gen9_mfc_stop(VADriverContextP ctx,
               struct encode_state *encode_state,
               struct intel_encoder_context *encoder_context,
               int *encoded_bits_size)
@@ -714,7 +715,7 @@ gen8_mfc_stop(VADriverContextP ctx,
     VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
     VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
     VACodedBufferSegment *coded_buffer_segment;
-    
+
     vaStatus = i965_MapBuffer(ctx, pPicParameter->coded_buf, (void **)&coded_buffer_segment);
     assert(vaStatus == VA_STATUS_SUCCESS);
     *encoded_bits_size = coded_buffer_segment->size * 8;
@@ -725,7 +726,7 @@ gen8_mfc_stop(VADriverContextP ctx,
 
 
 static void
-gen8_mfc_avc_slice_state(VADriverContextP ctx,
+gen9_mfc_avc_slice_state(VADriverContextP ctx,
                          VAEncPictureParameterBufferH264 *pic_param,
                          VAEncSliceParameterBufferH264 *slice_param,
                          struct encode_state *encode_state,
@@ -788,9 +789,9 @@ gen8_mfc_avc_slice_state(VADriverContextP ctx,
     for (i = 0; i < 6; i++)
         correct[i] = mfc_context->bit_rate_control_context[slice_type].Correct[i];
 
-    grow = mfc_context->bit_rate_control_context[slice_type].GrowInit + 
+    grow = mfc_context->bit_rate_control_context[slice_type].GrowInit +
         (mfc_context->bit_rate_control_context[slice_type].GrowResistance << 4);
-    shrink = mfc_context->bit_rate_control_context[slice_type].ShrinkInit + 
+    shrink = mfc_context->bit_rate_control_context[slice_type].ShrinkInit +
         (mfc_context->bit_rate_control_context[slice_type].ShrinkResistance << 4);
 
     BEGIN_BCS_BATCH(batch, 11);;
@@ -804,7 +805,7 @@ gen8_mfc_avc_slice_state(VADriverContextP ctx,
                   (chroma_log2_weight_denom << 8) |
                   (luma_log2_weight_denom << 0));
 
-    OUT_BCS_BATCH(batch, 
+    OUT_BCS_BATCH(batch,
                   (weighted_pred_idc << 30) |
                   (slice_param->direct_spatial_mv_pred_flag<<29) |             /*Direct Prediction Type*/
                   (slice_param->disable_deblocking_filter_idc << 27) |
@@ -817,28 +818,28 @@ gen8_mfc_avc_slice_state(VADriverContextP ctx,
                   (beginx << 16) |
                   slice_param->macroblock_address );
     OUT_BCS_BATCH(batch, (nexty << 16) | nextx);                       /*Next slice first MB X&Y*/
-    OUT_BCS_BATCH(batch, 
+    OUT_BCS_BATCH(batch,
                   (0/*rate_control_enable*/ << 31) |		/*in CBR mode RateControlCounterEnable = enable*/
                   (1 << 30) |		/*ResetRateControlCounter*/
                   (0 << 28) |		/*RC Triggle Mode = Always Rate Control*/
                   (4 << 24) |     /*RC Stable Tolerance, middle level*/
-                  (0/*rate_control_enable*/ << 23) |     /*RC Panic Enable*/                 
+                  (0/*rate_control_enable*/ << 23) |     /*RC Panic Enable*/
                   (0 << 22) |     /*QP mode, don't modfiy CBP*/
-                  (0 << 21) |     /*MB Type Direct Conversion Enabled*/ 
-                  (0 << 20) |     /*MB Type Skip Conversion Enabled*/ 
+                  (0 << 21) |     /*MB Type Direct Conversion Enabled*/
+                  (0 << 20) |     /*MB Type Skip Conversion Enabled*/
                   (last_slice << 19) |     /*IsLastSlice*/
                   (0 << 18) | 	/*BitstreamOutputFlag Compressed BitStream Output Disable Flag 0:enable 1:disable*/
-                  (1 << 17) |	    /*HeaderPresentFlag*/	
+                  (1 << 17) |	    /*HeaderPresentFlag*/
                   (1 << 16) |	    /*SliceData PresentFlag*/
                   (1 << 15) |	    /*TailPresentFlag*/
-                  (1 << 13) |	    /*RBSP NAL TYPE*/	
+                  (1 << 13) |	    /*RBSP NAL TYPE*/
                   (0 << 12) );    /*CabacZeroWordInsertionEnable*/
     OUT_BCS_BATCH(batch, mfc_context->mfc_indirect_pak_bse_object.offset);
     OUT_BCS_BATCH(batch,
-                  (maxQpN << 24) |     /*Target QP - 24 is lowest QP*/ 
+                  (maxQpN << 24) |     /*Target QP - 24 is lowest QP*/
                   (maxQpP << 16) |     /*Target QP + 20 is highest QP*/
                   (shrink << 8)  |
-                  (grow << 0));   
+                  (grow << 0));
     OUT_BCS_BATCH(batch,
                   (correct[5] << 20) |
                   (correct[4] << 16) |
@@ -855,7 +856,7 @@ gen8_mfc_avc_slice_state(VADriverContextP ctx,
 #ifdef MFC_SOFTWARE_HASWELL
 
 static int
-gen8_mfc_avc_pak_object_intra(VADriverContextP ctx, int x, int y, int end_mb,
+gen9_mfc_avc_pak_object_intra(VADriverContextP ctx, int x, int y, int end_mb,
                               int qp,unsigned int *msg,
                               struct intel_encoder_context *encoder_context,
                               unsigned char target_mb_size, unsigned char max_mb_size,
@@ -876,7 +877,7 @@ gen8_mfc_avc_pak_object_intra(VADriverContextP ctx, int x, int y, int end_mb,
     OUT_BCS_BATCH(batch, MFC_AVC_PAK_OBJECT | (len_in_dwords - 2));
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
-    OUT_BCS_BATCH(batch, 
+    OUT_BCS_BATCH(batch,
                   (0 << 24) |		/* PackedMvNum, Debug*/
                   (0 << 20) | 		/* No motion vector */
                   (1 << 19) |		/* CbpDcY */
@@ -885,14 +886,15 @@ gen8_mfc_avc_pak_object_intra(VADriverContextP ctx, int x, int y, int end_mb,
                   intra_msg);
 
     OUT_BCS_BATCH(batch, (0xFFFF << 16) | (y << 8) | x);		/* Code Block Pattern for Y*/
-    OUT_BCS_BATCH(batch, 0x000F000F);							/* Code Block Pattern */		
+    OUT_BCS_BATCH(batch, 0x000F000F);     /* Code Block Pattern */
+
     OUT_BCS_BATCH(batch, (0 << 27) | (end_mb << 26) | qp);	/* Last MB */
 
     /*Stuff for Intra MB*/
-    OUT_BCS_BATCH(batch, msg[1]);			/* We using Intra16x16 no 4x4 predmode*/	
-    OUT_BCS_BATCH(batch, msg[2]);	
-    OUT_BCS_BATCH(batch, msg[3]&0xFF);	
-    
+    OUT_BCS_BATCH(batch, msg[1]);	/* We using Intra16x16 no 4x4 predmode*/
+    OUT_BCS_BATCH(batch, msg[2]);
+    OUT_BCS_BATCH(batch, msg[3]&0xFF);
+
     /*MaxSizeInWord and TargetSzieInWord*/
     OUT_BCS_BATCH(batch, (max_mb_size << 24) |
                   (target_mb_size << 16) );
@@ -905,7 +907,7 @@ gen8_mfc_avc_pak_object_intra(VADriverContextP ctx, int x, int y, int end_mb,
 }
 
 static int
-gen8_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, int qp,
+gen9_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, int qp,
                               unsigned int *msg, unsigned int offset,
                               struct intel_encoder_context *encoder_context,
                               unsigned char target_mb_size,unsigned char max_mb_size, int slice_type,
@@ -975,8 +977,8 @@ gen8_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, in
     OUT_BCS_BATCH(batch, inter_msg);
 
     OUT_BCS_BATCH(batch, (0xFFFF<<16) | (y << 8) | x);        /* Code Block Pattern for Y*/
-    OUT_BCS_BATCH(batch, 0x000F000F);                         /* Code Block Pattern */  
-#if 0 
+    OUT_BCS_BATCH(batch, 0x000F000F);                         /* Code Block Pattern */
+#if 0
     if ( slice_type == SLICE_TYPE_B) {
         OUT_BCS_BATCH(batch, (0xF<<28) | (end_mb << 26) | qp);	/* Last MB */
     } else {
@@ -988,7 +990,7 @@ gen8_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, in
 
     inter_msg = msg[1] >> 8;
     /*Stuff for Inter MB*/
-    OUT_BCS_BATCH(batch, inter_msg);        
+    OUT_BCS_BATCH(batch, inter_msg);
     OUT_BCS_BATCH(batch, vme_context->ref_index_in_mb[0]);
     OUT_BCS_BATCH(batch, vme_context->ref_index_in_mb[1]);
 
@@ -996,8 +998,7 @@ gen8_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, in
     OUT_BCS_BATCH(batch, (max_mb_size << 24) |
                   (target_mb_size << 16) );
 
-    OUT_BCS_BATCH(batch, 0x0);    
-
+    OUT_BCS_BATCH(batch, 0x0);
     ADVANCE_BCS_BATCH(batch);
 
     return len_in_dwords;
@@ -1005,12 +1006,12 @@ gen8_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, in
 
 #define		AVC_INTRA_RDO_OFFSET	4
 #define		AVC_INTER_RDO_OFFSET	10
-#define		AVC_INTER_MSG_OFFSET	8	
+#define		AVC_INTER_MSG_OFFSET	8
 #define		AVC_INTER_MV_OFFSET		48
 #define		AVC_RDO_MASK		0xFFFF
 
-static void 
-gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
+static void
+gen9_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
                                        struct encode_state *encode_state,
                                        struct intel_encoder_context *encoder_context,
                                        int slice_index,
@@ -1020,7 +1021,7 @@ gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
     VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
-    VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[slice_index]->buffer; 
+    VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[slice_index]->buffer;
     unsigned int *msg = NULL, offset = 0;
     unsigned char *msg_ptr = NULL;
     int width_in_mbs = (mfc_context->surface_state.width + 15) / 16;
@@ -1049,16 +1050,16 @@ gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
     assert(pPicParameter->pic_init_qp >= 0 && pPicParameter->pic_init_qp < 52);
     assert(qp >= 0 && qp < 52);
 
-    gen8_mfc_avc_slice_state(ctx,
-                             pPicParameter,
-                             pSliceParameter,
-                             encode_state, encoder_context,
-                             (rate_control_mode == VA_RC_CBR), qp_slice, slice_batch);
+         gen9_mfc_avc_slice_state(ctx,
+                                  pPicParameter,
+                                  pSliceParameter,
+                                  encode_state, encoder_context,
+                                  (rate_control_mode == VA_RC_CBR), qp_slice, slice_batch);
 
-    if ( slice_index == 0)
-        intel_mfc_avc_pipeline_header_programing(ctx, encode_state, encoder_context, slice_batch);
+        if ( slice_index == 0)
+            intel_mfc_avc_pipeline_header_programing(ctx, encode_state, encoder_context, slice_batch);
 
-    intel_avc_slice_insert_packed_data(ctx, encode_state, encoder_context, slice_index, slice_batch);
+         intel_avc_slice_insert_packed_data(ctx, encode_state, encoder_context, slice_index, slice_batch);
 
     dri_bo_map(vme_context->vme_output.bo , 1);
     msg_ptr = (unsigned char *)vme_context->vme_output.bo->virtual;
@@ -1068,9 +1069,9 @@ gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
     } else {
         msg = (unsigned int *) (msg_ptr + pSliceParameter->macroblock_address * vme_context->vme_output.size_block);
     }
-   
-    for (i = pSliceParameter->macroblock_address; 
-         i < pSliceParameter->macroblock_address + pSliceParameter->num_macroblocks; i++) {
+
+    for (i = pSliceParameter->macroblock_address;
+        i < pSliceParameter->macroblock_address + pSliceParameter->num_macroblocks; i++) {
         int last_mb = (i == (pSliceParameter->macroblock_address + pSliceParameter->num_macroblocks - 1) );
         x = i % width_in_mbs;
         y = i / width_in_mbs;
@@ -1078,24 +1079,24 @@ gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
 
         if (is_intra) {
             assert(msg);
-            gen8_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg, encoder_context, 0, 0, slice_batch);
+            gen9_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg, encoder_context, 0, 0, slice_batch);
         } else {
 	    int inter_rdo, intra_rdo;
 	    inter_rdo = msg[AVC_INTER_RDO_OFFSET] & AVC_RDO_MASK;
 	    intra_rdo = msg[AVC_INTRA_RDO_OFFSET] & AVC_RDO_MASK;
 	    offset = i * vme_context->vme_output.size_block + AVC_INTER_MV_OFFSET;
-	    if (intra_rdo < inter_rdo) { 
-                gen8_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg, encoder_context, 0, 0, slice_batch);
+	    if (intra_rdo < inter_rdo) {
+                gen9_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg, encoder_context, 0, 0, slice_batch);
             } else {
 		msg += AVC_INTER_MSG_OFFSET;
-                gen8_mfc_avc_pak_object_inter(ctx, x, y, last_mb, qp, msg, offset, encoder_context, 0, 0, pSliceParameter->slice_type, slice_batch);
+                gen9_mfc_avc_pak_object_inter(ctx, x, y, last_mb, qp, msg, offset, encoder_context, 0, 0, pSliceParameter->slice_type, slice_batch);
             }
         }
     }
-   
+
     dri_bo_unmap(vme_context->vme_output.bo);
 
-    if ( last_slice ) {    
+    if ( last_slice ) {
         mfc_context->insert_object(ctx, encoder_context,
                                    tail_data, 2, 8,
                                    2, 1, 1, 0, slice_batch);
@@ -1104,15 +1105,16 @@ gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
                                    tail_data, 1, 8,
                                    1, 1, 1, 0, slice_batch);
     }
+
+
 }
 
 static dri_bo *
-gen8_mfc_avc_software_batchbuffer(VADriverContextP ctx,
+gen9_mfc_avc_software_batchbuffer(VADriverContextP ctx,
                                   struct encode_state *encode_state,
                                   struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch;
     dri_bo *batch_bo;
     int i;
@@ -1120,11 +1122,11 @@ gen8_mfc_avc_software_batchbuffer(VADriverContextP ctx,
     batch = mfc_context->aux_batchbuffer;
     batch_bo = batch->buffer;
     for (i = 0; i < encode_state->num_slice_params_ext; i++) {
-        gen8_mfc_avc_pipeline_slice_programing(ctx, encode_state, encoder_context, i, batch);
+        gen9_mfc_avc_pipeline_slice_programing(ctx, encode_state, encoder_context, i, batch);
     }
 
     intel_batchbuffer_align(batch, 8);
-    
+
     BEGIN_BCS_BATCH(batch, 2);
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, MI_BATCH_BUFFER_END);
@@ -1140,7 +1142,7 @@ gen8_mfc_avc_software_batchbuffer(VADriverContextP ctx,
 #else
 
 static void
-gen8_mfc_batchbuffer_surfaces_input(VADriverContextP ctx,
+gen9_mfc_batchbuffer_surfaces_input(VADriverContextP ctx,
                                     struct encode_state *encode_state,
                                     struct intel_encoder_context *encoder_context)
 
@@ -1163,7 +1165,7 @@ gen8_mfc_batchbuffer_surfaces_input(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_batchbuffer_surfaces_output(VADriverContextP ctx,
+gen9_mfc_batchbuffer_surfaces_output(VADriverContextP ctx,
                                      struct encode_state *encode_state,
                                      struct intel_encoder_context *encoder_context)
 
@@ -1176,7 +1178,7 @@ gen8_mfc_batchbuffer_surfaces_output(VADriverContextP ctx,
     mfc_context->mfc_batchbuffer_surface.num_blocks = width_in_mbs * height_in_mbs + encode_state->num_slice_params_ext * 8 + 1;
     mfc_context->mfc_batchbuffer_surface.size_block = 16 * CMD_LEN_IN_OWORD; /* 3 OWORDs */
     mfc_context->mfc_batchbuffer_surface.pitch = 16;
-    mfc_context->mfc_batchbuffer_surface.bo = dri_bo_alloc(i965->intel.bufmgr, 
+    mfc_context->mfc_batchbuffer_surface.bo = dri_bo_alloc(i965->intel.bufmgr,
                                                            "MFC batchbuffer",
                                                            mfc_context->mfc_batchbuffer_surface.num_blocks * mfc_context->mfc_batchbuffer_surface.size_block,
                                                            0x1000);
@@ -1188,21 +1190,21 @@ gen8_mfc_batchbuffer_surfaces_output(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_batchbuffer_surfaces_setup(VADriverContextP ctx, 
+gen9_mfc_batchbuffer_surfaces_setup(VADriverContextP ctx,
                                     struct encode_state *encode_state,
                                     struct intel_encoder_context *encoder_context)
 {
-    gen8_mfc_batchbuffer_surfaces_input(ctx, encode_state, encoder_context);
-    gen8_mfc_batchbuffer_surfaces_output(ctx, encode_state, encoder_context);
+    gen9_mfc_batchbuffer_surfaces_input(ctx, encode_state, encoder_context);
+    gen9_mfc_batchbuffer_surfaces_output(ctx, encode_state, encoder_context);
 }
 
 static void
-gen8_mfc_batchbuffer_idrt_setup(VADriverContextP ctx, 
+gen9_mfc_batchbuffer_idrt_setup(VADriverContextP ctx,
                                 struct encode_state *encode_state,
                                 struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
-    struct gen6_interface_descriptor_data *desc;   
+    struct gen6_interface_descriptor_data *desc;
     int i;
     dri_bo *bo;
 
@@ -1226,9 +1228,9 @@ gen8_mfc_batchbuffer_idrt_setup(VADriverContextP ctx,
         desc->desc3.binding_table_pointer = (BINDING_TABLE_OFFSET(0) >> 5);
         desc->desc4.constant_urb_entry_read_offset = 0;
         desc->desc4.constant_urb_entry_read_length = 4;
- 		
+
         /*kernel start*/
-        dri_bo_emit_reloc(bo,	
+        dri_bo_emit_reloc(bo,
                           I915_GEM_DOMAIN_INSTRUCTION, 0,
                           0,
                           i * sizeof(*desc) + offsetof(struct gen6_interface_descriptor_data, desc0),
@@ -1240,17 +1242,17 @@ gen8_mfc_batchbuffer_idrt_setup(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_batchbuffer_constant_setup(VADriverContextP ctx, 
+gen9_mfc_batchbuffer_constant_setup(VADriverContextP ctx,
                                     struct encode_state *encode_state,
                                     struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
-    
+
     (void)mfc_context;
 }
 
 static void
-gen8_mfc_batchbuffer_emit_object_command(struct intel_batchbuffer *batch,
+gen9_mfc_batchbuffer_emit_object_command(struct intel_batchbuffer *batch,
                                          int index,
                                          int head_offset,
                                          int batchbuffer_offset,
@@ -1266,18 +1268,18 @@ gen8_mfc_batchbuffer_emit_object_command(struct intel_batchbuffer *batch,
                                          int qp)
 {
     BEGIN_BATCH(batch, 12);
-    
+
     OUT_BATCH(batch, CMD_MEDIA_OBJECT | (12 - 2));
     OUT_BATCH(batch, index);
     OUT_BATCH(batch, 0);
     OUT_BATCH(batch, 0);
     OUT_BATCH(batch, 0);
     OUT_BATCH(batch, 0);
-   
+
     /*inline data */
     OUT_BATCH(batch, head_offset);
     OUT_BATCH(batch, batchbuffer_offset);
-    OUT_BATCH(batch, 
+    OUT_BATCH(batch,
               head_size << 16 |
               tail_size);
     OUT_BATCH(batch,
@@ -1296,7 +1298,7 @@ gen8_mfc_batchbuffer_emit_object_command(struct intel_batchbuffer *batch,
 }
 
 static void
-gen8_mfc_avc_batchbuffer_slice_command(VADriverContextP ctx,
+gen9_mfc_avc_batchbuffer_slice_command(VADriverContextP ctx,
                                        struct intel_encoder_context *encoder_context,
                                        VAEncSliceParameterBufferH264 *slice_param,
                                        int head_offset,
@@ -1326,7 +1328,7 @@ gen8_mfc_avc_batchbuffer_slice_command(VADriverContextP ctx,
 
         starting_mb += number_mb_cmds;
 
-        gen8_mfc_batchbuffer_emit_object_command(batch,
+        gen9_mfc_batchbuffer_emit_object_command(batch,
                                                  index,
                                                  head_offset,
                                                  batchbuffer_offset,
@@ -1364,7 +1366,7 @@ gen8_mfc_avc_batchbuffer_slice_command(VADriverContextP ctx,
         assert(mb_x <= 255 && mb_y <= 255);
         starting_mb += number_mb_cmds;
 
-        gen8_mfc_batchbuffer_emit_object_command(batch,
+        gen9_mfc_batchbuffer_emit_object_command(batch,
                                                  index,
                                                  head_offset,
                                                  batchbuffer_offset,
@@ -1380,12 +1382,12 @@ gen8_mfc_avc_batchbuffer_slice_command(VADriverContextP ctx,
                                                  qp);
     }
 }
-                          
+
 /*
  * return size in Owords (16bytes)
- */         
+ */
 static int
-gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
+gen9_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
                                struct encode_state *encode_state,
                                struct intel_encoder_context *encoder_context,
                                int slice_index,
@@ -1395,7 +1397,7 @@ gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
     struct intel_batchbuffer *slice_batch = mfc_context->aux_batchbuffer;
     VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
     VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
-    VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[slice_index]->buffer; 
+    VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[slice_index]->buffer;
     int width_in_mbs = (mfc_context->surface_state.width + 15) / 16;
     int height_in_mbs = (mfc_context->surface_state.height + 15) / 16;
     int last_slice = (pSliceParameter->macroblock_address + pSliceParameter->num_macroblocks) == (width_in_mbs * height_in_mbs);
@@ -1424,7 +1426,7 @@ gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
     assert(qp >= 0 && qp < 52);
 
     head_offset = old_used / 16;
-    gen8_mfc_avc_slice_state(ctx,
+    gen9_mfc_avc_slice_state(ctx,
                              pPicParameter,
                              pSliceParameter,
                              encode_state,
@@ -1436,15 +1438,17 @@ gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
     if (slice_index == 0)
         intel_mfc_avc_pipeline_header_programing(ctx, encode_state, encoder_context, slice_batch);
 
+
     intel_avc_slice_insert_packed_data(ctx, encode_state, encoder_context, slice_index, slice_batch);
 
+
     intel_batchbuffer_align(slice_batch, 16); /* aligned by an Oword */
     used = intel_batchbuffer_used_size(slice_batch);
     head_size = (used - old_used) / 16;
     old_used = used;
 
     /* tail */
-    if (last_slice) {    
+    if (last_slice) {
         mfc_context->insert_object(ctx,
                                    encoder_context,
                                    tail_data,
@@ -1472,8 +1476,7 @@ gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
     used = intel_batchbuffer_used_size(slice_batch);
     tail_size = (used - old_used) / 16;
 
-   
-    gen8_mfc_avc_batchbuffer_slice_command(ctx,
+    gen9_mfc_avc_batchbuffer_slice_command(ctx,
                                            encoder_context,
                                            pSliceParameter,
                                            head_offset,
@@ -1487,18 +1490,19 @@ gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_avc_batchbuffer_pipeline(VADriverContextP ctx,
+gen9_mfc_avc_batchbuffer_pipeline(VADriverContextP ctx,
                                   struct encode_state *encode_state,
                                   struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
     struct intel_batchbuffer *batch = encoder_context->base.batch;
     int i, size, offset = 0;
-    intel_batchbuffer_start_atomic(batch, 0x4000); 
+
+    intel_batchbuffer_start_atomic(batch, 0x4000);
     gen6_gpe_pipeline_setup(ctx, &mfc_context->gpe_context, batch);
 
     for ( i = 0; i < encode_state->num_slice_params_ext; i++) {
-        size = gen8_mfc_avc_batchbuffer_slice(ctx, encode_state, encoder_context, i, offset);
+        size = gen9_mfc_avc_batchbuffer_slice(ctx, encode_state, encoder_context, i, offset);
         offset += size;
     }
 
@@ -1507,24 +1511,24 @@ gen8_mfc_avc_batchbuffer_pipeline(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_build_avc_batchbuffer(VADriverContextP ctx, 
+gen9_mfc_build_avc_batchbuffer(VADriverContextP ctx,
                                struct encode_state *encode_state,
                                struct intel_encoder_context *encoder_context)
 {
-    gen8_mfc_batchbuffer_surfaces_setup(ctx, encode_state, encoder_context);
-    gen8_mfc_batchbuffer_idrt_setup(ctx, encode_state, encoder_context);
-    gen8_mfc_batchbuffer_constant_setup(ctx, encode_state, encoder_context);
-    gen8_mfc_avc_batchbuffer_pipeline(ctx, encode_state, encoder_context);
+    gen9_mfc_batchbuffer_surfaces_setup(ctx, encode_state, encoder_context);
+    gen9_mfc_batchbuffer_idrt_setup(ctx, encode_state, encoder_context);
+    gen9_mfc_batchbuffer_constant_setup(ctx, encode_state, encoder_context);
+    gen9_mfc_avc_batchbuffer_pipeline(ctx, encode_state, encoder_context);
 }
 
 static dri_bo *
-gen8_mfc_avc_hardware_batchbuffer(VADriverContextP ctx,
+gen9_mfc_avc_hardware_batchbuffer(VADriverContextP ctx,
                                   struct encode_state *encode_state,
                                   struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
 
-    gen8_mfc_build_avc_batchbuffer(ctx, encode_state, encoder_context);
+    gen9_mfc_build_avc_batchbuffer(ctx, encode_state, encoder_context);
     dri_bo_reference(mfc_context->mfc_batchbuffer_surface.bo);
 
     return mfc_context->mfc_batchbuffer_surface.bo;
@@ -1533,7 +1537,7 @@ gen8_mfc_avc_hardware_batchbuffer(VADriverContextP ctx,
 #endif
 
 static void
-gen8_mfc_avc_pipeline_programing(VADriverContextP ctx,
+gen9_mfc_avc_pipeline_programing(VADriverContextP ctx,
                                  struct encode_state *encode_state,
                                  struct intel_encoder_context *encoder_context)
 {
@@ -1543,27 +1547,27 @@ gen8_mfc_avc_pipeline_programing(VADriverContextP ctx,
     if ( intel_mfc_interlace_check(ctx, encode_state, encoder_context) ) {
         fprintf(stderr, "Current VA driver don't support interlace mode!\n");
         assert(0);
-        return; 
+        return;
     }
 
 #ifdef MFC_SOFTWARE_HASWELL
-    slice_batch_bo = gen8_mfc_avc_software_batchbuffer(ctx, encode_state, encoder_context);
+    slice_batch_bo = gen9_mfc_avc_software_batchbuffer(ctx, encode_state, encoder_context);
 #else
-    slice_batch_bo = gen8_mfc_avc_hardware_batchbuffer(ctx, encode_state, encoder_context);
+    slice_batch_bo = gen9_mfc_avc_hardware_batchbuffer(ctx, encode_state, encoder_context);
 #endif
 
     // begin programing
-    intel_batchbuffer_start_atomic_bcs(batch, 0x4000); 
+    intel_batchbuffer_start_atomic_bcs(batch, 0x4000);
     intel_batchbuffer_emit_mi_flush(batch);
-    
+
     // picture level programing
-    gen8_mfc_avc_pipeline_picture_programing(ctx, encode_state, encoder_context);
+    gen9_mfc_avc_pipeline_picture_programing(ctx, encode_state, encoder_context);
 
     BEGIN_BCS_BATCH(batch, 3);
     OUT_BCS_BATCH(batch, MI_BATCH_BUFFER_START | (1 << 8) | (1 << 0));
     OUT_BCS_RELOC(batch,
                   slice_batch_bo,
-                  I915_GEM_DOMAIN_COMMAND, 0, 
+                  I915_GEM_DOMAIN_COMMAND, 0,
                   0);
     OUT_BCS_BATCH(batch, 0);
     ADVANCE_BCS_BATCH(batch);
@@ -1576,7 +1580,7 @@ gen8_mfc_avc_pipeline_programing(VADriverContextP ctx,
 
 
 static VAStatus
-gen8_mfc_avc_encode_picture(VADriverContextP ctx, 
+gen9_mfc_avc_encode_picture(VADriverContextP ctx,
                             struct encode_state *encode_state,
                             struct intel_encoder_context *encoder_context)
 {
@@ -1584,15 +1588,15 @@ gen8_mfc_avc_encode_picture(VADriverContextP ctx,
     unsigned int rate_control_mode = encoder_context->rate_control_mode;
     int current_frame_bits_size;
     int sts;
- 
+
     for (;;) {
-        gen8_mfc_init(ctx, encode_state, encoder_context);
+        gen9_mfc_init(ctx, encode_state, encoder_context);
         intel_mfc_avc_prepare(ctx, encode_state, encoder_context);
         /*Programing bcs pipeline*/
-        gen8_mfc_avc_pipeline_programing(ctx, encode_state, encoder_context);	//filling the pipeline
-        gen8_mfc_run(ctx, encode_state, encoder_context);
+        gen9_mfc_avc_pipeline_programing(ctx, encode_state, encoder_context);	//filling the pipeline
+        gen9_mfc_run(ctx, encode_state, encoder_context);
         if (rate_control_mode == VA_RC_CBR /*|| rate_control_mode == VA_RC_VBR*/) {
-            gen8_mfc_stop(ctx, encode_state, encoder_context, &current_frame_bits_size);
+            gen9_mfc_stop(ctx, encode_state, encoder_context, &current_frame_bits_size);
             sts = intel_mfc_brc_postpack(encode_state, mfc_context, current_frame_bits_size);
             if (sts == BRC_NO_HRD_VIOLATION) {
                 intel_mfc_hrd_context_update(encode_state, mfc_context);
@@ -1618,14 +1622,14 @@ gen8_mfc_avc_encode_picture(VADriverContextP ctx,
  */
 
 static const int
-va_to_gen8_mpeg2_picture_type[3] = {
+va_to_gen9_mpeg2_picture_type[3] = {
     1,  /* I */
     2,  /* P */
     3   /* B */
 };
 
 static void
-gen8_mfc_mpeg2_pic_state(VADriverContextP ctx,
+gen9_mfc_mpeg2_pic_state(VADriverContextP ctx,
                          struct intel_encoder_context *encoder_context,
                          struct encode_state *encode_state)
 {
@@ -1653,11 +1657,11 @@ gen8_mfc_mpeg2_pic_state(VADriverContextP ctx,
                   pic_param->picture_coding_extension.bits.frame_pred_frame_dct << 10 |
                   pic_param->picture_coding_extension.bits.concealment_motion_vectors << 9 |
                   pic_param->picture_coding_extension.bits.q_scale_type << 8 |
-                  pic_param->picture_coding_extension.bits.intra_vlc_format << 7 | 
+                  pic_param->picture_coding_extension.bits.intra_vlc_format << 7 |
                   pic_param->picture_coding_extension.bits.alternate_scan << 6);
     OUT_BCS_BATCH(batch,
                   0 << 14 |     /* LoadSlicePointerFlag, 0 means only loading bitstream pointer once */
-                  va_to_gen8_mpeg2_picture_type[pic_param->picture_type] << 9 |
+                  va_to_gen9_mpeg2_picture_type[pic_param->picture_type] << 9 |
                   0);
     OUT_BCS_BATCH(batch,
                   1 << 31 |     /* slice concealment */
@@ -1684,7 +1688,7 @@ gen8_mfc_mpeg2_pic_state(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_mpeg2_qm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+gen9_mfc_mpeg2_qm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     unsigned char intra_qm[64] = {
         8, 16, 19, 22, 26, 27, 29, 34,
@@ -1708,12 +1712,12 @@ gen8_mfc_mpeg2_qm_state(VADriverContextP ctx, struct intel_encoder_context *enco
         16, 16, 16, 16, 16, 16, 16, 16
     };
 
-    gen8_mfc_qm_state(ctx, MFX_QM_MPEG_INTRA_QUANTIZER_MATRIX, (unsigned int *)intra_qm, 16, encoder_context);
-    gen8_mfc_qm_state(ctx, MFX_QM_MPEG_NON_INTRA_QUANTIZER_MATRIX, (unsigned int *)non_intra_qm, 16,encoder_context);
+    gen9_mfc_qm_state(ctx, MFX_QM_MPEG_INTRA_QUANTIZER_MATRIX, (unsigned int *)intra_qm, 16, encoder_context);
+    gen9_mfc_qm_state(ctx, MFX_QM_MPEG_NON_INTRA_QUANTIZER_MATRIX, (unsigned int *)non_intra_qm, 16,encoder_context);
 }
 
 static void
-gen8_mfc_mpeg2_fqm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+gen9_mfc_mpeg2_fqm_state(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     unsigned short intra_fqm[64] = {
         65536/0x8, 65536/0x10, 65536/0x13, 65536/0x16, 65536/0x16, 65536/0x1a, 65536/0x1a, 65536/0x1b,
@@ -1737,12 +1741,12 @@ gen8_mfc_mpeg2_fqm_state(VADriverContextP ctx, struct intel_encoder_context *enc
         0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
     };
 
-    gen8_mfc_fqm_state(ctx, MFX_QM_MPEG_INTRA_QUANTIZER_MATRIX, (unsigned int *)intra_fqm, 32, encoder_context);
-    gen8_mfc_fqm_state(ctx, MFX_QM_MPEG_NON_INTRA_QUANTIZER_MATRIX, (unsigned int *)non_intra_fqm, 32, encoder_context);
+    gen9_mfc_fqm_state(ctx, MFX_QM_MPEG_INTRA_QUANTIZER_MATRIX, (unsigned int *)intra_fqm, 32, encoder_context);
+    gen9_mfc_fqm_state(ctx, MFX_QM_MPEG_NON_INTRA_QUANTIZER_MATRIX, (unsigned int *)non_intra_fqm, 32, encoder_context);
 }
 
 static void
-gen8_mfc_mpeg2_slicegroup_state(VADriverContextP ctx,
+gen9_mfc_mpeg2_slicegroup_state(VADriverContextP ctx,
                                 struct intel_encoder_context *encoder_context,
                                 int x, int y,
                                 int next_x, int next_y,
@@ -1777,7 +1781,7 @@ gen8_mfc_mpeg2_slicegroup_state(VADriverContextP ctx,
                   x << 0 |
                   0);
     OUT_BCS_BATCH(batch, qp);   /* FIXME: SliceGroupQp */
-    /* bitstream pointer is only loaded once for the first slice of a frame when 
+    /* bitstream pointer is only loaded once for the first slice of a frame when
      * LoadSlicePointerFlag is 0
      */
     OUT_BCS_BATCH(batch, mfc_context->mfc_indirect_pak_bse_object.offset);
@@ -1789,7 +1793,7 @@ gen8_mfc_mpeg2_slicegroup_state(VADriverContextP ctx,
 }
 
 static int
-gen8_mfc_mpeg2_pak_object_intra(VADriverContextP ctx,
+gen9_mfc_mpeg2_pak_object_intra(VADriverContextP ctx,
                                 struct intel_encoder_context *encoder_context,
                                 int x, int y,
                                 int first_mb_in_slice,
@@ -1849,7 +1853,7 @@ gen8_mfc_mpeg2_pak_object_intra(VADriverContextP ctx,
 }
 
 /* Byte offset */
-#define MPEG2_INTER_MV_OFFSET   48 
+#define MPEG2_INTER_MV_OFFSET   48
 
 static struct _mv_ranges
 {
@@ -1887,7 +1891,7 @@ mpeg2_motion_vector(int mv, int pos, int display_max, int f_code)
 }
 
 static int
-gen8_mfc_mpeg2_pak_object_inter(VADriverContextP ctx,
+gen9_mfc_mpeg2_pak_object_inter(VADriverContextP ctx,
                                 struct encode_state *encode_state,
                                 struct intel_encoder_context *encoder_context,
                                 unsigned int *msg,
@@ -1905,7 +1909,7 @@ gen8_mfc_mpeg2_pak_object_inter(VADriverContextP ctx,
     VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
     int len_in_dwords = 9;
     short *mvptr, mvx0, mvy0, mvx1, mvy1;
-    
+
     if (batch == NULL)
         batch = encoder_context->base.batch;
 
@@ -2010,8 +2014,8 @@ intel_mfc_mpeg2_pipeline_header_programing(VADriverContextP ctx,
     }
 }
 
-static void 
-gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
+static void
+gen9_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
                                     struct encode_state *encode_state,
                                     struct intel_encoder_context *encoder_context,
                                     int slice_index,
@@ -2047,7 +2051,7 @@ gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
         v_next_start_pos = height_in_mbs;
     }
 
-    gen8_mfc_mpeg2_slicegroup_state(ctx,
+    gen9_mfc_mpeg2_slicegroup_state(ctx,
                                     encoder_context,
                                     h_start_pos,
                                     v_start_pos,
@@ -2059,7 +2063,7 @@ gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
                                     slice_param->quantiser_scale_code,
                                     slice_batch);
 
-    if (slice_index == 0) 
+    if (slice_index == 0)
         intel_mfc_mpeg2_pipeline_header_programing(ctx, encode_state, encoder_context, slice_batch);
 
     /* Insert '00' to make sure the header is valid */
@@ -2088,7 +2092,7 @@ gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
             msg = (unsigned int *)(msg_ptr + (slice_param->macroblock_address + j) * vme_context->vme_output.size_block);
 
             if (slice_param->is_intra_slice) {
-                gen8_mfc_mpeg2_pak_object_intra(ctx,
+                gen9_mfc_mpeg2_pak_object_intra(ctx,
                                                 encoder_context,
                                                 h_pos, v_pos,
                                                 first_mb_in_slice,
@@ -2106,8 +2110,8 @@ gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
 		inter_rdo = msg[AVC_INTER_RDO_OFFSET] & AVC_RDO_MASK;
 		intra_rdo = msg[AVC_INTRA_RDO_OFFSET] & AVC_RDO_MASK;
 
-		if (intra_rdo < inter_rdo) 
-                    gen8_mfc_mpeg2_pak_object_intra(ctx,
+		if (intra_rdo < inter_rdo)
+                    gen9_mfc_mpeg2_pak_object_intra(ctx,
                                                      encoder_context,
                                                      h_pos, v_pos,
                                                      first_mb_in_slice,
@@ -2121,7 +2125,7 @@ gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
                                                      0xff,
                                                      slice_batch);
 		else
-                    gen8_mfc_mpeg2_pak_object_inter(ctx,
+                    gen9_mfc_mpeg2_pak_object_inter(ctx,
                                                 encode_state,
                                                 encoder_context,
                                                 msg,
@@ -2169,18 +2173,16 @@ gen8_mfc_mpeg2_pipeline_slice_group(VADriverContextP ctx,
     }
 }
 
-/* 
- * A batch buffer for all slices, including slice state, 
+/*
+ * A batch buffer for all slices, including slice state
  * slice insert object and slice pak object commands
- *
  */
 static dri_bo *
-gen8_mfc_mpeg2_software_slice_batchbuffer(VADriverContextP ctx,
+gen9_mfc_mpeg2_software_slice_batchbuffer(VADriverContextP ctx,
                                           struct encode_state *encode_state,
                                           struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch;
     VAEncSliceParameterBufferMPEG2 *next_slice_group_param = NULL;
     dri_bo *batch_bo;
@@ -2195,11 +2197,11 @@ gen8_mfc_mpeg2_software_slice_batchbuffer(VADriverContextP ctx,
         else
             next_slice_group_param = (VAEncSliceParameterBufferMPEG2 *)encode_state->slice_params_ext[i + 1]->buffer;
 
-        gen8_mfc_mpeg2_pipeline_slice_group(ctx, encode_state, encoder_context, i, next_slice_group_param, batch);
+        gen9_mfc_mpeg2_pipeline_slice_group(ctx, encode_state, encoder_context, i, next_slice_group_param, batch);
     }
 
     intel_batchbuffer_align(batch, 8);
-    
+
     BEGIN_BCS_BATCH(batch, 2);
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, MI_BATCH_BUFFER_END);
@@ -2213,7 +2215,7 @@ gen8_mfc_mpeg2_software_slice_batchbuffer(VADriverContextP ctx,
 }
 
 static void
-gen8_mfc_mpeg2_pipeline_picture_programing(VADriverContextP ctx,
+gen9_mfc_mpeg2_pipeline_picture_programing(VADriverContextP ctx,
                                            struct encode_state *encode_state,
                                            struct intel_encoder_context *encoder_context)
 {
@@ -2222,35 +2224,35 @@ gen8_mfc_mpeg2_pipeline_picture_programing(VADriverContextP ctx,
     mfc_context->pipe_mode_select(ctx, MFX_FORMAT_MPEG2, encoder_context);
     mfc_context->set_surface_state(ctx, encoder_context);
     mfc_context->ind_obj_base_addr_state(ctx, encoder_context);
-    gen8_mfc_pipe_buf_addr_state(ctx, encoder_context);
-    gen8_mfc_bsp_buf_base_addr_state(ctx, encoder_context);
-    gen8_mfc_mpeg2_pic_state(ctx, encoder_context, encode_state);
-    gen8_mfc_mpeg2_qm_state(ctx, encoder_context);
-    gen8_mfc_mpeg2_fqm_state(ctx, encoder_context);
+    gen9_mfc_pipe_buf_addr_state(ctx, encoder_context);
+    gen9_mfc_bsp_buf_base_addr_state(ctx, encoder_context);
+    gen9_mfc_mpeg2_pic_state(ctx, encoder_context, encode_state);
+    gen9_mfc_mpeg2_qm_state(ctx, encoder_context);
+    gen9_mfc_mpeg2_fqm_state(ctx, encoder_context);
 }
 
 static void
-gen8_mfc_mpeg2_pipeline_programing(VADriverContextP ctx,
+gen9_mfc_mpeg2_pipeline_programing(VADriverContextP ctx,
                                    struct encode_state *encode_state,
                                    struct intel_encoder_context *encoder_context)
 {
     struct intel_batchbuffer *batch = encoder_context->base.batch;
     dri_bo *slice_batch_bo;
 
-    slice_batch_bo = gen8_mfc_mpeg2_software_slice_batchbuffer(ctx, encode_state, encoder_context);
+    slice_batch_bo = gen9_mfc_mpeg2_software_slice_batchbuffer(ctx, encode_state, encoder_context);
 
     // begin programing
-    intel_batchbuffer_start_atomic_bcs(batch, 0x4000); 
+    intel_batchbuffer_start_atomic_bcs(batch, 0x4000);
     intel_batchbuffer_emit_mi_flush(batch);
-    
+
     // picture level programing
-    gen8_mfc_mpeg2_pipeline_picture_programing(ctx, encode_state, encoder_context);
+    gen9_mfc_mpeg2_pipeline_picture_programing(ctx, encode_state, encoder_context);
 
     BEGIN_BCS_BATCH(batch, 4);
     OUT_BCS_BATCH(batch, MI_BATCH_BUFFER_START | (1 << 8) | (1 << 0));
     OUT_BCS_RELOC(batch,
                   slice_batch_bo,
-                  I915_GEM_DOMAIN_COMMAND, 0, 
+                  I915_GEM_DOMAIN_COMMAND, 0,
                   0);
     OUT_BCS_BATCH(batch, 0);
     OUT_BCS_BATCH(batch, 0);
@@ -2263,12 +2265,12 @@ gen8_mfc_mpeg2_pipeline_programing(VADriverContextP ctx,
 }
 
 static VAStatus
-intel_mfc_mpeg2_prepare(VADriverContextP ctx, 
+intel_mfc_mpeg2_prepare(VADriverContextP ctx,
                         struct encode_state *encode_state,
                         struct intel_encoder_context *encoder_context)
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
-    struct object_surface *obj_surface;	
+    struct object_surface *obj_surface;
     struct object_buffer *obj_buffer;
     struct i965_coded_buffer_segment *coded_buffer_segment;
     VAStatus vaStatus = VA_STATUS_SUCCESS;
@@ -2277,7 +2279,7 @@ intel_mfc_mpeg2_prepare(VADriverContextP ctx,
 
     /* reconstructed surface */
     obj_surface = encode_state->reconstructed_object;
-    i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
+    i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
     mfc_context->pre_deblocking_output.bo = obj_surface->bo;
     dri_bo_reference(mfc_context->pre_deblocking_output.bo);
     mfc_context->surface_state.width = obj_surface->orig_width;
@@ -2313,7 +2315,7 @@ intel_mfc_mpeg2_prepare(VADriverContextP ctx,
         if (mfc_context->reference_surfaces[i].bo)
             dri_bo_reference(mfc_context->reference_surfaces[i].bo);
     }
-    
+
     /* input YUV surface */
     obj_surface = encode_state->input_yuv_object;
     mfc_context->uncompressed_picture_source.bo = obj_surface->bo;
@@ -2338,21 +2340,21 @@ intel_mfc_mpeg2_prepare(VADriverContextP ctx,
 }
 
 static VAStatus
-gen8_mfc_mpeg2_encode_picture(VADriverContextP ctx, 
+gen9_mfc_mpeg2_encode_picture(VADriverContextP ctx,
                               struct encode_state *encode_state,
                               struct intel_encoder_context *encoder_context)
 {
-    gen8_mfc_init(ctx, encode_state, encoder_context);
+    gen9_mfc_init(ctx, encode_state, encoder_context);
     intel_mfc_mpeg2_prepare(ctx, encode_state, encoder_context);
     /*Programing bcs pipeline*/
-    gen8_mfc_mpeg2_pipeline_programing(ctx, encode_state, encoder_context);
-    gen8_mfc_run(ctx, encode_state, encoder_context);
+    gen9_mfc_mpeg2_pipeline_programing(ctx, encode_state, encoder_context);
+    gen9_mfc_run(ctx, encode_state, encoder_context);
 
     return VA_STATUS_SUCCESS;
 }
 
 static void
-gen8_mfc_context_destroy(void *context)
+gen9_mfc_context_destroy(void *context)
 {
     struct gen6_mfc_context *mfc_context = context;
     int i;
@@ -2366,7 +2368,7 @@ gen8_mfc_context_destroy(void *context)
     dri_bo_unreference(mfc_context->uncompressed_picture_source.bo);
     mfc_context->uncompressed_picture_source.bo = NULL;
 
-    dri_bo_unreference(mfc_context->mfc_indirect_pak_bse_object.bo); 
+    dri_bo_unreference(mfc_context->mfc_indirect_pak_bse_object.bo);
     mfc_context->mfc_indirect_pak_bse_object.bo = NULL;
 
     for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){
@@ -2389,7 +2391,7 @@ gen8_mfc_context_destroy(void *context)
 
     for (i = 0; i < MAX_MFC_REFERENCE_SURFACES; i++){
         dri_bo_unreference(mfc_context->reference_surfaces[i].bo);
-        mfc_context->reference_surfaces[i].bo = NULL;  
+        mfc_context->reference_surfaces[i].bo = NULL;
     }
 
     i965_gpe_context_destroy(&mfc_context->gpe_context);
@@ -2408,7 +2410,7 @@ gen8_mfc_context_destroy(void *context)
     free(mfc_context);
 }
 
-static VAStatus gen8_mfc_pipeline(VADriverContextP ctx,
+static VAStatus gen9_mfc_pipeline(VADriverContextP ctx,
                                   VAProfile profile,
                                   struct encode_state *encode_state,
                                   struct intel_encoder_context *encoder_context)
@@ -2421,13 +2423,13 @@ static VAStatus gen8_mfc_pipeline(VADriverContextP ctx,
     case VAProfileH264High:
     case VAProfileH264MultiviewHigh:
     case VAProfileH264StereoHigh:
-        vaStatus = gen8_mfc_avc_encode_picture(ctx, encode_state, encoder_context);
+        vaStatus = gen9_mfc_avc_encode_picture(ctx, encode_state, encoder_context);
         break;
 
         /* FIXME: add for other profile */
     case VAProfileMPEG2Simple:
     case VAProfileMPEG2Main:
-        vaStatus = gen8_mfc_mpeg2_encode_picture(ctx, encode_state, encoder_context);
+        vaStatus = gen9_mfc_mpeg2_encode_picture(ctx, encode_state, encoder_context);
         break;
 
     default:
@@ -2438,10 +2440,20 @@ static VAStatus gen8_mfc_pipeline(VADriverContextP ctx,
     return vaStatus;
 }
 
-Bool gen8_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+Bool gen9_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
-    struct gen6_mfc_context *mfc_context = calloc(1, sizeof(struct gen6_mfc_context));
+    struct gen6_mfc_context *mfc_context = NULL;
+
+#if MFC_SOFTWARE_HASWELL
+    if ((encoder_context->codec == CODEC_H264) ||
+        (encoder_context->codec == CODEC_H264_MVC) ||
+        (encoder_context->codec == CODEC_MPEG2)) {
+
+        return gen8_mfc_context_init(ctx, encoder_context);
+    }
+#endif
 
+    mfc_context = calloc(1, sizeof(struct gen6_mfc_context));
     mfc_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
 
     mfc_context->gpe_context.idrt.max_entries = MAX_GPE_KERNELS;
@@ -2457,21 +2469,21 @@ Bool gen8_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *e
 
     i965_gpe_load_kernels(ctx,
                           &mfc_context->gpe_context,
-                          gen8_mfc_kernels,
+                          gen9_mfc_kernels,
                           NUM_MFC_KERNEL);
 
-    mfc_context->pipe_mode_select = gen8_mfc_pipe_mode_select;
-    mfc_context->set_surface_state = gen8_mfc_surface_state;
-    mfc_context->ind_obj_base_addr_state = gen8_mfc_ind_obj_base_addr_state;
-    mfc_context->avc_img_state = gen8_mfc_avc_img_state;
-    mfc_context->avc_qm_state = gen8_mfc_avc_qm_state;
-    mfc_context->avc_fqm_state = gen8_mfc_avc_fqm_state;
-    mfc_context->insert_object = gen8_mfc_avc_insert_object;
+    mfc_context->pipe_mode_select = gen9_mfc_pipe_mode_select;
+    mfc_context->set_surface_state = gen9_mfc_surface_state;
+    mfc_context->ind_obj_base_addr_state = gen9_mfc_ind_obj_base_addr_state;
+    mfc_context->avc_img_state = gen9_mfc_avc_img_state;
+    mfc_context->avc_qm_state = gen9_mfc_avc_qm_state;
+    mfc_context->avc_fqm_state = gen9_mfc_avc_fqm_state;
+    mfc_context->insert_object = gen9_mfc_avc_insert_object;
     mfc_context->buffer_suface_setup = gen8_gpe_buffer_suface_setup;
 
     encoder_context->mfc_context = mfc_context;
-    encoder_context->mfc_context_destroy = gen8_mfc_context_destroy;
-    encoder_context->mfc_pipeline = gen8_mfc_pipeline;
+    encoder_context->mfc_context_destroy = gen9_mfc_context_destroy;
+    encoder_context->mfc_pipeline = gen9_mfc_pipeline;
     encoder_context->mfc_brc_prepare = intel_mfc_brc_prepare;
 
     return True;
diff --git a/src/gen9_mfd.c b/src/gen9_mfd.c
new file mode 100644
index 0000000..68e3ffc
--- /dev/null
+++ b/src/gen9_mfd.c
@@ -0,0 +1,1027 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Xiang Haihao <haihao.xiang at intel.com>
+ *
+ */
+
+#include "sysdeps.h"
+
+#include <va/va.h>
+#include <va/va_dec_hevc.h>
+
+#include "intel_batchbuffer.h"
+#include "intel_driver.h"
+#include "i965_defines.h"
+#include "i965_drv_video.h"
+#include "i965_decoder_utils.h"
+
+#include "gen9_mfd.h"
+#include "intel_media.h"
+
+#define OUT_BUFFER(buf_bo, is_target, ma)  do {                         \
+        if (buf_bo) {                                                   \
+            OUT_BCS_RELOC(batch,                                        \
+                          buf_bo,                                       \
+                          I915_GEM_DOMAIN_RENDER,                       \
+                          is_target ? I915_GEM_DOMAIN_RENDER : 0,       \
+                          0);                                           \
+        } else {                                                        \
+            OUT_BCS_BATCH(batch, 0);                                    \
+        }                                                               \
+        OUT_BCS_BATCH(batch, 0);                                        \
+        if (ma)                                                         \
+            OUT_BCS_BATCH(batch, 0);                                    \
+    } while (0)
+
+#define OUT_BUFFER_MA_TARGET(buf_bo)       OUT_BUFFER(buf_bo, 1, 1)
+#define OUT_BUFFER_MA_REFERENCE(buf_bo)    OUT_BUFFER(buf_bo, 0, 1)
+#define OUT_BUFFER_NMA_TARGET(buf_bo)      OUT_BUFFER(buf_bo, 1, 0)
+#define OUT_BUFFER_NMA_REFERENCE(buf_bo)   OUT_BUFFER(buf_bo, 0, 0)
+
+static void
+gen9_hcpd_init_hevc_surface(VADriverContextP ctx,
+                            VAPictureParameterBufferHEVC *pic_param,
+                            struct object_surface *obj_surface,
+                            struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    GenHevcSurface *gen9_hevc_surface;
+
+    if (!obj_surface)
+        return;
+
+    obj_surface->free_private_data = gen_free_hevc_surface;
+    gen9_hevc_surface = obj_surface->private_data;
+
+    if (!gen9_hevc_surface) {
+        gen9_hevc_surface = calloc(sizeof(GenHevcSurface), 1);
+        gen9_hevc_surface->base.frame_store_id = -1;
+        obj_surface->private_data = gen9_hevc_surface;
+    }
+
+    if (gen9_hevc_surface->motion_vector_temporal_bo == NULL) {
+        uint32_t size;
+
+        if (gen9_hcpd_context->ctb_size == 16)
+            size = ((gen9_hcpd_context->picture_width_in_pixels + 63) >> 6) *
+                ((gen9_hcpd_context->picture_height_in_pixels + 15) >> 4);
+        else
+            size = ((gen9_hcpd_context->picture_width_in_pixels + 31) >> 5) *
+                ((gen9_hcpd_context->picture_height_in_pixels + 31) >> 5);
+
+        size <<= 6; /* in unit of 64bytes */
+        gen9_hevc_surface->motion_vector_temporal_bo = dri_bo_alloc(i965->intel.bufmgr,
+                                                                    "motion vector temporal buffer",
+                                                                    size,
+                                                                    0x1000);
+    }
+}
+
+static VAStatus
+gen9_hcpd_hevc_decode_init(VADriverContextP ctx,
+                           struct decode_state *decode_state,
+                           struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    VAPictureParameterBufferHEVC *pic_param;
+    VASliceParameterBufferHEVC *slice_param;
+    struct object_surface *obj_surface;
+    uint32_t size;
+    int i, j, has_inter = 0;
+
+    for (j = 0; j < decode_state->num_slice_params && !has_inter; j++) {
+        assert(decode_state->slice_params && decode_state->slice_params[j]->buffer);
+        slice_param = (VASliceParameterBufferHEVC *)decode_state->slice_params[j]->buffer;
+
+        for (i = 0; i < decode_state->slice_params[j]->num_elements; i++) {
+            if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_B ||
+                slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_P) {
+                has_inter = 1;
+                break;
+            }
+
+            slice_param++;
+        }
+    }
+
+    assert(decode_state->pic_param && decode_state->pic_param->buffer);
+    pic_param = (VAPictureParameterBufferHEVC *)decode_state->pic_param->buffer;
+    intel_update_hevc_frame_store_index(ctx,
+                                        decode_state,
+                                        pic_param,
+                                        gen9_hcpd_context->reference_surfaces,
+                                        &gen9_hcpd_context->fs_ctx);
+
+    gen9_hcpd_context->picture_width_in_pixels = pic_param->pic_width_in_luma_samples;
+    gen9_hcpd_context->picture_height_in_pixels = pic_param->pic_height_in_luma_samples;
+    gen9_hcpd_context->ctb_size = (1 << (pic_param->log2_min_luma_coding_block_size_minus3 +
+                                         3 +
+                                         pic_param->log2_diff_max_min_luma_coding_block_size));
+    gen9_hcpd_context->picture_width_in_ctbs = ALIGN(gen9_hcpd_context->picture_width_in_pixels, gen9_hcpd_context->ctb_size) / gen9_hcpd_context->ctb_size;
+    gen9_hcpd_context->picture_height_in_ctbs = ALIGN(gen9_hcpd_context->picture_height_in_pixels, gen9_hcpd_context->ctb_size) / gen9_hcpd_context->ctb_size;
+    gen9_hcpd_context->min_cb_size = (1 << (pic_param->log2_min_luma_coding_block_size_minus3 + 3));
+    gen9_hcpd_context->picture_width_in_min_cb_minus1 = gen9_hcpd_context->picture_width_in_pixels / gen9_hcpd_context->min_cb_size - 1;
+    gen9_hcpd_context->picture_height_in_min_cb_minus1 = gen9_hcpd_context->picture_height_in_pixels / gen9_hcpd_context->min_cb_size - 1;
+
+    /* Current decoded picture */
+    obj_surface = decode_state->render_object;
+    hevc_ensure_surface_bo(ctx, decode_state, obj_surface, pic_param);
+    gen9_hcpd_init_hevc_surface(ctx, pic_param, obj_surface, gen9_hcpd_context);
+
+    size = ALIGN(gen9_hcpd_context->picture_width_in_pixels, 32) >> 3;
+    size <<= 6;
+    ALLOC_GEN_BUFFER((&gen9_hcpd_context->deblocking_filter_line_buffer), "line buffer", size);
+    ALLOC_GEN_BUFFER((&gen9_hcpd_context->deblocking_filter_tile_line_buffer), "tile line buffer", size);
+
+    size = ALIGN(gen9_hcpd_context->picture_height_in_pixels + 6 * gen9_hcpd_context->picture_height_in_ctbs, 32) >> 3;
+    size <<= 6;
+    ALLOC_GEN_BUFFER((&gen9_hcpd_context->deblocking_filter_tile_column_buffer), "tile column buffer", size);
+
+    if (has_inter) {
+        size = (((gen9_hcpd_context->picture_width_in_pixels + 15) >> 4) * 188 + 9 * gen9_hcpd_context->picture_width_in_ctbs + 1023) >> 9;
+        size <<= 6;
+        ALLOC_GEN_BUFFER((&gen9_hcpd_context->metadata_line_buffer), "metadata line buffer", size);
+
+        size = (((gen9_hcpd_context->picture_width_in_pixels + 15) >> 4) * 172 + 9 * gen9_hcpd_context->picture_width_in_ctbs + 1023) >> 9;
+        size <<= 6;
+        ALLOC_GEN_BUFFER((&gen9_hcpd_context->metadata_tile_line_buffer), "metadata tile line buffer", size);
+
+        size = (((gen9_hcpd_context->picture_height_in_pixels + 15) >> 4) * 176 + 89 * gen9_hcpd_context->picture_width_in_ctbs + 1023) >> 9;
+        size <<= 6;
+        ALLOC_GEN_BUFFER((&gen9_hcpd_context->metadata_tile_column_buffer), "metadata tile column buffer", size);
+    } else {
+        size = (gen9_hcpd_context->picture_width_in_pixels + 8 * gen9_hcpd_context->picture_width_in_ctbs + 1023) >> 9;
+        size <<= 6;
+        ALLOC_GEN_BUFFER((&gen9_hcpd_context->metadata_line_buffer), "metadata line buffer", size);
+
+        size = (gen9_hcpd_context->picture_width_in_pixels + 16 * gen9_hcpd_context->picture_width_in_ctbs + 1023) >> 9;
+        size <<= 6;
+        ALLOC_GEN_BUFFER((&gen9_hcpd_context->metadata_tile_line_buffer), "metadata tile line buffer", size);
+
+        size = (gen9_hcpd_context->picture_height_in_pixels + 8 * gen9_hcpd_context->picture_height_in_ctbs + 1023) >> 9;
+        size <<= 6;
+        ALLOC_GEN_BUFFER((&gen9_hcpd_context->metadata_tile_column_buffer), "metadata tile column buffer", size);
+    }
+
+    size = ALIGN(((gen9_hcpd_context->picture_width_in_pixels >> 1) + 3 * gen9_hcpd_context->picture_width_in_ctbs), 16) >> 3;
+    size <<= 6;
+    ALLOC_GEN_BUFFER((&gen9_hcpd_context->sao_line_buffer), "sao line buffer", size);
+
+    size = ALIGN(((gen9_hcpd_context->picture_width_in_pixels >> 1) + 6 * gen9_hcpd_context->picture_width_in_ctbs), 16) >> 3;
+    size <<= 6;
+    ALLOC_GEN_BUFFER((&gen9_hcpd_context->sao_tile_line_buffer), "sao tile line buffer", size);
+
+    size = ALIGN(((gen9_hcpd_context->picture_height_in_pixels >> 1) + 6 * gen9_hcpd_context->picture_height_in_ctbs), 16) >> 3;
+    size <<= 6;
+    ALLOC_GEN_BUFFER((&gen9_hcpd_context->sao_tile_column_buffer), "sao tile column buffer", size);
+
+    return VA_STATUS_SUCCESS;
+}
+
+static void
+gen9_hcpd_pipe_mode_select(VADriverContextP ctx,
+                           struct decode_state *decode_state,
+                           int codec,
+                           struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+
+    assert(codec == HCP_CODEC_HEVC);
+
+    BEGIN_BCS_BATCH(batch, 4);
+
+    OUT_BCS_BATCH(batch, HCP_PIPE_MODE_SELECT | (4 - 2));
+    OUT_BCS_BATCH(batch,
+                  (codec << 5) |
+                  (0 << 3) | /* disable Pic Status / Error Report */
+                  HCP_CODEC_SELECT_DECODE);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_surface_state(VADriverContextP ctx,
+                        struct decode_state *decode_state,
+                        struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    struct object_surface *obj_surface = decode_state->render_object;
+    unsigned int y_cb_offset;
+
+    assert(obj_surface);
+
+    y_cb_offset = obj_surface->y_cb_offset;
+
+    BEGIN_BCS_BATCH(batch, 3);
+
+    OUT_BCS_BATCH(batch, HCP_SURFACE_STATE | (3 - 2));
+    OUT_BCS_BATCH(batch,
+                  (0 << 28) |                   /* surface id */
+                  (obj_surface->width - 1));    /* pitch - 1 */
+    OUT_BCS_BATCH(batch,
+                  (SURFACE_FORMAT_PLANAR_420_8 << 28) |
+                  y_cb_offset);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_pipe_buf_addr_state(VADriverContextP ctx,
+                              struct decode_state *decode_state,
+                              struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    struct object_surface *obj_surface;
+    GenHevcSurface *gen9_hevc_surface;
+    int i;
+
+    BEGIN_BCS_BATCH(batch, 95);
+
+    OUT_BCS_BATCH(batch, HCP_PIPE_BUF_ADDR_STATE | (95 - 2));
+
+    obj_surface = decode_state->render_object;
+    assert(obj_surface && obj_surface->bo);
+    gen9_hevc_surface = obj_surface->private_data;
+    assert(gen9_hevc_surface && gen9_hevc_surface->motion_vector_temporal_bo);
+
+    OUT_BUFFER_MA_TARGET(obj_surface->bo); /* DW 1..3 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->deblocking_filter_line_buffer.bo);/* DW 4..6 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->deblocking_filter_tile_line_buffer.bo); /* DW 7..9 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->deblocking_filter_tile_column_buffer.bo); /* DW 10..12 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->metadata_line_buffer.bo);         /* DW 13..15 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->metadata_tile_line_buffer.bo);    /* DW 16..18 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->metadata_tile_column_buffer.bo);  /* DW 19..21 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->sao_line_buffer.bo);              /* DW 22..24 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->sao_tile_line_buffer.bo);         /* DW 25..27 */
+    OUT_BUFFER_MA_TARGET(gen9_hcpd_context->sao_tile_column_buffer.bo);       /* DW 28..30 */
+    OUT_BUFFER_MA_TARGET(gen9_hevc_surface->motion_vector_temporal_bo); /* DW 31..33 */
+    OUT_BUFFER_MA_TARGET(NULL); /* DW 34..36, reserved */
+
+    for (i = 0; i < ARRAY_ELEMS(gen9_hcpd_context->reference_surfaces); i++) {
+        obj_surface = gen9_hcpd_context->reference_surfaces[i].obj_surface;
+
+        if (obj_surface)
+            OUT_BUFFER_NMA_REFERENCE(obj_surface->bo);
+        else
+            OUT_BUFFER_NMA_REFERENCE(NULL);
+    }
+    OUT_BCS_BATCH(batch, 0);    /* DW 53, memory address attributes */
+
+    OUT_BUFFER_MA_REFERENCE(NULL); /* DW 54..56, ignore for decoding mode */
+    OUT_BUFFER_MA_TARGET(NULL);
+    OUT_BUFFER_MA_TARGET(NULL);
+    OUT_BUFFER_MA_TARGET(NULL);
+
+    for (i = 0; i < ARRAY_ELEMS(gen9_hcpd_context->reference_surfaces); i++) {
+        obj_surface = gen9_hcpd_context->reference_surfaces[i].obj_surface;
+        gen9_hevc_surface = NULL;
+
+        if (obj_surface && obj_surface->private_data)
+            gen9_hevc_surface = obj_surface->private_data;
+
+        if (gen9_hevc_surface)
+            OUT_BUFFER_NMA_REFERENCE(gen9_hevc_surface->motion_vector_temporal_bo);
+        else
+            OUT_BUFFER_NMA_REFERENCE(NULL);
+    }
+    OUT_BCS_BATCH(batch, 0);    /* DW 82, memory address attributes */
+
+    OUT_BUFFER_MA_TARGET(NULL);    /* DW 83..85, ignore for HEVC */
+    OUT_BUFFER_MA_TARGET(NULL);    /* DW 86..88, ignore for HEVC */
+    OUT_BUFFER_MA_TARGET(NULL);    /* DW 89..91, ignore for HEVC */
+    OUT_BUFFER_MA_TARGET(NULL);    /* DW 92..94, ignore for HEVC */
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_ind_obj_base_addr_state(VADriverContextP ctx,
+                                  dri_bo *slice_data_bo,
+                                  struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+
+    BEGIN_BCS_BATCH(batch, 14);
+
+    OUT_BCS_BATCH(batch, HCP_IND_OBJ_BASE_ADDR_STATE | (14 - 2));
+    OUT_BUFFER_MA_REFERENCE(slice_data_bo);        /* DW 1..3 */
+    OUT_BUFFER_NMA_REFERENCE(NULL);                /* DW 4..5, Upper Bound */
+    OUT_BUFFER_MA_REFERENCE(NULL);                 /* DW 6..8, CU, ignored */
+    OUT_BUFFER_MA_TARGET(NULL);                    /* DW 9..11, PAK-BSE, ignored */
+    OUT_BUFFER_NMA_TARGET(NULL);                   /* DW 12..13, Upper Bound  */
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_qm_state(VADriverContextP ctx,
+                   int size_id,
+                   int color_component,
+                   int pred_type,
+                   int dc,
+                   unsigned char *qm,
+                   int qm_length,
+                   struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    unsigned char qm_buffer[64];
+
+    assert(qm_length <= 64);
+    memset(qm_buffer, 0, sizeof(qm_buffer));
+    memcpy(qm_buffer, qm, qm_length);
+
+    BEGIN_BCS_BATCH(batch, 18);
+
+    OUT_BCS_BATCH(batch, HCP_QM_STATE | (18 - 2));
+    OUT_BCS_BATCH(batch,
+                  dc << 5 |
+                  color_component << 3 |
+                  size_id << 1 |
+                  pred_type);
+    intel_batchbuffer_data(batch, qm_buffer, 64);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_hevc_qm_state(VADriverContextP ctx,
+                        struct decode_state *decode_state,
+                        struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    VAIQMatrixBufferHEVC *iq_matrix;
+    VAPictureParameterBufferHEVC *pic_param;
+    int i;
+
+    if (decode_state->iq_matrix && decode_state->iq_matrix->buffer)
+        iq_matrix = (VAIQMatrixBufferHEVC *)decode_state->iq_matrix->buffer;
+    else
+        iq_matrix = &gen9_hcpd_context->iq_matrix_hevc;
+
+    assert(decode_state->pic_param && decode_state->pic_param->buffer);
+    pic_param = (VAPictureParameterBufferHEVC *)decode_state->pic_param->buffer;
+
+    if (!pic_param->pic_fields.bits.scaling_list_enabled_flag)
+        iq_matrix = &gen9_hcpd_context->iq_matrix_hevc;
+
+    for (i = 0; i < 6; i++) {
+        gen9_hcpd_qm_state(ctx,
+                           0, i % 3, i / 3, 0,
+                           iq_matrix->ScalingList4x4[i], 16,
+                           gen9_hcpd_context);
+    }
+
+    for (i = 0; i < 6; i++) {
+        gen9_hcpd_qm_state(ctx,
+                           1, i % 3, i / 3, 0,
+                           iq_matrix->ScalingList8x8[i], 64,
+                           gen9_hcpd_context);
+    }
+
+    for (i = 0; i < 6; i++) {
+        gen9_hcpd_qm_state(ctx,
+                           2, i % 3, i / 3, iq_matrix->ScalingListDC16x16[i],
+                           iq_matrix->ScalingList16x16[i], 64,
+                           gen9_hcpd_context);
+    }
+
+    for (i = 0; i < 2; i++) {
+        gen9_hcpd_qm_state(ctx,
+                           3, 0, i % 2, iq_matrix->ScalingListDC32x32[i],
+                           iq_matrix->ScalingList32x32[i], 64,
+                           gen9_hcpd_context);
+    }
+}
+
+static void
+gen9_hcpd_pic_state(VADriverContextP ctx,
+                    struct decode_state *decode_state,
+                    struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    VAPictureParameterBufferHEVC *pic_param;
+    int max_pcm_size_minus3 = 0, min_pcm_size_minus3 = 0;
+    int pcm_sample_bit_depth_luma_minus1 = 7, pcm_sample_bit_depth_chroma_minus1 = 7;
+    /*
+     * 7.4.3.1
+     *
+     * When not present, the value of loop_filter_across_tiles_enabled_flag
+     * is inferred to be equal to 1.
+     */
+    int loop_filter_across_tiles_enabled_flag = 1;
+
+    assert(decode_state->pic_param && decode_state->pic_param->buffer);
+    pic_param = (VAPictureParameterBufferHEVC *)decode_state->pic_param->buffer;
+
+    if (pic_param->pic_fields.bits.pcm_enabled_flag) {
+        max_pcm_size_minus3 = pic_param->log2_min_pcm_luma_coding_block_size_minus3 +
+            pic_param->log2_diff_max_min_pcm_luma_coding_block_size;
+        min_pcm_size_minus3 = pic_param->log2_min_pcm_luma_coding_block_size_minus3;
+        pcm_sample_bit_depth_luma_minus1 = (pic_param->pcm_sample_bit_depth_luma_minus1 & 0x0f);
+        pcm_sample_bit_depth_chroma_minus1 = (pic_param->pcm_sample_bit_depth_chroma_minus1 & 0x0f);
+    } else {
+        max_pcm_size_minus3 = MIN(pic_param->log2_min_luma_coding_block_size_minus3 + pic_param->log2_diff_max_min_luma_coding_block_size, 2);
+    }
+
+    if (pic_param->pic_fields.bits.tiles_enabled_flag)
+        loop_filter_across_tiles_enabled_flag = pic_param->pic_fields.bits.loop_filter_across_tiles_enabled_flag;
+
+    BEGIN_BCS_BATCH(batch, 19);
+
+    OUT_BCS_BATCH(batch, HCP_PIC_STATE | (19 - 2));
+
+    OUT_BCS_BATCH(batch,
+                  gen9_hcpd_context->picture_height_in_min_cb_minus1 << 16 |
+                  gen9_hcpd_context->picture_width_in_min_cb_minus1);
+    OUT_BCS_BATCH(batch,
+                  max_pcm_size_minus3 << 10 |
+                  min_pcm_size_minus3 << 8 |
+                  (pic_param->log2_min_transform_block_size_minus2 +
+                   pic_param->log2_diff_max_min_transform_block_size) << 6 |
+                  pic_param->log2_min_transform_block_size_minus2 << 4 |
+                  (pic_param->log2_min_luma_coding_block_size_minus3 +
+                   pic_param->log2_diff_max_min_luma_coding_block_size) << 2 |
+                  pic_param->log2_min_luma_coding_block_size_minus3);
+    OUT_BCS_BATCH(batch, 0); /* DW 3, ignored */
+    OUT_BCS_BATCH(batch,
+                  0 << 27 |
+                  pic_param->pic_fields.bits.strong_intra_smoothing_enabled_flag << 26 |
+                  pic_param->pic_fields.bits.transquant_bypass_enabled_flag << 25 |
+                  pic_param->pic_fields.bits.amp_enabled_flag << 23 |
+                  pic_param->pic_fields.bits.transform_skip_enabled_flag << 22 |
+                  !(pic_param->CurrPic.flags & VA_PICTURE_HEVC_BOTTOM_FIELD) << 21 |
+                  !!(pic_param->CurrPic.flags & VA_PICTURE_HEVC_FIELD_PIC) << 20 |
+                  pic_param->pic_fields.bits.weighted_pred_flag << 19 |
+                  pic_param->pic_fields.bits.weighted_bipred_flag << 18 |
+                  pic_param->pic_fields.bits.tiles_enabled_flag << 17 |
+                  pic_param->pic_fields.bits.entropy_coding_sync_enabled_flag << 16 |
+                  loop_filter_across_tiles_enabled_flag << 15 |
+                  pic_param->pic_fields.bits.sign_data_hiding_enabled_flag << 13 |
+                  pic_param->log2_parallel_merge_level_minus2 << 10 |
+                  pic_param->pic_fields.bits.constrained_intra_pred_flag << 9 |
+                  pic_param->pic_fields.bits.pcm_loop_filter_disabled_flag << 8 |
+                  (pic_param->diff_cu_qp_delta_depth & 0x03) << 6 |
+                  pic_param->pic_fields.bits.cu_qp_delta_enabled_flag << 5 |
+                  pic_param->pic_fields.bits.pcm_enabled_flag << 4 |
+                  pic_param->slice_parsing_fields.bits.sample_adaptive_offset_enabled_flag << 3 |
+                  0);
+    OUT_BCS_BATCH(batch,
+                  pcm_sample_bit_depth_luma_minus1 << 20 |
+                  pcm_sample_bit_depth_chroma_minus1 << 16 |
+                  pic_param->max_transform_hierarchy_depth_inter << 13 |
+                  pic_param->max_transform_hierarchy_depth_intra << 10 |
+                  (pic_param->pps_cr_qp_offset & 0x1f) << 5 |
+                  (pic_param->pps_cb_qp_offset & 0x1f));
+    OUT_BCS_BATCH(batch,
+                  0 << 29 |
+                  0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0); /* DW 10 */
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0); /* DW 15 */
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+    OUT_BCS_BATCH(batch, 0);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_tile_state(VADriverContextP ctx,
+                     struct decode_state *decode_state,
+                     struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    VAPictureParameterBufferHEVC *pic_param;
+    uint8_t pos_col[20], pos_row[24];
+    int i;
+
+    assert(decode_state->pic_param && decode_state->pic_param->buffer);
+    pic_param = (VAPictureParameterBufferHEVC *)decode_state->pic_param->buffer;
+
+    memset(pos_col, 0, sizeof(pos_col));
+    memset(pos_row, 0, sizeof(pos_row));
+
+    for (i = 0; i <= MIN(pic_param->num_tile_columns_minus1, 18); i++)
+        pos_col[i + 1] = pos_col[i] + pic_param->column_width_minus1[i] + 1;
+
+    for (i = 0; i <= MIN(pic_param->num_tile_rows_minus1, 20); i++)
+        pos_row[i + 1] = pos_row[i] + pic_param->row_height_minus1[i] + 1;
+
+    BEGIN_BCS_BATCH(batch, 13);
+
+    OUT_BCS_BATCH(batch, HCP_TILE_STATE | (13 - 2));
+
+    OUT_BCS_BATCH(batch,
+                  pic_param->num_tile_columns_minus1 << 5 |
+                  pic_param->num_tile_rows_minus1);
+    intel_batchbuffer_data(batch, pos_col, 20);
+    intel_batchbuffer_data(batch, pos_row, 24);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static int
+gen9_hcpd_get_reference_picture_frame_id(VAPictureHEVC *ref_pic,
+                                         GenFrameStore frame_store[MAX_GEN_HCP_REFERENCE_FRAMES])
+{
+    int i;
+
+    if (ref_pic->picture_id == VA_INVALID_ID ||
+        (ref_pic->flags & VA_PICTURE_HEVC_INVALID))
+        return 0;
+
+    for (i = 0; i < MAX_GEN_HCP_REFERENCE_FRAMES; i++) {
+        if (ref_pic->picture_id == frame_store[i].surface_id) {
+            assert(frame_store[i].frame_store_id < MAX_GEN_HCP_REFERENCE_FRAMES);
+            return frame_store[i].frame_store_id;
+        }
+    }
+
+    /* Should never get here !!! */
+    assert(0);
+    return 0;
+}
+
+static void
+gen9_hcpd_ref_idx_state_1(struct intel_batchbuffer *batch,
+                          int list,
+                          VAPictureParameterBufferHEVC *pic_param,
+                          VASliceParameterBufferHEVC *slice_param,
+                          GenFrameStore frame_store[MAX_GEN_HCP_REFERENCE_FRAMES])
+{
+    int i;
+    uint8_t num_ref_minus1 = (list ? slice_param->num_ref_idx_l1_active_minus1 : slice_param->num_ref_idx_l0_active_minus1);
+    uint8_t *ref_list = slice_param->RefPicList[list];
+
+    BEGIN_BCS_BATCH(batch, 18);
+
+    OUT_BCS_BATCH(batch, HCP_REF_IDX_STATE | (18 - 2));
+    OUT_BCS_BATCH(batch,
+                  num_ref_minus1 << 1 |
+                  list);
+
+    for (i = 0; i < 16; i++) {
+        if (i < MIN((num_ref_minus1 + 1), 15)) {
+            VAPictureHEVC *ref_pic = &pic_param->ReferenceFrames[ref_list[i]];
+            VAPictureHEVC *curr_pic = &pic_param->CurrPic;
+
+            OUT_BCS_BATCH(batch,
+                          !(ref_pic->flags & VA_PICTURE_HEVC_BOTTOM_FIELD) << 15 |
+                          !!(ref_pic->flags & VA_PICTURE_HEVC_FIELD_PIC) << 14 |
+                          !!(ref_pic->flags & VA_PICTURE_HEVC_LONG_TERM_REFERENCE) << 13 |
+                          0 << 12 |
+                          0 << 11 |
+                          gen9_hcpd_get_reference_picture_frame_id(ref_pic, frame_store) << 8 |
+                          (CLAMP(-128, 127, curr_pic->pic_order_cnt - ref_pic->pic_order_cnt) & 0xff));
+        } else {
+            OUT_BCS_BATCH(batch, 0);
+        }
+    }
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_ref_idx_state(VADriverContextP ctx,
+                        VAPictureParameterBufferHEVC *pic_param,
+                        VASliceParameterBufferHEVC *slice_param,
+                        struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_I)
+        return;
+
+    gen9_hcpd_ref_idx_state_1(batch, 0, pic_param, slice_param, gen9_hcpd_context->reference_surfaces);
+
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_P)
+        return;
+
+    gen9_hcpd_ref_idx_state_1(batch, 1, pic_param, slice_param, gen9_hcpd_context->reference_surfaces);
+}
+
+static void
+gen9_hcpd_weightoffset_state_1(struct intel_batchbuffer *batch,
+                               int list,
+                               VASliceParameterBufferHEVC *slice_param)
+{
+    int i;
+    uint8_t num_ref_minus1 = (list == 1) ? slice_param->num_ref_idx_l1_active_minus1 : slice_param->num_ref_idx_l0_active_minus1;
+    int8_t *luma_offset = (list == 1) ? slice_param->luma_offset_l1 : slice_param->luma_offset_l0;
+    int8_t *delta_luma_weight = (list == 1) ? slice_param->delta_luma_weight_l1 : slice_param->delta_luma_weight_l0;
+    int8_t (* chroma_offset)[2] = (list == 1) ? slice_param->ChromaOffsetL1 : slice_param->ChromaOffsetL0;
+    int8_t (* delta_chroma_weight)[2] = (list == 1) ? slice_param->delta_chroma_weight_l1 : slice_param->delta_chroma_weight_l0;
+
+    BEGIN_BCS_BATCH(batch, 34);
+
+    OUT_BCS_BATCH(batch, HCP_WEIGHTOFFSET | (34 - 2));
+    OUT_BCS_BATCH(batch, list);
+
+    for (i = 0; i < 16; i++) {
+        if (i < MIN((num_ref_minus1 + 1), 15)) {
+            OUT_BCS_BATCH(batch,
+                          luma_offset[i] << 8 |
+                          delta_luma_weight[i]);
+        } else {
+            OUT_BCS_BATCH(batch, 0);
+        }
+    }
+    for (i = 0; i < 16; i++) {
+        if (i < MIN((num_ref_minus1 + 1), 15)) {
+            OUT_BCS_BATCH(batch,
+                          chroma_offset[i][1] << 24 |
+                          delta_chroma_weight[i][1] << 16 |
+                          chroma_offset[i][0] << 8 |
+                          delta_chroma_weight[i][0]);
+        } else {
+            OUT_BCS_BATCH(batch, 0);
+        }
+    }
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_weightoffset_state(VADriverContextP ctx,
+                             VAPictureParameterBufferHEVC *pic_param,
+                             VASliceParameterBufferHEVC *slice_param,
+                             struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_I)
+        return;
+
+    if ((slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_P &&
+         !pic_param->pic_fields.bits.weighted_pred_flag) ||
+        (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_B &&
+         !pic_param->pic_fields.bits.weighted_bipred_flag))
+        return;
+
+    gen9_hcpd_weightoffset_state_1(batch, 0, slice_param);
+
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_P)
+        return;
+
+    gen9_hcpd_weightoffset_state_1(batch, 1, slice_param);
+}
+
+static int
+gen9_hcpd_get_collocated_ref_idx(VADriverContextP ctx,
+                                 VAPictureParameterBufferHEVC *pic_param,
+                                 VASliceParameterBufferHEVC *slice_param,
+                                 struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    uint8_t *ref_list;
+    VAPictureHEVC *ref_pic;
+
+    if (slice_param->collocated_ref_idx > 14)
+        return 0;
+
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_I)
+        return 0;
+
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_P ||
+        (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_B &&
+         slice_param->LongSliceFlags.fields.collocated_from_l0_flag))
+        ref_list = slice_param->RefPicList[0];
+    else {
+        assert(slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_B);
+        ref_list = slice_param->RefPicList[1];
+    }
+
+    ref_pic = &pic_param->ReferenceFrames[ref_list[slice_param->collocated_ref_idx]];
+
+    return gen9_hcpd_get_reference_picture_frame_id(ref_pic, gen9_hcpd_context->reference_surfaces);
+}
+
+static int
+gen9_hcpd_is_list_low_delay(uint8_t ref_list_count,
+                            uint8_t ref_list[15],
+                            VAPictureHEVC *curr_pic,
+                            VAPictureHEVC ref_surfaces[15])
+{
+    int i;
+
+    for (i = 0; i < MIN(ref_list_count, 15); i++) {
+        VAPictureHEVC *ref_pic;
+
+        if (ref_list[i] > 14)
+            continue;
+
+        ref_pic = &ref_surfaces[ref_list[i]];
+
+        if (ref_pic->pic_order_cnt > curr_pic->pic_order_cnt)
+            return 0;
+    }
+
+    return 1;
+}
+
+static int
+gen9_hcpd_is_low_delay(VADriverContextP ctx,
+                       VAPictureParameterBufferHEVC *pic_param,
+                       VASliceParameterBufferHEVC *slice_param)
+{
+    if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_I)
+        return 0;
+    else if (slice_param->LongSliceFlags.fields.slice_type == HEVC_SLICE_P)
+        return gen9_hcpd_is_list_low_delay(slice_param->num_ref_idx_l0_active_minus1 + 1,
+                                           slice_param->RefPicList[0],
+                                           &pic_param->CurrPic,
+                                           pic_param->ReferenceFrames);
+    else
+        return gen9_hcpd_is_list_low_delay(slice_param->num_ref_idx_l0_active_minus1 + 1,
+                                           slice_param->RefPicList[0],
+                                           &pic_param->CurrPic,
+                                           pic_param->ReferenceFrames) &&
+            gen9_hcpd_is_list_low_delay(slice_param->num_ref_idx_l1_active_minus1 + 1,
+                                        slice_param->RefPicList[1],
+                                        &pic_param->CurrPic,
+                                        pic_param->ReferenceFrames);
+}
+
+static void
+gen9_hcpd_slice_state(VADriverContextP ctx,
+                      VAPictureParameterBufferHEVC *pic_param,
+                      VASliceParameterBufferHEVC *slice_param,
+                      VASliceParameterBufferHEVC *next_slice_param,
+                      struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    int slice_hor_pos, slice_ver_pos, next_slice_hor_pos, next_slice_ver_pos;
+
+    slice_hor_pos = slice_param->slice_segment_address % gen9_hcpd_context->picture_width_in_ctbs;
+    slice_ver_pos = slice_param->slice_segment_address / gen9_hcpd_context->picture_width_in_ctbs;
+
+    if (next_slice_param) {
+        next_slice_hor_pos = next_slice_param->slice_segment_address % gen9_hcpd_context->picture_width_in_ctbs;
+        next_slice_ver_pos = next_slice_param->slice_segment_address / gen9_hcpd_context->picture_width_in_ctbs;
+    } else {
+        next_slice_hor_pos = 0;
+        next_slice_ver_pos = 0;
+    }
+
+    BEGIN_BCS_BATCH(batch, 9);
+
+    OUT_BCS_BATCH(batch, HCP_SLICE_STATE | (9 - 2));
+
+    OUT_BCS_BATCH(batch,
+                  slice_ver_pos << 16 |
+                  slice_hor_pos);
+    OUT_BCS_BATCH(batch,
+                  next_slice_ver_pos << 16 |
+                  next_slice_hor_pos);
+    OUT_BCS_BATCH(batch,
+                  (slice_param->slice_cr_qp_offset & 0x1f) << 17 |
+                  (slice_param->slice_cb_qp_offset & 0x1f) << 12 |
+                  (pic_param->init_qp_minus26 + 26 + slice_param->slice_qp_delta) << 6 |
+                  slice_param->LongSliceFlags.fields.slice_temporal_mvp_enabled_flag << 5 |
+                  slice_param->LongSliceFlags.fields.dependent_slice_segment_flag << 4 |
+                  !next_slice_param << 2 |
+                  slice_param->LongSliceFlags.fields.slice_type);
+    OUT_BCS_BATCH(batch,
+                  gen9_hcpd_get_collocated_ref_idx(ctx, pic_param, slice_param, gen9_hcpd_context) << 26 |
+                  (5 - slice_param->five_minus_max_num_merge_cand - 1) << 23 |
+                  slice_param->LongSliceFlags.fields.cabac_init_flag << 22 |
+                  slice_param->luma_log2_weight_denom << 19 |
+                  (slice_param->luma_log2_weight_denom + slice_param->delta_chroma_log2_weight_denom) << 16 |
+                  slice_param->LongSliceFlags.fields.collocated_from_l0_flag << 15 |
+                  gen9_hcpd_is_low_delay(ctx, pic_param, slice_param) << 14 |
+                  slice_param->LongSliceFlags.fields.mvd_l1_zero_flag << 13 |
+                  slice_param->LongSliceFlags.fields.slice_sao_luma_flag << 12 |
+                  slice_param->LongSliceFlags.fields.slice_sao_chroma_flag << 11 |
+                  slice_param->LongSliceFlags.fields.slice_loop_filter_across_slices_enabled_flag << 10 |
+                  (slice_param->slice_beta_offset_div2 & 0xf) << 5 |
+                  (slice_param->slice_tc_offset_div2 & 0xf) << 1 |
+                  slice_param->LongSliceFlags.fields.slice_deblocking_filter_disabled_flag);
+    OUT_BCS_BATCH(batch,
+                  slice_param->slice_data_byte_offset); /* DW 5 */
+    OUT_BCS_BATCH(batch,
+                  0 << 26 |
+                  0 << 20 |
+                  0);
+    OUT_BCS_BATCH(batch, 0);    /* Ignored for decoding */
+    OUT_BCS_BATCH(batch, 0);    /* Ignored for decoding */
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static void
+gen9_hcpd_bsd_object(VADriverContextP ctx,
+                     VASliceParameterBufferHEVC *slice_param,
+                     struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+
+    BEGIN_BCS_BATCH(batch, 3);
+
+    OUT_BCS_BATCH(batch, HCP_BSD_OBJECT | (3 - 2));
+
+    OUT_BCS_BATCH(batch, slice_param->slice_data_size);
+    OUT_BCS_BATCH(batch, slice_param->slice_data_offset);
+
+    ADVANCE_BCS_BATCH(batch);
+}
+
+static VAStatus
+gen9_hcpd_hevc_decode_picture(VADriverContextP ctx,
+                              struct decode_state *decode_state,
+                              struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    VAStatus vaStatus;
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch;
+    VAPictureParameterBufferHEVC *pic_param;
+    VASliceParameterBufferHEVC *slice_param, *next_slice_param, *next_slice_group_param;
+    dri_bo *slice_data_bo;
+    int i, j;
+
+    vaStatus = gen9_hcpd_hevc_decode_init(ctx, decode_state, gen9_hcpd_context);
+
+    if (vaStatus != VA_STATUS_SUCCESS)
+        goto out;
+
+    assert(decode_state->pic_param && decode_state->pic_param->buffer);
+    pic_param = (VAPictureParameterBufferHEVC *)decode_state->pic_param->buffer;
+
+    if (i965->intel.has_bsd2)
+        intel_batchbuffer_start_atomic_bcs_override(batch, 0x1000, BSD_RING0);
+    else
+        intel_batchbuffer_start_atomic_bcs(batch, 0x1000);
+    intel_batchbuffer_emit_mi_flush(batch);
+
+    gen9_hcpd_pipe_mode_select(ctx, decode_state, HCP_CODEC_HEVC, gen9_hcpd_context);
+    gen9_hcpd_surface_state(ctx, decode_state, gen9_hcpd_context);
+    gen9_hcpd_pipe_buf_addr_state(ctx, decode_state, gen9_hcpd_context);
+    gen9_hcpd_hevc_qm_state(ctx, decode_state, gen9_hcpd_context);
+    gen9_hcpd_pic_state(ctx, decode_state, gen9_hcpd_context);
+
+    if (pic_param->pic_fields.bits.tiles_enabled_flag)
+        gen9_hcpd_tile_state(ctx, decode_state, gen9_hcpd_context);
+
+    /* Need to double it works or not if the two slice groups have differenct slice data buffers */
+    for (j = 0; j < decode_state->num_slice_params; j++) {
+        assert(decode_state->slice_params && decode_state->slice_params[j]->buffer);
+        slice_param = (VASliceParameterBufferHEVC *)decode_state->slice_params[j]->buffer;
+        slice_data_bo = decode_state->slice_datas[j]->bo;
+
+        gen9_hcpd_ind_obj_base_addr_state(ctx, slice_data_bo, gen9_hcpd_context);
+
+        if (j == decode_state->num_slice_params - 1)
+            next_slice_group_param = NULL;
+        else
+            next_slice_group_param = (VASliceParameterBufferHEVC *)decode_state->slice_params[j + 1]->buffer;
+
+        for (i = 0; i < decode_state->slice_params[j]->num_elements; i++) {
+            if (i < decode_state->slice_params[j]->num_elements - 1)
+                next_slice_param = slice_param + 1;
+            else
+                next_slice_param = next_slice_group_param;
+
+            gen9_hcpd_slice_state(ctx, pic_param, slice_param, next_slice_param, gen9_hcpd_context);
+            gen9_hcpd_ref_idx_state(ctx, pic_param, slice_param, gen9_hcpd_context);
+            gen9_hcpd_weightoffset_state(ctx, pic_param, slice_param, gen9_hcpd_context);
+            gen9_hcpd_bsd_object(ctx, slice_param, gen9_hcpd_context);
+            slice_param++;
+        }
+    }
+
+    intel_batchbuffer_end_atomic(batch);
+    intel_batchbuffer_flush(batch);
+
+out:
+    return vaStatus;
+}
+
+static VAStatus
+gen9_hcpd_decode_picture(VADriverContextP ctx,
+                         VAProfile profile,
+                         union codec_state *codec_state,
+                         struct hw_context *hw_context)
+{
+    struct gen9_hcpd_context *gen9_hcpd_context = (struct gen9_hcpd_context *)hw_context;
+    struct decode_state *decode_state = &codec_state->decode;
+    VAStatus vaStatus;
+
+    assert(gen9_hcpd_context);
+
+    vaStatus = intel_decoder_sanity_check_input(ctx, profile, decode_state);
+
+    if (vaStatus != VA_STATUS_SUCCESS)
+        goto out;
+
+    switch (profile) {
+    case VAProfileHEVCMain:
+    case VAProfileHEVCMain10:
+        vaStatus = gen9_hcpd_hevc_decode_picture(ctx, decode_state, gen9_hcpd_context);
+        break;
+
+    default:
+        /* should never get here 1!! */
+        assert(0);
+        break;
+    }
+
+out:
+    return vaStatus;
+}
+
+static void
+gen9_hcpd_context_destroy(void *hw_context)
+{
+    struct gen9_hcpd_context *gen9_hcpd_context = (struct gen9_hcpd_context *)hw_context;
+
+    FREE_GEN_BUFFER((&gen9_hcpd_context->deblocking_filter_line_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->deblocking_filter_tile_line_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->deblocking_filter_tile_column_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->metadata_line_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->metadata_tile_line_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->metadata_tile_column_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->sao_line_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->sao_tile_line_buffer));
+    FREE_GEN_BUFFER((&gen9_hcpd_context->sao_tile_column_buffer));
+
+    intel_batchbuffer_free(gen9_hcpd_context->base.batch);
+    free(gen9_hcpd_context);
+}
+
+static void
+gen9_hcpd_hevc_context_init(VADriverContextP ctx,
+                            struct gen9_hcpd_context *gen9_hcpd_context)
+{
+    hevc_gen_default_iq_matrix(&gen9_hcpd_context->iq_matrix_hevc);
+}
+
+static struct hw_context *
+gen9_hcpd_context_init(VADriverContextP ctx, struct object_config *object_config)
+{
+    struct intel_driver_data *intel = intel_driver_data(ctx);
+    struct gen9_hcpd_context *gen9_hcpd_context = calloc(1, sizeof(struct gen9_hcpd_context));
+    int i;
+
+    if (!gen9_hcpd_context)
+        return NULL;
+
+    gen9_hcpd_context->base.destroy = gen9_hcpd_context_destroy;
+    gen9_hcpd_context->base.run = gen9_hcpd_decode_picture;
+    gen9_hcpd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_VEBOX, 0);
+
+    for (i = 0; i < ARRAY_ELEMS(gen9_hcpd_context->reference_surfaces); i++) {
+        gen9_hcpd_context->reference_surfaces[i].surface_id = VA_INVALID_ID;
+        gen9_hcpd_context->reference_surfaces[i].frame_store_id = -1;
+        gen9_hcpd_context->reference_surfaces[i].obj_surface = NULL;
+    }
+
+    switch (object_config->profile) {
+    case VAProfileHEVCMain:
+    case VAProfileHEVCMain10:
+        gen9_hcpd_hevc_context_init(ctx, gen9_hcpd_context);
+        break;
+
+    default:
+        break;
+    }
+
+    return (struct hw_context *)gen9_hcpd_context;
+}
+
+struct hw_context *
+gen9_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
+{
+    if (obj_config->profile == VAProfileHEVCMain ||
+        obj_config->profile == VAProfileHEVCMain10) {
+        return gen9_hcpd_context_init(ctx, obj_config);
+    } else {
+        return gen8_dec_hw_context_init(ctx, obj_config);
+    }
+}
diff --git a/src/i965_media_mpeg2.h b/src/gen9_mfd.h
similarity index 56%
copy from src/i965_media_mpeg2.h
copy to src/gen9_mfd.h
index 5b8867e..727c579 100644
--- a/src/i965_media_mpeg2.h
+++ b/src/gen9_mfd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2009 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -23,31 +23,48 @@
  *
  * Authors:
  *    Xiang Haihao <haihao.xiang at intel.com>
- *    Zou Nan hai <nanhai.zou at intel.com>
  *
  */
 
-#ifndef _I965_MEDIA_MPEG2_H_
-#define _I965_MEDIA_MPEG2_H_
+#ifndef GEN9_MFD_H
+#define GEN9_MFD_H
 
 #include <xf86drm.h>
 #include <drm.h>
 #include <i915_drm.h>
 #include <intel_bufmgr.h>
+#include "i965_decoder.h"
 
-struct decode_state;
-struct i965_media_context;
+struct hw_context;
 
-#define NUM_MPEG2_VLD_KERNELS           15
-
-struct i965_mpeg2_context
+struct gen9_hcpd_context
 {
-    struct i965_kernel vld_kernels[NUM_MPEG2_VLD_KERNELS];
-    VAIQMatrixBufferMPEG2 iq_matrix;
-    int wa_slice_vertical_position;
-};
+    struct hw_context base;
+
+    GenFrameStoreContext fs_ctx;
+
+    GenFrameStore reference_surfaces[MAX_GEN_HCP_REFERENCE_FRAMES];
 
-void i965_media_mpeg2_decode_init(VADriverContextP ctx, struct decode_state * decode_state, struct i965_media_context *media_context);
-void i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_context *media_context);
+    VAIQMatrixBufferHEVC  iq_matrix_hevc;
+
+    uint16_t picture_width_in_pixels;
+    uint16_t picture_height_in_pixels;
+    uint16_t picture_width_in_ctbs;
+    uint16_t picture_height_in_ctbs;
+    uint16_t picture_width_in_min_cb_minus1;
+    uint16_t picture_height_in_min_cb_minus1;
+    uint8_t ctb_size;
+    uint8_t min_cb_size;
+
+    GenBuffer deblocking_filter_line_buffer;
+    GenBuffer deblocking_filter_tile_line_buffer;
+    GenBuffer deblocking_filter_tile_column_buffer;
+    GenBuffer metadata_line_buffer;
+    GenBuffer metadata_tile_line_buffer;
+    GenBuffer metadata_tile_column_buffer;
+    GenBuffer sao_line_buffer;
+    GenBuffer sao_tile_line_buffer;
+    GenBuffer sao_tile_column_buffer;
+};
 
-#endif /* _I965_MEDIA_MPEG2_H_ */
+#endif /* GEN9_MFD_H */
diff --git a/src/gen9_post_processing.c b/src/gen9_post_processing.c
new file mode 100644
index 0000000..0aae781
--- /dev/null
+++ b/src/gen9_post_processing.c
@@ -0,0 +1,431 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "intel_batchbuffer.h"
+#include "intel_driver.h"
+#include "i965_defines.h"
+#include "i965_structs.h"
+#include "i965_drv_video.h"
+#include "i965_post_processing.h"
+#include "i965_render.h"
+#include "intel_media.h"
+
+#include "gen8_post_processing.h"
+
+static const uint32_t pp_null_gen9[][4] = {
+};
+
+static const uint32_t pp_nv12_load_save_nv12_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl2_to_pl2.g9b"
+};
+
+static const uint32_t pp_nv12_load_save_pl3_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl2_to_pl3.g9b"
+};
+
+static const uint32_t pp_pl3_load_save_nv12_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl3_to_pl2.g9b"
+};
+
+static const uint32_t pp_pl3_load_save_pl3_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl3_to_pl3.g9b"
+};
+
+static const uint32_t pp_nv12_scaling_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl2_to_pl2.g9b"
+};
+
+static const uint32_t pp_nv12_avs_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl2_to_pl2.g9b"
+};
+
+static const uint32_t pp_nv12_dndi_gen9[][4] = {
+};
+
+static const uint32_t pp_nv12_dn_gen9[][4] = {
+};
+
+static const uint32_t pp_nv12_load_save_pa_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl2_to_pa.g9b"
+};
+
+static const uint32_t pp_pl3_load_save_pa_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl3_to_pa.g9b"
+};
+
+static const uint32_t pp_pa_load_save_nv12_gen9[][4] = {
+#include "shaders/post_processing/gen9/pa_to_pl2.g9b"
+};
+
+static const uint32_t pp_pa_load_save_pl3_gen9[][4] = {
+#include "shaders/post_processing/gen9/pa_to_pl3.g9b"
+};
+
+static const uint32_t pp_pa_load_save_pa_gen9[][4] = {
+#include "shaders/post_processing/gen9/pa_to_pa.g9b"
+};
+
+static const uint32_t pp_rgbx_load_save_nv12_gen9[][4] = {
+#include "shaders/post_processing/gen9/rgbx_to_nv12.g9b"
+};
+
+static const uint32_t pp_nv12_load_save_rgbx_gen9[][4] = {
+#include "shaders/post_processing/gen9/pl2_to_rgbx.g9b"
+};
+
+static const uint32_t pp_nv12_blending_gen9[][4] = {
+};
+
+static struct pp_module pp_modules_gen9[] = {
+    {
+        {
+            "NULL module (for testing)",
+            PP_NULL,
+            pp_null_gen9,
+            sizeof(pp_null_gen9),
+            NULL,
+        },
+
+        pp_null_initialize,
+    },
+
+    {
+        {
+            "NV12_NV12",
+            PP_NV12_LOAD_SAVE_N12,
+            pp_nv12_load_save_nv12_gen9,
+            sizeof(pp_nv12_load_save_nv12_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "NV12_PL3",
+            PP_NV12_LOAD_SAVE_PL3,
+            pp_nv12_load_save_pl3_gen9,
+            sizeof(pp_nv12_load_save_pl3_gen9),
+            NULL,
+        },
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "PL3_NV12",
+            PP_PL3_LOAD_SAVE_N12,
+            pp_pl3_load_save_nv12_gen9,
+            sizeof(pp_pl3_load_save_nv12_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "PL3_PL3",
+            PP_PL3_LOAD_SAVE_N12,
+            pp_pl3_load_save_pl3_gen9,
+            sizeof(pp_pl3_load_save_pl3_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "NV12 Scaling module",
+            PP_NV12_SCALING,
+            pp_nv12_scaling_gen9,
+            sizeof(pp_nv12_scaling_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "NV12 AVS module",
+            PP_NV12_AVS,
+            pp_nv12_avs_gen9,
+            sizeof(pp_nv12_avs_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "NV12 DNDI module",
+            PP_NV12_DNDI,
+            pp_nv12_dndi_gen9,
+            sizeof(pp_nv12_dndi_gen9),
+            NULL,
+        },
+
+        pp_null_initialize,
+    },
+
+    {
+        {
+            "NV12 DN module",
+            PP_NV12_DN,
+            pp_nv12_dn_gen9,
+            sizeof(pp_nv12_dn_gen9),
+            NULL,
+        },
+
+        pp_null_initialize,
+    },
+    {
+        {
+            "NV12_PA module",
+            PP_NV12_LOAD_SAVE_PA,
+            pp_nv12_load_save_pa_gen9,
+            sizeof(pp_nv12_load_save_pa_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "PL3_PA module",
+            PP_PL3_LOAD_SAVE_PA,
+            pp_pl3_load_save_pa_gen9,
+            sizeof(pp_pl3_load_save_pa_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "PA_NV12 module",
+            PP_PA_LOAD_SAVE_NV12,
+            pp_pa_load_save_nv12_gen9,
+            sizeof(pp_pa_load_save_nv12_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "PA_PL3 module",
+            PP_PA_LOAD_SAVE_PL3,
+            pp_pa_load_save_pl3_gen9,
+            sizeof(pp_pa_load_save_pl3_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "PA_PA module",
+            PP_PA_LOAD_SAVE_PA,
+            pp_pa_load_save_pa_gen9,
+            sizeof(pp_pa_load_save_pa_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "RGBX_NV12 module",
+            PP_RGBX_LOAD_SAVE_NV12,
+            pp_rgbx_load_save_nv12_gen9,
+            sizeof(pp_rgbx_load_save_nv12_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+
+    {
+        {
+            "NV12_RGBX module",
+            PP_NV12_LOAD_SAVE_RGBX,
+            pp_nv12_load_save_rgbx_gen9,
+            sizeof(pp_nv12_load_save_rgbx_gen9),
+            NULL,
+        },
+
+        gen8_pp_plx_avs_initialize,
+    },
+};
+
+static void
+gen9_pp_pipeline_select(VADriverContextP ctx,
+                        struct i965_post_processing_context *pp_context)
+{
+    struct intel_batchbuffer *batch = pp_context->batch;
+
+    BEGIN_BATCH(batch, 1);
+    OUT_BATCH(batch,
+              CMD_PIPELINE_SELECT |
+              PIPELINE_SELECT_MEDIA |
+              GEN9_FORCE_MEDIA_AWAKE_ON |
+              GEN9_MEDIA_DOP_GATE_OFF |
+              GEN9_PIPELINE_SELECTION_MASK |
+              GEN9_MEDIA_DOP_GATE_MASK |
+              GEN9_FORCE_MEDIA_AWAKE_MASK);
+    ADVANCE_BATCH(batch);
+}
+
+static void
+gen9_pp_state_base_address(VADriverContextP ctx,
+                           struct i965_post_processing_context *pp_context)
+{
+    struct intel_batchbuffer *batch = pp_context->batch;
+
+    BEGIN_BATCH(batch, 19);
+    OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (19 - 2));
+    /* DW1 Generate state address */
+    OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0);
+    /* DW4. Surface state address */
+    OUT_RELOC(batch, pp_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
+    OUT_BATCH(batch, 0);
+    /* DW6. Dynamic state address */
+    OUT_RELOC(batch, pp_context->dynamic_state.bo, I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_SAMPLER,
+              0, 0 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+
+    /* DW8. Indirect object address */
+    OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+
+    /* DW10. Instruction base address */
+    OUT_RELOC(batch, pp_context->instruction_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+
+    OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
+
+    /* Bindless surface state base address */
+    OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0xfffff000);
+
+    ADVANCE_BATCH(batch);
+}
+
+static void
+gen9_pp_end_pipeline(VADriverContextP ctx,
+                     struct i965_post_processing_context *pp_context)
+{
+    struct intel_batchbuffer *batch = pp_context->batch;
+
+    BEGIN_BATCH(batch, 1);
+    OUT_BATCH(batch,
+              CMD_PIPELINE_SELECT |
+              PIPELINE_SELECT_MEDIA |
+              GEN9_FORCE_MEDIA_AWAKE_OFF |
+              GEN9_MEDIA_DOP_GATE_ON |
+              GEN9_PIPELINE_SELECTION_MASK |
+              GEN9_MEDIA_DOP_GATE_MASK |
+              GEN9_FORCE_MEDIA_AWAKE_MASK);
+    ADVANCE_BATCH(batch);
+}
+
+static void
+gen9_pp_pipeline_setup(VADriverContextP ctx,
+                       struct i965_post_processing_context *pp_context)
+{
+    struct intel_batchbuffer *batch = pp_context->batch;
+
+    intel_batchbuffer_start_atomic(batch, 0x1000);
+    intel_batchbuffer_emit_mi_flush(batch);
+    gen9_pp_pipeline_select(ctx, pp_context);
+    gen9_pp_state_base_address(ctx, pp_context);
+    gen8_pp_vfe_state(ctx, pp_context);
+    gen8_pp_curbe_load(ctx, pp_context);
+    gen8_interface_descriptor_load(ctx, pp_context);
+    gen8_pp_object_walker(ctx, pp_context);
+    gen9_pp_end_pipeline(ctx, pp_context);
+    intel_batchbuffer_end_atomic(batch);
+}
+
+static VAStatus
+gen9_post_processing(VADriverContextP ctx,
+                     struct i965_post_processing_context *pp_context,
+                     const struct i965_surface *src_surface,
+                     const VARectangle *src_rect,
+                     struct i965_surface *dst_surface,
+                     const VARectangle *dst_rect,
+                     int pp_index,
+                     void * filter_param)
+{
+    VAStatus va_status;
+
+    va_status = gen8_pp_initialize(ctx, pp_context,
+                                   src_surface,
+                                   src_rect,
+                                   dst_surface,
+                                   dst_rect,
+                                   pp_index,
+                                   filter_param);
+
+    if (va_status == VA_STATUS_SUCCESS) {
+        gen8_pp_states_setup(ctx, pp_context);
+        gen9_pp_pipeline_setup(ctx, pp_context);
+    }
+
+    return va_status;
+}
+
+void
+gen9_post_processing_context_init(VADriverContextP ctx,
+                                  void *data,
+                                  struct intel_batchbuffer *batch)
+{
+    struct i965_post_processing_context *pp_context = data;
+
+    gen8_post_processing_context_common_init(ctx, data, pp_modules_gen9, ARRAY_ELEMS(pp_modules_gen9), batch);
+
+    pp_context->intel_post_processing = gen9_post_processing;
+}
diff --git a/src/gen8_render.c b/src/gen9_render.c
similarity index 88%
copy from src/gen8_render.c
copy to src/gen9_render.c
index 9c49cbc..da8950e 100644
--- a/src/gen8_render.c
+++ b/src/gen9_render.c
@@ -48,28 +48,22 @@
 
 #include "i965_render.h"
 
-#define SF_KERNEL_NUM_GRF       16
-#define SF_MAX_THREADS          1
-
-#define PS_KERNEL_NUM_GRF       48
-#define PS_MAX_THREADS          32
-
 /* Programs for Gen8 */
-static const uint32_t sf_kernel_static_gen8[][4] ={
+static const uint32_t sf_kernel_static_gen9[][4] ={
 
 };
-static const uint32_t ps_kernel_static_gen8[][4] = {
-#include "shaders/render/exa_wm_src_affine.g8b"
-#include "shaders/render/exa_wm_src_sample_planar.g8b"
-#include "shaders/render/exa_wm_yuv_color_balance.g8b"
-#include "shaders/render/exa_wm_yuv_rgb.g8b"
-#include "shaders/render/exa_wm_write.g8b"
+static const uint32_t ps_kernel_static_gen9[][4] = {
+#include "shaders/render/exa_wm_src_affine.g9b"
+#include "shaders/render/exa_wm_src_sample_planar.g9b"
+#include "shaders/render/exa_wm_yuv_color_balance.g9b"
+#include "shaders/render/exa_wm_yuv_rgb.g9b"
+#include "shaders/render/exa_wm_write.g9b"
 };
 
-static const uint32_t ps_subpic_kernel_static_gen8[][4] = {
-#include "shaders/render/exa_wm_src_affine.g8b"
-#include "shaders/render/exa_wm_src_sample_argb.g8b"
-#include "shaders/render/exa_wm_write.g8b"
+static const uint32_t ps_subpic_kernel_static_gen9[][4] = {
+#include "shaders/render/exa_wm_src_affine.g9b"
+#include "shaders/render/exa_wm_src_sample_argb.g9b"
+#include "shaders/render/exa_wm_write.g9b"
 };
 
 
@@ -84,27 +78,27 @@ enum {
     PS_SUBPIC_KERNEL
 };
 
-static struct i965_kernel render_kernels_gen8[] = {
+static struct i965_kernel render_kernels_gen9[] = {
     {
         "SF",
         SF_KERNEL,
-        sf_kernel_static_gen8,
-        sizeof(sf_kernel_static_gen8),
+        sf_kernel_static_gen9,
+        sizeof(sf_kernel_static_gen9),
         NULL
     },
     {
         "PS",
         PS_KERNEL,
-        ps_kernel_static_gen8,
-        sizeof(ps_kernel_static_gen8),
+        ps_kernel_static_gen9,
+        sizeof(ps_kernel_static_gen9),
         NULL
     },
 
     {
         "PS_SUBPIC",
         PS_SUBPIC_KERNEL,
-        ps_subpic_kernel_static_gen8,
-        sizeof(ps_subpic_kernel_static_gen8),
+        ps_subpic_kernel_static_gen9,
+        sizeof(ps_subpic_kernel_static_gen9),
         NULL
     }
 };
@@ -144,7 +138,7 @@ static float yuv_to_rgb_smpte_240[3][4] = {
 
 
 static void
-gen8_render_set_surface_tiling(struct gen8_surface_state *ss, uint32_t tiling)
+gen9_render_set_surface_tiling(struct gen8_surface_state *ss, uint32_t tiling)
 {
    switch (tiling) {
    case I915_TILING_NONE:
@@ -162,9 +156,9 @@ gen8_render_set_surface_tiling(struct gen8_surface_state *ss, uint32_t tiling)
    }
 }
 
-/* Set "Shader Channel Select" for GEN8+ */
-void
-gen8_render_set_surface_scs(struct gen8_surface_state *ss)
+/* Set "Shader Channel Select" for GEN9+ */
+static void
+gen9_render_set_surface_scs(struct gen8_surface_state *ss)
 {
     ss->ss7.shader_chanel_select_r = HSW_SCS_RED;
     ss->ss7.shader_chanel_select_g = HSW_SCS_GREEN;
@@ -173,7 +167,7 @@ gen8_render_set_surface_scs(struct gen8_surface_state *ss)
 }
 
 static void
-gen8_render_set_surface_state(
+gen9_render_set_surface_state(
     struct gen8_surface_state *ss,
     dri_bo                    *bo,
     unsigned long              offset,
@@ -189,11 +183,11 @@ gen8_render_set_surface_state(
 
     memset(ss, 0, sizeof(*ss));
 
-    switch (flags & (I965_PP_FLAG_TOP_FIELD|I965_PP_FLAG_BOTTOM_FIELD)) {
-    case I965_PP_FLAG_BOTTOM_FIELD:
+    switch (flags & (VA_TOP_FIELD|VA_BOTTOM_FIELD)) {
+    case VA_BOTTOM_FIELD:
         ss->ss0.vert_line_stride_ofs = 1;
         /* fall-through */
-    case I965_PP_FLAG_TOP_FIELD:
+    case VA_TOP_FIELD:
         ss->ss0.vert_line_stride = 1;
         height /= 2;
         break;
@@ -214,11 +208,11 @@ gen8_render_set_surface_state(
     ss->ss0.horizontal_alignment = 1;
 
     dri_bo_get_tiling(bo, &tiling, &swizzle);
-    gen8_render_set_surface_tiling(ss, tiling);
+    gen9_render_set_surface_tiling(ss, tiling);
 }
 
 static void
-gen8_render_src_surface_state(
+gen9_render_src_surface_state(
     VADriverContextP ctx,
     int              index,
     dri_bo          *region,
@@ -241,11 +235,11 @@ gen8_render_src_surface_state(
     assert(ss_bo->virtual);
     ss = (char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index);
 
-    gen8_render_set_surface_state(ss,
+    gen9_render_set_surface_state(ss,
                                   region, offset,
                                   w, h,
                                   pitch, format, flags);
-    gen8_render_set_surface_scs(ss);
+    gen9_render_set_surface_scs(ss);
     dri_bo_emit_reloc(ss_bo,
                       I915_GEM_DOMAIN_SAMPLER, 0,
                       offset,
@@ -258,7 +252,7 @@ gen8_render_src_surface_state(
 }
 
 static void
-gen8_render_src_surfaces_state(
+gen9_render_src_surfaces_state(
     VADriverContextP ctx,
     struct object_surface *obj_surface,
     unsigned int     flags
@@ -273,35 +267,32 @@ gen8_render_src_surfaces_state(
     rh = obj_surface->orig_height;
     region = obj_surface->bo;
 
-    gen8_render_src_surface_state(ctx, 1, region, 0, rw, rh, region_pitch, I965_SURFACEFORMAT_R8_UNORM, flags);     /* Y */
-    gen8_render_src_surface_state(ctx, 2, region, 0, rw, rh, region_pitch, I965_SURFACEFORMAT_R8_UNORM, flags);
-
-    if (obj_surface->fourcc == VA_FOURCC_Y800) /* single plane for grayscale */
-        return;
+    gen9_render_src_surface_state(ctx, 1, region, 0, rw, rh, region_pitch, I965_SURFACEFORMAT_R8_UNORM, flags);     /* Y */
+    gen9_render_src_surface_state(ctx, 2, region, 0, rw, rh, region_pitch, I965_SURFACEFORMAT_R8_UNORM, flags);
 
-    if (obj_surface->fourcc == VA_FOURCC_NV12) {
-        gen8_render_src_surface_state(ctx, 3, region,
+    if (obj_surface->fourcc == VA_FOURCC('N', 'V', '1', '2')) {
+        gen9_render_src_surface_state(ctx, 3, region,
                                       region_pitch * obj_surface->y_cb_offset,
                                       obj_surface->cb_cr_width, obj_surface->cb_cr_height, obj_surface->cb_cr_pitch,
                                       I965_SURFACEFORMAT_R8G8_UNORM, flags); /* UV */
-        gen8_render_src_surface_state(ctx, 4, region,
+        gen9_render_src_surface_state(ctx, 4, region,
                                       region_pitch * obj_surface->y_cb_offset,
                                       obj_surface->cb_cr_width, obj_surface->cb_cr_height, obj_surface->cb_cr_pitch,
                                       I965_SURFACEFORMAT_R8G8_UNORM, flags);
     } else {
-        gen8_render_src_surface_state(ctx, 3, region,
+        gen9_render_src_surface_state(ctx, 3, region,
                                       region_pitch * obj_surface->y_cb_offset,
                                       obj_surface->cb_cr_width, obj_surface->cb_cr_height, obj_surface->cb_cr_pitch,
                                       I965_SURFACEFORMAT_R8_UNORM, flags); /* U */
-        gen8_render_src_surface_state(ctx, 4, region,
+        gen9_render_src_surface_state(ctx, 4, region,
                                       region_pitch * obj_surface->y_cb_offset,
                                       obj_surface->cb_cr_width, obj_surface->cb_cr_height, obj_surface->cb_cr_pitch,
                                       I965_SURFACEFORMAT_R8_UNORM, flags);
-        gen8_render_src_surface_state(ctx, 5, region,
+        gen9_render_src_surface_state(ctx, 5, region,
                                       region_pitch * obj_surface->y_cr_offset,
                                       obj_surface->cb_cr_width, obj_surface->cb_cr_height, obj_surface->cb_cr_pitch,
                                       I965_SURFACEFORMAT_R8_UNORM, flags); /* V */
-        gen8_render_src_surface_state(ctx, 6, region,
+        gen9_render_src_surface_state(ctx, 6, region,
                                       region_pitch * obj_surface->y_cr_offset,
                                       obj_surface->cb_cr_width, obj_surface->cb_cr_height, obj_surface->cb_cr_pitch,
                                       I965_SURFACEFORMAT_R8_UNORM, flags);
@@ -309,7 +300,7 @@ gen8_render_src_surfaces_state(
 }
 
 static void
-gen8_subpic_render_src_surfaces_state(VADriverContextP ctx,
+gen9_subpic_render_src_surfaces_state(VADriverContextP ctx,
                                       struct object_surface *obj_surface)
 {
     dri_bo *subpic_region;
@@ -321,12 +312,12 @@ gen8_subpic_render_src_surfaces_state(VADriverContextP ctx,
     assert(obj_surface->bo);
     subpic_region = obj_image->bo;
     /*subpicture surface*/
-    gen8_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format, 0);
-    gen8_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format, 0);
+    gen9_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format, 0);
+    gen9_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format, 0);
 }
 
 static void
-gen8_render_dest_surface_state(VADriverContextP ctx, int index)
+gen9_render_dest_surface_state(VADriverContextP ctx, int index)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -346,11 +337,11 @@ gen8_render_dest_surface_state(VADriverContextP ctx, int index)
     assert(ss_bo->virtual);
     ss = (char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index);
 
-    gen8_render_set_surface_state(ss,
+    gen9_render_set_surface_state(ss,
                                   dest_region->bo, 0,
                                   dest_region->width, dest_region->height,
                                   dest_region->pitch, format, 0);
-    gen8_render_set_surface_scs(ss);
+    gen9_render_set_surface_scs(ss);
     dri_bo_emit_reloc(ss_bo,
                       I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
                       0,
@@ -510,7 +501,7 @@ i965_render_upload_image_palette(
 }
 
 static void
-gen8_clear_dest_region(VADriverContextP ctx)
+gen9_clear_dest_region(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -562,7 +553,7 @@ gen8_clear_dest_region(VADriverContextP ctx)
 #define ALIGNMENT       64
 
 static void
-gen8_render_initialize(VADriverContextP ctx)
+gen9_render_initialize(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -658,7 +649,7 @@ gen8_render_initialize(VADriverContextP ctx)
 }
 
 static void
-gen8_render_sampler(VADriverContextP ctx)
+gen9_render_sampler(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -691,7 +682,7 @@ gen8_render_sampler(VADriverContextP ctx)
 }
 
 static void
-gen8_render_blend_state(VADriverContextP ctx)
+gen9_render_blend_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -719,7 +710,7 @@ gen8_render_blend_state(VADriverContextP ctx)
 
 
 static void
-gen8_render_cc_viewport(VADriverContextP ctx)
+gen9_render_cc_viewport(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -743,7 +734,7 @@ gen8_render_cc_viewport(VADriverContextP ctx)
 }
 
 static void
-gen8_render_color_calc_state(VADriverContextP ctx)
+gen9_render_color_calc_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -769,7 +760,7 @@ gen8_render_color_calc_state(VADriverContextP ctx)
 #define PI  3.1415926
 
 static void
-gen8_render_upload_constants(VADriverContextP ctx,
+gen9_render_upload_constants(VADriverContextP ctx,
                              struct object_surface *obj_surface,
                              unsigned int flags)
 {
@@ -794,11 +785,11 @@ gen8_render_upload_constants(VADriverContextP ctx,
     constant_buffer = (unsigned short *) cc_ptr;
 
     if (obj_surface->subsampling == SUBSAMPLE_YUV400) {
-        assert(obj_surface->fourcc == VA_FOURCC_Y800);
+        assert(obj_surface->fourcc == VA_FOURCC('Y', '8', '0', '0'));
 
         *constant_buffer = 2;
     } else {
-        if (obj_surface->fourcc == VA_FOURCC_NV12)
+        if (obj_surface->fourcc == VA_FOURCC('N', 'V', '1', '2'))
             *constant_buffer = 1;
         else
             *constant_buffer = 0;
@@ -831,7 +822,7 @@ gen8_render_upload_constants(VADriverContextP ctx,
 }
 
 static void
-gen8_render_setup_states(
+gen9_render_setup_states(
     VADriverContextP   ctx,
     struct object_surface *obj_surface,
     const VARectangle *src_rect,
@@ -839,25 +830,25 @@ gen8_render_setup_states(
     unsigned int       flags
 )
 {
-    gen8_render_dest_surface_state(ctx, 0);
-    gen8_render_src_surfaces_state(ctx, obj_surface, flags);
-    gen8_render_sampler(ctx);
-    gen8_render_cc_viewport(ctx);
-    gen8_render_color_calc_state(ctx);
-    gen8_render_blend_state(ctx);
-    gen8_render_upload_constants(ctx, obj_surface, flags);
+    gen9_render_dest_surface_state(ctx, 0);
+    gen9_render_src_surfaces_state(ctx, obj_surface, flags);
+    gen9_render_sampler(ctx);
+    gen9_render_cc_viewport(ctx);
+    gen9_render_color_calc_state(ctx);
+    gen9_render_blend_state(ctx);
+    gen9_render_upload_constants(ctx, obj_surface, flags);
     i965_render_upload_vertex(ctx, obj_surface, src_rect, dst_rect);
 }
 
 static void
-gen8_emit_state_base_address(VADriverContextP ctx)
+gen9_emit_state_base_address(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
     struct i965_render_state *render_state = &i965->render_state;
 
-    BEGIN_BATCH(batch, 16);
-    OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (16 - 2));
+    BEGIN_BATCH(batch, 19);
+    OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (19 - 2));
     OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* General state base address */
 	OUT_BATCH(batch, 0);
 	OUT_BATCH(batch, 0);
@@ -885,11 +876,16 @@ gen8_emit_state_base_address(VADriverContextP ctx)
     OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY); /* Dynamic state upper bound */
     OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY); /* Indirect object upper bound */
     OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY); /* Instruction access upper bound */
+
+    /* the bindless surface state address */
+    OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0xFFFF0000);
     ADVANCE_BATCH(batch);
 }
 
 static void
-gen8_emit_cc_state_pointers(VADriverContextP ctx)
+gen9_emit_cc_state_pointers(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -908,7 +904,7 @@ gen8_emit_cc_state_pointers(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_vertices(VADriverContextP ctx)
+gen9_emit_vertices(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -933,6 +929,13 @@ gen8_emit_vertices(VADriverContextP ctx)
               _3DPRIM_RECTLIST);
     ADVANCE_BATCH(batch);
 
+    OUT_BATCH(batch, GEN7_3DSTATE_VF | (2 - 2));
+    OUT_BATCH(batch, 0);
+
+    OUT_BATCH(batch, GEN8_3DSTATE_VF_INSTANCING | (3 - 2));
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0);
+
     BEGIN_BATCH(batch, 7);
     OUT_BATCH(batch, CMD_3DPRIMITIVE | (7 - 2));
     OUT_BATCH(batch,
@@ -946,7 +949,7 @@ gen8_emit_vertices(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_vertex_element_state(VADriverContextP ctx)
+gen9_emit_vertex_element_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -996,7 +999,7 @@ gen8_emit_vertex_element_state(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_vs_state(VADriverContextP ctx)
+gen9_emit_vs_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1053,7 +1056,7 @@ gen8_emit_vs_state(VADriverContextP ctx)
  * ----------------------------------------
  */
 static void
-gen8_emit_urb(VADriverContextP ctx)
+gen9_emit_urb(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1121,7 +1124,7 @@ gen8_emit_urb(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_bypass_state(VADriverContextP ctx)
+gen9_emit_bypass_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1230,8 +1233,8 @@ gen8_emit_bypass_state(VADriverContextP ctx)
     OUT_BATCH(batch, 0);
     ADVANCE_BATCH(batch);
 
-    BEGIN_BATCH(batch, 9);
-    OUT_BATCH(batch, GEN7_3DSTATE_DS | (9 - 2));
+    BEGIN_BATCH(batch, 11);
+    OUT_BATCH(batch, GEN7_3DSTATE_DS | (11 - 2));
     /* DW1. DS shader pointer */
     OUT_BATCH(batch, 0);
     OUT_BATCH(batch, 0);
@@ -1244,6 +1247,10 @@ gen8_emit_bypass_state(VADriverContextP ctx)
     OUT_BATCH(batch, 0);
     /* DW8. DS shader output URB */
     OUT_BATCH(batch, 0);
+
+    /* Dual-patch kernel start pointer */
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0);
     ADVANCE_BATCH(batch);
 
     BEGIN_BATCH(batch, 2);
@@ -1267,13 +1274,14 @@ gen8_emit_bypass_state(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_invarient_states(VADriverContextP ctx)
+gen9_emit_invarient_states(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
 
     BEGIN_BATCH(batch, 1);
-    OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D);
+    OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D |
+                     GEN9_PIPELINE_SELECTION_MASK);
     ADVANCE_BATCH(batch);
 
     BEGIN_BATCH(batch, 2);
@@ -1310,7 +1318,7 @@ gen8_emit_invarient_states(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_clip_state(VADriverContextP ctx)
+gen9_emit_clip_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1322,7 +1330,7 @@ gen8_emit_clip_state(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_sf_state(VADriverContextP ctx)
+gen9_emit_sf_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1336,8 +1344,8 @@ gen8_emit_sf_state(VADriverContextP ctx)
     ADVANCE_BATCH(batch);
 
 
-    BEGIN_BATCH(batch, 4);
-    OUT_BATCH(batch, GEN7_3DSTATE_SBE | (4 - 2));
+    BEGIN_BATCH(batch, 6);
+    OUT_BATCH(batch, GEN7_3DSTATE_SBE | (6 - 2));
     OUT_BATCH(batch,
 	      (GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH) |
 	      (GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET) |
@@ -1346,6 +1354,8 @@ gen8_emit_sf_state(VADriverContextP ctx)
               (1 << GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT));
     OUT_BATCH(batch, 0);
     OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, GEN9_SBE_ACTIVE_COMPONENT_XYZW);
+    OUT_BATCH(batch, 0);
     ADVANCE_BATCH(batch);
 
     /* SBE for backend setup */
@@ -1372,7 +1382,7 @@ gen8_emit_sf_state(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_wm_state(VADriverContextP ctx, int kernel)
+gen9_emit_wm_state(VADriverContextP ctx, int kernel)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1393,12 +1403,12 @@ gen8_emit_wm_state(VADriverContextP ctx, int kernel)
 	OUT_BATCH(batch, GEN8_3DSTATE_PSBLEND | (2 - 2));
 	OUT_BATCH(batch,
 		GEN8_PS_BLEND_HAS_WRITEABLE_RT);
-    	ADVANCE_BATCH(batch);
+	ADVANCE_BATCH(batch);
     } else if (kernel == PS_SUBPIC_KERNEL) {
 	BEGIN_BATCH(batch, 2);
 	OUT_BATCH(batch, GEN8_3DSTATE_PSBLEND | (2 - 2));
 	OUT_BATCH(batch,
-              	(GEN8_PS_BLEND_HAS_WRITEABLE_RT |
+		(GEN8_PS_BLEND_HAS_WRITEABLE_RT |
 		 GEN8_PS_BLEND_COLOR_BUFFER_BLEND_ENABLE |
 		 (I965_BLENDFACTOR_SRC_ALPHA << GEN8_PS_BLEND_SRC_ALPHA_BLEND_FACTOR_SHIFT) |
 		 (I965_BLENDFACTOR_INV_SRC_ALPHA << GEN8_PS_BLEND_DST_ALPHA_BLEND_FACTOR_SHIFT) |
@@ -1464,7 +1474,7 @@ gen8_emit_wm_state(VADriverContextP ctx, int kernel)
 }
 
 static void
-gen8_emit_depth_buffer_state(VADriverContextP ctx)
+gen9_emit_depth_buffer_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1510,7 +1520,7 @@ gen8_emit_depth_buffer_state(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_depth_stencil_state(VADriverContextP ctx)
+gen9_emit_depth_stencil_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1523,7 +1533,7 @@ gen8_emit_depth_stencil_state(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_wm_hz_op(VADriverContextP ctx)
+gen9_emit_wm_hz_op(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1538,7 +1548,7 @@ gen8_emit_wm_hz_op(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_viewport_state_pointers(VADriverContextP ctx)
+gen9_emit_viewport_state_pointers(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1556,7 +1566,7 @@ gen8_emit_viewport_state_pointers(VADriverContextP ctx)
 }
 
 static void
-gen8_emit_sampler_state_pointers(VADriverContextP ctx)
+gen9_emit_sampler_state_pointers(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
@@ -1570,41 +1580,41 @@ gen8_emit_sampler_state_pointers(VADriverContextP ctx)
 
 
 static void
-gen7_emit_drawing_rectangle(VADriverContextP ctx)
+gen9_emit_drawing_rectangle(VADriverContextP ctx)
 {
     i965_render_drawing_rectangle(ctx);
 }
 
 static void
-gen8_render_emit_states(VADriverContextP ctx, int kernel)
+gen9_render_emit_states(VADriverContextP ctx, int kernel)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
 
     intel_batchbuffer_start_atomic(batch, 0x1000);
     intel_batchbuffer_emit_mi_flush(batch);
-    gen8_emit_invarient_states(ctx);
-    gen8_emit_state_base_address(ctx);
-    gen8_emit_viewport_state_pointers(ctx);
-    gen8_emit_urb(ctx);
-    gen8_emit_cc_state_pointers(ctx);
-    gen8_emit_sampler_state_pointers(ctx);
-    gen8_emit_wm_hz_op(ctx);
-    gen8_emit_bypass_state(ctx);
-    gen8_emit_vs_state(ctx);
-    gen8_emit_clip_state(ctx);
-    gen8_emit_sf_state(ctx);
-    gen8_emit_depth_stencil_state(ctx);
-    gen8_emit_wm_state(ctx, kernel);
-    gen8_emit_depth_buffer_state(ctx);
-    gen7_emit_drawing_rectangle(ctx);
-    gen8_emit_vertex_element_state(ctx);
-    gen8_emit_vertices(ctx);
+    gen9_emit_invarient_states(ctx);
+    gen9_emit_state_base_address(ctx);
+    gen9_emit_viewport_state_pointers(ctx);
+    gen9_emit_urb(ctx);
+    gen9_emit_cc_state_pointers(ctx);
+    gen9_emit_sampler_state_pointers(ctx);
+    gen9_emit_wm_hz_op(ctx);
+    gen9_emit_bypass_state(ctx);
+    gen9_emit_vs_state(ctx);
+    gen9_emit_clip_state(ctx);
+    gen9_emit_sf_state(ctx);
+    gen9_emit_depth_stencil_state(ctx);
+    gen9_emit_wm_state(ctx, kernel);
+    gen9_emit_depth_buffer_state(ctx);
+    gen9_emit_drawing_rectangle(ctx);
+    gen9_emit_vertex_element_state(ctx);
+    gen9_emit_vertices(ctx);
     intel_batchbuffer_end_atomic(batch);
 }
 
 static void
-gen8_render_put_surface(
+gen9_render_put_surface(
     VADriverContextP   ctx,
     struct object_surface *obj_surface,
     const VARectangle *src_rect,
@@ -1615,15 +1625,15 @@ gen8_render_put_surface(
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
 
-    gen8_render_initialize(ctx);
-    gen8_render_setup_states(ctx, obj_surface, src_rect, dst_rect, flags);
-    gen8_clear_dest_region(ctx);
-    gen8_render_emit_states(ctx, PS_KERNEL);
+    gen9_render_initialize(ctx);
+    gen9_render_setup_states(ctx, obj_surface, src_rect, dst_rect, flags);
+    gen9_clear_dest_region(ctx);
+    gen9_render_emit_states(ctx, PS_KERNEL);
     intel_batchbuffer_flush(batch);
 }
 
 static void
-gen8_subpicture_render_blend_state(VADriverContextP ctx)
+gen9_subpicture_render_blend_state(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -1657,7 +1667,7 @@ gen8_subpicture_render_blend_state(VADriverContextP ctx)
 }
 
 static void
-gen8_subpic_render_upload_constants(VADriverContextP ctx,
+gen9_subpic_render_upload_constants(VADriverContextP ctx,
                                     struct object_surface *obj_surface)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
@@ -1686,25 +1696,25 @@ gen8_subpic_render_upload_constants(VADriverContextP ctx,
 }
 
 static void
-gen8_subpicture_render_setup_states(
+gen9_subpicture_render_setup_states(
     VADriverContextP   ctx,
     struct object_surface *obj_surface,
     const VARectangle *src_rect,
     const VARectangle *dst_rect
 )
 {
-    gen8_render_dest_surface_state(ctx, 0);
-    gen8_subpic_render_src_surfaces_state(ctx, obj_surface);
-    gen8_render_sampler(ctx);
-    gen8_render_cc_viewport(ctx);
-    gen8_render_color_calc_state(ctx);
-    gen8_subpicture_render_blend_state(ctx);
-    gen8_subpic_render_upload_constants(ctx, obj_surface);
+    gen9_render_dest_surface_state(ctx, 0);
+    gen9_subpic_render_src_surfaces_state(ctx, obj_surface);
+    gen9_render_sampler(ctx);
+    gen9_render_cc_viewport(ctx);
+    gen9_render_color_calc_state(ctx);
+    gen9_subpicture_render_blend_state(ctx);
+    gen9_subpic_render_upload_constants(ctx, obj_surface);
     i965_subpic_render_upload_vertex(ctx, obj_surface, dst_rect);
 }
 
 static void
-gen8_render_put_subpicture(
+gen9_render_put_subpicture(
     VADriverContextP   ctx,
     struct object_surface *obj_surface,
     const VARectangle *src_rect,
@@ -1717,15 +1727,15 @@ gen8_render_put_subpicture(
     struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
 
     assert(obj_subpic);
-    gen8_render_initialize(ctx);
-    gen8_subpicture_render_setup_states(ctx, obj_surface, src_rect, dst_rect);
-    gen8_render_emit_states(ctx, PS_SUBPIC_KERNEL);
+    gen9_render_initialize(ctx);
+    gen9_subpicture_render_setup_states(ctx, obj_surface, src_rect, dst_rect);
+    gen9_render_emit_states(ctx, PS_SUBPIC_KERNEL);
     i965_render_upload_image_palette(ctx, obj_subpic->obj_image, 0xff);
     intel_batchbuffer_flush(batch);
 }
 
 static void
-gen8_render_terminate(VADriverContextP ctx)
+gen9_render_terminate(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -1759,7 +1769,7 @@ gen8_render_terminate(VADriverContextP ctx)
 }
 
 bool
-gen8_render_init(VADriverContextP ctx)
+gen9_render_init(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
@@ -1768,12 +1778,12 @@ gen8_render_init(VADriverContextP ctx)
     unsigned char *kernel_ptr;
     struct i965_kernel *kernel;
 
-    render_state->render_put_surface = gen8_render_put_surface;
-    render_state->render_put_subpicture = gen8_render_put_subpicture;
-    render_state->render_terminate = gen8_render_terminate;
+    render_state->render_put_surface = gen9_render_put_surface;
+    render_state->render_put_subpicture = gen9_render_put_subpicture;
+    render_state->render_terminate = gen9_render_terminate;
 
-    memcpy(render_state->render_kernels, render_kernels_gen8,
-           sizeof(render_state->render_kernels));
+    memcpy(render_state->render_kernels, render_kernels_gen9,
+			sizeof(render_state->render_kernels));
 
     kernel_size = 4096;
 
@@ -1783,7 +1793,7 @@ gen8_render_init(VADriverContextP ctx)
         if (!kernel->size)
             continue;
 
-        kernel_size += kernel->size;
+        kernel_size += ALIGN(kernel->size, ALIGNMENT);
     }
 
     render_state->instruction_state.bo = dri_bo_alloc(i965->intel.bufmgr,
diff --git a/src/gen8_vme.c b/src/gen9_vme.c
similarity index 84%
copy from src/gen8_vme.c
copy to src/gen9_vme.c
index 8cae2a0..b4310f2 100644
--- a/src/gen8_vme.c
+++ b/src/gen9_vme.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2012 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -58,71 +58,71 @@
 #define CURBE_URB_ENTRY_LENGTH  4               /* in 256-bit, it should be less than or equal to CURBE_TOTAL_DATA_LENGTH / 32 */
 
 #define VME_MSG_LENGTH		32
-  
-static const uint32_t gen8_vme_intra_frame[][4] = {
-#include "shaders/vme/intra_frame_gen8.g8b"
+
+static const uint32_t gen9_vme_intra_frame[][4] = {
+#include "shaders/vme/intra_frame_gen9.g9b"
 };
 
-static const uint32_t gen8_vme_inter_frame[][4] = {
-#include "shaders/vme/inter_frame_gen8.g8b"
+static const uint32_t gen9_vme_inter_frame[][4] = {
+#include "shaders/vme/inter_frame_gen9.g9b"
 };
 
-static const uint32_t gen8_vme_inter_bframe[][4] = {
-#include "shaders/vme/inter_bframe_gen8.g8b"
+static const uint32_t gen9_vme_inter_bframe[][4] = {
+#include "shaders/vme/inter_bframe_gen9.g9b"
 };
 
-static struct i965_kernel gen8_vme_kernels[] = {
+static struct i965_kernel gen9_vme_kernels[] = {
     {
         "VME Intra Frame",
         VME_INTRA_SHADER, /*index*/
-        gen8_vme_intra_frame, 			
-        sizeof(gen8_vme_intra_frame),		
+        gen9_vme_intra_frame,
+        sizeof(gen9_vme_intra_frame),
         NULL
     },
     {
         "VME inter Frame",
         VME_INTER_SHADER,
-        gen8_vme_inter_frame,
-        sizeof(gen8_vme_inter_frame),
+        gen9_vme_inter_frame,
+        sizeof(gen9_vme_inter_frame),
         NULL
     },
     {
         "VME inter BFrame",
         VME_BINTER_SHADER,
-        gen8_vme_inter_bframe,
-        sizeof(gen8_vme_inter_bframe),
+        gen9_vme_inter_bframe,
+        sizeof(gen9_vme_inter_bframe),
         NULL
     }
 };
 
-static const uint32_t gen8_vme_mpeg2_intra_frame[][4] = {
-#include "shaders/vme/intra_frame_gen8.g8b"
+static const uint32_t gen9_vme_mpeg2_intra_frame[][4] = {
+#include "shaders/vme/intra_frame_gen9.g9b"
 };
 
-static const uint32_t gen8_vme_mpeg2_inter_frame[][4] = {
-#include "shaders/vme/mpeg2_inter_gen8.g8b"
+static const uint32_t gen9_vme_mpeg2_inter_frame[][4] = {
+#include "shaders/vme/mpeg2_inter_gen9.g9b"
 };
 
-static struct i965_kernel gen8_vme_mpeg2_kernels[] = {
+static struct i965_kernel gen9_vme_mpeg2_kernels[] = {
     {
         "VME Intra Frame",
         VME_INTRA_SHADER, /*index*/
-        gen8_vme_mpeg2_intra_frame, 			
-        sizeof(gen8_vme_mpeg2_intra_frame),		
+        gen9_vme_mpeg2_intra_frame,
+        sizeof(gen9_vme_mpeg2_intra_frame),
         NULL
     },
     {
         "VME inter Frame",
         VME_INTER_SHADER,
-        gen8_vme_mpeg2_inter_frame,
-        sizeof(gen8_vme_mpeg2_inter_frame),
+        gen9_vme_mpeg2_inter_frame,
+        sizeof(gen9_vme_mpeg2_inter_frame),
         NULL
     },
 };
 
 /* only used for VME source surface state */
-static void 
-gen8_vme_source_surface_state(VADriverContextP ctx,
+static void
+gen9_vme_source_surface_state(VADriverContextP ctx,
                               int index,
                               struct object_surface *obj_surface,
                               struct intel_encoder_context *encoder_context)
@@ -137,7 +137,7 @@ gen8_vme_source_surface_state(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_media_source_surface_state(VADriverContextP ctx,
+gen9_vme_media_source_surface_state(VADriverContextP ctx,
                                     int index,
                                     struct object_surface *obj_surface,
                                     struct intel_encoder_context *encoder_context)
@@ -152,7 +152,7 @@ gen8_vme_media_source_surface_state(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_media_chroma_source_surface_state(VADriverContextP ctx,
+gen9_vme_media_chroma_source_surface_state(VADriverContextP ctx,
                                            int index,
                                            struct object_surface *obj_surface,
                                            struct intel_encoder_context *encoder_context)
@@ -167,7 +167,7 @@ gen8_vme_media_chroma_source_surface_state(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_output_buffer_setup(VADriverContextP ctx,
+gen9_vme_output_buffer_setup(VADriverContextP ctx,
                              struct encode_state *encode_state,
                              int index,
                              struct intel_encoder_context *encoder_context)
@@ -194,7 +194,7 @@ gen8_vme_output_buffer_setup(VADriverContextP ctx,
      * 16 * (2 + 2 * (1 + 8 + 2))= 16 * 24.
      */
 
-    vme_context->vme_output.bo = dri_bo_alloc(i965->intel.bufmgr, 
+    vme_context->vme_output.bo = dri_bo_alloc(i965->intel.bufmgr,
                                               "VME output buffer",
                                               vme_context->vme_output.num_blocks * vme_context->vme_output.size_block,
                                               0x1000);
@@ -207,7 +207,7 @@ gen8_vme_output_buffer_setup(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_output_vme_batchbuffer_setup(VADriverContextP ctx,
+gen9_vme_output_vme_batchbuffer_setup(VADriverContextP ctx,
                                       struct encode_state *encode_state,
                                       int index,
                                       struct intel_encoder_context *encoder_context)
@@ -222,7 +222,7 @@ gen8_vme_output_vme_batchbuffer_setup(VADriverContextP ctx,
     vme_context->vme_batchbuffer.num_blocks = width_in_mbs * height_in_mbs + 1;
     vme_context->vme_batchbuffer.size_block = 64; /* 4 OWORDs */
     vme_context->vme_batchbuffer.pitch = 16;
-    vme_context->vme_batchbuffer.bo = dri_bo_alloc(i965->intel.bufmgr, 
+    vme_context->vme_batchbuffer.bo = dri_bo_alloc(i965->intel.bufmgr,
                                                    "VME batchbuffer",
                                                    vme_context->vme_batchbuffer.num_blocks * vme_context->vme_batchbuffer.size_block,
                                                    0x1000);
@@ -236,7 +236,7 @@ gen8_vme_output_vme_batchbuffer_setup(VADriverContextP ctx,
 }
 
 static VAStatus
-gen8_vme_surface_setup(VADriverContextP ctx, 
+gen9_vme_surface_setup(VADriverContextP ctx,
                        struct encode_state *encode_state,
                        int is_intra,
                        struct intel_encoder_context *encoder_context)
@@ -246,9 +246,9 @@ gen8_vme_surface_setup(VADriverContextP ctx,
     /*Setup surfaces state*/
     /* current picture for encoding */
     obj_surface = encode_state->input_yuv_object;
-    gen8_vme_source_surface_state(ctx, 0, obj_surface, encoder_context);
-    gen8_vme_media_source_surface_state(ctx, 4, obj_surface, encoder_context);
-    gen8_vme_media_chroma_source_surface_state(ctx, 6, obj_surface, encoder_context);
+    gen9_vme_source_surface_state(ctx, 0, obj_surface, encoder_context);
+    gen9_vme_media_source_surface_state(ctx, 4, obj_surface, encoder_context);
+    gen9_vme_media_chroma_source_surface_state(ctx, 6, obj_surface, encoder_context);
 
     if (!is_intra) {
 	VAEncSliceParameterBufferH264 *slice_param = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer;
@@ -257,25 +257,25 @@ gen8_vme_surface_setup(VADriverContextP ctx,
 	slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type);
 	assert(slice_type != SLICE_TYPE_I && slice_type != SLICE_TYPE_SI);
 
-	intel_avc_vme_reference_state(ctx, encode_state, encoder_context, 0, 1, gen8_vme_source_surface_state);
+	intel_avc_vme_reference_state(ctx, encode_state, encoder_context, 0, 1, gen9_vme_source_surface_state);
 
 	if (slice_type == SLICE_TYPE_B)
-            intel_avc_vme_reference_state(ctx, encode_state, encoder_context, 1, 2, gen8_vme_source_surface_state);
+            intel_avc_vme_reference_state(ctx, encode_state, encoder_context, 1, 2, gen9_vme_source_surface_state);
     }
 
     /* VME output */
-    gen8_vme_output_buffer_setup(ctx, encode_state, 3, encoder_context);
-    gen8_vme_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context);
+    gen9_vme_output_buffer_setup(ctx, encode_state, 3, encoder_context);
+    gen9_vme_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context);
 
     return VA_STATUS_SUCCESS;
 }
 
-static VAStatus gen8_vme_interface_setup(VADriverContextP ctx, 
+static VAStatus gen9_vme_interface_setup(VADriverContextP ctx,
                                          struct encode_state *encode_state,
                                          struct intel_encoder_context *encoder_context)
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
-    struct gen8_interface_descriptor_data *desc;   
+    struct gen8_interface_descriptor_data *desc;
     int i;
     dri_bo *bo;
     unsigned char *desc_ptr;
@@ -301,7 +301,6 @@ static VAStatus gen8_vme_interface_setup(VADriverContextP ctx,
         desc->desc5.constant_urb_entry_read_offset = 0;
         desc->desc5.constant_urb_entry_read_length = CURBE_URB_ENTRY_LENGTH;
 
- 		
         desc++;
     }
 
@@ -310,7 +309,7 @@ static VAStatus gen8_vme_interface_setup(VADriverContextP ctx,
     return VA_STATUS_SUCCESS;
 }
 
-static VAStatus gen8_vme_constant_setup(VADriverContextP ctx, 
+static VAStatus gen9_vme_constant_setup(VADriverContextP ctx,
                                         struct encode_state *encode_state,
                                         struct intel_encoder_context *encoder_context)
 {
@@ -325,10 +324,10 @@ static VAStatus gen8_vme_constant_setup(VADriverContextP ctx,
         encoder_context->codec == CODEC_H264_MVC) {
         if (vme_context->h264_level >= 30) {
             mv_num = 16;
-        
+
             if (vme_context->h264_level >= 31)
                 mv_num = 8;
-        } 
+        }
     } else if (encoder_context->codec == CODEC_MPEG2) {
         mv_num = 2;
     }
@@ -345,7 +344,7 @@ static VAStatus gen8_vme_constant_setup(VADriverContextP ctx,
      * in the GPU shader.
      */
     memcpy(constant_buffer, (char *)vme_context->vme_state_message, 128);
-	
+
     dri_bo_unmap(vme_context->gpe_context.dynamic_state.bo);
 
     return VA_STATUS_SUCCESS;
@@ -363,7 +362,7 @@ static inline int loop_in_bounds(int x_index, int y_index, int first_mb, int num
         return -1;
     if (y_index < 0 || y_index >= mb_height)
         return -1;
-	
+
     mb_index = y_index * mb_width + x_index;
     if (mb_index < first_mb || mb_index > (first_mb + num_mb))
         return -1;
@@ -371,7 +370,7 @@ static inline int loop_in_bounds(int x_index, int y_index, int first_mb, int num
 }
 
 static void
-gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx, 
+gen9wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
                                      struct encode_state *encode_state,
                                      int mb_width, int mb_height,
                                      int kernel,
@@ -384,7 +383,7 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
     unsigned int *command_ptr;
 
 #define		USE_SCOREBOARD		(1 << 21)
- 
+
     dri_bo_map(vme_context->vme_batchbuffer.bo, 1);
     command_ptr = vme_context->vme_batchbuffer.bo->virtual;
 
@@ -399,7 +398,7 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 	x_outer = first_mb % mb_width;
 	y_outer = first_mb / mb_width;
 	mb_row = y_outer;
-				 
+
 	for (; x_outer < (mb_width -2 ) && !loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) {
 	    x_inner = x_outer;
 	    y_inner = y_outer;
@@ -408,8 +407,8 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 		score_dep = 0;
 		if (x_inner != 0) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_AE;
-		    score_dep |= MB_SCOREBOARD_A; 
-		}
+		    score_dep |= MB_SCOREBOARD_A;
+                }
 		if (y_inner != mb_row) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_B;
 		    score_dep |= MB_SCOREBOARD_B;
@@ -420,8 +419,8 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 			score_dep |= MB_SCOREBOARD_C;
                     }
 		}
-							
-            	*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
+
+		*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
 		*command_ptr++ = kernel;
 		*command_ptr++ = USE_SCOREBOARD;
 		/* Indirect data */
@@ -446,16 +445,16 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
             xtemp_outer = 0;
 	x_outer = xtemp_outer;
 	y_outer = first_mb / mb_width;
-	for (;!loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) { 
-	    y_inner = y_outer;
+	for (;!loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) {
+            y_inner = y_outer;
 	    x_inner = x_outer;
 	    for (; !loop_in_bounds(x_inner, y_inner, first_mb, num_mb, mb_width, mb_height);) {
-	    	mb_intra_ub = 0;
+		mb_intra_ub = 0;
 		score_dep = 0;
 		if (x_inner != 0) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_AE;
-		    score_dep |= MB_SCOREBOARD_A; 
-		}
+		    score_dep |= MB_SCOREBOARD_A;
+                }
 		if (y_inner != mb_row) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_B;
 		    score_dep |= MB_SCOREBOARD_B;
@@ -468,7 +467,7 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
                     }
 		}
 
-            	*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
+		*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
 		*command_ptr++ = kernel;
 		*command_ptr++ = USE_SCOREBOARD;
 		/* Indirect data */
@@ -489,8 +488,8 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 	    if (x_outer >= mb_width) {
 		y_outer += 1;
 		x_outer = xtemp_outer;
-	    }		
-	}
+	    }
+        }
     }
 
     *command_ptr++ = MI_BATCH_BUFFER_END;
@@ -500,7 +499,7 @@ gen8wa_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx, 
+gen9_vme_fill_vme_batchbuffer(VADriverContextP ctx,
                               struct encode_state *encode_state,
                               int mb_width, int mb_height,
                               int kernel,
@@ -516,13 +515,13 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
     command_ptr = vme_context->vme_batchbuffer.bo->virtual;
 
     for (s = 0; s < encode_state->num_slice_params_ext; s++) {
-        VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer; 
+        VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer;
         int slice_mb_begin = pSliceParameter->macroblock_address;
         int slice_mb_number = pSliceParameter->num_macroblocks;
         unsigned int mb_intra_ub;
-	int slice_mb_x = pSliceParameter->macroblock_address % mb_width; 
+	int slice_mb_x = pSliceParameter->macroblock_address % mb_width;
         for (i = 0; i < slice_mb_number;  ) {
-            int mb_count = i + slice_mb_begin;    
+            int mb_count = i + slice_mb_begin;
             mb_x = mb_count % mb_width;
             mb_y = mb_count / mb_width;
 	    mb_intra_ub = 0;
@@ -544,7 +543,7 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
                     mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_C;
 		}
 	    }
-		
+
 	    if ((i == mb_width) && slice_mb_x) {
 		mb_intra_ub &= ~(INTRA_PRED_AVAIL_FLAG_D);
 	    }
@@ -554,7 +553,7 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
             *command_ptr++ = 0;
             *command_ptr++ = 0;
             *command_ptr++ = 0;
-   
+
             /*inline data */
             *command_ptr++ = (mb_width << 16 | mb_y << 8 | mb_x);
             *command_ptr++ = ((encoder_context->quality_level << 24) | (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8));
@@ -562,7 +561,7 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
             *command_ptr++ = CMD_MEDIA_STATE_FLUSH;
             *command_ptr++ = 0;
             i += 1;
-        } 
+        }
     }
 
     *command_ptr++ = MI_BATCH_BUFFER_END;
@@ -571,7 +570,7 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
     dri_bo_unmap(vme_context->vme_batchbuffer.bo);
 }
 
-static void gen8_vme_media_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+static void gen9_vme_media_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
 
@@ -589,7 +588,7 @@ static void gen8_vme_media_init(VADriverContextP ctx, struct intel_encoder_conte
     vme_context->vme_state.bo = NULL;
 }
 
-static void gen8_vme_pipeline_programing(VADriverContextP ctx, 
+static void gen9_vme_pipeline_programing(VADriverContextP ctx,
                                          struct encode_state *encode_state,
                                          struct intel_encoder_context *encoder_context)
 {
@@ -609,7 +608,7 @@ static void gen8_vme_pipeline_programing(VADriverContextP ctx,
         allow_hwscore = false;
     else {
         for (s = 0; s < encode_state->num_slice_params_ext; s++) {
-            pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer; 
+            pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer;
             if ((pSliceParameter->macroblock_address % width_in_mbs)) {
                 allow_hwscore = false;
                 break;
@@ -618,25 +617,25 @@ static void gen8_vme_pipeline_programing(VADriverContextP ctx,
     }
 
     if ((pSliceParameter->slice_type == SLICE_TYPE_I) ||
-  	(pSliceParameter->slice_type == SLICE_TYPE_I)) {
- 	kernel_shader = VME_INTRA_SHADER;
+        (pSliceParameter->slice_type == SLICE_TYPE_I)) {
+        kernel_shader = VME_INTRA_SHADER;
     } else if ((pSliceParameter->slice_type == SLICE_TYPE_P) ||
                (pSliceParameter->slice_type == SLICE_TYPE_SP)) {
-	kernel_shader = VME_INTER_SHADER;
+        kernel_shader = VME_INTER_SHADER;
     } else {
- 	kernel_shader = VME_BINTER_SHADER;
-	if (!allow_hwscore)
+        kernel_shader = VME_BINTER_SHADER;
+        if (!allow_hwscore)
             kernel_shader = VME_INTER_SHADER;
     }
     if (allow_hwscore)
-	gen8wa_vme_walker_fill_vme_batchbuffer(ctx, 
-                                             encode_state,
-                                             width_in_mbs, height_in_mbs,
-                                             kernel_shader,
-                                             pPicParameter->pic_fields.bits.transform_8x8_mode_flag,
-                                             encoder_context);
+        gen9wa_vme_walker_fill_vme_batchbuffer(ctx,
+                                               encode_state,
+                                               width_in_mbs, height_in_mbs,
+                                               kernel_shader,
+                                               pPicParameter->pic_fields.bits.transform_8x8_mode_flag,
+                                               encoder_context);
     else
-	gen8_vme_fill_vme_batchbuffer(ctx, 
+        gen9_vme_fill_vme_batchbuffer(ctx,
                                       encode_state,
                                       width_in_mbs, height_in_mbs,
                                       kernel_shader,
@@ -644,20 +643,22 @@ static void gen8_vme_pipeline_programing(VADriverContextP ctx,
                                       encoder_context);
 
     intel_batchbuffer_start_atomic(batch, 0x1000);
-    gen8_gpe_pipeline_setup(ctx, &vme_context->gpe_context, batch);
+    gen9_gpe_pipeline_setup(ctx, &vme_context->gpe_context, batch);
     BEGIN_BATCH(batch, 3);
     OUT_BATCH(batch, MI_BATCH_BUFFER_START | (1 << 8) | (1 << 0));
     OUT_RELOC(batch,
               vme_context->vme_batchbuffer.bo,
-              I915_GEM_DOMAIN_COMMAND, 0, 
+              I915_GEM_DOMAIN_COMMAND, 0,
               0);
     OUT_BATCH(batch, 0);
     ADVANCE_BATCH(batch);
 
-    intel_batchbuffer_end_atomic(batch);	
+    gen9_gpe_pipeline_end(ctx, &vme_context->gpe_context, batch);
+
+    intel_batchbuffer_end_atomic(batch);
 }
 
-static VAStatus gen8_vme_prepare(VADriverContextP ctx, 
+static VAStatus gen9_vme_prepare(VADriverContextP ctx,
                                  struct encode_state *encode_state,
                                  struct intel_encoder_context *encoder_context)
 {
@@ -669,24 +670,24 @@ static VAStatus gen8_vme_prepare(VADriverContextP ctx,
 
     if (!vme_context->h264_level ||
         (vme_context->h264_level != pSequenceParameter->level_idc)) {
-	vme_context->h264_level = pSequenceParameter->level_idc;	
-    }	
+	vme_context->h264_level = pSequenceParameter->level_idc;
+    }
 
     intel_vme_update_mbmv_cost(ctx, encode_state, encoder_context);
-    	
+
     /*Setup all the memory object*/
-    gen8_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
-    gen8_vme_interface_setup(ctx, encode_state, encoder_context);
-    //gen8_vme_vme_state_setup(ctx, encode_state, is_intra, encoder_context);
-    gen8_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen9_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
+    gen9_vme_interface_setup(ctx, encode_state, encoder_context);
+    //gen9_vme_vme_state_setup(ctx, encode_state, is_intra, encoder_context);
+    gen9_vme_constant_setup(ctx, encode_state, encoder_context);
 
     /*Programing media pipeline*/
-    gen8_vme_pipeline_programing(ctx, encode_state, encoder_context);
+    gen9_vme_pipeline_programing(ctx, encode_state, encoder_context);
 
     return vaStatus;
 }
 
-static VAStatus gen8_vme_run(VADriverContextP ctx, 
+static VAStatus gen9_vme_run(VADriverContextP ctx,
                              struct encode_state *encode_state,
                              struct intel_encoder_context *encoder_context)
 {
@@ -697,7 +698,7 @@ static VAStatus gen8_vme_run(VADriverContextP ctx,
     return VA_STATUS_SUCCESS;
 }
 
-static VAStatus gen8_vme_stop(VADriverContextP ctx, 
+static VAStatus gen9_vme_stop(VADriverContextP ctx,
                               struct encode_state *encode_state,
                               struct intel_encoder_context *encoder_context)
 {
@@ -705,21 +706,21 @@ static VAStatus gen8_vme_stop(VADriverContextP ctx,
 }
 
 static VAStatus
-gen8_vme_pipeline(VADriverContextP ctx,
+gen9_vme_pipeline(VADriverContextP ctx,
                   VAProfile profile,
                   struct encode_state *encode_state,
                   struct intel_encoder_context *encoder_context)
 {
-    gen8_vme_media_init(ctx, encoder_context);
-    gen8_vme_prepare(ctx, encode_state, encoder_context);
-    gen8_vme_run(ctx, encode_state, encoder_context);
-    gen8_vme_stop(ctx, encode_state, encoder_context);
+    gen9_vme_media_init(ctx, encoder_context);
+    gen9_vme_prepare(ctx, encode_state, encoder_context);
+    gen9_vme_run(ctx, encode_state, encoder_context);
+    gen9_vme_stop(ctx, encode_state, encoder_context);
 
     return VA_STATUS_SUCCESS;
 }
 
 static void
-gen8_vme_mpeg2_output_buffer_setup(VADriverContextP ctx,
+gen9_vme_mpeg2_output_buffer_setup(VADriverContextP ctx,
                                    struct encode_state *encode_state,
                                    int index,
                                    int is_intra,
@@ -745,7 +746,7 @@ gen8_vme_mpeg2_output_buffer_setup(VADriverContextP ctx,
      * 16 * (2 + 2 * (1 + 8 + 2))= 16 * 24.
      */
 
-    vme_context->vme_output.bo = dri_bo_alloc(i965->intel.bufmgr, 
+    vme_context->vme_output.bo = dri_bo_alloc(i965->intel.bufmgr,
                                               "VME output buffer",
                                               vme_context->vme_output.num_blocks * vme_context->vme_output.size_block,
                                               0x1000);
@@ -758,7 +759,7 @@ gen8_vme_mpeg2_output_buffer_setup(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_mpeg2_output_vme_batchbuffer_setup(VADriverContextP ctx,
+gen9_vme_mpeg2_output_vme_batchbuffer_setup(VADriverContextP ctx,
                                             struct encode_state *encode_state,
                                             int index,
                                             struct intel_encoder_context *encoder_context)
@@ -773,7 +774,7 @@ gen8_vme_mpeg2_output_vme_batchbuffer_setup(VADriverContextP ctx,
     vme_context->vme_batchbuffer.num_blocks = width_in_mbs * height_in_mbs + 1;
     vme_context->vme_batchbuffer.size_block = 64; /* 4 OWORDs */
     vme_context->vme_batchbuffer.pitch = 16;
-    vme_context->vme_batchbuffer.bo = dri_bo_alloc(i965->intel.bufmgr, 
+    vme_context->vme_batchbuffer.bo = dri_bo_alloc(i965->intel.bufmgr,
                                                    "VME batchbuffer",
                                                    vme_context->vme_batchbuffer.num_blocks * vme_context->vme_batchbuffer.size_block,
                                                    0x1000);
@@ -785,7 +786,7 @@ gen8_vme_mpeg2_output_vme_batchbuffer_setup(VADriverContextP ctx,
 }
 
 static VAStatus
-gen8_vme_mpeg2_surface_setup(VADriverContextP ctx, 
+gen9_vme_mpeg2_surface_setup(VADriverContextP ctx,
                              struct encode_state *encode_state,
                              int is_intra,
                              struct intel_encoder_context *encoder_context)
@@ -795,33 +796,33 @@ gen8_vme_mpeg2_surface_setup(VADriverContextP ctx,
     /*Setup surfaces state*/
     /* current picture for encoding */
     obj_surface = encode_state->input_yuv_object;
-    gen8_vme_source_surface_state(ctx, 0, obj_surface, encoder_context);
-    gen8_vme_media_source_surface_state(ctx, 4, obj_surface, encoder_context);
-    gen8_vme_media_chroma_source_surface_state(ctx, 6, obj_surface, encoder_context);
+    gen9_vme_source_surface_state(ctx, 0, obj_surface, encoder_context);
+    gen9_vme_media_source_surface_state(ctx, 4, obj_surface, encoder_context);
+    gen9_vme_media_chroma_source_surface_state(ctx, 6, obj_surface, encoder_context);
 
     if (!is_intra) {
         /* reference 0 */
         obj_surface = encode_state->reference_objects[0];
 
         if (obj_surface->bo != NULL)
-            gen8_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
+            gen9_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
 
         /* reference 1 */
         obj_surface = encode_state->reference_objects[1];
 
-        if (obj_surface && obj_surface->bo != NULL) 
-            gen8_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
+        if (obj_surface && obj_surface->bo != NULL)
+            gen9_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
     }
 
     /* VME output */
-    gen8_vme_mpeg2_output_buffer_setup(ctx, encode_state, 3, is_intra, encoder_context);
-    gen8_vme_mpeg2_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context);
+    gen9_vme_mpeg2_output_buffer_setup(ctx, encode_state, 3, is_intra, encoder_context);
+    gen9_vme_mpeg2_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context);
 
     return VA_STATUS_SUCCESS;
 }
 
 static void
-gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx, 
+gen9wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
                                            struct encode_state *encode_state,
                                            int mb_width, int mb_height,
                                            int kernel,
@@ -844,8 +845,7 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 
 	x_outer = 0;
 	y_outer = 0;
-	
-				 
+
 	for (; x_outer < (mb_width -2 ) && !loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) {
 	    x_inner = x_outer;
 	    y_inner = y_outer;
@@ -854,8 +854,8 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 		score_dep = 0;
 		if (x_inner != 0) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_AE;
-		    score_dep |= MB_SCOREBOARD_A; 
-		}
+		    score_dep |= MB_SCOREBOARD_A;
+                }
 		if (y_inner != 0) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_B;
 		    score_dep |= MB_SCOREBOARD_B;
@@ -868,8 +868,8 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 			score_dep |= MB_SCOREBOARD_C;
 		    }
 		}
-							
-            	*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
+
+		*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
 		*command_ptr++ = kernel;
 		*command_ptr++ = MPEG2_SCOREBOARD;
 		/* Indirect data */
@@ -894,16 +894,16 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
             xtemp_outer = 0;
 	x_outer = xtemp_outer;
 	y_outer = 0;
-	for (;!loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) { 
-	    y_inner = y_outer;
+	for (;!loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) {
+            y_inner = y_outer;
 	    x_inner = x_outer;
 	    for (; !loop_in_bounds(x_inner, y_inner, first_mb, num_mb, mb_width, mb_height);) {
-	    	mb_intra_ub = 0;
+		mb_intra_ub = 0;
 		score_dep = 0;
 		if (x_inner != 0) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_AE;
-		    score_dep |= MB_SCOREBOARD_A; 
-		}
+		    score_dep |= MB_SCOREBOARD_A;
+                }
 		if (y_inner != 0) {
 		    mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_B;
 		    score_dep |= MB_SCOREBOARD_B;
@@ -917,7 +917,7 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 		    }
 		}
 
-            	*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
+		*command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2));
 		*command_ptr++ = kernel;
 		*command_ptr++ = MPEG2_SCOREBOARD;
 		/* Indirect data */
@@ -938,7 +938,7 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 	    if (x_outer >= mb_width) {
 		y_outer += 1;
 		x_outer = xtemp_outer;
-	    }		
+            }
 	}
     }
 
@@ -950,7 +950,7 @@ gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_mpeg2_fill_vme_batchbuffer(VADriverContextP ctx, 
+gen9_vme_mpeg2_fill_vme_batchbuffer(VADriverContextP ctx,
                                     struct encode_state *encode_state,
                                     int mb_width, int mb_height,
                                     int kernel,
@@ -975,7 +975,7 @@ gen8_vme_mpeg2_fill_vme_batchbuffer(VADriverContextP ctx,
             unsigned int mb_intra_ub;
 
             for (i = 0; i < slice_mb_number;) {
-                int mb_count = i + slice_mb_begin;    
+                int mb_count = i + slice_mb_begin;
 
                 mb_x = mb_count % mb_width;
                 mb_y = mb_count / mb_width;
@@ -1001,7 +1001,7 @@ gen8_vme_mpeg2_fill_vme_batchbuffer(VADriverContextP ctx,
                 *command_ptr++ = 0;
                 *command_ptr++ = 0;
                 *command_ptr++ = 0;
-   
+
                 /*inline data */
                 *command_ptr++ = (mb_width << 16 | mb_y << 8 | mb_x);
                 *command_ptr++ = ( (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8));
@@ -1022,7 +1022,7 @@ gen8_vme_mpeg2_fill_vme_batchbuffer(VADriverContextP ctx,
 }
 
 static void
-gen8_vme_mpeg2_pipeline_programing(VADriverContextP ctx, 
+gen9_vme_mpeg2_pipeline_programing(VADriverContextP ctx,
                                    struct encode_state *encode_state,
                                    int is_intra,
                                    struct intel_encoder_context *encoder_context)
@@ -1057,14 +1057,14 @@ gen8_vme_mpeg2_pipeline_programing(VADriverContextP ctx,
 	kernel_shader = VME_INTER_SHADER;
     }
 
-    if (allow_hwscore) 
-	gen8wa_vme_mpeg2_walker_fill_vme_batchbuffer(ctx,
+    if (allow_hwscore)
+        gen9wa_vme_mpeg2_walker_fill_vme_batchbuffer(ctx,
                                                    encode_state,
                                                    width_in_mbs, height_in_mbs,
                                                    kernel_shader,
                                                    encoder_context);
     else
-	gen8_vme_mpeg2_fill_vme_batchbuffer(ctx, 
+	gen9_vme_mpeg2_fill_vme_batchbuffer(ctx,
                                             encode_state,
                                             width_in_mbs, height_in_mbs,
                                             is_intra ? VME_INTRA_SHADER : VME_INTER_SHADER,
@@ -1072,22 +1072,24 @@ gen8_vme_mpeg2_pipeline_programing(VADriverContextP ctx,
                                             encoder_context);
 
     intel_batchbuffer_start_atomic(batch, 0x1000);
-    gen8_gpe_pipeline_setup(ctx, &vme_context->gpe_context, batch);
+    gen9_gpe_pipeline_setup(ctx, &vme_context->gpe_context, batch);
     BEGIN_BATCH(batch, 4);
     OUT_BATCH(batch, MI_BATCH_BUFFER_START | (1 << 8) | (1 << 0));
     OUT_RELOC(batch,
               vme_context->vme_batchbuffer.bo,
-              I915_GEM_DOMAIN_COMMAND, 0, 
+              I915_GEM_DOMAIN_COMMAND, 0,
               0);
     OUT_BATCH(batch, 0);
     OUT_BATCH(batch, 0);
     ADVANCE_BATCH(batch);
 
-    intel_batchbuffer_end_atomic(batch);	
+    gen9_gpe_pipeline_end(ctx, &vme_context->gpe_context, batch);
+
+    intel_batchbuffer_end_atomic(batch);
 }
 
-static VAStatus 
-gen8_vme_mpeg2_prepare(VADriverContextP ctx, 
+static VAStatus
+gen9_vme_mpeg2_prepare(VADriverContextP ctx,
                        struct encode_state *encode_state,
                        struct intel_encoder_context *encoder_context)
 {
@@ -1101,36 +1103,35 @@ gen8_vme_mpeg2_prepare(VADriverContextP ctx,
 	vme_context->mpeg2_level = seq_param->sequence_extension.bits.profile_and_level_indication & MPEG2_LEVEL_MASK;
     }
 
-	
     /*Setup all the memory object*/
-    gen8_vme_mpeg2_surface_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
-    gen8_vme_interface_setup(ctx, encode_state, encoder_context);
-    //gen8_vme_vme_state_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
+    gen9_vme_mpeg2_surface_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
+    gen9_vme_interface_setup(ctx, encode_state, encoder_context);
+    //gen9_vme_vme_state_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
     intel_vme_mpeg2_state_setup(ctx, encode_state, encoder_context);
-    gen8_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen9_vme_constant_setup(ctx, encode_state, encoder_context);
 
     /*Programing media pipeline*/
-    gen8_vme_mpeg2_pipeline_programing(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
+    gen9_vme_mpeg2_pipeline_programing(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
 
     return vaStatus;
 }
 
 static VAStatus
-gen8_vme_mpeg2_pipeline(VADriverContextP ctx,
+gen9_vme_mpeg2_pipeline(VADriverContextP ctx,
                         VAProfile profile,
                         struct encode_state *encode_state,
                         struct intel_encoder_context *encoder_context)
 {
-    gen8_vme_media_init(ctx, encoder_context);
-    gen8_vme_mpeg2_prepare(ctx, encode_state, encoder_context);
-    gen8_vme_run(ctx, encode_state, encoder_context);
-    gen8_vme_stop(ctx, encode_state, encoder_context);
+    gen9_vme_media_init(ctx, encoder_context);
+    gen9_vme_mpeg2_prepare(ctx, encode_state, encoder_context);
+    gen9_vme_run(ctx, encode_state, encoder_context);
+    gen9_vme_stop(ctx, encode_state, encoder_context);
 
     return VA_STATUS_SUCCESS;
 }
 
 static void
-gen8_vme_context_destroy(void *context)
+gen9_vme_context_destroy(void *context)
 {
     struct gen6_vme_context *vme_context = context;
 
@@ -1153,7 +1154,7 @@ gen8_vme_context_destroy(void *context)
     free(vme_context);
 }
 
-Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
 {
     struct gen6_vme_context *vme_context = calloc(1, sizeof(struct gen6_vme_context));
     struct i965_kernel *vme_kernel_list = NULL;
@@ -1162,15 +1163,15 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
     switch (encoder_context->codec) {
     case CODEC_H264:
     case CODEC_H264_MVC:
-        vme_kernel_list = gen8_vme_kernels;
-        encoder_context->vme_pipeline = gen8_vme_pipeline;
-       	i965_kernel_num = sizeof(gen8_vme_kernels) / sizeof(struct i965_kernel); 
+        vme_kernel_list = gen9_vme_kernels;
+        encoder_context->vme_pipeline = gen9_vme_pipeline;
+        i965_kernel_num = sizeof(gen9_vme_kernels) / sizeof(struct i965_kernel);
         break;
 
     case CODEC_MPEG2:
-        vme_kernel_list = gen8_vme_mpeg2_kernels;
-        encoder_context->vme_pipeline = gen8_vme_mpeg2_pipeline;
-       	i965_kernel_num = sizeof(gen8_vme_mpeg2_kernels) / sizeof(struct i965_kernel); 
+        vme_kernel_list = gen9_vme_mpeg2_kernels;
+        encoder_context->vme_pipeline = gen9_vme_mpeg2_pipeline;
+        i965_kernel_num = sizeof(gen9_vme_mpeg2_kernels) / sizeof(struct i965_kernel);
 
         break;
 
@@ -1206,7 +1207,7 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
     vme_context->vme_media_chroma_surface_setup = gen8_gpe_media_chroma_surface_setup;
 
     encoder_context->vme_context = vme_context;
-    encoder_context->vme_context_destroy = gen8_vme_context_destroy;
+    encoder_context->vme_context_destroy = gen9_vme_context_destroy;
 
     vme_context->vme_state_message = malloc(VME_MSG_LENGTH * sizeof(int));
 
diff --git a/src/i965_avc_bsd.c b/src/i965_avc_bsd.c
index ebeb2a6..e6e86b0 100644
--- a/src/i965_avc_bsd.c
+++ b/src/i965_avc_bsd.c
@@ -51,7 +51,7 @@ i965_avc_bsd_init_avc_bsd_surface(VADriverContextP ctx,
 
     if (!avc_bsd_surface) {
         avc_bsd_surface = calloc(sizeof(GenAvcSurface), 1);
-        avc_bsd_surface->frame_store_id = -1;
+        avc_bsd_surface->base.frame_store_id = -1;
         assert((obj_surface->size & 0x3f) == 0);
         obj_surface->private_data = avc_bsd_surface;
     }
diff --git a/src/i965_decoder.h b/src/i965_decoder.h
index 14d4d0c..9ef0349 100644
--- a/src/i965_decoder.h
+++ b/src/i965_decoder.h
@@ -30,9 +30,27 @@
 
 #include <va/va.h>
 #include <va/va_dec_vp8.h>
+#include <va/va_dec_hevc.h>
 #include <intel_bufmgr.h>
 
 #define MAX_GEN_REFERENCE_FRAMES 16
+#define MAX_GEN_HCP_REFERENCE_FRAMES    8
+
+#define ALLOC_GEN_BUFFER(gen_buffer, string, size) do {         \
+        dri_bo_unreference(gen_buffer->bo);                     \
+        gen_buffer->bo = dri_bo_alloc(i965->intel.bufmgr,       \
+                                      string,                   \
+                                      size,                     \
+                                      0x1000);                  \
+        assert(gen_buffer->bo);                                 \
+        gen_buffer->valid = 1;                                  \
+    } while (0);
+
+#define FREE_GEN_BUFFER(gen_buffer) do {        \
+        dri_bo_unreference(gen_buffer->bo);     \
+        gen_buffer->bo = NULL;                  \
+        gen_buffer->valid = 0;                  \
+    } while (0)
 
 typedef struct gen_frame_store GenFrameStore;
 struct gen_frame_store {
diff --git a/src/i965_decoder_utils.c b/src/i965_decoder_utils.c
index 8b546db..89f34b2 100644
--- a/src/i965_decoder_utils.c
+++ b/src/i965_decoder_utils.c
@@ -572,22 +572,22 @@ compare_avc_ref_store_func(const void *p1, const void *p2)
     return fs1->ref_age - fs2->ref_age;
 }
 
-void
-intel_update_avc_frame_store_index(
+static void
+intel_update_codec_frame_store_index(
     VADriverContextP              ctx,
     struct decode_state          *decode_state,
-    VAPictureParameterBufferH264 *pic_param,
-    GenFrameStore                 frame_store[MAX_GEN_REFERENCE_FRAMES],
+    int poc,
+    GenFrameStore                 frame_store[],
+    int num_elements,
     GenFrameStoreContext         *fs_ctx
 )
 {
-    GenFrameStore *free_refs[MAX_GEN_REFERENCE_FRAMES];
+    GenFrameStore **free_refs = calloc(num_elements, sizeof(GenFrameStore *));
     uint32_t used_refs = 0, add_refs = 0;
     uint64_t age;
     int i, n, num_free_refs;
 
     /* Detect changes of access unit */
-    const int poc = avc_get_picture_poc(&pic_param->CurrPic);
     if (fs_ctx->age == 0 || fs_ctx->prev_poc != poc)
         fs_ctx->age++;
     fs_ctx->prev_poc = poc;
@@ -600,12 +600,12 @@ intel_update_avc_frame_store_index(
         if (!obj_surface)
             continue;
 
-        GenAvcSurface * const avc_surface = obj_surface->private_data;
-        if (!avc_surface)
+        GenCodecSurface * const codec_surface = obj_surface->private_data;
+        if (!codec_surface)
             continue;
-        if (avc_surface->frame_store_id >= 0) {
+        if (codec_surface->frame_store_id >= 0) {
             GenFrameStore * const fs =
-                &frame_store[avc_surface->frame_store_id];
+                &frame_store[codec_surface->frame_store_id];
             if (fs->surface_id == obj_surface->base.id) {
                 fs->obj_surface = obj_surface;
                 fs->ref_age = age;
@@ -618,7 +618,7 @@ intel_update_avc_frame_store_index(
 
     /* Build and sort out the list of retired candidates. The resulting
        list is ordered by increasing age when they were last used */
-    for (i = 0, n = 0; i < MAX_GEN_REFERENCE_FRAMES; i++) {
+    for (i = 0, n = 0; i < num_elements; i++) {
         if (!(used_refs & (1 << i))) {
             GenFrameStore * const fs = &frame_store[i];
             fs->obj_surface = NULL;
@@ -635,8 +635,8 @@ intel_update_avc_frame_store_index(
         if (!obj_surface || !(add_refs & (1 << i)))
             continue;
 
-        GenAvcSurface * const avc_surface = obj_surface->private_data;
-        if (!avc_surface)
+        GenCodecSurface * const codec_surface = obj_surface->private_data;
+        if (!codec_surface)
             continue;
         if (n < num_free_refs) {
             GenFrameStore * const fs = free_refs[n++];
@@ -644,11 +644,47 @@ intel_update_avc_frame_store_index(
             fs->obj_surface = obj_surface;
             fs->frame_store_id = fs - frame_store;
             fs->ref_age = age;
-            avc_surface->frame_store_id = fs->frame_store_id;
+            codec_surface->frame_store_id = fs->frame_store_id;
             continue;
         }
         WARN_ONCE("No free slot found for DPB reference list!!!\n");
     }
+
+    free(free_refs);
+}
+
+void
+intel_update_avc_frame_store_index(
+    VADriverContextP              ctx,
+    struct decode_state          *decode_state,
+    VAPictureParameterBufferH264 *pic_param,
+    GenFrameStore                 frame_store[MAX_GEN_REFERENCE_FRAMES],
+    GenFrameStoreContext         *fs_ctx
+)
+{
+    intel_update_codec_frame_store_index(ctx,
+                                         decode_state,
+                                         avc_get_picture_poc(&pic_param->CurrPic),
+                                         frame_store,
+                                         MAX_GEN_REFERENCE_FRAMES,
+                                         fs_ctx);
+}
+
+void
+intel_update_hevc_frame_store_index(
+    VADriverContextP              ctx,
+    struct decode_state          *decode_state,
+    VAPictureParameterBufferHEVC *pic_param,
+    GenFrameStore                 frame_store[MAX_GEN_HCP_REFERENCE_FRAMES],
+    GenFrameStoreContext         *fs_ctx
+    )
+{
+    intel_update_codec_frame_store_index(ctx,
+                                         decode_state,
+                                         pic_param->CurrPic.pic_order_cnt,
+                                         frame_store,
+                                         MAX_GEN_HCP_REFERENCE_FRAMES,
+                                         fs_ctx);
 }
 
 void
@@ -1056,6 +1092,89 @@ intel_decoder_check_vp8_parameter(VADriverContextP ctx,
 }
 
 VAStatus
+hevc_ensure_surface_bo(
+    VADriverContextP                    ctx,
+    struct decode_state                *decode_state,
+    struct object_surface              *obj_surface,
+    const VAPictureParameterBufferHEVC *pic_param
+)
+{
+    VAStatus va_status = VA_STATUS_SUCCESS;
+
+    /* (Re-)allocate the underlying surface buffer store, if necessary */
+    if (!obj_surface->bo || obj_surface->fourcc != VA_FOURCC_NV12) {
+        struct i965_driver_data * const i965 = i965_driver_data(ctx);
+
+        i965_destroy_surface_storage(obj_surface);
+
+        va_status = i965_check_alloc_surface_bo(ctx,
+                                                obj_surface,
+                                                i965->codec_info->has_tiled_surface,
+                                                VA_FOURCC_NV12,
+                                                SUBSAMPLE_YUV420);
+    }
+
+    return va_status;
+}
+
+static VAStatus
+intel_decoder_check_hevc_parameter(VADriverContextP ctx,
+                                   struct decode_state *decode_state)
+{
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)decode_state->pic_param->buffer;
+    VAStatus va_status = VA_STATUS_ERROR_INVALID_PARAMETER;
+    struct object_surface *obj_surface;
+    int i;
+    int min_cb_size;
+
+    if (pic_param->CurrPic.flags & VA_PICTURE_HEVC_INVALID ||
+        pic_param->CurrPic.picture_id == VA_INVALID_SURFACE)
+        goto error;
+
+    if (pic_param->CurrPic.picture_id != decode_state->current_render_target)
+        goto error;
+
+    min_cb_size = (1 << (pic_param->log2_min_luma_coding_block_size_minus3 + 3));
+
+    if (pic_param->pic_width_in_luma_samples % min_cb_size ||
+        pic_param->pic_height_in_luma_samples % min_cb_size)
+        goto error;
+
+    /* Fill in the reference objects array with the actual VA surface
+       objects with 1:1 correspondance with any entry in ReferenceFrames[],
+       i.e. including "holes" for invalid entries, that are expanded
+       to NULL in the reference_objects[] array */
+    for (i = 0; i < ARRAY_ELEMS(pic_param->ReferenceFrames); i++) {
+        const VAPictureHEVC * const va_pic = &pic_param->ReferenceFrames[i];
+
+        obj_surface = NULL;
+        if (!(va_pic->flags & VA_PICTURE_HEVC_INVALID) &&
+            va_pic->picture_id != VA_INVALID_ID) {
+            obj_surface = SURFACE(pic_param->ReferenceFrames[i].picture_id);
+
+            if (!obj_surface) {
+                va_status = VA_STATUS_ERROR_INVALID_SURFACE;
+                goto error;
+            }
+
+            va_status = hevc_ensure_surface_bo(ctx, decode_state, obj_surface,
+                                               pic_param);
+
+            if (va_status != VA_STATUS_SUCCESS)
+                goto error;
+        }
+
+        decode_state->reference_objects[i] = obj_surface;
+    }
+
+    va_status = VA_STATUS_SUCCESS;
+
+error:
+    return va_status;
+}
+
+VAStatus
 intel_decoder_sanity_check_input(VADriverContextP ctx,
                                  VAProfile profile,
                                  struct decode_state *decode_state)
@@ -1102,6 +1221,11 @@ intel_decoder_sanity_check_input(VADriverContextP ctx,
         vaStatus = intel_decoder_check_vp8_parameter(ctx, decode_state);
         break;
 
+    case VAProfileHEVCMain:
+    case VAProfileHEVCMain10:
+        vaStatus = intel_decoder_check_hevc_parameter(ctx, decode_state);
+        break;
+
     default:
         vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
         break;
@@ -1175,3 +1299,25 @@ intel_ensure_vp8_segmentation_buffer(VADriverContextP ctx, GenBuffer *buf,
     buf->valid = buf->bo != NULL;
     return buf->valid;
 }
+
+void
+hevc_gen_default_iq_matrix(VAIQMatrixBufferHEVC *iq_matrix)
+{
+    /* Flat_4x4_16 */
+    memset(&iq_matrix->ScalingList4x4, 16, sizeof(iq_matrix->ScalingList4x4));
+
+    /* Flat_8x8_16 */
+    memset(&iq_matrix->ScalingList8x8, 16, sizeof(iq_matrix->ScalingList8x8));
+
+    /* Flat_16x16_16 */
+    memset(&iq_matrix->ScalingList16x16, 16, sizeof(iq_matrix->ScalingList16x16));
+
+    /* Flat_32x32_16 */
+    memset(&iq_matrix->ScalingList32x32, 16, sizeof(iq_matrix->ScalingList32x32));
+
+    /* Flat_16x16_dc_16 */
+    memset(&iq_matrix->ScalingListDC16x16, 16, sizeof(iq_matrix->ScalingListDC16x16));
+
+    /* Flat_32x32_dc_16 */
+    memset(&iq_matrix->ScalingListDC32x32, 16, sizeof(iq_matrix->ScalingListDC32x32));
+}
diff --git a/src/i965_decoder_utils.h b/src/i965_decoder_utils.h
index 3e6acdd..3618034 100644
--- a/src/i965_decoder_utils.h
+++ b/src/i965_decoder_utils.h
@@ -111,6 +111,15 @@ intel_update_avc_frame_store_index(
 );
 
 void
+intel_update_hevc_frame_store_index(
+    VADriverContextP              ctx,
+    struct decode_state          *decode_state,
+    VAPictureParameterBufferHEVC *pic_param,
+    GenFrameStore                 frame_store[MAX_GEN_HCP_REFERENCE_FRAMES],
+    GenFrameStoreContext         *fs_ctx
+);
+
+void
 gen75_update_avc_frame_store_index(
     VADriverContextP                    ctx,
     struct decode_state                *decode_state,
@@ -154,4 +163,15 @@ bool
 intel_ensure_vp8_segmentation_buffer(VADriverContextP ctx, GenBuffer *buf,
     unsigned int mb_width, unsigned int mb_height);
 
+void
+hevc_gen_default_iq_matrix(VAIQMatrixBufferHEVC *iq_matrix);
+
+VAStatus
+hevc_ensure_surface_bo(
+    VADriverContextP                    ctx,
+    struct decode_state                *decode_state,
+    struct object_surface              *obj_surface,
+    const VAPictureParameterBufferHEVC *pic_param
+);
+
 #endif /* I965_DECODER_UTILS_H */
diff --git a/src/i965_defines.h b/src/i965_defines.h
index f010ca2..7c87274 100755
--- a/src/i965_defines.h
+++ b/src/i965_defines.h
@@ -327,6 +327,9 @@
 #define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_HS          CMD(3, 0, 0x2c)
 #define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_DS          CMD(3, 0, 0x2d)
 
+#define GEN7_3DSTATE_VF                                 CMD(3, 0, 0x0c)
+#define GEN8_3DSTATE_VF_INSTANCING                      CMD(3, 0, 0x49)
+
 #define MFX(pipeline, op, sub_opa, sub_opb)     \
     (3 << 29 |                                  \
      (pipeline) << 27 |                         \
@@ -379,9 +382,14 @@
 
 #define MFD_VC1_BSD_OBJECT                      MFX(2, 2, 1, 8)
 
+//MFX_JPEG #defines for JPEG decoder only
 #define MFX_JPEG_PIC_STATE                      MFX(2, 7, 0, 0)
 #define MFX_JPEG_HUFF_TABLE_STATE               MFX(2, 7, 0, 2)
 
+//MFC_JPEG #defines for JPEG encoder only
+#define MFC_JPEG_SCAN_OBJECT                    MFX(2, 7, 2, 9)
+#define MFC_JPEG_HUFF_TABLE_STATE               MFX(2, 7, 2, 3)
+
 #define MFD_JPEG_BSD_OBJECT                     MFX(2, 7, 1, 8)
 
 #define MFX_VP8_PIC_STATE                       MFX(2, 4, 0, 0)
@@ -400,6 +408,27 @@
 #define VEB_STATE                               VEB(2, 4, 0, 2)
 #define VEB_DNDI_IECP_STATE                     VEB(2, 4, 0, 3)
 
+#define HCP(command)                            \
+    (3 << 29 |                                  \
+     2 << 27 |                                  \
+     7 << 23 |                                  \
+     (command << 16))
+
+#define HCP_PIPE_MODE_SELECT                    HCP(0x00)
+#define HCP_SURFACE_STATE                       HCP(0x01)
+#define HCP_PIPE_BUF_ADDR_STATE                 HCP(0x02)
+#define HCP_IND_OBJ_BASE_ADDR_STATE             HCP(0x03)
+#define HCP_QM_STATE                            HCP(0x04)
+#define HCP_FQM_STATE                           HCP(0x05)
+#define HCP_PIC_STATE                           HCP(0x10)
+#define HCP_TILE_STATE                          HCP(0x11)
+#define HCP_REF_IDX_STATE                       HCP(0x12)
+#define HCP_WEIGHTOFFSET                        HCP(0x13)
+#define HCP_SLICE_STATE                         HCP(0x14)
+#define HCP_BSD_OBJECT                          HCP(0x20)
+#define HCP_PAK_OBJECT                          HCP(0x21)
+#define HCP_INSERT_PAK_OBJECT                   HCP(0x22)
+
 #define I965_DEPTHFORMAT_D32_FLOAT              1
 
 #define BASE_ADDRESS_MODIFY             (1 << 0)
@@ -800,9 +829,12 @@
 #define MFD_MODE_VLD            0
 #define MFD_MODE_IT             1
 
+#define MFX_SURFACE_YCRCB_NORMAL        0
+#define MFX_SURFACE_YCRCB_SWAPY         3
 #define MFX_SURFACE_PLANAR_420_8        4
 #define MFX_SURFACE_PLANAR_411_8        5
 #define MFX_SURFACE_PLANAR_422_8        6
+#define MFX_SURFACE_R8G8B8A8_UNORM      9
 #define MFX_SURFACE_MONOCHROME          12
 
 #define MPEG_I_PICTURE          1
@@ -820,5 +852,49 @@
 #define SUBSAMPLE_YUV444        4
 #define SUBSAMPLE_YUV411        5
 #define SUBSAMPLE_RGBX          6
+#define JPEG_ENC_SURFACE_NV12 1
+#define JPEG_ENC_SURFACE_UYVY 2
+#define JPEG_ENC_SURFACE_YUY2 3
+#define JPEG_ENC_SURFACE_Y8   4
+#define JPEG_ENC_SURFACE_RGB  5
+
+#define JPEG_ENC_MCU_YUV400     0
+#define JPEG_ENC_MCU_YUV420     1
+#define JPEG_ENC_MCU_YUV422H_2Y 2
+#define JPEG_ENC_MCU_RGB        3
+
+#define JPEG_ENC_ROUND_QUANT_DEFAULT 0
+#define JPEG_ENC_ROUND_QUANT_MINUS_128TH 1
+#define JPEG_ENC_ROUND_QUANT_PLUS_128TH 2
+#define JPEG_ENC_ROUND_QUANT_MINUS_64TH 3
+#define JPEG_ENC_ROUND_QUANT_PLUS_64TH 4
+#define JPEG_ENC_ROUND_QUANT_MINUS_32TH 5
+#define JPEG_ENC_ROUND_QUANT_MINUS_16TH 6
+#define JPEG_ENC_ROUND_QUANT_MINUS_8TH 7
+
+
+
+#define GEN9_PIPELINE_SELECTION_MASK        (0x3 << 8)
+#define GEN9_FORCE_MEDIA_AWAKE_MASK         (1 << 13)
+#define GEN9_FORCE_MEDIA_AWAKE_ON           (1 << 5)
+#define GEN9_FORCE_MEDIA_AWAKE_OFF          (0 << 5)
+
+#define GEN9_MEDIA_DOP_GATE_MASK            (1 << 12)
+#define GEN9_MEDIA_DOP_GATE_ON              (1 << 4)
+#define GEN9_MEDIA_DOP_GATE_OFF             (0 << 4)
+
+#define GEN9_SBE_ACTIVE_COMPONENT_NONE          0
+#define GEN9_SBE_ACTIVE_COMPONENT_XY            1
+#define GEN9_SBE_ACTIVE_COMPONENT_XYZ           2
+#define GEN9_SBE_ACTIVE_COMPONENT_XYZW          3
+
+#define HEVC_SLICE_B                            0
+#define HEVC_SLICE_P                            1
+#define HEVC_SLICE_I                            2
+
+#define HCP_CODEC_HEVC                          0
+
+#define HCP_CODEC_SELECT_DECODE                 0
+#define HCP_CODEC_SELECT_ENCODE                 1
 
 #endif /* _I965_DEFINES_H_ */
diff --git a/src/i965_device_info.c b/src/i965_device_info.c
index 2d3ced4..50bb78d 100644
--- a/src/i965_device_info.c
+++ b/src/i965_device_info.c
@@ -41,6 +41,10 @@
     (VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_YUV422 | \
      VA_RT_FORMAT_YUV444)
 
+/* Extra set of chroma formats supported for JPEG encoding (beyond YUV 4:2:0) */
+#define EXTRA_JPEG_ENC_CHROMA_FORMATS \
+    (VA_RT_FORMAT_YUV400| VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_RGB32)
+     
 /* Defines VA profile as a 32-bit unsigned integer mask */
 #define VA_PROFILE_MASK(PROFILE) \
     (1U << VAProfile##PROFILE)
@@ -89,6 +93,8 @@ static struct hw_codec_info ilk_hw_codec_info = {
     .num_filters = 0,
 };
 
+static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
+
 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
 extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *);
 static struct hw_codec_info snb_hw_codec_info = {
@@ -97,6 +103,7 @@ static struct hw_codec_info snb_hw_codec_info = {
     .proc_hw_context_init = i965_proc_context_init,
     .render_init = genx_render_init,
     .post_processing_context_init = i965_post_processing_context_init,
+    .preinit_hw_codec = gen6_hw_codec_preinit,
 
     .max_width = 2048,
     .max_height = 2048,
@@ -123,6 +130,8 @@ static struct hw_codec_info snb_hw_codec_info = {
     },
 };
 
+static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
+
 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
 static struct hw_codec_info ivb_hw_codec_info = {
@@ -131,6 +140,7 @@ static struct hw_codec_info ivb_hw_codec_info = {
     .proc_hw_context_init = i965_proc_context_init,
     .render_init = genx_render_init,
     .post_processing_context_init = i965_post_processing_context_init,
+    .preinit_hw_codec = gen7_hw_codec_preinit,
 
     .max_width = 4096,
     .max_height = 4096,
@@ -268,6 +278,54 @@ static struct hw_codec_info chv_hw_codec_info = {
                               VA_PROFILE_MASK(H264MultiviewHigh)),
     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
+    .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
+
+    .has_mpeg2_decoding = 1,
+    .has_mpeg2_encoding = 1,
+    .has_h264_decoding = 1,
+    .has_h264_encoding = 1,
+    .has_vc1_decoding = 1,
+    .has_jpeg_decoding = 1,
+    .has_jpeg_encoding = 1,
+    .has_vpp = 1,
+    .has_accelerated_getimage = 1,
+    .has_accelerated_putimage = 1,
+    .has_tiled_surface = 1,
+    .has_di_motion_adptive = 1,
+    .has_di_motion_compensated = 1,
+    .has_vp8_decoding = 1,
+    .has_h264_mvc_encoding = 1,
+
+    .num_filters = 5,
+    .filters = {
+        { VAProcFilterNoiseReduction, I965_RING_VEBOX },
+        { VAProcFilterDeinterlacing, I965_RING_VEBOX },
+        { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
+        { VAProcFilterColorBalance, I965_RING_VEBOX},
+        { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
+    },
+};
+
+extern struct hw_context *gen9_dec_hw_context_init(VADriverContextP, struct object_config *);
+extern struct hw_context *gen9_enc_hw_context_init(VADriverContextP, struct object_config *);
+extern void gen9_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
+static struct hw_codec_info skl_hw_codec_info = {
+    .dec_hw_context_init = gen9_dec_hw_context_init,
+    .enc_hw_context_init = gen9_enc_hw_context_init,
+    .proc_hw_context_init = gen75_proc_context_init,
+    .render_init = gen9_render_init,
+    .post_processing_context_init = gen9_post_processing_context_init,
+
+    .max_width = 4096,
+    .max_height = 4096,
+    .min_linear_wpitch = 64,
+    .min_linear_hpitch = 16,
+
+    .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
+                              VA_PROFILE_MASK(H264MultiviewHigh)),
+    .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
+    .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
+    .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
 
     .has_mpeg2_decoding = 1,
     .has_mpeg2_encoding = 1,
@@ -275,6 +333,7 @@ static struct hw_codec_info chv_hw_codec_info = {
     .has_h264_encoding = 1,
     .has_vc1_decoding = 1,
     .has_jpeg_decoding = 1,
+    .has_jpeg_encoding = 1,
     .has_vpp = 1,
     .has_accelerated_getimage = 1,
     .has_accelerated_putimage = 1,
@@ -283,6 +342,7 @@ static struct hw_codec_info chv_hw_codec_info = {
     .has_di_motion_compensated = 1,
     .has_vp8_decoding = 1,
     .has_h264_mvc_encoding = 1,
+    .has_hevc_decoding = 1,
 
     .num_filters = 5,
     .filters = {
@@ -415,6 +475,13 @@ static const struct intel_device_info chv_device_info = {
     .is_cherryview = 1,
 };
 
+static const struct intel_device_info skl_device_info = {
+    .gen = 9,
+
+    .urb_size = 4096,
+    .max_wm_threads = 64,       /* per PSD */
+};
+
 const struct intel_device_info *
 i965_get_device_info(int devid)
 {
@@ -438,7 +505,6 @@ static void cpuid(unsigned int op,
  * This function doesn't check the length. And the caller should
  * assure that the length of input string should be greater than 48.
  */
-
 static int intel_driver_detect_cpustring(char *model_id)
 {
     uint32_t *rdata;
@@ -493,18 +559,18 @@ static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *cod
     /* strip the cpufreq info */
     model_ptr = model_string;
     tmp_ptr = strstr(model_ptr, "@");
-
+   
     if (tmp_ptr)
         *tmp_ptr = '\0';
 
-    /* strip the space character */
+    /* strip the space character and convert to the lower case */
     model_ptr = model_string;
     model_len = strlen(model_string);
     for (i = 0; i < model_len; i++) {
-        if (model_string[i] != ' ') {
-            *model_ptr = model_string[i];
-            model_ptr++;
-        }
+         if (model_string[i] != ' ') {
+             *model_ptr = model_string[i];
+             model_ptr++;
+         }
     }
     *model_ptr = '\0';
 
@@ -528,4 +594,127 @@ static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *cod
 	codec_info->has_h264_mvc_encoding = 0;
 	codec_info->has_mpeg2_encoding = 0;
     }
+    return;
+}
+
+/*
+ * the hook_list for Sandybride.
+ * It is captured by /proc/cpuinfo and the space character is stripped.
+ */
+const static char *gen6_cpu_hook_list[] =  {
+"Intel(R)Celeron(R)CPU847",
+"Intel(R)Celeron(R)CPU867",
+};
+
+static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
+{
+    char model_string[64];
+    char *model_ptr, *tmp_ptr;
+    int i, model_len, list_len;
+    bool found;
+
+    memset(model_string, 0, sizeof(model_string));
+
+    /* If it can't detect cpu model_string, leave it alone */
+    if (intel_driver_detect_cpustring(model_string))
+        return;
+
+    /* strip the cpufreq info */
+    model_ptr = model_string;
+    tmp_ptr = strstr(model_ptr, "@");
+
+    if (tmp_ptr)
+        *tmp_ptr = '\0';
+
+    /* strip the space character and convert to the lower case */
+    model_ptr = model_string;
+    model_len = strlen(model_string);
+    for (i = 0; i < model_len; i++) {
+         if (model_string[i] != ' ') {
+             *model_ptr = model_string[i];
+             model_ptr++;
+         }
+    }
+    *model_ptr = '\0';
+
+    found = false;
+    list_len = sizeof(gen6_cpu_hook_list) / sizeof(char *);
+    model_len = strlen(model_string);
+    for (i = 0; i < list_len; i++) {
+        model_ptr = (char *)gen6_cpu_hook_list[i];
+
+        if (strlen(model_ptr) != model_len)
+            continue;
+
+        if (strncasecmp(model_string, model_ptr, model_len) == 0) {
+            found = true;
+            break;
+        }
+    }
+
+    if (found) {
+        codec_info->has_h264_encoding = 0;
+    }
+    return;
+}
+
+/*
+ * the hook_list for Ivybridge.
+ * It is captured by /proc/cpuinfo and the space character is stripped.
+ */
+const static char *gen7_cpu_hook_list[] =  {
+"Intel(R)Celeron(R)CPU1007U",
+};
+
+static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
+{
+    char model_string[64];
+    char *model_ptr, *tmp_ptr;
+    int i, model_len, list_len;
+    bool found;
+
+    memset(model_string, 0, sizeof(model_string));
+
+    /* If it can't detect cpu model_string, leave it alone */
+    if (intel_driver_detect_cpustring(model_string))
+        return;
+
+    /* strip the cpufreq info */
+    model_ptr = model_string;
+    tmp_ptr = strstr(model_ptr, "@");
+
+    if (tmp_ptr)
+        *tmp_ptr = '\0';
+
+    /* strip the space character and convert to the lower case */
+    model_ptr = model_string;
+    model_len = strlen(model_string);
+    for (i = 0; i < model_len; i++) {
+         if (model_string[i] != ' ') {
+             *model_ptr = model_string[i];
+             model_ptr++;
+         }
+    }
+    *model_ptr = '\0';
+
+    found = false;
+    list_len = sizeof(gen7_cpu_hook_list) / sizeof(char *);
+    model_len = strlen(model_string);
+    for (i = 0; i < list_len; i++) {
+        model_ptr = (char *)gen7_cpu_hook_list[i];
+
+        if (strlen(model_ptr) != model_len)
+            continue;
+
+        if (strncasecmp(model_string, model_ptr, model_len) == 0) {
+            found = true;
+            break;
+	}
+    }
+
+    if (found) {
+        codec_info->has_h264_encoding = 0;
+        codec_info->has_mpeg2_encoding = 0;
+    }
+    return;
 }
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index ba7c7be..c5f52dc 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -38,6 +38,7 @@
 # include "i965_output_wayland.h"
 #endif
 
+#include "intel_version.h"
 #include "intel_driver.h"
 #include "intel_memman.h"
 #include "intel_batchbuffer.h"
@@ -70,6 +71,9 @@
 
 #define HAS_JPEG_DECODING(ctx)  ((ctx)->codec_info->has_jpeg_decoding && \
                                  (ctx)->intel.has_bsd)
+                                                                  
+#define HAS_JPEG_ENCODING(ctx)  ((ctx)->codec_info->has_jpeg_encoding && \
+                                 (ctx)->intel.has_bsd)      
 
 #define HAS_VPP(ctx)    ((ctx)->codec_info->has_vpp)
 
@@ -95,6 +99,9 @@
 #define HAS_H264_MVC_ENCODING(ctx)  ((ctx)->codec_info->has_h264_mvc_encoding && \
                                      (ctx)->intel.has_bsd)
 
+#define HAS_HEVC_DECODING(ctx)          ((ctx)->codec_info->has_hevc_decoding && \
+                                         (ctx)->intel.has_bsd)
+
 static int get_sampling_from_fourcc(unsigned int fourcc);
 
 /* Check whether we are rendering to X11 (VA/X11 or VA/GLX API) */
@@ -335,6 +342,37 @@ get_subpic_format(const VAImageFormat *va_format)
     return NULL;
 }
 
+/* Checks whether the surface is in busy state */
+static bool
+is_surface_busy(struct i965_driver_data *i965,
+    struct object_surface *obj_surface)
+{
+    assert(obj_surface != NULL);
+
+    if (obj_surface->locked_image_id != VA_INVALID_ID)
+        return true;
+    if (obj_surface->derived_image_id != VA_INVALID_ID)
+        return true;
+    return false;
+}
+
+/* Checks whether the image is in busy state */
+static bool
+is_image_busy(struct i965_driver_data *i965, struct object_image *obj_image)
+{
+    struct object_buffer *obj_buffer;
+
+    assert(obj_image != NULL);
+
+    if (obj_image->derived_surface != VA_INVALID_ID)
+        return true;
+
+    obj_buffer = BUFFER(obj_image->image.buf);
+    if (obj_buffer && obj_buffer->export_refcount > 0)
+        return true;
+    return false;
+}
+
 #define I965_PACKED_HEADER_BASE         0
 #define I965_PACKED_MISC_HEADER_BASE    3
 
@@ -410,7 +448,8 @@ i965_QueryConfigProfiles(VADriverContextP ctx,
         profile_list[i++] = VAProfileNone;
     }
 
-    if (HAS_JPEG_DECODING(i965)) {
+    if (HAS_JPEG_DECODING(i965) ||
+        HAS_JPEG_ENCODING(i965)) {
         profile_list[i++] = VAProfileJPEGBaseline;
     }
 
@@ -424,6 +463,10 @@ i965_QueryConfigProfiles(VADriverContextP ctx,
         profile_list[i++] = VAProfileH264StereoHigh;
     }
 
+    if (HAS_HEVC_DECODING(i965)) {
+        profile_list[i++] = VAProfileHEVCMain;
+    }
+
     /* If the assert fails then I965_MAX_PROFILES needs to be bigger */
     ASSERT_RET(i <= I965_MAX_PROFILES, VA_STATUS_ERROR_OPERATION_FAILED);
     *num_profiles = i;
@@ -485,6 +528,9 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
     case VAProfileJPEGBaseline:
         if (HAS_JPEG_DECODING(i965))
             entrypoint_list[n++] = VAEntrypointVLD;
+        
+        if (HAS_JPEG_ENCODING(i965))
+            entrypoint_list[n++] = VAEntrypointEncPicture;
         break;
 
     case VAProfileVP8Version0_3:
@@ -494,6 +540,14 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
         if (HAS_VP8_ENCODING(i965))
             entrypoint_list[n++] = VAEntrypointEncSlice;
 
+        break;
+
+    case VAProfileHEVCMain:
+        if (HAS_HEVC_DECODING(i965))
+            entrypoint_list[n++] = VAEntrypointVLD;
+
+        break;
+
     default:
         break;
     }
@@ -553,7 +607,8 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile,
         break;
 
     case VAProfileJPEGBaseline:
-        if (HAS_JPEG_DECODING(i965) && entrypoint == VAEntrypointVLD) {
+        if ((HAS_JPEG_DECODING(i965) && entrypoint == VAEntrypointVLD) ||
+            (HAS_JPEG_ENCODING(i965) && entrypoint == VAEntrypointEncPicture)) {
             va_status = VA_STATUS_SUCCESS;
         } else {
             va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
@@ -581,6 +636,14 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile,
 
         break;
 
+    case VAProfileHEVCMain:
+        if (HAS_HEVC_DECODING(i965) && (entrypoint == VAEntrypointVLD))
+            va_status = VA_STATUS_SUCCESS;
+        else
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+
+        break;
+
     default:
         va_status = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
         break;
@@ -612,6 +675,9 @@ i965_get_default_chroma_formats(VADriverContextP ctx, VAProfile profile,
     case VAProfileJPEGBaseline:
         if (HAS_JPEG_DECODING(i965) && entrypoint == VAEntrypointVLD)
             chroma_formats |= i965->codec_info->jpeg_dec_chroma_formats;
+        if (HAS_JPEG_ENCODING(i965) && entrypoint == VAEntrypointEncPicture)
+            chroma_formats |= i965->codec_info->jpeg_enc_chroma_formats;
+        
         break;
 
     default:
@@ -683,6 +749,20 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                     attrib_list[i].value = ENCODER_QUALITY_RANGE;
 		break;
 	    }
+    
+    case VAConfigAttribEncJPEG: 
+        if( entrypoint == VAEntrypointEncPicture) {
+            VAConfigAttribValEncJPEG *configVal = (VAConfigAttribValEncJPEG*)&(attrib_list[i].value);
+            (configVal->bits).arithmatic_coding_mode = 0; // Huffman coding is used
+            (configVal->bits).progressive_dct_mode = 0;   // Only Sequential DCT is supported
+            (configVal->bits).non_interleaved_mode = 1;   // Support both interleaved and non-interleaved
+            (configVal->bits).differential_mode = 0;      // Baseline DCT is non-differential 
+            (configVal->bits).max_num_components = 3;     // Only 3 components supported
+            (configVal->bits).max_num_scans = 1;          // Only 1 scan per frame
+            (configVal->bits).max_num_huffman_tables = 3; // Max 3 huffman tables
+            (configVal->bits).max_num_quantization_tables = 3; // Max 3 quantization tables
+        }
+        break;
 
         default:
             /* Do nothing */
@@ -1190,6 +1270,7 @@ i965_CreateSurfaces2(
         obj_surface->fourcc = 0;
         obj_surface->bo = NULL;
         obj_surface->locked_image_id = VA_INVALID_ID;
+        obj_surface->derived_image_id = VA_INVALID_ID;
         obj_surface->private_data = NULL;
         obj_surface->free_private_data = NULL;
         obj_surface->subsampling = SUBSAMPLE_YUV420;
@@ -1347,7 +1428,8 @@ i965_guess_surface_format(VADriverContextP ctx,
 
     if (IS_GEN6(i965->intel.device_info) ||
         IS_GEN7(i965->intel.device_info) ||
-        IS_GEN8(i965->intel.device_info)) {
+        IS_GEN8(i965->intel.device_info) ||
+        IS_GEN9(i965->intel.device_info)) {
         *fourcc = VA_FOURCC_NV12;
         *is_tiled = 1;
         return;
@@ -1740,28 +1822,6 @@ i965_CreateContext(VADriverContextP ctx,
         return vaStatus;
     }
 
-    render_state->inited = 1;
-
-    switch (obj_config->profile) {
-    case VAProfileH264ConstrainedBaseline:
-    case VAProfileH264Main:
-    case VAProfileH264High:
-        if (!HAS_H264_DECODING(i965) &&
-            !HAS_H264_ENCODING(i965))
-            return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
-        render_state->interleaved_uv = 1;
-        break;
-    case VAProfileH264MultiviewHigh:
-    case VAProfileH264StereoHigh:
-        if (!HAS_H264_MVC_DECODING(i965))
-            return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
-        render_state->interleaved_uv = 1;
-        break;
-    default:
-        render_state->interleaved_uv = !!(IS_GEN6(i965->intel.device_info) || IS_GEN7(i965->intel.device_info) || IS_GEN8(i965->intel.device_info));
-        break;
-    }
-
     *context = contextID;
     obj_context->flags = flag;
     obj_context->context_id = contextID;
@@ -1789,7 +1849,8 @@ i965_CreateContext(VADriverContextP ctx,
             obj_context->codec_state.proc.current_render_target = VA_INVALID_ID;
             assert(i965->codec_info->proc_hw_context_init);
             obj_context->hw_context = i965->codec_info->proc_hw_context_init(ctx, obj_config);
-        } else if (VAEntrypointEncSlice == obj_config->entrypoint) { /*encode routin only*/
+         } else if ((VAEntrypointEncSlice == obj_config->entrypoint) || 
+                   (VAEntrypointEncPicture == obj_config->entrypoint)) { /*encode routine only*/
             VAConfigAttrib *packed_attrib;
             obj_context->codec_type = CODEC_ENC;
             memset(&obj_context->codec_state.encode, 0, sizeof(obj_context->codec_state.encode));
@@ -2060,6 +2121,9 @@ i965_MapBuffer(VADriverContextP ctx,
     ASSERT_RET(obj_buffer->buffer_store->bo || obj_buffer->buffer_store->buffer, VA_STATUS_ERROR_INVALID_BUFFER);
     ASSERT_RET(!(obj_buffer->buffer_store->bo && obj_buffer->buffer_store->buffer), VA_STATUS_ERROR_INVALID_BUFFER);
 
+    if (obj_buffer->export_refcount > 0)
+        return VA_STATUS_ERROR_INVALID_BUFFER;
+
     if (NULL != obj_buffer->buffer_store->bo) {
         unsigned int tiling, swizzle;
 
@@ -2096,24 +2160,42 @@ i965_MapBuffer(VADriverContextP ctx,
                     delimiter2 = MPEG2_DELIMITER2;
                     delimiter3 = MPEG2_DELIMITER3;
                     delimiter4 = MPEG2_DELIMITER4;
-                } else {
+                } else if(coded_buffer_segment->codec == CODEC_JPEG) {
+                    //In JPEG End of Image (EOI = 0xDDF9) marker can be used for delimiter.
+                    delimiter0 = 0xFF;
+                    delimiter1 = 0xD9;
+                }  else {
                     ASSERT_RET(0, VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
                 }
 
-                for (i = 0; i < obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000; i++) {
-                    if ((buffer[i] == delimiter0) &&
-                        (buffer[i + 1] == delimiter1) &&
-                        (buffer[i + 2] == delimiter2) &&
-                        (buffer[i + 3] == delimiter3) &&
-                        (buffer[i + 4] == delimiter4))
-                        break;
-                }
+                if(coded_buffer_segment->codec == CODEC_JPEG) {
+                    for(i = 0; i <  obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 1 - 0x1000; i++) {
+                        if( (buffer[i] == 0xFF) && (buffer[i + 1] == 0xD9)) {
+                            break;
+                        }
+                   }
 
-                if (i == obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000) {
-                    coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
+                   if (i == obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 1 - 0x1000) {
+                       coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
+                   }
+ 
+                   coded_buffer_segment->base.size = i + 2;
+                } else {
+                    for (i = 0; i < obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000; i++) {
+                        if ((buffer[i] == delimiter0) &&
+                            (buffer[i + 1] == delimiter1) &&
+                            (buffer[i + 2] == delimiter2) &&
+                            (buffer[i + 3] == delimiter3) &&
+                            (buffer[i + 4] == delimiter4))
+                            break;
+                        }
+
+                        if (i == obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000) {
+                            coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
+                        }
+                    coded_buffer_segment->base.size = i;
                 }
 
-                coded_buffer_segment->base.size = i;
                 coded_buffer_segment->mapped = 1;
             } else {
                 assert(coded_buffer_segment->base.buf);
@@ -2192,6 +2274,9 @@ i965_BeginPicture(VADriverContextP ctx,
     obj_config = obj_context->obj_config;
     ASSERT_RET(obj_config, VA_STATUS_ERROR_INVALID_CONFIG);
 
+    if (is_surface_busy(i965, obj_surface))
+        return VA_STATUS_ERROR_SURFACE_BUSY;
+
     switch (obj_config->profile) {
     case VAProfileMPEG2Simple:
     case VAProfileMPEG2Main:
@@ -2232,6 +2317,10 @@ i965_BeginPicture(VADriverContextP ctx,
         vaStatus = VA_STATUS_SUCCESS;
         break;
 
+    case VAProfileHEVCMain:
+        vaStatus = VA_STATUS_SUCCESS;
+        break;
+
     default:
         ASSERT_RET(0, VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
         break;
@@ -2406,6 +2495,7 @@ i965_decoder_render_picture(VADriverContextP ctx,
 // DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(picture_control, pic_control)
 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(qmatrix, q_matrix)
 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(iqmatrix, iq_matrix)
+DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(huffman_table, huffman_table)
 /* extended buffer */
 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(sequence_parameter_ext, seq_param_ext)
 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(picture_parameter_ext, pic_param_ext)
@@ -2509,6 +2599,10 @@ i965_encoder_render_picture(VADriverContextP ctx,
             vaStatus = I965_RENDER_ENCODE_BUFFER(picture_parameter_ext);
             break;
 
+        case VAHuffmanTableBufferType:
+            vaStatus = I965_RENDER_ENCODE_BUFFER(huffman_table);
+            break;
+
         case VAEncSliceParameterBufferType:
             vaStatus = I965_RENDER_ENCODE_BUFFER(slice_parameter_ext);
             if (vaStatus == VA_STATUS_SUCCESS) {
@@ -2724,7 +2818,8 @@ i965_RenderPicture(VADriverContextP ctx,
 
     if (VAEntrypointVideoProc == obj_config->entrypoint) {
         vaStatus = i965_proc_render_picture(ctx, context, buffers, num_buffers);
-    } else if (VAEntrypointEncSlice == obj_config->entrypoint ) {
+    } else if ((VAEntrypointEncSlice == obj_config->entrypoint ) || 
+               (VAEntrypointEncPicture == obj_config->entrypoint)) {
         vaStatus = i965_encoder_render_picture(ctx, context, buffers, num_buffers);
     } else {
         vaStatus = i965_decoder_render_picture(ctx, context, buffers, num_buffers);
@@ -2747,7 +2842,7 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context)
     if (obj_context->codec_type == CODEC_PROC) {
         ASSERT_RET(VAEntrypointVideoProc == obj_config->entrypoint, VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT);
     } else if (obj_context->codec_type == CODEC_ENC) {
-        ASSERT_RET(VAEntrypointEncSlice == obj_config->entrypoint, VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT);
+        ASSERT_RET(((VAEntrypointEncSlice == obj_config->entrypoint) || (VAEntrypointEncPicture == obj_config->entrypoint)), VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT);
 
         if (obj_context->codec_state.encode.num_packed_header_params_ext !=
                obj_context->codec_state.encode.num_packed_header_data_ext) {
@@ -2759,7 +2854,8 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context)
             return VA_STATUS_ERROR_INVALID_PARAMETER;
         }
         if (!(obj_context->codec_state.encode.seq_param ||
-                obj_context->codec_state.encode.seq_param_ext)) {
+                obj_context->codec_state.encode.seq_param_ext) &&
+                (VAEntrypointEncPicture != obj_config->entrypoint)) {
             return VA_STATUS_ERROR_INVALID_PARAMETER;
         }
         if ((obj_context->codec_state.encode.num_slice_params <=0) &&
@@ -3599,6 +3695,7 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
 
     *out_image = *image;
     obj_surface->flags |= SURFACE_DERIVED;
+    obj_surface->derived_image_id = image_id;
     obj_image->derived_surface = surface;
 
     return VA_STATUS_SUCCESS;
@@ -3642,6 +3739,7 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image)
 
     if (obj_surface) {
         obj_surface->flags &= ~SURFACE_DERIVED;
+        obj_surface->derived_image_id = VA_INVALID_ID;
     }
 
     i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image);
@@ -3860,73 +3958,38 @@ get_image_yuy2(struct object_image *obj_image, uint8_t *image_data,
 
 static VAStatus 
 i965_sw_getimage(VADriverContextP ctx,
-                 VASurfaceID surface,
-                 int x,   /* coordinates of the upper left source pixel */
-                 int y,
-                 unsigned int width,      /* width and height of the region */
-                 unsigned int height,
-                 VAImageID image)
+    struct object_surface *obj_surface, struct object_image *obj_image,
+    const VARectangle *rect)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
-    VAStatus va_status = VA_STATUS_SUCCESS;
-
-    struct object_surface *obj_surface = SURFACE(surface);
-    if (!obj_surface)
-        return VA_STATUS_ERROR_INVALID_SURFACE;
-
-    struct object_image *obj_image = IMAGE(image);
-    if (!obj_image)
-        return VA_STATUS_ERROR_INVALID_IMAGE;
-
-    if (x < 0 || y < 0)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (x + width > obj_surface->orig_width ||
-        y + height > obj_surface->orig_height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (x + width > obj_image->image.width ||
-        y + height > obj_image->image.height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
+    void *image_data = NULL;
+    VAStatus va_status;
 
     if (obj_surface->fourcc != obj_image->image.format.fourcc)
         return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
 
-    void *image_data = NULL;
-
     va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data);
     if (va_status != VA_STATUS_SUCCESS)
         return va_status;
 
-    VARectangle rect;
-    rect.x = x;
-    rect.y = y;
-    rect.width = width;
-    rect.height = height;
-
     switch (obj_image->image.format.fourcc) {
     case VA_FOURCC_YV12:
     case VA_FOURCC_I420:
-        /* I420 is native format for MPEG-2 decoded surfaces */
-        if (render_state->interleaved_uv)
-            goto operation_failed;
-        get_image_i420(obj_image, image_data, obj_surface, &rect);
+        get_image_i420(obj_image, image_data, obj_surface, rect);
         break;
     case VA_FOURCC_NV12:
-        /* NV12 is native format for H.264 decoded surfaces */
-        if (!render_state->interleaved_uv)
-            goto operation_failed;
-        get_image_nv12(obj_image, image_data, obj_surface, &rect);
+        get_image_nv12(obj_image, image_data, obj_surface, rect);
         break;
     case VA_FOURCC_YUY2:
         /* YUY2 is the format supported by overlay plane */
-        get_image_yuy2(obj_image, image_data, obj_surface, &rect);
+        get_image_yuy2(obj_image, image_data, obj_surface, rect);
         break;
     default:
     operation_failed:
         va_status = VA_STATUS_ERROR_OPERATION_FAILED;
         break;
     }
-
     if (va_status != VA_STATUS_SUCCESS)
         return va_status;
 
@@ -3936,44 +3999,11 @@ i965_sw_getimage(VADriverContextP ctx,
 
 static VAStatus 
 i965_hw_getimage(VADriverContextP ctx,
-                 VASurfaceID surface,
-                 int x,   /* coordinates of the upper left source pixel */
-                 int y,
-                 unsigned int width,      /* width and height of the region */
-                 unsigned int height,
-                 VAImageID image)
+    struct object_surface *obj_surface, struct object_image *obj_image,
+    const VARectangle *rect)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_surface src_surface;
     struct i965_surface dst_surface;
-    VAStatus va_status = VA_STATUS_SUCCESS;
-    VARectangle rect;
-    struct object_surface *obj_surface = SURFACE(surface);
-    struct object_image *obj_image = IMAGE(image);
-
-    if (!obj_surface)
-        return VA_STATUS_ERROR_INVALID_SURFACE;
-
-    if (!obj_image)
-        return VA_STATUS_ERROR_INVALID_IMAGE;
-
-    if (x < 0 || y < 0)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (x + width > obj_surface->orig_width ||
-        y + height > obj_surface->orig_height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (x + width > obj_image->image.width ||
-        y + height > obj_image->image.height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-
-    if (!obj_surface->bo)
-        return VA_STATUS_SUCCESS;
-    assert(obj_image->bo); // image bo is always created, see i965_CreateImage()
-
-    rect.x = x;
-    rect.y = y;
-    rect.width = width;
-    rect.height = height;
 
     src_surface.base = (struct object_base *)obj_surface;
     src_surface.type = I965_SURFACE_TYPE_SURFACE;
@@ -3983,14 +4013,7 @@ i965_hw_getimage(VADriverContextP ctx,
     dst_surface.type = I965_SURFACE_TYPE_IMAGE;
     dst_surface.flags = I965_SURFACE_FLAG_FRAME;
 
-    va_status = i965_image_processing(ctx,
-                                      &src_surface,
-                                      &rect,
-                                      &dst_surface,
-                                      &rect);
-
-
-    return va_status;
+    return i965_image_processing(ctx, &src_surface, rect, &dst_surface, rect);
 }
 
 VAStatus 
@@ -4003,20 +4026,41 @@ i965_GetImage(VADriverContextP ctx,
               VAImageID image)
 {
     struct i965_driver_data * const i965 = i965_driver_data(ctx);
-    VAStatus va_status = VA_STATUS_SUCCESS;
+    struct object_surface * const obj_surface = SURFACE(surface);
+    struct object_image * const obj_image = IMAGE(image);
+    VARectangle rect;
+    VAStatus va_status;
+
+    if (!obj_surface)
+        return VA_STATUS_ERROR_INVALID_SURFACE;
+    if (!obj_surface->bo) /* don't get anything, keep previous data */
+        return VA_STATUS_SUCCESS;
+    if (is_surface_busy(i965, obj_surface))
+        return VA_STATUS_ERROR_SURFACE_BUSY;
+
+    if (!obj_image || !obj_image->bo)
+        return VA_STATUS_ERROR_INVALID_IMAGE;
+    if (is_image_busy(i965, obj_image))
+        return VA_STATUS_ERROR_SURFACE_BUSY;
+
+    if (x < 0 || y < 0)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+    if (x + width > obj_surface->orig_width ||
+        y + height > obj_surface->orig_height)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+    if (x + width > obj_image->image.width ||
+        y + height > obj_image->image.height)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
 
     if (HAS_ACCELERATED_GETIMAGE(i965))
-        va_status = i965_hw_getimage(ctx,
-                                     surface,
-                                     x, y,
-                                     width, height,
-                                     image);
+        va_status = i965_hw_getimage(ctx, obj_surface, obj_image, &rect);
     else
-        va_status = i965_sw_getimage(ctx,
-                                     surface,
-                                     x, y,
-                                     width, height,
-                                     image);
+        va_status = i965_sw_getimage(ctx, obj_surface, obj_image, &rect);
 
     return va_status;
 }
@@ -4184,42 +4228,17 @@ put_image_yuy2(struct object_surface *obj_surface,
     return va_status;
 }
 
-
 static VAStatus
 i965_sw_putimage(VADriverContextP ctx,
-                 VASurfaceID surface,
-                 VAImageID image,
-                 int src_x,
-                 int src_y,
-                 unsigned int src_width,
-                 unsigned int src_height,
-                 int dest_x,
-                 int dest_y,
-                 unsigned int dest_width,
-                 unsigned int dest_height)
+    struct object_surface *obj_surface, struct object_image *obj_image,
+    const VARectangle *src_rect, const VARectangle *dst_rect)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
-    struct object_surface *obj_surface = SURFACE(surface);
-    struct object_image *obj_image = IMAGE(image);
     VAStatus va_status = VA_STATUS_SUCCESS;
     void *image_data = NULL;
 
-    ASSERT_RET(obj_surface, VA_STATUS_ERROR_INVALID_SURFACE);
-    ASSERT_RET(obj_image, VA_STATUS_ERROR_INVALID_IMAGE);
-
-    if (src_x < 0 || src_y < 0)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (src_x + src_width > obj_image->image.width ||
-        src_y + src_height > obj_image->image.height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (dest_x < 0 || dest_y < 0)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-    if (dest_x + dest_width > obj_surface->orig_width ||
-        dest_y + dest_height > obj_surface->orig_height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-
     /* XXX: don't allow scaling */
-    if (src_width != dest_width || src_height != dest_height)
+    if (src_rect->width != dst_rect->width ||
+        src_rect->height != dst_rect->height)
         return VA_STATUS_ERROR_INVALID_PARAMETER;
 
     if (obj_surface->fourcc) {
@@ -4244,27 +4263,17 @@ i965_sw_putimage(VADriverContextP ctx,
     va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data);
     if (va_status != VA_STATUS_SUCCESS)
         return va_status;
-
-    VARectangle src_rect, dest_rect;
-    src_rect.x       = src_x;
-    src_rect.y       = src_y;
-    src_rect.width   = src_width;
-    src_rect.height  = src_height;
-    dest_rect.x      = dest_x;
-    dest_rect.y      = dest_y;
-    dest_rect.width  = dest_width;
-    dest_rect.height = dest_height;
      
     switch (obj_image->image.format.fourcc) {
     case VA_FOURCC_YV12:
     case VA_FOURCC_I420:
-        va_status = put_image_i420(obj_surface, &dest_rect, obj_image, image_data, &src_rect);
+        va_status = put_image_i420(obj_surface, dst_rect, obj_image, image_data, src_rect);
         break;
     case VA_FOURCC_NV12:
-        va_status = put_image_nv12(obj_surface, &dest_rect, obj_image, image_data, &src_rect);
+        va_status = put_image_nv12(obj_surface, dst_rect, obj_image, image_data, src_rect);
         break;
     case VA_FOURCC_YUY2:
-        va_status = put_image_yuy2(obj_surface, &dest_rect, obj_image, image_data, &src_rect);
+        va_status = put_image_yuy2(obj_surface, dst_rect, obj_image, image_data, src_rect);
         break;
     default:
         va_status = VA_STATUS_ERROR_OPERATION_FAILED;
@@ -4279,38 +4288,11 @@ i965_sw_putimage(VADriverContextP ctx,
 
 static VAStatus 
 i965_hw_putimage(VADriverContextP ctx,
-                 VASurfaceID surface,
-                 VAImageID image,
-                 int src_x,
-                 int src_y,
-                 unsigned int src_width,
-                 unsigned int src_height,
-                 int dest_x,
-                 int dest_y,
-                 unsigned int dest_width,
-                 unsigned int dest_height)
+    struct object_surface *obj_surface, struct object_image *obj_image,
+    const VARectangle *src_rect, const VARectangle *dst_rect)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
-    struct object_surface *obj_surface = SURFACE(surface);
-    struct object_image *obj_image = IMAGE(image);
     struct i965_surface src_surface, dst_surface;
     VAStatus va_status = VA_STATUS_SUCCESS;
-    VARectangle src_rect, dst_rect;
-
-    ASSERT_RET(obj_surface,VA_STATUS_ERROR_INVALID_SURFACE);
-    ASSERT_RET(obj_image && obj_image->bo, VA_STATUS_ERROR_INVALID_IMAGE);
-
-    if (src_x < 0 ||
-        src_y < 0 ||
-        src_x + src_width > obj_image->image.width ||
-        src_y + src_height > obj_image->image.height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
-
-    if (dest_x < 0 ||
-        dest_y < 0 ||
-        dest_x + dest_width > obj_surface->orig_width ||
-        dest_y + dest_height > obj_surface->orig_height)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
 
     if (!obj_surface->bo) {
         unsigned int tiling, swizzle;
@@ -4329,24 +4311,16 @@ i965_hw_putimage(VADriverContextP ctx,
     src_surface.base = (struct object_base *)obj_image;
     src_surface.type = I965_SURFACE_TYPE_IMAGE;
     src_surface.flags = I965_SURFACE_FLAG_FRAME;
-    src_rect.x = src_x;
-    src_rect.y = src_y;
-    src_rect.width = src_width;
-    src_rect.height = src_height;
 
     dst_surface.base = (struct object_base *)obj_surface;
     dst_surface.type = I965_SURFACE_TYPE_SURFACE;
     dst_surface.flags = I965_SURFACE_FLAG_FRAME;
-    dst_rect.x = dest_x;
-    dst_rect.y = dest_y;
-    dst_rect.width = dest_width;
-    dst_rect.height = dest_height;
 
     va_status = i965_image_processing(ctx,
                                       &src_surface,
-                                      &src_rect,
+                                      src_rect,
                                       &dst_surface,
-                                      &dst_rect);
+                                      dst_rect);
 
     return  va_status;
 }
@@ -4364,33 +4338,50 @@ i965_PutImage(VADriverContextP ctx,
               unsigned int dest_width,
               unsigned int dest_height)
 {
-    struct i965_driver_data *i965 = i965_driver_data(ctx);
-    VAStatus va_status = VA_STATUS_SUCCESS;
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
+    struct object_surface * const obj_surface = SURFACE(surface);
+    struct object_image * const obj_image = IMAGE(image);
+    VARectangle src_rect, dst_rect;
+    VAStatus va_status;
+
+    if (!obj_surface)
+        return VA_STATUS_ERROR_INVALID_SURFACE;
+    if (is_surface_busy(i965, obj_surface))
+        return VA_STATUS_ERROR_SURFACE_BUSY;
+
+    if (!obj_image || !obj_image->bo)
+        return VA_STATUS_ERROR_INVALID_IMAGE;
+    if (is_image_busy(i965, obj_image))
+        return VA_STATUS_ERROR_SURFACE_BUSY;
+
+    if (src_x < 0 ||
+        src_y < 0 ||
+        src_x + src_width > obj_image->image.width ||
+        src_y + src_height > obj_image->image.height)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+    src_rect.x       = src_x;
+    src_rect.y       = src_y;
+    src_rect.width   = src_width;
+    src_rect.height  = src_height;
+
+    if (dest_x < 0 ||
+        dest_y < 0 ||
+        dest_x + dest_width > obj_surface->orig_width ||
+        dest_y + dest_height > obj_surface->orig_height)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+    dst_rect.x      = dest_x;
+    dst_rect.y      = dest_y;
+    dst_rect.width  = dest_width;
+    dst_rect.height = dest_height;
 
     if (HAS_ACCELERATED_PUTIMAGE(i965))
-        va_status = i965_hw_putimage(ctx,
-                                     surface,
-                                     image,
-                                     src_x,
-                                     src_y,
-                                     src_width,
-                                     src_height,
-                                     dest_x,
-                                     dest_y,
-                                     dest_width,
-                                     dest_height);
+        va_status = i965_hw_putimage(ctx, obj_surface, obj_image,
+            &src_rect, &dst_rect);
     else 
-        va_status = i965_sw_putimage(ctx,
-                                     surface,
-                                     image,
-                                     src_x,
-                                     src_y,
-                                     src_width,
-                                     src_height,
-                                     dest_x,
-                                     dest_y,
-                                     dest_width,
-                                     dest_height);
+        va_status = i965_sw_putimage(ctx, obj_surface, obj_image,
+            &src_rect, &dst_rect);
 
     return va_status;
 }
@@ -4644,7 +4635,8 @@ i965_GetSurfaceAttributes(
                 } else if (IS_GEN6(i965->intel.device_info)) {
                     attrib_list[i].value.value.i = VA_FOURCC_NV12;
                 } else if (IS_GEN7(i965->intel.device_info) ||
-                           IS_GEN8(i965->intel.device_info)) {
+                           IS_GEN8(i965->intel.device_info) ||
+                           IS_GEN9(i965->intel.device_info)) {
                     if (obj_config->profile == VAProfileJPEGBaseline)
                         attrib_list[i].value.value.i = 0; /* internal format */
                     else
@@ -4721,7 +4713,8 @@ i965_GetSurfaceAttributes(
                         }
                     }
                 } else if (IS_GEN7(i965->intel.device_info) ||
-                           IS_GEN8(i965->intel.device_info)) {
+                           IS_GEN8(i965->intel.device_info) ||
+                           IS_GEN9(i965->intel.device_info)) {
                     if (obj_config->entrypoint == VAEntrypointEncSlice ||
                         obj_config->entrypoint == VAEntrypointVideoProc) {
                         switch (attrib_list[i].value.value.i) {
@@ -4998,11 +4991,24 @@ i965_QuerySurfaceAttributes(VADriverContextP ctx,
                 attribs[i].type = VASurfaceAttribPixelFormat;
                 attribs[i].value.type = VAGenericValueTypeInteger;
                 attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
+                attribs[i].value.value.i = VA_FOURCC_BGRA;
+                i++;
+
+                attribs[i].type = VASurfaceAttribPixelFormat;
+                attribs[i].value.type = VAGenericValueTypeInteger;
+                attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
+                attribs[i].value.value.i = VA_FOURCC_BGRX;
+                i++;
+
+                attribs[i].type = VASurfaceAttribPixelFormat;
+                attribs[i].value.type = VAGenericValueTypeInteger;
+                attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
                 attribs[i].value.value.i = VA_FOURCC_YV16;
                 i++;
             }
         }
-    } else if (IS_GEN8(i965->intel.device_info)) {
+    } else if (IS_GEN8(i965->intel.device_info) ||
+               IS_GEN9(i965->intel.device_info)) {
         if (obj_config->entrypoint == VAEntrypointVLD) { /* decode */
             if (obj_config->profile == VAProfileJPEGBaseline) {
                 attribs[i].type = VASurfaceAttribPixelFormat;
@@ -5655,6 +5661,45 @@ struct {
 #endif
 };
 
+static bool
+ensure_vendor_string(struct i965_driver_data *i965, const char *chipset)
+{
+    int ret, len;
+
+    if (i965->va_vendor[0] != '\0')
+        return true;
+
+    len = 0;
+    ret = snprintf(i965->va_vendor, sizeof(i965->va_vendor),
+        "%s %s driver for %s - %d.%d.%d",
+        INTEL_STR_DRIVER_VENDOR, INTEL_STR_DRIVER_NAME, chipset,
+        INTEL_DRIVER_MAJOR_VERSION, INTEL_DRIVER_MINOR_VERSION,
+        INTEL_DRIVER_MICRO_VERSION);
+    if (ret < 0 || ret >= sizeof(i965->va_vendor))
+        goto error;
+    len = ret;
+
+    if (INTEL_DRIVER_PRE_VERSION > 0) {
+        ret = snprintf(&i965->va_vendor[len], sizeof(i965->va_vendor) - len,
+            ".pre%d", INTEL_DRIVER_PRE_VERSION);
+        if (ret < 0 || ret >= sizeof(i965->va_vendor))
+            goto error;
+        len += ret;
+
+        ret = snprintf(&i965->va_vendor[len], sizeof(i965->va_vendor) - len,
+            " (%s)", INTEL_DRIVER_GIT_VERSION);
+        if (ret < 0 || ret >= sizeof(i965->va_vendor))
+            goto error;
+        len += ret;
+    }
+    return true;
+
+error:
+    i965->va_vendor[0] = '\0';
+    ASSERT_RET(ret > 0 && len < sizeof(i965->va_vendor), false);
+    return false;
+}
+
 static VAStatus 
 i965_Init(VADriverContextP ctx)
 {
@@ -5669,9 +5714,6 @@ i965_Init(VADriverContextP ctx)
             break;
     }
 
-    if (i965->codec_info->preinit_hw_codec)
-        i965->codec_info->preinit_hw_codec(ctx, i965->codec_info);
-
     if (i == ARRAY_ELEMS(i965_sub_ops)) {
         switch (i965->intel.device_id) {
 #undef CHIPSET
@@ -5682,21 +5724,14 @@ i965_Init(VADriverContextP ctx)
             break;
         }
 
-        sprintf(i965->va_vendor, "%s %s driver for %s - %d.%d.%d",
-                INTEL_STR_DRIVER_VENDOR,
-                INTEL_STR_DRIVER_NAME,
-                chipset,
-                INTEL_DRIVER_MAJOR_VERSION,
-                INTEL_DRIVER_MINOR_VERSION,
-                INTEL_DRIVER_MICRO_VERSION);
-
-        if (INTEL_DRIVER_PRE_VERSION > 0) {
-            const int len = strlen(i965->va_vendor);
-            sprintf(&i965->va_vendor[len], ".pre%d", INTEL_DRIVER_PRE_VERSION);
-        }
+        if (!ensure_vendor_string(i965, chipset))
+            return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
         i965->current_context_id = VA_INVALID_ID;
 
+        if (i965->codec_info && i965->codec_info->preinit_hw_codec)
+            i965->codec_info->preinit_hw_codec(ctx, i965->codec_info);
+
         return VA_STATUS_SUCCESS;
     } else {
         i--;
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 3478165..9636010 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -33,6 +33,7 @@
 #include <va/va.h>
 #include <va/va_enc_h264.h>
 #include <va/va_enc_mpeg2.h>
+#include <va/va_enc_jpeg.h>
 #include <va/va_vpp.h>
 #include <va/va_backend.h>
 #include <va/va_backend_vpp.h>
@@ -142,6 +143,7 @@ struct encode_state
     struct buffer_store *iq_matrix;
     struct buffer_store *q_matrix;
     struct buffer_store **slice_params;
+    struct buffer_store *huffman_table;
     int max_slice_params;
     int num_slice_params;
 
@@ -263,6 +265,7 @@ struct object_surface
     unsigned int fourcc;    
     dri_bo *bo;
     VAImageID locked_image_id;
+    VAImageID derived_image_id;
     void (*free_private_data)(void **data);
     void *private_data;
     unsigned int subsampling;
@@ -346,6 +349,7 @@ struct hw_codec_info
     unsigned int h264_mvc_dec_profiles;
     unsigned int h264_dec_chroma_formats;
     unsigned int jpeg_dec_chroma_formats;
+    unsigned int jpeg_enc_chroma_formats;
 
     unsigned int has_mpeg2_decoding:1;
     unsigned int has_mpeg2_encoding:1;
@@ -364,6 +368,7 @@ struct hw_codec_info
     unsigned int has_vp8_decoding:1;
     unsigned int has_vp8_encoding:1;
     unsigned int has_h264_mvc_encoding:1;
+    unsigned int has_hevc_decoding:1;
 
     unsigned int num_filters;
     struct i965_filter filters[VAProcFilterCount];
@@ -447,6 +452,7 @@ va_enc_packed_type_to_idx(int packed_type);
 #define CODEC_H264      0
 #define CODEC_MPEG2     1
 #define CODEC_H264_MVC  2
+#define CODEC_JPEG      3
 
 #define H264_DELIMITER0 0x00
 #define H264_DELIMITER1 0x00
@@ -467,7 +473,7 @@ struct i965_coded_buffer_segment
     unsigned char codec;
 };
 
-#define I965_CODEDBUFFER_HEADER_SIZE   ALIGN(sizeof(struct i965_coded_buffer_segment), 64)
+#define I965_CODEDBUFFER_HEADER_SIZE   ALIGN(sizeof(struct i965_coded_buffer_segment), 0x1000)
 
 extern VAStatus i965_MapBuffer(VADriverContextP ctx,
 		VABufferID buf_id,       /* in */
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index f66d889..d924f5a 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -122,6 +122,131 @@ intel_encoder_check_yuv_surface(VADriverContextP ctx,
     return VA_STATUS_SUCCESS;
 }
 
+
+static VAStatus
+intel_encoder_check_jpeg_yuv_surface(VADriverContextP ctx,
+                                VAProfile profile,
+                                struct encode_state *encode_state,
+                                struct intel_encoder_context *encoder_context)
+{
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    struct i965_surface src_surface, dst_surface;
+    struct object_surface *obj_surface;
+    VAStatus status;
+    VARectangle rect;
+    int format=0, fourcc=0, subsample=0;
+
+    /* releae the temporary surface */
+    if (encoder_context->is_tmp_id) {
+        i965_DestroySurfaces(ctx, &encoder_context->input_yuv_surface, 1);
+        encode_state->input_yuv_object = NULL;
+    }
+
+    encoder_context->is_tmp_id = 0;
+    obj_surface = SURFACE(encode_state->current_render_target);
+    assert(obj_surface && obj_surface->bo);
+
+    if (!obj_surface || !obj_surface->bo)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+    unsigned int tiling = 0, swizzle = 0;
+
+    dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
+
+    if (tiling == I915_TILING_Y) {
+        if( (obj_surface->fourcc==VA_FOURCC_NV12)  || (obj_surface->fourcc==VA_FOURCC_UYVY) ||
+            (obj_surface->fourcc==VA_FOURCC_YUY2)  || (obj_surface->fourcc==VA_FOURCC_Y800) ||
+            (obj_surface->fourcc==VA_FOURCC_RGBA)  || (obj_surface->fourcc==VA_FOURCC_444P) ) {
+            encoder_context->input_yuv_surface = encode_state->current_render_target;
+            encode_state->input_yuv_object = obj_surface;
+            return VA_STATUS_SUCCESS;
+        }
+    }
+
+    rect.x = 0;
+    rect.y = 0;
+    rect.width = obj_surface->orig_width;
+    rect.height = obj_surface->orig_height;
+
+    src_surface.base = (struct object_base *)obj_surface;
+    src_surface.type = I965_SURFACE_TYPE_SURFACE;
+    src_surface.flags = I965_SURFACE_FLAG_FRAME;
+
+    switch( obj_surface->fourcc) {
+
+        case VA_FOURCC_YUY2:
+            fourcc = VA_FOURCC_YUY2;
+            format = VA_RT_FORMAT_YUV422;
+            subsample = SUBSAMPLE_YUV422H;
+            break;
+
+        case VA_FOURCC_UYVY:
+            fourcc = VA_FOURCC_UYVY;
+            format = VA_RT_FORMAT_YUV422;
+            subsample = SUBSAMPLE_YUV422H;
+            break;
+
+        case VA_FOURCC_Y800:
+            fourcc = VA_FOURCC_Y800;
+            format = VA_RT_FORMAT_YUV400;
+            subsample = SUBSAMPLE_YUV400;
+            break;
+
+        case VA_FOURCC_444P:
+            fourcc = VA_FOURCC_444P;
+            format = VA_RT_FORMAT_YUV444;
+            subsample = SUBSAMPLE_YUV444;
+            break;
+
+        case VA_FOURCC_RGBA:
+            fourcc = VA_FOURCC_RGBA;
+            format = VA_RT_FORMAT_RGB32;
+            subsample = SUBSAMPLE_RGBX;
+            break;
+
+        default: //All other scenarios will have NV12 format
+            fourcc = VA_FOURCC_NV12;
+            format = VA_RT_FORMAT_YUV420;
+            subsample = SUBSAMPLE_YUV420;
+            break;
+    }
+
+    status = i965_CreateSurfaces(ctx,
+                                 obj_surface->orig_width,
+                                 obj_surface->orig_height,
+                                 format,
+                                 1,
+                                 &encoder_context->input_yuv_surface);
+    assert(status == VA_STATUS_SUCCESS);
+
+    if (status != VA_STATUS_SUCCESS)
+        return status;
+
+    obj_surface = SURFACE(encoder_context->input_yuv_surface);
+    encode_state->input_yuv_object = obj_surface;
+    assert(obj_surface);
+    i965_check_alloc_surface_bo(ctx, obj_surface, 1, fourcc, subsample);
+
+    dst_surface.base = (struct object_base *)obj_surface;
+    dst_surface.type = I965_SURFACE_TYPE_SURFACE;
+    dst_surface.flags = I965_SURFACE_FLAG_FRAME;
+
+    //The Y800 format is expected to be tiled.
+    //Linear Y800 is a corner case and needs code in the i965_image_processing.
+    if(obj_surface->fourcc != VA_FOURCC_Y800){
+        status = i965_image_processing(ctx,
+                                   &src_surface,
+                                   &rect,
+                                   &dst_surface,
+                                   &rect);
+        assert(status == VA_STATUS_SUCCESS);
+    }
+
+    encoder_context->is_tmp_id = 1;
+
+    return VA_STATUS_SUCCESS;
+}
+
 static VAStatus
 intel_encoder_check_misc_parameter(VADriverContextP ctx,
                                   struct encode_state *encode_state,
@@ -271,6 +396,32 @@ error:
 }
 
 static VAStatus
+intel_encoder_check_jpeg_parameter(VADriverContextP ctx,
+                                  struct encode_state *encode_state,
+                                  struct intel_encoder_context *encoder_context)
+{
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    struct object_buffer *obj_buffer;
+    VAEncPictureParameterBufferJPEG *pic_param = (VAEncPictureParameterBufferJPEG *)encode_state->pic_param_ext->buffer;
+
+
+    assert(!(pic_param->pic_flags.bits.profile)); //Baseline profile is 0.
+
+    obj_buffer = BUFFER(pic_param->coded_buf);
+    assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
+
+    if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
+        goto error;
+
+    encode_state->coded_buf_object = obj_buffer;
+
+    return VA_STATUS_SUCCESS;
+
+error:
+    return VA_STATUS_ERROR_INVALID_PARAMETER;
+}
+
+static VAStatus
 intel_encoder_sanity_check_input(VADriverContextP ctx,
                                  VAProfile profile,
                                  struct encode_state *encode_state,
@@ -283,25 +434,36 @@ intel_encoder_sanity_check_input(VADriverContextP ctx,
     case VAProfileH264Main:
     case VAProfileH264High:
     case VAProfileH264MultiviewHigh:
-    case VAProfileH264StereoHigh:
+    case VAProfileH264StereoHigh: {
         vaStatus = intel_encoder_check_avc_parameter(ctx, encode_state, encoder_context);
+        if (vaStatus != VA_STATUS_SUCCESS)
+            goto out;
+        vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
         break;
+    }
 
     case VAProfileMPEG2Simple:
-    case VAProfileMPEG2Main:
+    case VAProfileMPEG2Main: {
         vaStatus = intel_encoder_check_mpeg2_parameter(ctx, encode_state, encoder_context);
+        if (vaStatus != VA_STATUS_SUCCESS)
+            goto out;
+        vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
         break;
+    }
+
+    case VAProfileJPEGBaseline:  {
+        vaStatus = intel_encoder_check_jpeg_parameter(ctx, encode_state, encoder_context);
+        if (vaStatus != VA_STATUS_SUCCESS)
+            goto out;
+        vaStatus = intel_encoder_check_jpeg_yuv_surface(ctx, profile, encode_state, encoder_context);
+        break;
+    }
 
     default:
         vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
         break;
     }
 
-    if (vaStatus != VA_STATUS_SUCCESS)
-        goto out;
-
-    vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
-
     if (vaStatus == VA_STATUS_SUCCESS)
         vaStatus = intel_encoder_check_misc_parameter(ctx, encode_state, encoder_context);
 
@@ -326,7 +488,9 @@ intel_encoder_end_picture(VADriverContextP ctx,
 
     encoder_context->mfc_brc_prepare(encode_state, encoder_context);
 
-    vaStatus = encoder_context->vme_pipeline(ctx, profile, encode_state, encoder_context);
+    if((encoder_context->vme_context && encoder_context->vme_pipeline)) {
+        vaStatus = encoder_context->vme_pipeline(ctx, profile, encode_state, encoder_context);
+    }
 
     if (vaStatus == VA_STATUS_SUCCESS)
         encoder_context->mfc_pipeline(ctx, profile, encode_state, encoder_context);
@@ -339,7 +503,10 @@ intel_encoder_context_destroy(void *hw_context)
     struct intel_encoder_context *encoder_context = (struct intel_encoder_context *)hw_context;
 
     encoder_context->mfc_context_destroy(encoder_context->mfc_context);
-    encoder_context->vme_context_destroy(encoder_context->vme_context);
+
+    if (encoder_context->vme_context_destroy && encoder_context->vme_context)
+       encoder_context->vme_context_destroy(encoder_context->vme_context);
+
     intel_batchbuffer_free(encoder_context->base.batch);
     free(encoder_context);
 }
@@ -382,6 +549,10 @@ intel_enc_hw_context_init(VADriverContextP ctx,
     case VAProfileH264MultiviewHigh:
         encoder_context->codec = CODEC_H264_MVC;
         break;
+        
+    case VAProfileJPEGBaseline:
+        encoder_context->codec = CODEC_JPEG;
+        break;
 
     default:
         /* Never get here */
@@ -404,9 +575,11 @@ intel_enc_hw_context_init(VADriverContextP ctx,
     }
 
     vme_context_init(ctx, encoder_context);
-    assert(encoder_context->vme_context);
-    assert(encoder_context->vme_context_destroy);
-    assert(encoder_context->vme_pipeline);
+    if(obj_config->profile != VAProfileJPEGBaseline) {
+        assert(encoder_context->vme_context);
+        assert(encoder_context->vme_context_destroy);
+        assert(encoder_context->vme_pipeline);
+    }
 
     mfc_context_init(ctx, encoder_context);
     assert(encoder_context->mfc_context);
@@ -441,3 +614,11 @@ gen8_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
     return intel_enc_hw_context_init(ctx, obj_config, gen8_vme_context_init, gen8_mfc_context_init);
 }
 
+struct hw_context *
+gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
+{
+    if (obj_config->profile == VAProfileJPEGBaseline)
+        return intel_enc_hw_context_init(ctx, obj_config, gen8_vme_context_init, gen8_mfc_context_init);
+    else
+        return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init);
+}
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index 20d49fc..13a9ad1 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -66,6 +66,9 @@ gen75_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config
 
 extern struct hw_context *
 gen8_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config);
+
+extern struct hw_context *
+gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config);
 #endif	/* _I965_ENCODER_H_ */
 
 
diff --git a/src/i965_gpe_utils.c b/src/i965_gpe_utils.c
index 3386b09..6d3b3ab 100644
--- a/src/i965_gpe_utils.c
+++ b/src/i965_gpe_utils.c
@@ -1207,3 +1207,107 @@ gen8_gpe_load_kernels(VADriverContextP ctx,
     return;
 }
 
+static void
+gen9_gpe_state_base_address(VADriverContextP ctx,
+                            struct i965_gpe_context *gpe_context,
+                            struct intel_batchbuffer *batch)
+{
+    BEGIN_BATCH(batch, 19);
+
+    OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (19 - 2));
+
+    OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);				//General State Base Address
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0);
+
+	/*DW4 Surface state base address */
+    OUT_RELOC(batch, gpe_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
+    OUT_BATCH(batch, 0);
+
+	/*DW6. Dynamic state base address */
+    if (gpe_context->dynamic_state.bo)
+        OUT_RELOC(batch, gpe_context->dynamic_state.bo,
+                  I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_SAMPLER,
+                  0, BASE_ADDRESS_MODIFY);
+    else
+        OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+
+    OUT_BATCH(batch, 0);
+
+	/*DW8. Indirect Object base address */
+    if (gpe_context->indirect_state.bo)
+        OUT_RELOC(batch, gpe_context->indirect_state.bo,
+                  I915_GEM_DOMAIN_SAMPLER,
+                  0, BASE_ADDRESS_MODIFY);
+    else
+        OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+
+    OUT_BATCH(batch, 0);
+
+	/*DW10. Instruct base address */
+    if (gpe_context->instruction_state.bo)
+        OUT_RELOC(batch, gpe_context->instruction_state.bo,
+                  I915_GEM_DOMAIN_INSTRUCTION,
+                  0, BASE_ADDRESS_MODIFY);
+    else
+        OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+
+    OUT_BATCH(batch, 0);
+
+	/* DW12. Size limitation */
+    OUT_BATCH(batch, 0xFFFFF000 | BASE_ADDRESS_MODIFY);		//General State Access Upper Bound
+    OUT_BATCH(batch, 0xFFFFF000 | BASE_ADDRESS_MODIFY);		//Dynamic State Access Upper Bound
+    OUT_BATCH(batch, 0xFFFFF000 | BASE_ADDRESS_MODIFY);		//Indirect Object Access Upper Bound
+    OUT_BATCH(batch, 0xFFFFF000 | BASE_ADDRESS_MODIFY);		//Instruction Access Upper Bound
+
+    /* the bindless surface state address */
+    OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
+    OUT_BATCH(batch, 0);
+    OUT_BATCH(batch, 0xFFFFF000);
+
+    ADVANCE_BATCH(batch);
+}
+
+static void
+gen9_gpe_select(VADriverContextP ctx,
+                struct i965_gpe_context *gpe_context,
+                struct intel_batchbuffer *batch)
+{
+    BEGIN_BATCH(batch, 1);
+    OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA |
+                     GEN9_PIPELINE_SELECTION_MASK |
+                     GEN9_MEDIA_DOP_GATE_OFF |
+                     GEN9_MEDIA_DOP_GATE_MASK |
+                     GEN9_FORCE_MEDIA_AWAKE_ON |
+                     GEN9_FORCE_MEDIA_AWAKE_MASK);
+    ADVANCE_BATCH(batch);
+}
+
+void
+gen9_gpe_pipeline_setup(VADriverContextP ctx,
+                        struct i965_gpe_context *gpe_context,
+                        struct intel_batchbuffer *batch)
+{
+    intel_batchbuffer_emit_mi_flush(batch);
+
+    gen9_gpe_select(ctx, gpe_context, batch);
+    gen9_gpe_state_base_address(ctx, gpe_context, batch);
+    gen8_gpe_vfe_state(ctx, gpe_context, batch);
+    gen8_gpe_curbe_load(ctx, gpe_context, batch);
+    gen8_gpe_idrt(ctx, gpe_context, batch);
+}
+
+void
+gen9_gpe_pipeline_end(VADriverContextP ctx,
+                      struct i965_gpe_context *gpe_context,
+                      struct intel_batchbuffer *batch)
+{
+    BEGIN_BATCH(batch, 1);
+    OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA |
+              GEN9_PIPELINE_SELECTION_MASK |
+              GEN9_MEDIA_DOP_GATE_ON |
+              GEN9_MEDIA_DOP_GATE_MASK |
+              GEN9_FORCE_MEDIA_AWAKE_OFF |
+              GEN9_FORCE_MEDIA_AWAKE_MASK);
+    ADVANCE_BATCH(batch);
+}
diff --git a/src/i965_gpe_utils.h b/src/i965_gpe_utils.h
index 2331152..7e39d46 100644
--- a/src/i965_gpe_utils.h
+++ b/src/i965_gpe_utils.h
@@ -219,4 +219,13 @@ void gen8_gpe_load_kernels(VADriverContextP ctx,
                            struct i965_gpe_context *gpe_context,
                            struct i965_kernel *kernel_list,
                            unsigned int num_kernels);
+
+void gen9_gpe_pipeline_setup(VADriverContextP ctx,
+                             struct i965_gpe_context *gpe_context,
+                             struct intel_batchbuffer *batch);
+
+void gen9_gpe_pipeline_end(VADriverContextP ctx,
+                             struct i965_gpe_context *gpe_context,
+                             struct intel_batchbuffer *batch);
+
 #endif /* _I965_GPE_UTILS_H_ */
diff --git a/src/i965_output_dri.c b/src/i965_output_dri.c
index 6f8ea31..9bba333 100644
--- a/src/i965_output_dri.c
+++ b/src/i965_output_dri.c
@@ -123,11 +123,9 @@ i965_put_surface_dri(
     union dri_buffer *buffer;
     struct intel_region *dest_region;
     struct object_surface *obj_surface; 
-    unsigned int pp_flag = 0;
     bool new_region = false;
     uint32_t name;
     int i, ret;
-    unsigned int color_flag = 0;
 
     /* Currently don't support DRI1 */
     if (!VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2))
@@ -179,21 +177,10 @@ i965_put_surface_dri(
         assert(ret == 0);
     }
 
-    color_flag = flags & VA_SRC_COLOR_MASK;
-    if (color_flag == 0)
-        color_flag = VA_SRC_BT601;
+    if (!(flags & VA_SRC_COLOR_MASK))
+        flags |= VA_SRC_BT601;
 
-    pp_flag = color_flag;
-
-    if ((flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC)
-        pp_flag |= I965_PP_FLAG_AVS;
-
-    if (flags & VA_TOP_FIELD)
-        pp_flag |= I965_PP_FLAG_TOP_FIELD;
-    else if (flags & VA_BOTTOM_FIELD)
-        pp_flag |= I965_PP_FLAG_BOTTOM_FIELD;
-
-    intel_render_put_surface(ctx, obj_surface, src_rect, dst_rect, pp_flag);
+    intel_render_put_surface(ctx, obj_surface, src_rect, dst_rect, flags);
 
     for (i = 0; i < I965_MAX_SUBPIC_SUM; i++) {
         if (obj_surface->obj_subpic[i] != NULL) {
diff --git a/src/i965_pciids.h b/src/i965_pciids.h
index fc046d1..22b8215 100644
--- a/src/i965_pciids.h
+++ b/src/i965_pciids.h
@@ -133,3 +133,18 @@ CHIPSET(0x22B0, chv, chv,       "Intel(R) CherryView")
 CHIPSET(0x22B1, chv, chv,       "Intel(R) CherryView")
 CHIPSET(0x22B2, chv, chv,       "Intel(R) CherryView")
 CHIPSET(0x22B3, chv, chv,       "Intel(R) CherryView")
+CHIPSET(0x1902, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1906, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x190E, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1912, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1913, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1915, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1916, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1917, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x191B, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x191E, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1921, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x1926, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x192B, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x193A, skl, skl,       "Intel(R) Skylake")
+CHIPSET(0x193B, skl, skl,       "Intel(R) Skylake")
diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c
index 6d435a8..865dc3f 100755
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -129,12 +129,12 @@ static VAStatus pp_null_initialize(VADriverContextP ctx, struct i965_post_proces
                                    struct i965_surface *dst_surface,
                                    const VARectangle *dst_rect,
                                    void *filter_param);
-static VAStatus pp_nv12_avs_initialize_nlas(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
-                                            const struct i965_surface *src_surface,
-                                            const VARectangle *src_rect,
-                                            struct i965_surface *dst_surface,
-                                            const VARectangle *dst_rect,
-                                            void *filter_param);
+static VAStatus
+pp_nv12_avs_initialize(VADriverContextP ctx,
+    struct i965_post_processing_context *pp_context,
+    const struct i965_surface *src_surface, const VARectangle *src_rect,
+    struct i965_surface *dst_surface, const VARectangle *dst_rect,
+    void *filter_param);
 static VAStatus pp_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
                                            const struct i965_surface *src_surface,
                                            const VARectangle *src_rect,
@@ -248,7 +248,7 @@ static struct pp_module pp_modules_gen5[] = {
             NULL,
         },
 
-        pp_nv12_avs_initialize_nlas,
+        pp_nv12_avs_initialize,
     },
 
     {
@@ -506,7 +506,7 @@ static struct pp_module pp_modules_gen6[] = {
             NULL,
         },
 
-        pp_nv12_avs_initialize_nlas,
+        pp_nv12_avs_initialize,
     },
 
     {
@@ -2363,14 +2363,59 @@ pp_avs_set_block_parameter(struct i965_post_processing_context *pp_context, int
     return 0;
 }
 
+static const AVSConfig gen5_avs_config = {
+    .coeff_frac_bits = 6,
+    .coeff_epsilon = 1.0f / (1U << 6),
+    .num_phases = 16,
+    .num_luma_coeffs = 8,
+    .num_chroma_coeffs = 4,
+
+    .coeff_range = {
+        .lower_bound = {
+            .y_k_h = { -0.25f, -0.5f, -1, 0, 0, -1, -0.5f, -0.25f },
+            .y_k_v = { -0.25f, -0.5f, -1, 0, 0, -1, -0.5f, -0.25f },
+            .uv_k_h = { -1, 0, 0, -1 },
+            .uv_k_v = { -1, 0, 0, -1 },
+        },
+        .upper_bound = {
+            .y_k_h = { 0.25f, 0.5f, 1, 2, 2, 1, 0.5f, 0.25f },
+            .y_k_v = { 0.25f, 0.5f, 1, 2, 2, 1, 0.5f, 0.25f },
+            .uv_k_h = { 1, 2, 2, 1 },
+            .uv_k_v = { 1, 2, 2, 1 },
+        },
+    },
+};
+
+static const AVSConfig gen6_avs_config = {
+    .coeff_frac_bits = 6,
+    .coeff_epsilon = 1.0f / (1U << 6),
+    .num_phases = 16,
+    .num_luma_coeffs = 8,
+    .num_chroma_coeffs = 4,
+
+    .coeff_range = {
+        .lower_bound = {
+            .y_k_h = { -0.25f, -0.5f, -1, -2, -2, -1, -0.5f, -0.25f },
+            .y_k_v = { -0.25f, -0.5f, -1, -2, -2, -1, -0.5f, -0.25f },
+            .uv_k_h = { -1, 0, 0, -1 },
+            .uv_k_v = { -1, 0, 0, -1 },
+        },
+        .upper_bound = {
+            .y_k_h = { 0.25f, 0.5f, 1, 2, 2, 1, 0.5f, 0.25f },
+            .y_k_v = { 0.25f, 0.5f, 1, 2, 2, 1, 0.5f, 0.25f },
+            .uv_k_h = { 1, 2, 2, 1 },
+            .uv_k_v = { 1, 2, 2, 1 },
+        },
+    },
+};
+
 static VAStatus
 pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
                        const struct i965_surface *src_surface,
                        const VARectangle *src_rect,
                        struct i965_surface *dst_surface,
                        const VARectangle *dst_rect,
-                       void *filter_param,
-                       int nlas)
+                       void *filter_param)
 {
     struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->pp_avs_context;
     struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
@@ -2382,6 +2427,11 @@ pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context
     int in_w, in_h, in_wpitch, in_hpitch;
     int out_w, out_h, out_wpitch, out_hpitch;
     int i;
+    AVSState * const avs = &pp_avs_context->state;
+    float sx, sy;
+
+    const int nlas = (pp_context->filter_flags & VA_FILTER_SCALING_MASK) ==
+        VA_FILTER_SCALING_NL_ANAMORPHIC;
 
     /* surface */
     obj_surface = (struct object_surface *)src_surface->base;
@@ -2433,47 +2483,74 @@ pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context
     sampler_8x8_state = pp_context->sampler_state_table.bo_8x8->virtual;
     memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
 
-    for (i = 0; i < 17; i++) {
-        /* for Y channel, currently ignore */
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 = 0x00;
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 = 0x00;
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 = 0x08;
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 = 0x18;
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 = 0x18;
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 = 0x08;
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 = 0x00;
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 = 0x00;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 = 0x00;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 = 0x00;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 = 0x10;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 = 0x10;
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 = 0x10;
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 = 0x10;
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 = 0x00;
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 = 0x00;
-        /* for U/V channel, 0.25 */
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c0 = 0x0;
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c1 = 0x0;
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 = 0x10;
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 = 0x10;
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 = 0x10;
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 = 0x10;
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c6 = 0x0;
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c7 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c0 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c1 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 = 0x10;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 = 0x10;
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 = 0x10;
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 = 0x10;
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c6 = 0x0;
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c7 = 0x0;
+    sx = (float)dst_rect->width / src_rect->width;
+    sy = (float)dst_rect->height / src_rect->height;
+    avs_update_coefficients(avs, sx, sy, pp_context->filter_flags);
+
+    assert(avs->config->num_phases == 16);
+    for (i = 0; i <= 16; i++) {
+        const AVSCoeffs * const coeffs = &avs->coeffs[i];
+
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 =
+            intel_format_convert(coeffs->y_k_h[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 =
+            intel_format_convert(coeffs->y_k_h[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 =
+            intel_format_convert(coeffs->y_k_h[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 =
+            intel_format_convert(coeffs->y_k_h[3], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 =
+            intel_format_convert(coeffs->y_k_h[4], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 =
+            intel_format_convert(coeffs->y_k_h[5], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 =
+            intel_format_convert(coeffs->y_k_h[6], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 =
+            intel_format_convert(coeffs->y_k_h[7], 1, 6, 1);
+
+        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 =
+            intel_format_convert(coeffs->uv_k_h[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 =
+            intel_format_convert(coeffs->uv_k_h[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 =
+            intel_format_convert(coeffs->uv_k_h[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 =
+            intel_format_convert(coeffs->uv_k_h[3], 1, 6, 1);
+
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 =
+            intel_format_convert(coeffs->y_k_v[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 =
+            intel_format_convert(coeffs->y_k_v[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 =
+            intel_format_convert(coeffs->y_k_v[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 =
+            intel_format_convert(coeffs->y_k_v[3], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 =
+            intel_format_convert(coeffs->y_k_v[4], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 =
+            intel_format_convert(coeffs->y_k_v[5], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 =
+            intel_format_convert(coeffs->y_k_v[6], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 =
+            intel_format_convert(coeffs->y_k_v[7], 1, 6, 1);
+
+        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 =
+            intel_format_convert(coeffs->uv_k_v[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 =
+            intel_format_convert(coeffs->uv_k_v[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 =
+            intel_format_convert(coeffs->uv_k_v[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 =
+            intel_format_convert(coeffs->uv_k_v[3], 1, 6, 1);
     }
 
-    sampler_8x8_state->dw136.default_sharpness_level = 0;
-    sampler_8x8_state->dw137.adaptive_filter_for_all_channel = 1;
-    sampler_8x8_state->dw137.bypass_y_adaptive_filtering = 1;
-    sampler_8x8_state->dw137.bypass_x_adaptive_filtering = 1;
+    /* Adaptive filter for all channels (DW4.15) */
+    sampler_8x8_state->coefficients[0].dw4.table_1x_filter_c1 = 1U << 7;
+
+    sampler_8x8_state->dw136.default_sharpness_level =
+        -avs_is_needed(pp_context->filter_flags);
+    sampler_8x8_state->dw137.ilk.bypass_y_adaptive_filtering = 1;
+    sampler_8x8_state->dw137.ilk.bypass_x_adaptive_filtering = 1;
     dri_bo_unmap(pp_context->sampler_state_table.bo_8x8);
 
     /* sampler 8x8 */
@@ -2643,23 +2720,6 @@ pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context
 }
 
 static VAStatus
-pp_nv12_avs_initialize_nlas(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
-                            const struct i965_surface *src_surface,
-                            const VARectangle *src_rect,
-                            struct i965_surface *dst_surface,
-                            const VARectangle *dst_rect,
-                            void *filter_param)
-{
-    return pp_nv12_avs_initialize(ctx, pp_context,
-                                  src_surface,
-                                  src_rect,
-                                  dst_surface,
-                                  dst_rect,
-                                  filter_param,
-                                  1);
-}
-
-static VAStatus
 gen6_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
                              const struct i965_surface *src_surface,
                              const VARectangle *src_rect,
@@ -2672,8 +2732,7 @@ gen6_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_c
                                   src_rect,
                                   dst_surface,
                                   dst_rect,
-                                  filter_param,
-                                  0);    
+                                  filter_param);
 }
 
 static int
@@ -2740,6 +2799,8 @@ gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con
     int index, i;
     int width[3], height[3], pitch[3], offset[3];
     int src_width, src_height;
+    AVSState * const avs = &pp_avs_context->state;
+    float sx, sy;
 
     /* source surface */
     gen7_pp_set_media_rw_message_surface(ctx, pp_context, src_surface, 0, 0,
@@ -2760,50 +2821,79 @@ gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con
     sampler_8x8_state = pp_context->sampler_state_table.bo_8x8->virtual;
     memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
 
-    for (i = 0; i < 17; i++) {
-	float coff;
-	coff = i;
-	coff = coff / 16;
-        /* for Y channel, currently ignore */
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 = 0x0;
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 = 0x0;
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 = 0x0;
-        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 = intel_format_convert(1 - coff, 1, 6,0);
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 = intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 = 0x0;
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 = 0x0;
-        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 = 0x0;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 = 0x0;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 = 0x0;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 = 0x0;
-        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 = intel_format_convert(1 - coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 = intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 = 0x0;
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 = 0x0;
-        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 = 0x0;
-        /* for U/V channel, 0.25 */
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c0 = 0x0;
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c1 = 0x0;
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 = 0x0;
-        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 = intel_format_convert(1 - coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 = intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 = 0;
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c6 = 0x0;
-        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c7 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c0 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c1 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 = 0x0;
-        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 = intel_format_convert(1 - coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 = intel_format_convert(coff, 1, 6, 0);
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 = 0x0;
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c6 = 0x0;
-        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c7 = 0x0;
+    sx = (float)dst_rect->width / src_rect->width;
+    sy = (float)dst_rect->height / src_rect->height;
+    avs_update_coefficients(avs, sx, sy, pp_context->filter_flags);
+
+    assert(avs->config->num_phases == 16);
+    for (i = 0; i <= 16; i++) {
+        const AVSCoeffs * const coeffs = &avs->coeffs[i];
+
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 =
+            intel_format_convert(coeffs->y_k_h[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 =
+            intel_format_convert(coeffs->y_k_h[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 =
+            intel_format_convert(coeffs->y_k_h[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 =
+            intel_format_convert(coeffs->y_k_h[3], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 =
+            intel_format_convert(coeffs->y_k_h[4], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 =
+            intel_format_convert(coeffs->y_k_h[5], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 =
+            intel_format_convert(coeffs->y_k_h[6], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 =
+            intel_format_convert(coeffs->y_k_h[7], 1, 6, 1);
+
+        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 =
+            intel_format_convert(coeffs->uv_k_h[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 =
+            intel_format_convert(coeffs->uv_k_h[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 =
+            intel_format_convert(coeffs->uv_k_h[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 =
+            intel_format_convert(coeffs->uv_k_h[3], 1, 6, 1);
+
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 =
+            intel_format_convert(coeffs->y_k_v[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 =
+            intel_format_convert(coeffs->y_k_v[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 =
+            intel_format_convert(coeffs->y_k_v[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 =
+            intel_format_convert(coeffs->y_k_v[3], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 =
+            intel_format_convert(coeffs->y_k_v[4], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 =
+            intel_format_convert(coeffs->y_k_v[5], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 =
+            intel_format_convert(coeffs->y_k_v[6], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 =
+            intel_format_convert(coeffs->y_k_v[7], 1, 6, 1);
+
+        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 =
+            intel_format_convert(coeffs->uv_k_v[0], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 =
+            intel_format_convert(coeffs->uv_k_v[1], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 =
+            intel_format_convert(coeffs->uv_k_v[2], 1, 6, 1);
+        sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 =
+            intel_format_convert(coeffs->uv_k_v[3], 1, 6, 1);
     }
 
-    sampler_8x8_state->dw136.default_sharpness_level = 0;
-    sampler_8x8_state->dw137.adaptive_filter_for_all_channel = 1;
-    sampler_8x8_state->dw137.bypass_y_adaptive_filtering = 1;
-    sampler_8x8_state->dw137.bypass_x_adaptive_filtering = 1;
+    sampler_8x8_state->dw136.default_sharpness_level =
+        -avs_is_needed(pp_context->filter_flags);
+    if (IS_HASWELL(i965->intel.device_info)) {
+        sampler_8x8_state->dw137.hsw.adaptive_filter_for_all_channel = 1;
+        sampler_8x8_state->dw137.hsw.bypass_y_adaptive_filtering = 1;
+        sampler_8x8_state->dw137.hsw.bypass_x_adaptive_filtering = 1;
+    }
+    else {
+        sampler_8x8_state->coefficients[0].dw4.table_1x_filter_c1 = 1U << 7;
+        sampler_8x8_state->dw137.ilk.bypass_y_adaptive_filtering = 1;
+        sampler_8x8_state->dw137.ilk.bypass_x_adaptive_filtering = 1;
+    }
     dri_bo_unmap(pp_context->sampler_state_table.bo_8x8);
 
     /* sampler 8x8 */
@@ -4694,7 +4784,7 @@ i965_scaling_processing(
     const VARectangle *src_rect,
     struct object_surface *dst_surface_obj,
     const VARectangle *dst_rect,
-    unsigned int       flags)
+    unsigned int       va_flags)
 {
     VAStatus va_status = VA_STATUS_SUCCESS;
     struct i965_driver_data *i965 = i965_driver_data(ctx);
@@ -4702,9 +4792,11 @@ i965_scaling_processing(
     assert(src_surface_obj->fourcc == VA_FOURCC_NV12);
     assert(dst_surface_obj->fourcc == VA_FOURCC_NV12);
 
-    if (HAS_VPP(i965) && (flags & I965_PP_FLAG_AVS)) {
+    if (HAS_VPP(i965)) {
         struct i965_surface src_surface;
         struct i965_surface dst_surface;
+        struct i965_post_processing_context *pp_context;
+        unsigned int filter_flags;
 
          _i965LockMutex(&i965->pp_mutex);
 
@@ -4715,13 +4807,15 @@ i965_scaling_processing(
          dst_surface.type = I965_SURFACE_TYPE_SURFACE;
          dst_surface.flags = I965_SURFACE_FLAG_FRAME;
 
-         va_status = i965_post_processing_internal(ctx, i965->pp_context,
-                                                   &src_surface,
-                                                   src_rect,
-                                                   &dst_surface,
-                                                   dst_rect,
-                                                   PP_NV12_AVS,
-                                                   NULL);
+         pp_context = i965->pp_context;
+         filter_flags = pp_context->filter_flags;
+         pp_context->filter_flags = va_flags;
+
+         va_status = i965_post_processing_internal(ctx, pp_context,
+             &src_surface, src_rect, &dst_surface, dst_rect,
+             avs_is_needed(va_flags) ? PP_NV12_AVS : PP_NV12_SCALING, NULL);
+
+         pp_context->filter_flags = filter_flags;
 
          _i965UnlockMutex(&i965->pp_mutex);
     }
@@ -4735,8 +4829,9 @@ i965_post_processing(
     struct object_surface *obj_surface,
     const VARectangle *src_rect,
     const VARectangle *dst_rect,
-    unsigned int       flags,
-    int               *has_done_scaling  
+    unsigned int       va_flags,
+    int               *has_done_scaling,
+    VARectangle *calibrated_rect
 )
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
@@ -4749,6 +4844,7 @@ i965_post_processing(
         VAStatus status;
         struct i965_surface src_surface;
         struct i965_surface dst_surface;
+        struct i965_post_processing_context *pp_context;
 
         /* Currently only support post processing for NV12 surface */
         if (obj_surface->fourcc != VA_FOURCC_NV12)
@@ -4756,51 +4852,27 @@ i965_post_processing(
 
         _i965LockMutex(&i965->pp_mutex);
 
-        if (flags & I965_PP_FLAG_MCDI) {
-            src_surface.base = (struct object_base *)obj_surface;
-            src_surface.type = I965_SURFACE_TYPE_SURFACE;
-            src_surface.flags = (flags & I965_PP_FLAG_TOP_FIELD) ? 
-                I965_SURFACE_FLAG_TOP_FIELD_FIRST : I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST;
-
-            status = i965_CreateSurfaces(ctx,
-                                         obj_surface->orig_width,
-                                         obj_surface->orig_height,
-                                         VA_RT_FORMAT_YUV420,
-                                         1,
-                                         &out_surface_id);
-            assert(status == VA_STATUS_SUCCESS);
-            obj_surface = SURFACE(out_surface_id);
-            assert(obj_surface);
-            i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
-            i965_vpp_clear_surface(ctx, i965->pp_context, obj_surface, 0); 
-
-            dst_surface.base = (struct object_base *)obj_surface;
-            dst_surface.type = I965_SURFACE_TYPE_SURFACE;
-            dst_surface.flags = I965_SURFACE_FLAG_FRAME;
-
-            i965_post_processing_internal(ctx, i965->pp_context,
-                                          &src_surface,
-                                          src_rect,
-                                          &dst_surface,
-                                          dst_rect,
-                                          PP_NV12_DNDI,
-                                          NULL);
-        }
-
-        if (flags & I965_PP_FLAG_AVS) {
+        pp_context = i965->pp_context;
+        pp_context->filter_flags = va_flags;
+        if (avs_is_needed(va_flags)) {
+            VARectangle tmp_dst_rect;
             struct i965_render_state *render_state = &i965->render_state;
             struct intel_region *dest_region = render_state->draw_region;
 
             if (out_surface_id != VA_INVALID_ID)
                 tmp_id = out_surface_id;
 
+            tmp_dst_rect.x = 0;
+            tmp_dst_rect.y = 0;
+            tmp_dst_rect.width = dst_rect->width;
+            tmp_dst_rect.height = dst_rect->height;
             src_surface.base = (struct object_base *)obj_surface;
             src_surface.type = I965_SURFACE_TYPE_SURFACE;
             src_surface.flags = I965_SURFACE_FLAG_FRAME;
 
             status = i965_CreateSurfaces(ctx,
-                                         dest_region->width,
-                                         dest_region->height,
+                                         dst_rect->width,
+                                         dst_rect->height,
                                          VA_RT_FORMAT_YUV420,
                                          1,
                                          &out_surface_id);
@@ -4808,17 +4880,17 @@ i965_post_processing(
             obj_surface = SURFACE(out_surface_id);
             assert(obj_surface);
             i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
-            i965_vpp_clear_surface(ctx, i965->pp_context, obj_surface, 0); 
+            i965_vpp_clear_surface(ctx, pp_context, obj_surface, 0);
 
             dst_surface.base = (struct object_base *)obj_surface;
             dst_surface.type = I965_SURFACE_TYPE_SURFACE;
             dst_surface.flags = I965_SURFACE_FLAG_FRAME;
 
-            i965_post_processing_internal(ctx, i965->pp_context,
+            i965_post_processing_internal(ctx, pp_context,
                                           &src_surface,
                                           src_rect,
                                           &dst_surface,
-                                          dst_rect,
+                                          &tmp_dst_rect,
                                           PP_NV12_AVS,
                                           NULL);
 
@@ -4826,6 +4898,10 @@ i965_post_processing(
                 i965_DestroySurfaces(ctx, &tmp_id, 1);
                 
             *has_done_scaling = 1;
+            calibrated_rect->x = 0;
+            calibrated_rect->y = 0;
+            calibrated_rect->width = dst_rect->width;
+            calibrated_rect->height = dst_rect->height;
         }
 
         _i965UnlockMutex(&i965->pp_mutex);
@@ -5265,6 +5341,7 @@ i965_post_processing_context_init(VADriverContextP ctx,
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     int i;
     struct i965_post_processing_context *pp_context = data;
+    const AVSConfig *avs_config;
 
     if (IS_IRONLAKE(i965->intel.device_info)) {
 	pp_context->urb.size = i965->intel.device_info->urb_size;
@@ -5331,6 +5408,10 @@ i965_post_processing_context_init(VADriverContextP ctx,
     pp_context->pp_dndi_context.current_out_obj_surface = NULL;
     pp_context->pp_dndi_context.frame_order = -1;
     pp_context->batch = batch;
+
+    avs_config = IS_IRONLAKE(i965->intel.device_info) ? &gen5_avs_config :
+        &gen6_avs_config;
+    avs_init_state(&pp_context->pp_avs_context.state, avs_config);
 }
 
 bool
@@ -5578,13 +5659,13 @@ i965_proc_picture(VADriverContextP ctx,
                                       NULL);
     } else {
 
+        proc_context->pp_context.filter_flags = pipeline_param->filter_flags;
         i965_post_processing_internal(ctx, &proc_context->pp_context,
                                       &src_surface,
                                       &src_rect,
                                       &dst_surface,
                                       &dst_rect,
-                                      (pipeline_param->filter_flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC ?
-                                      PP_NV12_AVS : PP_NV12_SCALING,
+                                      avs_is_needed(pipeline_param->filter_flags) ? PP_NV12_AVS : PP_NV12_SCALING,
                                       NULL);
     }
 
diff --git a/src/i965_post_processing.h b/src/i965_post_processing.h
index f0a277e..d434527 100755
--- a/src/i965_post_processing.h
+++ b/src/i965_post_processing.h
@@ -29,12 +29,9 @@
 #ifndef __I965_POST_PROCESSING_H__
 #define __I965_POST_PROCESSING_H__
 
-#define MAX_PP_SURFACES                 48
+#include "i965_vpp_avs.h"
 
-#define I965_PP_FLAG_TOP_FIELD          1
-#define I965_PP_FLAG_BOTTOM_FIELD       2
-#define I965_PP_FLAG_MCDI               4
-#define I965_PP_FLAG_AVS                8
+#define MAX_PP_SURFACES                 48
 
 enum
 {
@@ -79,6 +76,7 @@ struct pp_scaling_context
 
 struct pp_avs_context
 {
+    AVSState state;
     int dest_x; /* in pixel */
     int dest_y; /* in pixel */
     int dest_w;
@@ -493,6 +491,15 @@ struct i965_post_processing_context
     struct pp_dn_context pp_dn_context;
     void *private_context; /* pointer to the current private context */
     void *pipeline_param;  /* pointer to the pipeline parameter */
+    /**
+     * \ref Extra filter flags used as a fast path.
+     *
+     * This corresponds to vaPutSurface() flags, for direct rendering,
+     * or to VAProcPipelineParameterBuffer.filter_flags when the VPP
+     * interfaces are used. In the latter case, this is just a copy of
+     * that field.
+     */
+    unsigned int filter_flags;
 
     int (*pp_x_steps)(void *private_context);
     int (*pp_y_steps)(void *private_context);
@@ -550,8 +557,9 @@ i965_post_processing(
     struct object_surface *obj_surface,
     const VARectangle *src_rect,
     const VARectangle *dst_rect,
-    unsigned int       flags,
-    int                *has_done_scaling 
+    unsigned int       va_flags,
+    int                *has_done_scaling,
+    VARectangle *calibrated_rect
 );
 
 VAStatus
@@ -561,7 +569,7 @@ i965_scaling_processing(
     const VARectangle *src_rect,
     struct object_surface *dst_surface_obj,
     const VARectangle *dst_rect,
-    unsigned int       flags
+    unsigned int       va_flags
 );
 
 VAStatus
diff --git a/src/i965_render.c b/src/i965_render.c
index 38f70eb..f941d1b 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -708,11 +708,11 @@ i965_render_set_surface_state(
 
     memset(ss, 0, sizeof(*ss));
 
-    switch (flags & (I965_PP_FLAG_TOP_FIELD|I965_PP_FLAG_BOTTOM_FIELD)) {
-    case I965_PP_FLAG_BOTTOM_FIELD:
+    switch (flags & (VA_TOP_FIELD|VA_BOTTOM_FIELD)) {
+    case VA_BOTTOM_FIELD:
         ss->ss0.vert_line_stride_ofs = 1;
         /* fall-through */
-    case I965_PP_FLAG_TOP_FIELD:
+    case VA_TOP_FIELD:
         ss->ss0.vert_line_stride = 1;
         height /= 2;
         break;
@@ -779,11 +779,11 @@ gen7_render_set_surface_state(
 
     memset(ss, 0, sizeof(*ss));
 
-    switch (flags & (I965_PP_FLAG_TOP_FIELD|I965_PP_FLAG_BOTTOM_FIELD)) {
-    case I965_PP_FLAG_BOTTOM_FIELD:
+    switch (flags & (VA_TOP_FIELD|VA_BOTTOM_FIELD)) {
+    case VA_BOTTOM_FIELD:
         ss->ss0.vert_line_stride_ofs = 1;
         /* fall-through */
-    case I965_PP_FLAG_TOP_FIELD:
+    case VA_TOP_FIELD:
         ss->ss0.vert_line_stride = 1;
         height /= 2;
         break;
@@ -3095,12 +3095,14 @@ intel_render_put_surface(
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct i965_render_state *render_state = &i965->render_state;
     int has_done_scaling = 0;
+    VARectangle calibrated_rect;
     VASurfaceID out_surface_id = i965_post_processing(ctx,
                                                       obj_surface,
                                                       src_rect,
                                                       dst_rect,
                                                       flags,
-                                                      &has_done_scaling);
+                                                      &has_done_scaling,
+                                                      &calibrated_rect);
 
     assert((!has_done_scaling) || (out_surface_id != VA_INVALID_ID));
 
@@ -3111,7 +3113,7 @@ intel_render_put_surface(
             obj_surface = new_obj_surface;
 
         if (has_done_scaling)
-            src_rect = dst_rect;
+            src_rect = &calibrated_rect;
     }
 
     render_state->render_put_surface(ctx, obj_surface, src_rect, dst_rect, flags);
diff --git a/src/i965_render.h b/src/i965_render.h
index fde398b..2114cad 100644
--- a/src/i965_render.h
+++ b/src/i965_render.h
@@ -71,8 +71,6 @@ struct i965_render_state
         dri_bo *bo;
     } curbe;
 
-    unsigned short interleaved_uv;
-    unsigned short inited;
     struct intel_region *draw_region;
 
     int pp_flag; /* 0: disable, 1: enable */
@@ -157,4 +155,6 @@ gen8_render_set_surface_scs(struct gen8_surface_state *ss);
 
 extern bool gen8_render_init(VADriverContextP ctx);
 
+extern bool gen9_render_init(VADriverContextP ctx);
+
 #endif /* _I965_RENDER_H_ */
diff --git a/src/i965_structs.h b/src/i965_structs.h
index 682dc2d..0650a79 100644
--- a/src/i965_structs.h
+++ b/src/i965_structs.h
@@ -841,13 +841,24 @@ struct i965_sampler_8x8_state
         unsigned int default_sharpness_level:8;
     } dw136;
 
-    struct {
-        unsigned int bit_field_name:1;
-        unsigned int adaptive_filter_for_all_channel:1;
-        unsigned int pad0:19;
-        unsigned int bypass_y_adaptive_filtering:1;
-        unsigned int bypass_x_adaptive_filtering:1;
-        unsigned int pad1:9;
+    union {
+        /* Ironlake, Sandybridge, Ivybridge (Gen5+) */
+        struct {
+            unsigned int pad0:21;
+            unsigned int bypass_y_adaptive_filtering:1;
+            unsigned int bypass_x_adaptive_filtering:1;
+            unsigned int pad1:9;
+        } ilk;
+
+        /* Haswell (Gen7.5+) */
+        struct {
+            unsigned int rgb_adaptive:1;
+            unsigned int adaptive_filter_for_all_channel:1;
+            unsigned int pad0:19;
+            unsigned int bypass_y_adaptive_filtering:1;
+            unsigned int bypass_x_adaptive_filtering:1;
+            unsigned int pad1:9;
+        } hsw;
     } dw137;
 };
 
@@ -1219,6 +1230,194 @@ struct gen8_surface_state2
     } ss7;
 };
 
+struct gen9_surface_state2
+{
+    struct {
+        unsigned int pad0:16;
+        unsigned int y_offset:4;
+        unsigned int x_offset:7;
+        unsigned int pad1:3;
+        unsigned int rotation:2;
+    } ss0;
+
+    struct {
+        unsigned int cbcr_pixel_offset_v_direction:2;
+        unsigned int picture_structure:2;
+        unsigned int width:14;
+        unsigned int height:14;
+    } ss1;
+
+    struct {
+        unsigned int tile_walk:1;
+        unsigned int tiled_surface:1;
+        unsigned int half_pitch_for_chroma:1;
+        unsigned int pitch:18;
+        unsigned int address_ctrl:1; /* clamp or mirror mode */
+        unsigned int memory_compression_enable:1;
+        unsigned int memory_compression_mode:1;
+        unsigned int cbcr_pixel_offset_v_direction_msb:1;
+        unsigned int cbcr_pixel_offset_u_direction:1;
+        unsigned int interleave_chroma:1;
+        unsigned int surface_format:5;
+    } ss2;
+
+    struct {
+        unsigned int y_offset_for_cb:14;
+        unsigned int pad0:2;
+        unsigned int x_offset_for_cb:14;
+        unsigned int pad1:2;
+    } ss3;
+
+    struct {
+        unsigned int y_offset_for_cr:15;
+        unsigned int pad0:1;
+        unsigned int x_offset_for_cr:14;
+        unsigned int pad1:2;
+    } ss4;
+
+    struct {
+        unsigned int surface_object_mocs:7;
+	unsigned int pad0:11;
+	unsigned int tr_mode:2;
+	unsigned int pad1:10;
+	unsigned int vert_line_stride_offset:1;
+	unsigned int vert_line_stride:1;
+    } ss5;
+
+    struct {
+        unsigned int base_addr;
+    } ss6;
+
+    struct {
+        unsigned int base_addr_high:16;
+	unsigned int pad0:16;
+    } ss7;
+};
+
+struct gen9_surface_state
+{
+    struct {
+        unsigned int pad0:6;
+        unsigned int media_boundary_pixel_mode:2;
+        unsigned int render_cache_read_write:1;
+        unsigned int sampler_l2bypass_disable:1;
+        unsigned int vert_line_stride_ofs:1;
+        unsigned int vert_line_stride:1;
+        unsigned int tile_walk:1;
+        unsigned int tiled_surface:1;
+        unsigned int horizontal_alignment:2;
+        /* Field 16 */
+        unsigned int vertical_alignment:2;
+        unsigned int surface_format:9;     /**< BRW_SURFACEFORMAT_x */
+        unsigned int astc_enable:1;
+        unsigned int is_array:1;
+        unsigned int surface_type:3;       /**< BRW_SURFACE_1D/2D/3D/CUBE */
+    } ss0;
+
+    struct {
+        unsigned int surface_qpitch:15;
+        unsigned int pad0:4;
+        unsigned int base_mip_level:5;
+        unsigned int surface_mocs:7;
+        unsigned int pad1:1;
+    } ss1;
+
+    struct {
+        unsigned int width:14;
+        unsigned int pad0:2;
+        unsigned int height:14;
+        unsigned int pad1:2;
+    } ss2;
+
+    struct {
+        unsigned int pitch:18;
+        unsigned int pad:3;
+        unsigned int depth:11;
+    } ss3;
+
+    struct {
+        unsigned int multisample_position_palette_index:3;
+        unsigned int num_multisamples:3;
+        unsigned int multisampled_surface_storage_format:1;
+        unsigned int render_target_view_extent:11;
+        unsigned int min_array_elt:11;
+        unsigned int rotation:2;
+        unsigned int force_ncmp_reduce_type:1;
+    } ss4;
+
+    struct {
+        unsigned int mip_count:4;
+        unsigned int min_lod:4;
+        unsigned int miptail_start_lod:4;
+        unsigned int pad0:2;
+        unsigned int coherence_type:1;
+        unsigned int pad1:3;
+        unsigned int tr_mode:2;
+        unsigned int ewa_disable_cube:1;
+        unsigned int y_offset:3;
+        unsigned int pad2:1;
+        unsigned int x_offset:7;
+    } ss5;
+
+    struct {
+        unsigned int y_offset_uv_plane:14;
+        unsigned int pad0:2;
+        unsigned int x_offset_uv_plane:14;
+        unsigned int pad1:1;
+        unsigned int separate_uv_plane:1;
+    } ss6;
+
+    struct {
+        unsigned int resource_min_lod:12;
+        unsigned int pad0:4;
+        unsigned int shader_chanel_select_a:3;
+        unsigned int shader_chanel_select_b:3;
+        unsigned int shader_chanel_select_g:3;
+        unsigned int shader_chanel_select_r:3;
+        unsigned int pad1:2;
+        unsigned int memory_compression_enable:1;
+        unsigned int memory_compression_mode:1;
+    } ss7;
+
+    struct {
+        unsigned int base_addr;
+    } ss8;
+
+    struct {
+        unsigned int base_addr_high;
+    } ss9;
+
+    struct {
+        unsigned int quilt_width:5;
+        unsigned int quilt_height:5;
+        unsigned int pad0:6;
+        unsigned int pad1:16;
+    } ss10;
+
+    struct {
+        unsigned int y_offset_v_plane:14;
+        unsigned int pad0:2;
+        unsigned int x_offset_v_plane:14;
+        unsigned int pad1:2;
+    } ss11;
+
+    struct {
+        unsigned int pad0;
+    } ss12;
+
+    struct {
+        unsigned int pad0;
+    } ss13;
+
+    struct {
+        unsigned int pad0;
+    } ss14;
+
+    struct {
+        unsigned int pad0;
+    } ss15;
+};
+
 struct gen8_sampler_state
 {
    struct
@@ -1800,6 +1999,61 @@ struct gen7_sampler_dndi
     } dw7;
 };
 
+struct gen8_sampler_8x8_avs_coefficients
+{
+    struct {
+        unsigned int table_0x_filter_c0:8;
+        unsigned int table_0y_filter_c0:8;
+        unsigned int table_0x_filter_c1:8;
+        unsigned int table_0y_filter_c1:8;
+    } dw0;
+
+    struct {
+        unsigned int table_0x_filter_c2:8;
+        unsigned int table_0y_filter_c2:8;
+        unsigned int table_0x_filter_c3:8;
+        unsigned int table_0y_filter_c3:8;
+    } dw1;
+
+    struct {
+        unsigned int table_0x_filter_c4:8;
+        unsigned int table_0y_filter_c4:8;
+        unsigned int table_0x_filter_c5:8;
+        unsigned int table_0y_filter_c5:8;
+    } dw2;
+
+    struct {
+        unsigned int table_0x_filter_c6:8;
+        unsigned int table_0y_filter_c6:8;
+        unsigned int table_0x_filter_c7:8;
+        unsigned int table_0y_filter_c7:8;
+    } dw3;
+
+    struct {
+        unsigned int pad0:16;
+        unsigned int table_1x_filter_c2:8;
+        unsigned int table_1x_filter_c3:8;
+    } dw4;
+
+    struct {
+        unsigned int table_1x_filter_c4:8;
+        unsigned int table_1x_filter_c5:8;
+        unsigned int pad0:16;
+    } dw5;
+
+    struct {
+        unsigned int pad0:16;
+        unsigned int table_1y_filter_c2:8;
+        unsigned int table_1y_filter_c3:8;
+    } dw6;
+
+    struct {
+        unsigned int table_1y_filter_c4:8;
+        unsigned int table_1y_filter_c5:8;
+        unsigned int pad0:16;
+    } dw7;
+};
+
 struct gen8_sampler_8x8_avs {
     struct {
         unsigned int gain_factor:6;
@@ -1920,7 +2174,7 @@ struct gen8_sampler_8x8_avs {
     } dw15;
 
     /* DW16-DW151 */
-    struct i965_sampler_8x8_coefficient coefficients[17];
+    struct gen8_sampler_8x8_avs_coefficients coefficients[17];
     
     struct {
         unsigned int transition_area_with_8_pixels:3;
@@ -1957,4 +2211,8 @@ struct gen8_sampler_8x8_avs {
 #define SURFACE_STATE_PADDED_SIZE_1_GEN8        ALIGN(sizeof(struct gen8_surface_state2), 32)
 #define SURFACE_STATE_PADDED_SIZE_GEN8          MAX(SURFACE_STATE_PADDED_SIZE_0_GEN8, SURFACE_STATE_PADDED_SIZE_1_GEN8)
 
+#define SURFACE_STATE_PADDED_SIZE_0_GEN9        ALIGN(sizeof(struct gen9_surface_state), 32)
+#define SURFACE_STATE_PADDED_SIZE_1_GEN9        ALIGN(sizeof(struct gen9_surface_state2), 32)
+#define SURFACE_STATE_PADDED_SIZE_GEN9          MAX(SURFACE_STATE_PADDED_SIZE_0_GEN9, SURFACE_STATE_PADDED_SIZE_1_GEN9)
+
 #endif /* _I965_STRUCTS_H_ */
diff --git a/src/i965_vpp_avs.c b/src/i965_vpp_avs.c
new file mode 100644
index 0000000..f6fe906
--- /dev/null
+++ b/src/i965_vpp_avs.c
@@ -0,0 +1,267 @@
+/*
+ * i965_vpp_avs.c - Adaptive Video Scaler (AVS) block
+ *
+ * Copyright (C) 2014 Intel Corporation
+ *   Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel's prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ */
+
+#include "sysdeps.h"
+#include <math.h>
+#include <va/va.h>
+#include "i965_vpp_avs.h"
+
+typedef void (*AVSGenCoeffsFunc)(float *coeffs, int num_coeffs, int phase,
+    int num_phases, float f);
+
+/* Initializes all coefficients to zero */
+static void
+avs_init_coeffs(float *coeffs, int num_coeffs)
+{
+#if defined(__STDC_IEC_559__) && (__STDC_IEC_559__ > 0)
+    memset(coeffs, 0, num_coeffs * sizeof(*coeffs));
+#else
+    int i;
+
+    for (i = 0; i < num_coeffs; i++)
+        coeffs[i] = 0.0f;
+#endif
+}
+
+/* Computes the sinc(x) function */
+static float
+avs_sinc(float x)
+{
+    if (x == 0.0f)
+        return 1.0f;
+    return sin(x * M_PI) / (x * M_PI);
+}
+
+/* Convolution kernel for linear interpolation */
+static float
+avs_kernel_linear(float x)
+{
+    const float abs_x = fabsf(x);
+
+    return abs_x < 1.0f ? 1 - abs_x : 0.0f;
+}
+
+/* Convolution kernel for Lanczos-based interpolation */
+static float
+avs_kernel_lanczos(float x, float a)
+{
+    const float abs_x = fabsf(x);
+
+    return abs_x < a ? avs_sinc(x) * avs_sinc(x / a) : 0.0f;
+}
+
+/* Truncates floating-point value towards an epsilon factor */
+static inline float
+avs_trunc_coeff(float x, float epsilon)
+{
+    return rintf(x / epsilon) * epsilon;
+}
+
+/* Normalize coefficients for one sample/direction */
+static void
+avs_normalize_coeffs_1(float *coeffs, int num_coeffs, float epsilon)
+{
+    float s, sum = 0.0;
+    int i, c, r, r1;
+
+    for (i = 0; i < num_coeffs; i++)
+        sum += coeffs[i];
+
+    if (sum < epsilon)
+        return;
+
+    s = 0.0;
+    for (i = 0; i < num_coeffs; i++)
+        s += (coeffs[i] = avs_trunc_coeff(coeffs[i] / sum, epsilon));
+
+    /* Distribute the remaining bits, while allocating more to the center */
+    c = num_coeffs/2;
+    c = c - (coeffs[c - 1] > coeffs[c]);
+
+    r = (1.0f - s) / epsilon;
+    r1 = r / 4;
+    if (coeffs[c + 1] == 0.0f)
+        coeffs[c] += r * epsilon;
+    else {
+        coeffs[c] += (r - 2*r1) * epsilon;
+        coeffs[c - 1] += r1 * epsilon;
+        coeffs[c + 1] += r1 * epsilon;
+    }
+}
+
+/* Normalize all coefficients so that their sum yields 1.0f */
+static void
+avs_normalize_coeffs(AVSCoeffs *coeffs, const AVSConfig *config)
+{
+    avs_normalize_coeffs_1(coeffs->y_k_h, config->num_luma_coeffs,
+        config->coeff_epsilon);
+    avs_normalize_coeffs_1(coeffs->y_k_v, config->num_luma_coeffs,
+        config->coeff_epsilon);
+    avs_normalize_coeffs_1(coeffs->uv_k_h, config->num_chroma_coeffs,
+        config->coeff_epsilon);
+    avs_normalize_coeffs_1(coeffs->uv_k_v, config->num_chroma_coeffs,
+        config->coeff_epsilon);
+}
+
+/* Validate coefficients for one sample/direction */
+static bool
+avs_validate_coeffs_1(float *coeffs, int num_coeffs, const float *min_coeffs,
+    const float *max_coeffs)
+{
+    int i;
+
+    for (i = 0; i < num_coeffs; i++) {
+        if (coeffs[i] < min_coeffs[i] || coeffs[i] > max_coeffs[i])
+            return false;
+    }
+    return true;
+}
+
+/* Validate coefficients wrt. the supplied range in config */
+static bool
+avs_validate_coeffs(AVSCoeffs *coeffs, const AVSConfig *config)
+{
+    const AVSCoeffs * const min_coeffs = &config->coeff_range.lower_bound;
+    const AVSCoeffs * const max_coeffs = &config->coeff_range.upper_bound;
+
+    return avs_validate_coeffs_1(coeffs->y_k_h, config->num_luma_coeffs,
+            min_coeffs->y_k_h, max_coeffs->y_k_h) &&
+        avs_validate_coeffs_1(coeffs->y_k_v, config->num_luma_coeffs,
+            min_coeffs->y_k_v, max_coeffs->y_k_v) &&
+        avs_validate_coeffs_1(coeffs->uv_k_h, config->num_chroma_coeffs,
+            min_coeffs->uv_k_h, max_coeffs->uv_k_h) &&
+        avs_validate_coeffs_1(coeffs->uv_k_v, config->num_chroma_coeffs,
+            min_coeffs->uv_k_v, max_coeffs->uv_k_v);
+}
+
+/* Generate coefficients for default quality (bilinear) */
+static void
+avs_gen_coeffs_linear(float *coeffs, int num_coeffs, int phase, int num_phases,
+    float f)
+{
+    const int c = num_coeffs/2 - 1;
+    const float p = (float)phase / (num_phases*2);
+
+    avs_init_coeffs(coeffs, num_coeffs);
+    coeffs[c] = avs_kernel_linear(p);
+    coeffs[c + 1] = avs_kernel_linear(p - 1);
+}
+
+/* Generate coefficients for high quality (lanczos) */
+static void
+avs_gen_coeffs_lanczos(float *coeffs, int num_coeffs, int phase, int num_phases,
+    float f)
+{
+    const int c = num_coeffs/2 - 1;
+    const int l = num_coeffs > 4 ? 3 : 2;
+    const float p = (float)phase / (num_phases*2);
+    int i;
+
+    if (f > 1.0f)
+        f = 1.0f;
+    for (i = 0; i < num_coeffs; i++)
+        coeffs[i] = avs_kernel_lanczos((i - (c + p)) * f, l);
+}
+
+/* Generate coefficients with the supplied scaler */
+static bool
+avs_gen_coeffs(AVSState *avs, float sx, float sy, AVSGenCoeffsFunc gen_coeffs)
+{
+    const AVSConfig * const config = avs->config;
+    int i;
+
+    for (i = 0; i <= config->num_phases; i++) {
+        AVSCoeffs * const coeffs = &avs->coeffs[i];
+
+        gen_coeffs(coeffs->y_k_h, config->num_luma_coeffs,
+            i, config->num_phases, sx);
+        gen_coeffs(coeffs->uv_k_h, config->num_chroma_coeffs,
+            i, config->num_phases, sx);
+        gen_coeffs(coeffs->y_k_v, config->num_luma_coeffs,
+            i, config->num_phases, sy);
+        gen_coeffs(coeffs->uv_k_v, config->num_chroma_coeffs,
+            i, config->num_phases, sy);
+
+        avs_normalize_coeffs(coeffs, config);
+        if (!avs_validate_coeffs(coeffs, config))
+            return false;
+    }
+    return true;
+}
+
+/* Initializes AVS state with the supplied configuration */
+void
+avs_init_state(AVSState *avs, const AVSConfig *config)
+{
+    avs->config = config;
+    avs->flags = 0;
+    avs->scale_x = 0.0f;
+    avs->scale_y = 0.0f;
+}
+
+/* Checks whether the AVS scaling parameters changed */
+static inline bool
+avs_params_changed(AVSState *avs, float sx, float sy, uint32_t flags)
+{
+    if (avs->flags != flags)
+        return true;
+
+    if (flags >= VA_FILTER_SCALING_HQ) {
+        if (avs->scale_x != sx || avs->scale_y != sy)
+            return true;
+    }
+    else {
+        if (avs->scale_x == 0.0f || avs->scale_y == 0.0f)
+            return true;
+    }
+    return false;
+}
+
+/* Updates AVS coefficients for the supplied factors and quality level */
+bool
+avs_update_coefficients(AVSState *avs, float sx, float sy, uint32_t flags)
+{
+    AVSGenCoeffsFunc gen_coeffs;
+
+    flags &= VA_FILTER_SCALING_MASK;
+    if (!avs_params_changed(avs, sx, sy, flags))
+        return true;
+
+    switch (flags) {
+    case VA_FILTER_SCALING_HQ:
+        gen_coeffs = avs_gen_coeffs_lanczos;
+        break;
+    default:
+        gen_coeffs = avs_gen_coeffs_linear;
+        break;
+    }
+    if (!avs_gen_coeffs(avs, sx, sy, gen_coeffs)) {
+        assert(0 && "invalid set of coefficients generated");
+        return false;
+    }
+
+    avs->flags = flags;
+    avs->scale_x = sx;
+    avs->scale_y = sy;
+    return true;
+}
diff --git a/src/i965_vpp_avs.h b/src/i965_vpp_avs.h
new file mode 100644
index 0000000..0b01c8f
--- /dev/null
+++ b/src/i965_vpp_avs.h
@@ -0,0 +1,109 @@
+/*
+ * i965_vpp_avs.h - Adaptive Video Scaler (AVS) block
+ *
+ * Copyright (C) 2014 Intel Corporation
+ *   Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel's prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ */
+
+#ifndef I965_VPP_AVS_H
+#define I965_VPP_AVS_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/** Maximum number of phases for the sharp filter */
+#define AVS_MAX_PHASES 16
+
+/** Maximum number of coefficients for luma samples */
+#define AVS_MAX_LUMA_COEFFS 8
+
+/** Maximum number of coefficients for chroma samples */
+#define AVS_MAX_CHROMA_COEFFS 4
+
+typedef struct avs_coeffs               AVSCoeffs;
+typedef struct avs_coeffs_range         AVSCoeffsRange;
+typedef struct avs_config               AVSConfig;
+typedef struct avs_state                AVSState;
+
+/** AVS coefficients for one phase */
+struct avs_coeffs {
+    /** Coefficients for luma samples on the X-axis (horizontal) */
+    float y_k_h[AVS_MAX_LUMA_COEFFS];
+    /** Coefficients for luma samples on the Y-axis (vertical) */
+    float y_k_v[AVS_MAX_LUMA_COEFFS];
+    /** Coefficients for chroma samples on the X-axis (horizontal) */
+    float uv_k_h[AVS_MAX_CHROMA_COEFFS];
+    /** Coefficients for chroma samples on the Y-axis (vertical) */
+    float uv_k_v[AVS_MAX_CHROMA_COEFFS];
+};
+
+/** AVS coefficients range used for validation */
+struct avs_coeffs_range {
+    /** Lower bound for all coefficients */
+    AVSCoeffs lower_bound;
+    /** Upper bound for all coefficients */
+    AVSCoeffs upper_bound;
+};
+
+/** Static configuration (per-generation) */
+struct avs_config {
+    /** Number of bits used for the fractional part of a coefficient */
+    int coeff_frac_bits;
+    /** The smallest float that could be represented as a coefficient */
+    float coeff_epsilon;
+    /** Coefficients range */
+    AVSCoeffsRange coeff_range;
+    /** Number of phases for the sharp filter */
+    int num_phases;
+    /** Number of coefficients for luma samples */
+    int num_luma_coeffs;
+    /** Number of coefficients for chroma samples */
+    int num_chroma_coeffs;
+};
+
+/** AVS block state */
+struct avs_state {
+    /** Per-generation configuration parameters */
+    const AVSConfig *config;
+    /** Scaling flags */
+    uint32_t flags;
+    /** Scaling factor on the X-axis (horizontal) */
+    float scale_x;
+    /** Scaling factor on the Y-axis (vertical) */
+    float scale_y;
+    /** Coefficients for the polyphase scaler */
+    AVSCoeffs coeffs[AVS_MAX_PHASES + 1];
+};
+
+/** Initializes AVS state with the supplied configuration */
+void
+avs_init_state(AVSState *avs, const AVSConfig *config);
+
+/** Updates AVS coefficients for the supplied factors and quality level */
+bool
+avs_update_coefficients(AVSState *avs, float sx, float sy, uint32_t flags);
+
+/** Checks whether AVS is needed, e.g. if high-quality scaling is requested */
+static inline bool
+avs_is_needed(uint32_t flags)
+{
+    return ((flags & VA_FILTER_SCALING_MASK) >= VA_FILTER_SCALING_HQ);
+}
+
+#endif /* I965_VPP_AVS_H */
diff --git a/src/intel_batchbuffer.c b/src/intel_batchbuffer.c
index c6d3769..60178c6 100644
--- a/src/intel_batchbuffer.c
+++ b/src/intel_batchbuffer.c
@@ -33,16 +33,25 @@
 
 #define MAX_BATCH_SIZE		0x400000
 
+
+#define LOCAL_I915_EXEC_BSD_MASK		(3<<13)
+#define LOCAL_I915_EXEC_BSD_DEFAULT		(0<<13)	/* default ping-pong mode */
+#define LOCAL_I915_EXEC_BSD_RING0		(1<<13)
+#define LOCAL_I915_EXEC_BSD_RING1		(2<<13)
+
 static void 
 intel_batchbuffer_reset(struct intel_batchbuffer *batch, int buffer_size)
 {
     struct intel_driver_data *intel = batch->intel; 
     int batch_size = buffer_size;
+    int ring_flag;
+
+    ring_flag = batch->flag & I915_EXEC_RING_MASK;
 
-    assert(batch->flag == I915_EXEC_RENDER ||
-           batch->flag == I915_EXEC_BLT ||
-           batch->flag == I915_EXEC_BSD ||
-           batch->flag == I915_EXEC_VEBOX);
+    assert(ring_flag == I915_EXEC_RENDER ||
+           ring_flag == I915_EXEC_BLT ||
+           ring_flag == I915_EXEC_BSD ||
+           ring_flag == I915_EXEC_VEBOX);
 
     dri_bo_unreference(batch->buffer);
     batch->buffer = dri_bo_alloc(intel->bufmgr, 
@@ -69,10 +78,13 @@ struct intel_batchbuffer *
 intel_batchbuffer_new(struct intel_driver_data *intel, int flag, int buffer_size)
 {
     struct intel_batchbuffer *batch = calloc(1, sizeof(*batch));
-    assert(flag == I915_EXEC_RENDER ||
-           flag == I915_EXEC_BSD ||
-           flag == I915_EXEC_BLT ||
-           flag == I915_EXEC_VEBOX);
+    int ring_flag;
+
+    ring_flag = flag & I915_EXEC_RING_MASK;
+    assert(ring_flag == I915_EXEC_RENDER ||
+           ring_flag == I915_EXEC_BSD ||
+           ring_flag == I915_EXEC_BLT ||
+           ring_flag == I915_EXEC_VEBOX);
 
    if (!buffer_size || buffer_size < BATCH_SIZE) {
 	buffer_size = BATCH_SIZE;
@@ -182,12 +194,16 @@ void
 intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
 {
     struct intel_driver_data *intel = batch->intel; 
+    int ring_flag;
+
+    ring_flag = batch->flag & I915_EXEC_RING_MASK;
 
     if (IS_GEN6(intel->device_info) ||
         IS_GEN7(intel->device_info) ||
-        IS_GEN8(intel->device_info)) {
-        if (batch->flag == I915_EXEC_RENDER) {
-            if (IS_GEN8(intel->device_info)) {
+        IS_GEN8(intel->device_info) ||
+        IS_GEN9(intel->device_info)) {
+        if (ring_flag == I915_EXEC_RENDER) {
+            if (IS_GEN8(intel->device_info) || IS_GEN9(intel->device_info)) {
                 BEGIN_BATCH(batch, 6);
                 OUT_BATCH(batch, CMD_PIPE_CONTROL | (6 - 2));
 
@@ -247,14 +263,14 @@ intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
             }
 
         } else {
-            if (batch->flag == I915_EXEC_BLT) {
+            if (ring_flag == I915_EXEC_BLT) {
                 BEGIN_BLT_BATCH(batch, 4);
                 OUT_BLT_BATCH(batch, MI_FLUSH_DW);
                 OUT_BLT_BATCH(batch, 0);
                 OUT_BLT_BATCH(batch, 0);
                 OUT_BLT_BATCH(batch, 0);
                 ADVANCE_BLT_BATCH(batch);
-            }else if (batch->flag == I915_EXEC_VEBOX) {
+            }else if (ring_flag == I915_EXEC_VEBOX) {
                 BEGIN_VEB_BATCH(batch, 4);
                 OUT_VEB_BATCH(batch, MI_FLUSH_DW);
                 OUT_VEB_BATCH(batch, 0);
@@ -262,7 +278,7 @@ intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
                 OUT_VEB_BATCH(batch, 0);
                 ADVANCE_VEB_BATCH(batch);
             } else {
-                assert(batch->flag == I915_EXEC_BSD);
+                assert(ring_flag == I915_EXEC_BSD);
                 BEGIN_BCS_BATCH(batch, 4);
                 OUT_BCS_BATCH(batch, MI_FLUSH_DW | MI_FLUSH_DW_VIDEO_PIPELINE_CACHE_INVALIDATE);
                 OUT_BCS_BATCH(batch, 0);
@@ -272,12 +288,12 @@ intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
             }
         }
     } else {
-        if (batch->flag == I915_EXEC_RENDER) {
+        if (ring_flag == I915_EXEC_RENDER) {
             BEGIN_BATCH(batch, 1);
             OUT_BATCH(batch, MI_FLUSH | MI_FLUSH_STATE_INSTRUCTION_CACHE_INVALIDATE);
             ADVANCE_BATCH(batch);		
          } else {
-            assert(batch->flag == I915_EXEC_BSD);
+            assert(ring_flag == I915_EXEC_BSD);
             BEGIN_BCS_BATCH(batch, 1);
             OUT_BCS_BATCH(batch, MI_FLUSH | MI_FLUSH_STATE_INSTRUCTION_CACHE_INVALIDATE);
             ADVANCE_BCS_BATCH(batch);
@@ -301,10 +317,14 @@ intel_batchbuffer_advance_batch(struct intel_batchbuffer *batch)
 void
 intel_batchbuffer_check_batchbuffer_flag(struct intel_batchbuffer *batch, int flag)
 {
-    if (flag != I915_EXEC_RENDER &&
-        flag != I915_EXEC_BLT &&
-        flag != I915_EXEC_BSD &&
-        flag != I915_EXEC_VEBOX)
+    int ring_flag;
+
+    ring_flag = flag & I915_EXEC_RING_MASK;
+
+    if (ring_flag != I915_EXEC_RENDER &&
+        ring_flag != I915_EXEC_BLT &&
+        ring_flag != I915_EXEC_BSD &&
+        ring_flag != I915_EXEC_VEBOX)
         return;
 
     if (batch->flag == flag)
@@ -355,6 +375,25 @@ intel_batchbuffer_start_atomic_veb(struct intel_batchbuffer *batch, unsigned int
     intel_batchbuffer_start_atomic_helper(batch, I915_EXEC_VEBOX, size);
 }
 
+void intel_batchbuffer_start_atomic_bcs_override(struct intel_batchbuffer *batch, unsigned int size,
+                                                 bsd_ring_flag override_flag)
+{
+    uint32_t ring_flag;
+
+    switch(override_flag) {
+    case BSD_RING0:
+        ring_flag = I915_EXEC_BSD + LOCAL_I915_EXEC_BSD_RING0;
+        break;
+    case BSD_RING1:
+        ring_flag = I915_EXEC_BSD + LOCAL_I915_EXEC_BSD_RING1;
+        break;
+    default:
+        ring_flag = I915_EXEC_BSD + LOCAL_I915_EXEC_BSD_DEFAULT;
+        break;
+    }
+    intel_batchbuffer_start_atomic_helper(batch, ring_flag, size);
+}
+
 
 void
 intel_batchbuffer_end_atomic(struct intel_batchbuffer *batch)
diff --git a/src/intel_batchbuffer.h b/src/intel_batchbuffer.h
index 34ff66d..41d359d 100644
--- a/src/intel_batchbuffer.h
+++ b/src/intel_batchbuffer.h
@@ -51,9 +51,18 @@ int intel_batchbuffer_check_free_space(struct intel_batchbuffer *batch, int size
 int intel_batchbuffer_used_size(struct intel_batchbuffer *batch);
 void intel_batchbuffer_align(struct intel_batchbuffer *batch, unsigned int alignedment);
 
+typedef enum {
+    BSD_DEFAULT,
+    BSD_RING0,
+    BSD_RING1,
+} bsd_ring_flag;
+
+void intel_batchbuffer_start_atomic_bcs_override(struct intel_batchbuffer *batch, unsigned int size,
+                                                 bsd_ring_flag override_flag);
+
 #define __BEGIN_BATCH(batch, n, f) do {                         \
-        assert(f == batch->flag);                               \
-        intel_batchbuffer_check_batchbuffer_flag(batch, f);     \
+        assert(f == (batch->flag & I915_EXEC_RING_MASK));                               \
+        intel_batchbuffer_check_batchbuffer_flag(batch, batch->flag);     \
         intel_batchbuffer_require_space(batch, (n) * 4);        \
         intel_batchbuffer_begin_batch(batch, (n));              \
     } while (0)
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 994e64c..2e6fae3 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -36,6 +36,14 @@
 #include "intel_driver.h"
 uint32_t g_intel_debug_option_flags = 0;
 
+#ifdef I915_PARAM_HAS_BSD2
+#define LOCAL_I915_PARAM_HAS_BSD2 I915_PARAM_HAS_BSD2
+#endif
+
+#ifndef LOCAL_I915_PARAM_HAS_BSD2
+#define LOCAL_I915_PARAM_HAS_BSD2	30
+#endif
+
 static Bool
 intel_driver_get_param(struct intel_driver_data *intel, int param, int *value)
 {
@@ -77,6 +85,7 @@ intel_driver_init(VADriverContextP ctx)
     struct drm_state * const drm_state = (struct drm_state *)ctx->drm_state;
     int has_exec2 = 0, has_bsd = 0, has_blt = 0, has_vebox = 0;
     char *env_str = NULL;
+    int ret_value = 0;
 
     g_intel_debug_option_flags = 0;
     if ((env_str = getenv("VA_INTEL_DEBUG")))
@@ -115,7 +124,11 @@ intel_driver_init(VADriverContextP ctx)
         intel->has_blt = has_blt;
     if (intel_driver_get_param(intel, I915_PARAM_HAS_VEBOX, &has_vebox))
         intel->has_vebox = !!has_vebox;
-   
+
+    intel->has_bsd2 = 0;
+    if (intel_driver_get_param(intel, LOCAL_I915_PARAM_HAS_BSD2, &ret_value))
+        intel->has_bsd2 = !!ret_value;
+
     intel_driver_get_revid(intel, &intel->revision);
     intel_memman_init(intel);
     return true;
diff --git a/src/intel_driver.h b/src/intel_driver.h
index 432a0d9..f45c787 100644
--- a/src/intel_driver.h
+++ b/src/intel_driver.h
@@ -71,6 +71,7 @@ struct intel_batchbuffer;
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
+#define CLAMP(min, max, a) ((a) < (min) ? (min) : ((a) > (max) ? (max) : (a)))
 
 #define Bool int
 #define True 1
@@ -154,6 +155,7 @@ struct intel_driver_data
     unsigned int has_bsd    : 1; /* Flag: has bitstream decoder for H.264? */
     unsigned int has_blt    : 1; /* Flag: has BLT unit? */
     unsigned int has_vebox  : 1; /* Flag: has VEBOX unit */
+    unsigned int has_bsd2   : 1; /* Flag: has the second BSD video ring unit */
 
     const struct intel_device_info *device_info;
 };
@@ -192,4 +194,6 @@ struct intel_region
 #define IS_CHERRYVIEW(device_info)      (device_info->is_cherryview)
 #define IS_GEN8(device_info)            (device_info->gen == 8)
 
+#define IS_GEN9(device_info)            (device_info->gen == 9)
+
 #endif /* _INTEL_DRIVER_H_ */
diff --git a/src/intel_media.h b/src/intel_media.h
index 55136d6..73a03c7 100644
--- a/src/intel_media.h
+++ b/src/intel_media.h
@@ -31,15 +31,20 @@
 #include <va/va.h>
 #include <intel_bufmgr.h>
 
+typedef struct gen_codec_surface GenCodecSurface;
 
+struct gen_codec_surface
+{
+    int frame_store_id;
+};
 
 typedef struct gen_avc_surface GenAvcSurface;
 struct gen_avc_surface
 {
+    GenCodecSurface base;
     dri_bo *dmv_top;
     dri_bo *dmv_bottom;
     int dmv_bottom_flag;
-    int frame_store_id; /* only used for H.264 on earlier generations (<HSW) */
 };
 
 extern void gen_free_avc_surface(void **data);
@@ -47,4 +52,13 @@ extern void gen_free_avc_surface(void **data);
 
 extern int intel_format_convert(float src, int out_int_bits, int out_frac_bits,int out_sign_flag);
 
+typedef struct gen_hevc_surface GenHevcSurface;
+struct gen_hevc_surface
+{
+    GenCodecSurface base;
+    dri_bo *motion_vector_temporal_bo;
+};
+
+extern void gen_free_hevc_surface(void **data);
+
 #endif /* INTEL_MEDIA_H */
diff --git a/src/intel_media_common.c b/src/intel_media_common.c
index 504f9d9..f0e1cae 100644
--- a/src/intel_media_common.c
+++ b/src/intel_media_common.c
@@ -82,3 +82,28 @@ int intel_format_convert(float src, int out_int_bits, int out_frac_bits,int out_
      }
      return output_value;
 }
+
+static pthread_mutex_t free_hevc_surface_lock = PTHREAD_MUTEX_INITIALIZER;
+
+void
+gen_free_hevc_surface(void **data)
+{
+    GenHevcSurface *hevc_surface;
+
+    pthread_mutex_lock(&free_hevc_surface_lock);
+
+    hevc_surface = *data;
+
+    if (!hevc_surface) {
+        pthread_mutex_unlock(&free_hevc_surface_lock);
+        return;
+    }
+
+    dri_bo_unreference(hevc_surface->motion_vector_temporal_bo);
+    hevc_surface->motion_vector_temporal_bo = NULL;
+
+    free(hevc_surface);
+    *data = NULL;
+
+    pthread_mutex_unlock(&free_hevc_surface_lock);
+}
diff --git a/src/i965_output_wayland.h b/src/intel_version.h
similarity index 76%
copy from src/i965_output_wayland.h
copy to src/intel_version.h
index 61ca39f..18ffb2b 100644
--- a/src/i965_output_wayland.h
+++ b/src/intel_version.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+ * Copyright (C) 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -8,11 +8,11 @@
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,15 +22,15 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef I965_OUTPUT_WAYLAND_H
-#define I965_OUTPUT_WAYLAND_H
-
-#include <stdbool.h>
+#ifndef INTEL_VERSION_H
+#define INTEL_VERSION_H
 
-bool
-i965_output_wayland_init(VADriverContextP ctx);
-
-void
-i965_output_wayland_terminate(VADriverContextP ctx);
+/**
+ * INTEL_DRIVER_GIT_VERSION:
+ *
+ * The full version identifier of libva-intel-driver, from a git
+ * repository, in string form (suitable for string concatenation).
+ */
+#define INTEL_DRIVER_GIT_VERSION "1.3.2-72-g2b002e2"
 
-#endif /* I965_OUTPUT_WAYLAND_H */
+#endif /* INTEL_VERSION_H */
diff --git a/src/i965_output_wayland.h b/src/intel_version.h.in
similarity index 75%
copy from src/i965_output_wayland.h
copy to src/intel_version.h.in
index 61ca39f..050e834 100644
--- a/src/i965_output_wayland.h
+++ b/src/intel_version.h.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+ * Copyright (C) 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -8,11 +8,11 @@
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,15 +22,15 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef I965_OUTPUT_WAYLAND_H
-#define I965_OUTPUT_WAYLAND_H
-
-#include <stdbool.h>
+#ifndef INTEL_VERSION_H
+#define INTEL_VERSION_H
 
-bool
-i965_output_wayland_init(VADriverContextP ctx);
-
-void
-i965_output_wayland_terminate(VADriverContextP ctx);
+/**
+ * INTEL_DRIVER_GIT_VERSION:
+ *
+ * The full version identifier of libva-intel-driver, from a git
+ * repository, in string form (suitable for string concatenation).
+ */
+#define INTEL_DRIVER_GIT_VERSION "@INTEL_DRIVER_GIT_VERSION@"
 
-#endif /* I965_OUTPUT_WAYLAND_H */
+#endif /* INTEL_VERSION_H */
diff --git a/src/shaders/Makefile.in b/src/shaders/Makefile.in
index 2584361..1c0bc12 100644
--- a/src/shaders/Makefile.in
+++ b/src/shaders/Makefile.in
@@ -200,6 +200,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -246,6 +247,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -254,8 +256,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/src/shaders/h264/Makefile.in b/src/shaders/h264/Makefile.in
index 6dc2c9c..01166a1 100644
--- a/src/shaders/h264/Makefile.in
+++ b/src/shaders/h264/Makefile.in
@@ -200,6 +200,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -246,6 +247,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -254,8 +256,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/src/shaders/h264/ildb/Makefile.in b/src/shaders/h264/ildb/Makefile.in
index e30dacb..7076c91 100644
--- a/src/shaders/h264/ildb/Makefile.in
+++ b/src/shaders/h264/ildb/Makefile.in
@@ -140,6 +140,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -186,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -194,8 +196,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/src/shaders/h264/mc/Makefile.am b/src/shaders/h264/mc/Makefile.am
index ecc3b2e..5170503 100644
--- a/src/shaders/h264/mc/Makefile.am
+++ b/src/shaders/h264/mc/Makefile.am
@@ -185,17 +185,17 @@ if HAVE_GEN4ASM
 	rm $*.g4m
 
 $(INTEL_MC_GEN5_ASM): $(INTEL_MC_ASM) $(INTEL_MC_INC) $(INTEL_ILDB_ASM)
-	$(AM_V_GEN)cpp -DDEV_ILK -DBOOTSTRAP -I ../ildb/ AllAVC.asm > _mc0.$@	&& \
-	../../gpp.py _mc0.$@ $@						&& \
-	$(GEN4ASM) -l list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $@	   \
+	$(AM_V_GEN)cpp -DDEV_ILK -DBOOTSTRAP -I $(srcdir)/../ildb/ $(srcdir)/AllAVC.asm > _mc0.$@	&& \
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _mc0.$@ $@			&& \
+	$(GEN4ASM) -l $(srcdir)/list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $@	   \
 		-o /dev/null						&& \
 	mv tmp.$(INTEL_MC_EXPORT_GEN5) $(INTEL_MC_EXPORT_GEN5)		&& \
-	cpp -DDEV_ILK -I ../ildb/ AllAVC.asm > _mc1.$@			&& \
-	../../gpp.py _mc1.$@ $@						&& \
+	cpp -DDEV_ILK -I $(srcdir)/../ildb/ $(srcdir)/AllAVC.asm > _mc1.$@	&& \
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _mc1.$@ $@			&& \
 	rm _mc0.$@ _mc1.$@
 
 $(INTEL_MC_G4B_GEN5): $(INTEL_MC_GEN5_ASM)
-	$(AM_V_GEN)$(GEN4ASM) -l list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $<	   \
+	$(AM_V_GEN)$(GEN4ASM) -l $(srcdir)/list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $<	   \
 		-o $@							&& \
 	cat tmp.$(INTEL_MC_EXPORT_GEN5) | sed "s/_IP/_IP_GEN5/g"	   \
 		> $(INTEL_MC_EXPORT_GEN5)				&& \
diff --git a/src/shaders/h264/mc/Makefile.in b/src/shaders/h264/mc/Makefile.in
index 26f581b..1da9ab8 100644
--- a/src/shaders/h264/mc/Makefile.in
+++ b/src/shaders/h264/mc/Makefile.in
@@ -141,6 +141,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -195,8 +197,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -638,17 +638,17 @@ all-local: $(TARGETS)
 @HAVE_GEN4ASM_TRUE@	rm $*.g4m
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_MC_GEN5_ASM): $(INTEL_MC_ASM) $(INTEL_MC_INC) $(INTEL_ILDB_ASM)
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -DDEV_ILK -DBOOTSTRAP -I ../ildb/ AllAVC.asm > _mc0.$@	&& \
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _mc0.$@ $@						&& \
- at HAVE_GEN4ASM_TRUE@	$(GEN4ASM) -l list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $@	   \
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -DDEV_ILK -DBOOTSTRAP -I $(srcdir)/../ildb/ $(srcdir)/AllAVC.asm > _mc0.$@	&& \
+ at HAVE_GEN4ASM_TRUE@	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _mc0.$@ $@			&& \
+ at HAVE_GEN4ASM_TRUE@	$(GEN4ASM) -l $(srcdir)/list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $@	   \
 @HAVE_GEN4ASM_TRUE@		-o /dev/null						&& \
 @HAVE_GEN4ASM_TRUE@	mv tmp.$(INTEL_MC_EXPORT_GEN5) $(INTEL_MC_EXPORT_GEN5)		&& \
- at HAVE_GEN4ASM_TRUE@	cpp -DDEV_ILK -I ../ildb/ AllAVC.asm > _mc1.$@			&& \
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _mc1.$@ $@						&& \
+ at HAVE_GEN4ASM_TRUE@	cpp -DDEV_ILK -I $(srcdir)/../ildb/ $(srcdir)/AllAVC.asm > _mc1.$@	&& \
+ at HAVE_GEN4ASM_TRUE@	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _mc1.$@ $@			&& \
 @HAVE_GEN4ASM_TRUE@	rm _mc0.$@ _mc1.$@
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_MC_G4B_GEN5): $(INTEL_MC_GEN5_ASM)
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -l list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $<	   \
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -l $(srcdir)/list -a -e tmp.$(INTEL_MC_EXPORT_GEN5) -g 5 $<	   \
 @HAVE_GEN4ASM_TRUE@		-o $@							&& \
 @HAVE_GEN4ASM_TRUE@	cat tmp.$(INTEL_MC_EXPORT_GEN5) | sed "s/_IP/_IP_GEN5/g"	   \
 @HAVE_GEN4ASM_TRUE@		> $(INTEL_MC_EXPORT_GEN5)				&& \
diff --git a/src/shaders/mpeg2/Makefile.in b/src/shaders/mpeg2/Makefile.in
index a6a0e47..4a6803e 100644
--- a/src/shaders/mpeg2/Makefile.in
+++ b/src/shaders/mpeg2/Makefile.in
@@ -200,6 +200,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -246,6 +247,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -254,8 +256,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/src/shaders/mpeg2/vld/Makefile.am b/src/shaders/mpeg2/vld/Makefile.am
index bf718e0..37955dc 100644
--- a/src/shaders/mpeg2/vld/Makefile.am
+++ b/src/shaders/mpeg2/vld/Makefile.am
@@ -102,7 +102,7 @@ SUFFIXES = .g4a .g4s .g4b .g4b.gen5
 if HAVE_GEN4ASM
 $(INTEL_G4S): $(INTEL_G4A) $(INTEL_G4I)
 .g4a.g4s:
-	$(AM_V_GEN)m4 $< > $@
+	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 .g4s.g4b:
 	$(AM_V_GEN)$(GEN4ASM) -o $@ $<
 .g4s.g4b.gen5:
diff --git a/src/shaders/mpeg2/vld/Makefile.in b/src/shaders/mpeg2/vld/Makefile.in
index c0a74b7..682c9ca 100644
--- a/src/shaders/mpeg2/vld/Makefile.in
+++ b/src/shaders/mpeg2/vld/Makefile.in
@@ -141,6 +141,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -195,8 +197,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -553,7 +553,7 @@ all-local: $(TARGETS)
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_G4S): $(INTEL_G4A) $(INTEL_G4I)
 @HAVE_GEN4ASM_TRUE at .g4a.g4s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 $< > $@
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 @HAVE_GEN4ASM_TRUE at .g4s.g4b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -o $@ $<
 @HAVE_GEN4ASM_TRUE at .g4s.g4b.gen5:
diff --git a/src/shaders/post_processing/Makefile.am b/src/shaders/post_processing/Makefile.am
index 0f5c2bf..8901a2c 100644
--- a/src/shaders/post_processing/Makefile.am
+++ b/src/shaders/post_processing/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = gen5_6 gen7 gen75 gen8
+SUBDIRS = gen5_6 gen7 gen75 gen8 gen9
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/shaders/post_processing/Makefile.in b/src/shaders/post_processing/Makefile.in
index bfb3a42..f4e69cc 100644
--- a/src/shaders/post_processing/Makefile.in
+++ b/src/shaders/post_processing/Makefile.in
@@ -200,6 +200,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -246,6 +247,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -254,8 +256,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -310,7 +310,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 wayland_protocoldir = @wayland_protocoldir@
 wayland_scanner = @wayland_scanner@
-SUBDIRS = gen5_6 gen7 gen75 gen8
+SUBDIRS = gen5_6 gen7 gen75 gen8 gen9
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/shaders/post_processing/gen5_6/Makefile.am b/src/shaders/post_processing/gen5_6/Makefile.am
index 4a13d9d..cb47880 100755
--- a/src/shaders/post_processing/gen5_6/Makefile.am
+++ b/src/shaders/post_processing/gen5_6/Makefile.am
@@ -199,16 +199,16 @@ $(INTEL_G4B): $(INTEL_G4I)
 
 $(INTEL_PP_GEN5_ASM): $(INTEL_PP_ASM)
 .asm.g5s:
-	$(AM_V_GEN)cpp -D DEV_ILK -I Common/ -I Core_Kernels $< > _pp0.$@; \
-	../../gpp.py _pp0.$@ $@; \
+	$(AM_V_GEN)cpp -D DEV_ILK -I $(srcdir)/Common/ -I $(srcdir)/Core_Kernels $< > _pp0.$@; \
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@; \
 	rm _pp0.$@
 .g5s.g4b.gen5:
 	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 5 $<
 
 $(INTEL_PP_GEN6_ASM): $(INTEL_PP_ASM)
 .asm.g6s:
-	$(AM_V_GEN)cpp -D GT -I Common/ -I Core_Kernels $< > _pp0.$@; \
-	../../gpp.py _pp0.$@ $@; \
+	$(AM_V_GEN)cpp -D GT -I $(srcdir)/Common/ -I $(srcdir)/Core_Kernels $< > _pp0.$@; \
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@; \
 	rm _pp0.$@
 .g6s.g6b:
 	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 6 $<
diff --git a/src/shaders/post_processing/gen5_6/Makefile.in b/src/shaders/post_processing/gen5_6/Makefile.in
index 706852f..f3c952f 100644
--- a/src/shaders/post_processing/gen5_6/Makefile.in
+++ b/src/shaders/post_processing/gen5_6/Makefile.in
@@ -141,6 +141,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -195,8 +197,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -610,16 +610,16 @@ all-local: $(TARGETS)
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_PP_GEN5_ASM): $(INTEL_PP_ASM)
 @HAVE_GEN4ASM_TRUE at .asm.g5s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -D DEV_ILK -I Common/ -I Core_Kernels $< > _pp0.$@; \
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _pp0.$@ $@; \
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -D DEV_ILK -I $(srcdir)/Common/ -I $(srcdir)/Core_Kernels $< > _pp0.$@; \
+ at HAVE_GEN4ASM_TRUE@	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@; \
 @HAVE_GEN4ASM_TRUE@	rm _pp0.$@
 @HAVE_GEN4ASM_TRUE at .g5s.g4b.gen5:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 5 $<
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_PP_GEN6_ASM): $(INTEL_PP_ASM)
 @HAVE_GEN4ASM_TRUE at .asm.g6s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -D GT -I Common/ -I Core_Kernels $< > _pp0.$@; \
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _pp0.$@ $@; \
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -D GT -I $(srcdir)/Common/ -I $(srcdir)/Core_Kernels $< > _pp0.$@; \
+ at HAVE_GEN4ASM_TRUE@	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@; \
 @HAVE_GEN4ASM_TRUE@	rm _pp0.$@
 @HAVE_GEN4ASM_TRUE at .g6s.g6b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 6 $<
diff --git a/src/shaders/post_processing/gen7/Makefile.am b/src/shaders/post_processing/gen7/Makefile.am
index f4e2a8d..d76f7db 100644
--- a/src/shaders/post_processing/gen7/Makefile.am
+++ b/src/shaders/post_processing/gen7/Makefile.am
@@ -86,7 +86,7 @@ if HAVE_GEN4ASM
 $(INTEL_PP_GEN7_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G4A)
 .asm.g7s:
 	$(AM_V_GEN)cpp $< > _pp0.$@;		\
-	../../gpp.py _pp0.$@ $@;	\
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@;	\
 	rm _pp0.$@
 .g7s.g7b:
 	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 7 $<
diff --git a/src/shaders/post_processing/gen7/Makefile.in b/src/shaders/post_processing/gen7/Makefile.in
index 8e6d973..17a26a9 100644
--- a/src/shaders/post_processing/gen7/Makefile.in
+++ b/src/shaders/post_processing/gen7/Makefile.in
@@ -141,6 +141,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -195,8 +197,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -537,7 +537,7 @@ all-local: $(TARGETS)
 @HAVE_GEN4ASM_TRUE@$(INTEL_PP_GEN7_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G4A)
 @HAVE_GEN4ASM_TRUE at .asm.g7s:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp $< > _pp0.$@;		\
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _pp0.$@ $@;	\
+ at HAVE_GEN4ASM_TRUE@	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@;	\
 @HAVE_GEN4ASM_TRUE@	rm _pp0.$@
 @HAVE_GEN4ASM_TRUE at .g7s.g7b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 7 $<
diff --git a/src/shaders/post_processing/gen75/Makefile.in b/src/shaders/post_processing/gen75/Makefile.in
index 559e2cd..26f5363 100644
--- a/src/shaders/post_processing/gen75/Makefile.in
+++ b/src/shaders/post_processing/gen75/Makefile.in
@@ -140,6 +140,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -186,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -194,8 +196,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/src/shaders/post_processing/gen8/Makefile.am b/src/shaders/post_processing/gen8/Makefile.am
index 54533fc..475beb9 100644
--- a/src/shaders/post_processing/gen8/Makefile.am
+++ b/src/shaders/post_processing/gen8/Makefile.am
@@ -61,7 +61,7 @@ if HAVE_GEN4ASM
 $(INTEL_PP_GEN8_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G8A)
 .asm.g8s:
 	$(AM_V_GEN)cpp $< > _pp0.$@;		\
-	../../gpp.py _pp0.$@ $@;	\
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@;	\
 	rm _pp0.$@
 .g8s.g8b:
 	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 8 $<
diff --git a/src/shaders/post_processing/gen8/Makefile.in b/src/shaders/post_processing/gen8/Makefile.in
index 31dfd56..f9cfb99 100644
--- a/src/shaders/post_processing/gen8/Makefile.in
+++ b/src/shaders/post_processing/gen8/Makefile.in
@@ -141,6 +141,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -195,8 +197,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -512,7 +512,7 @@ all-local: $(TARGETS)
 @HAVE_GEN4ASM_TRUE@$(INTEL_PP_GEN8_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G8A)
 @HAVE_GEN4ASM_TRUE at .asm.g8s:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp $< > _pp0.$@;		\
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _pp0.$@ $@;	\
+ at HAVE_GEN4ASM_TRUE@	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@;	\
 @HAVE_GEN4ASM_TRUE@	rm _pp0.$@
 @HAVE_GEN4ASM_TRUE at .g8s.g8b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 8 $<
diff --git a/src/shaders/post_processing/gen8/Makefile.am b/src/shaders/post_processing/gen9/Makefile.am
similarity index 52%
copy from src/shaders/post_processing/gen8/Makefile.am
copy to src/shaders/post_processing/gen9/Makefile.am
index 54533fc..1e32dff 100644
--- a/src/shaders/post_processing/gen8/Makefile.am
+++ b/src/shaders/post_processing/gen9/Makefile.am
@@ -1,21 +1,19 @@
-INTEL_PP_G8B = \
-	pl2_to_pl2.g8b		\
-	pl2_to_pl3.g8b		\
-	pl3_to_pl2.g8b		\
-	pl3_to_pl3.g8b		\
-	pl2_to_rgbx.g8b		\
-	rgbx_to_nv12.g8b	\
-	pl2_to_pa.g8b		\
-	pl3_to_pa.g8b		\
-	pa_to_pl2.g8b		\
-	pa_to_pl3.g8b		\
-	pa_to_pa.g8b		\
-	$(NULL)
+SRCDIR = $(top_srcdir)/src/shaders/post_processing/gen8
+VPATH = $(SRCDIR)
 
-INTEL_PP_PRE_G8B =		\
-	sharpening_h_blur.g8b	\
-	sharpening_unmask.g8b	\
-	sharpening_v_blur.g8b
+INTEL_PP_G9B = \
+	pl2_to_pl2.g9b		\
+	pl2_to_pl3.g9b		\
+	pl3_to_pl2.g9b		\
+	pl3_to_pl3.g9b		\
+	pl2_to_rgbx.g9b		\
+	rgbx_to_nv12.g9b	\
+	pl2_to_pa.g9b		\
+	pl3_to_pa.g9b		\
+	pa_to_pl2.g9b		\
+	pa_to_pl3.g9b		\
+	pa_to_pa.g9b		\
+	$(NULL)
 
 INTEL_PP_G8A = \
 	EOT.g8a				\
@@ -45,35 +43,32 @@ INTEL_PP_G8A = \
 	VP_Setup.g8a			\
 	$(NULL)
 
-INTEL_PP_ASM = $(INTEL_PP_G8B:%.g8b=%.asm)
-INTEL_PP_GEN8_ASM = $(INTEL_PP_G8B:%.g8b=%.g8s)
+INTEL_PP_G9A = $(INTEL_PP_G8A)
+INTEL_PP_ASM = $(INTEL_PP_G9B:%.g9b=%.asm)
+INTEL_PP_GEN9_ASM = $(INTEL_PP_G9B:%.g9b=%.g9s)
 
 TARGETS  =
 if HAVE_GEN4ASM
-TARGETS += $(INTEL_PP_G8B)
+TARGETS += $(INTEL_PP_G9B)
 endif
 
 all-local: $(TARGETS)
 
-SUFFIXES = .g8b .g8s .asm
+SUFFIXES = .g9b .g9s .asm
 
-if HAVE_GEN4ASM
-$(INTEL_PP_GEN8_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G8A)
-.asm.g8s:
+$(INTEL_PP_GEN9_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G9A)
+.asm.g9s:
 	$(AM_V_GEN)cpp $< > _pp0.$@;		\
-	../../gpp.py _pp0.$@ $@;	\
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@;	\
 	rm _pp0.$@
-.g8s.g8b:
-	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 8 $<
-endif
+.g9s.g9b:
+	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 9 $<
 
-CLEANFILES = $(INTEL_PP_GEN7_ASM)
+CLEANFILES = $(INTEL_PP_GEN9_ASM)
 
 EXTRA_DIST = \
-	$(INTEL_PP_ASM)	\
-	$(INTEL_PP_G8A)	\
-	$(INTEL_PP_G8B) \
-	$(INTEL_PP_PRE_G8B)
+	$(INTEL_PP_G9B) \
+	$(NULL)
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/shaders/post_processing/gen8/Makefile.in b/src/shaders/post_processing/gen9/Makefile.in
similarity index 91%
copy from src/shaders/post_processing/gen8/Makefile.in
copy to src/shaders/post_processing/gen9/Makefile.in
index 31dfd56..6d5cbd9 100644
--- a/src/shaders/post_processing/gen8/Makefile.in
+++ b/src/shaders/post_processing/gen9/Makefile.in
@@ -13,7 +13,6 @@
 # PARTICULAR PURPOSE.
 
 @SET_MAKE@
-VPATH = @srcdir@
 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
 am__make_running_with_option = \
   case $${target_option-} in \
@@ -77,8 +76,8 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
- at HAVE_GEN4ASM_TRUE@am__append_1 = $(INTEL_PP_G8B)
-subdir = src/shaders/post_processing/gen8
+ at HAVE_GEN4ASM_TRUE@am__append_1 = $(INTEL_PP_G9B)
+subdir = src/shaders/post_processing/gen9
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@@ -109,6 +108,7 @@ am__can_run_installinfo = \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+VPATH = $(SRCDIR)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
@@ -141,6 +141,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -195,8 +197,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -251,25 +251,21 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 wayland_protocoldir = @wayland_protocoldir@
 wayland_scanner = @wayland_scanner@
-INTEL_PP_G8B = \
-	pl2_to_pl2.g8b		\
-	pl2_to_pl3.g8b		\
-	pl3_to_pl2.g8b		\
-	pl3_to_pl3.g8b		\
-	pl2_to_rgbx.g8b		\
-	rgbx_to_nv12.g8b	\
-	pl2_to_pa.g8b		\
-	pl3_to_pa.g8b		\
-	pa_to_pl2.g8b		\
-	pa_to_pl3.g8b		\
-	pa_to_pa.g8b		\
+SRCDIR = $(top_srcdir)/src/shaders/post_processing/gen8
+INTEL_PP_G9B = \
+	pl2_to_pl2.g9b		\
+	pl2_to_pl3.g9b		\
+	pl3_to_pl2.g9b		\
+	pl3_to_pl3.g9b		\
+	pl2_to_rgbx.g9b		\
+	rgbx_to_nv12.g9b	\
+	pl2_to_pa.g9b		\
+	pl3_to_pa.g9b		\
+	pa_to_pl2.g9b		\
+	pa_to_pl3.g9b		\
+	pa_to_pa.g9b		\
 	$(NULL)
 
-INTEL_PP_PRE_G8B = \
-	sharpening_h_blur.g8b	\
-	sharpening_unmask.g8b	\
-	sharpening_v_blur.g8b
-
 INTEL_PP_G8A = \
 	EOT.g8a				\
 	PL2_AVS_Buf_0.g8a		\
@@ -298,16 +294,15 @@ INTEL_PP_G8A = \
 	VP_Setup.g8a			\
 	$(NULL)
 
-INTEL_PP_ASM = $(INTEL_PP_G8B:%.g8b=%.asm)
-INTEL_PP_GEN8_ASM = $(INTEL_PP_G8B:%.g8b=%.g8s)
+INTEL_PP_G9A = $(INTEL_PP_G8A)
+INTEL_PP_ASM = $(INTEL_PP_G9B:%.g9b=%.asm)
+INTEL_PP_GEN9_ASM = $(INTEL_PP_G9B:%.g9b=%.g9s)
 TARGETS = $(am__append_1)
-SUFFIXES = .g8b .g8s .asm
-CLEANFILES = $(INTEL_PP_GEN7_ASM)
+SUFFIXES = .g9b .g9s .asm
+CLEANFILES = $(INTEL_PP_GEN9_ASM)
 EXTRA_DIST = \
-	$(INTEL_PP_ASM)	\
-	$(INTEL_PP_G8A)	\
-	$(INTEL_PP_G8B) \
-	$(INTEL_PP_PRE_G8B)
+	$(INTEL_PP_G9B) \
+	$(NULL)
 
 
 # Extra clean files so that maintainer-clean removes *everything*
@@ -315,7 +310,7 @@ MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .g8b .g8s .asm
+.SUFFIXES: .g9b .g9s .asm
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -325,9 +320,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/shaders/post_processing/gen8/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/shaders/post_processing/gen9/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign src/shaders/post_processing/gen8/Makefile
+	  $(AUTOMAKE) --foreign src/shaders/post_processing/gen9/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -509,13 +504,13 @@ uninstall-am:
 
 all-local: $(TARGETS)
 
- at HAVE_GEN4ASM_TRUE@$(INTEL_PP_GEN8_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G8A)
- at HAVE_GEN4ASM_TRUE@.asm.g8s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp $< > _pp0.$@;		\
- at HAVE_GEN4ASM_TRUE@	../../gpp.py _pp0.$@ $@;	\
- at HAVE_GEN4ASM_TRUE@	rm _pp0.$@
- at HAVE_GEN4ASM_TRUE@.g8s.g8b:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 8 $<
+$(INTEL_PP_GEN9_ASM): $(INTEL_PP_ASM) $(INTEL_PP_G9A)
+.asm.g9s:
+	$(AM_V_GEN)cpp $< > _pp0.$@;		\
+	$(PYTHON2) $(top_srcdir)/src/shaders/gpp.py _pp0.$@ $@;	\
+	rm _pp0.$@
+.g9s.g9b:
+	$(AM_V_GEN)$(GEN4ASM) -a -o $@ -g 9 $<
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/shaders/post_processing/gen8/pa_to_pa.g8b b/src/shaders/post_processing/gen9/pa_to_pa.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pa_to_pa.g8b
copy to src/shaders/post_processing/gen9/pa_to_pa.g9b
index 76fe27a..fe18a9e 100644
--- a/src/shaders/post_processing/gen8/pa_to_pa.g8b
+++ b/src/shaders/post_processing/gen9/pa_to_pa.g9b
@@ -276,4 +276,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x060a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x060a8018 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pa_to_pl2.g8b b/src/shaders/post_processing/gen9/pa_to_pl2.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pa_to_pl2.g8b
copy to src/shaders/post_processing/gen9/pa_to_pl2.g9b
index 3282c51..15235d7 100644
--- a/src/shaders/post_processing/gen8/pa_to_pl2.g8b
+++ b/src/shaders/post_processing/gen9/pa_to_pl2.g9b
@@ -233,4 +233,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x120a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x0a0a8019 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pa_to_pl3.g8b b/src/shaders/post_processing/gen9/pa_to_pl3.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pa_to_pl3.g8b
copy to src/shaders/post_processing/gen9/pa_to_pl3.g9b
index 3d1d087..3577887 100644
--- a/src/shaders/post_processing/gen8/pa_to_pl3.g8b
+++ b/src/shaders/post_processing/gen9/pa_to_pl3.g9b
@@ -186,4 +186,4 @@
    { 0x0c000031, 0x20002220, 0x060004a0, 0x060a8019 },
    { 0x0c000031, 0x20002220, 0x060005c0, 0x060a801a },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl2_to_pa.g8b b/src/shaders/post_processing/gen9/pl2_to_pa.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl2_to_pa.g8b
copy to src/shaders/post_processing/gen9/pl2_to_pa.g9b
index 0c0cda1..9a41961 100644
--- a/src/shaders/post_processing/gen8/pl2_to_pa.g8b
+++ b/src/shaders/post_processing/gen9/pl2_to_pa.g9b
@@ -284,4 +284,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x060a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x060a8018 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl2_to_pl2.g8b b/src/shaders/post_processing/gen9/pl2_to_pl2.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl2_to_pl2.g8b
copy to src/shaders/post_processing/gen9/pl2_to_pl2.g9b
index fa72882..de6637c 100644
--- a/src/shaders/post_processing/gen8/pl2_to_pl2.g8b
+++ b/src/shaders/post_processing/gen9/pl2_to_pl2.g9b
@@ -241,4 +241,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x120a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x0a0a8019 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl2_to_pl3.g8b b/src/shaders/post_processing/gen9/pl2_to_pl3.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl2_to_pl3.g8b
copy to src/shaders/post_processing/gen9/pl2_to_pl3.g9b
index 28a951c..106d615 100644
--- a/src/shaders/post_processing/gen8/pl2_to_pl3.g8b
+++ b/src/shaders/post_processing/gen9/pl2_to_pl3.g9b
@@ -194,4 +194,4 @@
    { 0x0c000031, 0x20002220, 0x060004a0, 0x060a8019 },
    { 0x0c000031, 0x20002220, 0x060005c0, 0x060a801a },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl2_to_rgbx.g8b b/src/shaders/post_processing/gen9/pl2_to_rgbx.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl2_to_rgbx.g8b
copy to src/shaders/post_processing/gen9/pl2_to_rgbx.g9b
index 9ee29c2..f37211f 100644
--- a/src/shaders/post_processing/gen8/pl2_to_rgbx.g8b
+++ b/src/shaders/post_processing/gen9/pl2_to_rgbx.g9b
@@ -735,4 +735,4 @@
    { 0x0c800031, 0x20002220, 0x060005c0, 0x0a0a8018 },
    { 0x0c800031, 0x20002220, 0x060006e0, 0x0a0a8018 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl3_to_pa.g8b b/src/shaders/post_processing/gen9/pl3_to_pa.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl3_to_pa.g8b
copy to src/shaders/post_processing/gen9/pl3_to_pa.g9b
index d6798c2..af542ec 100644
--- a/src/shaders/post_processing/gen8/pl3_to_pa.g8b
+++ b/src/shaders/post_processing/gen9/pl3_to_pa.g9b
@@ -300,4 +300,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x060a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x060a8018 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl3_to_pl2.g8b b/src/shaders/post_processing/gen9/pl3_to_pl2.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl3_to_pl2.g8b
copy to src/shaders/post_processing/gen9/pl3_to_pl2.g9b
index 9a141e7..cea24c7 100644
--- a/src/shaders/post_processing/gen8/pl3_to_pl2.g8b
+++ b/src/shaders/post_processing/gen9/pl3_to_pl2.g9b
@@ -257,4 +257,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x120a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x0a0a8019 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/pl3_to_pl3.g8b b/src/shaders/post_processing/gen9/pl3_to_pl3.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/pl3_to_pl3.g8b
copy to src/shaders/post_processing/gen9/pl3_to_pl3.g9b
index 67ac99c..bb21c62 100644
--- a/src/shaders/post_processing/gen8/pl3_to_pl3.g8b
+++ b/src/shaders/post_processing/gen9/pl3_to_pl3.g9b
@@ -210,4 +210,4 @@
    { 0x0c000031, 0x20002220, 0x060004a0, 0x060a8019 },
    { 0x0c000031, 0x20002220, 0x060005c0, 0x060a801a },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/post_processing/gen8/rgbx_to_nv12.g8b b/src/shaders/post_processing/gen9/rgbx_to_nv12.g9b
similarity index 99%
copy from src/shaders/post_processing/gen8/rgbx_to_nv12.g8b
copy to src/shaders/post_processing/gen9/rgbx_to_nv12.g9b
index 4cc113b..0a602d9 100644
--- a/src/shaders/post_processing/gen8/rgbx_to_nv12.g8b
+++ b/src/shaders/post_processing/gen9/rgbx_to_nv12.g9b
@@ -658,4 +658,4 @@
    { 0x0c000031, 0x20002220, 0x06000380, 0x120a8018 },
    { 0x0c000031, 0x20002220, 0x060004a0, 0x0a0a8019 },
    { 0x00600001, 0x2fe00208, 0x008d0000, 0x00000000 },
-   { 0x07000031, 0x20002220, 0x0e000fe0, 0x82000010 },
+   { 0x07000031, 0x20002220, 0x06000fe0, 0x82000010 },
diff --git a/src/shaders/render/Makefile.am b/src/shaders/render/Makefile.am
index e7d5e76..eef6108 100644
--- a/src/shaders/render/Makefile.am
+++ b/src/shaders/render/Makefile.am
@@ -103,6 +103,26 @@ INTEL_G8B =				\
 	exa_wm_yuv_rgb.g8b		\
 	exa_wm_write.g8b 
 
+INTEL_G9A =				\
+	exa_wm_src_affine.g9a 		\
+	exa_wm_src_sample_planar.g9a 	\
+	exa_wm_src_sample_argb.g9a 	\
+	exa_wm_yuv_color_balance.g9a	\
+	exa_wm_write.g9a 		\
+	exa_wm_yuv_rgb.g9a
+
+INTEL_G9I = $(INTEL_G4I)
+
+INTEL_G9S = $(INTEL_G9A:%.g9a=%.g9s)
+
+INTEL_G9B =				\
+	exa_wm_src_affine.g9b 		\
+	exa_wm_src_sample_planar.g9b 	\
+	exa_wm_src_sample_argb.g9b 	\
+	exa_wm_yuv_color_balance.g9b	\
+	exa_wm_yuv_rgb.g9b		\
+	exa_wm_write.g9b
+
 TARGETS  =
 if HAVE_GEN4ASM
 TARGETS += $(INTEL_G4B)
@@ -111,6 +131,7 @@ TARGETS += $(INTEL_G6B)
 TARGETS += $(INTEL_G7B)
 TARGETS += $(INTEL_G7B_HASWELL)
 TARGETS += $(INTEL_G8B)
+TARGETS += $(INTEL_G9B)
 endif
 
 all-local: $(TARGETS)
@@ -120,7 +141,7 @@ SUFFIXES = .g4a .g4s .g4b .g4b.gen5 .g6a .g6s .g6b .g7a .g7s .g7b .g7b.haswell .
 if HAVE_GEN4ASM
 $(INTEL_G4S): $(INTEL_G4A) $(INTEL_G4I)
 .g4a.g4s:
-	$(AM_V_GEN)m4 $< > $@
+	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 .g4s.g4b:
 	$(AM_V_GEN)$(GEN4ASM) -o $@ $<
 .g4s.g4b.gen5:
@@ -128,13 +149,13 @@ $(INTEL_G4S): $(INTEL_G4A) $(INTEL_G4I)
 
 $(INTEL_G6S): $(INTEL_G6A) $(INTEL_G6I)
 .g6a.g6s:
-	$(AM_V_GEN)m4 $< > $@
+	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 .g6s.g6b:
 	$(AM_V_GEN)$(GEN4ASM) -g 6 -o $@ $<
 
 $(INTEL_G7S): $(INTEL_G7A) $(INTEL_G7I)
 .g7a.g7s:
-	$(AM_V_GEN)m4 $< > $@
+	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 .g7s.g7b:
 	$(AM_V_GEN)$(GEN4ASM) -g 7 -o $@ $<
 .g7s.g7b.haswell:
@@ -143,10 +164,16 @@ $(INTEL_G7S): $(INTEL_G7A) $(INTEL_G7I)
 
 $(INTEL_G8S): $(INTEL_G8A) $(INTEL_G8I)
 .g8a.g8s:
-	$(AM_V_GEN)m4 $< > $@
+	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 .g8s.g8b:
 	$(AM_V_GEN)$(GEN4ASM) -g 8 -o $@ $<
 
+$(INTEL_G9S): $(INTEL_G9A) $(INTEL_G9I)
+.g9a.g9s:
+	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
+.g9s.g9b:
+	$(AM_V_GEN)$(GEN4ASM) -g 9 -o $@ $<
+
 endif
 
 CLEANFILES = \
@@ -154,6 +181,7 @@ CLEANFILES = \
 	$(INTEL_G6S)		\
 	$(INTEL_G7S)		\
 	$(INTEL_G8S)		\
+	$(INTEL_G9S)		\
 	$(NULL)
 
 EXTRA_DIST = \
@@ -168,6 +196,8 @@ EXTRA_DIST = \
 	$(INTEL_G7B_HASWELL)	\
 	$(INTEL_G8A)		\
 	$(INTEL_G8B)		\
+	$(INTEL_G9A)		\
+	$(INTEL_G9B)		\
 	$(NULL)
 
 # Extra clean files so that maintainer-clean removes *everything*
diff --git a/src/shaders/render/Makefile.in b/src/shaders/render/Makefile.in
index 46c14ef..fc2864e 100644
--- a/src/shaders/render/Makefile.in
+++ b/src/shaders/render/Makefile.in
@@ -79,7 +79,8 @@ build_triplet = @build@
 host_triplet = @host@
 @HAVE_GEN4ASM_TRUE at am__append_1 = $(INTEL_G4B) $(INTEL_G4B_GEN5) \
 @HAVE_GEN4ASM_TRUE@	$(INTEL_G6B) $(INTEL_G7B) \
- at HAVE_GEN4ASM_TRUE@	$(INTEL_G7B_HASWELL) $(INTEL_G8B)
+ at HAVE_GEN4ASM_TRUE@	$(INTEL_G7B_HASWELL) $(INTEL_G8B) \
+ at HAVE_GEN4ASM_TRUE@	$(INTEL_G9B)
 subdir = src/shaders/render
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -143,6 +144,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -189,6 +191,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -197,8 +200,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -352,6 +353,24 @@ INTEL_G8B = \
 	exa_wm_yuv_rgb.g8b		\
 	exa_wm_write.g8b 
 
+INTEL_G9A = \
+	exa_wm_src_affine.g9a 		\
+	exa_wm_src_sample_planar.g9a 	\
+	exa_wm_src_sample_argb.g9a 	\
+	exa_wm_yuv_color_balance.g9a	\
+	exa_wm_write.g9a 		\
+	exa_wm_yuv_rgb.g9a
+
+INTEL_G9I = $(INTEL_G4I)
+INTEL_G9S = $(INTEL_G9A:%.g9a=%.g9s)
+INTEL_G9B = \
+	exa_wm_src_affine.g9b 		\
+	exa_wm_src_sample_planar.g9b 	\
+	exa_wm_src_sample_argb.g9b 	\
+	exa_wm_yuv_color_balance.g9b	\
+	exa_wm_yuv_rgb.g9b		\
+	exa_wm_write.g9b
+
 TARGETS = $(am__append_1)
 SUFFIXES = .g4a .g4s .g4b .g4b.gen5 .g6a .g6s .g6b .g7a .g7s .g7b .g7b.haswell .g8a .g8b .g8s
 CLEANFILES = \
@@ -359,6 +378,7 @@ CLEANFILES = \
 	$(INTEL_G6S)		\
 	$(INTEL_G7S)		\
 	$(INTEL_G8S)		\
+	$(INTEL_G9S)		\
 	$(NULL)
 
 EXTRA_DIST = \
@@ -373,6 +393,8 @@ EXTRA_DIST = \
 	$(INTEL_G7B_HASWELL)	\
 	$(INTEL_G8A)		\
 	$(INTEL_G8B)		\
+	$(INTEL_G9A)		\
+	$(INTEL_G9B)		\
 	$(NULL)
 
 
@@ -381,7 +403,7 @@ MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .g4a .g4s .g4b .g4b.gen5 .g6a .g6s .g6b .g7a .g7s .g7b .g7b.haswell .g8a .g8b .g8s
+.SUFFIXES: .g4a .g4s .g4b .g4b.gen5 .g6a .g6s .g6b .g7a .g7s .g7b .g7b.haswell .g8a .g8b .g8s .g9a .g9b .g9s
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -577,7 +599,7 @@ all-local: $(TARGETS)
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_G4S): $(INTEL_G4A) $(INTEL_G4I)
 @HAVE_GEN4ASM_TRUE at .g4a.g4s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 $< > $@
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 @HAVE_GEN4ASM_TRUE at .g4s.g4b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -o $@ $<
 @HAVE_GEN4ASM_TRUE at .g4s.g4b.gen5:
@@ -585,13 +607,13 @@ all-local: $(TARGETS)
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_G6S): $(INTEL_G6A) $(INTEL_G6I)
 @HAVE_GEN4ASM_TRUE at .g6a.g6s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 $< > $@
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 @HAVE_GEN4ASM_TRUE at .g6s.g6b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 6 -o $@ $<
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_G7S): $(INTEL_G7A) $(INTEL_G7I)
 @HAVE_GEN4ASM_TRUE at .g7a.g7s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 $< > $@
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 @HAVE_GEN4ASM_TRUE at .g7s.g7b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 7 -o $@ $<
 @HAVE_GEN4ASM_TRUE at .g7s.g7b.haswell:
@@ -599,10 +621,16 @@ all-local: $(TARGETS)
 
 @HAVE_GEN4ASM_TRUE@$(INTEL_G8S): $(INTEL_G8A) $(INTEL_G8I)
 @HAVE_GEN4ASM_TRUE at .g8a.g8s:
- at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 $< > $@
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
 @HAVE_GEN4ASM_TRUE at .g8s.g8b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 8 -o $@ $<
 
+ at HAVE_GEN4ASM_TRUE@$(INTEL_G9S): $(INTEL_G9A) $(INTEL_G9I)
+ at HAVE_GEN4ASM_TRUE@.g9a.g9s:
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)m4 -I$(srcdir) $< > $@
+ at HAVE_GEN4ASM_TRUE@.g9s.g9b:
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 9 -o $@ $<
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/src/shaders/render/exa_wm_src_affine.g7a b/src/shaders/render/exa_wm_src_affine.g9a
similarity index 97%
copy from src/shaders/render/exa_wm_src_affine.g7a
copy to src/shaders/render/exa_wm_src_affine.g9a
index 88e5ed5..832f70c 100644
--- a/src/shaders/render/exa_wm_src_affine.g7a
+++ b/src/shaders/render/exa_wm_src_affine.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/src/shaders/render/exa_wm_src_affine.g8b b/src/shaders/render/exa_wm_src_affine.g9b
similarity index 100%
copy from src/shaders/render/exa_wm_src_affine.g8b
copy to src/shaders/render/exa_wm_src_affine.g9b
diff --git a/src/shaders/render/exa_wm_src_sample_argb.g8a b/src/shaders/render/exa_wm_src_sample_argb.g9a
similarity index 96%
copy from src/shaders/render/exa_wm_src_sample_argb.g8a
copy to src/shaders/render/exa_wm_src_sample_argb.g9a
index 3a4e99f..ca57ea6 100644
--- a/src/shaders/render/exa_wm_src_sample_argb.g8a
+++ b/src/shaders/render/exa_wm_src_sample_argb.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2013 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
  * Authors:
  *    Wang Zhenyu <zhenyu.z.wang at intel.com>
  *    Keith Packard <keithp at keithp.com>
+ *    Zhao Yakui <yakui.zhao at intel.com>
  */
 
 /* Sample the src surface */
@@ -56,4 +57,3 @@ send (16) src_msg_ind_gen8	/* msg reg index */
 
 mul (8) src_sample_a_01<1>f src_sample_a_01<8,8,1>f global_alpha { align1 mask_disable };
 mul (8) src_sample_a_23<1>f src_sample_a_23<8,8,1>f global_alpha { align1 mask_disable };
-
diff --git a/src/shaders/render/exa_wm_src_sample_argb.g8b b/src/shaders/render/exa_wm_src_sample_argb.g9b
similarity index 80%
copy from src/shaders/render/exa_wm_src_sample_argb.g8b
copy to src/shaders/render/exa_wm_src_sample_argb.g9b
index 2b04637..5cd181e 100644
--- a/src/shaders/render/exa_wm_src_sample_argb.g8b
+++ b/src/shaders/render/exa_wm_src_sample_argb.g9b
@@ -1,5 +1,5 @@
    { 0x00000001, 0x2008060c, 0x00000000, 0x00000000 },
    { 0x00600001, 0x2820020c, 0x008d0000, 0x00000000 },
-   { 0x02800031, 0x21c00a48, 0x0e000820, 0x0a8c0001 },
+   { 0x02800031, 0x21c00a48, 0x06000820, 0x0a8c0001 },
    { 0x00600041, 0x22803aec, 0x3a8d0280, 0x000000c0 },
    { 0x00600041, 0x22a03aec, 0x3a8d02a0, 0x000000c0 },
diff --git a/src/shaders/render/exa_wm_src_sample_planar.g8a b/src/shaders/render/exa_wm_src_sample_planar.g9a
similarity index 95%
copy from src/shaders/render/exa_wm_src_sample_planar.g8a
copy to src/shaders/render/exa_wm_src_sample_planar.g9a
index 7684491..f5369ca 100644
--- a/src/shaders/render/exa_wm_src_sample_planar.g8a
+++ b/src/shaders/render/exa_wm_src_sample_planar.g9a
@@ -85,7 +85,7 @@ mov (8) src_msg_gen8<1>UD    g0<8,8,1>UD  { align1 mask_disable };
 
 /* sample UV (CrCb) */
 send (16) src_msg_ind_gen8           /* msg reg index */
-        src_sample_g<1>UW       /* readback */                                                                                                                         
+        src_sample_g<1>UW       /* readback */
         null
         sampler (3,2,F)         /* sampler message description, (binding_table,sampler_index,datatype)
                                 /* here(src->dst) we should use src_sampler and src_surface */
@@ -103,4 +103,3 @@ send (16) src_msg_ind_gen8		/* msg reg index */
 	sampler (1,0,F)		/* sampler message description, (binding_table,sampler_index,datatype)
 				/* here(src->dst) we should use src_sampler and src_surface */
 	mlen 5 rlen 2 { align1 };   /* required message len 5, readback len 8 */
-	
diff --git a/src/shaders/render/exa_wm_src_sample_planar.g8b b/src/shaders/render/exa_wm_src_sample_planar.g9b
similarity index 80%
copy from src/shaders/render/exa_wm_src_sample_planar.g8b
copy to src/shaders/render/exa_wm_src_sample_planar.g9b
index f29cfe4..45e28b0 100644
--- a/src/shaders/render/exa_wm_src_sample_planar.g8b
+++ b/src/shaders/render/exa_wm_src_sample_planar.g9b
@@ -4,17 +4,17 @@
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000070 },
    { 0x00000001, 0x2008060c, 0x00000000, 0x0000e000 },
    { 0x00600001, 0x2820020c, 0x008d0000, 0x00000000 },
-   { 0x02800031, 0x22000a48, 0x0e000820, 0x0a2c0203 },
+   { 0x02800031, 0x22000a48, 0x06000820, 0x0a2c0203 },
    { 0x00000001, 0x2008060c, 0x00000000, 0x0000e000 },
    { 0x00600001, 0x2820020c, 0x008d0000, 0x00000000 },
-   { 0x02800031, 0x22400a48, 0x0e000820, 0x0a2c0405 },
+   { 0x02800031, 0x22400a48, 0x06000820, 0x0a2c0405 },
    { 0x00000020, 0x34000000, 0x0e001400, 0x00000060 },
    { 0x00800001, 0x22003eec, 0x38000000, 0x3f000000 },
    { 0x00800001, 0x22403eec, 0x38000000, 0x3f000000 },
    { 0x00000020, 0x34000000, 0x0e001400, 0x00000030 },
    { 0x00000001, 0x2008060c, 0x00000000, 0x0000c000 },
    { 0x00600001, 0x2820020c, 0x008d0000, 0x00000000 },
-   { 0x02800031, 0x22000a48, 0x0e000820, 0x0a4c0203 },
+   { 0x02800031, 0x22000a48, 0x06000820, 0x0a4c0203 },
    { 0x00000001, 0x2008060c, 0x00000000, 0x0000e000 },
    { 0x00600001, 0x2820020c, 0x008d0000, 0x00000000 },
-   { 0x02800031, 0x21c00a48, 0x0e000820, 0x0a2c0001 },
+   { 0x02800031, 0x21c00a48, 0x06000820, 0x0a2c0001 },
diff --git a/src/shaders/render/exa_wm_write.g7a b/src/shaders/render/exa_wm_write.g9a
similarity index 79%
copy from src/shaders/render/exa_wm_write.g7a
copy to src/shaders/render/exa_wm_write.g9a
index 4b17929..5275cdc 100644
--- a/src/shaders/render/exa_wm_write.g7a
+++ b/src/shaders/render/exa_wm_write.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -25,25 +25,25 @@
 include(`exa_wm.g4i')
 
 /* header */
-define(`data_port_msg_2_0',     `g64')
-define(`data_port_msg_2_1',     `g65')
-define(`data_port_msg_2_ind',   `64')
+define(`data_port_msg_2_0',     `g112')
+define(`data_port_msg_2_1',     `g113')
+define(`data_port_msg_2_ind',   `112')
 
 mov (8) data_port_msg_2_0<1>UD g0<8,8,1>UD {align1 mask_disable};
 mov (8) data_port_msg_2_1<1>UD g1<8,8,1>UD {align1 mask_disable};
 
 /*
- * Prepare data in g66-g67 for Red channel, g68-g69 for Green channel,
- * g70-g71 for Blue and g72-g73 for Alpha channel
+ * Prepare data in g114-g115 for Red channel, g116-g117 for Green channel,
+ * g118-g119 for Blue and g120-g121 for Alpha channel
  */
-define(`slot_r_00',     `g66')
-define(`slot_r_01',     `g67')
-define(`slot_g_00',     `g68')
-define(`slot_g_01',     `g69')
-define(`slot_b_00',     `g70')
-define(`slot_b_01',     `g71')
-define(`slot_a_00',     `g72')
-define(`slot_a_01',     `g73')
+define(`slot_r_00',     `g114')
+define(`slot_r_01',     `g115')
+define(`slot_g_00',     `g116')
+define(`slot_g_01',     `g117')
+define(`slot_b_00',     `g118')
+define(`slot_b_01',     `g119')
+define(`slot_a_00',     `g120')
+define(`slot_a_01',     `g121')
 
 mov (8) slot_r_00<1>F     src_sample_r_01<8,8,1>F { align1 mask_disable };
 mov (8) slot_r_01<1>F     src_sample_r_23<8,8,1>F { align1 mask_disable };
@@ -57,9 +57,9 @@ mov (8) slot_b_01<1>F     src_sample_b_23<8,8,1>F { align1 mask_disable };
 mov (8) slot_a_00<1>F     src_sample_a_01<8,8,1>F { align1 mask_disable };
 mov (8) slot_a_01<1>F     src_sample_a_23<8,8,1>F { align1 mask_disable };
 
-send (16) 
-	data_port_msg_2_ind 
-	null<1>UW 
+send (16)
+	data_port_msg_2_ind
+	null<1>UW
 	null
 	write (
 	       0,   /* binding table index */
@@ -67,7 +67,7 @@ send (16)
 	       12,  /* render target write */
 	       0,   /* ignore for Ivybridge */
 	       1    /* header present */
-	) 
+	)
 	mlen 10
 	rlen 0
 	{ align1 EOT };
@@ -80,4 +80,3 @@ nop;
 nop;
 nop;
 nop;
-
diff --git a/src/shaders/render/exa_wm_write.g9b b/src/shaders/render/exa_wm_write.g9b
new file mode 100644
index 0000000..e625b9d
--- /dev/null
+++ b/src/shaders/render/exa_wm_write.g9b
@@ -0,0 +1,19 @@
+   { 0x00600001, 0x2e00020c, 0x008d0000, 0x00000000 },
+   { 0x00600001, 0x2e20020c, 0x008d0020, 0x00000000 },
+   { 0x00600001, 0x2e403aec, 0x008d01c0, 0x00000000 },
+   { 0x00600001, 0x2e603aec, 0x008d01e0, 0x00000000 },
+   { 0x00600001, 0x2e803aec, 0x008d0200, 0x00000000 },
+   { 0x00600001, 0x2ea03aec, 0x008d0220, 0x00000000 },
+   { 0x00600001, 0x2ec03aec, 0x008d0240, 0x00000000 },
+   { 0x00600001, 0x2ee03aec, 0x008d0260, 0x00000000 },
+   { 0x00600001, 0x2f003aec, 0x008d0280, 0x00000000 },
+   { 0x00600001, 0x2f203aec, 0x008d02a0, 0x00000000 },
+   { 0x05800031, 0x20000a40, 0x06000e00, 0x940b1000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+   { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g8a b/src/shaders/render/exa_wm_yuv_color_balance.g9a
similarity index 97%
copy from src/shaders/render/exa_wm_yuv_color_balance.g8a
copy to src/shaders/render/exa_wm_yuv_color_balance.g9a
index f3cc28f..511e3f3 100644
--- a/src/shaders/render/exa_wm_yuv_color_balance.g8a
+++ b/src/shaders/render/exa_wm_yuv_color_balance.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2013 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g8b b/src/shaders/render/exa_wm_yuv_color_balance.g9b
similarity index 100%
copy from src/shaders/render/exa_wm_yuv_color_balance.g8b
copy to src/shaders/render/exa_wm_yuv_color_balance.g9b
diff --git a/src/shaders/render/exa_wm_yuv_rgb.g8a b/src/shaders/render/exa_wm_yuv_rgb.g9a
similarity index 97%
copy from src/shaders/render/exa_wm_yuv_rgb.g8a
copy to src/shaders/render/exa_wm_yuv_rgb.g9a
index 9da53c8..e5f82c6 100644
--- a/src/shaders/render/exa_wm_yuv_rgb.g8a
+++ b/src/shaders/render/exa_wm_yuv_rgb.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2013 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/src/shaders/render/exa_wm_yuv_rgb.g8b b/src/shaders/render/exa_wm_yuv_rgb.g9b
similarity index 100%
copy from src/shaders/render/exa_wm_yuv_rgb.g8b
copy to src/shaders/render/exa_wm_yuv_rgb.g9b
diff --git a/src/shaders/utils/Makefile.am b/src/shaders/utils/Makefile.am
index dd19d62..4a5d89d 100644
--- a/src/shaders/utils/Makefile.am
+++ b/src/shaders/utils/Makefile.am
@@ -24,16 +24,22 @@ INTEL_G75A	= mfc_batchbuffer_hsw.g75a
 INTEL_GEN75_INC	= mfc_batchbuffer_hsw.inc
 INTEL_GEN75_ASM	= $(INTEL_G75A:%.g75a=%.gen75.asm)
 
+INTEL_G9B	= mfc_batchbuffer_avc_intra.g9b mfc_batchbuffer_avc_inter.g9b
+INTEL_G9A	= mfc_batchbuffer_avc_intra.g9a mfc_batchbuffer_avc_inter.g9a
+INTEL_GEN9_INC	= mfc_batchbuffer.inc
+INTEL_GEN9_ASM	= $(INTEL_G9A:%.g9a=%.gen9.asm)
+
 TARGETS  =
 if HAVE_GEN4ASM
 TARGETS += $(INTEL_G6B)
 TARGETS += $(INTEL_G7B)
 TARGETS += $(INTEL_G75B)
+TARGETS += $(INTEL_G9B)
 endif
 
 all-local: $(TARGETS)
 
-SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm
+SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g9a .g9b .gen9.asm
 
 if HAVE_GEN4ASM
 $(INTEL_GEN6_ASM): $(MFC_CORE) $(MFC_CORE_AVC) $(INTEL_GEN6_INC)
@@ -59,9 +65,18 @@ $(INTEL_GEN75_ASM): $(MFC_CORE_HSW) $(INTEL_GEN75_INC)
 	rm _mfc0.$@
 .gen75.asm.g75b:
 	$(AM_V_GEN)$(GEN4ASM) -g 7.5 -o $@ $<
+
+$(INTEL_GEN9_ASM): $(MFC_CORE) $(MFC_CORE_AVC) $(INTEL_GEN9_INC)
+.g9a.gen9.asm:
+	$(AM_V_GEN)cpp -P -DDEV_IVB $< > _mfc0.$@ 	&& \
+	m4 _mfc0.$@ > $@				&& \
+	rm _mfc0.$@
+.gen9.asm.g9b:
+	$(AM_V_GEN)$(GEN4ASM) -g 9 -o $@ $<
+
 endif
 
-CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM)
+CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM) $(INTEL_GEN9_ASM)
 
 EXTRA_DIST = \
 	$(INTEL_G6A)		\
@@ -73,6 +88,9 @@ EXTRA_DIST = \
 	$(INTEL_GEN6_INC)	\
 	$(INTEL_GEN7_INC)	\
 	$(INTEL_GEN75_INC)	\
+	$(INTEL_G9A)		\
+	$(INTEL_G9B)		\
+	$(INTEL_GEN9_INC)	\
 	$(MFC_CORE)		\
 	$(MFC_CORE_AVC)		\
 	$(MFC_CORE_HSW)		\
diff --git a/src/shaders/utils/Makefile.in b/src/shaders/utils/Makefile.in
index 268b9a4..8054af2 100644
--- a/src/shaders/utils/Makefile.in
+++ b/src/shaders/utils/Makefile.in
@@ -78,7 +78,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 @HAVE_GEN4ASM_TRUE at am__append_1 = $(INTEL_G6B) $(INTEL_G7B) \
- at HAVE_GEN4ASM_TRUE@	$(INTEL_G75B)
+ at HAVE_GEN4ASM_TRUE@	$(INTEL_G75B) $(INTEL_G9B)
 subdir = src/shaders/utils
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -142,6 +142,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -188,6 +189,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -196,8 +198,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -276,9 +276,13 @@ INTEL_G75B = mfc_batchbuffer_hsw.g75b
 INTEL_G75A = mfc_batchbuffer_hsw.g75a
 INTEL_GEN75_INC = mfc_batchbuffer_hsw.inc
 INTEL_GEN75_ASM = $(INTEL_G75A:%.g75a=%.gen75.asm)
+INTEL_G9B = mfc_batchbuffer_avc_intra.g9b mfc_batchbuffer_avc_inter.g9b
+INTEL_G9A = mfc_batchbuffer_avc_intra.g9a mfc_batchbuffer_avc_inter.g9a
+INTEL_GEN9_INC = mfc_batchbuffer.inc
+INTEL_GEN9_ASM = $(INTEL_G9A:%.g9a=%.gen9.asm)
 TARGETS = $(am__append_1)
-SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm
-CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM)
+SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g9a .g9b .gen9.asm
+CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM) $(INTEL_GEN9_ASM)
 EXTRA_DIST = \
 	$(INTEL_G6A)		\
 	$(INTEL_G6B)		\
@@ -289,6 +293,9 @@ EXTRA_DIST = \
 	$(INTEL_GEN6_INC)	\
 	$(INTEL_GEN7_INC)	\
 	$(INTEL_GEN75_INC)	\
+	$(INTEL_G9A)		\
+	$(INTEL_G9B)		\
+	$(INTEL_GEN9_INC)	\
 	$(MFC_CORE)		\
 	$(MFC_CORE_AVC)		\
 	$(MFC_CORE_HSW)		\
@@ -300,7 +307,7 @@ MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm
+.SUFFIXES: .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g9a .g9b .gen9.asm
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -518,6 +525,14 @@ all-local: $(TARGETS)
 @HAVE_GEN4ASM_TRUE at .gen75.asm.g75b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 7.5 -o $@ $<
 
+ at HAVE_GEN4ASM_TRUE@$(INTEL_GEN9_ASM): $(MFC_CORE) $(MFC_CORE_AVC) $(INTEL_GEN9_INC)
+ at HAVE_GEN4ASM_TRUE@.g9a.gen9.asm:
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -P -DDEV_IVB $< > _mfc0.$@ 	&& \
+ at HAVE_GEN4ASM_TRUE@	m4 _mfc0.$@ > $@				&& \
+ at HAVE_GEN4ASM_TRUE@	rm _mfc0.$@
+ at HAVE_GEN4ASM_TRUE@.gen9.asm.g9b:
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 9 -o $@ $<
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/src/shaders/utils/mfc_batchbuffer_avc_inter.g6a b/src/shaders/utils/mfc_batchbuffer_avc_inter.g9a
similarity index 94%
copy from src/shaders/utils/mfc_batchbuffer_avc_inter.g6a
copy to src/shaders/utils/mfc_batchbuffer_avc_inter.g9a
index bef586a..ebc884c 100644
--- a/src/shaders/utils/mfc_batchbuffer_avc_inter.g6a
+++ b/src/shaders/utils/mfc_batchbuffer_avc_inter.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2012 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -22,6 +22,7 @@
  *
  * Authors:
  *    Xiang Haihao <haihao.xiang at intel.com>
+ *    Li Zhong <zhong.li at intel.com>
  */
 
 #include "mfc_batchbuffer.inc"
diff --git a/src/shaders/utils/mfc_batchbuffer_avc_inter.g9b b/src/shaders/utils/mfc_batchbuffer_avc_inter.g9b
new file mode 100644
index 0000000..dfea916
--- /dev/null
+++ b/src/shaders/utils/mfc_batchbuffer_avc_inter.g9b
@@ -0,0 +1,90 @@
+   { 0x00800001, 0x21000608, 0x00000000, 0x00000000 },
+   { 0x00800001, 0x21400608, 0x00000000, 0x00000000 },
+   { 0x00000001, 0x21342288, 0x00000014, 0x00000000 },
+   { 0x00000001, 0x21280208, 0x000000a0, 0x00000000 },
+   { 0x00000001, 0x21542288, 0x00000014, 0x00000000 },
+   { 0x00000001, 0x21480208, 0x000000a4, 0x00000000 },
+   { 0x01000005, 0x20001240, 0x160000ac, 0x00040004 },
+   { 0x00010020, 0x34000000, 0x0e001400, 0x00000090 },
+   { 0x00600001, 0x28000208, 0x008d0120, 0x00000000 },
+   { 0x0a800031, 0x22000a48, 0x06000800, 0x02180001 },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00600001, 0x28200208, 0x008d0200, 0x00000000 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0002 },
+   { 0x00000040, 0x21280208, 0x06000128, 0x00000001 },
+   { 0x00000040, 0x21480208, 0x06000148, 0x00000001 },
+   { 0x01000040, 0x20aa1a68, 0x1e0000aa, 0xffffffff },
+   { 0x00110020, 0x34000000, 0x0e001400, 0xffffff70 },
+   { 0x00000041, 0x21e01208, 0x220000b4, 0x000000b1 },
+   { 0x00000040, 0x21e00208, 0x220001e0, 0x000000b0 },
+   { 0x00000041, 0x21080208, 0x060001e0, 0x0000000a },
+   { 0x00000040, 0x21080208, 0x16000108, 0x00080008 },
+   { 0x00600001, 0x28000208, 0x008d0100, 0x00000000 },
+   { 0x0a800031, 0x22000a48, 0x06000800, 0x02180200 },
+   { 0x00800001, 0x23400608, 0x00000000, 0x00000000 },
+   { 0x01000005, 0x20001241, 0x160000ac, 0x00020002 },
+   { 0x01000005, 0x20000200, 0x06000200, 0x00002000 },
+   { 0x00110020, 0x34000000, 0x0e001400, 0x00000130 },
+   { 0x00000001, 0x23400608, 0x00000000, 0x71490009 },
+   { 0x00000041, 0x23480208, 0x060001e0, 0x000000a0 },
+   { 0x00000001, 0x23540608, 0x00000000, 0x000f000f },
+   { 0x00000001, 0x23440208, 0x00000208, 0x00000000 },
+   { 0x00000001, 0x234c0208, 0x00000200, 0x00000000 },
+   { 0x00000040, 0x23501208, 0x060000b0, 0xffff0000 },
+   { 0x00000040, 0x20b02288, 0x160000b0, 0x00010001 },
+   { 0x01000010, 0x20001240, 0x220000b4, 0x000000b0 },
+   { 0x00010001, 0x20b01688, 0x10000000, 0x00000000 },
+   { 0x00010040, 0x20b12288, 0x160000b1, 0x00010001 },
+   { 0x00000001, 0x23580608, 0x00000000, 0x00000000 },
+   { 0x00110001, 0x23580609, 0x00000000, 0x04000000 },
+   { 0x01000010, 0x20001240, 0x160000ae, 0x00010001 },
+   { 0x00110001, 0x23580608, 0x00000000, 0x00000000 },
+   { 0x00000040, 0x23580208, 0x22000358, 0x000000b6 },
+   { 0x00000001, 0x235c0208, 0x00000204, 0x00000000 },
+   { 0x00000001, 0x23600208, 0x000000b8, 0x00000000 },
+   { 0x00000001, 0x23640208, 0x000000bc, 0x00000000 },
+   { 0x00000020, 0x34000000, 0x0e001400, 0x00000110 },
+   { 0x00000001, 0x23400608, 0x00000000, 0x71490009 },
+   { 0x00000001, 0x23540608, 0x00000000, 0x000f000f },
+   { 0x00000040, 0x23501208, 0x060000b0, 0xffff0000 },
+   { 0x00000040, 0x20b02288, 0x160000b0, 0x00010001 },
+   { 0x01000010, 0x20001240, 0x220000b4, 0x000000b0 },
+   { 0x00010001, 0x20b01688, 0x10000000, 0x00000000 },
+   { 0x00010040, 0x20b12288, 0x160000b1, 0x00010001 },
+   { 0x00000001, 0x23580608, 0x00000000, 0x00000000 },
+   { 0x00110001, 0x23580609, 0x00000000, 0x04000000 },
+   { 0x01000010, 0x20001240, 0x160000ae, 0x00010001 },
+   { 0x00110001, 0x23580608, 0x00000000, 0x00000000 },
+   { 0x00000040, 0x23580208, 0x22000358, 0x000000b6 },
+   { 0x00000005, 0x234c0208, 0x0e000200, 0x0000ffff },
+   { 0x00000040, 0x234c0208, 0x0600034c, 0x000e0000 },
+   { 0x00000001, 0x235c0208, 0x00000204, 0x00000000 },
+   { 0x00000001, 0x23600208, 0x00000208, 0x00000000 },
+   { 0x00000005, 0x23640208, 0x0600020c, 0x000000fc },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00600001, 0x28200208, 0x008d0340, 0x00000000 },
+   { 0x00600001, 0x28400208, 0x008d0360, 0x00000000 },
+   { 0x00000040, 0x21080208, 0x06000108, 0x0000000a },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x060a0302 },
+   { 0x00000040, 0x21480208, 0x06000148, 0x00000004 },
+   { 0x00000040, 0x21e00208, 0x060001e0, 0x00000001 },
+   { 0x01000040, 0x20ae1a68, 0x1e0000ae, 0xffffffff },
+   { 0x00110020, 0x34000000, 0x0e001400, 0xfffffcd0 },
+   { 0x00010020, 0x34000001, 0x0e001400, 0x000000f0 },
+   { 0x00600001, 0x28000208, 0x008d0120, 0x00000000 },
+   { 0x0a800031, 0x22000a48, 0x06000800, 0x02180001 },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00600001, 0x28200208, 0x008d0200, 0x00000000 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0002 },
+   { 0x00000040, 0x21280208, 0x06000128, 0x00000001 },
+   { 0x00000040, 0x21480208, 0x06000148, 0x00000001 },
+   { 0x01000040, 0x20a81a68, 0x1e0000a8, 0xffffffff },
+   { 0x00110020, 0x34000000, 0x0e001400, 0xffffff70 },
+   { 0x01000005, 0x20001240, 0x160000ac, 0x00010001 },
+   { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00400001, 0x28200608, 0x00000000, 0x00000000 },
+   { 0x00000001, 0x28240608, 0x00000000, 0x05000000 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0002 },
+   { 0x00600001, 0x28000208, 0x008d0000, 0x00000000 },
+   { 0x07800031, 0x24000a00, 0x06000800, 0x82000010 },
diff --git a/src/shaders/utils/mfc_batchbuffer_avc_intra.g7a b/src/shaders/utils/mfc_batchbuffer_avc_intra.g9a
similarity index 94%
copy from src/shaders/utils/mfc_batchbuffer_avc_intra.g7a
copy to src/shaders/utils/mfc_batchbuffer_avc_intra.g9a
index fba9bd5..22d2ce7 100644
--- a/src/shaders/utils/mfc_batchbuffer_avc_intra.g7a
+++ b/src/shaders/utils/mfc_batchbuffer_avc_intra.g9a
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2012 Intel Corporation
+ * Copyright © 2014 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -22,6 +22,7 @@
  *
  * Authors:
  *    Xiang Haihao <haihao.xiang at intel.com>
+ *    Li Zhong <zhong.li at intel.com>
  */
 
 #include "mfc_batchbuffer.inc"
diff --git a/src/shaders/utils/mfc_batchbuffer_avc_intra.g9b b/src/shaders/utils/mfc_batchbuffer_avc_intra.g9b
new file mode 100644
index 0000000..8f4d916
--- /dev/null
+++ b/src/shaders/utils/mfc_batchbuffer_avc_intra.g9b
@@ -0,0 +1,66 @@
+   { 0x00800001, 0x21000608, 0x00000000, 0x00000000 },
+   { 0x00800001, 0x21400608, 0x00000000, 0x00000000 },
+   { 0x00000001, 0x21342288, 0x00000014, 0x00000000 },
+   { 0x00000001, 0x21280208, 0x000000a0, 0x00000000 },
+   { 0x00000001, 0x21542288, 0x00000014, 0x00000000 },
+   { 0x00000001, 0x21480208, 0x000000a4, 0x00000000 },
+   { 0x01000005, 0x20001240, 0x160000ac, 0x00040004 },
+   { 0x00010020, 0x34000000, 0x0e001400, 0x00000090 },
+   { 0x00600001, 0x28000208, 0x008d0120, 0x00000000 },
+   { 0x0a800031, 0x22000a48, 0x06000800, 0x02180001 },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00600001, 0x28200208, 0x008d0200, 0x00000000 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0002 },
+   { 0x00000040, 0x21280208, 0x06000128, 0x00000001 },
+   { 0x00000040, 0x21480208, 0x06000148, 0x00000001 },
+   { 0x01000040, 0x20aa1a68, 0x1e0000aa, 0xffffffff },
+   { 0x00110020, 0x34000000, 0x0e001400, 0xffffff70 },
+   { 0x00000041, 0x21081208, 0x220000b4, 0x000000b1 },
+   { 0x00000040, 0x21080208, 0x22000108, 0x000000b0 },
+   { 0x00800001, 0x23400608, 0x00000000, 0x00000000 },
+   { 0x00000001, 0x23400608, 0x00000000, 0x71490009 },
+   { 0x00000001, 0x23540608, 0x00000000, 0x000f000f },
+   { 0x01000005, 0x20001241, 0x160000ac, 0x00020002 },
+   { 0x00600001, 0x28000208, 0x008d0100, 0x00000000 },
+   { 0x0a800031, 0x22000a48, 0x06000800, 0x02180000 },
+   { 0x00000040, 0x23501208, 0x060000b0, 0xffff0000 },
+   { 0x00000040, 0x20b02288, 0x160000b0, 0x00010001 },
+   { 0x01000010, 0x20001240, 0x220000b4, 0x000000b0 },
+   { 0x00010001, 0x20b01688, 0x10000000, 0x00000000 },
+   { 0x00010040, 0x20b12288, 0x160000b1, 0x00010001 },
+   { 0x00000001, 0x23580608, 0x00000000, 0x00000000 },
+   { 0x00110001, 0x23580609, 0x00000000, 0x04000000 },
+   { 0x01000010, 0x20001240, 0x160000ae, 0x00010001 },
+   { 0x00110001, 0x23580608, 0x00000000, 0x00000000 },
+   { 0x00000040, 0x23580208, 0x22000358, 0x000000b6 },
+   { 0x00000005, 0x234c0208, 0x0e000200, 0x0000ffff },
+   { 0x00000040, 0x234c0208, 0x0600034c, 0x000e0000 },
+   { 0x00000001, 0x235c0208, 0x00000204, 0x00000000 },
+   { 0x00000001, 0x23600208, 0x00000208, 0x00000000 },
+   { 0x00000005, 0x23640208, 0x0600020c, 0x000000fc },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00600001, 0x28200208, 0x008d0340, 0x00000000 },
+   { 0x00600001, 0x28400208, 0x008d0360, 0x00000000 },
+   { 0x00000040, 0x21080208, 0x06000108, 0x00000001 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x060a0302 },
+   { 0x00000040, 0x21480208, 0x06000148, 0x00000004 },
+   { 0x01000040, 0x20ae1a68, 0x1e0000ae, 0xffffffff },
+   { 0x00110020, 0x34000000, 0x0e001400, 0xfffffe70 },
+   { 0x00010020, 0x34000001, 0x0e001400, 0x000000f0 },
+   { 0x00600001, 0x28000208, 0x008d0120, 0x00000000 },
+   { 0x0a800031, 0x22000a48, 0x06000800, 0x02180001 },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00600001, 0x28200208, 0x008d0200, 0x00000000 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0002 },
+   { 0x00000040, 0x21280208, 0x06000128, 0x00000001 },
+   { 0x00000040, 0x21480208, 0x06000148, 0x00000001 },
+   { 0x01000040, 0x20a81a68, 0x1e0000a8, 0xffffffff },
+   { 0x00110020, 0x34000000, 0x0e001400, 0xffffff70 },
+   { 0x01000005, 0x20001240, 0x160000ac, 0x00010001 },
+   { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
+   { 0x00600001, 0x28000208, 0x008d0140, 0x00000000 },
+   { 0x00400001, 0x28200608, 0x00000000, 0x00000000 },
+   { 0x00000001, 0x28240608, 0x00000000, 0x05000000 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0002 },
+   { 0x00600001, 0x28000208, 0x008d0000, 0x00000000 },
+   { 0x07800031, 0x24000a00, 0x06000800, 0x82000010 },
diff --git a/src/shaders/vme/Makefile.am b/src/shaders/vme/Makefile.am
index d89b689..382c8a5 100644
--- a/src/shaders/vme/Makefile.am
+++ b/src/shaders/vme/Makefile.am
@@ -2,6 +2,7 @@ VME_CORE	= batchbuffer.asm intra_frame.asm inter_frame.asm
 VME7_CORE	= batchbuffer.asm intra_frame_ivb.asm inter_frame_ivb.asm inter_bframe_ivb.asm mpeg2_inter_ivb.asm
 VME75_CORE	= batchbuffer.asm intra_frame_haswell.asm inter_frame_haswell.asm inter_bframe_haswell.asm mpeg2_inter_haswell.asm
 VME8_CORE	= intra_frame_gen8.asm	inter_frame_gen8.asm inter_bframe_gen8.asm mpeg2_inter_gen8.asm
+VME9_CORE	= $(VME8_CORE)
 
 INTEL_G6B	= batchbuffer.g6b intra_frame.g6b inter_frame.g6b
 INTEL_G6A	= batchbuffer.g6a intra_frame.g6a inter_frame.g6a
@@ -25,17 +26,24 @@ INTEL_GEN8_INC	= vme8.inc vme75_mpeg2.inc
 INTEL_GEN8_ASM	= $(INTEL_G8A:%.g8a=%.gen8.asm)
 
 
+INTEL_G9B	= intra_frame_gen9.g9b inter_frame_gen9.g9b inter_bframe_gen9.g9b mpeg2_inter_gen9.g9b
+INTEL_G9A	= intra_frame_gen9.g9a inter_frame_gen9.g9a inter_bframe_gen9.g9a mpeg2_inter_gen9.g9a
+INTEL_GEN9_INC	= $(INTEL_GEN8_INC)
+INTEL_GEN9_ASM	= $(INTEL_G9A:%.g9a=%.gen9.asm)
+
+
 TARGETS  =
 if HAVE_GEN4ASM
 TARGETS += $(INTEL_G6B)
 TARGETS += $(INTEL_G7B)
 TARGETS += $(INTEL_G75B)
 TARGETS += $(INTEL_G8B)
+TARGETS += $(INTEL_G9B)
 endif
 
 all-local: $(TARGETS)
 
-SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g8a .g8b .gen8.asm
+SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g8a .g8b .gen8.asm .g9a .g9b .gen9.asm
 
 if HAVE_GEN4ASM
 $(INTEL_GEN6_ASM): $(VME_CORE) $(INTEL_GEN6_INC)
@@ -71,9 +79,17 @@ $(INTEL_GEN8_ASM): $(VME8_CORE) $(INTEL_GEN8_INC)
 .gen8.asm.g8b:
 	$(AM_V_GEN)$(GEN4ASM) -g 8 -o $@ $<
 
+$(INTEL_GEN9_ASM): $(VME9_CORE) $(INTEL_GEN9_INC)
+.g9a.gen9.asm:
+	$(AM_V_GEN)cpp -P $< > _vme0.$@ 	&& \
+	m4 _vme0.$@ > $@				&& \
+	rm _vme0.$@
+.gen9.asm.g9b:
+	$(AM_V_GEN)$(GEN4ASM) -g 9 -o $@ $<
+
 endif
 
-CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM) $(INTEL_GEN8_ASM)
+CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM) $(INTEL_GEN8_ASM) $(INTEL_GEN9_ASM)
 
 EXTRA_DIST = \
 	$(INTEL_G6A)		\
@@ -84,13 +100,17 @@ EXTRA_DIST = \
 	$(INTEL_G7B)		\
 	$(INTEL_G8A)            \
 	$(INTEL_G8B)            \
+	$(INTEL_G9A)		\
+	$(INTEL_G9B)		\
 	$(INTEL_GEN6_INC)	\
 	$(INTEL_GEN75_INC)	\
 	$(INTEL_GEN7_INC)	\
 	$(INTEL_GEN8_INC)       \
+	$(INTEL_GEN9_INC)	\
 	$(VME75_CORE)		\
 	$(VME7_CORE)		\
 	$(VME8_CORE)            \
+	$(VME9_CORE)		\
 	$(VME_CORE)		\
 	$(NULL)
 
diff --git a/src/shaders/vme/Makefile.in b/src/shaders/vme/Makefile.in
index ac7e97d..98d9236 100644
--- a/src/shaders/vme/Makefile.in
+++ b/src/shaders/vme/Makefile.in
@@ -78,7 +78,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 @HAVE_GEN4ASM_TRUE at am__append_1 = $(INTEL_G6B) $(INTEL_G7B) \
- at HAVE_GEN4ASM_TRUE@	$(INTEL_G75B) $(INTEL_G8B)
+ at HAVE_GEN4ASM_TRUE@	$(INTEL_G75B) $(INTEL_G8B) $(INTEL_G9B)
 subdir = src/shaders/vme
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -142,6 +142,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -188,6 +189,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -196,8 +198,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -256,6 +256,7 @@ VME_CORE = batchbuffer.asm intra_frame.asm inter_frame.asm
 VME7_CORE = batchbuffer.asm intra_frame_ivb.asm inter_frame_ivb.asm inter_bframe_ivb.asm mpeg2_inter_ivb.asm
 VME75_CORE = batchbuffer.asm intra_frame_haswell.asm inter_frame_haswell.asm inter_bframe_haswell.asm mpeg2_inter_haswell.asm
 VME8_CORE = intra_frame_gen8.asm	inter_frame_gen8.asm inter_bframe_gen8.asm mpeg2_inter_gen8.asm
+VME9_CORE = $(VME8_CORE)
 INTEL_G6B = batchbuffer.g6b intra_frame.g6b inter_frame.g6b
 INTEL_G6A = batchbuffer.g6a intra_frame.g6a inter_frame.g6a
 INTEL_GEN6_INC = batchbuffer.inc vme.inc
@@ -272,9 +273,13 @@ INTEL_G8B = intra_frame_gen8.g8b inter_frame_gen8.g8b inter_bframe_gen8.g8b mpeg
 INTEL_G8A = intra_frame_gen8.g8a inter_frame_gen8.g8a inter_bframe_gen8.g8a mpeg2_inter_gen8.g8a
 INTEL_GEN8_INC = vme8.inc vme75_mpeg2.inc
 INTEL_GEN8_ASM = $(INTEL_G8A:%.g8a=%.gen8.asm)
+INTEL_G9B = intra_frame_gen9.g9b inter_frame_gen9.g9b inter_bframe_gen9.g9b mpeg2_inter_gen9.g9b
+INTEL_G9A = intra_frame_gen9.g9a inter_frame_gen9.g9a inter_bframe_gen9.g9a mpeg2_inter_gen9.g9a
+INTEL_GEN9_INC = $(INTEL_GEN8_INC)
+INTEL_GEN9_ASM = $(INTEL_G9A:%.g9a=%.gen9.asm)
 TARGETS = $(am__append_1)
-SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g8a .g8b .gen8.asm
-CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM) $(INTEL_GEN8_ASM)
+SUFFIXES = .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g8a .g8b .gen8.asm .g9a .g9b .gen9.asm
+CLEANFILES = $(INTEL_GEN6_ASM) $(INTEL_GEN7_ASM) $(INTEL_GEN75_ASM) $(INTEL_GEN8_ASM) $(INTEL_GEN9_ASM)
 EXTRA_DIST = \
 	$(INTEL_G6A)		\
 	$(INTEL_G6B)		\
@@ -284,13 +289,17 @@ EXTRA_DIST = \
 	$(INTEL_G7B)		\
 	$(INTEL_G8A)            \
 	$(INTEL_G8B)            \
+	$(INTEL_G9A)		\
+	$(INTEL_G9B)		\
 	$(INTEL_GEN6_INC)	\
 	$(INTEL_GEN75_INC)	\
 	$(INTEL_GEN7_INC)	\
 	$(INTEL_GEN8_INC)       \
+	$(INTEL_GEN9_INC)	\
 	$(VME75_CORE)		\
 	$(VME7_CORE)		\
 	$(VME8_CORE)            \
+	$(VME9_CORE)		\
 	$(VME_CORE)		\
 	$(NULL)
 
@@ -300,7 +309,7 @@ MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g8a .g8b .gen8.asm
+.SUFFIXES: .g6a .g6b .g7a .g7b .gen6.asm .gen7.asm .g75a .g75b .gen75.asm .g8a .g8b .gen8.asm .g9a .g9b .gen9.asm
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -526,6 +535,14 @@ all-local: $(TARGETS)
 @HAVE_GEN4ASM_TRUE at .gen8.asm.g8b:
 @HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 8 -o $@ $<
 
+ at HAVE_GEN4ASM_TRUE@$(INTEL_GEN9_ASM): $(VME9_CORE) $(INTEL_GEN9_INC)
+ at HAVE_GEN4ASM_TRUE@.g9a.gen9.asm:
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)cpp -P $< > _vme0.$@ 	&& \
+ at HAVE_GEN4ASM_TRUE@	m4 _vme0.$@ > $@				&& \
+ at HAVE_GEN4ASM_TRUE@	rm _vme0.$@
+ at HAVE_GEN4ASM_TRUE@.gen9.asm.g9b:
+ at HAVE_GEN4ASM_TRUE@	$(AM_V_GEN)$(GEN4ASM) -g 9 -o $@ $<
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/src/shaders/vme/inter_bframe_gen8.g8a b/src/shaders/vme/inter_bframe_gen9.g9a
similarity index 100%
copy from src/shaders/vme/inter_bframe_gen8.g8a
copy to src/shaders/vme/inter_bframe_gen9.g9a
diff --git a/src/shaders/vme/inter_bframe_gen8.g8b b/src/shaders/vme/inter_bframe_gen9.g9b
similarity index 95%
copy from src/shaders/vme/inter_bframe_gen8.g8b
copy to src/shaders/vme/inter_bframe_gen9.g9b
index 77daf5a..2f77a6f 100644
--- a/src/shaders/vme/inter_bframe_gen8.g8b
+++ b/src/shaders/vme/inter_bframe_gen9.g9b
@@ -18,21 +18,21 @@
    { 0x00000041, 0x24880208, 0x06000488, 0x00000018 },
    { 0x00000001, 0x24942288, 0x00000014, 0x00000000 },
    { 0x00600001, 0x28000208, 0x008d0400, 0x00000000 },
-   { 0x04600031, 0x23800a88, 0x0e000800, 0x02190004 },
+   { 0x0c600031, 0x23800a88, 0x06000800, 0x02190004 },
    { 0x00600001, 0x28000208, 0x008d0420, 0x00000000 },
-   { 0x04600031, 0x23a00a88, 0x0e000800, 0x02290004 },
+   { 0x0c600031, 0x23a00a88, 0x06000800, 0x02290004 },
    { 0x00200009, 0x24002228, 0x164500a0, 0x00030003 },
    { 0x00000041, 0x24000a28, 0x1e000400, 0x00020002 },
    { 0x00000040, 0x24000a28, 0x1e000400, 0xfff8fff8 },
    { 0x00000040, 0x24040a28, 0x1e000404, 0xffffffff },
    { 0x00600001, 0x28000208, 0x008d0400, 0x00000000 },
-   { 0x04600031, 0x26000a88, 0x0e000800, 0x02190006 },
+   { 0x0c600031, 0x26000a88, 0x06000800, 0x02190006 },
    { 0x00200009, 0x24202228, 0x164500a0, 0x00030003 },
    { 0x00000041, 0x24200a28, 0x1e000420, 0x00020002 },
    { 0x00000040, 0x24200a28, 0x1e000420, 0xfffcfffc },
    { 0x00000001, 0x24280e08, 0x08000000, 0x00070003 },
    { 0x00600001, 0x28000208, 0x008d0420, 0x00000000 },
-   { 0x04600031, 0x26200a88, 0x0e000800, 0x02190006 },
+   { 0x0c600031, 0x26200a88, 0x06000800, 0x02190006 },
    { 0x00600001, 0x24600608, 0x00000000, 0x00000000 },
    { 0x00600001, 0x2ac00608, 0x00000000, 0x00000000 },
    { 0x00600001, 0x2a800608, 0x00000000, 0x00000000 },
@@ -52,12 +52,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2af41e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000160 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2af41e68, 0x18000000, 0xffffffff },
    { 0x00000001, 0x2fa00208, 0x00000b84, 0x00000000 },
    { 0x00000001, 0x2fa40208, 0x00000b80, 0x00000000 },
@@ -90,12 +90,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b141e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000160 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2b141e68, 0x18000000, 0xffffffff },
    { 0x00000001, 0x2fa00208, 0x00000b84, 0x00000000 },
    { 0x00000001, 0x2fa40208, 0x00000b80, 0x00000000 },
@@ -127,12 +127,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x000003c0 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00000001, 0x2fa00208, 0x00000b84, 0x00000000 },
    { 0x00000001, 0x2fa40208, 0x00000b80, 0x00000000 },
@@ -165,12 +165,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000160 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a88, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a88, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00000001, 0x2fa00208, 0x00000b84, 0x00000000 },
    { 0x00000001, 0x2fa40208, 0x00000b80, 0x00000000 },
@@ -281,7 +281,7 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00000001, 0x244c0608, 0x00000000, 0x00800000 },
    { 0x00600001, 0x28000208, 0x008d0440, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10782000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10782000 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00000001, 0x28200208, 0x00000180, 0x00000000 },
    { 0x00000001, 0x28240208, 0x00000190, 0x00000000 },
@@ -291,7 +291,7 @@
    { 0x00000001, 0x28340208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x28380208, 0x0000019c, 0x00000000 },
    { 0x00000001, 0x283c0208, 0x00000488, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
    { 0x00000001, 0x244c0608, 0x00000000, 0x00200700 },
    { 0x00000001, 0x24561648, 0x10000000, 0x20202020 },
    { 0x00000001, 0x24400208, 0x00000448, 0x00000000 },
@@ -322,7 +322,7 @@
    { 0x00000001, 0x288c0608, 0x00000000, 0x000f0f0f },
    { 0x00400001, 0x28900608, 0x00000000, 0x00000000 },
    { 0x00600001, 0x28b00608, 0x00000000, 0x00000000 },
-   { 0x08600031, 0x21800a08, 0x0e000800, 0x0c784000 },
+   { 0x08600031, 0x21800a08, 0x06000800, 0x0c784000 },
    { 0x00000001, 0x25740608, 0x00000000, 0x00000000 },
    { 0x00000001, 0x25752288, 0x00000199, 0x00000000 },
    { 0x00000001, 0x25762288, 0x0000019a, 0x00000000 },
@@ -339,28 +339,28 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d0560, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d0580, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10786000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10786000 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000002 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00000001, 0x28200208, 0x00000180, 0x00000000 },
    { 0x00000001, 0x28240208, 0x00000198, 0x00000000 },
    { 0x00000001, 0x28280208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x282c0208, 0x00000574, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0003 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0003 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000001 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00600001, 0x28200208, 0x008d01a0, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d01c0, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d01e0, 0x00000000 },
    { 0x00600001, 0x28800208, 0x008d0200, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x0a0a0403 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x0a0a0403 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000008 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00600001, 0x28200208, 0x008d0240, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x0219e003 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x0219e003 },
    { 0x00600001, 0x2e000208, 0x008d0000, 0x00000000 },
-   { 0x07800031, 0x24000a40, 0x0e000e00, 0x82000010 },
+   { 0x07800031, 0x24000a40, 0x06000e00, 0x82000010 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x06000010, 0x20001a60, 0x1a000fa0, 0x00000fa4 },
diff --git a/src/shaders/vme/inter_frame_gen8.g8a b/src/shaders/vme/inter_frame_gen9.g9a
similarity index 100%
copy from src/shaders/vme/inter_frame_gen8.g8a
copy to src/shaders/vme/inter_frame_gen9.g9a
diff --git a/src/shaders/vme/inter_frame_gen8.g8b b/src/shaders/vme/inter_frame_gen9.g9b
similarity index 93%
copy from src/shaders/vme/inter_frame_gen8.g8b
copy to src/shaders/vme/inter_frame_gen9.g9b
index d0cc25d..b79042c 100644
--- a/src/shaders/vme/inter_frame_gen8.g8b
+++ b/src/shaders/vme/inter_frame_gen9.g9b
@@ -18,21 +18,21 @@
    { 0x00000041, 0x24880208, 0x06000488, 0x00000018 },
    { 0x00000001, 0x24942288, 0x00000014, 0x00000000 },
    { 0x00600001, 0x28000208, 0x008d0400, 0x00000000 },
-   { 0x04600031, 0x23800a88, 0x0e000800, 0x02190004 },
+   { 0x0c600031, 0x23800a88, 0x06000800, 0x02190004 },
    { 0x00600001, 0x28000208, 0x008d0420, 0x00000000 },
-   { 0x04600031, 0x23a00a88, 0x0e000800, 0x02290004 },
+   { 0x0c600031, 0x23a00a88, 0x06000800, 0x02290004 },
    { 0x00200009, 0x24002228, 0x164500a0, 0x00030003 },
    { 0x00000041, 0x24000a28, 0x1e000400, 0x00020002 },
    { 0x00000040, 0x24000a28, 0x1e000400, 0xfff8fff8 },
    { 0x00000040, 0x24040a28, 0x1e000404, 0xffffffff },
    { 0x00600001, 0x28000208, 0x008d0400, 0x00000000 },
-   { 0x04600031, 0x26000a88, 0x0e000800, 0x02190006 },
+   { 0x0c600031, 0x26000a88, 0x06000800, 0x02190006 },
    { 0x00200009, 0x24202228, 0x164500a0, 0x00030003 },
    { 0x00000041, 0x24200a28, 0x1e000420, 0x00020002 },
    { 0x00000040, 0x24200a28, 0x1e000420, 0xfffcfffc },
    { 0x00000001, 0x24280e08, 0x08000000, 0x00070003 },
    { 0x00600001, 0x28000208, 0x008d0420, 0x00000000 },
-   { 0x04600031, 0x26200a88, 0x0e000800, 0x02190006 },
+   { 0x0c600031, 0x26200a88, 0x06000800, 0x02190006 },
    { 0x00600001, 0x2ac00608, 0x00000000, 0x00000000 },
    { 0x00600001, 0x2a800608, 0x00000000, 0x00000000 },
    { 0x01000005, 0x20001240, 0x160000a6, 0x00040004 },
@@ -51,12 +51,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2af41e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2ae40208, 0x00450bc8, 0x00000000 },
    { 0x00000001, 0x2af01e68, 0x18000000, 0x00010001 },
    { 0x00600001, 0x2b400608, 0x00000000, 0x00000000 },
@@ -71,12 +71,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b141e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2b040208, 0x00450bf0, 0x00000000 },
    { 0x00000001, 0x2b101e68, 0x18000000, 0x00010001 },
    { 0x00600001, 0x2b400608, 0x00000000, 0x00000000 },
@@ -90,12 +90,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000180 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2b240208, 0x00450bf0, 0x00000000 },
    { 0x00000001, 0x2b301e68, 0x18000000, 0x00010001 },
    { 0x00000020, 0x34000000, 0x0e001400, 0x00000130 },
@@ -110,12 +110,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a88, 0x0e000b40, 0x02480403 },
+   { 0x0a800031, 0x2ba00a88, 0x06000b40, 0x02480403 },
    { 0x00200001, 0x2b240208, 0x00450c18, 0x00000000 },
    { 0x00000001, 0x2b301e68, 0x18000000, 0x00010001 },
    { 0x00000040, 0x24000a28, 0x0a000b00, 0x00000b20 },
@@ -182,7 +182,7 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00000001, 0x244c0608, 0x00000000, 0x00800000 },
    { 0x00600001, 0x28000208, 0x008d0440, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10782000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10782000 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00000001, 0x28200208, 0x00000180, 0x00000000 },
    { 0x00000001, 0x28240208, 0x00000190, 0x00000000 },
@@ -192,7 +192,7 @@
    { 0x00000001, 0x28340208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x28380208, 0x0000019c, 0x00000000 },
    { 0x00000001, 0x283c0208, 0x00000488, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
    { 0x01000010, 0x20002240, 0x160000a7, 0x00020002 },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000160 },
    { 0x00000001, 0x28600608, 0x00000000, 0x01010101 },
@@ -256,7 +256,7 @@
    { 0x00000001, 0x28a80608, 0x00000000, 0x0f0f0f0f },
    { 0x00000001, 0x28ac0608, 0x00000000, 0x000f0f0f },
    { 0x00400001, 0x28b00608, 0x00000000, 0x00000000 },
-   { 0x08600031, 0x21800a08, 0x0e000800, 0x0c784000 },
+   { 0x08600031, 0x21800a08, 0x06000800, 0x0c784000 },
    { 0x00000001, 0x25740608, 0x00000000, 0x00000000 },
    { 0x00000001, 0x25752288, 0x00000199, 0x00000000 },
    { 0x00000001, 0x25762288, 0x0000019a, 0x00000000 },
@@ -271,28 +271,28 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d0560, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d0580, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10786000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10786000 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000002 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00000001, 0x28200208, 0x00000180, 0x00000000 },
    { 0x00000001, 0x28240208, 0x00000198, 0x00000000 },
    { 0x00000001, 0x28280208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x282c0208, 0x00000574, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0003 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0003 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000001 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00600001, 0x28200208, 0x008d01a0, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d01c0, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d01e0, 0x00000000 },
    { 0x00600001, 0x28800208, 0x008d0200, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x0a0a0403 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x0a0a0403 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000008 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00600001, 0x28200208, 0x008d0240, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x0219e003 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x0219e003 },
    { 0x00600001, 0x2e000208, 0x008d0000, 0x00000000 },
-   { 0x07800031, 0x24000a40, 0x0e000e00, 0x82000010 },
+   { 0x07800031, 0x24000a40, 0x06000e00, 0x82000010 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x06000010, 0x20001a60, 0x1a000fa0, 0x00000fa4 },
diff --git a/src/shaders/vme/intra_frame_gen8.g8a b/src/shaders/vme/intra_frame_gen9.g9a
similarity index 100%
copy from src/shaders/vme/intra_frame_gen8.g8a
copy to src/shaders/vme/intra_frame_gen9.g9a
diff --git a/src/shaders/vme/intra_frame_gen8.g8b b/src/shaders/vme/intra_frame_gen9.g9b
similarity index 90%
copy from src/shaders/vme/intra_frame_gen8.g8b
copy to src/shaders/vme/intra_frame_gen9.g9b
index 56c7283..63d7455 100644
--- a/src/shaders/vme/intra_frame_gen8.g8b
+++ b/src/shaders/vme/intra_frame_gen9.g9b
@@ -18,21 +18,21 @@
    { 0x00000041, 0x24880208, 0x06000488, 0x00000002 },
    { 0x00000001, 0x24942288, 0x00000014, 0x00000000 },
    { 0x00600001, 0x28000208, 0x008d0400, 0x00000000 },
-   { 0x04600031, 0x23800a88, 0x0e000800, 0x02190004 },
+   { 0x0c600031, 0x23800a88, 0x06000800, 0x02190004 },
    { 0x00600001, 0x28000208, 0x008d0420, 0x00000000 },
-   { 0x04600031, 0x23a00a88, 0x0e000800, 0x02290004 },
+   { 0x0c600031, 0x23a00a88, 0x06000800, 0x02290004 },
    { 0x00200009, 0x24002228, 0x164500a0, 0x00030003 },
    { 0x00000041, 0x24000a28, 0x1e000400, 0x00020002 },
    { 0x00000040, 0x24000a28, 0x1e000400, 0xfff8fff8 },
    { 0x00000040, 0x24040a28, 0x1e000404, 0xffffffff },
    { 0x00600001, 0x28000208, 0x008d0400, 0x00000000 },
-   { 0x04600031, 0x26000a88, 0x0e000800, 0x02190006 },
+   { 0x0c600031, 0x26000a88, 0x06000800, 0x02190006 },
    { 0x00200009, 0x24202228, 0x164500a0, 0x00030003 },
    { 0x00000041, 0x24200a28, 0x1e000420, 0x00020002 },
    { 0x00000040, 0x24200a28, 0x1e000420, 0xfffcfffc },
    { 0x00000001, 0x24280e08, 0x08000000, 0x00070003 },
    { 0x00600001, 0x28000208, 0x008d0420, 0x00000000 },
-   { 0x04600031, 0x26200a88, 0x0e000800, 0x02190006 },
+   { 0x0c600031, 0x26200a88, 0x06000800, 0x02190006 },
    { 0x00600001, 0x28400208, 0x008d0020, 0x00000000 },
    { 0x00600001, 0x28600608, 0x00000000, 0x00000000 },
    { 0x00600001, 0x28800608, 0x00000000, 0x00000000 },
@@ -57,7 +57,7 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00000040, 0x244c0208, 0x0600044c, 0x00800000 },
    { 0x00600001, 0x28000208, 0x008d0440, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10782000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10782000 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00000001, 0x28200208, 0x00000180, 0x00000000 },
    { 0x00000001, 0x28240208, 0x00000190, 0x00000000 },
@@ -67,6 +67,6 @@
    { 0x00000001, 0x28340208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x28380208, 0x0000019c, 0x00000000 },
    { 0x00000001, 0x283c0208, 0x00000488, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
    { 0x00600001, 0x2e000208, 0x008d0000, 0x00000000 },
-   { 0x07800031, 0x24000a40, 0x0e000e00, 0x82000010 },
+   { 0x07800031, 0x24000a40, 0x06000e00, 0x82000010 },
diff --git a/src/shaders/vme/mpeg2_inter_gen8.g8a b/src/shaders/vme/mpeg2_inter_gen9.g9a
similarity index 100%
copy from src/shaders/vme/mpeg2_inter_gen8.g8a
copy to src/shaders/vme/mpeg2_inter_gen9.g9a
diff --git a/src/shaders/vme/mpeg2_inter_gen8.g8b b/src/shaders/vme/mpeg2_inter_gen9.g9b
similarity index 94%
copy from src/shaders/vme/mpeg2_inter_gen8.g8b
copy to src/shaders/vme/mpeg2_inter_gen9.g9b
index 6686c9f..222da7c 100644
--- a/src/shaders/vme/mpeg2_inter_gen8.g8b
+++ b/src/shaders/vme/mpeg2_inter_gen9.g9b
@@ -28,12 +28,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2af41e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02180203 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02180203 },
    { 0x00200001, 0x2ae40208, 0x00450ba0, 0x00000000 },
    { 0x00000001, 0x2af01e68, 0x18000000, 0x00010001 },
    { 0x00600001, 0x2b400608, 0x00000000, 0x00000000 },
@@ -48,12 +48,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b141e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02180203 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02180203 },
    { 0x00200001, 0x2b040208, 0x00450ba0, 0x00000000 },
    { 0x00000001, 0x2b101e68, 0x18000000, 0x00010001 },
    { 0x00600001, 0x2b400608, 0x00000000, 0x00000000 },
@@ -67,12 +67,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000180 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a08, 0x0e000b40, 0x02180203 },
+   { 0x0a800031, 0x2ba00a08, 0x06000b40, 0x02180203 },
    { 0x00200001, 0x2b240208, 0x00450ba0, 0x00000000 },
    { 0x00000001, 0x2b301e68, 0x18000000, 0x00010001 },
    { 0x00000020, 0x34000000, 0x0e001400, 0x00000130 },
@@ -87,12 +87,12 @@
    { 0x00000040, 0x2b480208, 0x12000b48, 0x00000400 },
    { 0x00000041, 0x2b480208, 0x06000b48, 0x00000018 },
    { 0x00000001, 0x2b542288, 0x00000014, 0x00000000 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x02280303 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x02280303 },
    { 0x05000010, 0x20001260, 0x12000b70, 0x00000b88 },
    { 0x00210001, 0x2b341e68, 0x18000000, 0xffffffff },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000040 },
    { 0x00000040, 0x2b480208, 0x06000b48, 0x00000003 },
-   { 0x0a800031, 0x2ba00a88, 0x0e000b40, 0x02180203 },
+   { 0x0a800031, 0x2ba00a88, 0x06000b40, 0x02180203 },
    { 0x00200001, 0x2b240208, 0x00450ba0, 0x00000000 },
    { 0x00000001, 0x2b301e68, 0x18000000, 0x00010001 },
    { 0x00000040, 0x24000a28, 0x0a000b00, 0x00000b20 },
@@ -164,7 +164,7 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00000001, 0x244c0608, 0x00000000, 0x00800000 },
    { 0x00600001, 0x28000208, 0x008d0440, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10782000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10782000 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00000001, 0x28200208, 0x00000180, 0x00000000 },
    { 0x00000001, 0x28240208, 0x00000190, 0x00000000 },
@@ -174,7 +174,7 @@
    { 0x00000001, 0x28340208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x28380208, 0x0000019c, 0x00000000 },
    { 0x00000001, 0x283c0208, 0x00000488, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
    { 0x00000001, 0x244c0608, 0x00000000, 0x7e200000 },
    { 0x00000001, 0x24561648, 0x10000000, 0x28302830 },
    { 0x00000001, 0x24440208, 0x00000440, 0x00000000 },
@@ -200,7 +200,7 @@
    { 0x00000001, 0x28a80608, 0x00000000, 0x0f0f0f0f },
    { 0x00000001, 0x28ac0608, 0x00000000, 0x000f0f0f },
    { 0x00400001, 0x28b00608, 0x00000000, 0x00000000 },
-   { 0x08600031, 0x21800a08, 0x0e000800, 0x0c784000 },
+   { 0x08600031, 0x21800a08, 0x06000800, 0x0c784000 },
    { 0x00000001, 0x25740608, 0x00000000, 0x00000000 },
    { 0x00000001, 0x25752288, 0x00000199, 0x00000000 },
    { 0x00000001, 0x25762288, 0x0000019a, 0x00000000 },
@@ -217,7 +217,7 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d0560, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d0580, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10786000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10786000 },
    { 0x01000005, 0x20001240, 0x160000a6, 0x00040004 },
    { 0x00110020, 0x34000000, 0x0e001400, 0x000004a0 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
@@ -227,21 +227,21 @@
    { 0x00000001, 0x28240208, 0x00000198, 0x00000000 },
    { 0x00000001, 0x28280208, 0x00000188, 0x00000000 },
    { 0x00000001, 0x282c0208, 0x00000574, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0003 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0003 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000001 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00600001, 0x28200208, 0x008d01a0, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d01c0, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d01e0, 0x00000000 },
    { 0x00600001, 0x28800208, 0x008d0200, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
    { 0x00000040, 0x24880208, 0x06000488, 0x00000008 },
    { 0x00600001, 0x28000208, 0x008d0480, 0x00000000 },
    { 0x00600001, 0x28200208, 0x008d0240, 0x00000000 },
-   { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
-   { 0x0a800031, 0x2b600a08, 0x0e000b40, 0x0219e003 },
+   { 0x0a800031, 0x20000a60, 0x06000800, 0x040a0203 },
+   { 0x0a800031, 0x2b600a08, 0x06000b40, 0x0219e003 },
    { 0x00600001, 0x2e000208, 0x008d0000, 0x00000000 },
-   { 0x07800031, 0x24000a40, 0x0e000e00, 0x82000010 },
+   { 0x07800031, 0x24000a40, 0x06000e00, 0x82000010 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x04000010, 0x20001a60, 0x1a000fa0, 0x00000fa4 },
@@ -343,7 +343,7 @@
    { 0x00000001, 0x28a80608, 0x00000000, 0x0f0f0f0f },
    { 0x00000001, 0x28ac0608, 0x00000000, 0x000f0f0f },
    { 0x00400001, 0x28b00608, 0x00000000, 0x00000000 },
-   { 0x08600031, 0x21800a08, 0x0e000800, 0x0c784000 },
+   { 0x08600031, 0x21800a08, 0x06000800, 0x0c784000 },
    { 0x00000001, 0x25740608, 0x00000000, 0x00000000 },
    { 0x00000001, 0x25752288, 0x00000199, 0x00000000 },
    { 0x00000001, 0x25762288, 0x0000019a, 0x00000000 },
@@ -360,7 +360,7 @@
    { 0x00600001, 0x28200208, 0x008d0460, 0x00000000 },
    { 0x00600001, 0x28400208, 0x008d0560, 0x00000000 },
    { 0x00600001, 0x28600208, 0x008d0580, 0x00000000 },
-   { 0x0d600031, 0x21800a08, 0x0e000800, 0x10786000 },
+   { 0x0d600031, 0x21800a08, 0x06000800, 0x10786000 },
    { 0x05000010, 0x20001240, 0x12000188, 0x00000c88 },
    { 0x00010020, 0x34000000, 0x0e001400, 0x00000020 },
    { 0x00600001, 0x21800208, 0x008d0c80, 0x00000000 },
diff --git a/src/wayland-drm-client-protocol.h b/src/wayland-drm-client-protocol.h
new file mode 100644
index 0000000..cba188e
--- /dev/null
+++ b/src/wayland-drm-client-protocol.h
@@ -0,0 +1,213 @@
+/* 
+ * Copyright © 2008-2011 Kristian Høgsberg
+ * Copyright © 2010-2011 Intel Corporation
+ * 
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that\n the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ * 
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#ifndef DRM_CLIENT_PROTOCOL_H
+#define DRM_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct wl_drm;
+
+extern const struct wl_interface wl_drm_interface;
+
+#ifndef WL_DRM_ERROR_ENUM
+#define WL_DRM_ERROR_ENUM
+enum wl_drm_error {
+	WL_DRM_ERROR_AUTHENTICATE_FAIL = 0,
+	WL_DRM_ERROR_INVALID_FORMAT = 1,
+	WL_DRM_ERROR_INVALID_NAME = 2,
+};
+#endif /* WL_DRM_ERROR_ENUM */
+
+#ifndef WL_DRM_FORMAT_ENUM
+#define WL_DRM_FORMAT_ENUM
+enum wl_drm_format {
+	WL_DRM_FORMAT_C8 = 0x20203843,
+	WL_DRM_FORMAT_RGB332 = 0x38424752,
+	WL_DRM_FORMAT_BGR233 = 0x38524742,
+	WL_DRM_FORMAT_XRGB4444 = 0x32315258,
+	WL_DRM_FORMAT_XBGR4444 = 0x32314258,
+	WL_DRM_FORMAT_RGBX4444 = 0x32315852,
+	WL_DRM_FORMAT_BGRX4444 = 0x32315842,
+	WL_DRM_FORMAT_ARGB4444 = 0x32315241,
+	WL_DRM_FORMAT_ABGR4444 = 0x32314241,
+	WL_DRM_FORMAT_RGBA4444 = 0x32314152,
+	WL_DRM_FORMAT_BGRA4444 = 0x32314142,
+	WL_DRM_FORMAT_XRGB1555 = 0x35315258,
+	WL_DRM_FORMAT_XBGR1555 = 0x35314258,
+	WL_DRM_FORMAT_RGBX5551 = 0x35315852,
+	WL_DRM_FORMAT_BGRX5551 = 0x35315842,
+	WL_DRM_FORMAT_ARGB1555 = 0x35315241,
+	WL_DRM_FORMAT_ABGR1555 = 0x35314241,
+	WL_DRM_FORMAT_RGBA5551 = 0x35314152,
+	WL_DRM_FORMAT_BGRA5551 = 0x35314142,
+	WL_DRM_FORMAT_RGB565 = 0x36314752,
+	WL_DRM_FORMAT_BGR565 = 0x36314742,
+	WL_DRM_FORMAT_RGB888 = 0x34324752,
+	WL_DRM_FORMAT_BGR888 = 0x34324742,
+	WL_DRM_FORMAT_XRGB8888 = 0x34325258,
+	WL_DRM_FORMAT_XBGR8888 = 0x34324258,
+	WL_DRM_FORMAT_RGBX8888 = 0x34325852,
+	WL_DRM_FORMAT_BGRX8888 = 0x34325842,
+	WL_DRM_FORMAT_ARGB8888 = 0x34325241,
+	WL_DRM_FORMAT_ABGR8888 = 0x34324241,
+	WL_DRM_FORMAT_RGBA8888 = 0x34324152,
+	WL_DRM_FORMAT_BGRA8888 = 0x34324142,
+	WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
+	WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
+	WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
+	WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
+	WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
+	WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
+	WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
+	WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
+	WL_DRM_FORMAT_YUYV = 0x56595559,
+	WL_DRM_FORMAT_YVYU = 0x55595659,
+	WL_DRM_FORMAT_UYVY = 0x59565955,
+	WL_DRM_FORMAT_VYUY = 0x59555956,
+	WL_DRM_FORMAT_AYUV = 0x56555941,
+	WL_DRM_FORMAT_NV12 = 0x3231564e,
+	WL_DRM_FORMAT_NV21 = 0x3132564e,
+	WL_DRM_FORMAT_NV16 = 0x3631564e,
+	WL_DRM_FORMAT_NV61 = 0x3136564e,
+	WL_DRM_FORMAT_YUV410 = 0x39565559,
+	WL_DRM_FORMAT_YVU410 = 0x39555659,
+	WL_DRM_FORMAT_YUV411 = 0x31315559,
+	WL_DRM_FORMAT_YVU411 = 0x31315659,
+	WL_DRM_FORMAT_YUV420 = 0x32315559,
+	WL_DRM_FORMAT_YVU420 = 0x32315659,
+	WL_DRM_FORMAT_YUV422 = 0x36315559,
+	WL_DRM_FORMAT_YVU422 = 0x36315659,
+	WL_DRM_FORMAT_YUV444 = 0x34325559,
+	WL_DRM_FORMAT_YVU444 = 0x34325659,
+};
+#endif /* WL_DRM_FORMAT_ENUM */
+
+struct wl_drm_listener {
+	/**
+	 * device - device
+	 * @name: name
+	 */
+	void (*device)(void *data,
+		       struct wl_drm *wl_drm,
+		       const char *name);
+	/**
+	 * format - format
+	 * @format: format
+	 */
+	void (*format)(void *data,
+		       struct wl_drm *wl_drm,
+		       uint32_t format);
+	/**
+	 * authenticated - authenticated
+	 */
+	void (*authenticated)(void *data,
+			      struct wl_drm *wl_drm);
+};
+
+static inline int
+wl_drm_add_listener(struct wl_drm *wl_drm,
+		    const struct wl_drm_listener *listener, void *data)
+{
+	return wl_proxy_add_listener((struct wl_proxy *) wl_drm,
+				     (void (**)(void)) listener, data);
+}
+
+#define WL_DRM_AUTHENTICATE	0
+#define WL_DRM_CREATE_BUFFER	1
+#define WL_DRM_CREATE_PLANAR_BUFFER	2
+
+static inline void
+wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
+{
+	wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data);
+}
+
+static inline void *
+wl_drm_get_user_data(struct wl_drm *wl_drm)
+{
+	return wl_proxy_get_user_data((struct wl_proxy *) wl_drm);
+}
+
+static inline void
+wl_drm_destroy(struct wl_drm *wl_drm)
+{
+	wl_proxy_destroy((struct wl_proxy *) wl_drm);
+}
+
+static inline void
+wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id)
+{
+	wl_proxy_marshal((struct wl_proxy *) wl_drm,
+			 WL_DRM_AUTHENTICATE, id);
+}
+
+static inline struct wl_buffer *
+wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
+{
+	struct wl_proxy *id;
+
+	id = wl_proxy_create((struct wl_proxy *) wl_drm,
+			     &wl_buffer_interface);
+	if (!id)
+		return NULL;
+
+	wl_proxy_marshal((struct wl_proxy *) wl_drm,
+			 WL_DRM_CREATE_BUFFER, id, name, width, height, stride, format);
+
+	return (struct wl_buffer *) id;
+}
+
+static inline struct wl_buffer *
+wl_drm_create_planar_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
+{
+	struct wl_proxy *id;
+
+	id = wl_proxy_create((struct wl_proxy *) wl_drm,
+			     &wl_buffer_interface);
+	if (!id)
+		return NULL;
+
+	wl_proxy_marshal((struct wl_proxy *) wl_drm,
+			 WL_DRM_CREATE_PLANAR_BUFFER, id, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
+
+	return (struct wl_buffer *) id;
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/wayland/Makefile.in b/src/wayland/Makefile.in
index af7ea6f..ddfac58 100644
--- a/src/wayland/Makefile.in
+++ b/src/wayland/Makefile.in
@@ -162,6 +162,7 @@ FGREP = @FGREP@
 GEN4ASM = @GEN4ASM@
 GEN4ASM_CFLAGS = @GEN4ASM_CFLAGS@
 GEN4ASM_LIBS = @GEN4ASM_LIBS@
+GIT = @GIT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -208,6 +209,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYTHON2 = @PYTHON2@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -216,8 +218,6 @@ STRIP = @STRIP@
 VERSION = @VERSION@
 WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
 WAYLAND_LIBS = @WAYLAND_LIBS@
-WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
-WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@

-- 
intel-vaapi-driver packaging



More information about the pkg-multimedia-commits mailing list