]> git.sesse.net Git - vlc/blobdiff - configure.ac
Embed manifest files as Windows PE resource
[vlc] / configure.ac
index 43a0d17d878070c11c6c3619500f40017e51c083..4e50beeb28d919a41e2a5754f49c5c2834b095ff 100644 (file)
@@ -1,20 +1,20 @@
 dnl Autoconf settings for vlc
 
-AC_COPYRIGHT([Copyright 2002-2011 the VideoLAN team])
+AC_COPYRIGHT([Copyright 2002-2012 VLC authors and VideoLAN])
 
-AC_INIT(vlc, 1.2.0-pre2)
-VERSION_MAJOR=1
-VERSION_MINOR=2
+AC_INIT(vlc, 2.1.0-git)
+VERSION_MAJOR=2
+VERSION_MINOR=1
 VERSION_REVISION=0
 VERSION_EXTRA=0
-VERSION_DEV=pre1
+VERSION_DEV=git
 
 PKGDIR="vlc"
 AC_SUBST(PKGDIR)
 
 CONFIGURE_LINE="`echo "$0 $ac_configure_args" | sed -e 's/\\\/\\\\\\\/g'`"
-CODENAME="Twoflower"
-COPYRIGHT_YEARS="1996-2011"
+CODENAME="Rincewind"
+COPYRIGHT_YEARS="1996-2012"
 
 AC_CONFIG_SRCDIR(src/libvlc.c)
 AC_CONFIG_AUX_DIR(autotools)
@@ -59,6 +59,7 @@ AC_DEFINE([_FILE_OFFSET_BITS], 64, [Define to 64 for large files support.])
 AC_DEFINE([_REENTRANT],, [Define to expose reentrant functions.])
 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>.])
 
 AM_PROG_CC_C_O
 AC_PROG_CXX
@@ -78,11 +79,6 @@ AC_C_CONST
 AC_C_INLINE
 AC_C_RESTRICT
 
-dnl
-dnl  Save *FLAGS
-dnl
-VLC_SAVE_FLAGS
-
 dnl Extend the --help string at the current spot.
 AC_DEFUN([EXTEND_HELP_STRING], [m4_divert_once([HELP_ENABLE], [$1])])
 
@@ -109,33 +105,32 @@ case "${host_os}" in
     ;;
   bsdi*)
     SYS=bsdi
-    CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
+    CFLAGS="${CFLAGS} -pthread"
     VLC_ADD_LIBS([vcd cdda vcdx],[-ldvd])
     ;;
-  *bsd*)
-    SYS="${host_os}"
-    CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
-    case "${host_os}" in
-      freebsd*)
-        CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
-        CPPFLAGS="${CPPFLAGS_save}"
-        LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
-        LDFLAGS="${LDFLAGS_save}"
-        ;;
-      openbsd*)
-        CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include -I/usr/X11R6/include"
-        CPPFLAGS="${CPPFLAGS_save}"
-        LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib -L/usr/X11R6/lib/"
-        LDFLAGS="${LDFLAGS_save}"
-        ;;
-    esac
+  freebsd*)
+    SYS=freebsd
+    CFLAGS="${CFLAGS} -pthread"
+    CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
+    LDFLAGS="${LDFLAGS} -L/usr/local/lib"
+    ;;
+  openbsd*)
+    SYS=openbsd
+    CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/X11R6/include"
+    LDFLAGS="${LDFLAGS} -L/usr/local/lib -L/usr/X11R6/lib/"
+    ;;
+  netbsd*)
+    SYS=netbsd
+    ;;
+  dragonfly*)
+    SYS=dragonfly
     ;;
   darwin*)
 
     dnl Force gcc "-arch" flag
     ARCH_flag=""
     case "${host}" in
-      i386*)
+      i?86*)
         ARCH_flag="-arch i386"
       ;;
       ppc64*)
@@ -150,45 +145,52 @@ case "${host_os}" in
     esac
 
     SYS=darwin
-    CFLAGS_save="${CFLAGS_save} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"; CFLAGS="${CFLAGS_save}"
-    CXXFLAGS_save="${CXXFLAGS_save} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"; CXXFLAGS="${CXXFLAGS_save}"
-    CPPFLAGS_save="${CPPFLAGS_save} ${ARCH_flag}"; CPPFLAGS="${CPPFLAGS_save}"
-    OBJCFLAGS_save="${OBJCFLAGS_save} -D_INTL_REDIRECT_MACROS -std=gnu99 ${ARCH_flag}"; OBJCFLAGS="${OBJCFLAGS_save}"
-    LDFLAGS_save="${LDFLAGS_save} -Wl,-headerpad_max_install_names ${ARCH_flag}"; LDFLAGS="${LDFLAGS_save}"
+    CFLAGS="${CFLAGS} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"
+    CXXFLAGS="${CXXFLAGS} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"
+    CPPFLAGS="${CPPFLAGS} ${ARCH_flag}"
+    OBJCFLAGS="${OBJCFLAGS} -D_INTL_REDIRECT_MACROS -std=gnu99 ${ARCH_flag}"
+    LDFLAGS="${LDFLAGS} -Wl,-headerpad_max_install_names ${ARCH_flag}"
     VLC_ADD_LIBS([mkv mp4 motion], [-Wl,-framework,IOKit,-framework,CoreFoundation])
     VLC_ADD_LIBS([libvlc vlc],[-Wl,-undefined,dynamic_lookup])
-    VLC_ADD_LIBS([avcodec avformat access_avio swscale postproc i420_rgb_mmx x264],[-Wl,-read_only_relocs,suppress])
+    VLC_ADD_LIBS([avcodec avformat access_avio swscale postproc i420_rgb_mmx x264 x26410b],[-Wl,-read_only_relocs,suppress])
     VLC_ADD_CFLAGS([motion],[-fconstant-cfstrings])
     VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation])
 
+    dnl Allow binaries created on Lion to run on earlier releases
+    AC_EGREP_CPP(yes,
+           [#import <Cocoa/Cocoa.h>
+            #ifdef MAC_OS_X_VERSION_10_7
+            yes
+            #endif],
+            [AC_MSG_RESULT([yes])
+            AC_LIBOBJ([getdelim])
+            AC_LIBOBJ([strndup])
+            AC_LIBOBJ([strnlen])],)
+
     dnl
     dnl  Check for Mac OS X SDK settings
     dnl
     AC_ARG_WITH(macosx-sdk,
       [AS_HELP_STRING([--with-macosx-sdk=DIR],
         [compile using the SDK in DIR])])
-    test "${with_macosx_sdk}" = "" && with_macosx_sdk=/Developer/SDKs/MacOSX10.5.sdk
-    ! test -d "${with_macosx_sdk}" && AC_MSG_ERROR([SDK "${with_macosx_sdk}" not found])
-    CPP="${CPP} -isysroot ${with_macosx_sdk}"
-    CC="${CC} -isysroot ${with_macosx_sdk}"
-    CXX="${CXX} -isysroot ${with_macosx_sdk}"
-    OBJC="${OBJC} -isysroot ${with_macosx_sdk}"
-    LD="${LD} -syslibroot ${with_macosx_sdk}"
+    test "${with_macosx_sdk}" = "" && with_macosx_sdk=/Developer/SDKs/MacOSX10.6.sdk
+    test ! -d "${with_macosx_sdk}" && AC_MSG_ERROR([SDK "${with_macosx_sdk}" not found])
     AC_ARG_WITH(macosx-version-min,
       [AS_HELP_STRING([--with-macosx-version-min=VERSION],
         [compile for MacOS X VERSION and above])])
-    if test "${with_macosx_version_min}" != "" ; then
-        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} -macosx_version_min=${with_macosx_version_min}"
-        CFLAGS_save="${CFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; CFLAGS="${CFLAGS_save}"
-        CXXFLAGS_save="${CXXFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; CXXFLAGS="${CXXFLAGS_save}"
-        OBJCFLAGS_save="${OBJCFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; OBJCFLAGS="${OBJCFLAGS_save}"
-        MACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}
-        export MACOSX_DEPLOYMENT_TARGET
+    if test "${with_macosx_version_min}" = "" ; then
+       with_macosx_version_min=10.5
     fi
+    MACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}
+    CPP="${CPP} -isysroot ${with_macosx_sdk} -mmacosx-version-min=${with_macosx_version_min}"
+    CC="${CC} -isysroot ${with_macosx_sdk} -mmacosx-version-min=${with_macosx_version_min}"
+    CXX="${CXX} -isysroot ${with_macosx_sdk} -mmacosx-version-min=${with_macosx_version_min}"
+    OBJC="${OBJC} -isysroot ${with_macosx_sdk} -mmacosx-version-min=${with_macosx_version_min}"
+    LD="${LD} -syslibroot ${with_macosx_sdk} -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
     ;;
   *mingw32* | *cygwin* | *wince* | *mingwce*)
     AC_CHECK_TOOL(WINDRES, windres, :)
@@ -260,7 +262,7 @@ case "${host_os}" in
     ;;
   *os2*)
     SYS=os2
-    LDFLAGS_save="${LDFLAGS_save} -Zomf -Zbin-files -Zargs-wild"; LDFLAGS="${LDFLAGS_save}"
+    LDFLAGS="${LDFLAGS} -Zomf -Zbin-files -Zargs-wild"
     ;;
   *)
     SYS="${host_os}"
@@ -323,20 +325,15 @@ AS_IF([test -n "${CONTRIB_DIR}"], [
   AC_MSG_RESULT([${CONTRIB_DIR}])
   export PATH=${CONTRIB_DIR}/bin:$PATH
   CPPFLAGS="${CPPFLAGS} -I${CONTRIB_DIR}/include"
-  CPPFLAGS_save="${CPPFLAGS_save} -I${CONTRIB_DIR}/include"
   CFLAGS="${CFLAGS} -I${CONTRIB_DIR}/include"
-  CFLAGS_save="${CFLAGS_save} -I${CONTRIB_DIR}/include"
   CXXFLAGS="${CXXFLAGS} -I${CONTRIB_DIR}/include"
-  CXXFLAGS_save="${CXXFLAGS_save} -I${CONTRIB_DIR}/include"
   OBJCFLAGS="${OBJCFLAGS} -I${CONTRIB_DIR}/include"
-  OBJCFLAGS_save="${OBJCFLAGS_save} -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"
   ])
   LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
-  LDFLAGS_save="${LDFLAGS_save} -L${CONTRIB_DIR}/lib"
 
   AS_IF([test "${SYS}" = "darwin"], [
     export LD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$LD_LIBRARY_PATH"
@@ -432,7 +429,6 @@ AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
     ])
     dnl force use of mingw provided c99 *printf over msvcrt
     CPPFLAGS="${CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=1"
-    CPPFLAGS_save="${CPPFLAGS_save} -D__USE_MINGW_ANSI_STDIO=1"
 ])
 
 dnl Check for the need to include the mingwex lib for mingw32
@@ -445,25 +441,21 @@ fi
 
 dnl Check for fnative-struct or mms-bitfields support for mingw32
 if test "${SYS}" = "mingw32" ; then
+    VLC_SAVE_FLAGS
+    CFLAGS="${CFLAGS} -mms-bitfields"
+    CXXFLAGS="${CXXFLAGS} -mms-bitfields"
     AC_CACHE_CHECK([if \$CC accepts -mms-bitfields],
         [ac_cv_c_mms_bitfields],
-        [CFLAGS="${CFLAGS_save} -mms-bitfields"
-         AC_TRY_COMPILE([],,ac_cv_c_mms_bitfields=yes, ac_cv_c_mms_bitfields=no)])
-    if test "${ac_cv_c_mms_bitfields}" != "no"; then
-        CFLAGS_save="${CFLAGS_save} -mms-bitfields";
-        CXXFLAGS_save="${CXXFLAGS_save} -mms-bitfields";
-    else
+        [AC_TRY_COMPILE([],,ac_cv_c_mms_bitfields=yes, ac_cv_c_mms_bitfields=no)])
+    if test "${ac_cv_c_mms_bitfields}" = "no"; then
+        VLC_RESTORE_FLAGS
+        CFLAGS="${CFLAGS} -fnative-struct"
+        CXXFLAGS="${CXXFLAGS} -fnative-struct"
         AC_CACHE_CHECK([if \$CC accepts -fnative-struct],
             [ac_cv_c_fnative_struct],
-            [CFLAGS="${CFLAGS_save} -fnative-struct"
-             AC_TRY_COMPILE([],,ac_cv_c_fnative_struct=yes, ac_cv_c_fnative_struct=no)])
-        if test "${ac_cv_c_fnative_struct}" != "no"; then
-            CFLAGS_save="${CFLAGS_save} -fnative-struct";
-            CXXFLAGS_save="${CXXFLAGS_save} -fnative-struct";
-        fi
+            [AC_TRY_COMPILE([],,ac_cv_c_fnative_struct=yes, ac_cv_c_fnative_struct=no)])
+        "${ac_cv_c_fnative_struct}" = "no" && VLC_RESTORE_FLAGS
     fi
-
-    CFLAGS="${CFLAGS_save}"; CXXFLAGS="${CXXFLAGS_save}"
 fi
 
 dnl
@@ -486,8 +478,6 @@ AC_PREPROC_IFELSE([AC_LANG_SOURCE([
     AC_MSG_ERROR([Buggy GNU/libc (version 2.5 - 2.7) present. VLC would crash; there is no viable
 work-around for this. Check with your distribution vendor on how to update the
 glibc run-time. Alternatively, build with --disable-nls.])
-  ], [
-    AC_DEFINE(DISABLE_BUGGY_GLIBC_CHECK, 1, [Disables runtime check for buggy glibc.])
   ])
 ])
 
@@ -500,12 +490,41 @@ 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 if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp uselocale])
-AC_REPLACE_FUNCS([asprintf atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r inet_pton lldiv localtime_r nrand48 rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy vasprintf])
+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 inet_pton lldiv localtime_r nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp 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>], [
+        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])])
+
+dnl C11 static_assert()
+AC_MSG_CHECKING([for static_assert in assert.h])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE([
+#include <assert.h>
+#ifndef static_assert
+# error BOOM!
+#endif
+])], [
+  AC_MSG_RESULT([yes])
+  AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define to 1 if <assert.h> defines static_assert.])
+], [
+  AC_MSG_RESULT([no])
+])
+
 # Windows CE does not have strcoll()
 AC_FUNC_STRCOLL
 
@@ -514,15 +533,6 @@ AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity])
 
 AH_BOTTOM([#include <vlc_fixups.h>])
 
-dnl Check for poll
-AC_SEARCH_LIBS(poll, [poll], [
-  AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS has poll().])
-], [
-  AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" -a "${SYS}" != "os2"], [
-    AC_MSG_ERROR([poll() is required.])
-  ])
-])
-
 dnl Check for struct pollfd
 AC_CHECK_TYPES([struct pollfd],,,
 [#include <sys/types.h>
@@ -533,8 +543,8 @@ AC_CHECK_TYPES([struct pollfd],,,
 #endif
 ])
 
-dnl Check for connect
-LIBS_save="$LIBS"
+dnl Checks for socket stuff
+VLC_SAVE_FLAGS
 SOCKET_LIBS=""
 AC_SEARCH_LIBS(connect, [socket], [
   AS_IF([test "$ac_cv_search_connect" != "none required"], [
@@ -548,15 +558,24 @@ AC_SEARCH_LIBS(connect, [socket], [
     SOCKET_LIBS="-lws2"
   ])
 ])
-LIBS="$LIBS_save"
+
+AC_SEARCH_LIBS([getaddrinfo], [nsl], [
+ AS_IF([test "$ac_cv_search_getaddrinfo" != "none required"], [
+    SOCKET_LIBS="$ac_cv_search_getaddrinfo $SOCKET_LIBS"
+  ])
+],, [${SOCKET_LIBS}])
+
+AC_CHECK_FUNCS([if_nameindex if_nametoindex])
+VLC_RESTORE_FLAGS
+
 AS_IF([test -n "$SOCKET_LIBS"], [
-  VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_shout sap stream_out_select stream_out_standard stream_out_rtp stream_out_raop vod_rtsp access_realrtsp rtp oldrc netsync gnutls flac ts audioscrobbler lua remoteosd zvbi audiobargraph_a netsync],[${SOCKET_LIBS}])
+  VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_shout sap stream_out_select stream_out_standard stream_out_rtp stream_out_raop vod_rtsp access_realrtsp rtp oldrc netsync gnutls flac ts audioscrobbler lua remoteosd zvbi audiobargraph_a netsync stream_filter_dash],[${SOCKET_LIBS}])
 ])
 AC_SUBST(SOCKET_LIBS)
 
 dnl Check for socklen_t
 AH_TEMPLATE(socklen_t, [Define to `int' if <sys/socket.h> does not define.])
-AC_CACHE_CHECK([for socklen_t in sys/socket.h],
+AC_CACHE_CHECK([for socklen_t in sys/socket.h], dnl ` (fix VIM syntax highlight
 ac_cv_type_socklen_t,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 [#include <sys/types.h>
@@ -572,8 +591,8 @@ AS_IF([test "$ac_cv_type_socklen_t" = no],
  [AC_DEFINE(socklen_t, int)])
 
 dnl Check for struct sockaddr_storage
-AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does not define.])
-AH_TEMPLATE(ss_family, [Define to `sa_family' if <sys/socket.h> does not define.])
+AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does not define.]) dnl ` (fix VIM syntax highlight
+AH_TEMPLATE(ss_family, [Define to `sa_family' if <sys/socket.h> does not define.]) dnl ` (fix VIM syntax highlight
 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_struct_sockaddr_storage,
   [AC_TRY_COMPILE(
     [#include <sys/types.h>
@@ -591,13 +610,6 @@ AS_IF([test "${ac_cv_struct_sockaddr_storage}" = no], [
   AC_DEFINE(ss_family, sa_family)
 ])
 
-dnl getaddrinfo, getnameinfo and gai_strerror check
-dnl  -lnsl and -lsocket are needed on Solaris;
-dnl  we purposedly make the test fail on Windows
-LIBS_save="${LIBS}"
-AC_SEARCH_LIBS([getaddrinfo], [nsl],,, [${SOCKET_LIBS}])
-LIBS="${LIBS_save}"
-
 dnl FreeBSD has a gnugetopt library for this:
 GNUGETOPT_LIBS=""
 AC_CHECK_FUNC(getopt_long,, [
@@ -608,7 +620,7 @@ 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 visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mod mpc dmo quicktime realvideo qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x264 hqdn3d],[-lm])
+  VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph],[-lm])
   LIBM="-lm"
 ], [
   LIBM=""
@@ -623,14 +635,14 @@ AC_CHECK_LIB(m,lrintf, [
 dnl Check for dynamic plugins
 LIBDL=""
 have_dynamic_objects="no"
-LIBS_save="$LIBS"
+VLC_SAVE_FLAGS
 AC_SEARCH_LIBS(dlopen, [dl svld], [
   AS_IF([test "$ac_cv_search_dlopen" != "none required"], [
     LIBDL="$ac_cv_search_dlopen"
   ])
   have_dynamic_objects="yes"
 ])
-LIBS="$LIBS_save"
+VLC_RESTORE_FLAGS
 
 # Windows
 AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
@@ -650,27 +662,17 @@ AS_IF([test "${have_dynamic_objects}" != "no"], [
 AM_CONDITIONAL(HAVE_DYNAMIC_PLUGINS, [test "${have_dynamic_objects}" != "no"])
 
 AC_SUBST(LIBDL)
-VLC_ADD_LIBS([realvideo lua],[$LIBDL])
+VLC_ADD_LIBS([lua],[$LIBDL])
 
 dnl Check for thread library
 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
-  dnl Check for pthreads - borrowed from XMMS
-  THREAD_LIB=error
-  if test "${THREAD_LIB}" = "error"; then
-    AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
-  fi
-  if test "${THREAD_LIB}" = "error"; then
-    AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads")
-  fi
-  if test "${THREAD_LIB}" = "error"; then
-    AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r")
-  fi
-  if test "${THREAD_LIB}" = "error"; then
-    AC_CHECK_FUNCS(pthread_mutex_lock)
-    THREAD_LIB=""
-  fi
 
-  VLC_ADD_LIBS([libvlccore libvlc vlc plugin],[${THREAD_LIB}])
+  VLC_SAVE_FLAGS
+  LIBS=""
+  AC_SEARCH_LIBS(pthread_rwlock_init, pthread pthreads c_r, [
+    VLC_ADD_LIBS([libvlccore libvlc vlc plugin],[${LIBS}])
+  ])
+  VLC_RESTORE_FLAGS
 
   AC_CHECK_LIB(rt, clock_nanosleep, [
     VLC_ADD_LIBS([libvlccore],[-lrt])
@@ -689,18 +691,10 @@ if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
   ])
 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
 
-dnl Check for misc headers
-AC_MSG_CHECKING(for strncasecmp in strings.h)
-AC_EGREP_HEADER(strncasecmp,strings.h,[
-  AC_MSG_RESULT(yes)
-  AC_DEFINE(STRNCASECMP_IN_STRINGS_H, 1,
-            Define if <strings.h> defines strncasecmp.)],[
-  AC_MSG_RESULT(no)])
-
 dnl Check for headers
 AC_CHECK_HEADERS([search.h])
-AC_CHECK_HEADERS(getopt.h strings.h locale.h xlocale.h)
-AC_CHECK_HEADERS(fcntl.h sys/time.h sys/ioctl.h sys/stat.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])
 AC_CHECK_HEADERS([net/if.h], [], [],
   [
@@ -715,11 +709,11 @@ AC_CHECK_HEADERS([sys/mount.h], [], [],
 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; 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)
+  AC_CHECK_HEADERS(syslog.h mntent.h)
 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
 
 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.])
+AH_TEMPLATE(ssize_t, [Define to `int' if <stddef.h> does not define.]) dnl ` (fix VIM syntax highlight
 AC_CHECK_TYPE(ssize_t,, [
   AC_DEFINE(ssize_t, int)
 ])
@@ -826,18 +820,19 @@ fi
 esac
 
 dnl Check for ntohl, etc.
+VLC_SAVE_FLAGS
+CFLAGS="${CFLAGS} -Wall -Werror"
 AC_CACHE_CHECK([for ntohl in sys/param.h],
     [ac_cv_c_ntohl_sys_param_h],
-    [CFLAGS="${CFLAGS_save} -Wall -Werror"
-     AC_TRY_COMPILE([#include <sys/param.h>],
+    [     AC_TRY_COMPILE([#include <sys/param.h>],
         [int meuh; ntohl(meuh);],
         ac_cv_c_ntohl_sys_param_h=yes, ac_cv_c_ntohl_sys_param_h=no)])
 if test "${ac_cv_c_ntohl_sys_param_h}" != "no"; then
     AC_DEFINE(NTOHL_IN_SYS_PARAM_H, 1, Define if <sys/param.h> defines ntohl.)
 fi
+VLC_RESTORE_FLAGS
 
 EXTEND_HELP_STRING([Optimization options:])
-VLC_RESTORE_FLAGS
 dnl
 dnl  Compiler warnings
 dnl
@@ -899,25 +894,20 @@ AS_IF([test "${enable_coverage}" != "no"], [
   LDFLAGS="-lgcov ${LDFLAGS}"
 ])
 
-VLC_SAVE_FLAGS
-
 AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"], [
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -fvisibility=hidden"
+  CXXFLAGS="${CXXFLAGS} -fvisibility=hidden"
+  OBJCFLAGS="${OBJCFLAGS} -fvisibility=hidden"
   AC_CACHE_CHECK([if $CC accepts -fvisibility=hidden],
                  [ac_cv_c_visibility_hidden], [
-    CFLAGS="${CFLAGS_save} -fvisibility=hidden"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
       ac_cv_c_visibility_hidden=yes
     ], [
       ac_cv_c_visibility_hidden=no
     ])
   ])
-  AS_IF([test "${ac_cv_c_visibility_hidden}" != "no"], [
-    VLC_RESTORE_FLAGS
-    CFLAGS="${CFLAGS} -fvisibility=hidden"
-    CXXFLAGS="${CXXFLAGS} -fvisibility=hidden"
-    OBJCFLAGS="${OBJCFLAGS} -fvisibility=hidden"
-    VLC_SAVE_FLAGS
-  ])
+  AS_IF([test "${ac_cv_c_visibility_hidden}" = "no"], [VLC_RESTORE_FLAGS])
 ])
 
 
@@ -932,100 +922,93 @@ AC_ARG_ENABLE(optimizations,
 dnl Check for various optimization flags
 AS_IF([test "${enable_optimizations}" != "no"], [
 
-  C_O=""
   dnl -O4 and -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_save} -O4"
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
         ac_cv_c_o4=yes
       ], [
         ac_cv_c_o4=no
       ])
     ])
-    AS_IF([test "${ac_cv_c_o4}" != "no"], [
-      C_O="-O4"
-    ], [
+    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], [
-        CFLAGS="${CFLAGS_save} -O3"
         AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
           ac_cv_c_o3=yes
         ], [
           ac_cv_c_o3=no
         ])
       ])
-      AS_IF([test "${ac_cv_c_o3}" != "no"], [
-        C_O="-O3"
-      ])
+      AS_IF([test "${ac_cv_c_o3}" = "no"], [VLC_RESTORE_FLAGS])
     ])
   ])
 
-  VLC_RESTORE_FLAGS
-  CFLAGS="${CFLAGS} ${C_O}"
-  CXXFLAGS="${CXXFLAGS} ${C_O}"
-  OBJCFLAGS="${OBJCFLAGS} ${C_O}"
-  VLC_SAVE_FLAGS
-
   dnl Check for -ffast-math
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -ffast-math"
+  CXXFLAGS="${CXXFLAGS} -ffast-math"
+  OBJCFLAGS="${OBJCFLAGS} -ffast-math"
   AC_CACHE_CHECK([if $CC accepts -ffast-math], [ac_cv_c_fast_math], [
-    CFLAGS="${CFLAGS_save} -ffast-math"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
       ac_cv_c_fast_math=yes
     ], [
       ac_cv_c_fast_math=no
     ])
   ])
-  AS_IF([test "${ac_cv_c_fast_math}" != "no"], [
-    VLC_RESTORE_FLAGS
-    CFLAGS="${CFLAGS} -ffast-math"
-    CXXFLAGS="${CXXFLAGS} -ffast-math"
-    OBJCFLAGS="${OBJCFLAGS} -ffast-math"
-    VLC_SAVE_FLAGS
-  ])
+  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
+#endif
+])
 
   dnl Check for -funroll-loops
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -funroll-loops"
+  CXXFLAGS="${CXXFLAGS} -funroll-loops"
+  OBJCFLAGS="${OBJCFLAGS} -funroll-loops"
   AC_CACHE_CHECK([if $CC accepts -funroll-loops], [ac_cv_c_unroll_loops], [
-    CFLAGS="${CFLAGS_save} -funroll-loops"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
       ac_cv_c_unroll_loops=yes
     ], [
       ac_cv_c_unroll_loops=no
     ])
   ])
-  AS_IF([test "${ac_cv_c_unroll_loops}" != "no"], [
-    VLC_RESTORE_FLAGS
-    CFLAGS="${CFLAGS} -funroll-loops"
-    CXXFLAGS="${CXXFLAGS} -funroll-loops"
-    OBJCFLAGS="${OBJCFLAGS} -funroll-loops"
-    VLC_SAVE_FLAGS
-  ])
+  AS_IF([test "${ac_cv_c_unroll_loops}" = "no"], [VLC_RESTORE_FLAGS])
 
   AS_IF([test "$enable_debug" = "no"], [
     dnl Check for -fomit-frame-pointer
+    VLC_SAVE_FLAGS
+    CFLAGS="${CFLAGS} -fomit-frame-pointer"
+    CXXFLAGS="${CXXFLAGS} -fomit-frame-pointer"
+    OBJCFLAGS="${OBJCFLAGS} -fomit-frame-pointer"
     AC_CACHE_CHECK([if $CC accepts -fomit-frame-pointer],
       [ac_cv_c_omit_frame_pointer], [
-      CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
         ac_cv_c_omit_frame_pointer=yes
       ], [
         ac_cv_c_omit_frame_pointer=no
       ])
     ])
-    AS_IF([test "${ac_cv_c_omit_frame_pointer}" != "no"], [
-      VLC_RESTORE_FLAGS
-        CFLAGS="${CFLAGS} -fomit-frame-pointer"
-        CXXFLAGS="${CXXFLAGS} -fomit-frame-pointer"
-        OBJCFLAGS="${OBJCFLAGS} -fomit-frame-pointer"
-      VLC_SAVE_FLAGS
-    ])
+    AS_IF([test "${ac_cv_c_omit_frame_pointer}" = "no"], [VLC_RESTORE_FLAGS])
   ])
 ])
 
 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], [
-    CFLAGS="${CFLAGS_save} -bundle -undefined error"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
       ac_cv_ld_darwin=yes
     ], [
@@ -1035,19 +1018,21 @@ AS_IF([test "${SYS}" = "darwin"], [
   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"
 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
     [ac_cv_c_attribute_aligned],
     [ac_cv_c_attribute_aligned=0
-        CFLAGS="${CFLAGS_save} -Werror"
     for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
         AC_TRY_COMPILE([],
         [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
         [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
-    done
-        CFLAGS="${CFLAGS_save}"])
+    done])
+VLC_RESTORE_FLAGS
 if test "${ac_cv_c_attribute_aligned}" != "0"; then
     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
         [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
@@ -1122,9 +1107,9 @@ have_mmx="no"
 have_mmxext="no"
 AS_IF([test "${enable_mmx}" != "no"], [
   ARCH="${ARCH} mmx"
-
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -mmmx"
   AC_CACHE_CHECK([if $CC groks MMX intrinsics], [ac_cv_c_mmx_intrinsics], [
-    CFLAGS="${CFLAGS_save} -O -mmmx"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 [#include <mmintrin.h>
 #include <stdint.h>
@@ -1142,15 +1127,15 @@ frobzor = (uint64_t)a;]])], [
     ], [
       ac_cv_c_mmx_intrinsics=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_c_mmx_intrinsics}" != "no"], [
-    AC_DEFINE(HAVE_MMX_INTRINSICS, 1,
-              [Define to 1 if MMX intrinsics are available.])
+    AC_DEFINE(HAVE_MMX_INTRINSICS, 1, [Define to 1 if MMX intrinsics are available.])
   ])
 
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -mmmx"
   AC_CACHE_CHECK([if $CC groks MMX inline assembly], [ac_cv_mmx_inline], [
-    CFLAGS="${CFLAGS_save} -mmmx"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("packuswb %%mm1,%%mm2"::"r"(p):"mm1", "mm2");
@@ -1160,17 +1145,14 @@ asm volatile("packuswb %%mm1,%%mm2"::"r"(p):"mm1", "mm2");
     ], [
       ac_cv_mmx_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
   AS_IF([test "${ac_cv_mmx_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_MMX, 1,
-              [Define to 1 inline MMX assembly is available.])
+    AC_DEFINE(CAN_COMPILE_MMX, 1, [Define to 1 inline MMX assembly is available.])
     have_mmx="yes"
   ])
 
   AC_CACHE_CHECK([if $CC groks MMX EXT inline assembly],
                  [ac_cv_mmxext_inline], [
-    CFLAGS="${CFLAGS_save} -mmmx"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("maskmovq %%mm1,%%mm2"::"r"(p):"mm1", "mm2");
@@ -1180,11 +1162,10 @@ asm volatile("maskmovq %%mm1,%%mm2"::"r"(p):"mm1", "mm2");
     ], [
       ac_cv_mmxext_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_mmxext_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_MMXEXT, 1,
-              [Define to 1 if MMX EXT inline assembly is available.])
+    AC_DEFINE(CAN_COMPILE_MMXEXT, 1, [Define to 1 if MMX EXT inline assembly is available.])
     have_mmxext="yes"
   ])
 ])
@@ -1210,8 +1191,9 @@ have_sse2="no"
 AS_IF([test "${enable_sse}" != "no"], [
   ARCH="${ARCH} sse sse2"
 
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -msse2"
   AC_CACHE_CHECK([if $CC groks SSE2 intrinsics], [ac_cv_c_sse2_intrinsics], [
-    CFLAGS="${CFLAGS_save} -O -msse2"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 [#include <emmintrin.h>
 #include <stdint.h>
@@ -1229,15 +1211,15 @@ frobzor = (uint64_t)_mm_movepi64_pi64(a);]])], [
     ], [
       ac_cv_c_sse2_intrinsics=no
     ])
-    CFLAGS="${CFLAGS_save}"
-])
+  ])
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_c_sse2_intrinsics}" != "no"], [
-    AC_DEFINE(HAVE_SSE2_INTRINSICS, 1,
-              [Define to 1 if SSE2 intrinsics are available.])
+    AC_DEFINE(HAVE_SSE2_INTRINSICS, 1, [Define to 1 if SSE2 intrinsics are available.])
   ])
 
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -msse"
   AC_CACHE_CHECK([if $CC groks SSE inline assembly], [ac_cv_sse_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("xorps %%xmm1,%%xmm2"::"r"(p):"xmm1", "xmm2");
@@ -1247,15 +1229,13 @@ asm volatile("xorps %%xmm1,%%xmm2"::"r"(p):"xmm1", "xmm2");
     ], [
       ac_cv_sse_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+
   AS_IF([test "${ac_cv_sse_inline}" != "no" -a "${SYS}" != "solaris"], [
-    AC_DEFINE(CAN_COMPILE_SSE, 1,
-              [Define to 1 if SSE inline assembly is available.])
+    AC_DEFINE(CAN_COMPILE_SSE, 1, [Define to 1 if SSE inline assembly is available.])
   ])
 
   AC_CACHE_CHECK([if $CC groks SSE2 inline assembly], [ac_cv_sse2_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p):"xmm1", "xmm2");
@@ -1265,17 +1245,14 @@ asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p):"xmm1", "xmm2");
     ], [
       ac_cv_sse2_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
   AS_IF([test "${ac_cv_sse2_inline}" != "no" -a "${SYS}" != "solaris"], [
-    AC_DEFINE(CAN_COMPILE_SSE2, 1,
-              [Define to 1 if SSE2 inline assembly is available.])
+    AC_DEFINE(CAN_COMPILE_SSE2, 1, [Define to 1 if SSE2 inline assembly is available.])
     have_sse2="yes"
   ])
 
   # SSE3
   AC_CACHE_CHECK([if $CC groks SSE3 inline assembly], [ac_cv_sse3_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("movsldup %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
@@ -1285,14 +1262,12 @@ asm volatile("movsldup %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
     ], [
       ac_cv_sse3_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+
   AS_IF([test "${ac_cv_sse3_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_SSE3, 1,
-              [Define to 1 if SSE3 inline assembly is available.]) ])
+    AC_DEFINE(CAN_COMPILE_SSE3, 1, [Define to 1 if SSE3 inline assembly is available.]) ])
   # SSSE3
   AC_CACHE_CHECK([if $CC groks SSSE3 inline assembly], [ac_cv_ssse3_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("pabsw %%xmm0,%%xmm0"::"r"(p):"xmm0");
@@ -1302,16 +1277,14 @@ asm volatile("pabsw %%xmm0,%%xmm0"::"r"(p):"xmm0");
     ], [
       ac_cv_ssse3_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+
   AS_IF([test "${ac_cv_ssse3_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_SSSE3, 1,
-              [Define to 1 if SSSE3 inline assembly is available.]) ])
+    AC_DEFINE(CAN_COMPILE_SSSE3, 1, [Define to 1 if SSSE3 inline assembly is available.]) ])
 
   # SSE4.1
   AC_CACHE_CHECK([if $CC groks SSE4.1 inline assembly],
                  [ac_cv_sse4_1_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("pmaxsb %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
@@ -1321,16 +1294,14 @@ asm volatile("pmaxsb %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
     ], [
       ac_cv_sse4_1_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+
   AS_IF([test "${ac_cv_sse4_1_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_SSE4_1, 1,
-              [Define to 1 if SSE4_1 inline assembly is available.]) ])
+    AC_DEFINE(CAN_COMPILE_SSE4_1, 1, [Define to 1 if SSE4_1 inline assembly is available.]) ])
 
   # SSE4.2
   AC_CACHE_CHECK([if $CC groks SSE4.2 inline assembly],
                  [ac_cv_sse4_2_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("pcmpgtq %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
@@ -1340,15 +1311,13 @@ asm volatile("pcmpgtq %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
     ], [
       ac_cv_sse4_2_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+
   AS_IF([test "${ac_cv_sse4_2_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_SSE4_2, 1,
-              [Define to 1 if SSE4_2 inline assembly is available.]) ])
+    AC_DEFINE(CAN_COMPILE_SSE4_2, 1, [Define to 1 if SSE4_2 inline assembly is available.]) ])
 
   # SSE4A
   AC_CACHE_CHECK([if $CC groks SSE4A inline assembly], [ac_cv_sse4a_inline], [
-    CFLAGS="${CFLAGS_save} -msse"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("insertq %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
@@ -1358,17 +1327,17 @@ asm volatile("insertq %%xmm1,%%xmm0"::"r"(p):"xmm0", "xmm1");
     ], [
       ac_cv_sse4a_inline=no
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_sse4a_inline}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_SSE4A, 1,
-              [Define to 1 if SSE4A inline assembly is available.]) ])
+    AC_DEFINE(CAN_COMPILE_SSE4A, 1, [Define to 1 if SSE4A inline assembly is available.]) ])
 ])
 AM_CONDITIONAL([HAVE_SSE2], [test "$have_sse2" = "yes"])
 
+VLC_SAVE_FLAGS
+CFLAGS="${CFLAGS} -mmmx"
 have_3dnow="no"
 AC_CACHE_CHECK([if $CC groks 3D Now! inline assembly], [ac_cv_3dnow_inline], [
-  CFLAGS="${CFLAGS_save} -mmmx"
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
 void *p;
 asm volatile("pfadd %%mm1,%%mm2"::"r"(p):"mm1", "mm2");
@@ -1378,8 +1347,8 @@ asm volatile("pfadd %%mm1,%%mm2"::"r"(p):"mm1", "mm2");
   ], [
     ac_cv_3dnow_inline=no
   ])
-  CFLAGS="${CFLAGS_save}"
 ])
+VLC_RESTORE_FLAGS
 AS_IF([test "${ac_cv_3dnow_inline}" != "no"], [
   AC_DEFINE(CAN_COMPILE_3DNOW, 1,
             [Define to 1 if 3D Now! inline assembly is available.])
@@ -1394,8 +1363,9 @@ AC_ARG_ENABLE(neon,
   AS_IF([test "${host_cpu}" = "arm"], [enable_neon="yes"] ,[enable_neon="no"])
 ])
 AS_IF([test "${enable_neon}" != "no"], [
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -mfpu=neon"
   AC_CACHE_CHECK([if $CC groks NEON inline assembly], [ac_cv_neon_inline], [
-    CFLAGS="${CFLAGS_save} -mfpu=neon"
     AC_COMPILE_IFELSE([
       AC_LANG_PROGRAM(,[[
 asm volatile("vqmovun.s64 d0, q1":::"d0");
@@ -1406,12 +1376,11 @@ asm volatile("ssat r0, #1, r0":::"r0"); /* assume ARMv6 */
     ], [
       ac_cv_neon_inline="no"
     ])
-    CFLAGS="${CFLAGS_save}"
   ])
+  VLC_RESTORE_FLAGS
   AS_IF([test "$ac_cv_neon_inline" != "no"], [
     NEON_CFLAGS="$ac_cv_neon_inline"
-    AC_DEFINE([CAN_COMPILE_NEON], 1,
-      [Define to 1 if NEON (and ARMv6) assembly is available with NEON_CFLAGS.])
+    AC_DEFINE([CAN_COMPILE_NEON], 1, [Define to 1 if NEON (and ARMv6) assembly is available with NEON_CFLAGS.])
   ])
 ], [
   ac_cv_neon_inline="no"
@@ -1429,16 +1398,17 @@ AC_ARG_ENABLE(altivec,
 have_altivec="no"
 AS_IF([test "${enable_altivec}" = "yes"], [
   ARCH="${ARCH} altivec";
+  VLC_SAVE_FLAGS
   AC_CACHE_CHECK([if $CC groks AltiVec inline assembly],
     [ac_cv_altivec_inline],
-    [CFLAGS="${CFLAGS_save}"
-     AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
+    [AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
          ac_cv_altivec_inline="yes",
-         [CFLAGS="${CFLAGS_save} -Wa,-m7400"
+         [CFLAGS="${CFLAGS} -Wa,-m7400"
           AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
             [ac_cv_altivec_inline="-Wa,-m7400"],
             ac_cv_altivec_inline=no)
          ])])
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_altivec_inline}" != "no"], [
     AC_DEFINE(CAN_COMPILE_ALTIVEC, 1,
               [Define to 1 if AltiVec inline assembly is available.])
@@ -1460,32 +1430,33 @@ 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_save} -mpim-altivec -force_cpusubtype_ALL"
+   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_save} -faltivec"
+      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_save} -maltivec"
+         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_save} -maltivec -mabi=altivec"
+            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_save} -fvec"
+               CFLAGS="${CFLAGS} -fvec"
                AC_TRY_COMPILE([#include <altivec.h>],
                  [vec_ld(0, (unsigned char *)0);],
                  [ac_cv_c_altivec="-fvec"],
@@ -1494,29 +1465,24 @@ dnl - Others: test should fail
            ])
         ])
      ])
-   CFLAGS="${CFLAGS_save}"
   ])
-  AS_IF([test "${ac_cv_c_altivec}" != "no"], [
-    CPPFLAGS="${CPPFLAGS_save} ${ac_cv_c_altivec}"
-  ])
-
-  AC_CHECK_HEADERS(altivec.h)
-  CPPFLAGS="${CPPFLAGS_save}"
 
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_c_altivec}" != "no"], [
-    AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1,
-              [Define to 1 if C AltiVec extensions are available.])
+    CPPFLAGS="${CPPFLAGS} ${ac_cv_c_altivec}"
+    AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1, [Define to 1 if C AltiVec extensions are available.])
     VLC_ADD_CFLAGS([libvlccore],[${ac_cv_c_altivec}])
     VLC_ADD_CFLAGS([i420_yuy2_altivec memcpyaltivec deinterlace],[${ac_cv_c_altivec} ${ac_cv_c_altivec_abi}])
     have_altivec="yes"
   ])
+  AC_CHECK_HEADERS(altivec.h)
 
+  VLC_SAVE_FLAGS
+  LDFLAGS="${LDFLAGS} -Wl,-framework,vecLib"
   AC_CACHE_CHECK([if linker needs -framework vecLib],
     [ac_cv_ld_altivec],
-    [LDFLAGS="${LDFLAGS} -Wl,-framework,vecLib"
-     AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)
-     LDFLAGS="${LDFLAGS_save}"
-    ])
+    [AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)])
+  VLC_RESTORE_FLAGS
   AS_IF([test "${ac_cv_ld_altivec}" != "no"], [
     VLC_ADD_LIBS([libvlccore memcpyaltivec],[-Wl,-framework,vecLib])
   ])
@@ -1549,21 +1515,16 @@ fi
 
 dnl NOTE: this can't be cached cleanly
 AS_IF([test -n "${CFLAGS_TUNING}"], [
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} ${CFLAGS_TUNING}"
   AC_MSG_CHECKING([whether $CC accepts ${CFLAGS_TUNING}])
-  CFLAGS="${CFLAGS_save} ${CFLAGS_TUNING}"
   AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [
-    tuning="yes"
+    AC_MSG_RESULT([yes])
   ], [
-    CFLAGS_TUNING=""; tuning="no"
-    AS_IF([test "${with_tuning}"], [
-      AC_MSG_ERROR([requested tuning not supported])
-    ])
+    VLC_RESTORE_FLAGS
+    AC_MSG_RESULT([no])
+    AS_IF([test "${with_tuning}"], [AC_MSG_ERROR([requested tuning not supported])])
   ])
-  CFLAGS="${CFLAGS_save}"
-  AC_MSG_RESULT([$tuning])
-  VLC_RESTORE_FLAGS
-  CFLAGS="${CFLAGS} ${CFLAGS_TUNING}"
-  VLC_SAVE_FLAGS
 ])
 
 dnl
@@ -1703,7 +1664,7 @@ AC_ARG_ENABLE(live555,
     [enable RTSP input through live555 (default enabled)])])
 AS_IF([test "${enable_live555}" != "no" -a -n "${CXX}"], [
   AC_LANG_PUSH(C++)
-  CPPFLAGS_save="${CPPFLAGS}"
+  VLC_SAVE_FLAGS
   AS_IF([test -z "${CONTRIB_DIR}"], [
     CPPFLAGS_live555="-I/usr/include/liveMedia -I/usr/include/groupsock -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment"
   ], [
@@ -1714,10 +1675,10 @@ AS_IF([test "${enable_live555}" != "no" -a -n "${CXX}"], [
   ])
   CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_live555}"
 
-  AC_CACHE_CHECK([for live555 version 1275091200 or later], [ac_cv_live555], [
+  AC_CACHE_CHECK([for live555 version 1324598400 or later], [ac_cv_live555], [
     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
 [#include <liveMedia_version.hh>
-#if !defined (LIVEMEDIA_LIBRARY_VERSION_INT) || (LIVEMEDIA_LIBRARY_VERSION_INT < 1275091200)
+#if !defined (LIVEMEDIA_LIBRARY_VERSION_INT) || (LIVEMEDIA_LIBRARY_VERSION_INT < 1324598400)
 # error BOOM
 #endif]])
     ], [
@@ -1728,39 +1689,12 @@ AS_IF([test "${enable_live555}" != "no" -a -n "${CXX}"], [
   ])
   AS_IF([test "$ac_cv_live555" = "no"], [
     AC_MSG_WARN([liveMedia is missing or its installed version is too old:
-Version 2010.05.29 or later is required to proceed.
+Version 2011.12.23 or later is required to proceed.
 You can get an updated one from http://www.live555.com/liveMedia .])
     AS_IF([test -n "${enable_live555}"], [
       AC_MSG_ERROR([Update live555 or pass --disable-live555 to disable RTSP input support.])
     ])
-    ac_cv_live555_usable=""
   ], [
-    dnl Check that live555 is patched correctly.
-    AC_CACHE_CHECK([for live555 usability], [ac_cv_live555_usable], [
-      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
-[#include <locale.h>
-#ifdef __APPLE__
-# include <xlocale.h>
-#endif
-#undef LC_ALL
-#define LC_ALL BOOM
-#ifdef LC_ALL_MASK
-#include <Locale.hh>
-#endif
-#include <GroupsockHelper.hh>]], [
-[struct in_addr addr;
-our_inet_ntoa(addr, NULL);]])
-      ], [
-        ac_cv_live555_usable="yes"
-      ], [
-        ac_cv_live555_usable="no"
-      ])
-    ])
-    AS_IF([test "$ac_cv_live555_usable" = "no"], [
-      AC_MSG_ERROR([liveMedia lacks patches and is not usable.
-Please apply our patches from the VLC contrib (contrib/src/live555/).
-You can also disable RTSP input with --disable-live555. You were warned.])
-    ])
     other_libs="-lgroupsock -lBasicUsageEnvironment -lUsageEnvironment"
     other_libs_pic="-lgroupsock_pic -lBasicUsageEnvironment_pic -lUsageEnvironment_pic"
     AS_IF([test "${SYS}" = "mingw32"], [
@@ -1783,7 +1717,7 @@ You can also disable RTSP input with --disable-live555. You were warned.])
         VLC_ADD_LIBS([live555], [-lliveMedia ${other_libs}])
       ],[],[${other_libs}])],[${other_libs_pic}])
   ])
-  CPPFLAGS="${CPPFLAGS_save}"
+  VLC_RESTORE_FLAGS
   AC_LANG_POP(C++)
 ])
 
@@ -1808,15 +1742,6 @@ if test "$SYS" = "linux" -a "${enable_linsys}" != "no"; then
   )
 fi
 
-dnl libdvdcss
-darwin_libdvdcss_extralibs="-Wl,-framework,CoreFoundation -Wl,-framework,IOKit"
-libdvdcss_extralibs=""
-test "${SYS}" = darwin && libdvdcss_extralibs="${darwin_libdvdcss_extralibs}"
-AC_CHECK_LIB(dvdcss, dvdcss_interface_2, [
-    VLC_ADD_LIBS([dvdread], -ldvdcss "${libdvdcss_extralibs}")
-    VLC_ADD_LIBS([dvdnav], -ldvdcss "${libdvdcss_extralibs}")
-    ],, "${libdvdcss_extralibs}")
-
 dnl
 dnl dvdread module: check for libdvdread
 dnl
@@ -1857,7 +1782,7 @@ then
       AC_CHECK_HEADERS(dshow.h,
       [ VLC_ADD_PLUGIN([dshow])
         VLC_ADD_CXXFLAGS([dshow],[])
-        VLC_ADD_LIBS([dshow],[-lole32 -loleaut32 -luuid]) ])
+        VLC_ADD_LIBS([dshow],[-lole32 -loleaut32 -luuid -lstrmiids -lksuser])])
     AC_LANG_POP(C++)
   fi
 fi
@@ -1865,7 +1790,7 @@ fi
 dnl
 dnl  Blu-ray Disc Support with libbluray
 dnl
-PKG_ENABLE_MODULES_VLC([BLURAY], [libbluray], [libbluray >= 0.2 libxml-2.0 >= 2.6 ], (libbluray for Blu-ray disc support ) )
+PKG_ENABLE_MODULES_VLC([BLURAY], [libbluray], [libbluray >= 0.2.1], (libbluray for Blu-ray disc support ) )
 
 dnl
 dnl  OpenCV wrapper and example filters
@@ -1904,22 +1829,17 @@ fi
 dnl
 dnl  Video4Linux 2
 dnl
-AC_ARG_ENABLE(libv4l2, [AS_HELP_STRING([--disable-libv4l2],
-  [disable userspace V4L2 library (default auto)])])
+AC_ARG_ENABLE(v4l2, [AS_HELP_STRING([--disable-v4l2],
+  [disable Video4Linux version 2 (default auto)])])
 AC_ARG_ENABLE(pvr, [AS_HELP_STRING([--enable-pvr],
   [support PVR V4L2 cards (default disabled)])])
 have_v4l2="no"
-AC_CHECK_HEADERS([linux/videodev2.h sys/videoio.h], [
-  have_v4l2="yes"
+AS_IF([test "$enable_v4l2" != "no"], [
+  AC_CHECK_HEADERS([linux/videodev2.h sys/videoio.h], [
+    have_v4l2="yes"
+  ])
 ])
 AS_IF([test "$have_v4l2" = "yes"], [
-  AS_IF([test "${enable_libv4l2}" != "no"], [
-    PKG_CHECK_MODULES(LIBV4L2, libv4l2, [
-      AC_DEFINE(HAVE_LIBV4L2, 1, [Define to 1 if libv4l2 is available])
-    ], [
-      AC_MSG_WARN([${LIBV4L2_PKG_ERRORS}.])
-    ])
-  ])
   AS_IF([test "${enable_pvr}" = "yes"], [
     VLC_ADD_PLUGIN([pvr])
   ])
@@ -1941,13 +1861,14 @@ then
   then
     VLC_ADD_CPPFLAGS([decklink],[-I${with_decklink_sdk}/include])
   fi
-  CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_decklink}"
+  VLC_SAVE_FLAGS
+  CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_decklink}"
   AC_LANG_PUSH(C++)
   AC_CHECK_HEADERS(DeckLinkAPIDispatch.cpp, [
     VLC_ADD_PLUGIN([decklink])
   ],[AC_MSG_WARN(Blackmagic DeckLink SDI include files not found, decklink disabled)])
   AC_LANG_POP(C++)
-  CPPFLAGS="${CPPFLAGS_save}"
+  VLC_RESTORE_FLAGS
 fi
 
 
@@ -2041,17 +1962,21 @@ fi
 dnl
 dnl Linux DVB
 dnl
-AC_CACHE_CHECK([for Linux DVB version 5], [ac_cv_linux_s2api], [
+AC_CACHE_CHECK([for Linux DVB version 5.1], [ac_cv_linux_dvb_5_1], [
   AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
 [#include <linux/dvb/version.h>
 #if (DVB_API_VERSION < 5)
-EXPLODE
-#endif]])], [
-  ac_cv_linux_s2api=yes
+# error Linux DVB API v3.2 and older are not supported.
+#endif
+#if (DVB_API_VERSION == 5 && DVB_API_VERSION_MINOR < 1)
+# error Linux DVB API v5.0 is unsupported. Please update.
+#endif
+]])], [
+  ac_cv_linux_dvb_5_1=yes
 ], [
-  ac_cv_linux_s2api=no
+  ac_cv_linux_dvb_5_1=no
 ])])
-AM_CONDITIONAL([HAVE_LINUX_DVB], [test "$ac_cv_linux_s2api" = "yes"])
+AM_CONDITIONAL([HAVE_LINUX_DVB], [test "$ac_cv_linux_dvb_5_1" = "yes"])
 
 dnl
 dnl  Screen capture module
@@ -2070,8 +1995,6 @@ if test "${enable_screen}" != "no"; then
   elif test "${SYS}" = "mingw32"; then
     VLC_ADD_PLUGIN([screen])
     VLC_ADD_LIBS([screen],[-lgdi32])
-  elif test "${SYS}" = "mingwce"; then
-    CPPFLAGS="${CPPFLAGS_save}"
   fi
 fi
 
@@ -2313,18 +2236,7 @@ AC_ARG_ENABLE(iomx,
   [  --enable-iomx           iomx codec module (default disabled)])
 if test "${enable_iomx}" = "yes"
 then
-  CPPFLAGS_save="${CPPFLAGS}"
-  CPPFLAGS="${CPPFLAGS} -I${srcdir}/modules/codec/omxil" # For the OMX headers
-  AC_LANG_PUSH([C++])
-  AC_CHECK_HEADER(media/stagefright/OMXClient.h, [
-    VLC_ADD_PLUGIN([iomx])
-    VLC_ADD_CXXFLAGS([iomx], [-fno-exceptions -fno-rtti])
-    VLC_ADD_LIBS([iomx], [-lstagefright -lmedia -lutils -lbinder])
-  ], [
-    AC_MSG_ERROR("Could not find IOMX headers")
-  ])
-  AC_LANG_POP([C++])
-  CPPFLAGS="${CPPFLAGS_save}"
+  VLC_ADD_PLUGIN([iomx])
 fi
 
 dnl
@@ -2389,28 +2301,29 @@ then
       AC_MSG_RESULT(yes)
       VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${real_mad_tree}])
       VLC_ADD_LIBS([mpgatofixed32],[-L${real_mad_tree}/.libs])
-      LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
+      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 ])
       ],[])
-      LDFLAGS="${LDFLAGS_save}"
+      VLC_RESTORE_FLAGS
     else
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree does not have mad.h])
     fi
   else
-    CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_mpgatofixed32}"
-    LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
+    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.]) ])
     AC_CHECK_LIB(mad, mad_bit_init, [
       VLC_ADD_PLUGIN([mpgatofixed32])
       VLC_ADD_LIBS([mpgatofixed32],[-lmad])],
       [ AC_MSG_ERROR([Cannot find libmad library...]) ])
-    CPPFLAGS="${CPPFLAGS_save}"
-    LDFLAGS="${LDFLAGS_save}"
+    VLC_RESTORE_FLAGS
   fi
 fi
 
@@ -2421,12 +2334,12 @@ AC_ARG_ENABLE(merge-ffmpeg,
 ])
 AM_CONDITIONAL([MERGE_FFMPEG], [test "$enable_merge_ffmpeg" != "no"])
 
+VLC_SAVE_FLAGS
+LDFLAGS="${LDFLAGS} -Wl,-Bsymbolic"
 AC_CACHE_CHECK([if linker supports -Bsymbolic],
   [ac_cv_ld_bsymbolic],
-  [LDFLAGS="${LDFLAGS} -Wl,-Bsymbolic"
-    AC_TRY_LINK([],,ac_cv_ld_bsymbolic=yes,ac_cv_ld_bsymbolic=no)
-    LDFLAGS="${LDFLAGS_save}"
-  ])
+  [AC_TRY_LINK([],,ac_cv_ld_bsymbolic=yes,ac_cv_ld_bsymbolic=no)])
+VLC_RESTORE_FLAGS
 
 dnl
 dnl  avcodec decoder/encoder plugin
@@ -2511,7 +2424,9 @@ AS_IF([test "${enable_dxva2}" != "no"], [
     AS_IF([test "${enable_dxva2}" = "yes"],
           [AC_MSG_ERROR([dxva2 is present but libavcodec/dxva2.h is missing])],
               [AC_MSG_WARN([dxva2 is present but libavcodec/dxva2.h is missing ])])
-        ])
+        ], [#undef _WIN32_WINNT
+            /* DXVA2 is only available in Vista and above */
+            #define _WIN32_WINNT 0x600])
       ],[
     AS_IF([test "${enable_dxva2}" = "yes"],
               [AC_MSG_ERROR([Could not find required dxva2api.h])],
@@ -2657,8 +2572,9 @@ then
       AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
     fi
   else
-    CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_faad}"
-    LDFLAGS="${LDFLAGS_save} ${LIBS_faad}"
+    VLC_SAVE_FLAGS
+    CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_faad}"
+    LDFLAGS="${LDFLAGS} ${LIBS_faad}"
     AC_CHECK_HEADERS(faad.h, ,
       [ AC_MSG_ERROR([Cannot find development headers for libfaad...]) ])
     AC_CHECK_LIB(faad, faacDecOpen, [
@@ -2668,8 +2584,7 @@ then
         VLC_ADD_PLUGIN([faad])
         VLC_ADD_LIBS([faad],[-lfaad]) ],
         [ AC_MSG_ERROR([Cannot find libfaad library...]) ]))
-    LDFLAGS="${LDFLAGS_save}"
-    CPPFLAGS="${CPPFLAGS_save}"
+    VLC_RESTORE_FLAGS
   fi
 fi
 
@@ -2694,15 +2609,6 @@ if test "${enable_quicktime}" = "yes"; then
   fi
 fi
 
-dnl
-dnl  Real plugin
-dnl
-AC_ARG_ENABLE(real,
-  [  --enable-real           Real video decoder module (default disabled)])
-if test "${enable_real}" = "yes"; then
-  VLC_ADD_PLUGIN([realvideo])
-fi
-
 dnl
 dnl A52/AC3 decoder plugin
 dnl
@@ -2730,7 +2636,8 @@ then
       AC_MSG_RESULT(yes)
       VLC_ADD_CPPFLAGS([a52tofloat32],[-I${real_a52_tree}])
       VLC_ADD_LIBS([a52tofloat32],[-L${real_a52_tree}/liba52/.libs])
-      LDFLAGS="${LDFLAGS_save} ${LIBS_a52tofloat32}"
+      VLC_SAVE_FLAGS
+      LDFLAGS="${LDFLAGS} ${LIBS_a52tofloat32}"
       AC_CHECK_LIB(a52, a52_free, [
         VLC_ADD_PLUGIN([a52tofloat32])
         VLC_ADD_CPPFLAGS([a52tofloat32],[-DUSE_A52DEC_TREE])
@@ -2743,7 +2650,6 @@ then
           AC_MSG_ERROR([the specified tree has not been compiled])
         fi
       ])
-      LDFLAGS="${LDFLAGS_save}"
     else
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree does not have a52.h])
@@ -2757,8 +2663,9 @@ then
       LDFLAGS_test="-L${with_a52}/lib"
       CPPFLAGS_test="-I${with_a52}/include"
     fi
-    CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test} ${CPPFLAGS_a52tofloat32}"
-    LDFLAGS="${LDFLAGS_save} ${LDFLAGS_test} ${LIBS_a52tofloat32}"
+    VLC_SAVE_FLAGS
+    CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_test} ${CPPFLAGS_a52tofloat32}"
+    LDFLAGS="${LDFLAGS} ${LDFLAGS_test} ${LIBS_a52tofloat32}"
     AC_CHECK_HEADERS(a52dec/a52.h, [
       AC_CHECK_LIB(a52, a52_free, [
         VLC_ADD_PLUGIN([a52tofloat32])
@@ -2770,8 +2677,7 @@ 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.])
     ])
-    CPPFLAGS="${CPPFLAGS_save}"
-    LDFLAGS="${LDFLAGS_save}"
+    VLC_RESTORE_FLAGS
   fi
 fi
 
@@ -2822,11 +2728,7 @@ AS_IF([test "${enable_speex}" != "no"], [
   PKG_CHECK_MODULES([SPEEXDSP], [speexdsp], [
     have_speexdsp="yes"
   ], [
-    AS_IF([test -n "${enable_speex}"], [
-      AC_MSG_ERROR([${SPEEXDSP_PKG_ERRORS}.])
-    ], [
-      AC_MSG_WARN([${SPEEXDSP_PKG_ERRORS}.])
-    ])
+    AC_MSG_WARN([${SPEEXDSP_PKG_ERRORS}.])
   ])
 ])
 AM_CONDITIONAL([HAVE_SPEEXDSP], [test "$have_speexdsp" = "yes"])
@@ -2834,7 +2736,7 @@ AM_CONDITIONAL([HAVE_SPEEXDSP], [test "$have_speexdsp" = "yes"])
 dnl
 dnl  theora decoder plugin
 dnl
-PKG_ENABLE_MODULES_VLC([THEORA], [], [ogg theora >= 1.0], [experimental theora codec], [auto])
+PKG_ENABLE_MODULES_VLC([THEORA], [], [ogg theoradec >= 1.0 theoraenc], [experimental theora codec], [auto])
 
 dnl
 dnl  dirac encoder plugin
@@ -2853,16 +2755,71 @@ AC_ARG_ENABLE(png,
   [  --enable-png            PNG support (default enabled)])
 if test "${enable_png}" != "no"; then
 AC_CHECK_HEADERS(png.h, [
-  LDFLAGS="${LDFLAGS_save} -lz"
+  VLC_SAVE_FLAGS
+  LDFLAGS="${LDFLAGS} -lz $LIBM"
   AC_CHECK_LIB(png, png_set_rows, [
-    VLC_ADD_LIBS([png],[-lpng -lz -lm])
+    VLC_ADD_LIBS([png],[-lpng -lz $LIBM])
     VLC_ADD_PLUGIN([png osdmenu osd_parser])],
-    [],[-lz])
-    LDFLAGS="${LDFLAGS_save}"
+    [],[-lz $LIBM] )
+  VLC_RESTORE_FLAGS
   ])
 fi
 AM_CONDITIONAL(BUILD_OSDMENU, [test "${enable_png}" != "no"])
 
+dnl
+dnl H264 encoder plugin (10-bit lib264)
+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_LDFLAGS([x26410b],[${X26410B_LIBS}])
+        AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
+          VLC_ADD_LIBS([x26410b],[-Wl,-Bsymbolic])
+        ])
+        VLC_ADD_CFLAGS([x26410b],[${X26410B_CFLAGS}])
+        if echo ${X26410B_LIBS} |grep -q 'pthreadGC2'; then
+          VLC_ADD_CFLAGS([x26410b], [-DPTW32_STATIC_LIB])
+        fi
+    ], [
+       if test "${enable_x26410b}" = "yes"; then
+        AC_MSG_ERROR([x26410b module doesn't work without staticly compiled libx264.a])
+       fi
+    ])
+  fi
+fi
+
+
 dnl
 dnl H264 encoder plugin (using libx264)
 dnl
@@ -2897,7 +2854,6 @@ if test "${enable_x264}" != "no"; then
       ],[
         AC_MSG_ERROR([the specified tree has not been compiled])
       ])
-      LDFLAGS="${LDFLAGS_save}"
     else
       AC_MSG_RESULT(no)
       AC_MSG_ERROR([the specified tree does not have x264.h])
@@ -2920,14 +2876,13 @@ if test "${enable_x264}" != "no"; then
             AC_MSG_ERROR([${X264_PKG_ERRORS}: you may get it from http://www.videolan.org/x264.html])
           fi
       ])
-    LDFLAGS="${LDFLAGS_save}"
   fi
 fi
 
 dnl
 dnl libfluidsynth (MIDI synthetizer) plugin
 dnl
-PKG_ENABLE_MODULES_VLC([FLUIDSYNTH], [], [fluidsynth], [MIDI synthetiser with libfluidsynth], [auto])
+PKG_ENABLE_MODULES_VLC([FLUIDSYNTH], [], [fluidsynth >= 1.1.2], [MIDI synthetiser with libfluidsynth], [auto])
 
 dnl
 dnl Teletext Modules
@@ -3107,11 +3062,7 @@ AS_IF([test "${enable_xcb}" != "no"], [
     AS_IF([test "${have_gl}" != "yes"], [
       AC_MSG_ERROR([${GL_PKG_ERRORS}. Pass --disable-glx if you do not need OpenGL X11 support.])
     ])
-    PKG_CHECK_MODULES(XLIB_XCB, [x11-xcb], [
-      VLC_ADD_PLUGIN([xcb_glx])
-    ], [
-      AC_MSG_ERROR([${XLIB_XCB_PKG_ERRORS}. Pass --disable-glx if you do not need OpenGL X11 support.])
-    ])
+    VLC_ADD_PLUGIN([xcb_glx])
   ])
 ])
 AM_CONDITIONAL([HAVE_XCB], [test "${have_xcb}" = "yes"])
@@ -3292,7 +3243,7 @@ if test "${enable_directx}" != "no"; then
       [ VLC_ADD_PLUGIN([direct3d])
         VLC_ADD_LIBS([direct3d],[-lgdi32])
       ])
-      VLC_ADD_LIBS([direct3d directx glwin32],[-lole32])
+      VLC_ADD_LIBS([direct3d directx glwin32],[-lole32 -luuid])
   fi
 fi
 
@@ -3308,7 +3259,7 @@ AC_ARG_ENABLE(direct2d,
 AS_IF([test "${enable_direct2d}" != "no"], [
   AC_CHECK_HEADERS(d2d1.h, [
     VLC_ADD_PLUGIN([direct2d])
-    VLC_ADD_LIBS([direct2d],[-lgdi32 -lole32])
+    VLC_ADD_LIBS([direct2d],[-lgdi32 -lole32 -luuid])
   ], [
     AC_MSG_WARN([Cannot find Direct2D headers!])
   ])
@@ -3322,7 +3273,7 @@ AC_ARG_ENABLE(wingdi,
 if test "${enable_wingdi}" != "no"; then
   if test "${SYS}" = "mingw32"; then
     VLC_ADD_PLUGIN([wingdi])
-    VLC_ADD_LIBS([wingdi],[-lgdi32 -lole32])
+    VLC_ADD_LIBS([wingdi],[-lgdi32 -lole32 -luuid])
   fi
   if test "${SYS}" = "mingwce"; then
     VLC_ADD_PLUGIN([wingdi wingapi])
@@ -3356,12 +3307,10 @@ if test "${enable_directfb}" = "yes"; then
     LIBS_mydirectfb=
     if test "${with_directfb}" != "no" -a -n "${with_directfb}"; then
         dnl Trying the given location
-        CPPFLAGS_save="${CPPFLAGS}"
-        LIBS_save="${LIBS}"
+        VLC_SAVE_FLAGS
 
         CPPFLAGS_new="-I${with_directfb}/include -D_REENTRANT -D_GNU_SOURCE"
-        LIBS_new="-L${with_directfb}/lib/fusion/.libs/ -L${with_directfb}/lib/direct/.libs/"
-        LIBS_new="${LIBS_new} -L${with_directfb}/src/.libs/"
+        LIBS_new="-L${with_directfb}/lib/fusion/.libs/ -L${with_directfb}/lib/direct/.libs/ -L${with_directfb}/src/.libs/"
 
         CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_new}"
         LIBS="${LIBS} ${LIBS_new}"
@@ -3375,9 +3324,7 @@ if test "${enable_directfb}" = "yes"; then
             ], have_directfb="false")
         ], have_directfb="false")
 
-        dnl Restore flags
-        CPPFLAGS="${CPPFLAGS_save}"
-        LIBS="${LIBS_save}"
+        VLC_RESTORE_FLAGS
 
         if test "${have_directfb}" = "true"; then
             LIBS_mydirectfb="${LIBS_new} -lz $LIBDL -ldirectfb -lfusion -ldirect -lpthread"
@@ -3517,8 +3464,8 @@ dnl  Open Sound System module
 dnl
 AC_ARG_ENABLE(oss,
   [AS_HELP_STRING([--enable-oss],
-    [support the Open Sound System OSS (default enabled on BSD)])],, [
-  AS_IF([test "$SYS" = "mingw32" -o "$SYS" = "mingwce" -o "$SYS" = "linux"], [
+    [support the Open Sound System OSS (default enabled on FreeBSD/NetBSD/DragonFlyBSD)])],, [
+  AS_IF([test "$SYS" = "mingw32" -o "$SYS" = "mingwce" -o "$SYS" = "linux" -o "$SYS" = "openbsd"], [
     enable_oss="no"
   ])
 ])
@@ -3536,9 +3483,22 @@ AC_SUBST(OSS_LIBS)
 AM_CONDITIONAL([HAVE_OSS], [test "${have_oss}" = "yes"])
 
 dnl
-dnl  Portaudio module
+dnl  OpenBSD sndio module
 dnl
-PKG_ENABLE_MODULES_VLC([PORTAUDIO], [], [portaudio-2.0], [Portaudio library support], [auto])
+AC_ARG_ENABLE([sndio],
+  [AS_HELP_STRING([--disable-sndio],
+    [support the OpenBSD sndio (default auto)])],, [
+  AS_IF([test "$SYS" = "opensd"], [
+    enable_sndio="yes"
+  ])
+])
+have_sndio="no"
+AS_IF([test "$enable_sndio" != "no"], [
+  AC_CHECK_HEADER([sndio.h], [
+    have_sndio="yes"
+  ])
+])
+AM_CONDITIONAL([HAVE_SNDIO], [test "${have_sndio}" = "yes"])
 
 dnl
 dnl  win32 waveOut plugin
@@ -3632,58 +3592,6 @@ dnl
 
 EXTEND_HELP_STRING([Interface plugins:])
 
-dnl
-dnl Skins2 module
-dnl
-AC_ARG_ENABLE(skins2,
-  [AS_HELP_STRING([--enable-skins2], [skins interface module (default auto)])])
-AS_IF([test "${enable_skins2}" != "no"], [
-  have_skins_deps="yes"
-  AS_IF([test "${SYS}" = "mingw32"], [
-    VLC_ADD_CPPFLAGS([skins2],[-U_OFF_T_ -U_off_t -Imodules/gui/skins2 -DWIN32_SKINS])
-    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
-    VLC_ADD_LIBS([skins2],[-lgdi32 -lole32 -luuid -lmsimg32])
-
-  ], [test "${SYS}" = "darwin"], [
-    VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 -DMACOSX_SKINS])
-    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
-    VLC_ADD_LIBS([skins2],[-Wl,-framework,Carbon])
-
-  ], [
-    PKG_CHECK_MODULES([XPM], [xpm],, [have_skins_deps="no"])
-    PKG_CHECK_MODULES([XINERAMA], [xinerama],, [have_skins_deps="no"])
-    PKG_CHECK_MODULES([XEXT], [xext],, [have_skins_deps="no"])
-    VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 ${X_CFLAGS} ${XEXT_CFLAGS} ${XPM_CFLAGS} -DX11_SKINS])
-    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
-    VLC_ADD_LIBS([skins2],[${X_LIBS} ${X_PRE_LIBS} ${XEXT_LIBS} ${XPM_LIBS} ${XINERAMA_LIBS} -lX11])
-
-  ])
-  AS_IF([test "${have_freetype}" != "yes"], [
-    have_skins_deps="no"
-  ])
-
-  AS_IF([test "${have_skins_deps}" = "no"], [
-    AS_IF([test "x${enable_skins2}" = "x"], [
-      AC_MSG_WARN([Skins2 interface disabled due to missing dependencies.])
-    ], [
-      AC_MSG_ERROR([Skins2 interface requires FreeType, libxpm, libxext and libxinerama])
-    ])
-    enable_skins2="no"
-  ], [
-    VLC_ADD_PLUGIN([skins2])
-    ALIASES="${ALIASES} svlc"
-  ])
-])
-AM_CONDITIONAL(BUILD_SKINS, [test "${enable_skins2}" = "yes"])
-
-AC_ARG_ENABLE(libtar,
-  [  --enable-libtar         libtar support for skins2 (default auto)])
-AS_IF([test "${enable_skins2}" = "yes" && test "${enable_libtar}" != "no"], [
-  AC_CHECK_HEADERS(libtar.h, [
-    VLC_ADD_LIBS([skins2],[-ltar])
-  ])
-])
-
 dnl
 dnl Hildon UI
 dnl
@@ -3725,7 +3633,7 @@ AS_IF([test "${enable_qt4}" != "no"], [
     ALIASES="${ALIASES} qvlc"
 
     AC_LANG_PUSH([C++])
-    CPPFLAGS_save="${CPPFLAGS}"
+    VLC_SAVE_FLAGS
 
     AC_MSG_CHECKING([whether Qt uses X11])
     CPPFLAGS="${CPPFLAGS} ${QT4_CFLAGS}"
@@ -3742,7 +3650,7 @@ AS_IF([test "${enable_qt4}" != "no"], [
       AC_MSG_RESULT([no])
     ])
 
-    CPPFLAGS="${CPPFLAGS_save}"
+    VLC_RESTORE_FLAGS
     AC_LANG_POP([C++])
 
     AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
@@ -3768,8 +3676,69 @@ AM_CONDITIONAL(ENABLE_QT4, [test "x$enable_qt4" != "xno"])
 dnl
 dnl Simple test for skins2 dependency
 dnl
-AS_IF([test "${enable_skins2}" != "no" && test "x$enable_qt4" = "xno"], [
-  AC_MSG_ERROR([The skins2 module depends on a the Qt4 development package. Without it you will not be able to open any dialog box from the interface, which makes the skins2 interface rather useless. Install the Qt4 development package or alternatively you can also configure with: --disable-qt4 --disable-skins2.])
+AS_IF([test "x$enable_qt4" = "xno"], [
+  AS_IF([test "${enable_skins2}" = "yes"], [
+    AC_MSG_ERROR([The skins2 module depends on the Qt4 interface. Without it you will not be able to open any dialog box from the interface, which makes the skins2 interface rather useless. Install the Qt4 development package or alternatively you can also configure with: --disable-qt4 --disable-skins2.])
+  ], [
+    enable_skins2="no"
+    AC_MSG_WARN([The skins2 module depends on the Qt4 interface, Qt4 is not built so skins2 is disabled.])
+  ])
+])
+
+dnl
+dnl Skins2 module
+dnl
+AC_ARG_ENABLE(skins2,
+  [AS_HELP_STRING([--enable-skins2], [skins interface module (default auto)])])
+AS_IF([test "${enable_skins2}" != "no"], [
+  have_skins_deps="yes"
+
+  dnl Win32
+  AS_IF([test "${SYS}" = "mingw32"], [
+    VLC_ADD_CPPFLAGS([skins2],[-U_OFF_T_ -U_off_t -Imodules/gui/skins2 -DWIN32_SKINS])
+    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
+    VLC_ADD_LIBS([skins2],[-lgdi32 -lole32 -luuid -lmsimg32])
+  dnl MacOS
+  ], [test "${SYS}" = "darwin"], [
+    VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 -DMACOSX_SKINS])
+    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
+    VLC_ADD_LIBS([skins2],[-Wl,-framework,Carbon])
+  dnl Linux/Unix
+  ], [
+    PKG_CHECK_MODULES([XPM], [xpm],, [have_skins_deps="no"])
+    PKG_CHECK_MODULES([XINERAMA], [xinerama],, [have_skins_deps="no"])
+    PKG_CHECK_MODULES([XEXT], [xext],, [have_skins_deps="no"])
+    VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 ${X_CFLAGS} ${XEXT_CFLAGS} ${XPM_CFLAGS} -DX11_SKINS])
+    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
+    VLC_ADD_LIBS([skins2],[${X_LIBS} ${X_PRE_LIBS} ${XEXT_LIBS} ${XPM_LIBS} ${XINERAMA_LIBS} -lX11])
+  ])
+
+  dnl we need freetype
+  AS_IF([test "${have_freetype}" != "yes"], [
+    have_skins_deps="no"
+  ])
+
+  AS_IF([test "${have_skins_deps}" = "no"], [
+    AS_IF([test "x${enable_skins2}" = "x"], [
+      AC_MSG_WARN([Skins2 interface disabled due to missing dependencies.])
+    ], [
+      AC_MSG_ERROR([Skins2 interface requires FreeType, libxpm, libxext and libxinerama])
+    ])
+    enable_skins2="no"
+  ], [
+    VLC_ADD_PLUGIN([skins2])
+    ALIASES="${ALIASES} svlc"
+    enable_skins2="yes"
+  ])
+])
+AM_CONDITIONAL(BUILD_SKINS, [test "${enable_skins2}" = "yes"])
+
+AC_ARG_ENABLE(libtar,
+  [  --enable-libtar         libtar support for skins2 (default auto)])
+AS_IF([test "${enable_skins2}" = "yes" && test "${enable_libtar}" != "no"], [
+  AC_CHECK_HEADERS(libtar.h, [
+    VLC_ADD_LIBS([skins2],[-ltar])
+  ])
 ])
 
 dnl
@@ -3785,12 +3754,14 @@ then
 
   VLC_ADD_LIBS([macosx], [-Wl,-framework,QTKit -Wl,-framework,IOKit -Wl,-framework,AddressBook -Wl,-framework,WebKit])
 
-  CFLAGS="-I${CONTRIB_DIR}/Sparkle.framework/Headers ${CFLAGS_saved}"
-  AC_CHECK_HEADERS(Sparkle.h, [
-    VLC_ADD_LIBS([macosx], [-F${CONTRIB_DIR} -Wl,-framework,Sparkle])
-    VLC_ADD_OBJCFLAGS([macosx], [-F${CONTRIB_DIR}])
-  ])
-  if ! test -d ${CONTRIB_DIR}/BGHUDAppKit.framework
+  if test ! -d ${CONTRIB_DIR}/Sparkle.framework
+  then
+    AC_MSG_ERROR([Sparkle framework is required and was not found in ${CONTRIB_DIR}])
+  fi
+  VLC_ADD_LIBS([macosx], [-F${CONTRIB_DIR} -Wl,-framework,Sparkle])
+  VLC_ADD_OBJCFLAGS([macosx], [-F${CONTRIB_DIR}])
+
+  if test ! -d ${CONTRIB_DIR}/BGHUDAppKit.framework
   then
     AC_MSG_ERROR([BGHUDAppKit framework is required and was not found in ${CONTRIB_DIR}])
   fi
@@ -3815,31 +3786,27 @@ dnl
 dnl  ncurses module
 dnl
 AC_ARG_ENABLE(ncurses,
-  [  --disable-ncurses       ncurses interface support (default disabled)],
-  [if test "${enable_ncurses}" != "no"; then
-    AC_CHECK_HEADER(ncurses.h,
-      [AC_CHECK_LIB(ncursesw, mvprintw,
-        [VLC_ADD_PLUGIN([ncurses])
-        VLC_ADD_LIBS([ncurses],[-lncursesw])
+[AS_HELP_STRING([--disable-ncurses],[ncurses text-based interface (default auto)])])
+if test "${enable_ncurses}" != "no"; then
+  VLC_SAVE_FLAGS
+  LIBS=""
+  AC_CHECK_HEADER(ncurses.h, [
+    AC_CHECK_LIB(ncursesw, mvprintw, [
+      AC_SEARCH_LIBS([tgetent], [ncursesw tinfow tinfo], [
+        VLC_ADD_PLUGIN([ncurses])
         ALIASES="${ALIASES} nvlc"
-        AC_CHECK_LIB(ncursesw, tgetent, [],
-          AC_CHECK_LIB(tinfow, tgetent, [VLC_ADD_LIBS([ncurses],[-ltinfow])],
-            [AC_CHECK_LIB(tinfo, tgetent, [VLC_ADD_LIBS([ncurses],[-ltinfo])],
-              [AS_IF([test "${enable_ncurses}" = "yes"],
-                [AC_MSG_ERROR([tgetent not found in ncursesw tinfow tinfo]
-               )])])
-            ]
-          )
-        )
-        ],
-          [AS_IF([test "${enable_ncurses}" = "yes"], [
-            AC_MSG_ERROR([libncursesw not found])])]
-        )],
-        [AS_IF([test "${enable_ncurses}" = "yes"], [
-          AC_MSG_ERROR([ncurses.h not found])])]
-        )
-  fi]
-)
+        VLC_ADD_LIBS([ncurses],[-lncursesw ${LIBS}])
+      ], [
+        AS_IF([test "${enable_ncurses}" = "yes"], [AC_MSG_ERROR([tgetent not found])])
+      ])
+    ], [
+      AS_IF([test "${enable_ncurses}" = "yes"], [AC_MSG_ERROR([libncursesw not found])])
+    ])
+  ], [
+    AS_IF([test "${enable_ncurses}" = "yes"], [AC_MSG_ERROR([ncurses.h not found])])
+  ])
+  VLC_RESTORE_FLAGS
+fi
 
 dnl
 dnl  XOSD plugin
@@ -3850,8 +3817,13 @@ if test "${enable_xosd}" = "yes"
 then
   AC_CHECK_HEADERS(xosd.h,
     AC_CHECK_LIB(xosd, xosd_set_horizontal_offset, [
-      VLC_ADD_PLUGIN([xosd])
-      VLC_ADD_LIBS([xosd],[-lxosd])
+      AS_IF([test "${no_x}" != "yes"], [
+          VLC_ADD_PLUGIN([xosd])
+          VLC_ADD_LIBS([xosd],[-lxosd ${X_LIBS} ${X_PRE_LIBS} -lX11])
+          VLC_ADD_CFLAGS([xosd],[${X_CFLAGS}])
+        ],[
+          AC_MSG_ERROR([Xlib is required with xosd.])
+        ])
     ])
   )
 fi
@@ -4125,7 +4097,7 @@ AC_ARG_WITH(kde-solid,
   AS_HELP_STRING([--with-kde-solid=PATH],
                  [KDE Solid actions directory (auto)]),, [
 
-if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" ; then
+if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" -a "${SYS}" != "darwin" ; then
   with_kde_solid="yes"
 fi
 ])
@@ -4152,9 +4124,8 @@ AC_ARG_ENABLE(loader,
 AM_CONDITIONAL(LOADER, [test "${enable_loader}" = "yes"])
 AS_IF([test "${enable_loader}" = "yes"],
   [ VLC_ADD_PLUGIN([dmo])
-    VLC_ADD_CPPFLAGS([dmo quicktime realvideo],[-I\\\${top_srcdir}/modules/codec/loader])
-    VLC_ADD_LIBS([dmo quicktime realvideo],[\\\${top_builddir}/modules/codec/loader/libloader.la])
-    VLC_ADD_CPPFLAGS([realvideo], [-DLOADER])
+    VLC_ADD_CPPFLAGS([dmo quicktime ],[-I\\\${top_srcdir}/modules/codec/loader])
+    VLC_ADD_LIBS([dmo quicktime ],[\\\${top_builddir}/modules/codec/loader/libloader.la])
     VLC_ADD_LIBS([dmo quicktime], [-lpthread])
   ])
 
@@ -4199,17 +4170,7 @@ AC_DEFINE_UNQUOTED(VLC_COMPILER, "`$CC -v 2>&1 | tail -n 1`", [compiler])
 dnl
 dnl  Handle substvars that use $(top_srcdir)
 dnl
-CPPFLAGS_save="-I\$(top_srcdir)/include -I\$(top_builddir)/include ${CPPFLAGS_save}"
-
-dnl
-dnl  Restore *FLAGS
-dnl
-VLC_RESTORE_FLAGS
-
-dnl
-dnl Sort the modules list
-dnl
-PLUGINS=$( (for i in `echo $PLUGINS`; do echo $i; done)|sort|xargs )
+CPPFLAGS="-I\$(top_srcdir)/include -I\$(top_builddir)/include ${CPPFLAGS}"
 
 dnl
 dnl  Configuration is finished
@@ -4333,21 +4294,27 @@ dnl Generate makefiles
 AC_OUTPUT
 
 dnl Do we have to use make or gmake ?
-USE_MAKE_OR_GMAKE=`case "${SYS}" in openbsd*) echo "gmake";; *) echo "make";; esac`
+if make --version 2>&1|grep -q GNU
+then
+    # GNU make, all seems good
+    MAKE=make
+else
+    # Known GNU make alias (on BSD)
+    MAKE=gmake
+fi
 dnl Shortcut to nice compile message
-rm -f compile
 if test -n $SHELL; then
   SHELL=${CONFIG_SHELL-/bin/sh}
 fi
-echo '#! '$SHELL >compile
-echo rm -f .error\$\$ >>compile
-echo ERROR=0 >>compile
-echo export PATH=$PATH LANG=C >>compile
-echo "($USE_MAKE_OR_GMAKE V=1 \$@ 2>&1 || touch .error\$\$)| \\" >>compile
-echo '`sed -ne "s/^top_srcdir *= *//p" < Makefile`/extras/buildsystem/make.pl' >>compile
-echo test -f .error\$\$ \&\& ERROR=1 >>compile
-echo rm -f .error\$\$ >>compile
-echo exit \$ERROR >>compile
+rm -f compile
+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
+test -f .error\$\$ && ERROR=1
+rm -f .error\$\$
+exit \$ERROR" >compile
 chmod a+x compile
 
 echo "
@@ -4363,4 +4330,4 @@ else
 echo "build vlc executable  : no"
 fi
 echo "
-To build vlc and its plugins, type \`./compile' or \`$USE_MAKE_OR_GMAKE'."
+To build vlc and its plugins, type \`$MAKE', or \`./compile' if you like nice colors."