]> git.sesse.net Git - vlc/blobdiff - configure.ac
fifo: fix FIFO bytes size computation
[vlc] / configure.ac
index 6da74e61d665f636c19f7378962a36c50c9103cf..58d5122d62eee8e58963735d44d34b35f3e141c9 100644 (file)
@@ -1,10 +1,10 @@
 dnl Autoconf settings for vlc
 
-AC_COPYRIGHT([Copyright 2002-2013 VLC authors and VideoLAN])
+AC_COPYRIGHT([Copyright 1999-2015 VLC authors and VideoLAN])
 
-AC_INIT(vlc, 2.2.0-git)
-VERSION_MAJOR=2
-VERSION_MINOR=2
+AC_INIT(vlc, 3.0.0-git)
+VERSION_MAJOR=3
+VERSION_MINOR=0
 VERSION_REVISION=0
 VERSION_EXTRA=0
 VERSION_DEV=git
@@ -13,8 +13,8 @@ PKGDIR="vlc"
 AC_SUBST(PKGDIR)
 
 CONFIGURE_LINE="`echo "$0 $ac_configure_args" | sed -e 's/\\\/\\\\\\\/g'`"
-CODENAME="Weatherwax"
-COPYRIGHT_YEARS="1996-2013"
+CODENAME="Vetinari"
+COPYRIGHT_YEARS="1996-2015"
 
 AC_CONFIG_SRCDIR(src/libvlc.c)
 AC_CONFIG_AUX_DIR(autotools)
@@ -56,7 +56,11 @@ AC_PROG_CC_C99
 AC_USE_SYSTEM_EXTENSIONS
 AC_DEFINE([_FORTIFY_SOURCE], 2, [Define to 2 to get glibc warnings.])
 AC_DEFINE([_FILE_OFFSET_BITS], 64, [Define to 64 for large files support.])
-AC_DEFINE([_REENTRANT],, [Define to expose reentrant functions.])
+AH_TOP([
+#ifndef _REENTRANT
+# define _REENTRANT
+#endif
+])
 AC_DEFINE([_THREAD_SAFE],, [Same as _REENTANT for some other OSes.])
 AC_DEFINE([__LIBVLC__],, [Define within the LibVLC source code tree.])
 AC_DEFINE([WIN32_LEAN_AND_MEAN],, [Define to limit the scope of <windows.h>.])
@@ -73,6 +77,7 @@ AM_PROG_AS
 
 AC_ARG_VAR([DESKTOP_FILE_VALIDATE], [Validator for desktop entry files])
 AC_CHECK_PROGS(DESKTOP_FILE_VALIDATE, [${DESKTOP_FILE_VALIDATE} desktop-file-validate], :)
+AC_PATH_PROG(YASM, yasm)
 
 dnl Check for compiler properties
 AC_C_CONST
@@ -96,6 +101,20 @@ dnl
 dnl  Check the operating system
 dnl
 HAVE_WIN64="0"
+HAVE_IOS="0"
+HAVE_OSX="0"
+
+YASMFLAGS=""
+case "${host}" in
+    i?86*)
+    YASMFLAGS="-f elf32"
+        ;;
+    x86_64*)
+    YASMFLAGS="-f elf64"
+        ;;
+esac
+
+
 case "${host_os}" in
   "")
     SYS=unknown
@@ -131,6 +150,7 @@ case "${host_os}" in
     case "${host}" in
       i?86*)
         ARCH_flag="-arch i386"
+        YASMFLAGS="-f macho32"
       ;;
       ppc64*)
         ARCH_flag="-arch ppc64"
@@ -140,6 +160,7 @@ case "${host_os}" in
       ;;
       x86_64*)
         ARCH_flag="-arch x86_64"
+        YASMFLAGS="-f macho64"
       ;;
       arm*)
         ac_cv_c_bigendian="no"
@@ -154,8 +175,15 @@ case "${host_os}" in
     OBJCFLAGS="${OBJCFLAGS} -D_INTL_REDIRECT_MACROS -std=gnu99 ${ARCH_flag}"
     LDFLAGS="${LDFLAGS} -Wl,-headerpad_max_install_names ${ARCH_flag}"
     VLC_ADD_LIBS([libvlc vlc],[-Wl,-undefined,dynamic_lookup,-framework,AppKit])
-    VLC_ADD_LIBS([avcodec access_avio swscale postproc i420_rgb_mmx x262 x264 x26410b],[-Wl,-read_only_relocs,suppress])
-    VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation,-framework,SystemConfiguration])
+    VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation,-framework,CoreServices])
+
+    AC_EGREP_CPP(yes,
+            [#import <TargetConditionals.h>
+             #if TARGET_OS_IPHONE
+             yes
+             #endif],
+             [HAVE_IOS="1"],
+             [HAVE_OSX="1"])
 
     dnl Allow binaries created on Lion to run on earlier releases
     AC_EGREP_CPP(yes,
@@ -186,16 +214,11 @@ case "${host_os}" in
       [AS_HELP_STRING([--with-macosx-version-min=VERSION],
         [compile for Mac OS X VERSION and above])])
     if test "${with_macosx_version_min}" != "" ; then
-        MACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}
         CPP="${CPP} -mmacosx-version-min=${with_macosx_version_min}"
         CC="${CC} -mmacosx-version-min=${with_macosx_version_min}"
         CXX="${CXX} -mmacosx-version-min=${with_macosx_version_min}"
         OBJC="${OBJC} -mmacosx-version-min=${with_macosx_version_min}"
         LD="${LD} -mmacosx_version_min=${with_macosx_version_min}"
-        CFLAGS="${CFLAGS} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"
-        CXXFLAGS="${CXXFLAGS} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"
-        OBJCFLAGS="${OBJCFLAGS} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"
-        export MACOSX_DEPLOYMENT_TARGET
     fi
     ;;
   *mingw32* | *cygwin* | *wince* | *mingwce*)
@@ -207,6 +230,14 @@ case "${host_os}" in
     AC_DEFINE([_WIN32_IE], 0x0600, [Define to '0x0600' for IE 6.0 (and shell) APIs.])
     AC_DEFINE([_UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
     AC_DEFINE([UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
+    AC_DEFINE([_ISOC99_SOURCE], [1], [Extensions to ISO C89 from ISO C99.])
+    AC_DEFINE([_ISOC11_SOURCE], [1], [Extensions to ISO C99 from ISO C11.])
+    AC_DEFINE([_POSIX_SOURCE], [1], [IEEE Std 1003.1.])
+    AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
+    AC_DEFINE([_XOPEN_SOURCE], [700], [POSIX and XPG 7th edition])
+    AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [XPG things and X/Open Unix extensions.])
+    AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.])
+    AC_DEFINE([_SVID_SOURCE], [1], [ISO C, POSIX, and SVID things.])
 
     case "${host_os}" in
       *mingw32*)
@@ -227,9 +258,6 @@ case "${host_os}" in
         # DEP, ASLR, NO SEH
         LDFLAGS="${LDFLAGS} -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase"
 
-        VLC_ADD_LIBS([libvlccore],[-lwinmm])
-        VLC_ADD_LDFLAGS([vlc],[-mwindows])
-        VLC_ADD_LIBS([win32text],[-lgdi32])
         AC_CHECK_PROGS(U2D, [unix2dos todos], unix2dos)
         ac_default_prefix="`pwd`/_win32"
         DESTDIR="`pwd`/_win32/"
@@ -242,10 +270,12 @@ case "${host_os}" in
                 HAVE_WIN64="1"
                 WINDOWS_ARCH="x64"
                 PROGRAMFILES="PROGRAMFILES64"
+                YASMFLAGS="-f win64"
             ;;
             *)
                 WINDOWS_ARCH="x86"
                 PROGRAMFILES="PROGRAMFILES"
+                YASMFLAGS="-f win32"
             ;;
         esac
         AC_SUBST(WINDOWS_ARCH)
@@ -267,7 +297,8 @@ case "${host_os}" in
     ;;
   *os2*)
     SYS=os2
-    LDFLAGS="${LDFLAGS} -Zomf -Zbin-files -Zargs-wild"
+    LDFLAGS="${LDFLAGS} -Zomf -Zbin-files -Zargs-wild -Zhigh-mem"
+    AC_LIBOBJ([freeaddrinfo])
     ;;
   *)
     SYS="${host_os}"
@@ -279,6 +310,10 @@ AM_CONDITIONAL(HAVE_OS2,     test "${SYS}" = "os2")
 AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
 AM_CONDITIONAL(HAVE_WIN64,   test "${HAVE_WIN64}" = "1")
 AM_CONDITIONAL(HAVE_SYMBIAN, test "${SYS}" = "symbian")
+AM_CONDITIONAL(HAVE_IOS,   test "${HAVE_IOS}" = "1")
+AM_CONDITIONAL(HAVE_OSX,   test "${HAVE_OSX}" = "1")
+
+AC_SUBST(YASMFLAGS)
 
 dnl
 dnl Sadly autoconf does not think about testing foo.exe when ask to test
@@ -361,11 +396,7 @@ AS_IF([test -n "${CONTRIB_DIR}"], [
   CFLAGS="${CFLAGS} -I${CONTRIB_DIR}/include"
   CXXFLAGS="${CXXFLAGS} -I${CONTRIB_DIR}/include"
   OBJCFLAGS="${OBJCFLAGS} -I${CONTRIB_DIR}/include"
-  AS_IF([test "$build" = "$host" -o "$PKG_CONFIG_LIBDIR"], [
-    export PKG_CONFIG_PATH="${CONTRIB_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH"
-  ], [
-    export PKG_CONFIG_LIBDIR="${CONTRIB_DIR}/lib/pkgconfig"
-  ])
+  export PKG_CONFIG_PATH="${CONTRIB_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH"
   LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
 
   AS_IF([test "${SYS}" = "darwin"], [
@@ -379,6 +410,13 @@ AS_IF([test -n "${CONTRIB_DIR}"], [
 ])
 AC_SUBST(CONTRIB_DIR)
 
+dnl Add extras/tools to the PATH
+TOOLS_DIR="${srcdir}/extras/tools/build/bin"
+AS_IF([test -d "${TOOLS_DIR}"], [
+    TOOLS_DIR=`cd "${TOOLS_DIR}" && pwd`
+    export PATH="${TOOLS_DIR}":$PATH
+])
+
 dnl
 dnl  Libtool
 dnl  It's very bad, but our former custom system was worst
@@ -406,7 +444,7 @@ AS_IF([test "${enable_shared}" = "no" -a "${enable_vlc}" != "no"], [
 dnl
 dnl Gettext stuff
 dnl
-AM_GNU_GETTEXT_VERSION([0.18.3])
+AM_GNU_GETTEXT_VERSION([0.19.2])
 AM_GNU_GETTEXT([external], [need-ngettext])
 
 dnl
@@ -417,6 +455,7 @@ AM_ICONV
 dnl
 dnl checks for mingw
 AS_IF([test "${SYS}" = "mingw32"], [
+
 dnl Check for broken versions of mingw-runtime compatability library
     AC_MSG_CHECKING(for broken mingw-runtime)
     AC_PREPROC_IFELSE([AC_LANG_SOURCE([
@@ -434,10 +473,14 @@ dnl Check for broken versions of mingw-runtime compatability library
         AC_MSG_RESULT([present])
         AC_MSG_ERROR([LibVLC requires mingw-runtime version 3.15 or higher, or mingw-w64 version 3.0 or higher!])
     ])
+
     dnl force use of mingw provided c99 *printf over msvcrt
     CPPFLAGS="${CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=1"
 
-dnl Check for the need to include the mingwex lib for mingw32
+    dnl Add WinMainCRTStartup entry point to show it's a WinMain application
+    VLC_ADD_LDFLAGS([vlc],[-mwindows])
+
+    dnl Check for the need to include the mingwex lib for mingw32
     VLC_SAVE_FLAGS
     AC_CHECK_LIB(mingwex,opendir,
         AC_CHECK_LIB(mingw32,opendir,,
@@ -445,7 +488,7 @@ dnl Check for the need to include the mingwex lib for mingw32
     )
     VLC_RESTORE_FLAGS
 
-dnl Check for fnative-struct or mms-bitfields support for mingw32
+    dnl Check for fnative-struct or mms-bitfields support for mingw32
     VLC_SAVE_FLAGS
     CFLAGS="${CFLAGS} -mms-bitfields"
     CXXFLAGS="${CXXFLAGS} -mms-bitfields"
@@ -468,11 +511,16 @@ AC_ARG_ENABLE(winstore_app,
                     [Build targetted for Windows Store apps (default disabled)]))
 
 vlc_winstore_app=0
-AS_IF([test "${SYS}" = "mingw32" -a "${enable_winstore_app}" = "yes"], [
+AS_IF([test "${SYS}" = "mingw32"],[
+  AS_IF([test "${enable_winstore_app}" = "yes"], [
     vlc_winstore_app=1
-    VLC_ADD_LIBS([libvlccore], [-lole32 -lruntimeobject])
+     VLC_ADD_LIBS([libvlccore], [-lole32 -lruntimeobject])
+    ],[
+     VLC_ADD_LIBS([libvlccore],[-lwinmm])
     ])
+  ])
 AC_DEFINE_UNQUOTED(VLC_WINSTORE_APP, ${vlc_winstore_app}, [Define to 1 if you want to build for Windows Store apps])
+AM_CONDITIONAL([HAVE_WINSTORE], [test "$vlc_winstore_app" = "1"])
 
 
 dnl
@@ -507,27 +555,17 @@ need_libc=false
 
 dnl Check for usual libc functions
 AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
-AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale])
-AC_REPLACE_FUNCS([atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r lldiv localtime_r nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
+AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r isatty lstat memalign mmap open_memstream openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale pthread_cond_timedwait_monotonic_np pthread_condattr_setclock])
+AC_REPLACE_FUNCS([atof atoll dirfd fdopendir flockfile fsync getdelim getpid lldiv nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
 AC_CHECK_FUNCS(fdatasync,,
   [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
 ])
 
 dnl mingw64 implements those as static inline, not functions with C linkage
-AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([#include <stdio.h>], [
-        char *c;
-        if (asprintf(&c, "%s %d", "string", 1) == -1)
-            c = NULL;
-    ])],[AC_DEFINE([HAVE_ASPRINTF],[1],[Define to 1 if you have asprintf function])],[AC_LIBOBJ([asprintf])])
-AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([#include <stdio.h>
-                     #include <stdarg.h>], [
-        char *c;
-        va_list ap;
-        if (vasprintf(&c, "%s %d", ap) == -1)
-            c = NULL;
-    ])],[AC_DEFINE([HAVE_VASPRINTF],[1],[Define to 1 if you have asprintf function])],[AC_LIBOBJ([vasprintf])])
+VLC_REPLACE_DECL([asprintf], [#include <stdio.h>])
+VLC_REPLACE_DECL([vasprintf], [#include <stdio.h>])
+VLC_REPLACE_DECL([gmtime_r], [#include <time.h>])
+VLC_REPLACE_DECL([localtime_r], [#include <time.h>])
 
 dnl C11 static_assert()
 AC_MSG_CHECKING([for static_assert in assert.h])
@@ -578,9 +616,9 @@ AC_SEARCH_LIBS(connect, [socket], [
   ])
 ])
 
-AC_SEARCH_LIBS([getaddrinfo], [nsl], [
- AS_IF([test "$ac_cv_search_getaddrinfo" != "none required"], [
-    SOCKET_LIBS="$ac_cv_search_getaddrinfo $SOCKET_LIBS"
+AC_SEARCH_LIBS([inet_pton], [nsl], [
+ AS_IF([test "$ac_cv_search_inet_pton" != "none required"], [
+    SOCKET_LIBS="$ac_cv_search_inet_pton $SOCKET_LIBS"
   ])
 ],, [${SOCKET_LIBS}])
 
@@ -600,10 +638,6 @@ AC_LINK_IFELSE([
     ])],[AC_DEFINE([HAVE_INET_PTON],[1],[Define to 1 if you have inet_pton function])],[AC_LIBOBJ([inet_pton])])
 AC_CHECK_FUNCS([if_nameindex if_nametoindex])
 VLC_RESTORE_FLAGS
-
-AS_IF([test -n "$SOCKET_LIBS"], [
-  VLC_ADD_LIBS([access_rtmp access_output_shout sap stream_out_standard stream_out_rtp stream_out_raop vod_rtsp rtp oldrc netsync gnutls ts remoteosd audiobargraph_a],[${SOCKET_LIBS}])
-])
 AC_SUBST(SOCKET_LIBS)
 
 dnl Check for socklen_t
@@ -651,7 +685,6 @@ AC_CHECK_FUNC(getopt_long,, [
 AC_SUBST(GNUGETOPT_LIBS)
 
 AC_CHECK_LIB(m,cos,[
-  VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom noise grain scene chorus_flanger freetype swscale postproc equalizer spatializer param_eq samplerate freetype mpc qt4 compressor headphone_channel_mixer normvol audiobargraph_a audiobargraph_v mono colorthres extract ball hotkeys mosaic gaussianblur x262 x26410b hqdn3d anaglyph oldrc ncurses oldmovie glspectrum],[-lm])
   LIBM="-lm"
 ], [
   LIBM=""
@@ -662,14 +695,17 @@ AC_CHECK_LIB(m,lrintf, [
   AC_DEFINE(HAVE_LRINTF, 1, [Define to 1 if you have the lrintf function])
   VLC_ADD_LIBS([skins2],[-lm])
 ])
+AC_CHECK_LIB(m,nanf,
+  AC_DEFINE(HAVE_NANF, 1, [Define to 1 if you have the NANF function])
+)
 
 dnl Check for dynamic plugins
 LIBDL=""
 have_dynamic_objects="no"
 VLC_SAVE_FLAGS
-AC_SEARCH_LIBS(dlopen, [dl svld], [
-  AS_IF([test "$ac_cv_search_dlopen" != "none required"], [
-    LIBDL="$ac_cv_search_dlopen"
+AC_SEARCH_LIBS(dlsym, [dl svld], [
+  AS_IF([test "$ac_cv_search_dlsym" != "none required"], [
+    LIBDL="$ac_cv_search_dlsym"
   ])
   have_dynamic_objects="yes"
 ])
@@ -718,26 +754,28 @@ AS_IF([test "${SYS}" != "mingw32"], [
 ])
 AC_SUBST(LIBPTHREAD)
 
+dnl
 dnl Check for headers
-AC_CHECK_HEADERS([search.h])
-AC_CHECK_HEADERS(getopt.h locale.h xlocale.h)
-AC_CHECK_HEADERS([sys/time.h sys/ioctl.h])
-AC_CHECK_HEADERS([arpa/inet.h netinet/udplite.h sys/eventfd.h])
+dnl
+
+dnl  POSIX
+AC_CHECK_HEADERS([arpa/inet.h pthread.h search.h sys/shm.h sys/socket.h])
 AC_CHECK_HEADERS([net/if.h], [], [],
-  [
-    #include <sys/types.h>
-    #include <sys/socket.h>
-  ])
-AC_CHECK_HEADERS([sys/mount.h], [], [],
-  [
-    #include <sys/param.h>
-  ])
+[
+#include <sys/types.h>
+#include <sys/socket.h>
+])
+AC_CHECK_HEADER([syslog.h], [have_syslog="yes"], [have_syslog="no"])
+AM_CONDITIONAL([HAVE_SYSLOG], [test "$have_syslog" = "yes"])
+
+dnl  BSD
+AC_CHECK_HEADERS([netinet/udplite.h sys/param.h sys/mount.h])
 
-if test "${SYS}" != "mingw32"; then
-  AC_CHECK_HEADERS(machine/param.h sys/shm.h)
-  AC_CHECK_HEADERS([linux/version.h linux/dccp.h scsi/scsi.h linux/magic.h])
-  AC_CHECK_HEADERS(syslog.h mntent.h)
-fi # end "${SYS}" != "mingw32"
+dnl  GNU/Linux
+AC_CHECK_HEADERS([getopt.h linux/dccp.h linux/magic.h mntent.h sys/eventfd.h])
+
+dnl  MacOS
+AC_CHECK_HEADERS([xlocale.h])
 
 dnl LP64 and LLP64 architectures had better define ssize_t by themselves...
 AH_TEMPLATE(ssize_t, [Define to `int' if <stddef.h> does not define.]) dnl ` (fix VIM syntax highlight
@@ -745,11 +783,6 @@ AC_CHECK_TYPE(ssize_t,, [
   AC_DEFINE(ssize_t, int)
 ])
 
-dnl Check for threads library
-if test "${SYS}" != "mingw32"; then
-  AC_CHECK_HEADERS(pthread.h)
-fi # end "${SYS}" != "mingw32"
-
 dnl It seems that autoconf detects pkg-config only during the first
 dnl PKG_CHECK_MODULES from configure.ac - which makes sense. But in our case,
 dnl it is nested within a conditional block, so it was not working right.
@@ -819,6 +852,16 @@ AS_IF([test "${enable_dbus}" != "no"], [
 ])
 AM_CONDITIONAL([HAVE_DBUS], [test "${have_dbus}" = "yes"])
 
+
+dnl Check for systemd
+PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [
+  have_systemd="yes"
+], [
+  AC_MSG_WARN([${SYSTEMD_PKG_ERRORS}.])
+])
+AM_CONDITIONAL([HAVE_SYSTEMD], [test "${have_systemd}" = "yes"])
+
+
 dnl Check for ntohl, etc.
 VLC_SAVE_FLAGS
 CFLAGS="${CFLAGS} -Wall -Werror"
@@ -837,7 +880,7 @@ dnl
 dnl  Compiler warnings
 dnl
 
-RDC_PROG_CC_WFLAGS([all extra sign-compare undef pointer-arith bad-function-cast write-strings missing-prototypes volatile-register-var error-implicit-function-declaration])
+RDC_PROG_CC_WFLAGS([all extra sign-compare undef pointer-arith bad-function-cast write-strings missing-prototypes volatile-register-var error-implicit-function-declaration init-self logical-op])
 RDC_PROG_CC_FLAGS([-pipe])
 AC_LANG_PUSH([C++])
 RDC_PROG_CXX_WFLAGS([all extra sign-compare undef pointer-arith volatile-register-var])
@@ -922,33 +965,20 @@ AC_ARG_ENABLE(optimizations,
 dnl Check for various optimization flags
 AS_IF([test "${enable_optimizations}" != "no"], [
 
-  dnl -O4 and -O3 only in production builds
-  AS_IF([test "{enable_debug}" = "no"], [
+  dnl -O3 only in production builds
+  AS_IF([test "${enable_debug}" = "no"], [
     VLC_SAVE_FLAGS
-    CFLAGS="${CFLAGS} -O4"
-    CXXFLAGS="${CXXFLAGS} -O4"
-    OBJCFLAGS="${OBJCFLAGS} -O4"
-    AC_CACHE_CHECK([if $CC accepts -O4], [ac_cv_c_o4], [
+    CFLAGS="${CFLAGS} -O3"
+    CXXFLAGS="${CXXFLAGS} -O3"
+    OBJCFLAGS="${OBJCFLAGS} -O3"
+    AC_CACHE_CHECK([if $CC accepts -O3],  [ac_cv_c_o3], [
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
-        ac_cv_c_o4=yes
+        ac_cv_c_o3=yes
       ], [
-        ac_cv_c_o4=no
-      ])
-    ])
-    AS_IF([test "${ac_cv_c_o4}" = "no"], [
-      VLC_RESTORE_FLAGS
-      CFLAGS="${CFLAGS} -O3"
-      CXXFLAGS="${CXXFLAGS} -O3"
-      OBJCFLAGS="${OBJCFLAGS} -O3"
-      AC_CACHE_CHECK([if $CC accepts -O3],  [ac_cv_c_o3], [
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
-          ac_cv_c_o3=yes
-        ], [
-          ac_cv_c_o3=no
-        ])
+        ac_cv_c_o3=no
       ])
-      AS_IF([test "${ac_cv_c_o3}" = "no"], [VLC_RESTORE_FLAGS])
     ])
+    AS_IF([test "${ac_cv_c_o3}" = "no"], [VLC_RESTORE_FLAGS])
   ])
 
   dnl Check for -ffast-math
@@ -966,8 +996,13 @@ AS_IF([test "${enable_optimizations}" != "no"], [
   AS_IF([test "${ac_cv_c_fast_math}" = "no"], [VLC_RESTORE_FLAGS])
   AH_BOTTOM([
 #ifndef __FAST_MATH__
-# pragma STDC FENV_ACCESS OFF
-# pragma STDC FP_CONTRACT ON
+# ifndef _MSC_VER
+#  pragma STDC FENV_ACCESS OFF
+#  pragma STDC FP_CONTRACT ON
+# else
+#  pragma fenv_access(off)
+#  pragma fp_contract(on)
+# endif
 #endif
 ])
 
@@ -1016,24 +1051,6 @@ VLC_RESTORE_FLAGS
 SYMBOLIC_LDFLAGS="${ac_cv_ld_bsymbolic}"
 AC_SUBST(SYMBOLIC_LDFLAGS)
 
-dnl Check for Darwin plugin linking flags
-AS_IF([test "${SYS}" = "darwin"], [
-  VLC_SAVE_FLAGS
-  CFLAGS="${CFLAGS} -bundle -undefined error"
-  AC_CACHE_CHECK([if $CC accepts -bundle -undefined error],
-    [ac_cv_ld_darwin], [
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
-      ac_cv_ld_darwin=yes
-    ], [
-      ac_cv_ld_darwin=no
-    ])
-  ])
-  AS_IF([test "${ac_cv_ld_darwin}" != "no"], [
-    VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error])
-  ])
-  VLC_RESTORE_FLAGS
-])
-
 dnl Checks for __attribute__(aligned()) directive
 VLC_SAVE_FLAGS
 CFLAGS="${CFLAGS} -Werror"
@@ -1394,9 +1411,9 @@ AS_IF([test "${enable_altivec}" = "yes"], [
     [ac_cv_altivec_inline],
     [AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
          ac_cv_altivec_inline="yes",
-         [CFLAGS="${CFLAGS} -Wa,-m7400"
+         [CFLAGS="${CFLAGS} -Wa,-maltivec"
           AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
-            [ac_cv_altivec_inline="-Wa,-m7400"],
+            [ac_cv_altivec_inline="-Wa,-maltivec"],
             ac_cv_altivec_inline=no)
          ])])
   VLC_RESTORE_FLAGS
@@ -1410,53 +1427,18 @@ AS_IF([test "${enable_altivec}" = "yes"], [
     have_altivec="yes"
   ])
 
-dnl The AltiVec C extensions
-dnl
-dnl There are several possible cases:
-dnl - OS X PPC, gcc 4.x: use -mpim-altivec -force_cpusubtype_ALL, don't
-dnl                      need <altivec.h>
-dnl - OS X PPC, gcc 3.x: need -faltivec, don't need <altivec.h>
-dnl - Linux PPC, gcc 3.4, 4.x: need <altivec.h> which requires -maltivec
-dnl - Linux PPC, gcc 3.3: need <altivec.h> and -maltivec -mabi=altivec
-dnl - Linux PPC, gcc 3.x: need <altivec.h> and -fvec
-dnl - Others: test should fail
   VLC_SAVE_FLAGS
   AC_CACHE_CHECK([if \$CC groks AltiVec C extensions],
-  [ac_cv_c_altivec],
-  [# OS X/PPC test (gcc 4.x)
-   CFLAGS="${CFLAGS} -mpim-altivec -force_cpusubtype_ALL"
-   AC_TRY_COMPILE([vector unsigned char foo;],
-     [vec_ld(0, (unsigned char *)0);],
-     [ac_cv_c_altivec="-mpim-altivec -force_cpusubtype_ALL"],
-     [# OS X/PPC test (gcc 3.x)
-      CFLAGS="${CFLAGS} -faltivec"
-      AC_TRY_COMPILE([vector unsigned char foo;],
-        [vec_ld(1 * sizeof(vector float), (unsigned char *)0);],
-        [ac_cv_c_altivec="-faltivec"],
-        dnl Below this are the Linux tests
-        [# Linux/PPC test (gcc 4.x)
-         CFLAGS="${CFLAGS} -maltivec"
-         AC_TRY_COMPILE([#include <altivec.h>],
-           [vec_ld(0, (unsigned char *)0);],
-           [ac_cv_c_altivec="-maltivec"],
-           [# Linux/PPC test (gcc 3.3)
-            CFLAGS="${CFLAGS} -maltivec -mabi=altivec"
-            AC_TRY_COMPILE([#include <altivec.h>],
-              [vec_ld(0, (unsigned char *)0);],
-              [ac_cv_c_altivec=""
-               ac_cv_c_altivec_abi="-maltivec -mabi=altivec"],
-              [# Linux/PPC test (gcc 3.3)
-               CFLAGS="${CFLAGS} -fvec"
-               AC_TRY_COMPILE([#include <altivec.h>],
-                 [vec_ld(0, (unsigned char *)0);],
-                 [ac_cv_c_altivec="-fvec"],
-                 [ac_cv_c_altivec=no])
-              ])
-           ])
-        ])
-     ])
+  [ac_cv_c_altivec], [
+    CFLAGS="${CFLAGS} -maltivec"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
+[#include <altivec.h>]], [
+[vec_ld(0, (unsigned char *)0);]])], [
+      ac_cv_c_altivec="-maltivec"
+    ], [
+      ac_cv_c_altivec="no"
+    ])
   ])
-
   VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_c_altivec}" != "no"], [
     CPPFLAGS="${CPPFLAGS} ${ac_cv_c_altivec}"
@@ -1558,7 +1540,7 @@ then
   AS_IF([test "${LUAC}" = "false"], [
     AC_MSG_ERROR([Could not find the LUA byte compiler.])
   ])
-  AS_IF([test -d ${CONTRIB_DIR} -a -f ${CONTRIB_DIR}/lib/liblua.a -a `echo|${LUAC} -o - -|od -j 8 -N 2 -t x2|head -n 1|cut -d' ' -f2` != 0404], [
+  AS_IF([test -d "${CONTRIB_DIR}" -a -f "${CONTRIB_DIR}/lib/liblua.a" -a `echo|${LUAC} -o - -|od -j 8 -N 2 -t x2|head -n 1|tr -s ' '|cut -d' ' -f2` != 0404], [
     AC_MSG_ERROR([You need 32-bits luac when using using lua from contrib.])
   ])
 fi
@@ -1594,12 +1576,30 @@ AS_IF([test "${enable_vlm}" != "no"], [
 AM_CONDITIONAL([ENABLE_VLM], [test "${enable_vlm}" != "no"])
 
 
+dnl
+dnl Addons manager storage and repositories modules
+dnl
+AC_ARG_ENABLE(addonmanagermodules,
+  [AS_HELP_STRING([--disable-addonmanagermodules],
+    [disable the addons manager modules (default enabled)])])
+if test "${enable_addonmanagermodules}" != "no"
+then
+  AC_DEFINE(ENABLE_ADDONMANAGERMODULES, 1, [Define if you want the addons manager modules])
+fi
+AM_CONDITIONAL([ENABLE_ADDONMANAGERMODULES], [test "${enable_addonmanagermodules}" != "no"])
+
+
 dnl
 dnl  Input plugins
 dnl
 
 EXTEND_HELP_STRING([Input plugins:])
 
+dnl
+dnl  libarchive access module
+dnl
+PKG_ENABLE_MODULES_VLC([ARCHIVE], [access_archive], [libarchive >= 3.1.0], (libarchive support), [auto])
+
 dnl
 dnl  live555 input
 dnl
@@ -1711,30 +1711,17 @@ AS_IF([test "$SYS" = "linux" -a "${enable_linsys}" != "no"], [
 dnl
 dnl dvdread module: check for libdvdread
 dnl
-PKG_ENABLE_MODULES_VLC([DVDREAD], [], [dvdread], [dvdread input module], [auto])
+PKG_ENABLE_MODULES_VLC([DVDREAD], [], [dvdread > 4.9.0], [dvdread input module], [auto])
 
 dnl
 dnl libdvdnav plugin
 dnl
-AC_ARG_ENABLE(dvdnav,
-  [AS_HELP_STRING([--disable-dvdnav],
-    [disable DVD navigation with libdvdnav (default auto)])])
-AS_IF([test "${enable_dvdnav}" != "no"], [
-  PKG_CHECK_MODULES(DVDNAV, dvdnav, [
-    VLC_ADD_PLUGIN([dvdnav])
-    AC_CHECK_LIB(dvdnav, dvdnav_get_video_resolution,
-      AC_DEFINE(HAVE_DVDNAV_GET_VIDEO_RESOLUTION, 1, [Define if you have dvdnav_get_video_resolution.]),
-        [], [${LIBS_dvdnav}])
-    AC_CHECK_LIB(dvdnav, dvdnav_describe_title_chapters,
-      AC_DEFINE(HAVE_DVDNAV_DESCRIBE_TITLE_CHAPTERS, 1, [Define if you have dvdnav_describe_title_chapters.]),
-        [], [${LIBS_dvdnav}])],
-      [AC_MSG_WARN([${DVDNAV_PKG_ERRORS}.])])
-])
+PKG_ENABLE_MODULES_VLC([DVDNAV], [], [dvdnav > 4.9.0], [DVD with navigation input module (dvdnav)], [auto])
 
 dnl
 dnl  Blu-ray Disc Support with libbluray
 dnl
-PKG_ENABLE_MODULES_VLC([BLURAY], [libbluray], [libbluray >= 0.2.1], (libbluray for Blu-ray disc support ) )
+PKG_ENABLE_MODULES_VLC([BLURAY], [libbluray], [libbluray >= 0.5.0], (libbluray for Blu-ray disc support ) )
 
 dnl
 dnl  OpenCV wrapper and example filters
@@ -1746,13 +1733,17 @@ dnl
 dnl  libsmbclient plugin
 dnl
 PKG_ENABLE_MODULES_VLC([SMBCLIENT], [smb], [smbclient], (SMB/CIFS support), [auto])
-AS_IF([test "${SYS}" = "mingw32"], [ VLC_ADD_PLUGIN([access_smb]) ])
+AS_IF([test "${SYS}" = "mingw32"], [ VLC_ADD_PLUGIN([smb]) ])
 
+dnl
+dnl  liBDSM access module
+dnl
+PKG_ENABLE_MODULES_VLC([DSM], [dsm], [libdsm >= 0.0.4], [libdsm SMB/CIFS access/sd module], [auto])
 
 dnl
 dnl sftp access support
 dnl
-PKG_ENABLE_MODULES_VLC([SFTP], [access_sftp], [libssh2], (support SFTP file transfer via libssh2), [auto])
+PKG_ENABLE_MODULES_VLC([SFTP], [sftp], [libssh2], (support SFTP file transfer via libssh2), [auto])
 
 dnl
 dnl  Video4Linux 2
@@ -1956,6 +1947,12 @@ then
 fi
 AM_CONDITIONAL(HAVE_AVFOUNDATION, [test "${have_avfoundation}" != "no"])
 
+dnl
+dnl  DCP plugin (using asdcplib)
+dnl
+PKG_WITH_MODULES([ASDCP], [asdcplib], [have_asdcp="yes"])
+AM_CONDITIONAL(HAVE_ASDCP, [test "${have_asdcp}" = "yes"])
+
 dnl
 dnl  Demux plugins
 dnl
@@ -1966,7 +1963,7 @@ dnl
 dnl  libdvbpsi check for ts mux/demux
 dnl
 have_dvbpsi="no"
-PKG_WITH_MODULES([DVBPSI], [libdvbpsi], [have_dvbpsi="yes"])
+PKG_WITH_MODULES([DVBPSI], [libdvbpsi >= 1.0.0], [have_dvbpsi="yes"])
 AM_CONDITIONAL(HAVE_DVBPSI, [test "${have_dvbpsi}" = "yes"])
 
 
@@ -2022,9 +2019,12 @@ AS_IF([test "${enable_sid}" != "no"], [
 dnl
 dnl  ogg demux plugin
 dnl
-PKG_ENABLE_MODULES_VLC([OGG], [], [ogg >= 1.0], [Ogg demux support], [auto])
+PKG_ENABLE_MODULES_VLC([OGG], [mux_ogg], [ogg >= 1.0], [Ogg demux support], [auto])
+PKG_CHECK_MODULES(LIBVORBIS, [vorbis >= 1.1], [
+    AC_DEFINE(HAVE_LIBVORBIS, 1, [Define to 1 if you have the libvorbis])
+],[true])
+PKG_ENABLE_MODULES_VLC([OGG], [], [ogg >= 1.0], [Ogg demux support], [auto], [${LIBVORBIS_CFLAGS}], [${LIBVORBIS_LIBS}])
 if test "${enable_sout}" != "no"; then
-    PKG_ENABLE_MODULES_VLC([MUX_OGG], [], [ogg >= 1.0], [Ogg mux support], [auto])
 dnl Check for libshout
     PKG_ENABLE_MODULES_VLC([SHOUT], [access_output_shout], [shout >= 2.1], [libshout output plugin], [auto])
 fi
@@ -2090,6 +2090,7 @@ if test "${enable_mod}" != "no" ; then
     PKG_CHECK_MODULES(LIBMODPLUG, [libmodplug >= 0.8.4 libmodplug != 0.8.8], [
           VLC_ADD_PLUGIN([mod])
           VLC_ADD_CXXFLAGS([mod],[$LIBMODPLUG_CFLAGS])
+          VLC_ADD_CFLAGS([mod],[$LIBMODPLUG_CFLAGS]) #modules/demux/mod.c needs CFLAGS_mod, not CXXFLAGS_mod
           VLC_ADD_LIBS([mod],[$LIBMODPLUG_LIBS])
     ],[
        AS_IF([test -n "${enable_mod}"],
@@ -2130,14 +2131,10 @@ then
 fi
 
 dnl
-dnl shine fixed point mp3 encoder
+dnl shine encoder plugin
 dnl
-AC_ARG_ENABLE(shine,
-  [  --enable-shine          shine mp3 encoding module (default disabled)])
-if test "${enable_shine}" = "yes"
-then
-  VLC_ADD_PLUGIN([shine])
-fi
+PKG_ENABLE_MODULES_VLC([SHINE], [], [shine >= 3.0.0], [MPEG Audio Layer 3 encoder], [auto], [], [], [])
+
 
 dnl
 dnl openmax il codec plugin
@@ -2202,61 +2199,45 @@ fi
 dnl
 dnl  mad plugin
 dnl
+have_mad="no"
+MAD_CFLAGS=""
+MAD_LIBS=""
+
+AC_ARG_WITH(mad, [  --with-mad=PATH         path to libmad], [
+  enable_mad="yes"
+], [
+  with_mad="no"
+])
+AS_IF([test "${with_mad}" != "no"], [
+  MAD_CFLAGS="-I${with_mad}/include"
+  MAD_LIBS="-L${with_mad}/lib"
+])
+
 AC_ARG_ENABLE(mad,
   [  --enable-mad            libmad module (default enabled)])
-if test "${enable_mad}" != "no"
-then
-  AC_ARG_WITH(mad,
-    [  --with-mad=PATH         path to libmad],[],[])
-  if test "${with_mad}" != "no" -a -n "${with_mad}"
-  then
-    VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${with_mad}/include])
-    VLC_ADD_LIBS([mpgatofixed32],[-L${with_mad}/lib])
-  fi
-
-  AC_ARG_WITH(mad-tree,
-    [  --with-mad-tree=PATH    mad tree for static linking],[],[])
-  if test "${with_mad_tree}" != "no" -a -n "${with_mad_tree}"
-  then
-    real_mad_tree="`cd ${with_mad_tree} 2>/dev/null && pwd`"
-    if test -z "${real_mad_tree}"
-    then
-      dnl  The given directory can't be found
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_mad_tree} directory does not exist])
-    fi
-    dnl  Use a custom libmad
-    AC_MSG_CHECKING(for mad.h in ${real_mad_tree})
-    if test -f ${real_mad_tree}/mad.h
-    then
-      AC_MSG_RESULT(yes)
-      VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${real_mad_tree}])
-      VLC_ADD_LIBS([mpgatofixed32],[-L${real_mad_tree}/.libs])
-      VLC_SAVE_FLAGS
-      LDFLAGS="${LDFLAGS} ${LIBS_mpgatofixed32}"
-      AC_CHECK_LIB(mad, mad_bit_init, [
-        VLC_ADD_PLUGIN([mpgatofixed32])
-        VLC_ADD_LIBS([mpgatofixed32],[-lmad])
-        ],[ AC_MSG_ERROR([the specified tree has not been compiled ])
-      ],[])
-      VLC_RESTORE_FLAGS
-    else
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([the specified tree does not have mad.h])
-    fi
-  else
-    VLC_SAVE_FLAGS
-    CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_mpgatofixed32}"
-    LDFLAGS="${LDFLAGS} ${LIBS_mpgatofixed32}"
-    AC_CHECK_HEADERS(mad.h, ,
-      [ AC_MSG_ERROR([Could not find libmad on your system: you may get it from http://www.underbit.com/products/mad/. Alternatively you can use --disable-mad to disable the mad plugin.]) ])
+AS_IF([test "${enable_mad}" != "no"], [
+  VLC_SAVE_FLAGS
+  CPPFLAGS="${CPPFLAGS} ${MAD_CFLAGS}"
+  LDFLAGS="${LDFLAGS} ${MAD_LIBS}"
+  AC_CHECK_HEADERS(mad.h, [
     AC_CHECK_LIB(mad, mad_bit_init, [
-      VLC_ADD_PLUGIN([mpgatofixed32])
-      VLC_ADD_LIBS([mpgatofixed32],[-lmad])],
-      [ AC_MSG_ERROR([Cannot find libmad library...]) ])
-    VLC_RESTORE_FLAGS
-  fi
-fi
+      have_mad="yes"
+      MAD_LIBS="${MAD_LIBS} -lmad"
+    ])
+  ])
+  VLC_RESTORE_FLAGS
+  AS_IF([test -n "$enable_mad" -a "${have_mad}" = "no"], [
+    AC_MSG_ERROR([Could not find libmad. Install it or pass --disable-mad to disable it.])
+  ])
+])
+AC_SUBST(MAD_CFLAGS)
+AC_SUBST(MAD_LIBS)
+AM_CONDITIONAL([HAVE_MAD], [test "${have_mad}" = "yes"])
+
+dnl  mpg123 plugin
+dnl
+dnl
+PKG_ENABLE_MODULES_VLC([MPG123], [mpg123], [libmpg123], [libmpg123 decoder support], [auto])
 
 
 AC_ARG_ENABLE(merge-ffmpeg,
@@ -2265,13 +2246,47 @@ AC_ARG_ENABLE(merge-ffmpeg,
 ])
 AM_CONDITIONAL([MERGE_FFMPEG], [test "$enable_merge_ffmpeg" != "no"])
 
+AC_MSG_CHECKING([for libavutil variant])
+PKG_CHECK_EXISTS([libavutil], [
+  libavutil_version="$(${PKG_CONFIG} --modversion libavutil)"
+  libavutil_micro="${libavutil_version##*.}"
+  AS_IF([test ${libavutil_micro} -le 99], [
+    avfork="libav"
+  ], [
+    avfork="ffmpeg"
+  ])
+], [
+  avfork="none"
+])
+AC_MSG_RESULT([${avfork}])
+
+dnl
+dnl gstreamer stuff
+dnl
+AC_ARG_ENABLE(gst-decode,
+  [  --enable-gst-decode     GStreamer based decoding support (currently supports only video decoding) (default auto)])
+
+have_gst_decode="no"
+AS_IF([test "${enable_gst_decode}" != "no"], [
+  PKG_CHECK_MODULES([GST_APP], [gstreamer-app-1.0], [
+    PKG_CHECK_MODULES([GST_VIDEO], [gstreamer-video-1.0], [
+      have_gst_decode="yes"
+    ], [
+      AC_MSG_WARN([${GST_VIDEO_PKG_ERRORS}. GStreamer decoder module will not be built.])
+    ])
+  ], [
+    AC_MSG_WARN([${GST_APP_PKG_ERRORS}. GStreamer modules will not be built.])
+  ])
+])
+AM_CONDITIONAL([HAVE_GST_DECODE], [test "${have_gst_decode}" = "yes"])
+
 dnl
 dnl  avcodec decoder/encoder plugin
 dnl
 AC_ARG_ENABLE(avcodec,
 [  --enable-avcodec        libavcodec codec (default enabled)])
 AS_IF([test "${enable_avcodec}" != "no"], [
-  PKG_CHECK_MODULES(AVCODEC,[libavcodec >= 53.34.0 libavutil >= 51.22.0], [
+  PKG_CHECK_MODULES(AVCODEC,[libavcodec >= 54.25.0 libavutil >= 52.0.0], [
     dnl PKG_CHECK_EXISTS([libavcodec < 56],, [
     dnl   AC_MSG_ERROR([libavcodec versions 56 and later are not supported yet.])
     dnl ])
@@ -2299,30 +2314,50 @@ AC_ARG_ENABLE(libva,
 AS_IF([test "${enable_libva}" = "yes" -a "${have_avcodec}" != "yes" ], [
   AC_MSG_ERROR([--enable-libva and --disable-avcodec options are mutually exclusive. Use --enable-avcodec.])
 ])
-have_avcodec_vaapi="no"
-AS_IF([test "${enable_libva}" != "no" -a "${have_avcodec}" = "yes"], [
-  PKG_CHECK_MODULES(LIBVA, [libva libva-x11], [
-    VLC_SAVE_FLAGS
-    CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
-    CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
-    AC_CHECK_HEADERS(libavcodec/vaapi.h, [
-      AC_MSG_NOTICE([VAAPI acceleration activated])
-      have_avcodec_vaapi="yes"
-    ],[
-      AS_IF([test -n "${enable_libva}"], [
-        AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])
-      ], [
-        AC_MSG_WARN([libva is present but libavcodec/vaapi.h is missing ])
-      ])
-    ])
-    VLC_RESTORE_FLAGS
-  ],[
+
+have_vaapi="no"
+have_vaapi_drm="no"
+have_vaapi_x11="no"
+AS_IF([test "${enable_libva}" != "no"], [
+  PKG_CHECK_EXISTS([libva], [
+    have_vaapi="yes"
+  ], [
     AS_IF([test -n "${enable_libva}"], [
       AC_MSG_ERROR([${LIBVA_PKG_ERRORS}.])
     ], [
       AC_MSG_WARN([${LIBVA_PKG_ERRORS}.])
     ])
   ])
+  PKG_CHECK_MODULES([LIBVA_DRM], [libva-drm], [
+    have_vaapi_drm="yes"
+  ], [
+    AC_MSG_WARN([${LIBVA_DRM_PKG_ERRORS}.])
+  ])
+  PKG_CHECK_MODULES(LIBVA_X11, [libva-x11], [
+    have_vaapi_x11="yes"
+  ], [
+    AC_MSG_WARN([${LIBVA_X11_PKG_ERRORS}.])
+  ])
+])
+AM_CONDITIONAL([HAVE_VAAPI_DRM], [test "${have_vaapi_drm}" = "yes"])
+AM_CONDITIONAL([HAVE_VAAPI_X11], [test "${have_vaapi_x11}" = "yes"])
+
+have_avcodec_vaapi="no"
+AS_IF([test "${have_vaapi}" = "yes" -a "${have_avcodec}" = "yes"], [
+  VLC_SAVE_FLAGS
+  CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
+  CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
+  AC_CHECK_HEADERS([libavcodec/vaapi.h], [
+    AC_MSG_NOTICE([VAAPI acceleration activated])
+    have_avcodec_vaapi="yes"
+  ],[
+    AS_IF([test -n "${enable_libva}"], [
+      AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])
+    ], [
+      AC_MSG_WARN([libva is present but libavcodec/vaapi.h is missing ])
+    ])
+  ])
+  VLC_RESTORE_FLAGS
 ])
 AM_CONDITIONAL([HAVE_AVCODEC_VAAPI], [test "${have_avcodec_vaapi}" = "yes"])
 
@@ -2373,25 +2408,31 @@ AS_IF([test "${enable_vda}" != "no"], [
   if test "${SYS}" = "darwin"; then
   AS_IF([test "x${have_avcodec}" = "xyes"], [
     AC_CHECK_HEADERS(VideoDecodeAcceleration/VDADecoder.h,
-    [
-      PKG_CHECK_EXISTS([libavcodec >= 55.19.0], [
-        have_avcodec_vda="yes"
-      ],[
-        AS_IF([test "${enable_vda}" = "yes"],
-         [AC_MSG_ERROR([libavcodec >= 55.19.0 is required for VDA decoding])],
-         [AC_MSG_WARN([libavcodec >= 55.19.0 is required for VDA decoding])])
-      ])
-    ],[
+      [
+        AC_CHECK_HEADERS(libavcodec/vda.h, [
+           have_avcodec_vda="yes"
+        ],[
        AS_IF([test "${enable_vda}" = "yes"],
-      [AC_MSG_ERROR([Could not find required VideoDecodeAcceleration/VDADecoder.h])],
-      [AC_MSG_WARN([VideoDecodeAcceleration/VDADecoder.h not found])])
-    ])
+             [AC_MSG_ERROR([vda is present but libavcodec/vda.h is missing])],
+              [AC_MSG_WARN([vda is present but libavcodec/vda.h is missing ])])
+        ])
+  ],[
+       AS_IF([test "${enable_vda}" = "yes"],
+              [AC_MSG_ERROR([Could not find required VideoDecodeAcceleration/VDADecoder.h])],
+              [AC_MSG_WARN([VideoDecodeAcceleration/VDADecoder.h not found])])
+      ])
   ],[
     AS_IF([test "x${enable_vda}" != "x"], [
       AC_MSG_ERROR([--enable-vda and --disable-avcodec options are mutually exclusive.])
     ])
-  ])
-  fi
+ ])
+ AS_IF([test "${have_avcodec_vda}" = "yes"], [
+     SAVE_LIBS=$LIBS
+     LIBS="$LIBS $AVCODEC_LIBS"
+     AC_CHECK_FUNCS([av_vda_alloc_context])
+     LIBS=$SAVE_LIBS
+ ])
+ fi
 ])
 AM_CONDITIONAL([HAVE_AVCODEC_VDA], [test "${have_avcodec_vda}" = "yes"])
 
@@ -2411,6 +2452,7 @@ AS_IF([test "${enable_avformat}" != "no"], [
       CPPFLAGS="${CPPFLAGS} ${AVFORMAT_CFLAGS}"
       CFLAGS="${CFLAGS} ${AVFORMAT_CFLAGS}"
       AC_CHECK_HEADERS(libavformat/avformat.h libavformat/avio.h)
+      AC_CHECK_HEADERS(libavcodec/avcodec.h)
       AC_CHECK_HEADERS(libavutil/avutil.h)
       AS_IF([test "$enable_merge_ffmpeg" = "no"], [
         have_avformat="no"
@@ -2437,6 +2479,7 @@ then
       CPPFLAGS="${CPPFLAGS} ${SWSCALE_CFLAGS}"
       CFLAGS="${CFLAGS} ${SWSCALE_CFLAGS}"
       AC_CHECK_HEADERS(libswscale/swscale.h)
+      AC_CHECK_HEADERS(libavutil/avutil.h)
       VLC_ADD_PLUGIN([swscale])
       VLC_ADD_LIBS([swscale],[$SWSCALE_LIBS])
       VLC_ADD_CFLAGS([swscale],[$SWSCALE_CFLAGS])
@@ -2464,8 +2507,6 @@ then
       CFLAGS="${CFLAGS} ${POSTPROC_CFLAGS}"
       AC_CHECK_HEADERS(postproc/postprocess.h)
       VLC_ADD_PLUGIN([postproc])
-      VLC_ADD_LIBS([postproc],[$POSTPROC_LIBS $AVUTIL_LIBS])
-      VLC_ADD_CFLAGS([postproc],[$POSTPROC_CFLAGS $AVUTIL_CFLAGS])
       VLC_RESTORE_FLAGS
     ],[
       AC_MSG_WARN([${POSTPROC_PKG_ERRORS}.])
@@ -2477,47 +2518,46 @@ dnl  faad decoder plugin
 dnl
 AC_ARG_ENABLE(faad,
 [  --enable-faad           faad codec (default auto)])
-if test "${enable_faad}" != "no"; then
-  AC_ARG_WITH(faad-tree,  [  --with-faad-tree=PATH   faad tree for static linking])
-  if test -n "${with_faad_tree}"; then
-    AC_MSG_CHECKING(for libfaad.a in ${with_faad_tree})
-    real_faad_tree="`cd ${with_faad_tree} 2>/dev/null && pwd`"
-    if test -z "${real_faad_tree}"; then
-      dnl  The given directory can't be found
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot cd to ${with_faad_tree}])
-    fi
-    if test -f "${real_faad_tree}/libfaad/.libs/libfaad.a"; then
-      dnl  Use the custom faad
-      AC_MSG_RESULT(${real_faad_tree}/libfaad/.libs/libfaad.a)
+have_faad="no"
+AS_IF([test "${enable_faad}" != "no"], [
+  AC_CHECK_HEADERS([faad.h], [
+    AC_CHECK_LIB(faad, faacDecOpen, [have_faad="yes"],, [$LIBM])
+    AC_CHECK_LIB(faad, NeAACDecOpen, [have_faad="yes"],, [$LIBM])
+
+    AS_IF([test "${have_faad}" = "yes"], [
       VLC_ADD_PLUGIN([faad])
-      VLC_ADD_LIBS([faad],[${real_faad_tree}/libfaad/.libs/libfaad.a])
-      VLC_ADD_CPPFLAGS([faad],[-I${real_faad_tree}/include])
-    else
-      dnl  The given libfaad wasn't built
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
-    fi
-  else
-    VLC_SAVE_FLAGS
-    CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_faad}"
-    LDFLAGS="${LDFLAGS} ${LIBS_faad}"
-    AC_CHECK_HEADERS(faad.h,
-      [ AC_CHECK_LIB(faad, faacDecOpen, [
-          VLC_ADD_PLUGIN([faad])
-          VLC_ADD_LIBS([faad],[-lfaad]) ], [
-            AC_CHECK_LIB(faad, NeAACDecOpen, [
-              VLC_ADD_PLUGIN([faad])
-              VLC_ADD_LIBS([faad],[-lfaad]) ], [
-                AS_IF([test "${enable_faad}" = "yes"],
-                [ AC_MSG_ERROR([Cannot find libfaad library...]) ],
-                [ AC_MSG_WARN([Cannot find libfaad library...]) ]) ]) ])
-      ] , [ AS_IF([test "${enable_faad}" = "yes"],
-        [ AC_MSG_ERROR([Cannot find development headers for libfaad...]) ],
-        [ AC_MSG_WARN([Cannot find development headers for libfaad...]) ]) ])
-    VLC_RESTORE_FLAGS
-  fi
-fi
+      VLC_ADD_LIBS([faad],[-lfaad])
+    ], [
+      AS_IF([test "${enable_faad}" = "yes"], [
+        AC_MSG_ERROR([cannot find FAAD library])
+      ], [
+        AC_MSG_WARN([cannot find FAAD library])
+      ])
+    ])
+  ])
+])
+
+dnl
+dnl libvpx decoder plugin
+dnl
+AC_ARG_ENABLE(vpx,
+    AS_HELP_STRING([--enable-vpx],[libvpx VP8/VP9 decoder (default auto)]))
+AS_IF([test "${enable_vpx}" != "no"],[
+    PKG_CHECK_MODULES([VPX], [vpx] , [
+        VLC_ADD_PLUGIN([vpx])
+        VLC_ADD_CPPFLAGS([vpx], [${VPX_CFLAGS}])
+        VLC_ADD_LIBS([vpx], [${VPX_LIBS}])
+        AC_CHECK_LIB([vpx],[vpx_codec_vp8_dx], [
+            VLC_ADD_CPPFLAGS([vpx], [-DENABLE_VP8_DECODER])
+        ], [], [${VPX_LIBS}])
+        AC_CHECK_LIB([vpx],[vpx_codec_vp9_dx], [
+            VLC_ADD_CPPFLAGS([vpx], [-DENABLE_VP9_DECODER])
+        ], [], [${VPX_LIBS}])
+    ], [
+    AS_IF([test "${enable_vpx}" = "yes"],[
+        AC_MSG_ERROR([libvpx was not found])
+    ])])
+])
 
 dnl
 dnl twolame encoder plugin
@@ -2554,43 +2594,6 @@ if test "${enable_a52}" != "no"
 then
   AC_ARG_WITH(a52,
     [  --with-a52=PATH         a52 headers and libraries])
-  AC_ARG_WITH(a52-tree,
-    [  --with-a52-tree=PATH    a52dec tree for static linking ],[],[])
-  if test "${with_a52_tree}" != "no" -a -n "${with_a52_tree}"
-  then
-    real_a52_tree="`cd ${with_a52_tree} 2>/dev/null && pwd`"
-    if test -z "${real_a52_tree}"
-    then
-      dnl  The given directory can't be found
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_a52_tree} directory does not exist])
-    fi
-    dnl  Use a custom a52dec
-    AC_MSG_CHECKING(for a52.h in ${real_a52_tree}/include)
-    if test -f ${real_a52_tree}/include/a52.h
-    then
-      AC_MSG_RESULT(yes)
-      VLC_ADD_CPPFLAGS([a52tofloat32],[-I${real_a52_tree}])
-      VLC_ADD_LIBS([a52tofloat32],[-L${real_a52_tree}/liba52/.libs])
-      VLC_SAVE_FLAGS
-      LDFLAGS="${LDFLAGS} ${LIBS_a52tofloat32}"
-      AC_CHECK_LIB(a52, a52_free, [
-        VLC_ADD_PLUGIN([a52tofloat32])
-        VLC_ADD_CPPFLAGS([a52tofloat32],[-DUSE_A52DEC_TREE])
-        VLC_ADD_LIBS([a52tofloat32],[-la52])
-        ],[
-        if test -f ${real_a52_tree}/liba52/.libs/liba52.a
-        then
-          AC_MSG_ERROR([make sure you have at least a52dec-0.7.3 ($real_a52_tree)])
-        else
-          AC_MSG_ERROR([the specified tree has not been compiled])
-        fi
-      ])
-    else
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([the specified tree does not have a52.h])
-    fi
-  else
     if test -z "${with_a52}"
     then
       LDFLAGS_test=""
@@ -2614,7 +2617,6 @@ then
       AC_MSG_ERROR([Could not find liba52 on your system: you may get it from http://liba52.sf.net/. Alternatively you can use --disable-a52 to disable the a52 plugin.])
     ])
     VLC_RESTORE_FLAGS
-  fi
 fi
 
 dnl
@@ -2666,7 +2668,7 @@ AM_CONDITIONAL([HAVE_SPEEXDSP], [test "$have_speexdsp" = "yes"])
 dnl
 dnl  Opus plugin
 dnl
-PKG_ENABLE_MODULES_VLC([OPUS], [], [ogg opus], [Opus support], [auto])
+PKG_ENABLE_MODULES_VLC([OPUS], [], [ogg opus >= 1.0.3], [Opus support], [auto])
 
 dnl
 dnl  theora decoder plugin
@@ -2674,9 +2676,9 @@ dnl
 PKG_ENABLE_MODULES_VLC([THEORA], [], [ogg theoradec >= 1.0 theoraenc], [experimental theora codec], [auto])
 
 dnl
-dnl  dirac encoder plugin
+dnl  Daala decoder plugin
 dnl
-PKG_ENABLE_MODULES_VLC([DIRAC], [], [dirac >= 0.10.0], [dirac encoder], [auto])
+PKG_ENABLE_MODULES_VLC([DAALA], [], [ogg daaladec daalaenc], [experimental daala codec], [disabled])
 
 dnl
 dnl  schroedinger decoder plugin (for dirac format video)
@@ -2699,33 +2701,34 @@ AC_CHECK_HEADERS(png.h, [
   ])
 ])
 
+dnl
+dnl  JPEG decoder module
+dnl
+AC_ARG_ENABLE(jpeg,
+  [  --enable-jpeg           JPEG support (default enabled)])
+AS_IF([test "${enable_jpeg}" != "no"], [
+AC_CHECK_HEADERS(jpeglib.h, [
+  VLC_ADD_PLUGIN([jpeg])
+  ])
+])
+
+dnl
+dnl  BPG decoder module
+dnl
+AC_ARG_ENABLE(bpg,
+  [  --enable-bpg           BPG support (default disabled)])
+AS_IF([test "${enable_bpg}" != "no"], [
+AC_CHECK_HEADERS(libbpg.h, [
+  VLC_ADD_PLUGIN([bpg])
+  ])
+])
+
 dnl
 dnl H262 encoder plugin (lib262)
 dnl
 AC_ARG_ENABLE(x262,
   [  --enable-x262           H262 encoding support with static libx262 (default disabled)])
 if test "${enable_x262}" != "no"; then
-AC_ARG_WITH(x262-tree,
-  [ --with-x262-tree=PATH      H262 encoding module with libx262 (static linking)],[],[])
-  if test "${with_x262_tree}" != "no" -a -n "${with_x262_tree}"
-  then
-    real_x262_tree="̧`cd ${with_x262_tree} 2>/dev/null && pwd`"
-    if test -z "${real_x262_tree}"
-    then
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_x262_tree} directory does not exist])
-    fi
-    AC_MSG_CHECKING(for x262.h in ${real_x262_tree})
-    if test -f ${with_x262_tree}/x262_config.h
-    then
-      VLC_ADD_PLUGIN([x262])
-      VLC_ADD_CFLAGS([x262],[-I${with_x262_tree}])
-      VLC_ADD_LIBS([x262],[-L${with_x262_tree} -lm -lpthread -lx262])
-    else
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_x262_tree} doesnt have x262_config.h])
-    fi
-  else
     PKG_CHECK_MODULES(X262, x262, [
         VLC_ADD_PLUGIN([x262])
         VLC_ADD_LDFLAGS([x262],[${X262_LIBS}])
@@ -2741,27 +2744,10 @@ AC_ARG_WITH(x262-tree,
         AC_MSG_ERROR([x262 module doesn't work without staticly compiled libx262.a])
        fi
     ])
-  fi
 fi
 
 dnl x265 encoder
-AC_ARG_ENABLE(x265,
-  AS_HELP_STRING([--enable-x265],[H265 / HEVC encoding support with libx265 (default enabled)]))
-AS_IF( [test "${enable_x265}" != "no"],[
-  AC_CHECK_HEADER([x265.h], [
-      AC_CHECK_LIB([x265],[x265_encoder_open], [
-        VLC_ADD_PLUGIN([x265])
-        VLC_ADD_LIBS([x265], [-lx265 -lstdc++ -lm -lpthread])
-      ], [
-        AC_MSG_ERROR([x265 library not found])
-      ], [-lstdc++ -lm -lpthread])
-  ], [
-    AS_IF([test "${enable_x265}" = "yes"], [
-        AC_MSG_ERROR([x265.h not found])
-    ])
-  ])
-])
-
+PKG_ENABLE_MODULES_VLC([X265],, [x265], [HEVC/H.265 encoder], [auto])
 
 dnl
 dnl H264 encoder plugin (10-bit lib264)
@@ -2769,35 +2755,6 @@ dnl
 AC_ARG_ENABLE(x26410b,
   [  --enable-x26410b           H264 10-bit encoding support with static libx264 (default disabled)])
 if test "${enable_x26410b}" != "no"; then
-AC_ARG_WITH(x26410b-tree,
-  [ --with-x26410b-tree=PATH      H264 10-bit encoding module with libx264 (static linking)],[],[])
-  if test "${with_x26410b_tree}" != "no" -a -n "${with_x26410b_tree}"
-  then
-    real_x26410b_tree="̧`cd ${with_x26410b_tree} 2>/dev/null && pwd`"
-    if test -z "${real_x26410b_tree}"
-    then
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_x26410b_tree} directory does not exist])
-    fi
-    AC_MSG_CHECKING(for x264.h in ${real_x26410b_tree})
-    if test -f ${with_x26410b_tree}/x264_config.h
-    then
-      AC_MSG_RESULT(yes)
-      AC_MSG_CHECKING(for 10-bit build of x264)
-      if grep -q "BIT_DEPTH.*10"  ${with_x26410b_tree}/x264_config.h ;then
-        AC_MSG_RESULT(yes)
-        VLC_ADD_PLUGIN([x26410b])
-        VLC_ADD_CFLAGS([x26410b],[-I${with_x26410b_tree}])
-        VLC_ADD_LIBS([x26410b],[-L${with_x26410b_tree} -lm -lpthread -lx264])
-      else
-        AC_MSG_RESULT(no)
-        AC_MSG_ERROR([${with_x26410b_tree} isnt build 10-bit])
-      fi
-    else
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_x26410b_tree} doesnt have x264_config.h])
-    fi
-  else
     PKG_CHECK_MODULES(X26410B, x26410b, [
         VLC_ADD_PLUGIN([x26410b])
         VLC_ADD_LIBS([x26410b],[${X26410B_LIBS}])
@@ -2813,7 +2770,6 @@ AC_ARG_WITH(x26410b-tree,
         AC_MSG_ERROR([x26410b module doesn't work without staticly compiled libx264.a])
        fi
     ])
-  fi
 fi
 
 
@@ -2823,39 +2779,6 @@ dnl
 AC_ARG_ENABLE(x264,
   [  --enable-x264           H264 encoding support with libx264 (default enabled)])
 if test "${enable_x264}" != "no"; then
-  AC_ARG_WITH(x264-tree,
-    [  --with-x264-tree=PATH   x264 tree for static linking ],[],[])
-  if test "${with_x264_tree}" != "no" -a -n "${with_x264_tree}"
-  then
-    real_x264_tree="`cd ${with_x264_tree} 2>/dev/null && pwd`"
-    if test -z "${real_x264_tree}"
-    then
-      dnl  The given directory can't be found
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([${with_x264_tree} directory does not exist])
-    fi
-    dnl  Use a custom libx264
-    AC_MSG_CHECKING(for x264.h in ${real_x264_tree})
-    if test -f ${real_x264_tree}/x264.h
-    then
-      AC_MSG_RESULT(yes)
-      VLC_ADD_CPPFLAGS([x264],[-I${real_x264_tree}])
-      VLC_ADD_LIBS([x264],[-L${real_x264_tree}])
-      PKG_CHECK_MODULES(X264,x264, [
-        VLC_ADD_PLUGIN([x264])
-        VLC_ADD_LIBS([x264],[${X264_LIBS}])
-        VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
-        if echo ${X264_LIBS} |grep -q 'pthreadGC2'; then
-          VLC_ADD_CFLAGS([x264], [-DPTW32_STATIC_LIB])
-        fi
-      ],[
-        AC_MSG_ERROR([the specified tree has not been compiled])
-      ])
-    else
-      AC_MSG_RESULT(no)
-      AC_MSG_ERROR([the specified tree does not have x264.h])
-    fi
-  else
       PKG_CHECK_MODULES(X264,x264 >= 0.86, [
         VLC_ADD_PLUGIN([x264])
         VLC_ADD_LIBS([x264],[${X264_LIBS}])
@@ -2873,7 +2796,6 @@ if test "${enable_x264}" != "no"; then
             AC_MSG_ERROR([${X264_PKG_ERRORS}: you may get it from http://www.videolan.org/x264.html])
           fi
       ])
-  fi
 fi
 
 dnl
@@ -2934,6 +2856,29 @@ AS_IF( [test "${enable_libass}" != "no"], [
       ])
   ])
 
+dnl
+dnl ARIB subtitles rendering module
+dnl
+AC_ARG_ENABLE(aribsub,
+  [  --enable-aribsub        ARIB Subtitles support (default enabled)])
+AS_IF( [test "${enable_aribsub}" != "no" ],[
+  PKG_CHECK_MODULES(ARIBB24, [aribb24 >= 1.0.1], [
+      have_aribb24="yes"
+      VLC_ADD_PLUGIN([aribsub])
+      VLC_ADD_LIBS([aribsub],[-laribb24])
+      AC_DEFINE(HAVE_ARIBB24, 1, [Define if libaribb24 is available.])
+    ],[
+      AC_MSG_WARN(Library [aribb24] needed for [aribsub] was not found)
+      have_aribb24="no"
+  ])
+])
+AM_CONDITIONAL([HAVE_ARIBB24], [test x"${have_aribb24}" = x"yes"])
+
+dnl
+dnl ARIB B25
+dnl
+PKG_ENABLE_MODULES_VLC([ARIBB25], [aribcam], [aribb25 >= 0.2.6], [ARIB STD-B25], [auto])
+
 dnl
 dnl  kate decoder plugin
 dnl
@@ -2963,23 +2908,32 @@ EXTEND_HELP_STRING([Video plugins:])
 dnl
 dnl  OpenGL
 dnl
+PKG_CHECK_MODULES([EGL], [egl], [
+  have_egl="yes"
+], [
+  have_egl="no"
+])
+AM_CONDITIONAL([HAVE_EGL], [test "${have_egl}" = "yes"])
+
+have_gl="no"
 PKG_CHECK_MODULES([GL], [gl], [
   have_gl="yes"
 ], [
-  AC_CHECK_HEADER([GL/gl.h], [
-    have_gl="yes"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef _WIN32
+# include <GL/glew.h>
+#endif
+#include <GL/gl.h>
+]], [
+    [int t0 = GL_TEXTURE0;]])
+  ], [
     GL_CFLAGS=""
-    AS_IF([test "${SYS}" = "mingw32"], [
-      AC_CHECK_HEADER([GL/glew.h], [
-      ], [
-        have_gl="no"
-      ])
-      GL_LIBS="-lopengl32"
-    ], [
+    have_gl="yes"
+    AS_IF([test "${SYS}" != "mingw32"], [
       GL_LIBS="-lGL"
+    ], [
+      GL_LIBS="-lopengl32"
     ])
-  ], [
-    have_gl="no"
   ])
 ])
 AM_CONDITIONAL([HAVE_GL], [test "${have_gl}" = "yes"])
@@ -2989,16 +2943,6 @@ PKG_ENABLE_MODULES_VLC([GLES2], [], [glesv2], [OpenGL ES v2 support], [disabled]
 dnl OpenGL ES 1: depends on EGL 1.0
 PKG_ENABLE_MODULES_VLC([GLES1], [], [glesv1_cm], [OpenGL ES v1 support], [disabled])
 
-AC_ARG_ENABLE(egl,
-  [  --enable-egl            OpenGL support through EGL (default disabled)],, [
-  enable_egl="no"
-])
-AS_IF([test "$enable_egl" != "no"], [
-  PKG_CHECK_MODULES([EGL], [egl], [
-    VLC_ADD_PLUGIN([egl])
-  ])
-])
-
 dnl
 dnl  Xlib
 dnl
@@ -3021,10 +2965,6 @@ AC_ARG_ENABLE(xvideo,
   [  --enable-xvideo         XVideo support (default enabled)],, [
     enable_xvideo="$enable_xcb"
 ])
-AC_ARG_ENABLE(glx,
-  [  --enable-glx            OpenGL support through GLX (default enabled)],, [
-  enable_glx="$enable_xcb"
-])
 
 have_xcb="no"
 have_xcb_keysyms="no"
@@ -3077,20 +3017,65 @@ AM_CONDITIONAL([HAVE_VDPAU], [test "${have_vdpau}" = "yes"])
 
 have_avcodec_vdpau="no"
 AS_IF([test "${have_vdpau}" = "yes" -a "${have_avcodec}" = "yes"], [
-  PKG_CHECK_EXISTS([libavutil >= 0.52.4 libavcodec >= 54.36.0], [
+  case "${avfork}" in
+    libav) av_vdpau_ver="55.26.0" ;;
+    ffmpeg) av_vdpau_ver="55.42.100" ;;
+  esac
+  PKG_CHECK_EXISTS([libavutil >= 52.4.0 libavcodec >= ${av_vdpau_ver}], [
     have_avcodec_vdpau="yes"
     AC_MSG_NOTICE([VDPAU decoding acceleration activated])
   ], [
     AS_IF([test -n "${enable_vdpau}"], [
-      AC_MSG_ERROR([libavutil >= 0.52.4 and libavcodec >= 54.36.0 are required for VDPAU decoding.])
+      AC_MSG_ERROR([libav libavutil >= 52.4.0 and libavcodec >= 55.26.0 are required for VDPAU decoding.])
     ], [
-      AC_MSG_WARN([libavutil >= 0.52.4 and libavcodec >= 54.36.0 are required for VDPAU decoding.])
+      AC_MSG_WARN([libav libavutil >= 52.4.0 and libavcodec >= 55.26.0 are required for VDPAU decoding.])
     ])
   ])
 ])
 AM_CONDITIONAL([HAVE_AVCODEC_VDPAU], [test "${have_avcodec_vdpau}" = "yes"])
 
 
+dnl
+dnl  Wayland
+dnl
+AC_ARG_ENABLE(wayland,
+  [AS_HELP_STRING([--enable-wayland], [Wayland support (default auto)])])
+have_wayland="no"
+AC_ARG_VAR([WAYLAND_SCANNER], [Wayland scanner utility])
+
+AS_IF([test "${enable_wayland}" != "no"], [
+  AC_MSG_CHECKING([for the Wayland scanner])
+  AS_IF([test -z "$WAYLAND_SCANNER"], [
+    PKG_CHECK_EXISTS([wayland-scanner], [
+      WAYLAND_SCANNER="$(${PKG_CONFIG} wayland-scanner --variable wayland_scanner)"
+    ], [
+      WAYLAND_SCANNER="wayland-scanner"
+    ])
+  ])
+  AC_MSG_RESULT([$WAYLAND_SCANNER])
+
+  PKG_CHECK_MODULES([WAYLAND_CLIENT], [wayland-client >= 1.5.91], [
+    have_wayland="yes"
+  ], [
+    AS_IF([test -n "${enable_wayland}"], [
+      AC_MSG_ERROR([${WAYLAND_CLIENT_PKG_ERRORS}.])
+    ])
+  ])
+
+  AS_IF([test "${have_egl}" = "yes"], [
+    PKG_CHECK_MODULES([WAYLAND_EGL], [wayland-egl], [
+      have_wayland_egl="yes"
+    ], [
+      AS_IF([test -n "${enable_wayland}"], [
+        AC_MSG_ERROR([${WAYLAND_EGL_PKG_ERRORS}.])
+      ])
+    ])
+  ])
+])
+AM_CONDITIONAL([HAVE_WAYLAND], [test "${have_wayland}" = "yes"])
+AM_CONDITIONAL([HAVE_WAYLAND_EGL], [test "${have_wayland_egl}" = "yes"])
+
+
 dnl
 dnl  SDL module
 dnl
@@ -3105,11 +3090,6 @@ then
       if test "${SYS}" != "darwin"; then
         VLC_ADD_PLUGIN([vout_sdl])
       fi
-      if test "${SYS}" != "mingw32" -a "${SYS}" != "os2"; then
-        VLC_ADD_LIBS([vout_sdl],[${X_LIBS} ${X_PRE_LIBS} -lX11])
-      fi
-      VLC_ADD_CFLAGS([vout_sdl],[${SDL_CFLAGS}])
-      VLC_ADD_LIBS([vout_sdl],[${SDL_LIBS}])
 
       # SDL_image
       AS_IF([ test "${enable_sdl_image}" != "no"],[
@@ -3123,29 +3103,6 @@ then
    ])
 fi
 
-
-dnl
-dnl Mac Vout
-AC_ARG_ENABLE(macosx-vout,
-  [  --enable-macosx-vout    Mac OS X video output module (default enabled on Mac OS X)])
-if test "x${enable_macosx_vout}" != "xno" &&
-  (test "${SYS}" = "darwin" || test "${enable_macosx_vout}" = "yes")
-then
-  VLC_ADD_LIBS([vout_macosx],[-Wl,-framework,Cocoa])
-  VLC_ADD_LIBS([vout_macosx],[-Wl,-framework,OpenGL])
-  VLC_ADD_PLUGIN([vout_macosx])
-fi
-
-dnl
-dnl Mac CoreGraphics Layer Vout
-AC_ARG_ENABLE(coregraphicslayer-vout,
-  [  --enable-coregraphicslayer-vout CoreGraphics layered video output module (default disabled)])
-if test "${enable_coregraphicslayer_vout}" = "yes"; then
-  VLC_ADD_LIBS([vout_coregraphicslayer],[-Wl,-framework,Cocoa])
-  VLC_ADD_LIBS([vout_coregraphicslayer],[-Wl,-framework,QuartzCore])
-  VLC_ADD_PLUGIN([vout_coregraphicslayer])
-fi
-
 dnl
 dnl  freetype module
 dnl
@@ -3178,47 +3135,44 @@ AC_ARG_WITH([default-monospace-font-family],
         [AC_DEFINE_UNQUOTED([DEFAULT_MONOSPACE_FAMILY],
             "$withval", [Default monospace font family])])
 
+have_freetype="no"
+have_fontconfig="no"
+have_fribidi="no"
+
 if test "${enable_freetype}" != "no"; then
    PKG_CHECK_MODULES(FREETYPE, freetype2, [
-      have_freetype=yes
-      VLC_ADD_PLUGIN([freetype])
-      VLC_ADD_CPPFLAGS([freetype skins2],[${FREETYPE_CFLAGS}])
-      if test "${SYS}" = "mingw32"; then
-        VLC_ADD_LIBS([freetype],[-liconv -lz])
-      fi
-      VLC_ADD_LIBS([freetype skins2],[${FREETYPE_LIBS}])
-
-      AC_CHECK_HEADERS(Carbon/Carbon.h,
-                       [VLC_ADD_LIBS([freetype],[-Wl,-framework,Carbon])])
+      have_freetype="yes"
+      VLC_ADD_CPPFLAGS([skins2],[${FREETYPE_CFLAGS}])
+      VLC_ADD_LIBS([skins2],[${FREETYPE_LIBS}])
 
       dnl fontconfig support
       if test "${SYS}" != "mingw32"; then
           if test "${enable_fontconfig}" != "no"; then
             AC_CHECK_HEADERS(fontconfig/fontconfig.h, [
-              VLC_ADD_CPPFLAGS([freetype],[-DHAVE_FONTCONFIG])
-              VLC_ADD_LIBS([freetype],[-lfontconfig])
+              have_fontconfig="yes"
             ],[AC_MSG_WARN([library fontconfig not found. Styles will be disabled in freetype])])
           fi
-      else
-          VLC_ADD_LIBS([freetype],[-lgdi32])
       fi
 
       dnl fribidi support
       if test "${enable_fribidi}" != "no"; then
         PKG_CHECK_MODULES(FRIBIDI, fribidi, [
-          VLC_ADD_CPPFLAGS([freetype skins2], [${FRIBIDI_CFLAGS} -DHAVE_FRIBIDI])
-          VLC_ADD_LIBS([freetype skins2], [${FRIBIDI_LIBS}])
+          have_fribidi="yes"
+          VLC_ADD_CPPFLAGS([skins2], [${FRIBIDI_CFLAGS} -DHAVE_FRIBIDI])
+          VLC_ADD_LIBS([skins2], [${FRIBIDI_LIBS}])
         ],[AC_MSG_WARN([${FRIBIDI_PKG_ERRORS}. Bidirectional support will be disabled in FreeType.])])
       fi
-
   ],[
-  have_freetype=no
   AS_IF([test -n "${enable_freetype}"],[
     AC_MSG_ERROR([${FREETYPE_PKG_ERRORS}. Install FreeType2 development or configure with --disable-freetype.])
     ])
   ])
 fi
 
+AM_CONDITIONAL([HAVE_FREETYPE], [test "${have_freetype}" = "yes"])
+AM_CONDITIONAL([HAVE_FONTCONFIG], [test "${have_fontconfig}" = "yes"])
+AM_CONDITIONAL([HAVE_FRIBIDI], [test "${have_fribidi}" = "yes"])
+
 
 dnl
 dnl  QuartzText vout module (iOS/Mac OS)
@@ -3229,13 +3183,13 @@ if test "x${enable_macosx_quartztext}" != "xno" &&
   (test "${SYS}" = "darwin" || test "${enable_macosx_quartztext}" = "yes")
 then
   VLC_ADD_PLUGIN([quartztext])
-  VLC_ADD_LIBS([quartztext],[-Wl,-framework,ApplicationServices])
 fi
 
 dnl
-dnl  SVG module
+dnl  SVG module (text rendering and image decoding)
 dnl
 PKG_ENABLE_MODULES_VLC([SVG], [], [librsvg-2.0 >= 2.9.0], [SVG rendering library],[auto])
+PKG_ENABLE_MODULES_VLC([SVGDEC], [], [librsvg-2.0 >= 2.9.0 cairo >= 1.13.1], [SVG image decoder library],[auto])
 
 dnl
 dnl  android surface module
@@ -3243,36 +3197,10 @@ dnl
 AC_ARG_ENABLE(android-surface,
   [  --enable-android-surface   Android Surface video output module (default disabled)])
 if test "${enable_android_surface}" = "yes"; then
-  if test "${HAVE_ANDROID}" = "1"; then
      VLC_ADD_PLUGIN([android_surface])
-     VLC_ADD_LIBS([android_surface], [-ldl])
-  fi
-fi
-
-
-dnl
-dnl  iOS vout module
-dnl
-AC_ARG_ENABLE(ios-vout,
-  [  --enable-ios-vout    iOS video output module (default disabled)])
-if test "${enable_ios_vout}" = "yes"
-then
-  VLC_ADD_PLUGIN([vout_ios])
-  VLC_ADD_LIBS([vout_ios], [-Wl,-framework,OpenGLES,-framework,QuartzCore,-framework,UIKit,-framework,Foundation])
-fi
-
-dnl
-dnl  iOS ES2 vout module
-dnl
-AC_ARG_ENABLE(ios-vout2,
-  [  --enable-ios-vout2    iOS video output module (default disabled)])
-if test "${enable_ios_vout2}" = "yes"
-then
-  VLC_ADD_PLUGIN([vout_ios2])
-  VLC_ADD_LIBS([vout_ios2], [-Wl,-framework,OpenGLES,-framework,QuartzCore,-framework,UIKit])
+     VLC_ADD_PLUGIN([android_window])
 fi
 
-
 dnl
 dnl  Windows DirectX module
 dnl
@@ -3303,9 +3231,14 @@ AS_IF([test "${enable_directx}" != "no"], [
     #include <GL/gl.h>
   ])
 
-  dnl Direct3D
+  dnl Direct3D11
+  AC_CHECK_HEADERS(d3d11.h, [
+    VLC_ADD_PLUGIN([direct3d11])
+  ])
+
+  dnl Direct3D9
   AC_CHECK_HEADERS(d3d9.h, [
-    VLC_ADD_PLUGIN([direct3d])
+    VLC_ADD_PLUGIN([direct3d9])
   ])
 
   dnl Direct2D
@@ -3398,10 +3331,6 @@ then
   if test "${have_aa}" = "true"
   then
     VLC_ADD_PLUGIN([aa])
-    VLC_ADD_LIBS([aa],[-laa])
-    if test "${SYS}" != "mingw32"; then
-      VLC_ADD_LIBS([aa],[${X_LIBS} ${X_PRE_LIBS} -lX11])
-    fi
   fi
 fi
 
@@ -3433,6 +3362,35 @@ AS_IF([test "$enable_kva" != "no"], [
 AC_SUBST(KVA_LIBS)
 AM_CONDITIONAL([HAVE_KVA], [test "${have_kva}" = "yes"])
 
+dnl
+dnl MMAL plugin
+dnl
+AC_ARG_ENABLE(mmal,
+  AS_HELP_STRING([--enable-mmal],
+    [Multi-Media Abstraction Layer (MMAL) hardware plugin (default enable)]))
+if test "${enable_mmal}" != "no"; then
+  VLC_SAVE_FLAGS
+  LDFLAGS="${LDFLAGS} -L/opt/vc/lib -lvchostif"
+  CPPFLAGS="${CPPFLAGS} -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
+  AC_CHECK_HEADERS(interface/mmal/mmal.h,
+    [ AC_CHECK_LIB(bcm_host, vc_tv_unregister_callback_full, [
+        have_mmal="yes"
+        VLC_ADD_PLUGIN([mmal])
+        VLC_ADD_LDFLAGS([mmal],[ -L/opt/vc/lib ])
+        VLC_ADD_CFLAGS([mmal],[ -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux ])
+        VLC_ADD_LIBS([mmal],[ -lbcm_host -lmmal -lvchostif ]) ], [
+          AS_IF([test "${enable_mmal}" = "yes"],
+            [ AC_MSG_ERROR([Cannot find bcm library...]) ],
+            [ AC_MSG_WARN([Cannot find bcm library...]) ])
+          ],
+        [])
+    ] , [ AS_IF([test "${enable_mmal}" = "yes"],
+      [ AC_MSG_ERROR([Cannot find development headers for mmal...]) ],
+      [ AC_MSG_WARN([Cannot find development headers for mmal...]) ]) ])
+  VLC_RESTORE_FLAGS
+fi
+AM_CONDITIONAL([HAVE_MMAL], [test "${have_mmal}" = "yes"])
+
 dnl
 dnl  Audio plugins
 dnl
@@ -3447,23 +3405,11 @@ AC_ARG_ENABLE(pulse,
     [use the PulseAudio client library (default auto)])])
 have_pulse="no"
 AS_IF([test "${enable_pulse}" != "no"], [
-  PKG_CHECK_MODULES([PULSE], [libpulse >= 0.9.22], [
+  PKG_CHECK_MODULES([PULSE], [libpulse >= 1.0], [
     have_pulse="yes"
   ], [
-    PKG_CHECK_MODULES([PULSE], [libpulse >= 0.9.16], [
-      AS_IF([test "${no_x}" != "yes"], [
-        have_pulse="yes"
-        PULSE_LIBS="$PULSE_LIBS ${X_LIBS} ${X_PRE_LIBS} -lX11"
-      ], [
-        AS_IF([test "${enable_pulse}" = "yes"], [
-          AC_MSG_ERROR([Xlib is required with PulseAudio pre-0.9.22 versions
-(see http://www.pulseaudio.org/ticket/799 for further reference).])
-        ])
-      ])
-    ], [
-      AS_IF([test "x${enable_pulse}" != "x"], [
-        AC_MSG_ERROR([$PULSE_PKG_ERRORS. PulseAudio 0.9.22 or later required.])
-      ])
+    AS_IF([test "x${enable_pulse}" != "x"], [
+      AC_MSG_ERROR([$PULSE_PKG_ERRORS. PulseAudio 1.0 or later required.])
     ])
   ])
 ])
@@ -3551,31 +3497,6 @@ AS_IF([test "$enable_wasapi" != "no"], [
 ])
 AM_CONDITIONAL([HAVE_WASAPI], [test "${have_wasapi}" = "yes"])
 
-dnl
-dnl  CoreAudio plugin
-dnl
-AC_ARG_ENABLE(macosx-audio,
-  [  --enable-macosx-audio   Mac OS X audio module (default enabled on MacOS X)])
-if test "x${enable_macosx_audio}" != "xno" &&
-  (test "${SYS}" = "darwin" || test "${enable_macosx_audio}" = "yes")
-then
-  AC_CHECK_HEADER([CoreAudio/CoreAudio.h],
-    [ VLC_ADD_PLUGIN([auhal])
-    ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
-fi
-
-dnl
-dnl  iOS CoreAudio plugin
-dnl
-AC_ARG_ENABLE(ios-audio,
-  [  --enable-ios-audio       Audio module for iOS (default disabled)])
-if test "${enable_ios_audio}" = "yes"
-then
-  AC_CHECK_HEADER([AudioUnit/AudioUnit.h],
-    [ VLC_ADD_PLUGIN([audiounit_ios])
-    ], [ AC_MSG_ERROR([cannot find AudioUnit headers]) ])
-fi
-
 dnl
 dnl  AudioQueue plugin
 dnl
@@ -3656,9 +3577,7 @@ dnl  chromaprint audio track fingerprinter
 dnl
 m4_pushdef([libchromaprint_version], 0.6.0)
 PKG_WITH_MODULES([CHROMAPRINT],[libchromaprint >= libchromaprint_version],
-    VLC_ADD_PLUGIN([stream_out_chromaprint])
-    VLC_ADD_CFLAGS([stream_out_chromaprint],[${CHROMAPRINT_CFLAGS}] [-I./webservices -I../stream_out])
-    VLC_ADD_LIBS([stream_out_chromaprint],[${CHROMAPRINT_LIBS}])
+    VLC_ADD_PLUGIN([stream_out_chromaprint]),
     AS_IF([test "${enable_chromaprint}" = "yes"],
         [AC_MSG_ERROR(Library [libchromaprint >= libchromaprint_version] needed for [chromaprint] was not found)],
         [AC_MSG_WARN(Library [libchromaprint >= libchromaprint_version] needed for [chromaprint] was not found)]
@@ -3666,6 +3585,28 @@ PKG_WITH_MODULES([CHROMAPRINT],[libchromaprint >= libchromaprint_version],
     [(Chromaprint based audio fingerprinter)],[auto])
 m4_popdef([libchromaprint_version])
 
+dnl
+dnl  Chromecast streaming support
+dnl
+m4_pushdef([protobuf_lite_version], 2.5.0)
+AC_ARG_VAR(PROTOC, [protobuf compiler])
+AC_PATH_PROGS(PROTOC, protoc, no)
+PKG_WITH_MODULES([CHROMECAST],[protobuf-lite >= protobuf_lite_version], [
+    AS_IF([test "x${PROTOC}" != "xno"], [
+        build_chromecast="yes"
+    ], [
+    AC_MSG_ERROR(protoc compiler needed for [chromecast] was not found)
+    ])
+], [
+    AS_IF([test "${enable_chromecast}" = "yes"],
+        AC_MSG_ERROR(Library [protobuf-lite >= protobuf_lite_version] needed for [chromecast] was not found),
+        AC_MSG_WARN(Library [protobuf-lite >= protobuf_lite_version] needed for [chromecast] was not found)
+    )
+    enable_chromecast="no"
+], [(Chromecast streaming support)], [auto])
+AM_CONDITIONAL([BUILD_CHROMECAST], [test "${build_chromecast}" = "yes"])
+m4_popdef([protobuf_lite_version])
+
 dnl
 dnl  Interface plugins
 dnl
@@ -3683,10 +3624,17 @@ AC_ARG_ENABLE(qt, [
 ])
 AS_IF([test "${enable_qt}" != "no"], [
   PKG_CHECK_MODULES([QT], [Qt5Core >= 5.1.0 Qt5Widgets Qt5Gui], [
+      PKG_CHECK_MODULES([QTX11], [Qt5X11Extras], [
+          VLC_ADD_LIBS([qt4],[${QTX11_LIBS}])
+          VLC_ADD_CXXFLAGS([qt4],[${QTX11_CFLAGS} -DQT5_HAS_X11])
+      ],[
+          AC_MSG_WARN([Not building Qt Interface with X11 helpers.])
+      ])
       QT_PATH="$(eval $PKG_CONFIG --variable=exec_prefix Qt5Core)"
-      AC_PATH_PROGS(MOC, [moc-qt5 moc], moc, [${QT_PATH}/bin ${CONTRIB_DIR}/bin])
-      AC_PATH_PROG(RCC, [rcc-qt5 rcc], rcc, [${QT_PATH}/bin ${CONTRIB_DIR}/bin])
-      AC_PATH_PROGS(UIC, [uic-qt5 uic], uic, [${QT_PATH}/bin ${CONTRIB_DIR}/bin])
+      QT_HOST_PATH="$(eval $PKG_CONFIG --variable=host_bins Qt5Core)"
+      AC_PATH_PROGS(MOC, [moc-qt5 moc], moc, ["${QT_HOST_PATH}" "${QT_PATH}/bin" "${CONTRIB_DIR}/bin"])
+      AC_PATH_PROGS(RCC, [rcc-qt5 rcc], rcc, ["${QT_HOST_PATH}" "${QT_PATH}/bin" "${CONTRIB_DIR}/bin"])
+      AC_PATH_PROGS(UIC, [uic-qt5 uic], uic, ["${QT_HOST_PATH}" "${QT_PATH}/bin" "${CONTRIB_DIR}/bin"])
     ], [
       PKG_CHECK_MODULES([QT], [QtCore QtGui >= 4.6.0],, [
         AS_IF([test -n "${enable_qt}"],[
@@ -3697,34 +3645,14 @@ AS_IF([test "${enable_qt}" != "no"], [
         enable_qt="no"
       ])
       QT_PATH="$(eval $PKG_CONFIG --variable=exec_prefix QtCore)"
-      AC_PATH_PROGS(MOC, [moc-qt4 moc], moc, [${QT_PATH}/bin ${CONTRIB_DIR}/bin])
+      AC_PATH_PROGS(MOC, [moc-qt4 moc], moc, ["${QT_PATH}/bin" "${CONTRIB_DIR}/bin"])
       AC_PATH_PROG(RCC, rcc, rcc, [${QT_PATH}/bin ${CONTRIB_DIR}/bin])
-      AC_PATH_PROGS(UIC, [uic-qt4 uic], uic, [${QT_PATH}/bin ${CONTRIB_DIR}/bin])
+      AC_PATH_PROGS(UIC, [uic-qt4 uic], uic, ["${QT_PATH}/bin" "${CONTRIB_DIR}/bin"])
     ])
 ])
 AS_IF([test "${enable_qt}" != "no"], [
   VLC_ADD_PLUGIN([qt4])
   ALIASES="${ALIASES} qvlc"
-
-  AC_LANG_PUSH([C++])
-  VLC_SAVE_FLAGS
-
-  AC_MSG_CHECKING([whether Qt uses Xlib])
-  CPPFLAGS="${CPPFLAGS} ${QT_CFLAGS}"
-  AC_PREPROC_IFELSE([AC_LANG_SOURCE([
-#include <QWidget>
-#if !defined (Q_WS_X11)
-# error Fail
-#endif
-  ])], [
-    AC_MSG_RESULT([yes])
-  ], [
-    AC_MSG_RESULT([no])
-  ])
-
-  VLC_RESTORE_FLAGS
-  AC_LANG_POP([C++])
-
 ])
 AM_CONDITIONAL(ENABLE_QT4, [test "$enable_qt" != "no"])
 
@@ -3859,11 +3787,10 @@ dnl  ncurses module
 dnl
 AC_ARG_ENABLE(ncurses,
 [AS_HELP_STRING([--disable-ncurses],[ncurses text-based interface (default auto)])])
+have_ncurses="no"
 AS_IF([test "${enable_ncurses}" != "no"] ,[
   PKG_CHECK_MODULES([NCURSES], [ncursesw], [
-    VLC_ADD_PLUGIN([ncurses])
-    VLC_ADD_CFLAGS([ncurses],[${NCURSES_CFLAGS}])
-    VLC_ADD_LIBS([ncurses],[${NCURSES_LIBS}])
+    have_ncurses="yes"
     ALIASES="${ALIASES} nvlc"
   ], [
     AS_IF([test -n "${enable_ncurses}"], [
@@ -3871,21 +3798,22 @@ AS_IF([test "${enable_ncurses}" != "no"] ,[
     ])
   ])
 ])
+AM_CONDITIONAL([HAVE_NCURSES], [test "${have_ncurses}" = "yes"])
 
 dnl
 dnl  Lirc plugin
 dnl
 AC_ARG_ENABLE(lirc,
   [  --enable-lirc           lirc support (default disabled)])
-if test "${enable_lirc}" = "yes"
-then
-  AC_CHECK_HEADER(lirc/lirc_client.h, AC_CHECK_LIB(lirc_client, lirc_init, have_lirc="true", have_lirc="false"),have_lirc="false")
-  if test "${have_lirc}" = "true"
-  then
-    VLC_ADD_PLUGIN([lirc])
-    VLC_ADD_LIBS([lirc],[-llirc_client])
-  fi
-fi
+have_lirc="no"
+AS_IF([test "${enable_lirc}" = "yes"], [
+  AC_CHECK_HEADER(lirc/lirc_client.h, [
+    AC_CHECK_LIB(lirc_client, lirc_init, [
+      have_lirc="true"
+    ])
+  ])
+])
+AM_CONDITIONAL([HAVE_LIRC], [test "${have_lirc}" = "yes"])
 
 EXTEND_HELP_STRING([Visualisations and Video filter plugins:])
 dnl
@@ -3922,8 +3850,6 @@ AS_IF([test "${enable_vsxu}" != "no"],
     PKG_CHECK_MODULES(VSXU, libvsxu,
     [
       VLC_ADD_PLUGIN([vsxu])
-      VLC_ADD_CXXFLAGS([vsxu],[$VSXU_CFLAGS])
-      VLC_ADD_LIBS([vsxu],[$VSXU_LIBS])
     ],[
       AC_MSG_WARN([${VSXU_PKG_ERRORS}.])
     ])
@@ -3937,23 +3863,10 @@ AS_HELP_STRING([--disable-atmo],[AtmoLight (homemade Philips Ambilight clone)
                 (default enabled)]),, [enable_atmo="yes"])
 AS_IF([test "${enable_atmo}" != no], [
   AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "linux"], [
-    AC_LANG_PUSH(C++)
     VLC_ADD_PLUGIN([atmo])
-    AC_LANG_POP(C++)
   ])
 ])
 
-dnl
-dnl  glSpectrum
-dnl
-AC_ARG_ENABLE(glspectrum,
-  [  --enable-glspectrum    3D OpenGL spectrum visualization (default auto)])
-if test "${enable_glspectrum}" != "no" && test "${have_gl}" = "yes"
-then
-    VLC_ADD_PLUGIN([glspectrum])
-    VLC_ADD_LIBS([glspectrum],[$GL_LIBS])
-fi
-
 EXTEND_HELP_STRING([Service Discovery plugins:])
 dnl
 dnl  Bonjour services discovery
@@ -3994,10 +3907,10 @@ AS_IF([test "${enable_libgcrypt}" != "no"], [
       GCRYPT_CFLAGS="`libgcrypt-config --cflags`"
       GCRYPT_LIBS="`libgcrypt-config --libs`"
     ], [
-      AC_MSG_ERROR([libgcrypt not found. Install libgcrypt or use --disable-libgcrypt. Have a nice day.])
+      AC_MSG_ERROR([libgcrypt not found. Install libgcrypt or pass --disable-libgcrypt.])
     ], [`libgcrypt-config --libs`])
   ], [
-    AC_MSG_ERROR([libgcrypt version 1.1.94 or higher not found. Install libgcrypt or use --disable-libgcrypt. Have a nice day.])
+    AC_MSG_ERROR([libgcrypt version 1.1.94 or higher not found. Install libgcrypt or pass --disable-libgcrypt.])
   ], [#include <gcrypt.h>]
   )
 ])
@@ -4012,7 +3925,7 @@ dnl
 AC_ARG_ENABLE(gnutls,
   [  --enable-gnutls         GNU TLS TLS/SSL support (default enabled)])
 AS_IF([test "${enable_gnutls}" != "no"], [
-  PKG_CHECK_MODULES(GNUTLS, [gnutls >= 3.0.20], [
+  PKG_CHECK_MODULES(GNUTLS, [gnutls >= 3.2.0], [
     VLC_ADD_PLUGIN([gnutls])
   ], [
     AS_IF([test -n "${enable_gnutls}"], [
@@ -4029,7 +3942,7 @@ AC_ARG_ENABLE(taglib,
   [AS_HELP_STRING([--disable-taglib],
     [do not use TagLib (default enabled)])])
 AS_IF([test "${enable_taglib}" != "no"], [
-  PKG_CHECK_MODULES(TAGLIB, taglib >= 1.6.1, [
+  PKG_CHECK_MODULES(TAGLIB, taglib >= 1.9, [
     VLC_ADD_PLUGIN([taglib])
   ], [
     AC_MSG_WARN([${TAGLIB_PKG_ERRORS}.])])
@@ -4186,32 +4099,13 @@ AC_CONFIG_FILES([
   lib/Makefile
   bin/Makefile
   test/Makefile
-  modules/access/rtp/Makefile
-  modules/access_output/Makefile
-  modules/audio_filter/Makefile
-  modules/audio_mixer/Makefile
-  modules/control/Makefile
-  modules/gui/Makefile
+  modules/gui/ios_dialog_provider/Makefile
   modules/gui/macosx/Makefile
   modules/gui/minimal_macosx/Makefile
   modules/gui/macosx_dialog_provider/Makefile
   modules/gui/qt4/Makefile
   modules/gui/skins2/Makefile
-  modules/lua/Makefile
-  modules/misc/Makefile
-  modules/mux/Makefile
-  modules/notify/Makefile
-  modules/packetizer/Makefile
-  modules/stream_filter/Makefile
-  modules/stream_out/Makefile
-  modules/text_renderer/Makefile
-  modules/video_chroma/Makefile
-  modules/video_filter/Makefile
-  modules/video_output/Makefile
-  modules/video_splitter/Makefile
-  modules/visualization/Makefile
-  modules/arm_neon/Makefile
-  modules/hw/vdpau/Makefile
+  modules/hw/mmal/Makefile
 ])
 
 AM_COND_IF([HAVE_WIN32], [
@@ -4246,11 +4140,12 @@ if test -n $SHELL; then
   SHELL=${CONFIG_SHELL-/bin/sh}
 fi
 rm -f compile
+compile_top_srcdir=`sed -ne "s/^top_srcdir *= *//p" < Makefile`
 echo "#! $SHELL
 rm -f .error\$\$
 ERROR=0
 export PATH=\"$PATH\" LANG=C
-($MAKE V=1 \$@ 2>&1 || touch .error\$\$)| `sed -ne \"s/^top_srcdir *= *//p\" < Makefile`/extras/buildsystem/make.pl
+($MAKE V=1 \$@ 2>&1 || touch .error\$\$)| $compile_top_srcdir/extras/buildsystem/make.pl
 test -f .error\$\$ && ERROR=1
 rm -f .error\$\$
 exit \$ERROR" >compile